Skip to content
This repository was archived by the owner on Jul 15, 2024. It is now read-only.

Initialize ns_window on mac #37

Merged
merged 1 commit into from
Nov 26, 2022
Merged

Initialize ns_window on mac #37

merged 1 commit into from
Nov 26, 2022

Conversation

raphlinus
Copy link
Contributor

We were setting ns_view but not ns_window, which was causing the query to fetch scale to fail, and thus dpi wrong.

I'm not 100% sure we should be calling the window method to get this, we could store the NSWindow pointer in the WindowHandle. The main reason we didn't do this was to support the VST use case, but that's not actively being developed.

In any case, I think this is probably "good enough."

We were setting ns_view but not ns_window, which was causing the query to fetch scale to fail, and thus dpi wrong.

I'm not 100% sure we should be calling the `window` method to get this, we could store the NSWindow pointer in the WindowHandle. The main reason we didn't do this was to support the VST use case, but that's not actively being developed.

In any case, I think this is probably "good enough."
@dfrg
Copy link
Contributor

dfrg commented Nov 26, 2022

Hrm. According to the code, we're grabbing the scale from the view and not the window:

let scale_factor: CGFloat = unsafe { msg_send![*self.nsview.load(), backingScaleFactor] };

Even without this change, scale is currently returning 2.0 for me which should be correct.

@raphlinus
Copy link
Contributor Author

raphlinus commented Nov 26, 2022

It's not the grabbing of the scale factor, it's the setting of it when creating the MetalLayer surface. ns_window was null, so it was being skipped.

This particular code is going away, but it's very easy to imagine that other glazier clients will also depend on ns_window being initialized.

@dfrg
Copy link
Contributor

dfrg commented Nov 26, 2022

Oh! I was looking for references to NSWindow and scale factor and couldn't find them. This explains why :)

@raphlinus raphlinus merged commit 7b2e4a6 into main Nov 26, 2022
@raphlinus raphlinus deleted the mac_dpi branch November 26, 2022 22:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants