Skip to content

Commit

Permalink
Better X11 window focus handling for scratchpads.
Browse files Browse the repository at this point in the history
Prior to this commit, the behavior regarding window focus within a
scratchpad was unexpected. When a window in the scratchpad was focused,
the entire scratchpad group would also be focused, based on the settings
of focus_on_window_activation being set to "focus" or "smart".

With this commit, the focus behavior has been refined. Now, only the
activated window within the scratchpad will be focused and brought to
the front, mirroring the expected toggle behavior.
  • Loading branch information
amosbird committed May 2, 2024
1 parent 8d254f6 commit 97d9a87
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions libqtile/backend/x11/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2149,8 +2149,15 @@ def handle_ClientMessage(self, event): # noqa: N802
focus_behavior = self.qtile.config.focus_on_window_activation
if focus_behavior == "focus":
logger.debug("Focusing window")
self.qtile.current_screen.set_group(self.group)
self.group.focus(self)
# Windows belonging to a scratchpad need to be toggled properly
if isinstance(self.group, ScratchPad):
for dropdown in self.group.dropdowns.values():
if dropdown.window is self:
dropdown.show()
break
else:
self.qtile.current_screen.set_group(self.group)
self.group.focus(self)
elif focus_behavior == "smart":
if not self.group.screen:
logger.debug(
Expand All @@ -2159,8 +2166,15 @@ def handle_ClientMessage(self, event): # noqa: N802
return
if self.group.screen == self.qtile.current_screen:
logger.debug("Focusing window")
self.qtile.current_screen.set_group(self.group)
self.group.focus(self)
# Windows belonging to a scratchpad need to be toggled properly
if isinstance(self.group, ScratchPad):
for dropdown in self.group.dropdowns.values():
if dropdown.window is self:
dropdown.show()
break
else:
self.qtile.current_screen.set_group(self.group)
self.group.focus(self)
else: # self.group.screen != self.qtile.current_screen:
logger.debug("Setting urgent flag for window")
self.urgent = True
Expand Down

0 comments on commit 97d9a87

Please sign in to comment.