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

Issue:
[Wayland] KeyboardLayout widget not working
### The issue:

qtile version 0.20.1.dev78+gb7167931

The keyboard layout, from US to ES, does not change when choosing the language layout. In X11 it works

KeyboardLaout config part

                widget.KeyboardLayout(
                    configured_keyboards=['us','es'],
                ),


### Required:

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


Discussion:
**I too have this exact issue using latest git version under wayland**

I have two keyboards, one on the laptop which is GB layout and my custom built handwired one which is US layout. If I boot into qtile wayland changing the keyboard layout does nothing on either keyboard.                                                                                                                                                          But if I power cycle my external keyboard then that keyboard starts to function with the keyboard layout widget allowing me to switch between us and gb. But the laptops keyboard sticks at the default setup in the wayland input rules of gb. It's like something isn't getting refreshed ?
I have also noticed if I connect another keyboard that also doesn't get affected until i unplug and plug it back in. Only the last board to be reset is the one that works.
Have you seen this issue @m-col  ??       

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
@@ -1003,7 +1003,8 @@ def cmd_set_keymap(
         identical to those accepted by the env variables.
         """
         if self.keyboards:
-            self.keyboards[-1].set_keymap(layout, options, variant)
+            for keyboard in self.keyboards:
+                keyboard.set_keymap(layout, options, variant)
         else:
             logger.warning("Could not set keymap: no keyboards set up.")
 


Test patch:
Repository: qtile/qtile

Issue:
Clicking blank screen then previous window doesn't focus clicked window
### The issue:

I have two screens, and `follow_mouse_focus = False`.

Suppose I have two windows on my first monitor, A and B, A is currently focused, and I have no windows on my second monitor.

If I click my second monitor, the focused screen is now my second monitor. 
Interestingly, I can still type stuff in A afterwards, but it doesn't have the focus outline anymore.

Now if I click A, not only does qtile not shift the focus to A (as in no focus outline), my second monitor also remains the focused screen. 
**I expect that if I click A, A should be refocused and that my first monitor is also now focused.**

However, if I click B, everything works as expected. 

However, if I click B, everything works as expected.

I don't see any relevant logs, and I'm running qtile version 0.21.0 on Archlinux. 

### Required:

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


Discussion:
Thanks for the report. I can confirm I also see this behaviour.

Will take a look when I can.

Resolving patch:
diff --git a/libqtile/backend/x11/core.py b/libqtile/backend/x11/core.py
--- a/libqtile/backend/x11/core.py
+++ b/libqtile/backend/x11/core.py
@@ -888,6 +888,8 @@ def focus_by_click(self, e, window=None):
             # clicked on root window
             screen = qtile.find_screen(e.root_x, e.root_y)
             if screen:
+                if qtile.current_window:
+                    qtile.current_window._grab_click()
                 qtile.focus_screen(screen.index, warp=False)
 
     def flush(self):
diff --git a/libqtile/bar.py b/libqtile/bar.py
--- a/libqtile/bar.py
+++ b/libqtile/bar.py
@@ -524,6 +524,8 @@ 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 and self.screen is not self.qtile.current_screen:
+            if self.qtile.core.name == "x11" and self.qtile.current_window:
+                self.qtile.current_window._grab_click()
             index = self.qtile.screens.index(self.screen)
             self.qtile.focus_screen(index, warp=False)
 


Test patch:
Repository: qtile/qtile

Issue:
No option to change icon size for widget Launchbar
qtile --version :0.22.1
### The issue:

The icons from the Launchbar widget seem to take all the height of the bar by default.
![image](https://user-images.githubusercontent.com/27446196/191794299-7a3f6973-bc5c-4b6d-8899-d628f969de98.png)

Padding option only changes the space between icons.
Some option like spacing, margin(_x, _y), padding(_x, _y)and especially icon_size would be welcomed.



### Required:

- [X] I have searched past issues to see if this bug has already been reported.


Discussion:

Resolving patch:
diff --git a/libqtile/widget/launchbar.py b/libqtile/widget/launchbar.py
--- a/libqtile/widget/launchbar.py
+++ b/libqtile/widget/launchbar.py
@@ -82,6 +82,8 @@ class LaunchBar(base._Widget):
             " ('logout', 'qshell:self.qtile.cmd_shutdown()', 'logout from qtile')]",
         ),
         ("text_only", False, "Don't use any icons."),
+        ("icon_size", None, "Size of icons. ``None`` to fit to bar."),
+        ("padding_y", 0, "Vertical adjustment for icons."),
     ]
 
     def __init__(
@@ -126,6 +128,9 @@ def _configure(self, qtile, pbar):
 
     def setup_images(self):
         """Create image structures for each icon files."""
+        self._icon_size = self.icon_size if self.icon_size is not None else self.bar.height - 4
+        self._icon_padding = (self.bar.height - self._icon_size) // 2
+
         for img_name, iconfile in self.icons_files.items():
             if iconfile is None or self.text_only:
                 # Only warn the user that there's no icon if they haven't set text only mode
@@ -165,7 +170,7 @@ def setup_images(self):
             input_width = img.width
             input_height = img.height
 
-            sp = input_height / (self.bar.height - 4)
+            sp = input_height / (self._icon_size)
             width = int(input_width / sp)
 
             imgpat = cairocffi.SurfacePattern(img.surface)
@@ -248,8 +253,11 @@ def draw(self):
                 )
             else:
                 # display an icon
+                self.drawer.ctx.save()
+                self.drawer.ctx.translate(0, self._icon_padding + self.padding_y)
                 self.drawer.ctx.set_source(self.surfaces[name])
                 self.drawer.ctx.paint()
+                self.drawer.ctx.restore()
             self.drawer.draw(
                 offsetx=self.offset + xoffset,
                 offsety=self.offsety,


Test patch:
Repository: qtile/qtile

Issue:
[Wayland] Apps can't fullscreen automatically when opened
### The issue:

Apps that automatically open as fullscreen apps like games or mpv don't do so but open tiled not fullscreen. On X11 I don't have this problem but on the wayland side it is.

- qtile version: 0.22.1
- Can't find anything related in logs
- [my config](https://github.com/cronyakatsuki/dots/tree/main/.config/qtile) in case it's a problem with my configuration.

### Required:

- [x] I have searched past issues to see if this bug has already been reported.


Discussion:
Thanks for the report. Please could you give some other examples of apps that do this? For mpv (and celluloid) if I set `fullscreen=yes` in the mpv config windows still don't open in fullscreen, in both x11 and wayland. If an app requests to be fullscreen, does it correctly get fullscreened? For example firefox makes the request if you hit f11.
Yes when an app like firefox, mpv, games (like osu! with xwayland) request to be fullscreened while it's running it can fullscreen, but mpv for example with the option `fs` set in `~/.config/mpv/mpv.conf` will fuscreen on load in x11 but won't in wayland.
Xonotic for example won't to go fullscreen no matter what unless I forcibly fullscreen it with qtile.

Resolving patch:
diff --git a/libqtile/backend/wayland/xdgwindow.py b/libqtile/backend/wayland/xdgwindow.py
--- a/libqtile/backend/wayland/xdgwindow.py
+++ b/libqtile/backend/wayland/xdgwindow.py
@@ -68,6 +68,7 @@ def __init__(self, core: Core, qtile: Qtile, surface: XdgSurface):
         self.add_listener(surface.new_popup_event, self._on_new_popup)
         self.add_listener(surface.surface.commit_event, self._on_commit)
         self.add_listener(surface.surface.new_subsurface_event, self._on_new_subsurface)
+        self.add_listener(surface.toplevel.request_fullscreen_event, self._on_request_fullscreen)
 
     def finalize(self) -> None:
         Window.finalize(self)
@@ -106,9 +107,6 @@ def _on_map(self, _listener: Listener, _data: Any) -> None:
                 self.ftm_handle.set_app_id(self._wm_class or "")
 
             # Add the toplevel's listeners
-            self.add_listener(
-                surface.toplevel.request_fullscreen_event, self._on_request_fullscreen
-            )
             self.add_listener(surface.toplevel.set_title_event, self._on_set_title)
             self.add_listener(surface.toplevel.set_app_id_event, self._on_set_app_id)
             self.add_listener(


Test patch:
Repository: qtile/qtile

Issue:
`centre` doesn't centre window on correct screen.
Separate issue created from https://github.com/qtile/qtile/issues/2163#issuecomment-1218821651_:

> However, it has another issue - `cmd_center` doesn't seem to work correctly for my second monitor (the window always becomes centered on my left monitor). This is on X11. I can file a separate issue for this if it's not the intended behavior (unless I made a mistake in my code).

      


Discussion:

Resolving patch:
diff --git a/libqtile/backend/base.py b/libqtile/backend/base.py
--- a/libqtile/backend/base.py
+++ b/libqtile/backend/base.py
@@ -544,8 +544,8 @@ def center(self) -> None:
 
         screen = self.group.screen
 
-        x = (screen.width - self.width) // 2
-        y = (screen.height - self.height) // 2
+        x = screen.x + (screen.width - self.width) // 2
+        y = screen.y + (screen.height - self.height) // 2
 
         self.place(
             x,


Test patch:
diff --git a/test/test_window.py b/test/test_window.py
--- a/test/test_window.py
+++ b/test/test_window.py
@@ -1,6 +1,6 @@
 import pytest
 
-from test.conftest import BareConfig
+from test.conftest import BareConfig, dualmonitor
 from test.layouts.layout_utils import assert_focused
 from test.test_manager import ManagerConfig
 
@@ -200,6 +200,7 @@ def test_bring_front_click(manager, bring_front_click):
         assert wins.index(wids[0]) < wins.index(wids[1]) < wins.index(wids[2])
 
 
+@dualmonitor
 @bare_config
 def test_center_window(manager):
     """Check that floating windows are centered correctly."""
@@ -219,3 +220,15 @@ def test_center_window(manager):
     assert info["y"] == (600 - 100) / 2  # (screen height - window height) / 2
     assert info["width"] == 200
     assert info["height"] == 100
+
+    manager.c.window.togroup("b")  # Second screen
+    manager.c.to_screen(1)  # Focus screen
+    manager.c.group["b"].toscreen()  # Make sure group b is on that screen
+
+    # Second screen is 640x480 at offset (800, 0)
+    manager.c.window.center()
+    info = manager.c.window.info()
+    assert info["x"] == 800 + (640 - 200) / 2  # offset + (screen width - window width) / 2
+    assert info["y"] == (480 - 100) / 2  # (screen height - window height) / 2
+    assert info["width"] == 200
+    assert info["height"] == 100
Repository: qtile/qtile

Issue:
Outer Non-modal KeyChord in Nested Chain Not Aborted After Inner Key Is Pressed 
### The issue:

In previous versions of Qtile, when I press a key in the innermost layer of a nested keychord chain, all of the outer keychords in the chain would be exited. However recently (I believe it started when I updated to 0.22.1, but I didn't check at the beginning as I assumed I mispressed something). I have not changed my config recently (until today when I was trying to figure out what was going on).

Version: 0.22.1 installed with Pacman on Arch


## Minimal Config
An example minimal config that has a problematic KeyChord chain in it can be created by inserting the following into the default config file (https://docs.qtile.org/en/latest/manual/config/default.html#default-config):
In the imports section:
```python
import KeyChord
```
In the `keys` list:
```python
    KeyChord([mod], 'x', [
        Key([], 't', lazy.spawn(terminal)),
        KeyChord([], 'w', [
            Key([], 'w', lazy.spawn('firefox')),
            Key([], 'q', lazy.spawn('firefox https://docs.qtile.org/en/latest/manual/config/default.html#default-config')),
        ]),
    ]),
```
## Example 1: Outer Layer Does Not Abort
### Expected Behavior
Using this configuration I would expect `Super-x, w, w, t` to run `firefox` and send a 't' to the focused application (probably typing a 't' into the address bar of Firefox).
### Actual Behavior
Firefox is started, but rather than the `t` being sent to Firefox, a terminal window is launched.
## Example 2: Outer Layer Aborts After A Key on It's Level Is Pressed
### Expected Behavior
`Super-x, w, w, t, t` should launch Firefox and send 'tt' to it.
### Actual Behavior
Firefox is started, a terminal is started, and a 't' is typed into the terminal.

### Xephyr Note
When running this in Xephyr for me, firefox opens outside, but if the mouse and keyboard are grabbed you can still see that the terminal gets launched with the next press of `t`, I would have used another program that acts less weird, but I can't think of any other ubiquitous GUI programs.

### Required:

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


Discussion:
Thanks. There were some changes to KeyChords but this shouldn't have broken.

I'll test when I can and see if I can post a fix.
I tested the same configuration on a computer that had not been updated (it was on 21 still) and it did not have the problem. I then updated it to 0.22.1 and it had the problem.
I forgot to mention earlier, but I am running X11 not Wayland (on both computers).

Resolving patch:
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -473,7 +473,7 @@ def ungrab_chord(self) -> None:
         # Find another named mode or load the root keybindings:
         while self.chord_stack:
             chord = self.chord_stack.pop()
-            if chord.mode != "":
+            if chord.mode:
                 self.grab_chord(chord)
                 break
         else:


Test patch:
Repository: qtile/qtile

Issue:
simple_key_binder doesn't work after using a KeyChord
### The issue:

Qtile 0.22.1, in logs no errors or warns.
simple_key_binder doesn't work after using a KeyChord.
If I use simple_key_binder to generate Group switching keys, then Group switching does not work after using KeyChord. I am forced to do reload_config.
For the solution, I had to use: for i in Groups.
I see: https://github.com/qtile/qtile/issues/3734
My full config (correct) and line: https://github.com/Koljasha/archlinux/blob/7bef1b8d4d4fc972cdcbfa90453b5967ff739227/config/qtile/config.py#L279
For error: uncomment L279, comment L281-L290

### Required:

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


Discussion:
I had the same issue, and I did the same as you. I did not report it because I was in a hurry in that moment and I just forgot but now that I try to reuse the functionality I have to go through again into troubleshoot, al;so I found some other posts with the same problem on the internet. https://www.reddit.com/r/qtile/comments/r2nwmg/comment/hm5xqsd/  and https://www.reddit.com/r/qtile/comments/sip7wz/comment/hvacq2g/ and this https://github.com/qtile/qtile/issues/3734

EDITED: The codesti link was just scraped from github.

Resolving patch:
diff --git a/libqtile/dgroups.py b/libqtile/dgroups.py
--- a/libqtile/dgroups.py
+++ b/libqtile/dgroups.py
@@ -41,6 +41,7 @@ def func(dgroup):
         # unbind all
         for key in dgroup.keys[:]:
             dgroup.qtile.ungrab_key(key)
+            dgroup.qtile.config.keys.remove(key)
             dgroup.keys.remove(key)
 
         if keynames:
@@ -55,9 +56,8 @@ def func(dgroup):
             key = Key([mod], keyname, lazy.group[name].toscreen())
             key_s = Key([mod, "shift"], keyname, lazy.window.togroup(name))
             key_c = Key([mod, "control"], keyname, lazy.group.switch_groups(name))
-            dgroup.keys.append(key)
-            dgroup.keys.append(key_s)
-            dgroup.keys.append(key_c)
+            dgroup.keys.extend([key, key_s, key_c])
+            dgroup.qtile.config.keys.extend([key, key_s, key_c])
             dgroup.qtile.grab_key(key)
             dgroup.qtile.grab_key(key_s)
             dgroup.qtile.grab_key(key_c)


Test patch:
Repository: qtile/qtile

Issue:
Battery plugin error on Freebsd
### The issue:

When i try to use Battery widget on Freebsd 13.1 ive got the error
```
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/libqtile/core/manager.py", line 113, in load_config
    self.config.load()
  File "/usr/local/lib/python3.9/site-packages/libqtile/confreader.py", line 110, in load
    config = importlib.import_module(name)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/kobzar/.config/qtile/config.py", line 282, in <module>
    widget.Battery(
  File "/usr/local/lib/python3.9/site-packages/libqtile/widget/battery.py", line 335, in __init__
    self._battery = self._load_battery(**config)
  File "/usr/local/lib/python3.9/site-packages/libqtile/widget/battery.py", line 345, in _load_battery
    return load_battery(**config)
  File "/usr/local/lib/python3.9/site-packages/libqtile/widget/battery.py", line 99, in load_battery
    return _FreeBSDBattery(str(config["battery"]))
KeyError: 'battery'
```

So, i just change this value in battery.py widget
```
#return _FreeBSDBattery(str(config["battery"]))
return _FreeBSDBattery("0")
```
And now all look fine

### Required:

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


Discussion:

Resolving patch:
diff --git a/libqtile/widget/battery.py b/libqtile/widget/battery.py
--- a/libqtile/widget/battery.py
+++ b/libqtile/widget/battery.py
@@ -107,7 +107,7 @@ def load_battery(**config) -> _Battery:
     """
     system = platform.system()
     if system == "FreeBSD":
-        return _FreeBSDBattery(str(config["battery"]))
+        return _FreeBSDBattery(str(config.get("battery", 0)))
     elif system == "Linux":
         return _LinuxBattery(**config)
     else:


Test patch:
Repository: qtile/qtile

Issue:
hide_show_bar("all") errors when there are bar.Gap objects on any side
### The issue:

```
❯ qtile --version
0.22.1
```
If there are Gap objects on any side, and use the "all" option to toggle bar visibility with `hide_show_bar()` function, it throws an error warning.
For my case, I have a bar only on one side, bottom, and rest are `Gap`s, the `hide_show_bar()` function's default option "all".

logs from `~/.local/share/qtile/qtile.log`
```
2022-12-28 06:08:54,637 ERROR libqtile manager.py:process_key_event():L407 KB command error hide_show_bar: Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/libqtile/command/interface.py", line 312, in call
    return SUCCESS, cmd(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/libqtile/core/manager.py", line 1565, in cmd_hide_show_bar
    if is_show is None:
AttributeError: 'Gap' object has no attribute 'is_show'
```
For the key press event, I'm using this in my config, since "all" is default
`Key([mod], "b", lazy.hide_show_bar(), desc="Toggle bar visibility")`
Instead of using the `if bar:` condition, checking if the bar is an actual bar object or not resolves the issue.
```
for bar in [screen.left, screen.right, screen.top, screen.bottom]:
#if bar:                                ## the original condition
if isinstance(bar, libqtile.bar.Bar):
    if is_show is None:
        is_show = not bar.is_show()
    bar.show(is_show)
```
I don't know if this is meant to be as is for bars on all sides only, but I think this way, you wouldn't have to toggle each bar one at a time either.

### Required:

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


Discussion:
Thanks. Agreed that this looks like a bug. I can submit your fix as a PR later unless you'd like to do it yourself.

Resolving patch:
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -1663,7 +1663,7 @@ def hide_show_bar(
             screen = self.current_screen
             is_show = None
             for bar in [screen.left, screen.right, screen.top, screen.bottom]:
-                if bar:
+                if isinstance(bar, libqtile.bar.Bar):
                     if is_show is None:
                         is_show = not bar.is_show()
                     bar.show(is_show)


Test patch:
Repository: qtile/qtile

Issue:
Wayland: `get_inputs` command reports type:pointer instead of type:trackpad for trackpads
### The issue:

Perhaps other input device types are being incorrectly reported.

### Required:

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


Discussion:

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
@@ -25,6 +25,7 @@
 import os
 import time
 import typing
+from collections import defaultdict
 
 import pywayland
 import pywayland.server
@@ -1286,26 +1287,18 @@ def unhide_cursor(self) -> None:
     @expose_command()
     def get_inputs(self) -> dict[str, list[dict[str, str]]]:
         """Get information on all input devices."""
-        info = {}
-        device_lists: dict[str, list[inputs._Device]] = {
-            "type:keyboard": self.keyboards,  # type: ignore
-            "type:pointer": self._pointers,  # type: ignore
-        }
-
-        for type_key, devices in device_lists.items():
-            type_info = []
-
-            for dev in devices:
-                type_info.append(
-                    dict(
-                        name=dev.wlr_device.name,
-                        identifier=dev.get_info()[1],
-                    )
-                )
-
-            info[type_key] = type_info
+        info: defaultdict[str, list[dict]] = defaultdict(list)
+        devices: list[inputs._Device] = self.keyboards + self._pointers  # type: ignore
+
+        for dev in devices:
+            type_key, identifier = dev.get_info()
+            type_info = dict(
+                name=dev.wlr_device.name,
+                identifier=identifier,
+            )
+            info[type_key].append(type_info)
 
-        return info
+        return dict(info)
 
     def get_mouse_position(self) -> tuple[int, int]:
         """Get mouse coordinates."""


Test patch: