From 47023befbf5565b36bf4f482ab16420f6678efae Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Sun, 2 Oct 2022 22:15:36 +0200 Subject: [PATCH] contrib/inactive-windows-transparency: Show only one window as focused Script currently has the ability to show multiple windows as active, wrongly implying that more than one window can be focused at the same time. It happens when multiple outputs are configured such that multiple workspaces can be simultaneously shown. Stemming from a conditional to only change transparency values if the focus change is done on the same workspace in which the previous focus change was made. (Introduced in: 6235423544b7e3feab5a6775cd4d06a3b171dd54.) Commit is somewhat poor in that it clumps multiple features into one commit, so it's hard to understand what problem the author attempted to solve with the conditional. I, for one, can not see any other reason for adding this arguably incorrect behavior, as it goes directly against the script's purpose. As such, it's regarded as a bug and the change will remove the behavior entirely, not making it an option. --- contrib/inactive-windows-transparency.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/contrib/inactive-windows-transparency.py b/contrib/inactive-windows-transparency.py index e1ddf0f2a..0cf0dc0b6 100755 --- a/contrib/inactive-windows-transparency.py +++ b/contrib/inactive-windows-transparency.py @@ -13,7 +13,6 @@ from functools import partial def on_window_focus(inactive_opacity, ipc, event): global prev_focused - global prev_workspace focused_workspace = ipc.get_tree().find_focused() @@ -21,14 +20,13 @@ def on_window_focus(inactive_opacity, ipc, event): return focused = event.container - workspace = focused_workspace.workspace().num - if focused.id != prev_focused.id: # https://github.com/swaywm/sway/issues/2859 + # on_window_focus not called only when focused is changed, + # but also when a window is moved + if focused.id != prev_focused.id: focused.command("opacity 1") - if workspace == prev_workspace: - prev_focused.command("opacity " + inactive_opacity) + prev_focused.command("opacity " + inactive_opacity) prev_focused = focused - prev_workspace = workspace def remove_opacity(ipc): @@ -59,7 +57,6 @@ if __name__ == "__main__": ipc = i3ipc.Connection() prev_focused = None - prev_workspace = ipc.get_tree().find_focused().workspace().num for window in ipc.get_tree(): if window.focused: