Skip to content

Commit

Permalink
fix: BrowserView drag now delegates to the OS when possible (#31176)
Browse files Browse the repository at this point in the history
Co-authored-by: @anulman <@anulman>
  • Loading branch information
trop[bot] committed Sep 30, 2021
1 parent 447c073 commit 00969fe
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions shell/browser/native_browser_view_mac.mm
Expand Up @@ -59,7 +59,8 @@ + (void)load {
}

- (BOOL)mouseDownCanMoveWindow {
return NO;
return
[self.window respondsToSelector:@selector(performWindowDragWithEvent:)];
}

- (BOOL)acceptsFirstMouse:(NSEvent*)event {
Expand All @@ -85,16 +86,15 @@ - (NSView*)hitTest:(NSPoint)point {
- (void)mouseDown:(NSEvent*)event {
[super mouseDown:event];

if ([self.window respondsToSelector:@selector(performWindowDragWithEvent)]) {
if ([self.window respondsToSelector:@selector(performWindowDragWithEvent:)]) {
// According to Google, using performWindowDragWithEvent:
// does not generate a NSWindowWillMoveNotification. Hence post one.
[[NSNotificationCenter defaultCenter]
postNotificationName:NSWindowWillMoveNotification
object:self];

if (@available(macOS 10.11, *)) {
[self.window performWindowDragWithEvent:event];
}
[self.window performWindowDragWithEvent:event];

return;
}

Expand All @@ -106,7 +106,7 @@ - (void)mouseDown:(NSEvent*)event {
}

- (void)mouseDragged:(NSEvent*)event {
if ([self.window respondsToSelector:@selector(performWindowDragWithEvent)]) {
if ([self.window respondsToSelector:@selector(performWindowDragWithEvent:)]) {
return;
}

Expand Down

0 comments on commit 00969fe

Please sign in to comment.