Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macos: Set layerContentsPlacement to topleft #3731

Merged
merged 2 commits into from
Apr 20, 2021
Merged

Conversation

scoopr
Copy link
Contributor

@scoopr scoopr commented Apr 18, 2021

No description provided.

@scoopr
Copy link
Contributor Author

scoopr commented Apr 18, 2021

One weird thing I noticed, that when dragging a window between hidpi and lodpi screens, it tries to animate the change in scale, which I find weird. And I'm not sure how to disable, as I don't know around what I could do the CATransation. But it is a really minor thing.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making this!

@@ -338,7 +338,17 @@ impl GfxManagedMetalLayerDelegate {
}
decl.register();
});
GfxManagedMetalLayerDelegate(Class::get(CAML_DELEGATE_CLASS).unwrap())
let klass = Class::get(CAML_DELEGATE_CLASS).unwrap();
let obj = unsafe { msg_send![klass, new] };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

fn drop(&mut self) {
unsafe {
let () = msg_send![self.0, release];
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra ";"

// doesn't result in stretching, which combined with newly rendered
// frames results in jerky movement.
#[allow(non_upper_case_globals)]
const NSViewLayerContentsPlacementTopLeft: i32 = 11;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit concerned about this path. The view is something controlled by the client, not us. We should try to do minimum changes, if any, to that view. Is it reasonable to say that this should be a winit problem? Or basically, whoever actually manages the NSView, while gfx-rs shouldn't be that person.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now, I agree that winit should be setting the placement, but last time I tried, it didn't work, so I figured it is something about the layer within the view, and not the view itself.

I can do more tests with winit setting it too, but it'll take some time until I can get to it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! if there is something we are missing here, we'd need to know, what it is.
Note that this issue doesn't need to block gfx-0.8, since it's not an API breaking fix.

@kvark kvark added this to the Version 0.8 milestone Apr 18, 2021
@scoopr
Copy link
Contributor Author

scoopr commented Apr 20, 2021

How about this?

Though I was thinking of making the layer delegate a proper instance anyway, with the idea that it would actually return NO, but set the contentScale directly itself and then call out for the layer/view display method, if that would route through the winit to actually draw the layer at that point. But it may be that this is such small corner-case that it doesn't matter.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just one note

src/backend/metal/src/lib.rs Outdated Show resolved Hide resolved
scoopr added 2 commits April 20, 2021 18:48
By setting the contentGravity to top-left, the resizing of the
window doesn't result in stretching, which combined with newly rendered
frames results in jerky movement.
The delegate was set to the class of an object but the delegate method
was an instance method. This just makes it a class method, thereby
fixing the `layer:shouldInheritContentsScale:fromWindow:` method.
Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
bors r+

@bors
Copy link
Contributor

bors bot commented Apr 20, 2021

@bors bors bot merged commit 875d105 into gfx-rs:master Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants