ipc: Monitor gains the id that CONTRACT-sessions v2 promised
The contract bump added Monitor.id and nobody implemented it: slice B predates v2, so the integration slice had to join a client to its output through Workspace.monitor instead. Field added, parsed from `monitors -j`, and -1 when a reply omits it -- a missing id must not default to 0, which would silently bind every such client to the first output. Two tests: the id is parsed, and omitting it yields -1.
This commit is contained in:
1 parent
39f0180d2d
commit
57fdd4f636
2 files changed
+29
No files matched your search
@@ -95,6 +95,7 @@ class CompositorUnavailable(Exception):
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Monitor:
|
||||
id: int
|
||||
name: str
|
||||
x: int
|
||||
y: int
|
||||
@@ -237,6 +238,13 @@ def _monitor(raw: dict) -> Monitor:
|
||||
if not isinstance(name, str) or not name:
|
||||
raise CompositorUnavailable("monitors: an entry has no name")
|
||||
return Monitor(
|
||||
# `monitors -j` reports the id that `clients -j` refers to as a client's
|
||||
# `monitor`. Joining through it is how a client is tied to the output it
|
||||
# is on -- `Client.monitor` is that same number rendered as text, while
|
||||
# `Workspace.monitor` is a name. CONTRACT-sessions v2 added this field;
|
||||
# `-1` is the honest value when a reply omits it, because no compositor
|
||||
# numbers a monitor negative.
|
||||
id=_as_int(raw.get("id"), -1),
|
||||
name=name,
|
||||
x=_as_int(raw.get("x"), 0),
|
||||
y=_as_int(raw.get("y"), 0),
|
||||
|
||||
Reference in new issue
Block a user