feat: take the last of sway out of the classroom
The DVD player was the only thing still speaking a compositor the room no longer runs. It asked sway's tree whether VLC's window had really gone fullscreen, because VLC reports playing while its window is still the black startup one the loading cover exists to hide. VLC's own status was measured as a replacement and is not one: it reports fullscreen true in the same 250ms poll as playing, because the flag is the option it was started with and not a report about its window. So the cover is held for a floor and capped by the deadline that was already there, and the compositor is not asked anything. Focus-or-launch went the same way. The session already takes an exclusive lock, so a second one cannot start, and bringing an existing one to the front is the panel's job. classroom-window, classroom_sway and classroom_chrome are gone with it — the last of them was reachable from nothing at all. DVD also moves out of the status row, where it sat beside the clock as though a disc were a machine reading. It is an application: it is in the row with Wonder Ink and the browser, and classroom-provision removes it from the layout on a machine with no optical drive, which retires DVD_ENABLED. A computer that moves between rooms takes its drive with it; nobody remembers to edit a file when it does. The panel is rebuilt from the package at every login now. Plasma keeps whatever panel it first built, so an update could change the bar in the package and never change it in a room — measured, with an icon that outlived the file it came from. Editing the live panel configuration was tried instead and destroyed the panel, because the shell owns that file. Removing it before the shell starts is safe and makes the desktop stateless. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
18cf0249dd
commit
d2d30d6b0c
@@ -107,56 +107,33 @@ print("6. the disc is the last argument")
|
||||
check("dvd:// selects dvdnav for menus", command[-1] == "dvd:///dev/sr0")
|
||||
|
||||
print()
|
||||
print("7. the loading surface waits for a fullscreen VLC window")
|
||||
print("7. the loading surface holds until the player is ready")
|
||||
|
||||
import json # noqa: E402
|
||||
import os # noqa: E402
|
||||
import subprocess # noqa: E402
|
||||
import tempfile # noqa: E402
|
||||
import re # noqa: E402
|
||||
|
||||
|
||||
def tree_with(app, fullscreen):
|
||||
return {
|
||||
"tree": {
|
||||
"type": "root", "id": 1, "nodes": [{
|
||||
"type": "output", "id": 2, "name": "HDMI-A-1", "nodes": [{
|
||||
"type": "workspace", "id": 3, "name": "1",
|
||||
"nodes": ([] if app is None else [{
|
||||
"type": "con", "id": 10, "pid": 100,
|
||||
"app_id": None,
|
||||
"window_properties": {"class": app, "instance": app},
|
||||
"focused": True,
|
||||
"fullscreen_mode": 1 if fullscreen else 0,
|
||||
"nodes": [], "floating_nodes": [],
|
||||
}]),
|
||||
"floating_nodes": [],
|
||||
}], "floating_nodes": [],
|
||||
}], "floating_nodes": [],
|
||||
},
|
||||
"workspaces": [{"name": "1", "focused": True, "visible": True}],
|
||||
}
|
||||
class FakeControl:
|
||||
"""Stands in for VLC's HTTP interface."""
|
||||
|
||||
def __init__(self, body):
|
||||
self.body = body
|
||||
|
||||
def field(self, pattern):
|
||||
found = re.search(pattern, self.body)
|
||||
return found.group(1) if found else None
|
||||
|
||||
def wants_fullscreen(self):
|
||||
return self.field(r"<fullscreen>(\w+)</fullscreen>") == "true"
|
||||
|
||||
|
||||
work = tempfile.mkdtemp()
|
||||
os.makedirs(f"{work}/bin", exist_ok=True)
|
||||
|
||||
with open(f"{work}/bin/swaymsg", "w") as shim:
|
||||
shim.write(
|
||||
"#!/usr/bin/env python3\n"
|
||||
"import json, os, sys\n"
|
||||
"state = json.load(open(os.environ['MOCK_TREE']))\n"
|
||||
"print(json.dumps(state['tree' if sys.argv[2] == 'get_tree'"
|
||||
" else 'workspaces']))\n"
|
||||
)
|
||||
os.chmod(f"{work}/bin/swaymsg", 0o755)
|
||||
os.environ["PATH"] = f"{work}/bin:" + os.environ["PATH"]
|
||||
os.environ["MOCK_TREE"] = f"{work}/tree.json"
|
||||
|
||||
|
||||
def set_tree(app, fullscreen):
|
||||
with open(f"{work}/tree.json", "w") as handle:
|
||||
json.dump(tree_with(app, fullscreen), handle)
|
||||
source = open(sys.argv[1] + "/scripts/classroom-dvd-session").read()
|
||||
|
||||
check("the session no longer asks a window manager anything",
|
||||
"classroom_sway" not in source and "swaymsg" not in source)
|
||||
check("and holds the cover for a floor instead",
|
||||
"MINIMUM_COVER_SECONDS" in source)
|
||||
check("VLC's own flag is named for what it is, not for the window",
|
||||
"wants_fullscreen" in source and "player_is_fullscreen" not in source)
|
||||
|
||||
ready = None
|
||||
|
||||
@@ -169,37 +146,37 @@ try:
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("GtkLayerShell", "0.1")
|
||||
|
||||
loader = SourceFileLoader("dvdsession", sys.argv[1] + "/scripts/classroom-dvd-session")
|
||||
loader = SourceFileLoader(
|
||||
"dvdsession", sys.argv[1] + "/scripts/classroom-dvd-session")
|
||||
spec = importlib.util.spec_from_loader("dvdsession", loader)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules["dvdsession"] = module
|
||||
loader.exec_module(module)
|
||||
ready = module.DvdSession.player_is_fullscreen
|
||||
ready = module.DvdSession.player_is_ready
|
||||
except Exception as error: # noqa: BLE001
|
||||
print(f" skip GTK unavailable here ({type(error).__name__})")
|
||||
|
||||
if ready is not None:
|
||||
set_tree("vlc", False)
|
||||
check("a tiled VLC window is not ready", ready(None) is False)
|
||||
floor = module.MINIMUM_COVER_SECONDS
|
||||
|
||||
set_tree("vlc", True)
|
||||
check("a fullscreen VLC window is ready", ready(None) is True)
|
||||
class Session:
|
||||
def __init__(self, body, elapsed):
|
||||
self.control = FakeControl(body)
|
||||
self.elapsed = elapsed
|
||||
|
||||
set_tree("Google-chrome", True)
|
||||
check("someone else's fullscreen window is not VLC", ready(None) is False)
|
||||
FULL = "<state>playing</state><fullscreen>true</fullscreen>"
|
||||
WINDOWED = "<state>playing</state><fullscreen>false</fullscreen>"
|
||||
|
||||
set_tree(None, False)
|
||||
check("no windows at all is not ready", ready(None) is False)
|
||||
|
||||
check("playback state alone is no longer the condition",
|
||||
"player_is_fullscreen" in module.DvdSession.watch_startup.__doc__
|
||||
or "fullscreen" in module.DvdSession.watch_startup.__doc__)
|
||||
check("the handover is held briefly after both agree",
|
||||
500 <= module.STABILISE_MS <= 1000, f"got {module.STABILISE_MS}")
|
||||
check("the safety deadline is still there",
|
||||
module.LOADING_DEADLINE_SECONDS == 20)
|
||||
|
||||
subprocess.run(["rm", "-rf", work])
|
||||
check("a player that is not set fullscreen is never ready",
|
||||
ready(Session(WINDOWED, floor + 5)) is False)
|
||||
check("a fullscreen player is not ready before the floor",
|
||||
ready(Session(FULL, floor / 2)) is False)
|
||||
check("and is ready after it",
|
||||
ready(Session(FULL, floor + 0.1)) is True)
|
||||
check("a silent VLC is not ready",
|
||||
ready(Session("", floor + 5)) is False)
|
||||
check("the startup watcher still explains what it waits for",
|
||||
"fullscreen" in module.DvdSession.watch_startup.__doc__)
|
||||
|
||||
print()
|
||||
print(f"passed: {passed} failed: {failed}")
|
||||
|
||||
Reference in New Issue
Block a user