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:
Hermenix committed 2026-10-03 04:51:07 +00:00
1 parent 39f0180d2d
commit 57fdd4f636
2 files changed
+29

No files matched your search

+21
View File
@@ -37,6 +37,9 @@ def test_monitors(servers, good_handler, ipc):
request, _ = servers(good_handler)
monitors = ipc.monitors()
assert [m.name for m in monitors] == ["HEADLESS-2", "HEADLESS-3"]
# The id is what ties a client to the output it is on: `clients -j` reports
# a client's monitor as this same number, while workspaces report a name.
assert [m.id for m in monitors] == [0, 1]
first = monitors[0]
assert (first.x, first.y, first.width, first.height) == (0, 0, 1280, 720)
assert first.scale == 1.0
@@ -47,6 +50,24 @@ def test_monitors(servers, good_handler, ipc):
assert request.requests == [("j", "monitors")]
def test_monitors_without_an_id_is_minus_one(servers, ipc):
"""A reply that omits the id must not join to a real output.
`Monitor.id` is the join key for a client's output, so a missing id has to be
a value no compositor can use -- `-1` -- rather than a plausible-looking `0`
that would silently bind every such client to the first output.
"""
def handler(flags, command):
return ('[{"name": "HEADLESS-9", "x": 0, "y": 0, "width": 100, '
'"height": 50, "scale": 1.0}]')
servers(handler)
monitors = ipc.monitors()
assert [m.id for m in monitors] == [-1]
assert monitors[0].name == "HEADLESS-9"
def test_workspaces(servers, good_handler, ipc):
servers(good_handler)
workspaces = ipc.workspaces()