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 16 matching lines...) Expand all Loading... |
27 namespace ui { | 27 namespace ui { |
28 class InputMethod; | 28 class InputMethod; |
29 } | 29 } |
30 | 30 |
31 namespace views { | 31 namespace views { |
32 namespace test { | 32 namespace test { |
33 class BridgedNativeWidgetTestApi; | 33 class BridgedNativeWidgetTestApi; |
34 } | 34 } |
35 | 35 |
36 class CocoaMouseCapture; | 36 class CocoaMouseCapture; |
| 37 class CocoaWindowMoveLoop; |
37 class NativeWidgetMac; | 38 class NativeWidgetMac; |
38 class View; | 39 class View; |
39 | 40 |
40 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or | 41 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or |
41 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the | 42 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the |
42 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window. | 43 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window. |
43 class VIEWS_EXPORT BridgedNativeWidget | 44 class VIEWS_EXPORT BridgedNativeWidget |
44 : public ui::LayerDelegate, | 45 : public ui::LayerDelegate, |
45 public ui::LayerOwner, | 46 public ui::LayerOwner, |
46 public ui::internal::InputMethodDelegate, | 47 public ui::internal::InputMethodDelegate, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // Sets the desired visibility of the window and updates the visibility of | 93 // Sets the desired visibility of the window and updates the visibility of |
93 // descendant windows where necessary. | 94 // descendant windows where necessary. |
94 void SetVisibilityState(WindowVisibilityState new_state); | 95 void SetVisibilityState(WindowVisibilityState new_state); |
95 | 96 |
96 // Acquiring mouse capture first steals capture from any existing | 97 // Acquiring mouse capture first steals capture from any existing |
97 // CocoaMouseCaptureDelegate, then captures all mouse events until released. | 98 // CocoaMouseCaptureDelegate, then captures all mouse events until released. |
98 void AcquireCapture(); | 99 void AcquireCapture(); |
99 void ReleaseCapture(); | 100 void ReleaseCapture(); |
100 bool HasCapture(); | 101 bool HasCapture(); |
101 | 102 |
| 103 // Start moving the window, pinned to the mouse cursor, and monitor events. |
| 104 // Return MOVE_LOOP_SUCCESSFUL on mouse up or MOVE_LOOP_CANCELED on premature |
| 105 // termination via EndMoveLoop() or when window is destroyed during the drag. |
| 106 Widget::MoveLoopResult RunMoveLoop(const gfx::Vector2d& drag_offset); |
| 107 void EndMoveLoop(); |
| 108 |
102 // See views::Widget. | 109 // See views::Widget. |
103 void SetNativeWindowProperty(const char* key, void* value); | 110 void SetNativeWindowProperty(const char* key, void* value); |
104 void* GetNativeWindowProperty(const char* key) const; | 111 void* GetNativeWindowProperty(const char* key) const; |
105 | 112 |
106 // Sets the cursor associated with the NSWindow. Retains |cursor|. | 113 // Sets the cursor associated with the NSWindow. Retains |cursor|. |
107 void SetCursor(NSCursor* cursor); | 114 void SetCursor(NSCursor* cursor); |
108 | 115 |
109 // Called internally by the NSWindowDelegate when the window is closing. | 116 // Called internally by the NSWindowDelegate when the window is closing. |
110 void OnWindowWillClose(); | 117 void OnWindowWillClose(); |
111 | 118 |
112 // Called by the NSWindowDelegate when a fullscreen operation begins. If | 119 // Called by the NSWindowDelegate when a fullscreen operation begins. If |
113 // |target_fullscreen_state| is true, the target state is fullscreen. | 120 // |target_fullscreen_state| is true, the target state is fullscreen. |
114 // Otherwise, a transition has begun to come out of fullscreen. | 121 // Otherwise, a transition has begun to come out of fullscreen. |
115 void OnFullscreenTransitionStart(bool target_fullscreen_state); | 122 void OnFullscreenTransitionStart(bool target_fullscreen_state); |
116 | 123 |
117 // Called when a fullscreen transition completes. If target_fullscreen_state() | 124 // Called when a fullscreen transition completes. If target_fullscreen_state() |
118 // does not match |actual_fullscreen_state|, a new transition will begin. | 125 // does not match |actual_fullscreen_state|, a new transition will begin. |
119 void OnFullscreenTransitionComplete(bool actual_fullscreen_state); | 126 void OnFullscreenTransitionComplete(bool actual_fullscreen_state); |
120 | 127 |
121 // Transition the window into or out of fullscreen. This will immediately | 128 // Transition the window into or out of fullscreen. This will immediately |
122 // invert the value of target_fullscreen_state(). | 129 // invert the value of target_fullscreen_state(). |
123 void ToggleDesiredFullscreenState(); | 130 void ToggleDesiredFullscreenState(); |
124 | 131 |
125 // Called by the NSWindowDelegate when the size of the window changes. | 132 // Called by the NSWindowDelegate when the size of the window changes. |
126 void OnSizeChanged(); | 133 void OnSizeChanged(); |
127 | 134 |
| 135 // Called once by the NSWindowDelegate when the position of the window has |
| 136 // changed. |
| 137 void OnPositionChanged(); |
| 138 |
128 // Called by the NSWindowDelegate when the visibility of the window may have | 139 // Called by the NSWindowDelegate when the visibility of the window may have |
129 // changed. For example, due to a (de)miniaturize operation, or the window | 140 // changed. For example, due to a (de)miniaturize operation, or the window |
130 // being reordered in (or out of) the screen list. | 141 // being reordered in (or out of) the screen list. |
131 void OnVisibilityChanged(); | 142 void OnVisibilityChanged(); |
132 | 143 |
133 // Explicitly set the visibility. This is called when Cocoa requests a draw, | 144 // Explicitly set the visibility. This is called when Cocoa requests a draw, |
134 // but hasn't updated the value of -[NSWindow isVisible] yet. | 145 // but hasn't updated the value of -[NSWindow isVisible] yet. |
135 void OnVisibilityChangedTo(bool new_visibility); | 146 void OnVisibilityChangedTo(bool new_visibility); |
136 | 147 |
137 // Called by the NSWindowDelegate on a scale factor or color space change. | 148 // Called by the NSWindowDelegate on a scale factor or color space change. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 gfx::Vector2d GetChildWindowOffset() const override; | 266 gfx::Vector2d GetChildWindowOffset() const override; |
256 bool IsVisibleParent() const override; | 267 bool IsVisibleParent() const override; |
257 void RemoveChildWindow(BridgedNativeWidget* child) override; | 268 void RemoveChildWindow(BridgedNativeWidget* child) override; |
258 | 269 |
259 views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this. | 270 views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this. |
260 base::scoped_nsobject<NSWindow> window_; | 271 base::scoped_nsobject<NSWindow> window_; |
261 base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_; | 272 base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_; |
262 base::scoped_nsobject<BridgedContentView> bridged_view_; | 273 base::scoped_nsobject<BridgedContentView> bridged_view_; |
263 std::unique_ptr<ui::InputMethod> input_method_; | 274 std::unique_ptr<ui::InputMethod> input_method_; |
264 std::unique_ptr<CocoaMouseCapture> mouse_capture_; | 275 std::unique_ptr<CocoaMouseCapture> mouse_capture_; |
| 276 std::unique_ptr<CocoaWindowMoveLoop> window_move_loop_; |
265 std::unique_ptr<TooltipManager> tooltip_manager_; | 277 std::unique_ptr<TooltipManager> tooltip_manager_; |
266 FocusManager* focus_manager_; // Weak. Owned by our Widget. | 278 FocusManager* focus_manager_; // Weak. Owned by our Widget. |
267 Widget::InitParams::Type widget_type_; | 279 Widget::InitParams::Type widget_type_; |
268 | 280 |
269 BridgedNativeWidgetOwner* parent_; // Weak. If non-null, owns this. | 281 BridgedNativeWidgetOwner* parent_; // Weak. If non-null, owns this. |
270 std::vector<BridgedNativeWidget*> child_windows_; | 282 std::vector<BridgedNativeWidget*> child_windows_; |
271 | 283 |
272 base::scoped_nsobject<NSView> compositor_superview_; | 284 base::scoped_nsobject<NSView> compositor_superview_; |
273 std::unique_ptr<ui::AcceleratedWidgetMac> compositor_widget_; | 285 std::unique_ptr<ui::AcceleratedWidgetMac> compositor_widget_; |
274 std::unique_ptr<ui::Compositor> compositor_; | 286 std::unique_ptr<ui::Compositor> compositor_; |
(...skipping 24 matching lines...) Expand all Loading... |
299 bool invalidate_shadow_on_frame_swap_ = false; | 311 bool invalidate_shadow_on_frame_swap_ = false; |
300 | 312 |
301 AssociatedViews associated_views_; | 313 AssociatedViews associated_views_; |
302 | 314 |
303 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); | 315 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); |
304 }; | 316 }; |
305 | 317 |
306 } // namespace views | 318 } // namespace views |
307 | 319 |
308 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ | 320 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ |
OLD | NEW |