From 017bea932c37b6cae2c961afd29396f212b27287 Mon Sep 17 00:00:00 2001 From: Syphdias Date: Tue, 8 Nov 2022 00:26:51 +0100 Subject: Find output by analysing parent instead of ipc_data Apparently there are differences in the returned ipc_data for sway and we cannot use the ipc_data of the event that triggered the handler. To accommodate this, we look at the currently focused container and check its parents recursively until we find the output. --- autotiling/main.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/autotiling/main.py b/autotiling/main.py index e5b3ad7..8f7e673 100644 --- a/autotiling/main.py +++ b/autotiling/main.py @@ -47,9 +47,21 @@ def save_string(string, file): print(e) +def output_name(con): + if con.type == "root": + return None + + if p := con.parent: + if p.type == "output": + return p.name + else: + return output_name(p) + + def switch_splitting(i3, e, debug, outputs, workspaces, depth_limit): try: - output = e.ipc_data.get("container", {}).get("output", "") + con = i3.get_tree().find_focused() + output = output_name(con) # Stop, if outputs is set and current output is not in the selection if outputs and output not in outputs: if debug: @@ -59,7 +71,6 @@ def switch_splitting(i3, e, debug, outputs, workspaces, depth_limit): ) return - con = i3.get_tree().find_focused() if con and not workspaces or (str(con.workspace().num) in workspaces): if con.floating: # We're on i3: on sway it would be None -- cgit