Chromium Code Reviews| Index: ui/views/cocoa/native_widget_mac_nswindow.mm |
| diff --git a/ui/views/cocoa/native_widget_mac_nswindow.mm b/ui/views/cocoa/native_widget_mac_nswindow.mm |
| index f3ccb522652a85af015b7bf64c9c3651ae8d91dd..46b1a15ac93d21233a0c9409acef32a8bfa41b88 100644 |
| --- a/ui/views/cocoa/native_widget_mac_nswindow.mm |
| +++ b/ui/views/cocoa/native_widget_mac_nswindow.mm |
| @@ -5,6 +5,7 @@ |
| #import "ui/views/cocoa/native_widget_mac_nswindow.h" |
| #include "base/mac/foundation_util.h" |
| +#include "base/mac/sdk_forward_declarations.h" |
| #import "ui/views/cocoa/bridged_native_widget.h" |
| #import "ui/base/cocoa/user_interface_item_command_handler.h" |
| #import "ui/views/cocoa/views_nswindow_delegate.h" |
| @@ -107,14 +108,32 @@ |
| return [super hasKeyAppearance]; |
| } |
| -// Override sendEvent to allow key events to be forwarded to a toolkit-views |
| -// menu while it is active, and while still allowing any native subview to |
| -// retain firstResponder status. |
| +// Override sendEvent to intercept window drag events and allow key events to be |
| +// forwarded to a toolkit-views menu while it is active, and while still |
| +// allowing any native subview to retain firstResponder status. |
| - (void)sendEvent:(NSEvent*)event { |
| // Let CommandDispatcher check if this is a redispatched event. |
| if ([commandDispatcher_ preSendEvent:event]) |
| return; |
| + // If a window drag event monitor is not used, query the BridgedNativeWidget |
| + // to decide if a window drag should be performed. |
| + if (!views::BridgedNativeWidget::ShouldUseDragEventMonitor()) { |
| + views::BridgedNativeWidget* bridge = |
| + views::NativeWidgetMac::GetBridgeForNativeWindow(self); |
| + |
| + if (bridge && bridge->ShouldDragWindow(event)) { |
| + // Using performWindowDragWithEvent: does not generate a |
| + // NSWindowWillMoveNotification. Hence post one. |
| + [[NSNotificationCenter defaultCenter] |
|
karandeepb
2016/11/09 04:44:20
Have added this notification. I am not sure if it'
tapted
2016/11/09 05:06:56
Ooh nice - this seems legit. So long as we track w
karandeepb
2016/11/09 06:33:22
Yes correct.
|
| + postNotificationName:NSWindowWillMoveNotification |
| + object:self]; |
| + |
| + [self performWindowDragWithEvent:event]; |
| + return; |
| + } |
| + } |
| + |
| NSEventType type = [event type]; |
| if ((type != NSKeyDown && type != NSKeyUp) || ![self hasViewsMenuActive]) { |
| [super sendEvent:event]; |