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

Issue:
qtile version
As we ask users to say version during posting new issue, it would be better to have git version included. Especially in latest version.
It could be in format: 
```
$ qtile --version
0.15.0 (3449.01b0bc06)
```



Discussion:
It's not clear to me how to get setuptools to do this, but yes, that would be great.
What about [setuptools_scm](https://pypi.org/project/setuptools-scm/)? You get something like ``0.15.1.dev59+gde942288`` for the test code airwoodix@de94228 (so 59 commits past the last tag `0.15.1`, versioned with git, SHA ``de942288``). The output is in principle customizable but one should stick to [PEP440](https://www.python.org/dev/peps/pep-0440/).
I think @airwoodix given `setuptools_scm` is the way to go. Tested the diff, got `0.15.1.dev65+g1d7b4c5a.d20200429`. I think it is all what we need. Can you @airwoodix make a PR? Just it would be grate to use that in docs build, too. Maybe write version to file, we could reuse it all around as `from libqtile.version import version` or something similar. 

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -12,6 +12,7 @@
 # serve to show the default.
 
 import os
+import setuptools_scm
 import sys
 from unittest.mock import MagicMock
 
@@ -97,7 +98,7 @@ def __dir__(self):
 # built documents.
 #
 # The short X.Y version.
-version = '0.15.0'
+version = setuptools_scm.get_version(root="..")
 # The full version, including alpha/beta/rc tags.
 release = version
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -90,6 +90,7 @@ def get_cffi_modules():
 
 setup(
     cmdclass={'install': CheckCairoXcb},
+    use_scm_version=True,
     cffi_modules=get_cffi_modules(),
     install_requires=["cffi>=1.0.0"],
 )


Test patch:
Repository: qtile/qtile

Issue:
RTD doesn't run script/ffibuild
```
[rtd-command-info] start-time: 2020-04-30T03:23:17.858528Z, end-time: 2020-04-30T03:23:31.649069Z, duration: 13, exit-code: 0
python /home/docs/checkouts/readthedocs.org/user_builds/qtile/envs/latest/bin/sphinx-build -T -E -b readthedocs -d _build/doctrees-readthedocs -D language=en . _build/html
Running Sphinx v1.8.5
loading translations [en]... done
Unmet dependencies for '.widget.pulse_volume.PulseVolume': No module named 'libqtile.widget._pulse_audio'
building pango
python: can't open file './libqtile/pango_ffi_build.py': [Errno 2] No such file or directory
building xcursors
python: can't open file './libqtile/backend/x11/xcursors_ffi_build.py': [Errno 2] No such file or directory
building pulseaudio volume control
python: can't open file './libqtile/widget/pulseaudio_ffi.py': [Errno 2] No such file or directory
```


Discussion:

Resolving patch:
diff --git a/docs/sphinx_qtile.py b/docs/sphinx_qtile.py
--- a/docs/sphinx_qtile.py
+++ b/docs/sphinx_qtile.py
@@ -201,8 +201,8 @@ def make_rst(self):
 
 def generate_keybinding_images():
     this_dir = os.path.dirname(__file__)
-    ffibuild_path = os.path.abspath(os.path.join(this_dir, "..", "scripts", "ffibuild"))
-    call([ffibuild_path])
+    base_dir = os.path.abspath(os.path.join(this_dir, ".."))
+    call(['make', '-C', base_dir, 'run-ffibuild'])
     call(['make', '-C', this_dir, 'genkeyimg'])
 
 


Test patch:
Repository: qtile/qtile

Issue:
Current desktop not properly set when switching to a group on another screen
If i just move the mouse between monitors, the group on the screen from the new monitor does get focus but something's not being set properly and `rofi -modi windowcd -show windowcd` still shows the windows from the previously active group.

However, if I manually click on the currently active group displayed in the GroupBox widget then everything works as expected afterwards and the windows from that group are shown by the same rofi command that I have bound to _alt-`_.

So it seems to me that this is an issue with how qtile handles changing the current desktop when switching focus to a group on another screen and not something wrong with rofi itself.

I'm still on version 0.14.2 because the latest one still doesn't play nice with jetbrains products I use for work everyday.


Discussion:

Resolving patch:
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -822,6 +822,7 @@ def focus_screen(self, n, warp=True):
         self.current_screen = self.screens[n]
         if old != self.current_screen:
             hook.fire("current_screen_change")
+            hook.fire("setgroup")
             old.group.layout_all()
             self.current_group.focus(self.current_window, warp)
 


Test patch:
Repository: qtile/qtile

Issue:
using deprecated asyncio api
  /home/travis/build/qtile/qtile/libqtile/core/manager.py:263: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
999    self._stopped_event = asyncio.Event(loop=self._eventloop)


Discussion:

Resolving patch:
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -238,7 +238,7 @@ def setup_eventloop(self) -> None:
         logger.debug('Adding io watch')
         self.core.setup_listener(self, self._eventloop)
 
-        self._stopped_event = asyncio.Event(loop=self._eventloop)
+        self._stopped_event = asyncio.Event()
 
         # This is a little strange. python-dbus internally depends on gobject,
         # so gobject's threads need to be running, and a gobject "main loop


Test patch:
Repository: qtile/qtile

Issue:
Missing content on docs.qtile.org
The documentation for extensions and widgets seems to be missing from http://docs.qtile.org/en/latest/manual/ref/extensions.html since today.

# Qtile version

I am fairly sure that the documentation was still working yesterday, at the very least the day before.

Can andybody confirm this?


Discussion:
On my phone right now, but it looks like builds should be working:

https://readthedocs.org/projects/qtile/builds/

On Thu, May 14, 2020, 2:08 PM tcld <notifications@github.com> wrote:

> The documentation for extensions and widgets seems to be missing from
> http://docs.qtile.org/en/latest/manual/ref/extensions.html since today.
> Qtile version
>
> I am fairly sure that the documentation was still working yesterday, at
> the very least the day before.
>
> Can andybody confirm this?
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/qtile/qtile/issues/1731>, or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAF7VV45WCALJMZZGB7J7WDRRRFS5ANCNFSM4NA7YVAQ>
> .
>


Resolving patch:
diff --git a/docs/sphinx_qtile.py b/docs/sphinx_qtile.py
--- a/docs/sphinx_qtile.py
+++ b/docs/sphinx_qtile.py
@@ -182,8 +182,8 @@ def make_rst(self):
 
         for item in dir(module):
             obj = import_object(self.arguments[0], item)
-            if not inspect.isclass(obj) and (BaseClass and
-                not isinstance(obj, BaseClass)):
+            if not inspect.isclass(obj) or (BaseClass and
+                not issubclass(obj, BaseClass)):
                 continue
 
             context = {
diff --git a/libqtile/utils.py b/libqtile/utils.py
--- a/libqtile/utils.py
+++ b/libqtile/utils.py
@@ -21,6 +21,7 @@
 import functools
 import importlib
 import os
+import sys
 import traceback
 import warnings
 from shutil import which
@@ -197,6 +198,9 @@ def safe_import(module_names, class_name, globals_, fallback=None):
 
     The globals are filled with a proxy function so that the module is imported
     only if the class is being instanciated.
+
+    An exception is made when the documentation is being built with Sphinx, in
+    which case the class is eagerly imported, for inspection.
     """
     module_path = '.'.join(module_names)
     if type(class_name) is list:
@@ -208,7 +212,10 @@ def class_proxy(*args, **kwargs):
         cls = import_class(module_path, class_name, fallback)
         return cls(*args, **kwargs)
 
-    globals_[class_name] = class_proxy
+    if "sphinx" in sys.modules:
+        globals_[class_name] = import_class(module_path, class_name, fallback)
+    else:
+        globals_[class_name] = class_proxy
 
 
 def send_notification(title, message, urgent=False, timeout=10000):


Test patch:
Repository: qtile/qtile

Issue:
Cannot input in gmrun window
This commit 0f886606e1f35226b325f5405d43946976eae831 introduced a bug for `gmrun` windows at least. When spawning, one cannot input text into it. This is fixed by unfloating the window, and continues to work even when refloating it.

Window properties:

```
_NET_WM_USER_TIME(CARDINAL) = 5511537
_NET_WM_DESKTOP(CARDINAL) = 1
WM_STATE(WM_STATE):
		window state: Normal
		icon window: 0x0
WM_HINTS(WM_HINTS):
		Client accepts input or input focus: True
		Initial state is Normal State.
		window id # of group leader: 0x1c00001
XdndAware(ATOM) = BITMAP
_MOTIF_DRAG_RECEIVER_INFO(_MOTIF_DRAG_RECEIVER_INFO) = 0x6c, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x2, 0x0, 0x0
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 29360133
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DIALOG
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x1c00004
WM_CLIENT_LEADER(WINDOW): window id # 0x1c00001
_NET_WM_PID(CARDINAL) = 64030
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLIENT_MACHINE(STRING) = "corsair"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
		program specified location: 0, 0
		program specified minimum size: 412 by 75
		program specified maximum size: 412 by 75
		window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "gmrun", "Gmrun"
WM_ICON_NAME(STRING) = "Execute program feat. completion"
_NET_WM_ICON_NAME(UTF8_STRING) = "Execute program feat. completion"
WM_NAME(STRING) = "Execute program feat. completion"
_NET_WM_NAME(UTF8_STRING) = "Execute program feat. completion"
```

Just tell me if you need logs and I'll add some!


Discussion:

Resolving patch:
diff --git a/libqtile/layout/floating.py b/libqtile/layout/floating.py
--- a/libqtile/layout/floating.py
+++ b/libqtile/layout/floating.py
@@ -209,6 +209,10 @@ def compute_client_position(self, client, screen):
         return above
 
     def configure(self, client, screen):
+        # After this, the client will be mapped. Either this will do it, or the
+        # client has already done it.
+        client.hidden = False
+
         # 'sun-awt-X11-XWindowPeer' is a dropdown used in Java application,
         # don't reposition it anywhere, let Java app to control it
         cls = client.window.get_wm_class() or ''


Test patch:
Repository: qtile/qtile

Issue:
widget.CheckUpdates not hidden when no updates are available
<!--
Please do not ask general questions here! There are [community
contact](https://github.com/qtile/qtile#community) options for that.
-->

# Issue description

<!--
A brief discussion of what failed and how it failed. A description of
what you tried is helpful, i.e. "When I use lazy.kill() on a window I get
the following stack trace" instead of "Closing windows doesn't work".
-->

The documentation for [`CheckUpdates`](http://docs.qtile.org/en/latest/manual/ref/widgets.html#checkupdates) `display_format` mentions that the given format-specifier will only be used when there are updates available - giving rise to the assumption that the widget would be invisible when no updates are available (which seems very reasonable).

This doesn't seem to be the case for me, though. I am permanently seeing a `0`. So either the documentation or the implementation might need a little tweak.

# Qtile version

<!--
Please include the exact commit hash of the version of Qtile that failed.
-->

0.15.1


Discussion:

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
@@ -75,7 +75,11 @@ def _check_updates(self):
                 self.subtr = 0
         except CalledProcessError:
             updates = ""
-        num_updates = str(len(updates.splitlines()) - self.subtr)
+        num_updates = len(updates.splitlines()) - self.subtr
+
+        if num_updates == 0:
+            return ""
+        num_updates = str(num_updates)
 
         if self.restart_indicator and os.path.exists('/var/run/reboot-required'):
             num_updates += self.restart_indicator


Test patch:
Repository: qtile/qtile

Issue:
Leaving group with fullscreen window and then returning to it is broken
# Description

When I create a fullscreen window in a group, and then change to another group
and back to the original group, the fullscreen window is no longer rendered. Functionality
for the window is still there, however. E.g. when running a zoom ;) conversation in
fullscreen mode, the audio part of the conversation continues whereas window containing
the video does not render. Clearly the window (and it's functionality) is still someplace,
just not rendered.

Other applications also exhibit this behavior when used in fullscreen mode. Another example
is chromium (enter fullscreen mode with F11).

# Commit hash

This behavior manifests itself with current git, master branch. I bisected the issue,
and the last good commit that does not exhibit this behavior is: 52d787944ebb669d5e90d7d372648e539034c271.

# Stack traces
No stack traces were thrown.


Discussion:

Resolving patch:
diff --git a/libqtile/layout/floating.py b/libqtile/layout/floating.py
--- a/libqtile/layout/floating.py
+++ b/libqtile/layout/floating.py
@@ -209,25 +209,24 @@ def compute_client_position(self, client, screen):
         return above
 
     def configure(self, client, screen):
-        # After this, the client will be mapped. Either this will do it, or the
-        # client has already done it.
-        client.hidden = False
-
         # 'sun-awt-X11-XWindowPeer' is a dropdown used in Java application,
         # don't reposition it anywhere, let Java app to control it
         cls = client.window.get_wm_class() or ''
         is_java_dropdown = 'sun-awt-X11-XWindowPeer' in cls
         if is_java_dropdown:
+            client.unhide()
             return
 
         # similar to above but the X11 version, the client may have already
         # placed itself. let's respect that
         if client.has_user_set_position():
+            client.unhide()
             return
 
         # ok, it's not java and the window itself didn't position it, but users
         # may still have asked us not to mess with it
         if self.no_reposition_match is not None and self.no_reposition_match.compare(client):
+            client.unhide()
             return
 
         if client.has_focus:


Test patch:
Repository: qtile/qtile

Issue:
Qtile screens not updating on restart after changing number of monitors
# Issue description

When I unplug a third monitor from my laptop (and have xrandr run automatically via udev) and then restart qtile, I still see in my status bar the third screen being present (3 of my groups are highlighted as if they are on a screen).  Also, my hotkeys for switching screens still behave as if this third screen exists.  

This happens even with a default qtile config.  I don't see any relevant lines in the qtile logs that would suggest a problem with the reset; it's as if this is intended behavior?

I was also using this tip: http://docs.qtile.org/en/latest/manual/ref/hooks.html#libqtile.hook.subscribe.screen_change to have qtile update to the correct number of screens on unplug, but was having a strange issue where every time a monitor was plugged in/unplugged my qtile would freeze for 1-3 minutes before resetting and working properly.  I stopped using this because of this slowness, but now I have this current issue.  Is there a difference between the restart command here and the lazy.restart() that is used by the default config's keybindings?

# Qtile version

commit b82c7c36b8e4ffe5ccb009c22f8c197ec5532dfe 
Author: Sean Vig <sean.v.775@gmail.com>
Date:   Mon Apr 27 22:31:53 2020 -0400

    Use additional async functionality
    
    Move more of the setup functionality into async. I think it'd be great if
    nothing needed to be passed a loop in the constructor and all of the async
    initialization could be called in async tasks, which would then be able to
    automatically get the running loop. Some additional refactoring could help
    with this. This may set us on a path that the Qtile object can be easily
    re-made from within the session manager if we can pull out enough of the
    direct loop handling from that.
    
    Closes #1689


Discussion:
Is there a way to completely purge/delete all qtile state relating to screens on restart (and refresh it as if qtile just started for the first time)?  I'm thinking this might solve my issues here.

Resolving patch:
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -186,6 +186,9 @@ def noop(qtile):
                 logger.exception("failed restoring state")
 
         self.core.scan()
+        if state:
+            for screen in self.screens:
+                screen.group.layout_all()
         self.update_net_desktops()
         hook.subscribe.setgroup(self.update_net_desktops)
 


Test patch:
Repository: qtile/qtile

Issue:
configure() in libqtile.backend.x11.xcbq is not robust
<!--
Please do not ask general questions here! There are [community
contact](https://github.com/qtile/qtile#community) options for that.
-->

# Issue description

The function is not robust, as it breaks on xcffib declaring a version with patch level:
https://github.com/qtile/qtile/blob/464bf7f191e800bcb8a075d465841cde81bc15f8/libqtile/backend/x11/xcbq.py#L619-L628

# Qtile version

0.16.1

# Stack traces

Testing breaks on this:

```
>           raise AssertionError("Error launching Qtile, traceback:\n%s" % error)
E           AssertionError: Error launching Qtile, traceback:
E           Traceback (most recent call last):
E             File "/build/qtile/src/qtile-0.16.1/test/conftest.py", line 286, in run_qtile
E               q = SessionManager(kore, config_class(), fname=self.sockfile)
E             File "/build/qtile/src/qtile-0.16.1/libqtile/core/session_manager.py", line 31, in __init__
E               self.qtile = Qtile(kore, config, self.eventloop, no_spawn=no_spawn, state=state)
E             File "/build/qtile/src/qtile-0.16.1/libqtile/core/manager.py", line 161, in __init__
E               self._process_screens()
E             File "/build/qtile/src/qtile-0.16.1/libqtile/core/manager.py", line 352, in _process_screens
E               scr._configure(
E             File "/build/qtile/src/qtile-0.16.1/libqtile/config.py", line 289, in _configure
E               i._configure(qtile, self)
E             File "/build/qtile/src/qtile-0.16.1/libqtile/bar.py", line 208, in _configure
E               self.window = window.Internal.create(
E             File "/build/qtile/src/qtile-0.16.1/libqtile/window.py", line 688, in create
E               i.place(x, y, width, height, 0, None)
E             File "/build/qtile/src/qtile-0.16.1/libqtile/window.py", line 492, in place
E               self.window.configure(**kwarg)
E             File "/build/qtile/src/qtile-0.16.1/libqtile/backend/x11/xcbq.py", line 623, in configure
E               if float(xcffib.__xcb_proto_version__) < 1.12:
E           ValueError: could not convert string to float: '1.14.1'
```
# Configuration

n/a



Discussion:

Resolving patch:
diff --git a/libqtile/backend/x11/xcbq.py b/libqtile/backend/x11/xcbq.py
--- a/libqtile/backend/x11/xcbq.py
+++ b/libqtile/backend/x11/xcbq.py
@@ -623,7 +623,7 @@ def configure(self, **kwargs):
         mask, values = ConfigureMasks(**kwargs)
         # older versions of xcb pack everything into unsigned ints "=I"
         # since 1.12, uses switches to pack things sensibly
-        if float(xcffib.__xcb_proto_version__) < 1.12:
+        if float(".".join(xcffib.__xcb_proto_version__.split(".")[0: 2])) < 1.12:
             values = [i & 0xffffffff for i in values]
         return self.conn.conn.core.ConfigureWindow(self.wid, mask, values)
 


Test patch:
Repository: qtile/qtile

Issue:
Erratic layout change on desktop switch
# Issue description

I have experimented the same issue described in #1945 but I guess this is more general trouble around  EWMH/NetWM interactions. If I use [wmctrl](http://tripie.sweb.cz/utils/wmctrl/) to try to interact with qtile, it regularly causes layout change on current desktop.

More precisely, if I try to switch desktop, it switched layout and not desktop : `wmctrl -s 1` don't navigate to desktop 1 but change to the second layout available (index 1). 

# Qtile version

Latest stable, from Archlinux repository.

I have not included stack trace nor my configuration as I guess it's not relevant here (multiple groups and layouts activated, no errors) but please let me know if I'm wrong.

That said, if I use `wmctrl -s 9` for example, I got a trace

```
2020-11-19 15:56:07,284 ERROR libqtile xcore.py:_xpoll():L277 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/libqtile/backend/x11/xcore.py", line 245, in _xpoll
    ret = target(event)
  File "/usr/lib/python3.8/site-packages/libqtile/backend/x11/xcore.py", line 528, in handle_ClientMessage
    self.qtile.cmd_to_layout_index(index)
  File "/usr/lib/python3.8/site-packages/libqtile/core/manager.py", line 1059, in cmd_to_layout_index
    group.use_layout(index)
  File "/usr/lib/python3.8/site-packages/libqtile/group.py", line 129, in use_layout
    assert 0 <= index < len(self.layouts), "layout index out of bounds"
AssertionError: layout index out of bounds
```
And thanks for this awesome piece of work ;)


Discussion:
Can you xtrace it? I'm not sure exactly what these things are sending.

Resolving patch:
diff --git a/libqtile/backend/x11/xcore.py b/libqtile/backend/x11/xcore.py
--- a/libqtile/backend/x11/xcore.py
+++ b/libqtile/backend/x11/xcore.py
@@ -535,7 +535,7 @@ def handle_ClientMessage(self, event) -> None:  # noqa: N802
         if atoms["_NET_CURRENT_DESKTOP"] == opcode:
             index = data.data32[0]
             try:
-                self.qtile.cmd_to_layout_index(index)
+                self.qtile.groups[index].cmd_toscreen()
             except IndexError:
                 logger.info("Invalid Desktop Index: %s" % index)
 


Test patch: