-
Notifications
You must be signed in to change notification settings - Fork 328
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
devdraw: Handle windowDidResize to support non-live window resize. #212
devdraw: Handle windowDidResize to support non-live window resize. #212
Conversation
src/cmd/devdraw/cocoa-screen-metal.m
Outdated
- (void)windowDidResize:(NSNotification *)notification | ||
{ | ||
if([self inLiveResize]) { | ||
LOG(@"Skip resizeimg in live resize"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this useful? Seems like it would overwhelm the log whenever a user-driven resize is active.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattwidmann Thank you for your review! I'll remove this debug Log.
src/cmd/devdraw/cocoa-screen-metal.m
Outdated
@@ -197,6 +197,7 @@ + (void)makewin:(NSValue *)v | |||
[win setContentView:myContent]; | |||
[myContent setWantsLayer:YES]; | |||
[myContent setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay]; | |||
[[NSNotificationCenter defaultCenter] addObserver:myContent selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:nil]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this pass win
as the object? I wonder why myContent
would work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to register this event for the view. Just using the NSApplicationDelegate method should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review!
@jxy If I use NSWindowDelegate method on AppDelgate,
How can I check inLiveResize flag of DevDrawView?
I'll check inLiveReisize through myContent
value thanks!
src/cmd/devdraw/cocoa-screen-metal.m
Outdated
@@ -373,6 +374,12 @@ - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theAppl | |||
return YES; | |||
} | |||
|
|||
- (void)windowWillClose:(NSNotification *)notification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need a notification registered for it, too? Or is this enabled by default when asking for another notification on the window?
This may overlap with other resizing event. Perhaps we need to remove other events that calls resizeimg? |
@jxy Thank you for your review When I resize by mouse, |
src/cmd/devdraw/cocoa-screen-metal.m
Outdated
@@ -373,6 +373,13 @@ - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theAppl | |||
return YES; | |||
} | |||
|
|||
- (void)windowDidResize:(NSNotification *)notification | |||
{ | |||
if(![myContent inLiveResize]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that we probably need to check if img is nil before calling resizeimg. It may get resized before attachscreen.
I think setContentSize would trigger windowDidResize. Please verify. Probably we can just remove the resizeimg call after the call to setContentSize in function resizewindow. |
It's probably better to squash your commits. |
@jxy Thank you for your review! I just update codes & squashed |
Compiling this on macos 10.14.5 I get:
|
Yes. There is an extra |
@mkmik Thank you for your reporting! Fixed :) |
This supports non-live window resize.
Committed, thanks. |
Some window management tools (e.g Moom which I'm using on my mac) using Accessibility API to support resizing window from keyboard.
And current Metal cocoa screen (Implemented in #194) only redraw after live resize event to improve performance.
But window resizing through accessibility API does not sent live-resize event.
So I'm add a handler for windowDidResize event, and check inLiveResize flag to skip inefficient redraw.