| OLD | NEW |
| 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 #ifndef UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ | 5 #ifndef UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ |
| 6 #define UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ | 6 #define UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 SHOW_AND_ACTIVATE_WINDOW, // Shows with -[NSWindow makeKeyAndOrderFront:]. | 60 SHOW_AND_ACTIVATE_WINDOW, // Shows with -[NSWindow makeKeyAndOrderFront:]. |
| 61 SHOW_INACTIVE, // Shows with -[NSWindow orderWindow:..]. Orders | 61 SHOW_INACTIVE, // Shows with -[NSWindow orderWindow:..]. Orders |
| 62 // the window above its parent if it has one. | 62 // the window above its parent if it has one. |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // Return the size that |window| will take for the given client area |size|, | 65 // Return the size that |window| will take for the given client area |size|, |
| 66 // based on its current style mask. | 66 // based on its current style mask. |
| 67 static gfx::Size GetWindowSizeForClientSize(NSWindow* window, | 67 static gfx::Size GetWindowSizeForClientSize(NSWindow* window, |
| 68 const gfx::Size& size); | 68 const gfx::Size& size); |
| 69 | 69 |
| 70 // Whether an event monitor should be used to intercept window drag events. |
| 71 static bool ShouldUseDragEventMonitor(); |
| 72 |
| 70 // Creates one side of the bridge. |parent| must not be NULL. | 73 // Creates one side of the bridge. |parent| must not be NULL. |
| 71 explicit BridgedNativeWidget(NativeWidgetMac* parent); | 74 explicit BridgedNativeWidget(NativeWidgetMac* parent); |
| 72 ~BridgedNativeWidget() override; | 75 ~BridgedNativeWidget() override; |
| 73 | 76 |
| 74 // Initialize the bridge, "retains" ownership of |window|. | 77 // Initialize the bridge, "retains" ownership of |window|. |
| 75 void Init(base::scoped_nsobject<NSWindow> window, | 78 void Init(base::scoped_nsobject<NSWindow> window, |
| 76 const Widget::InitParams& params); | 79 const Widget::InitParams& params); |
| 77 | 80 |
| 78 // Sets or clears the focus manager to use for tracking focused views. | 81 // Sets or clears the focus manager to use for tracking focused views. |
| 79 // This does NOT take ownership of |focus_manager|. | 82 // This does NOT take ownership of |focus_manager|. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 147 |
| 145 // Called by the NSWindowDelegate when the system control tint changes. | 148 // Called by the NSWindowDelegate when the system control tint changes. |
| 146 void OnSystemControlTintChanged(); | 149 void OnSystemControlTintChanged(); |
| 147 | 150 |
| 148 // Called by the NSWindowDelegate on a scale factor or color space change. | 151 // Called by the NSWindowDelegate on a scale factor or color space change. |
| 149 void OnBackingPropertiesChanged(); | 152 void OnBackingPropertiesChanged(); |
| 150 | 153 |
| 151 // Called by the NSWindowDelegate when the window becomes or resigns key. | 154 // Called by the NSWindowDelegate when the window becomes or resigns key. |
| 152 void OnWindowKeyStatusChangedTo(bool is_key); | 155 void OnWindowKeyStatusChangedTo(bool is_key); |
| 153 | 156 |
| 154 // Called by NSWindowDelegate when the application receives a mouse-down, but | 157 // Returns true if the |event| should initiate a window drag. |
| 155 // before the event is processed by NSWindows. Returning true here will cause | 158 bool ShouldDragWindow(NSEvent* event); |
| 156 // the event to be cancelled and reposted at the CGSessionEventTap level. This | 159 |
| 157 // is used to determine whether a mouse-down should drag the window. | 160 // Called when the application receives a mouse-down, but before the event is |
| 158 virtual bool ShouldRepostPendingLeftMouseDown(NSPoint location_in_window); | 161 // processed by NSWindow. Returning true here will cause the event to be |
| 162 // cancelled and reposted at the CGSessionEventTap level. This is used to |
| 163 // determine whether a mouse-down should drag the window. Only called when |
| 164 // ShouldUseDragEventMonitor() returns true. |
| 165 // Virtual for testing. |
| 166 virtual bool ShouldRepostPendingLeftMouseDown(NSEvent* event); |
| 159 | 167 |
| 160 // Called by NativeWidgetMac when the window size constraints change. | 168 // Called by NativeWidgetMac when the window size constraints change. |
| 161 void OnSizeConstraintsChanged(); | 169 void OnSizeConstraintsChanged(); |
| 162 | 170 |
| 163 // See widget.h for documentation. | 171 // See widget.h for documentation. |
| 164 ui::InputMethod* GetInputMethod(); | 172 ui::InputMethod* GetInputMethod(); |
| 165 | 173 |
| 166 // The restored bounds will be derived from the current NSWindow frame unless | 174 // The restored bounds will be derived from the current NSWindow frame unless |
| 167 // fullscreen or transitioning between fullscreen states. | 175 // fullscreen or transitioning between fullscreen states. |
| 168 gfx::Rect GetRestoredBounds() const; | 176 gfx::Rect GetRestoredBounds() const; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 bool initial_visibility_suppressed_ = false; | 328 bool initial_visibility_suppressed_ = false; |
| 321 | 329 |
| 322 AssociatedViews associated_views_; | 330 AssociatedViews associated_views_; |
| 323 | 331 |
| 324 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); | 332 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); |
| 325 }; | 333 }; |
| 326 | 334 |
| 327 } // namespace views | 335 } // namespace views |
| 328 | 336 |
| 329 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ | 337 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ |
| OLD | NEW |