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

Side by Side Diff: ui/views/cocoa/native_widget_mac_nswindow.mm

Issue 2475173002: MacViews: Fix window dragging on Sierra. (Closed)
Patch Set: Tests 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ui/views/cocoa/native_widget_mac_nswindow.h" 5 #import "ui/views/cocoa/native_widget_mac_nswindow.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/mac/sdk_forward_declarations.h"
8 #import "ui/views/cocoa/bridged_native_widget.h" 9 #import "ui/views/cocoa/bridged_native_widget.h"
9 #import "ui/base/cocoa/user_interface_item_command_handler.h" 10 #import "ui/base/cocoa/user_interface_item_command_handler.h"
10 #import "ui/views/cocoa/views_nswindow_delegate.h" 11 #import "ui/views/cocoa/views_nswindow_delegate.h"
11 #include "ui/views/controls/menu/menu_controller.h" 12 #include "ui/views/controls/menu/menu_controller.h"
12 #include "ui/views/widget/native_widget_mac.h" 13 #include "ui/views/widget/native_widget_mac.h"
13 #include "ui/views/widget/widget_delegate.h" 14 #include "ui/views/widget/widget_delegate.h"
14 15
15 @interface NSWindow (Private) 16 @interface NSWindow (Private)
16 - (BOOL)hasKeyAppearance; 17 - (BOOL)hasKeyAppearance;
17 @end 18 @end
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 !views::NativeWidgetMac::GetBridgeForNativeWindow(self)->parent(); 101 !views::NativeWidgetMac::GetBridgeForNativeWindow(self)->parent();
101 } 102 }
102 103
103 // Lets the traffic light buttons on the parent window keep their active state. 104 // Lets the traffic light buttons on the parent window keep their active state.
104 - (BOOL)hasKeyAppearance { 105 - (BOOL)hasKeyAppearance {
105 if ([self delegate] && [self viewsWidget]->IsAlwaysRenderAsActive()) 106 if ([self delegate] && [self viewsWidget]->IsAlwaysRenderAsActive())
106 return YES; 107 return YES;
107 return [super hasKeyAppearance]; 108 return [super hasKeyAppearance];
108 } 109 }
109 110
110 // Override sendEvent to allow key events to be forwarded to a toolkit-views 111 // Override sendEvent to intercept window drag events and allow key events to be
111 // menu while it is active, and while still allowing any native subview to 112 // forwarded to a toolkit-views menu while it is active, and while still
112 // retain firstResponder status. 113 // allowing any native subview to retain firstResponder status.
113 - (void)sendEvent:(NSEvent*)event { 114 - (void)sendEvent:(NSEvent*)event {
114 // Let CommandDispatcher check if this is a redispatched event. 115 // Let CommandDispatcher check if this is a redispatched event.
115 if ([commandDispatcher_ preSendEvent:event]) 116 if ([commandDispatcher_ preSendEvent:event])
116 return; 117 return;
117 118
119 // If a window drag event monitor is not used, query the BridgedNativeWidget
120 // to decide if a window drag should be performed.
121 if (!views::BridgedNativeWidget::ShouldUseDragEventMonitor()) {
122 views::BridgedNativeWidget* bridge =
123 views::NativeWidgetMac::GetBridgeForNativeWindow(self);
124
125 if (bridge && bridge->ShouldDragWindow(event)) {
126 [self performWindowDragWithEvent:event];
127 return;
128 }
129 }
130
118 NSEventType type = [event type]; 131 NSEventType type = [event type];
119 if ((type != NSKeyDown && type != NSKeyUp) || ![self hasViewsMenuActive]) { 132 if ((type != NSKeyDown && type != NSKeyUp) || ![self hasViewsMenuActive]) {
120 [super sendEvent:event]; 133 [super sendEvent:event];
121 return; 134 return;
122 } 135 }
123 136
124 // Send to the menu, after converting the event into an action message using 137 // Send to the menu, after converting the event into an action message using
125 // the content view. 138 // the content view.
126 if (type == NSKeyDown) 139 if (type == NSKeyDown)
127 [[self contentView] keyDown:event]; 140 [[self contentView] keyDown:event];
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 id appController = [NSApp delegate]; 214 id appController = [NSApp delegate];
202 DCHECK([appController 215 DCHECK([appController
203 conformsToProtocol:@protocol(NSUserInterfaceValidations)]); 216 conformsToProtocol:@protocol(NSUserInterfaceValidations)]);
204 return [appController validateUserInterfaceItem:item]; 217 return [appController validateUserInterfaceItem:item];
205 } 218 }
206 219
207 return [super validateUserInterfaceItem:item]; 220 return [super validateUserInterfaceItem:item];
208 } 221 }
209 222
210 @end 223 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698