Three things, none of them redesigns. The close affordance for a secondary Chrome window was a separate layer-shell surface anchored to that window's corner, repositioned by a five-per-second poll. Any position change tore the surface down and built another, so on real hardware it chased the window and flickered. Removed entirely: the GTK button process, the geometry maths that placed it, the --close-button mode that spawned it, and the poll loop that drove it. The window helper no longer imports GTK at all. The behaviour underneath it was right and is kept. The first Chrome top-level is the classroom browser, tiled and borderless; later ones float centred at about three quarters of the output. Creation order is the only thing that can tell them apart — confirmed on a real session, where every Chrome top-level shares app_id, shell, PID and a null transient_for, and sway exposes no window properties for Wayland toplevels at all. Titles are still not used. It now follows sway's own window events instead of polling, so dragging a popup costs nothing. Close moved into the dock, which was already on screen and does not move, so it cannot chase anything. It appears only while a secondary window is focused and runs kill on that one container. The helper publishes which window that is; the dock watches the file rather than polling. A stock sway title bar has no close button, so restoring the border would not have solved this either. Two bugs found by looking rather than by testing state. Chrome renegotiates the size of a popup opened with explicit dimensions after the resize returns, which left windows centred for a width they no longer had; placement now settles and repeats once, at creation only, so dragging is still free. And the dock's Close button came up empty because show_all does not recurse into a no-show-all widget. The printer's Location is now blank. CUPS prints it under the queue name in every dialog, so "Ekklesia Classroom" was a second line the teacher had to read past; the identity is one word. The already-configured check includes Location, so a machine set up before this is corrected rather than left as close enough. Co-Authored-By: Claude Opus 5 <[email protected]>
67 lines
1.8 KiB
Python
67 lines
1.8 KiB
Python
"""Stable roles for Chrome's otherwise indistinguishable top-level windows."""
|
|
|
|
from classroom_sway import matches
|
|
|
|
|
|
CHROME_PATTERNS = (
|
|
r"google-chrome",
|
|
r"chrome",
|
|
r"chrome-.*",
|
|
r"google-chrome-.*",
|
|
)
|
|
|
|
|
|
def chrome_windows(current):
|
|
"""Chrome containers in Sway tree order, without using page titles."""
|
|
return [window for window in current if matches(window, CHROME_PATTERNS)]
|
|
|
|
|
|
class ChromeRoles:
|
|
"""Remember the first Chrome container and classify every later one."""
|
|
|
|
def __init__(self):
|
|
self.primary = None
|
|
self.secondary = []
|
|
|
|
def update(self, current):
|
|
identifiers = [window["id"] for window in chrome_windows(current)]
|
|
previous_primary = self.primary
|
|
previous_secondary = list(self.secondary)
|
|
|
|
promoted = None
|
|
|
|
if self.primary not in identifiers:
|
|
self.primary = identifiers[0] if identifiers else None
|
|
|
|
if self.primary is not None and previous_primary is not None:
|
|
promoted = self.primary
|
|
|
|
self.secondary = [
|
|
identifier
|
|
for identifier in previous_secondary
|
|
if identifier in identifiers and identifier != self.primary
|
|
]
|
|
|
|
new_secondary = []
|
|
|
|
for identifier in identifiers:
|
|
if identifier == self.primary or identifier in self.secondary:
|
|
continue
|
|
|
|
self.secondary.append(identifier)
|
|
new_secondary.append(identifier)
|
|
|
|
removed = [
|
|
identifier
|
|
for identifier in previous_secondary
|
|
if identifier not in identifiers
|
|
]
|
|
|
|
return {
|
|
"primary": self.primary,
|
|
"promoted": promoted,
|
|
"new_secondary": new_secondary,
|
|
"removed": removed,
|
|
"active_secondary": self.secondary[-1] if self.secondary else None,
|
|
}
|