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:
6235423544.) 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.
This commit is contained in:
gibbz00 2022-10-02 22:15:36 +02:00
parent 10c697d33a
commit 47023befbf

View file

@ -13,7 +13,6 @@ from functools import partial
def on_window_focus(inactive_opacity, ipc, event): def on_window_focus(inactive_opacity, ipc, event):
global prev_focused global prev_focused
global prev_workspace
focused_workspace = ipc.get_tree().find_focused() focused_workspace = ipc.get_tree().find_focused()
@ -21,14 +20,13 @@ def on_window_focus(inactive_opacity, ipc, event):
return return
focused = event.container 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") focused.command("opacity 1")
if workspace == prev_workspace:
prev_focused.command("opacity " + inactive_opacity) prev_focused.command("opacity " + inactive_opacity)
prev_focused = focused prev_focused = focused
prev_workspace = workspace
def remove_opacity(ipc): def remove_opacity(ipc):
@ -59,7 +57,6 @@ if __name__ == "__main__":
ipc = i3ipc.Connection() ipc = i3ipc.Connection()
prev_focused = None prev_focused = None
prev_workspace = ipc.get_tree().find_focused().workspace().num
for window in ipc.get_tree(): for window in ipc.get_tree():
if window.focused: if window.focused: