linebender / glazier

Deprecated Rust Window Creation Library
Apache License 2.0
206 stars 32 forks source link

Failure to detect scale factor change on macOS #175

Open nicoburns opened 12 months ago

nicoburns commented 12 months ago

Tested on: macOS

Tested with:

Dragging a window between monitors with different scale factors causes the rendering to mess up (either scale too large or too small depending on which direction the window was dragged). And this is not corrected by forcing a repaint via resizing the window.

I added a scale function yo the implementation of WinHandler in Xilem, and it is not being called when I drag the window between screens.

nicoburns commented 12 months ago

I am able to react to the scale factor change event by registering a callback for windowDidChangeBackingProperties: (https://developer.apple.com/documentation/appkit/nswindowdelegate/1419517-windowdidchangebackingproperties) in the window delegate similar to https://github.com/rust-windowing/winit/blob/master/src/platform_impl/macos/window_delegate.rs#L156C18-L156C50.

I am also able to retrieve the correct scale factor after this point. But unfortunately rendering still seems to be messed up.

Correct rendering:

Screenshot 2023-11-22 at 16 39 22

After dragging from HiDPI (scale factor 2.0)-> Regular DPI (scale factor 1.0):

Screenshot 2023-11-22 at 16 38 59

After dragging from Regular DPI (scale factor 1.0) -> HiDPI (scale factor 2.0):

Screenshot 2023-11-22 at 16 39 11

The correct rendering is "anchored" to whichever screen the app first launched on and always shows correctly on that screen.