Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Unified Diff: ui/views/cocoa/native_widget_mac_nswindow.mm

Issue 2475173002: MacViews: Fix window dragging on Sierra. (Closed)
Patch Set: Rebase. Update comment. #include=>#import. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..0f077fe12b65c90ba4126e6ba6496e134b0071f7 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"
+#import "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 @@ - (BOOL)hasKeyAppearance {
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]
+ postNotificationName:NSWindowWillMoveNotification
+ object:self];
+
+ [self performWindowDragWithEvent:event];
+ return;
+ }
+ }
+
NSEventType type = [event type];
if ((type != NSKeyDown && type != NSKeyUp) || ![self hasViewsMenuActive]) {
[super sendEvent:event];
« no previous file with comments | « ui/views/cocoa/bridged_native_widget_interactive_uitest.mm ('k') | ui/views/cocoa/views_nswindow_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698