RGFW: incorrect monitor scaling (macOS) (HiDPI)
% ./examples/microui_demo/microui_demo
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: CGRectContainsRect(CGRectMake((CGFloat)INT_MIN, (CGFloat)INT_MIN, (CGFloat)INT_MAX - (CGFloat)INT_MIN, (CGFloat)INT_MAX - (CGFloat)INT_MIN), frame). self=<NSWindow: 0x14d0046c0> frame={{89, 2147483625}, {1262, 946}}'
*** First throw call stack:
(
0 CoreFoundation 0x0000000186e00300 __exceptionPreprocess + 176
1 libobjc.A.dylib 0x00000001868e6cd8 objc_exception_throw + 88
2 Foundation 0x000000018878c978 -[NSMutableDictionary(NSMutableDictionary) initWithContentsOfFile:] + 0
3 AppKit 0x000000018a8fbbac -[NSWindow _reallySetFrame:] + 852
4 AppKit 0x000000018a8fb57c -[NSWindow _oldPlaceWindow:fromServer:] + 188
5 AppKit 0x000000018a8fab88 -[NSWindow _setFrameCommon:display:fromServer:] + 1984
6 microui_demo 0x00000001049e37a4 RGFW_window_move + 316
7 microui_demo 0x00000001049e09a0 RGFW_createWindow + 1816
8 microui_demo 0x00000001049e014c r_init + 84
9 microui_demo 0x00000001049e182c main + 40
10 dyld 0x0000000186924274 start + 2840
)
libc++abi: terminating due to uncaught exception of type NSException
zsh: abort ./examples/microui_demo/microui_demo
Wrong 2nd parameter for the CGRectMake?
M1, Sequoia 15.1.1
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 36 (30 by maintainers)
Works!
@OleksiyPuzikov The latest update should fix all of these issues.
@robrohan According to the apple documentation on backingScaleFactor.
This explains the values we’re seeing when it’s on your hiDPI monitor, versus your non-hiDPI monitor. This seems to have nothing to do with the actually scaling of display, but only scaling if it’s using hiDPI or non hiDPI.
I’ve implemented a function to get the NSScreen from the
CGDirectDisplayIDHowever due to how it would probably be better to calculate if it’s using hiDPI or not in some other way, to avoid extra processing.
May work to calculate this.
I also want to ensure there is some way to check the ‘backingScaleFactor’ on the other backends as well.
I also want to make sure the naming of this value is clear.
For example web uses the term “devicePixelRatio” https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
@robrohan Thank you for all of the information, this is very helpful.
They should be doing the same thing, but I’ve been having issues with my method of scaling windows. As you can see from earlier in the issue, there seem to be some weird results from my method.
I’m pretty sure the scaling should take account for the window size and the scaling option by the OS.