Repository navigation
Conversation
probonopd
force-pushed
the
fix-per-screen-scale
branch
from
October 26, 2026 18:46
1c0b48e to
7b94a76
Compare
-userSpaceScaleFactor returned GSScaleFactor for every screen, and the frame and content rect conversions of every window used the factor of the main screen, so a monitor of high pixel density next to a normal one could only get one factor for both. When the backend reports different resolutions for the screens, each screen takes its factor from its own resolution. A window keeps the factor it is laid out with in _scaleFactor (the former _reserved_1, so the instance size does not change) and converts its frame and its decoration offsets with it. When a move, a screen parameter change or ordering in gives a window a screen of another factor, the window converts its frame so its content keeps its size in points, lays itself out again and posts NSWindowDidChangeBackingPropertiesNotification with NSBackingPropertyOldScaleFactorKey. A window switches only when it would cover more of the other screen by a margin of 8 pixels, desktop windows keep their factor, and a window that keeps switching stops and logs a warning. -resetCursorRects compares the pointer with the frame of the decoration view rather than its bounds, which are points. When all screens report the same resolution, which includes every single-monitor setup, nothing changes and GSScaleFactor is used as before.
probonopd
force-pushed
the
fix-per-screen-scale
branch
from
October 26, 2026 19:25
7b94a76 to
98993da
Compare
Contributor
|
This looks good to me, but I guess this and all the outstanding screen related issues in gui and back, really ought to be applied more or less together, and I think we need to take care about the order they are applied in too. |
Contributor
Author
|
Agree that this should be looked at after the release. |
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, for example a 4K laptop panel next to a 1080p monitor, GNUstep can only use one scale factor: every NSScreen returns GSScaleFactor and every window converts its frame with the factor of the main screen, so windows are either too large on one monitor or too small on the other. This follows up on the discussion in #191 and #189 and keeps the model settled there: window and screen frames stay in device pixels and the scale stays in libs-gui.
This PR belongs together with gnustep/libs-back#253, which makes the X11 backend report a resolution per monitor (from the RandR output property "DPI" that XLibre creates on every output, 96 = 1.0x). Please merge this one first: on its own it changes nothing, because no backend reports different resolutions for different screens yet (x11 answers 72 dpi, win32 the same system DPI for every screen).
When the backend reports different resolutions for the screens, each NSScreen takes its factor from its own resolution. A window keeps the factor it is laid out with in
_scaleFactor(the former_reserved_1, same size, so no ABI change), and the frame/content conversions of GSWindowDecorationView use the window's factor and its own decoration offsets instead of the main screen's. When a move, a screen parameter change or ordering in gives a window a screen of another factor, it converts its frame so the content keeps its size in points, lays itself out again and posts NSWindowDidChangeBackingPropertiesNotification with NSBackingPropertyOldScaleFactorKey. A window switches only when it would cover more of the other screen by 8 pixels, so a window on the edge switches once; desktop windows keep their factor, and a window that keeps switching stops and logs a warning. When all screens report the same resolution, which includes every single-monitor setup, nothing changes.Two new tests, run against this branch's library (
LD_LIBRARY_PATH=Source/obj, checked with ldd) on Xvfb:The NSScreen test against unpatched master (cacd5cb):
Live, on an Xorg with two dummy outputs (DPI 192 and 96) and both PRs applied, a window with a 300x200 content rect is 600x400 pixels on the first output and 300x200 pixels on the second, its content stays 300x200 points in both directions, and changing DPI at run time converts open windows.
Known limits: font hinting still follows the global GSScaleFactor; saved frames are pixels, so a frame saved on a 2x monitor is converted only when the window is ordered in; a window manager that ignores the client's resize during an interactive move leaves the old pixel size until the next resize; applications that cache
[[NSScreen mainScreen] userSpaceScaleFactor]still assume one factor.cc @pkgdemon