def on_map_request(self, e): ev = e.xmaprequest wa = xlib.XWindowAttributes() log.debug('on_map_request %s' % ev.window) if not xlib.XGetWindowAttributes(e.xany.display, ev.window, byref(wa)): log.debug('couldnt get XGetWindowAttributes') return if wa.override_redirect: return # check we dont already have a client instance for this window client = Client.get_by_window(ev.window) if client is None: # it could be a frame window we've created... client = Client.get_by_frame(ev.window) if client is None: for screen in self.screens: if (addressof(wa.screen.contents) == addressof(xlib.XScreenOfDisplay(e.xany.display, screen.num).contents)): screen.manage(ev.window, wa) return assert(screen is not None, "looking for screen %s(%s) failed" %(wa.screen, type(wa.screen)))
def on_configure_request(self, e): ev = e.xconfigurerequest client = Client.get_by_window(ev.window) if client is not None: geom = client.geom.copy() if ev.value_mask & xlib.CWX: geom.x = ev.x if ev.value_mask & xlib.CWY: geom.y = ev.y if ev.value_mask & xlib.CWWidth: geom.width = ev.width if ev.value_mask & xlib.CWHeight: geom.height = ev.height if (geom.x != client.geom.x or geom.y != client.geom.y or geom.width != client.geom.width or geom.height != client.geom.height): client.resize(geom) else: client.configure_window() else: wc = xlib.XWindowChanges() wc.x = ev.x wc.y = ev.y wc.width = ev.width wc.height = ev.height wc.border_width = ev.border_width wc.sibling = ev.above wc.stack_mode = ev.detail xlib.XConfigureWindow(e.xany.display, ev.window, ev.value_mask, byref(wc))
def on_unmap_notify(self, e): ev = e.xunmap client = Client.get_by_window(ev.window) log.debug('on_unmap_notify %s %s' % (ev.window, client)) if (client is not None and ev.event == client.screen.root_window and ev.send_event and get_window_state(client.window) == xlib.NormalState): client.remove()
def process_ewmh_message(self, ev): log.debug('ewmh message %s' % ev.message_type) if ev.message_type == samuraix.atoms['_NET_CURRENT_DESKTOP']: log.debug('_NET_CURRENT_DESKTOP') pass # change the desktop elif ev.message_type == samuraix.atoms['_NET_CLOSE_WINDOW']: client = Client.get_by_window(ev.window) log.debug('_NET_CLOSE_WINDOW %s' % client) if client: client.kill() elif ev.message_type == samuraix.atoms['_NET_WM_STATE']: client = Client.get_by_window(ev.window) log.debug('_NET_WM_STATE %s' % client) if client: setted = ev.data.l[0] == samuraix.atoms client.process_ewmh_state_atom(ev.data.l[1], ev.data.l[0]) if ev.data.l[2]: client.process_ewmh_state_atom(ev.data.l[2], ev.data.l[0])
def handle_net_wm_desktop(self, evt): """ handle the _NET_WM_DESKTOP client message. Somebody is requesting to change the desktop of the client. """ client = Client.get_by_window(evt.window) desktops = self.plugin.get_data(self.screen).desktops if client: # but shouldnt ever be invalid. new_idx = evt.data.data32[0] if new_idx == self.idx: # doesn't change anything, so don't do anything. pass elif new_idx == 0xffffffff: # TODO: show on all desktops log.warning('%s requests to be shown on all desktops - not implemented' % client) else: if not new_idx < len(desktops): log.warning('%s requests to be shown on desktop %d - no such desktop' % new_idx) else: desktop = desktops[new_idx] self.move_client_to_desktop(client, desktop)
def on_property_notify(self, e): ev = e.xproperty log.debug('on_property_notify %s' % ev.atom) if ev.state == xlib.PropertyDelete: return client = Client.get_by_window(ev.window) if client: log.debug('prop change for client %s' % client) if ev.atom == xatom.XA_WM_TRANSIENT_FOR: trans = xlib.Window() xlib.XGetTransientForHint(e.xany.display, client.window, byref(trans)) # needs rearrange elif ev.atom == xatom.XA_WM_NORMAL_HINTS: client.update_size_hints() elif ev.atom == xatom.XA_WM_HINTS: client.update_wm_hints() elif ev.atom == xatom.XA_WM_NAME or ev.atom == samuraix.atoms['_NET_WM_NAME']: client.update_title()
def on_enter_notify(self, e): ev = e.xcrossing log.debug(str((ev.mode, ev.x_root, ev.y_root, self.pointer_x, self.pointer_y, ev.x, ev.y))) if (ev.mode != xlib.NotifyNormal or (ev.x_root == self.pointer_x and ev.y_root == self.pointer_y)): log.debug('skipping on_enter_notify event') return client = Client.get_by_window(ev.window) log.debug('on_enter_notify %s %s' % (ev.window, client)) if client: self.pointer_x = ev.x_root self.pointer_y = ev.y_root client.dispatch_event('on_enter') else: for screen in self.screens: if ev.window == screen.root_window: screen.grab_buttons() return
def on_button_press(self, e): ev = e.xbutton wdummy = xlib.Window() udummy = c_uint() i = c_int() x = c_int() y = c_int() client = Client.get_by_window(ev.window) if client is not None: client.desktop.focus_client(client) if CLEANMASK(ev.state) == xlib.NoSymbol and ev.button == xlib.Button1: xlib.XAllowEvents(samuraix.display, xlib.ReplayPointer, xlib.CurrentTime) client.grab_buttons() else: client.dispatch_event('on_button_press', ev) else: for screen in self.screens: if (screen.root_window == ev.window and xlib.XQueryPointer(e.xany.display, ev.window, byref(wdummy), byref(wdummy), byref(x), byref(y), byref(i), byref(i), byref(udummy))): screen.dispatch_event('on_button_press', ev)
def on_destroy_notify(self, e): ev = e.xdestroywindow client = Client.get_by_window(ev.window) log.debug('on_destory_notify %s %s' % (ev.window, client)) if client is not None: client.remove()