internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: qtile/qtile

Issue:
Treetab disappears on qtile restart
When I have an active group using the `treetab` windowing mode and restart Qtile, the tabs column disappears (or more likely, isn't redrawn). If I switch to a different group and switch back, the column is drawn correctly

https://user-images.githubusercontent.com/20801821/144071895-23719b7a-1a3f-44c8-b3b7-053a782a0f1a.mp4

`qtile --version`: `0.18.1`

<details>
<summary>~/.local/share/qtile/qtile.log</summary>

```
2021-11-30 07:54:56,827 WARNING libqtile lifecycle.py:_atexit():L34 Restarting Qtile with os.execv(...)
2021-11-30 07:54:57,357 WARNING libqtile config.py:<module>():L27 Number of monitors: 2
2021-11-30 07:54:57,526 WARNING libqtile config.py:<module>():L28 Monitor resolutions:[(1920, 1280), (1920, 1080)]
```
</details>

_Unrelated note: I tried to use the new "issue form" thing on GitHub, but it just returns a HTTP 400 error when I tried to submit it_


Discussion:
Oddly I can't reproduce, even on `0.18.1` with an otherwise default config. If you try it with a mostly default config, does the issue persist?
Hmmm. Haven't tested it yet, but it might be a compositor issue (picom). I'll test with and without when I get a chance.
Shockingly, it's not a picom issue.

I've also tried it with the default config (while uncommenting the `layout.TreeTab()` line), and still get the same behavior.

Worth noting I'm on Manjaro 21.2.0, with qtile installed through the "normal" channels (ie. not from the AUR). I've had this issue over multiple computers, but with the same installation (ie. I physically moved the boot drive from one machine to the other). Those computers were running AMD and Intel CPUs (and their integrated graphics) respectively, so I doubt it's a hardware issue.
I ran in that problem too. Setting the default layout to a group will cause, that the panel 'stays open'.

Resolving patch:
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -168,6 +168,7 @@ def load_config(self, initial=False) -> None:
 
         if self._state:
             for screen in self.screens:
+                screen.group.layout.show(screen.get_rect())
                 screen.group.layout_all()
         self._state = None
         self.update_desktops()


Test patch:
Repository: qtile/qtile

Issue:
Accessing Systray icons via IPC results in crash
From reddit: https://www.reddit.com/r/qtile/comments/rssnm8/conflict_between_system_tray_widget_and/

Posting here as a reminder to fix it.


Discussion:
This happens because `libqtile.backend.x11.window._Window` does not inherit `libqtile.command.base.CommandObject` (although, `libqtile.backend.base._Window` does).

Will prepare a fix for this.

Resolving patch:
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -775,7 +775,9 @@ def _items(self, name: str) -> ItemT:
         elif name == "bar":
             return False, [x.position for x in self.current_screen.gaps]
         elif name == "window":
-            return True, list(self.windows_map.keys())
+            windows: List[Union[str, int]]
+            windows = [k for k, v in self.windows_map.items() if isinstance(v, CommandObject)]
+            return True, windows
         elif name == "screen":
             return True, list(range(len(self.screens)))
         elif name == "core":
@@ -801,7 +803,11 @@ def _select(self, name: str, sel: Optional[Union[str, int]]) -> Optional[Command
             if sel is None:
                 return self.current_window
             else:
-                return self.windows_map.get(sel)  # type: ignore
+                windows: Dict[Union[str, int], base._Window]
+                windows = {
+                    k: v for k, v in self.windows_map.items() if isinstance(v, CommandObject)
+                }
+                return windows.get(sel)
         elif name == "screen":
             if sel is None:
                 return self.current_screen


Test patch:
Repository: qtile/qtile

Issue:
With multi monitors, clicking empty screen group does not fully focus screen?
Basically I ran into this with dmenu (additional case below) which I have a keybinding for..
To replicate, you need at least 2 monitors. 
On first monitor open a window, the second monitor should be an empty workspace, click the second monitor workspace to active it, open dmenu. I expected dmenu to open in the second monitor but it opens in the first monitor. If the second monitor has a window open then moving your mouse over will activate the workspace and dmenu will appear in the appropriate workspace.

This is also notable for example, I have a bar in both screens with the CurrentLayout widget on each, if you repeat the scenario above but instead of dmenu go to the second screen and click the CurrentLayout widget which by default cycles through the available layouts, in this case clicking the widget on the second screen actually cycles the layouts on the first monitor.


Discussion:
Thanks. This is probably a similar issue to #3165 (i.e. there's an underlying issue that causes both issues).

Resolving patch:
diff --git a/libqtile/bar.py b/libqtile/bar.py
--- a/libqtile/bar.py
+++ b/libqtile/bar.py
@@ -446,6 +446,11 @@ def get_widget_in_position(self, x: int, y: int) -> typing.Optional[_Widget]:
         return None
 
     def process_button_click(self, x: int, y: int, button: int) -> None:
+        # If we're clicking on a bar that's not on the current screen, focus that screen
+        if self.screen is not self.qtile.current_screen:
+            index = self.qtile.screens.index(self.screen)
+            self.qtile.focus_screen(index, warp=False)
+
         widget = self.get_widget_in_position(x, y)
         if widget:
             widget.button_press(


Test patch:
Repository: qtile/qtile

Issue:
If TreeTab layout is active when removed from the config and reloading causes qtile to enter into invalid state.
I rant into this whilst experimenting with my config. if TreeTab layout is active while being removed from the config and reloading, it causes the TreeTab panel to stay on permanently, requiring a qtile restart.  


Discussion:
Thanks for reporting.

Have confirmed this is the case. Will work on a fix.

Resolving patch:
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -281,8 +281,10 @@ def _finalize_configurables(self) -> None:
                 widget.finalize()
             self.widgets_map.clear()
 
-            for layout in self.config.layouts:
-                layout.finalize()
+            # For layouts we need to finalize each clone of a layout in each group
+            for group in self.groups:
+                for layout in group.layouts:
+                    layout.finalize()
 
             for screen in self.screens:
                 for gap in screen.gaps:
diff --git a/libqtile/layout/tree.py b/libqtile/layout/tree.py
--- a/libqtile/layout/tree.py
+++ b/libqtile/layout/tree.py
@@ -475,6 +475,8 @@ def configure(self, client, screen_rect):
             client.hide()
 
     def finalize(self):
+        if self._panel:
+            self._panel.kill()
         Layout.finalize(self)
         if self._drawer is not None:
             self._drawer.finalize()


Test patch:
Repository: qtile/qtile

Issue:
CheckUpdates widget swallows crashes and shows as no updates
As per title, it's not clear if the check update command is working as any error in the command results in the widget treating it as no updates. 

This makes debugging impossible.


Discussion:
In the corresponding PR (https://github.com/qtile/qtile/pull/3160) we decided that this would be a no-fix. Shall we close this?
How about, rather than fixing, we make the docs clearer?
Good idea

Resolving patch:
diff --git a/libqtile/widget/check_updates.py b/libqtile/widget/check_updates.py
--- a/libqtile/widget/check_updates.py
+++ b/libqtile/widget/check_updates.py
@@ -26,7 +26,21 @@
 
 
 class CheckUpdates(base.ThreadPoolText):
-    """Shows number of pending updates in different unix systems"""
+    """
+    Shows number of pending updates in different unix systems.
+
+    .. note::
+
+        It is common for package managers to return a non-zero code when there are no
+        updates. As a result, the widget will treat *any* error as if there are no updates.
+        If you are using a custom commmand/script, you should therefore ensure that it
+        returns zero when it completes if you wish to see the output of your command.
+
+        In addition, as no errors are recorded to the log, if the widget is showing no
+        updates and you believe that to be incorrect, you should run the appropriate
+        command in a terminal to view any error messages.
+
+    """
 
     defaults = [
         ("distro", "Arch", "Name of your distribution"),


Test patch:
Repository: qtile/qtile

Issue:
Battery widget doesn't respect extension_defaults
OS: Arch linux
Qtile version: 0.19.0

I have defined `extension_defaults` for all my widgets (see part of  my config file below). This seems to be respected by all the widgets I use except the Battery widget, which seems to respect the foreground color, but not the background color. Manually adding `background=bg` to the Battery widget works.

This line gives a black background (wrong) and the correct foreground color:
`widget.Battery(battery=0, format='{percent:2.0%}', low_percentage=0, show_short_text=False),`

This line gives the correct background color and the correct foreground color:
`widget.Battery(battery=0, format='{percent:2.0%}', low_percentage=0, show_short_text=False, background=bg),`

Part of my config file:
```
# colors
bg = "#282828" 
fg = "#ebdbb2"
gray = "#928374"
bright_gray = "#a89984"
red = "#cc241d"
bright_red = "#fb4934"
green = "#98971a"
bright_green = "#b8bb26"
yellow= "#d79921"
bright_yellow = "#fabd2f"
blue = "#458588"
bright_blue = "#83a598"
purple = "#b16286"
bright_purple = "#d3869b"
aqua = "#689d6a"
faded_aqua = "#8ec07c"

# theme defaults
widget_defaults = dict(
    font='RobotoMono Nerd Font',
    fontsize=16,
    padding=3,
    background=bg,
    foreground=fg
)
extension_defaults = widget_defaults.copy()
```


Discussion:
Interesting. I've actually just been looking at a very similar issue for the `Volume` widget (#3203).

I'll take a look.

Resolving patch:
diff --git a/libqtile/widget/battery.py b/libqtile/widget/battery.py
--- a/libqtile/widget/battery.py
+++ b/libqtile/widget/battery.py
@@ -339,10 +339,13 @@ def __init__(self, **config) -> None:
         self._battery = self._load_battery(**config)
         self._has_notified = False
 
+    def _configure(self, qtile, bar):
         if not self.low_background:
             self.low_background = self.background
         self.normal_background = self.background
 
+        base.ThreadPoolText._configure(self, qtile, bar)
+
     @staticmethod
     def _load_battery(**config):
         """Function used to load the Battery object


Test patch:
Repository: qtile/qtile

Issue:
Systray widget crash
2022-01-27 09:48:40,366 ERROR libqtile bar.py:_configure_widget():L324 Systray widget crashed during _configure with error: ConfigError('Only one Systray can be used.')
[config.txt](https://github.com/qtile/qtile/files/7948239/config.txt)




Discussion:
Hmm. That shouldn't have happened.

Did this happen the first time you started or did you restart/reload the config before the crash happened?

EDIT: both `restart` and `reload_config` work ok for me.
confirm the issue.
multi-screen setup, only one systray init in config.
error on fresh start, when manually reload config, widget loads fine.
Ah. I wonder if it's crashing because of screens being reconfigured.

Will test.
Confirmed - it's `cmd_reconfigure_screens`.

Sorry about that.

Will work on a fix.

Resolving patch:
diff --git a/libqtile/widget/systray.py b/libqtile/widget/systray.py
--- a/libqtile/widget/systray.py
+++ b/libqtile/widget/systray.py
@@ -143,12 +143,12 @@ def calculate_length(self):
     def _configure(self, qtile, bar):
         base._Widget._configure(self, qtile, bar)
 
-        if Systray._instances > 0:
-            raise ConfigError("Only one Systray can be used.")
-
         if self.configured:
             return
 
+        if Systray._instances > 0:
+            raise ConfigError("Only one Systray can be used.")
+
         self.conn = conn = qtile.core.conn
         win = conn.create_window(-1, -1, 1, 1)
         window._Window.__init__(self, window.XWindow(conn, win.wid), qtile)
@@ -200,10 +200,10 @@ def create_mirror(self):
         """
         Systray cannot be mirrored as we do not use a Drawer object to render icons.
 
-        Return itself so that, when the bar tries to configure it again, a ConfigError
-        is raised.
+        Return new, unconfigured instance so that, when the bar tries to configure it
+        again, a ConfigError is raised.
         """
-        return self
+        return Systray()
 
     def handle_ClientMessage(self, event):  # noqa: N802
         atoms = self.conn.atoms


Test patch:
Repository: qtile/qtile

Issue:
[Xwayland] With the latest Git update, once again Spotify does not honor qtile layouts. Could someone confirm please? Thanks
With the latest Git update, once again Spotify does not honor qtile layouts. (close issue #3273) Could someone confirm please? Thanks

_Originally posted by @cr1ogen in https://github.com/qtile/qtile/issues/3273#issuecomment-1046430113_


Discussion:
I think this was confirmed on IRC yesterday but I've not verified this myself.

![2022-02-21_12-02-1645458228](https://user-images.githubusercontent.com/9537788/154987475-8ffc7461-a5e5-4150-89d5-71b889b618e3.png)


I too can confirm that Spotify yesterday did open in floating mode and you could tile it back to normal using shift + mod + f but that doesn't seem to work as of the last days updates. It did work yesterday but now only tiles it to the right hand side and not the full window for monadtall ???

This is the ouput of `qtile cmd-obj -o cmd -f windows`

{'float_info': {'height': 1004, 'width': 922, 'x': 976, 'y': 54},
  'floating': False,
  'fullscreen': False,
  'group': '阮 ₆',
  'height': 1004,
  'id': 5,
  'maximized': False,
  'minimized': False,
  'name': 'Spotify',
  'width': 922,
  'wm_class': ['Spotify'],
  'x': 2896,
  'y': 54}]


![2022-02-21_19-02-1645471002](https://user-images.githubusercontent.com/1571498/155015327-d1f85ec9-30f0-42ff-b78a-49aaab52386c.jpg)

Just done a `git bisect`. It's this commit: https://github.com/qtile/qtile/commit/d0a27321b27577e0a57634c7fe63574a0c28e538

Resolving patch:
diff --git a/libqtile/backend/wayland/window.py b/libqtile/backend/wayland/window.py
--- a/libqtile/backend/wayland/window.py
+++ b/libqtile/backend/wayland/window.py
@@ -915,7 +915,6 @@ def _on_map(self, _listener: Listener, _data: Any) -> None:
             # Add event listeners
             self.add_listener(self.surface.surface.commit_event, self._on_commit)
             self.add_listener(self.surface.request_fullscreen_event, self._on_request_fullscreen)
-            self.add_listener(self.surface.request_configure_event, self._on_request_configure)
             self.add_listener(self.surface.set_title_event, self._on_set_title)
             self.add_listener(self.surface.set_class_event, self._on_set_class)
             self.add_listener(
@@ -958,13 +957,6 @@ def _on_request_fullscreen(self, _listener: Listener, _data: Any) -> None:
         if self.qtile.config.auto_fullscreen:
             self.fullscreen = not self.fullscreen
 
-    def _on_request_configure(
-        self, _listener: Listener, event: xwayland.SurfaceConfigureEvent
-    ) -> None:
-        logger.debug("Signal: xwindow request_configure")
-        self.surface.configure(event.x, event.y, event.width, event.height)
-        self.floating = True
-
     def _on_set_title(self, _listener: Listener, _data: Any) -> None:
         logger.debug("Signal: xwindow set_title")
         title = self.surface.title


Test patch:
Repository: qtile/qtile

Issue:
[Wayland] Please split input config for pointer and touchpad devices
Last week https://github.com/qtile/qtile/pull/2548 was merged, which is awesome! There's one improvement I would like to as for though: to be able to split the configuration of `type:pointer` and `type:touchpad` devices. Currently only `type:pointer` is supported, which covers both mouses and touchpads. This leads in my case to `natural_scroll=True` being applied to my mouse too, which I find very annoying. :)


Discussion:
Do you get a warning level log message saying `"Device not configured. Type 'touchpad' not recognised."` when you try to use `type:touchpad`?

Resolving patch:
diff --git a/libqtile/backend/wayland/inputs.py b/libqtile/backend/wayland/inputs.py
--- a/libqtile/backend/wayland/inputs.py
+++ b/libqtile/backend/wayland/inputs.py
@@ -329,6 +329,12 @@ def configure_device(device: InputDevice, configs: dict[str, InputConfig]) -> No
     identifier = "%d:%d:%s" % (device.vendor, device.product, name)
     type_key = "type:" + device.device_type.name.lower()
 
+    if type_key == "type:pointer":
+        # This checks whether the pointer is a touchpad.
+        handle = device.libinput_get_device_handle()
+        if handle and libinput.libinput_device_config_tap_get_finger_count(handle) > 0:
+            type_key = "type:touchpad"
+
     if identifier in configs:
         conf = configs[identifier]
     elif type_key in configs:


Test patch:
Repository: qtile/qtile

Issue:
StatusNotifier bugs
### The issue:

Just a note to remind me to fix some issues with the `StatusNotifier` widget:

- [x] Ayatana apps need to issue a signal when registered
- [x] `RegisterStatusNotifierItem` does not return so libappindicator apps produce warning messages and may disconnect

Both easily fixable!

### Required:

- [X] I have searched past issues to see if this bug has already been reported.


Discussion:

Resolving patch:
diff --git a/libqtile/widget/statusnotifier.py b/libqtile/widget/statusnotifier.py
--- a/libqtile/widget/statusnotifier.py
+++ b/libqtile/widget/statusnotifier.py
@@ -349,6 +349,9 @@ def _message_handler(self, message):
         Ayatana indicators seem to register themselves by passing their object
         path rather than the service providing that object. We therefore need
         to identify the sender of the message in order to register the service.
+
+        Returning False so senders receieve a reply (returning True prevents
+        reply being sent)
         """
         if message.member != "RegisterStatusNotifierItem":
             return False
@@ -358,9 +361,12 @@ def _message_handler(self, message):
         if message.sender == message.body[0]:
             return False
 
-        self._items.append(message.sender)
-        self.on_item_added(message.sender, message.body[0])
-        return True
+        if message.sender not in self._items:
+            self._items.append(message.sender)
+            if self.on_item_added is not None:
+                self.on_item_added(message.sender, message.body[0])
+            self.StatusNotifierItemRegistered(message.sender)
+        return False
 
     async def _setup_listeners(self):
         """
@@ -394,6 +400,8 @@ def _name_owner_changed(self, message):
     def RegisterStatusNotifierItem(self, service: "s"):  # type: ignore  # noqa: F821, N802
         if service not in self._items:
             self._items.append(service)
+            if self.on_item_added is not None:
+                self.on_item_added(service)
             self.StatusNotifierItemRegistered(service)
 
     @method()
@@ -418,8 +426,6 @@ def ProtocolVersion(self) -> "i":  # type: ignore  # noqa: F821, N802
 
     @signal()
     def StatusNotifierItemRegistered(self, service) -> "s":  # type: ignore  # noqa: F821, N802
-        if self.on_item_added is not None:
-            self.on_item_added(service)
         return service
 
     @signal()


Test patch:
Repository: qtile/qtile

Issue:
XWayland: second xwayland window doesn't receive input
When opening multiple X applications through the new XWayland support, they don't ever receive input. Only the first opened window gets the input, and all input actions done in more recently opened X applications get performed in the first one. When the first window is closed, the second window becomes the first (FIFO like) and gets all input from all XWayland applications.

This only happens with XWayland windows, all Wayland windows correctly receive input when focused.


Discussion:
If I open two xterm windows I can type and click into both of them just fine. Is there a specific kind of window (e.g. electron-based) that the problem is limited to? Also, is this one or more monitors, and if multiple, does it persist with just one? There are some input issues with multiple monitors and xwayland currently.
I'm afraid you have some good points there... I tested it with several combinations of vscode, gimp and element, but 2 of them are electron apps. And I also have a dual monitor setup. I'll test this later again to narrow it down.
Same here. Y try with Steam, Spotify, and firefox xWayland. firefox wayland works fine
https://github.com/qtile/qtile/issues/3259#issuecomment-1022806339
Don't forget about this bug, it should be a priority in wayland xD
Lol, I actually did forget about it. I'll bump it up :wink: 
If you drag the windows around does anything change? Like if you have two windows, and one isn't getting input, if you drag one to the far left and one to the far right, do you start to see input in the two windows? I'm beginning to think that the XWayland server's view of window positions is wrong, and its not relaying input how we expect.
If the 2 windows take up the same position, but on 2 different groups (so one is unmapped, but if it was mapped, they would overlap), the input in the overlapped area goes to the one that is "above" the other, even though it is unmapped.

Is this consistent with everyone else's experience?

Resolving patch:
diff --git a/libqtile/backend/wayland/core.py b/libqtile/backend/wayland/core.py
--- a/libqtile/backend/wayland/core.py
+++ b/libqtile/backend/wayland/core.py
@@ -775,6 +775,7 @@ def focus_window(
 
         elif surface.is_xwayland_surface and isinstance(win.surface, xwayland.Surface):
             win.surface.activate(True)
+            win.surface.restack(None, 0)  # XCB_STACK_MODE_ABOVE
             win.ftm_handle.set_activated(True)
 
         if enter and self.seat.keyboard._ptr:  # This pointer is NULL when headless


Test patch: