Closed falkTX closed 1 year ago
I don't think using the transientParent here is appropriate (they aren't really related in terms of window hierarchy, and a transient child can be on another display).
Otherwise, seems reasonable enough, although this function is inherently kludgey and will always be potentially broken in certain situations if the scale factor is used before realizing. Doing this properly needs more/different API.
Fixed in 604dbd1, thanks.
I went with something roughly the same as your solution, except it tries a little harder to find some monitor and corresponding scale factor. It will always return a "reasonable" scale factor, although it can still be wrong with multiple displays (always the case in this situation).
Found a little regression from my previous code when updating to latest pugl. Typically we query the scale factor before realizing the view, otherwise the view is created with the wrong size and needs to be resized right after. On Windows, the scaleFactor is cached in pugl internals and only set during realize.
An option for this is to simply fetch the scale factor using the parent window, if one is has been set. IMO
puglGetScaleFactor
should always return a valid value. If there is no view/window yet, simply return the value from the default screen, which is already the case on macOS.The following patch fixes the issue for me:
I can open a PR for the patch if you want.
PS: I did not test under macOS yet.