Skip to content

Commit

Permalink
trailfocus.py: Check parent instead of state for toplevels
Browse files Browse the repository at this point in the history
  • Loading branch information
soreau committed Nov 25, 2023
1 parent ab565ea commit 0bc6487
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ipc-scripts/trailfocus.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ def output_realized(output):
def sort_views():
try:
views = commands_sock.list_views()
outputs.clear()
timestamps = []
for v in views:
if v["app-id"] == "$unfocus panel" or v["layer"] == "background":
continue
if v["state"] != {} and v["state"]["minimized"]:
if "parent" in v and v["state"]["minimized"]:
continue
timestamps.append(v["last-focus-timestamp"])
if not output_realized(v["output"]):
Expand All @@ -35,7 +36,7 @@ def sort_views():
for v in views:
if v["output"] != o or v["app-id"] == "$unfocus panel" or v["layer"] == "background":
continue
if v["state"] != {} and v["state"]["minimized"]:
if "parent" in v and v["state"]["minimized"]:
continue
i += 1
o_step = 0.2 / i
Expand All @@ -50,7 +51,7 @@ def sort_views():
continue
if v["output"] != o or v["app-id"] == "$unfocus panel" or v["layer"] == "background":
break
if v["state"] != {} and v["state"]["minimized"]:
if "parent" in v and v["state"]["minimized"]:
break
o_value += o_step
b_value += b_step
Expand All @@ -59,7 +60,8 @@ def sort_views():
commands_sock.set_view_brightness(v["id"], b_value, 1000)
commands_sock.set_view_saturation(v["id"], s_value, 1000)
break
except:
except Exception as error:
print("An exception occurred:", error)
pass

sort_views()
Expand Down

0 comments on commit 0bc6487

Please sign in to comment.