diff options
author | Syphdias <syphdias+git@gmail.com> | 2022-11-08 00:26:51 +0100 |
---|---|---|
committer | Syphdias <syphdias+git@gmail.com> | 2022-11-08 00:26:51 +0100 |
commit | 017bea932c37b6cae2c961afd29396f212b27287 (patch) | |
tree | 441698c0c256700d45b61cb2917bfd14a3dc1865 | |
parent | 2faad763b0138712201e4d78825d2a0dc1798204 (diff) | |
download | autotiling-017bea932c37b6cae2c961afd29396f212b27287.tar.gz |
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.
-rw-r--r-- | autotiling/main.py | 15 |
1 files 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 |