Monitor hotplug - #12
Merged
Merged
Conversation
PSLDM built one pane for each monitor at the start and never looked again. A monitor that arrived during the lock or during the greeter showed no pane, and a monitor that went away left a dead pane behind. A laptop lid that closed the last screen ended the program. Surfaces now watches the monitor list of the display. A monitor that arrives gets a pane, and a monitor that leaves loses it. The count can fall to zero, and both programs stay in memory until a monitor comes back. The locker keeps the lock during that time, so a closed lid never opens the session. - Surfaces holds the panes in a RefCell and keeps the monitor of each one, so the set can change while the program runs. - The lock host builds its surfaces from the `monitor` signal of gtk4-session-lock, the only safe moment to make a lock surface. That signal needs the v1_2 feature and gtk4-layer-shell 1.2 or later. - The layer-shell host reads the monitor list of the display, and it now holds the application open, as the lock host already did. - Surfaces::on_new_pane gives every pane its handlers and its first frame, both the first panes and the panes that arrive later. - The greeter keeps the user and the session in one place, so a screen that goes away takes no choice with it. - A new pane no longer takes the keyboard from the screen that the user types on. - The greeter compositor gives an unknown monitor the mode that the monitor prefers, with the position and the scale that Hyprland picks. /etc/psldm/monitors.lua still wins for a monitor that it names. Tested in a nested Hyprland instance with `hyprctl output create headless` and `hyprctl output remove`: the greeter and the locker both add and drop panes, and both survive a monitor count of zero. Closes #11 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GRi2nLG1kntocGApdMopMd
psldm-lock stopped with a segmentation fault when a monitor left while
the screen was locked.
GDK removes a monitor in two steps. It takes the monitor out of the
list first, then it invalidates the monitor:
g_list_store_remove (self->monitors, i);
gdk_monitor_invalidate (GDK_MONITOR (monitor));
Step one brought the program to Surfaces::drop_gone_monitors, which
dropped the pane and the window of that monitor. gtk4-session-lock
keeps no reference of its own to that window, so this program held the
only one, and the drop freed the window. Step two then called the
handler of the library on the free memory:
static void gtk_lock_surface_unmap_window(struct gtk_lock_surface_t* self) {
GtkWindow* window = self->gtk_window;
...
g_signal_handlers_disconnect_by_data(window, self);
The core dump shows the fault inside libgtk-4, under a Wayland
callback, at `mov 0x8(%rbx),%rdi`.
drop_gone_monitors now takes the panes out of the list and gives them
up in an idle callback. The list is correct at once, and the memory
stays until the Wayland event ends, so the library reads a window that
is still there.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E5ag7LJrDqAWveeef6twDr
DNAPrototypeX
commented
Sep 9, 2026
The three paragraphs said what the code and the Hyprland files already say. The install section covers /etc/psldm/monitors.lua, and the greeter configuration carries the rest in its comments. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TWyxdWoZGKfm1XWRvvem1L
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the locker and greeter crashing if a monitor is unplugged while the screen is locked.