Пример #1
0
    def handle_MapRequest(self, event) -> None:  # noqa: N802
        assert self.qtile is not None

        xwin = window.XWindow(self.conn, event.window)
        try:
            attrs = xwin.get_attributes()
            internal = xwin.get_property("QTILE_INTERNAL")
        except (xcffib.xproto.WindowError, xcffib.xproto.AccessError):
            return

        if attrs and attrs.override_redirect:
            return

        win = self.qtile.windows_map.get(xwin.wid)
        if win:
            if isinstance(win, window.Window) and win.group is self.qtile.current_group:
                win.unhide()
            return

        if internal:
            win = window.Internal(xwin, self.qtile)
            self.qtile.manage(win)
            win.unhide()
        else:
            win = window.Window(xwin, self.qtile)

            if xwin.get_wm_type() == "dock" or win.reserved_space:
                assert self.qtile.current_screen is not None
                win.cmd_static(self.qtile.current_screen.index)
                return

            self.qtile.manage(win)
            if not win.group or not win.group.screen:
                return
            win.unhide()
Пример #2
0
    def scan(self) -> None:
        """Scan for existing windows"""
        assert self.qtile is not None

        _, _, children = self._root.query_tree()
        for item in children:
            try:
                attrs = item.get_attributes()
                state = item.get_wm_state()
                internal = item.get_property("QTILE_INTERNAL")
            except (xcffib.xproto.WindowError, xcffib.xproto.AccessError):
                continue

            if attrs and attrs.map_state == xcffib.xproto.MapState.Unmapped or attrs.override_redirect:
                continue
            if state and state[0] == window.WithdrawnState:
                item.unmap()
                continue

            win = self.qtile.windows_map.get(item.wid)
            if win:
                win.unhide()
                return

            if internal:
                win = window.Internal(item, self.qtile)
            else:
                win = window.Window(item, self.qtile)

                if item.get_wm_type() == "dock" or win.reserved_space:
                    assert self.qtile.current_screen is not None
                    win.cmd_static(self.qtile.current_screen.index)
                    continue

            self.qtile.manage(win)
Пример #3
0
    def create_internal(self, x: int, y: int, width: int,
                        height: int) -> base.Internal:
        assert self.qtile is not None

        win = self.conn.create_window(x, y, width, height)
        internal = window.Internal(win, self.qtile)
        internal.place(x, y, width, height, 0, None)
        self.qtile.manage(internal)
        return internal
Пример #4
0
    def create_internal(self,
                        x: int,
                        y: int,
                        width: int,
                        height: int,
                        desired_depth: Optional[int] = 32) -> base.Internal:
        assert self.qtile is not None

        win = self.conn.create_window(x, y, width, height, desired_depth)
        internal = window.Internal(win, self.qtile, desired_depth)
        internal.place(x, y, width, height, 0, None)
        self.qtile.manage(internal)
        return internal
Пример #5
0
    def distribute_windows(self, initial) -> None:
        """Assign windows to groups"""
        assert self.qtile is not None

        if not initial:
            # We are just reloading config
            for win in self.qtile.windows_map.values():
                if type(win) is window.Window:
                    win.set_group()
            return

        # Qtile just started - scan for clients
        _, _, children = self._root.query_tree()
        for item in children:
            try:
                attrs = item.get_attributes()
                state = item.get_wm_state()
                internal = item.get_property("QTILE_INTERNAL")
            except (xcffib.xproto.WindowError, xcffib.xproto.AccessError):
                continue

            if (
                attrs
                and attrs.map_state == xcffib.xproto.MapState.Unmapped
                or attrs.override_redirect
            ):
                continue
            if state and state[0] == window.WithdrawnState:
                item.unmap()
                continue

            if item.wid in self.qtile.windows_map:
                win = self.qtile.windows_map[item.wid]
                win.unhide()
                return

            if internal:
                win = window.Internal(item, self.qtile)
            else:
                win = window.Window(item, self.qtile)

                if item.get_wm_type() == "dock" or win.reserved_space:
                    assert self.qtile.current_screen is not None
                    win.cmd_static(self.qtile.current_screen.index)
                    continue

            self.qtile.manage(win)
Пример #6
0
    def __init__(self, qtile, x=50, y=50, width=256, height=64, **config):
        configurable.Configurable.__init__(self, **config)
        self.add_defaults(Popup.defaults)
        self.qtile = qtile

        win = qtile.core.conn.create_window(x, y, width, height)
        win.set_property("QTILE_INTERNAL", 1)
        self.win = window.Internal(win, qtile)
        self.qtile.windows_map[self.win.wid] = self.win
        self.win.opacity = self.opacity
        self.drawer = drawer.Drawer(
            self.qtile,
            self.win.wid,
            width,
            height,
        )
        self.layout = self.drawer.textlayout(
            text='',
            colour=self.foreground,
            font_family=self.font,
            font_size=self.font_size,
            font_shadow=self.fontshadow,
            wrap=self.wrap,
            markup=True,
        )
        self.layout.layout.set_alignment(
            pangocffi.ALIGNMENTS[self.text_alignment])

        if self.border_width:
            self.win.window.configure(borderwidth=self.border_width)
        if self.corner_radius:
            self.win.window.round_corners(width, height, self.corner_radius,
                                          self.border_width)

        self.win.handle_Expose = self._handle_Expose
        self.win.handle_KeyPress = self._handle_KeyPress
        self.win.handle_ButtonPress = self._handle_ButtonPress

        self.x = self.win.x
        self.y = self.win.y
        if not self.border_width:
            self.border = None