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

Side by Side 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 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 #import "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 // Using performWindowDragWithEvent: does not generate a
127 // NSWindowWillMoveNotification. Hence post one.
128 [[NSNotificationCenter defaultCenter]
129 postNotificationName:NSWindowWillMoveNotification
130 object:self];
131
132 [self performWindowDragWithEvent:event];
133 return;
134 }
135 }
136
118 NSEventType type = [event type]; 137 NSEventType type = [event type];
119 if ((type != NSKeyDown && type != NSKeyUp) || ![self hasViewsMenuActive]) { 138 if ((type != NSKeyDown && type != NSKeyUp) || ![self hasViewsMenuActive]) {
120 [super sendEvent:event]; 139 [super sendEvent:event];
121 return; 140 return;
122 } 141 }
123 142
124 // Send to the menu, after converting the event into an action message using 143 // Send to the menu, after converting the event into an action message using
125 // the content view. 144 // the content view.
126 if (type == NSKeyDown) 145 if (type == NSKeyDown)
127 [[self contentView] keyDown:event]; 146 [[self contentView] keyDown:event];
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 id appController = [NSApp delegate]; 220 id appController = [NSApp delegate];
202 DCHECK([appController 221 DCHECK([appController
203 conformsToProtocol:@protocol(NSUserInterfaceValidations)]); 222 conformsToProtocol:@protocol(NSUserInterfaceValidations)]);
204 return [appController validateUserInterfaceItem:item]; 223 return [appController validateUserInterfaceItem:item];
205 } 224 }
206 225
207 return [super validateUserInterfaceItem:item]; 226 return [super validateUserInterfaceItem:item];
208 } 227 }
209 228
210 @end 229 @end
OLDNEW
« 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