def handle_ClientMessage(self, event): # noqa: N802 atoms = self.qtile.conn.atoms opcode = event.type data = event.data.data32 message = data[1] wid = data[2] conn = self.qtile.conn.conn parent = self.bar.window.window if opcode == atoms['_NET_SYSTEM_TRAY_OPCODE'] and message == 0: w = xcbq.Window(self.qtile.conn, wid) icon = Icon(w, self.qtile, self) self.icons[wid] = icon self.qtile.windows_map[wid] = icon conn.core.ChangeSaveSet(SetMode.Insert, wid) conn.core.ReparentWindow(wid, parent.wid, 0, 0) conn.flush() info = icon.window.get_property('_XEMBED_INFO', unpack=int) if not info: self.bar.draw() return False if info[1]: self.bar.draw() return False
def _configure(self, qtile, bar): base._Widget._configure(self, qtile, bar) win = qtile.conn.create_window(-1, -1, 1, 1) window._Window.__init__(self, xcbq.Window(qtile.conn, win.wid), qtile) qtile.windows_map[win.wid] = self # Even when we have multiple "Screen"s, we are setting up as the system # tray on a particular X display, that is the screen we need to # reference in the atom if qtile.current_screen: self.screen = qtile.current_screen.index self.bar = bar atoms = qtile.conn.atoms qtile.conn.conn.core.SetSelectionOwner( win.wid, atoms['_NET_SYSTEM_TRAY_S{:d}'.format(self.screen)], xcffib.CurrentTime) data = [ xcffib.CurrentTime, atoms['_NET_SYSTEM_TRAY_S{:d}'.format(self.screen)], win.wid, 0, 0 ] union = ClientMessageData.synthetic(data, "I" * 5) event = ClientMessageEvent.synthetic(format=32, window=qtile.root.wid, type=atoms['MANAGER'], data=union) qtile.root.send_event(event, mask=EventMask.StructureNotify)
def is_blacklisted(self, owner_id): if not self.blacklist: return False if owner_id in self.qtile.windows_map: owner = self.qtile.windows_map[owner_id].window else: owner = xcbq.Window(self.qtile.conn, owner_id) owner_class = owner.get_wm_class() if owner_class: for wm_class in self.blacklist: if wm_class in owner_class: return True
def handle_ConfigureRequest(self, event): # noqa: N802 # It's not managed, or not mapped, so we just obey it. cw = xcffib.xproto.ConfigWindow args = {} if event.value_mask & cw.X: args["x"] = max(event.x, 0) if event.value_mask & cw.Y: args["y"] = max(event.y, 0) if event.value_mask & cw.Height: args["height"] = max(event.height, 0) if event.value_mask & cw.Width: args["width"] = max(event.width, 0) if event.value_mask & cw.BorderWidth: args["borderwidth"] = max(event.border_width, 0) w = xcbq.Window(self.conn, event.window) w.configure(**args)
def handle_MapRequest(self, event) -> None: # noqa: N802 assert self.qtile is not None window = xcbq.Window(self.conn, event.window) self.qtile.map_window(window)
def __init__(self, display_name: str = None) -> None: """Setup the X11 core backend :param display_name: The display name to setup the X11 connection to. Uses the DISPLAY environment variable if not given. """ if display_name is None: display_name = os.environ.get("DISPLAY") if not display_name: raise QtileError("No DISPLAY set") self.conn = xcbq.Connection(display_name) self._display_name = display_name # Because we only do Xinerama multi-screening, # we can assume that the first # screen's root is _the_ root. self._root = self.conn.default_screen.root supporting_wm_wid = self._root.get_property("_NET_SUPPORTING_WM_CHECK", "WINDOW", unpack=int) if len(supporting_wm_wid) > 0: supporting_wm_wid = supporting_wm_wid[0] supporting_wm = xcbq.Window(self.conn, supporting_wm_wid) existing_wmname = supporting_wm.get_property("_NET_WM_NAME", "UTF8_STRING", unpack=str) if existing_wmname: logger.error("not starting; existing window manager {}".format(existing_wmname)) raise ExistingWMException(existing_wmname) self._root.set_attribute( eventmask=( xcffib.xproto.EventMask.StructureNotify | xcffib.xproto.EventMask.SubstructureNotify | xcffib.xproto.EventMask.SubstructureRedirect | xcffib.xproto.EventMask.EnterWindow | xcffib.xproto.EventMask.LeaveWindow ) ) self._root.set_property( "_NET_SUPPORTED", [self.conn.atoms[x] for x in xcbq.SUPPORTED_ATOMS] ) self._wmname = "qtile" self._supporting_wm_check_window = self.conn.create_window(-1, -1, 1, 1) self._supporting_wm_check_window.set_property("_NET_WM_NAME", self._wmname) self._supporting_wm_check_window.set_property( "_NET_SUPPORTING_WM_CHECK", self._supporting_wm_check_window.wid ) self._root.set_property( "_NET_SUPPORTING_WM_CHECK", self._supporting_wm_check_window.wid ) self._selection = { "PRIMARY": {"owner": None, "selection": ""}, "CLIPBOARD": {"owner": None, "selection": ""}, } self._selection_window = self.conn.create_window(-1, -1, 1, 1) self._selection_window.set_attribute( eventmask=xcffib.xproto.EventMask.PropertyChange ) if hasattr(self.conn, "xfixes"): self.conn.xfixes.select_selection_input(self._selection_window, "PRIMARY") # type: ignore self.conn.xfixes.select_selection_input(self._selection_window, "CLIPBOARD") # type: ignore primary_atom = self.conn.atoms["PRIMARY"] reply = self.conn.conn.core.GetSelectionOwner(primary_atom).reply() self._selection["PRIMARY"]["owner"] = reply.owner clipboard_atom = self.conn.atoms["CLIPBOARD"] reply = self.conn.conn.core.GetSelectionOwner(primary_atom).reply() self._selection["CLIPBOARD"]["owner"] = reply.owner # ask for selection on start-up self.convert_selection(primary_atom) self.convert_selection(clipboard_atom) # setup the default cursor self._root.set_cursor("left_ptr") self.qtile = None # type: Optional[Qtile] self._painter = None numlock_code = self.conn.keysym_to_keycode(xcbq.keysyms["Num_Lock"])[0] self._numlock_mask = xcbq.ModMasks.get(self.conn.get_modifier(numlock_code), 0) self._valid_mask = ~(self._numlock_mask | xcbq.ModMasks["lock"])