Repository navigation
Conversation
resolutionForScreen: always returned 72x72, so the gui could not tell monitors of different pixel density apart. It now returns the resolution of the monitor it is asked for, from the RandR output property "DPI" (96 = 1.0x, created by XLibre for every output and settable by any client on other servers), or, when the user default GSScreenScaleFromSize is set, from the output's physical size, rounded to GSScaleFactorStep (0.25). A change of "DPI" is handled like a screen change. When every monitor reports the same value, 72x72 is returned as before, so GSScaleFactor stays in charge. The new styleoffsets:::::window: returns the offsets of one window from its own _NET_FRAME_EXTENTS, kept per window and refreshed when the property changes, since a window manager that draws title bars per monitor gives windows of the same style different extents. The resize event for such a change is delivered in order with those of ConfigureNotify, and ConfigureNotify sizes older than the last resize request are ignored, so a window moving between monitors keeps the size the gui gave it. Cursors get the size of the monitor under the pointer: theme cursors are loaded at 24 pixels times its factor and image cursors are resampled from their size in points (Source/x11/cursorscale.c, tested in Tests/x11/cursorscale.m). When every monitor runs at 1.0, cursors are made exactly as before.
probonopd
force-pushed
the
fix-per-screen-scale
branch
from
October 26, 2026 18:43
aaeba43 to
4de42f2
Compare
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.
With two monitors of different pixel density,
-resolutionForScreen:returns 72x72 for every monitor, so the gui cannot tell them apart and draws everything at one scale factor.This PR belongs together with gnustep/libs-gui#1019, which gives each NSScreen and each window its own factor. Please merge the libs-gui one first; this one depends on it to lay windows out per monitor.
-resolutionForScreen:now returns the resolution of the monitor it is asked for (NSScreen already passes the monitor index), taken from the RandR output property "DPI" (INTEGER, 96 = 1.0x). XLibre creates that property on every output, and on other servers any client, such as a display configuration tool, can create it with XRRChangeOutputProperty. As an opt-in, the user default GSScreenScaleFromSize derives it from the output's physical size, rounded to GSScaleFactorStep (0.25). A change of "DPI" is handled like a screen change. When every monitor reports the same value, which includes every single-monitor setup, 72x72 is returned as before and GSScaleFactor stays in charge.The rest makes windows behave when they cross monitors:
styleoffsets:::::window:returns one window's own_NET_FRAME_EXTENTS, kept per window and refreshed on change, since a window manager that draws title bars per monitor gives windows of the same style different extents; that resize is delivered in order with the ConfigureNotify ones; and ConfigureNotify sizes older than the last resize request are ignored, which otherwise made a window lose width on every round trip between monitors. Cursors get the size of the monitor under the pointer (theme cursors at 24 px times its factor, image cursors resampled from points); with every monitor at 1.0 they are made exactly as before.The size rule and the resampling are covered by a new test:
The rest of Tests/x11 gives the same result with and without this branch here (4 failures in decorationfallback.m, frameextents.m and reparentoffsets.m on master too, because those tests load the installed backend). Live, on an Xorg with two dummy outputs whose "DPI" was set to 192 and 96, a window with a 300x200 content rect is 600x400 pixels on the first and 300x200 on the second, and setting "DPI" at run time converts open windows.
Known limits: the "DPI" property is only created automatically by XLibre; on Xorg something has to set it (the GSScreenScaleFromSize fallback is opt-in because the server's physical sizes are not always trustworthy); cursors without a theme come from the cursor font in one size.
cc @pkgdemon