Skip to content

RandR screen change: collapse the notify burst onto the newest event, refresh screen data, realign windows from server truth - #251

Merged
fredkiefer merged 2 commits into
gnustep:masterfrom
e4779:randr-screenchange-realign
Oct 15, 2026
Merged

fredkiefer merged 2 commits into
gnustep:masterfrom
e4779:randr-screenchange-realign

Conversation

@e4779

@e4779 e4779 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #249 and the analysis in that thread.

What this changes in the RRScreenChangeNotify branch

  1. Collapse the notify burst onto the newest event. The server defers RRScreenChangeNotify per client until its next request, so a burst often starts with a stale duplicate of the previous state. The drain now assigns inside the loop: the branch always processes the last (newest) event, and *event stays untouched when nothing was drained.

  2. Refresh the backend screen data before the gui rebuilds NSScreen. XRRGetScreenResources can serve cached state one transition old (RRSetScreenSize does not bump the resources config timestamp), so resetScreens can derive the previous screen size. Calling screenList (root geometry + per-CRTC info — the same fresh sources as x11: build single-monitor screen frame from root geometry, not the CRTC #249) before [NSScreen resetScreens] makes the gui see current data.

  3. Realign mapped windows from the server truth. After the screen update, each viewable window is re-read via XGetGeometry/XTranslateCoordinates, its os-frame recomputed and cached, and the corrected origin propagated to the gui via GSAppKitWindowMoved. The backend becomes the single remapper for screen changes.

Validation

Container harness (Xvfb + RANDR, WM-less, GSScaleFactor 1.3): a Terminal window's title bar across a 1280×800 → 1024×768 → 1280×800 cycle moves 271 → 270 → 270 px (a 1 px rounding difference), stable across repeated fresh runs and 4-cycle sequences. Without the change the window jumps ±32 px on every cycle.

Note: the full jump fix is two-layer — this PR pairs with the libs-gui guard in applicationDidChangeScreenParameters: (gnustep/libs-gui#1006), which stops the gui from re-applying the old→new delta onto a frame the backend has already realigned.

…align windows

The server defers RRScreenChangeNotify per client until its next
request, so the notify burst often starts with a stale duplicate:
collapse it onto the last event. XRRGetScreenResources can serve
cached state one transition old (RRSetScreenSize does not bump the
config timestamp), so refresh the backend screen data from fresh
sources before the gui rebuilds NSScreen, then realign mapped
windows from the server truth and propagate the corrected origins
to the gui, making the backend the single remapper for screen
changes.

Pairs with gnustep/libs-gui#1006 (gui-side guard against re-applying
the old->new delta on an already-realigned frame).
Comment thread Source/x11/XGServerEvent.m
Comment thread Source/x11/XGServerEvent.m Outdated
Comment thread Source/x11/XGServerEvent.m Outdated
&& (xEvent.xconfigure.window == RootWindow(dpy, defScreen)))
{
// Check if other RandR events are waiting in the queue.
// The server defers RRScreenChangeNotify per client until

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please advice your LLM to use less verbose comments?

@e4779

e4779 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — fixed in the follow-up commit: braces everywhere, GS_FOR_IN, single-line comments.

@rfm rfm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good/reasonable to me

@e4779
e4779 requested a review from fredkiefer October 15, 2026 11:12
@fredkiefer

Copy link
Copy Markdown
Member

Richard's approval is good enough for me and I like the idea behind this patch.

@fredkiefer
fredkiefer merged commit 36ac709 into gnustep:master Oct 15, 2026
5 checks passed
@e4779
e4779 deleted the randr-screenchange-realign branch October 16, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants