i3-companion: fix some edge cases for exclusive workspaces

This commit is contained in:
Vincent Bernat 2021-07-07 18:52:19 +02:00
parent 2172a05592
commit d215c151a9

View file

@ -42,6 +42,7 @@ application_icons = {
"google-chrome": "", "google-chrome": "",
"inkscape": "", "inkscape": "",
"libreoffice": "", "libreoffice": "",
"mpv": "",
"pavucontrol": "", "pavucontrol": "",
"signal": "", "signal": "",
"snes9x-gtk": "", "snes9x-gtk": "",
@ -132,6 +133,7 @@ intrusive_apps = {
"vbeterm" "vbeterm"
} }
@on(Event.WINDOW_NEW) @on(Event.WINDOW_NEW)
async def worksplace_exclusive(i3, event): async def worksplace_exclusive(i3, event):
"""Move new windows on a new workspace instead of sharing a workspace """Move new windows on a new workspace instead of sharing a workspace
@ -142,11 +144,11 @@ async def worksplace_exclusive(i3, event):
"""Can this new window intrude any workspace?""" """Can this new window intrude any workspace?"""
if w.floating in {"auto_on", "user_on"}: if w.floating in {"auto_on", "user_on"}:
return True return True
if w.ipc_data['window_type'] not in {"normal", "splash"}: if w.ipc_data['window_type'] not in {"normal", "splash", "unknown"}:
return True return True
if w.sticky: if w.sticky:
return True return True
ids = {s.lower() ids = {s is not None and s.lower() or None
for s in {w.name, w.window_class, w.window_instance}} for s in {w.name, w.window_class, w.window_instance}}
if ids.intersection(intrusive_apps): if ids.intersection(intrusive_apps):
return True return True
@ -161,7 +163,7 @@ async def worksplace_exclusive(i3, event):
workspace = tree.find_focused().workspace() workspace = tree.find_focused().workspace()
if not workspace: if not workspace:
return return
ids = {s.lower() ids = {s is not None and s.lower() or None
for w in workspace.leaves() for w in workspace.leaves()
for s in {w.name, w.window_class, w.window_instance}} for s in {w.name, w.window_class, w.window_instance}}
exclusives = ids.intersection(exclusive_apps) exclusives = ids.intersection(exclusive_apps)