We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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!

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `libqtile/layout/floating.py`
Content:
```
1 # Copyright (c) 2010 matt
2 # Copyright (c) 2010-2011 Paul Colomiets
3 # Copyright (c) 2011 Mounier Florian
4 # Copyright (c) 2012 Craig Barnes
5 # Copyright (c) 2012, 2014-2015 Tycho Andersen
6 # Copyright (c) 2013 Tao Sauvage
7 # Copyright (c) 2013 Julien Iguchi-Cartigny
8 # Copyright (c) 2014 ramnes
9 # Copyright (c) 2014 Sean Vig
10 # Copyright (c) 2014 dequis
11 # Copyright (c) 2018 Nazar Mokrynskyi
12 #
13 # Permission is hereby granted, free of charge, to any person obtaining a copy
14 # of this software and associated documentation files (the "Software"), to deal
15 # in the Software without restriction, including without limitation the rights
16 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 # copies of the Software, and to permit persons to whom the Software is
18 # furnished to do so, subject to the following conditions:
19 #
20 # The above copyright notice and this permission notice shall be included in
21 # all copies or substantial portions of the Software.
22 #
23 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 # SOFTWARE.
30 
31 from libqtile.layout.base import Layout
32 
33 DEFAULT_FLOAT_WM_TYPES = set([
34     'utility',
35     'notification',
36     'toolbar',
37     'splash',
38     'dialog',
39 ])
40 
41 DEFAULT_FLOAT_RULES = [
42     {"role": "About"},
43     {"wmclass": "file_progress"},
44 ]
45 
46 
47 class Floating(Layout):
48     """
49     Floating layout, which does nothing with windows but handles focus order
50     """
51     defaults = [
52         ("border_focus", "#0000ff", "Border colour for the focused window."),
53         ("border_normal", "#000000", "Border colour for un-focused windows."),
54         ("border_width", 1, "Border width."),
55         ("max_border_width", 0, "Border width for maximize."),
56         ("fullscreen_border_width", 0, "Border width for fullscreen."),
57         ("name", "floating", "Name of this layout."),
58         (
59             "auto_float_types",
60             DEFAULT_FLOAT_WM_TYPES,
61             "default wm types to automatically float"
62         ),
63     ]
64 
65     def __init__(self, float_rules=None, no_reposition_match=None, **config):
66         """
67         If you have certain apps that you always want to float you can provide
68         ``float_rules`` to do so. ``float_rules`` is a list of
69         dictionaries containing some or all of the keys::
70 
71             {'wname': WM_NAME, 'wmclass': WM_CLASS, 'role': WM_WINDOW_ROLE}
72 
73         The keys must be specified as above.  You only need one, but
74         you need to provide the value for it.  When a new window is
75         opened it's ``match`` method is called with each of these
76         rules.  If one matches, the window will float.  The following
77         will float gimp and skype::
78 
79             float_rules=[dict(wmclass="skype"), dict(wmclass="gimp")]
80 
81         Specify these in the ``floating_layout`` in your config.
82 
83         Floating layout will try to center most of floating windows by default,
84         but if you don't want this to happen for certain windows that are
85         centered by mistake, you can use ``no_reposition_match`` option to
86         specify them and layout will rely on windows to position themselves in
87         correct location on the screen.
88         """
89         Layout.__init__(self, **config)
90         self.clients = []
91         self.focused = None
92         self.group = None
93         self.float_rules = float_rules or DEFAULT_FLOAT_RULES
94         self.no_reposition_match = no_reposition_match
95         self.add_defaults(Floating.defaults)
96 
97     def match(self, win):
98         """Used to default float some windows"""
99         if win.window.get_wm_type() in self.auto_float_types:
100             return True
101         for rule_dict in self.float_rules:
102             if win.match(**rule_dict):
103                 return True
104         return False
105 
106     def find_clients(self, group):
107         """Find all clients belonging to a given group"""
108         return [c for c in self.clients if c.group is group]
109 
110     def to_screen(self, group, new_screen):
111         """Adjust offsets of clients within current screen"""
112         for win in self.find_clients(group):
113             if win.maximized:
114                 win.maximized = True
115             elif win.fullscreen:
116                 win.fullscreen = True
117             else:
118                 # catch if the client hasn't been configured
119                 try:
120                     # By default, place window at same offset from top corner
121                     new_x = new_screen.x + win.float_x
122                     new_y = new_screen.y + win.float_y
123                 except AttributeError:
124                     # this will be handled in .configure()
125                     pass
126                 else:
127                     # make sure window isn't off screen left/right...
128                     new_x = min(new_x, new_screen.x + new_screen.width - win.width)
129                     new_x = max(new_x, new_screen.x)
130                     # and up/down
131                     new_y = min(new_y, new_screen.y + new_screen.height - win.height)
132                     new_y = max(new_y, new_screen.y)
133 
134                     win.x = new_x
135                     win.y = new_y
136             win.group = new_screen.group
137 
138     def focus_first(self, group=None):
139         if group is None:
140             clients = self.clients
141         else:
142             clients = self.find_clients(group)
143 
144         if clients:
145             return clients[0]
146 
147     def focus_next(self, win):
148         if win not in self.clients or win.group is None:
149             return
150 
151         clients = self.find_clients(win.group)
152         idx = clients.index(win)
153         if len(clients) > idx + 1:
154             return clients[idx + 1]
155 
156     def focus_last(self, group=None):
157         if group is None:
158             clients = self.clients
159         else:
160             clients = self.find_clients(group)
161 
162         if clients:
163             return clients[-1]
164 
165     def focus_previous(self, win):
166         if win not in self.clients or win.group is None:
167             return
168 
169         clients = self.find_clients(win.group)
170         idx = clients.index(win)
171         if idx > 0:
172             return clients[idx - 1]
173 
174     def focus(self, client):
175         self.focused = client
176 
177     def blur(self):
178         self.focused = None
179 
180     def compute_client_position(self, client, screen):
181         """ recompute client.x and client.y, returning whether or not to place
182         this client above other windows or not """
183         above = False
184         transient_for = client.window.get_wm_transient_for()
185         win = client.group.qtile.windows_map.get(transient_for)
186         if win is not None:
187             # if transient for a window, place in the center of the window
188             center_x = win.x + win.width / 2
189             center_y = win.y + win.height / 2
190         else:
191             center_x = screen.x + screen.width / 2
192             center_y = screen.y + screen.height / 2
193             above = True
194 
195         x = center_x - client.width / 2
196         y = center_y - client.height / 2
197 
198         # don't go off the right...
199         x = min(x, screen.x + screen.width)
200         # or left...
201         x = max(x, screen.x)
202         # or bottom...
203         y = min(y, screen.y + screen.height)
204         # or top
205         y = max(y, screen.y)
206 
207         client.x = int(round(x))
208         client.y = int(round(y))
209         return above
210 
211     def configure(self, client, screen):
212         # 'sun-awt-X11-XWindowPeer' is a dropdown used in Java application,
213         # don't reposition it anywhere, let Java app to control it
214         cls = client.window.get_wm_class() or ''
215         is_java_dropdown = 'sun-awt-X11-XWindowPeer' in cls
216         if is_java_dropdown:
217             return
218 
219         # similar to above but the X11 version, the client may have already
220         # placed itself. let's respect that
221         if client.has_user_set_position():
222             return
223 
224         # ok, it's not java and the window itself didn't position it, but users
225         # may still have asked us not to mess with it
226         if self.no_reposition_match is not None and self.no_reposition_match.compare(client):
227             return
228 
229         if client.has_focus:
230             bc = client.group.qtile.color_pixel(self.border_focus)
231         else:
232             bc = client.group.qtile.color_pixel(self.border_normal)
233         if client.maximized:
234             bw = self.max_border_width
235         elif client.fullscreen:
236             bw = self.fullscreen_border_width
237         else:
238             bw = self.border_width
239         above = False
240 
241         # We definitely have a screen here, so let's be sure we'll float on screen
242         try:
243             client.float_x
244             client.float_y
245         except AttributeError:
246             # this window hasn't been placed before, let's put it in a sensible spot
247             above = self.compute_client_position(client, screen)
248 
249         client.place(
250             client.x,
251             client.y,
252             client.width,
253             client.height,
254             bw,
255             bc,
256             above,
257         )
258         client.unhide()
259 
260     def add(self, client):
261         self.clients.append(client)
262         self.focused = client
263 
264     def remove(self, client):
265         if client not in self.clients:
266             return
267 
268         next_focus = self.focus_next(client)
269         if client is self.focused:
270             self.blur()
271         self.clients.remove(client)
272         return next_focus
273 
274     def info(self):
275         d = Layout.info(self)
276         d["clients"] = [c.name for c in self.clients]
277         return d
278 
279     def cmd_next(self):
280         # This can't ever be called, but implement the abstract method
281         pass
282 
283     def cmd_previous(self):
284         # This can't ever be called, but implement the abstract method
285         pass
286
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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 @@
         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 ''

{"golden_diff": "diff --git a/libqtile/layout/floating.py b/libqtile/layout/floating.py\n--- a/libqtile/layout/floating.py\n+++ b/libqtile/layout/floating.py\n@@ -209,6 +209,10 @@\n         return above\n \n     def configure(self, client, screen):\n+        # After this, the client will be mapped. Either this will do it, or the\n+        # client has already done it.\n+        client.hidden = False\n+\n         # 'sun-awt-X11-XWindowPeer' is a dropdown used in Java application,\n         # don't reposition it anywhere, let Java app to control it\n         cls = client.window.get_wm_class() or ''\n", "issue": "Cannot input in gmrun window\nThis 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.\r\n\r\nWindow properties:\r\n\r\n```\r\n_NET_WM_USER_TIME(CARDINAL) = 5511537\r\n_NET_WM_DESKTOP(CARDINAL) = 1\r\nWM_STATE(WM_STATE):\r\n\t\twindow state: Normal\r\n\t\ticon window: 0x0\r\nWM_HINTS(WM_HINTS):\r\n\t\tClient accepts input or input focus: True\r\n\t\tInitial state is Normal State.\r\n\t\twindow id # of group leader: 0x1c00001\r\nXdndAware(ATOM) = BITMAP\r\n_MOTIF_DRAG_RECEIVER_INFO(_MOTIF_DRAG_RECEIVER_INFO) = 0x6c, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0\r\n_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x2, 0x0, 0x0\r\n_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 29360133\r\n_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DIALOG\r\n_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x1c00004\r\nWM_CLIENT_LEADER(WINDOW): window id # 0x1c00001\r\n_NET_WM_PID(CARDINAL) = 64030\r\nWM_LOCALE_NAME(STRING) = \"en_US.UTF-8\"\r\nWM_CLIENT_MACHINE(STRING) = \"corsair\"\r\nWM_NORMAL_HINTS(WM_SIZE_HINTS):\r\n\t\tprogram specified location: 0, 0\r\n\t\tprogram specified minimum size: 412 by 75\r\n\t\tprogram specified maximum size: 412 by 75\r\n\t\twindow gravity: NorthWest\r\nWM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST\r\nWM_CLASS(STRING) = \"gmrun\", \"Gmrun\"\r\nWM_ICON_NAME(STRING) = \"Execute program feat. completion\"\r\n_NET_WM_ICON_NAME(UTF8_STRING) = \"Execute program feat. completion\"\r\nWM_NAME(STRING) = \"Execute program feat. completion\"\r\n_NET_WM_NAME(UTF8_STRING) = \"Execute program feat. completion\"\r\n```\r\n\r\nJust tell me if you need logs and I'll add some!\n", "before_files": [{"content": "# Copyright (c) 2010 matt\n# Copyright (c) 2010-2011 Paul Colomiets\n# Copyright (c) 2011 Mounier Florian\n# Copyright (c) 2012 Craig Barnes\n# Copyright (c) 2012, 2014-2015 Tycho Andersen\n# Copyright (c) 2013 Tao Sauvage\n# Copyright (c) 2013 Julien Iguchi-Cartigny\n# Copyright (c) 2014 ramnes\n# Copyright (c) 2014 Sean Vig\n# Copyright (c) 2014 dequis\n# Copyright (c) 2018 Nazar Mokrynskyi\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom libqtile.layout.base import Layout\n\nDEFAULT_FLOAT_WM_TYPES = set([\n    'utility',\n    'notification',\n    'toolbar',\n    'splash',\n    'dialog',\n])\n\nDEFAULT_FLOAT_RULES = [\n    {\"role\": \"About\"},\n    {\"wmclass\": \"file_progress\"},\n]\n\n\nclass Floating(Layout):\n    \"\"\"\n    Floating layout, which does nothing with windows but handles focus order\n    \"\"\"\n    defaults = [\n        (\"border_focus\", \"#0000ff\", \"Border colour for the focused window.\"),\n        (\"border_normal\", \"#000000\", \"Border colour for un-focused windows.\"),\n        (\"border_width\", 1, \"Border width.\"),\n        (\"max_border_width\", 0, \"Border width for maximize.\"),\n        (\"fullscreen_border_width\", 0, \"Border width for fullscreen.\"),\n        (\"name\", \"floating\", \"Name of this layout.\"),\n        (\n            \"auto_float_types\",\n            DEFAULT_FLOAT_WM_TYPES,\n            \"default wm types to automatically float\"\n        ),\n    ]\n\n    def __init__(self, float_rules=None, no_reposition_match=None, **config):\n        \"\"\"\n        If you have certain apps that you always want to float you can provide\n        ``float_rules`` to do so. ``float_rules`` is a list of\n        dictionaries containing some or all of the keys::\n\n            {'wname': WM_NAME, 'wmclass': WM_CLASS, 'role': WM_WINDOW_ROLE}\n\n        The keys must be specified as above.  You only need one, but\n        you need to provide the value for it.  When a new window is\n        opened it's ``match`` method is called with each of these\n        rules.  If one matches, the window will float.  The following\n        will float gimp and skype::\n\n            float_rules=[dict(wmclass=\"skype\"), dict(wmclass=\"gimp\")]\n\n        Specify these in the ``floating_layout`` in your config.\n\n        Floating layout will try to center most of floating windows by default,\n        but if you don't want this to happen for certain windows that are\n        centered by mistake, you can use ``no_reposition_match`` option to\n        specify them and layout will rely on windows to position themselves in\n        correct location on the screen.\n        \"\"\"\n        Layout.__init__(self, **config)\n        self.clients = []\n        self.focused = None\n        self.group = None\n        self.float_rules = float_rules or DEFAULT_FLOAT_RULES\n        self.no_reposition_match = no_reposition_match\n        self.add_defaults(Floating.defaults)\n\n    def match(self, win):\n        \"\"\"Used to default float some windows\"\"\"\n        if win.window.get_wm_type() in self.auto_float_types:\n            return True\n        for rule_dict in self.float_rules:\n            if win.match(**rule_dict):\n                return True\n        return False\n\n    def find_clients(self, group):\n        \"\"\"Find all clients belonging to a given group\"\"\"\n        return [c for c in self.clients if c.group is group]\n\n    def to_screen(self, group, new_screen):\n        \"\"\"Adjust offsets of clients within current screen\"\"\"\n        for win in self.find_clients(group):\n            if win.maximized:\n                win.maximized = True\n            elif win.fullscreen:\n                win.fullscreen = True\n            else:\n                # catch if the client hasn't been configured\n                try:\n                    # By default, place window at same offset from top corner\n                    new_x = new_screen.x + win.float_x\n                    new_y = new_screen.y + win.float_y\n                except AttributeError:\n                    # this will be handled in .configure()\n                    pass\n                else:\n                    # make sure window isn't off screen left/right...\n                    new_x = min(new_x, new_screen.x + new_screen.width - win.width)\n                    new_x = max(new_x, new_screen.x)\n                    # and up/down\n                    new_y = min(new_y, new_screen.y + new_screen.height - win.height)\n                    new_y = max(new_y, new_screen.y)\n\n                    win.x = new_x\n                    win.y = new_y\n            win.group = new_screen.group\n\n    def focus_first(self, group=None):\n        if group is None:\n            clients = self.clients\n        else:\n            clients = self.find_clients(group)\n\n        if clients:\n            return clients[0]\n\n    def focus_next(self, win):\n        if win not in self.clients or win.group is None:\n            return\n\n        clients = self.find_clients(win.group)\n        idx = clients.index(win)\n        if len(clients) > idx + 1:\n            return clients[idx + 1]\n\n    def focus_last(self, group=None):\n        if group is None:\n            clients = self.clients\n        else:\n            clients = self.find_clients(group)\n\n        if clients:\n            return clients[-1]\n\n    def focus_previous(self, win):\n        if win not in self.clients or win.group is None:\n            return\n\n        clients = self.find_clients(win.group)\n        idx = clients.index(win)\n        if idx > 0:\n            return clients[idx - 1]\n\n    def focus(self, client):\n        self.focused = client\n\n    def blur(self):\n        self.focused = None\n\n    def compute_client_position(self, client, screen):\n        \"\"\" recompute client.x and client.y, returning whether or not to place\n        this client above other windows or not \"\"\"\n        above = False\n        transient_for = client.window.get_wm_transient_for()\n        win = client.group.qtile.windows_map.get(transient_for)\n        if win is not None:\n            # if transient for a window, place in the center of the window\n            center_x = win.x + win.width / 2\n            center_y = win.y + win.height / 2\n        else:\n            center_x = screen.x + screen.width / 2\n            center_y = screen.y + screen.height / 2\n            above = True\n\n        x = center_x - client.width / 2\n        y = center_y - client.height / 2\n\n        # don't go off the right...\n        x = min(x, screen.x + screen.width)\n        # or left...\n        x = max(x, screen.x)\n        # or bottom...\n        y = min(y, screen.y + screen.height)\n        # or top\n        y = max(y, screen.y)\n\n        client.x = int(round(x))\n        client.y = int(round(y))\n        return above\n\n    def configure(self, client, screen):\n        # 'sun-awt-X11-XWindowPeer' is a dropdown used in Java application,\n        # don't reposition it anywhere, let Java app to control it\n        cls = client.window.get_wm_class() or ''\n        is_java_dropdown = 'sun-awt-X11-XWindowPeer' in cls\n        if is_java_dropdown:\n            return\n\n        # similar to above but the X11 version, the client may have already\n        # placed itself. let's respect that\n        if client.has_user_set_position():\n            return\n\n        # ok, it's not java and the window itself didn't position it, but users\n        # may still have asked us not to mess with it\n        if self.no_reposition_match is not None and self.no_reposition_match.compare(client):\n            return\n\n        if client.has_focus:\n            bc = client.group.qtile.color_pixel(self.border_focus)\n        else:\n            bc = client.group.qtile.color_pixel(self.border_normal)\n        if client.maximized:\n            bw = self.max_border_width\n        elif client.fullscreen:\n            bw = self.fullscreen_border_width\n        else:\n            bw = self.border_width\n        above = False\n\n        # We definitely have a screen here, so let's be sure we'll float on screen\n        try:\n            client.float_x\n            client.float_y\n        except AttributeError:\n            # this window hasn't been placed before, let's put it in a sensible spot\n            above = self.compute_client_position(client, screen)\n\n        client.place(\n            client.x,\n            client.y,\n            client.width,\n            client.height,\n            bw,\n            bc,\n            above,\n        )\n        client.unhide()\n\n    def add(self, client):\n        self.clients.append(client)\n        self.focused = client\n\n    def remove(self, client):\n        if client not in self.clients:\n            return\n\n        next_focus = self.focus_next(client)\n        if client is self.focused:\n            self.blur()\n        self.clients.remove(client)\n        return next_focus\n\n    def info(self):\n        d = Layout.info(self)\n        d[\"clients\"] = [c.name for c in self.clients]\n        return d\n\n    def cmd_next(self):\n        # This can't ever be called, but implement the abstract method\n        pass\n\n    def cmd_previous(self):\n        # This can't ever be called, but implement the abstract method\n        pass\n", "path": "libqtile/layout/floating.py"}], "after_files": [{"content": "# Copyright (c) 2010 matt\n# Copyright (c) 2010-2011 Paul Colomiets\n# Copyright (c) 2011 Mounier Florian\n# Copyright (c) 2012 Craig Barnes\n# Copyright (c) 2012, 2014-2015 Tycho Andersen\n# Copyright (c) 2013 Tao Sauvage\n# Copyright (c) 2013 Julien Iguchi-Cartigny\n# Copyright (c) 2014 ramnes\n# Copyright (c) 2014 Sean Vig\n# Copyright (c) 2014 dequis\n# Copyright (c) 2018 Nazar Mokrynskyi\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom libqtile.layout.base import Layout\n\nDEFAULT_FLOAT_WM_TYPES = set([\n    'utility',\n    'notification',\n    'toolbar',\n    'splash',\n    'dialog',\n])\n\nDEFAULT_FLOAT_RULES = [\n    {\"role\": \"About\"},\n    {\"wmclass\": \"file_progress\"},\n]\n\n\nclass Floating(Layout):\n    \"\"\"\n    Floating layout, which does nothing with windows but handles focus order\n    \"\"\"\n    defaults = [\n        (\"border_focus\", \"#0000ff\", \"Border colour for the focused window.\"),\n        (\"border_normal\", \"#000000\", \"Border colour for un-focused windows.\"),\n        (\"border_width\", 1, \"Border width.\"),\n        (\"max_border_width\", 0, \"Border width for maximize.\"),\n        (\"fullscreen_border_width\", 0, \"Border width for fullscreen.\"),\n        (\"name\", \"floating\", \"Name of this layout.\"),\n        (\n            \"auto_float_types\",\n            DEFAULT_FLOAT_WM_TYPES,\n            \"default wm types to automatically float\"\n        ),\n    ]\n\n    def __init__(self, float_rules=None, no_reposition_match=None, **config):\n        \"\"\"\n        If you have certain apps that you always want to float you can provide\n        ``float_rules`` to do so. ``float_rules`` is a list of\n        dictionaries containing some or all of the keys::\n\n            {'wname': WM_NAME, 'wmclass': WM_CLASS, 'role': WM_WINDOW_ROLE}\n\n        The keys must be specified as above.  You only need one, but\n        you need to provide the value for it.  When a new window is\n        opened it's ``match`` method is called with each of these\n        rules.  If one matches, the window will float.  The following\n        will float gimp and skype::\n\n            float_rules=[dict(wmclass=\"skype\"), dict(wmclass=\"gimp\")]\n\n        Specify these in the ``floating_layout`` in your config.\n\n        Floating layout will try to center most of floating windows by default,\n        but if you don't want this to happen for certain windows that are\n        centered by mistake, you can use ``no_reposition_match`` option to\n        specify them and layout will rely on windows to position themselves in\n        correct location on the screen.\n        \"\"\"\n        Layout.__init__(self, **config)\n        self.clients = []\n        self.focused = None\n        self.group = None\n        self.float_rules = float_rules or DEFAULT_FLOAT_RULES\n        self.no_reposition_match = no_reposition_match\n        self.add_defaults(Floating.defaults)\n\n    def match(self, win):\n        \"\"\"Used to default float some windows\"\"\"\n        if win.window.get_wm_type() in self.auto_float_types:\n            return True\n        for rule_dict in self.float_rules:\n            if win.match(**rule_dict):\n                return True\n        return False\n\n    def find_clients(self, group):\n        \"\"\"Find all clients belonging to a given group\"\"\"\n        return [c for c in self.clients if c.group is group]\n\n    def to_screen(self, group, new_screen):\n        \"\"\"Adjust offsets of clients within current screen\"\"\"\n        for win in self.find_clients(group):\n            if win.maximized:\n                win.maximized = True\n            elif win.fullscreen:\n                win.fullscreen = True\n            else:\n                # catch if the client hasn't been configured\n                try:\n                    # By default, place window at same offset from top corner\n                    new_x = new_screen.x + win.float_x\n                    new_y = new_screen.y + win.float_y\n                except AttributeError:\n                    # this will be handled in .configure()\n                    pass\n                else:\n                    # make sure window isn't off screen left/right...\n                    new_x = min(new_x, new_screen.x + new_screen.width - win.width)\n                    new_x = max(new_x, new_screen.x)\n                    # and up/down\n                    new_y = min(new_y, new_screen.y + new_screen.height - win.height)\n                    new_y = max(new_y, new_screen.y)\n\n                    win.x = new_x\n                    win.y = new_y\n            win.group = new_screen.group\n\n    def focus_first(self, group=None):\n        if group is None:\n            clients = self.clients\n        else:\n            clients = self.find_clients(group)\n\n        if clients:\n            return clients[0]\n\n    def focus_next(self, win):\n        if win not in self.clients or win.group is None:\n            return\n\n        clients = self.find_clients(win.group)\n        idx = clients.index(win)\n        if len(clients) > idx + 1:\n            return clients[idx + 1]\n\n    def focus_last(self, group=None):\n        if group is None:\n            clients = self.clients\n        else:\n            clients = self.find_clients(group)\n\n        if clients:\n            return clients[-1]\n\n    def focus_previous(self, win):\n        if win not in self.clients or win.group is None:\n            return\n\n        clients = self.find_clients(win.group)\n        idx = clients.index(win)\n        if idx > 0:\n            return clients[idx - 1]\n\n    def focus(self, client):\n        self.focused = client\n\n    def blur(self):\n        self.focused = None\n\n    def compute_client_position(self, client, screen):\n        \"\"\" recompute client.x and client.y, returning whether or not to place\n        this client above other windows or not \"\"\"\n        above = False\n        transient_for = client.window.get_wm_transient_for()\n        win = client.group.qtile.windows_map.get(transient_for)\n        if win is not None:\n            # if transient for a window, place in the center of the window\n            center_x = win.x + win.width / 2\n            center_y = win.y + win.height / 2\n        else:\n            center_x = screen.x + screen.width / 2\n            center_y = screen.y + screen.height / 2\n            above = True\n\n        x = center_x - client.width / 2\n        y = center_y - client.height / 2\n\n        # don't go off the right...\n        x = min(x, screen.x + screen.width)\n        # or left...\n        x = max(x, screen.x)\n        # or bottom...\n        y = min(y, screen.y + screen.height)\n        # or top\n        y = max(y, screen.y)\n\n        client.x = int(round(x))\n        client.y = int(round(y))\n        return above\n\n    def configure(self, client, screen):\n        # After this, the client will be mapped. Either this will do it, or the\n        # client has already done it.\n        client.hidden = False\n\n        # 'sun-awt-X11-XWindowPeer' is a dropdown used in Java application,\n        # don't reposition it anywhere, let Java app to control it\n        cls = client.window.get_wm_class() or ''\n        is_java_dropdown = 'sun-awt-X11-XWindowPeer' in cls\n        if is_java_dropdown:\n            return\n\n        # similar to above but the X11 version, the client may have already\n        # placed itself. let's respect that\n        if client.has_user_set_position():\n            return\n\n        # ok, it's not java and the window itself didn't position it, but users\n        # may still have asked us not to mess with it\n        if self.no_reposition_match is not None and self.no_reposition_match.compare(client):\n            return\n\n        if client.has_focus:\n            bc = client.group.qtile.color_pixel(self.border_focus)\n        else:\n            bc = client.group.qtile.color_pixel(self.border_normal)\n        if client.maximized:\n            bw = self.max_border_width\n        elif client.fullscreen:\n            bw = self.fullscreen_border_width\n        else:\n            bw = self.border_width\n        above = False\n\n        # We definitely have a screen here, so let's be sure we'll float on screen\n        try:\n            client.float_x\n            client.float_y\n        except AttributeError:\n            # this window hasn't been placed before, let's put it in a sensible spot\n            above = self.compute_client_position(client, screen)\n\n        client.place(\n            client.x,\n            client.y,\n            client.width,\n            client.height,\n            bw,\n            bc,\n            above,\n        )\n        client.unhide()\n\n    def add(self, client):\n        self.clients.append(client)\n        self.focused = client\n\n    def remove(self, client):\n        if client not in self.clients:\n            return\n\n        next_focus = self.focus_next(client)\n        if client is self.focused:\n            self.blur()\n        self.clients.remove(client)\n        return next_focus\n\n    def info(self):\n        d = Layout.info(self)\n        d[\"clients\"] = [c.name for c in self.clients]\n        return d\n\n    def cmd_next(self):\n        # This can't ever be called, but implement the abstract method\n        pass\n\n    def cmd_previous(self):\n        # This can't ever be called, but implement the abstract method\n        pass\n", "path": "libqtile/layout/floating.py"}]}