def focus(self): try: if self.passive: self.conn.core.SetInputFocus(xproto.InputFocus.PointerRoot, self.win, xproto.Time.CurrentTime) elif self.local_active: err = self.conn.core.SetInputFocusChecked( xproto.InputFocus.PointerRoot, self.win, xproto.Time.CurrentTime) err.check() packed = event.pack_client_message(self.win, "WM_PROTOCOLS", atom.WM_TAKE_FOCUS, xproto.Time.CurrentTime) event.send_event(self.win, 0, packed) elif self.global_active: packed = event.pack_client_message(self.win, "WM_PROTOCOLS", atom.WM_TAKE_FOCUS, xproto.Time.CurrentTime) event.send_event(self.win, 0, packed) else: return self.wm.current_name = self.get_wm_name() self.wm.current_win = self ewmh.set_active_window(self.win) except (xproto.BadMatch, xproto.BadWindow): return
def close(self): if aid('WM_DELETE_WINDOW') in self.win.protocols: event.send_event( state.conn, self.win.id, 0, event.pack_client_message(self.win.id, aid('WM_PROTOCOLS'), aid('WM_DELETE_WINDOW'))) else: state.conn.core.KillClientChecked(self.win.id)
def destroy(self): #we need to handle WM_DELETE_window try: protos = self.get_wm_protocols() if protos and atom.WM_DELETE_WINDOW in protos: packed = event.pack_client_message(self.win, "WM_PROTOCOLS", atom.WM_DELETE_WINDOW, xproto.Time.CurrentTime) event.send_event(self.win, 0,packed) else: self.conn.core.DestroyWindow(self.win) except xproto.BadWindow: return
def focus(self): try: if self.passive : self.conn.core.SetInputFocus(xproto.InputFocus.PointerRoot, self.win, xproto.Time.CurrentTime) elif self.local_active: err = self.conn.core.SetInputFocusChecked(xproto.InputFocus.PointerRoot, self.win, xproto.Time.CurrentTime) err.check() packed = event.pack_client_message(self.win, "WM_PROTOCOLS", atom.WM_TAKE_FOCUS, xproto.Time.CurrentTime) event.send_event(self.win, 0,packed) elif self.global_active: packed = event.pack_client_message(self.win, "WM_PROTOCOLS", atom.WM_TAKE_FOCUS, xproto.Time.CurrentTime) event.send_event(self.win, 0,packed) else: return self.wm.current_name = self.get_wm_name() self.wm.current_win = self ewmh.set_active_window(self.win) except (xproto.BadMatch, xproto.BadWindow): return
def destroy(self): #we need to handle WM_DELETE_window try: protos = self.get_wm_protocols() if protos and atom.WM_DELETE_WINDOW in protos: packed = event.pack_client_message(self.win, "WM_PROTOCOLS", atom.WM_DELETE_WINDOW, xproto.Time.CurrentTime) event.send_event(self.win, 0, packed) else: self.conn.core.DestroyWindow(self.win) except xproto.BadWindow: return
def focus(self): if self.win.hints['input'] == 1: state.conn.core.SetInputFocusChecked( xcb.xproto.InputFocus.PointerRoot, self.win.id, xcb.xproto.Time.CurrentTime).check() self.focused() elif aid('WM_TAKE_FOCUS') in self.win.protocols: packed = event.pack_client_message(self.win.id, aid('WM_PROTOCOLS'), aid('WM_TAKE_FOCUS'), events.time) event.send_event(state.conn, self.win.id, 0, packed) self.focused()