claim windows by pid, and find the compositor after a restart

Two things stood between "containers enabled" and an application actually
sitting on its own output, and neither was where I said it was.

ipc: discovery refused whenever two instance directories existed, which every
compositor restart leaves behind (a log file where a live compositor used to
be). After two rebuilds the broker could not reach any compositor at all, so no
container could be created and the pointer had nothing to aim at. It now asks
each candidate for its version and uses the one that answers, preferring the
newest only when two answer, and still refusing when none do.

container_host.claim: windows are assigned by the pid the compositor already
reports, not by the class stamp the per-session rule matches -- foot, GTK, Qt
and the chromium wrapper all ignore that stamp, so the desk was created and
left empty while the window sat in special:quarantine. The claim moves the
window to its desk's workspace, makes that workspace the one the desk is
showing, and reads back: the record says where the window is, never where it
was sent. Called from both places a window can appear -- the read-back at start
and container.reconcile -- and skipped in the steady state, because a move is a
real change on screen and should not be dispatched for its own sake.
This commit is contained in:
Hermenix committed 2026-10-03 19:39:33 +00:00
1 parent 336474793f
commit 352cfdcb24
6 files changed
+359 -12

No files matched your search

+53
View File
@@ -213,10 +213,63 @@ class FakeCompositor:
return "ok"
if words[:2] == ["output", "remove"] and len(words) == 3:
return "ok" if self._remove_output(words[2]) else f"no such output {words[2]}"
if words[:2] == ["dispatch", "movetoworkspacesilent"] and len(words) == 3:
return self._move_to_workspace(words[2])
if words[:2] == ["dispatch", "workspace"] and len(words) == 3:
return self._show_workspace(words[2])
if words[:1] == ["keyword"]:
return self._keyword(command[len("keyword") :].strip())
return f"unknown request {command!r}"
# -- dispatches -------------------------------------------------------
def _move_to_workspace(self, spec: str) -> str:
"""``<workspace>,address:<addr>`` -- what the broker claims with.
Moving a window is the one thing that puts a real application on its
desk, because no allowlisted app carries the class the rule matches.
"""
workspace_text, _, address = spec.partition(",address:")
if not workspace_text.isdigit() or not address:
return f"malformed move {spec!r}"
client = next((c for c in self._clients if c["address"] == address), None)
if client is None:
return f"no such window {address}"
workspace = int(workspace_text)
monitor = next(
(m["name"] for m in self._monitors if m["id"] == client["monitor"]), None
)
if not any(w["id"] == workspace for w in self._workspaces):
self._workspaces.append(
{"id": workspace, "name": str(workspace), "monitor": monitor, "windows": 0}
)
for entry in self._workspaces:
if entry["id"] == client["workspace"]["id"]:
entry["windows"] = max(0, entry["windows"] - 1)
if entry["id"] == workspace:
entry["windows"] += 1
client["workspace"] = {"id": workspace, "name": str(workspace)}
return "ok"
def _show_workspace(self, workspace_text: str) -> str:
"""``workspace <n>`` -- makes that workspace the visible one.
Only meaningful on the output that holds it, which is how Hyprland
behaves: the workspace's own monitor switches to it.
"""
if not workspace_text.lstrip("-").isdigit():
return f"malformed workspace {workspace_text!r}"
workspace = int(workspace_text)
holder = next((w["monitor"] for w in self._workspaces if w["id"] == workspace), None)
if holder is None:
return f"no such workspace {workspace}"
for monitor in self._monitors:
if monitor["name"] == holder:
monitor["activeWorkspace"] = {"id": workspace, "name": str(workspace)}
return "ok"
def _keyword(self, rest: str) -> str:
name, _, body = rest.partition(" ")
if name == "workspace":