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

Side by Side Diff: ui/views/cocoa/bridged_native_widget.h

Issue 1747803003: MacViews: Implement Tab Dragging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove CGEvent-generating code from ui_controls_mac.mm Created 4 years, 6 months 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 #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
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
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 191 }
181 192
182 bool target_fullscreen_state() const { return target_fullscreen_state_; } 193 bool target_fullscreen_state() const { return target_fullscreen_state_; }
183 bool window_visible() { return window_visible_; } 194 bool window_visible() { return window_visible_; }
184 195
185 // Overridden from ui::internal::InputMethodDelegate: 196 // Overridden from ui::internal::InputMethodDelegate:
186 ui::EventDispatchDetails DispatchKeyEventPostIME(ui::KeyEvent* key) override; 197 ui::EventDispatchDetails DispatchKeyEventPostIME(ui::KeyEvent* key) override;
187 198
188 private: 199 private:
189 friend class test::BridgedNativeWidgetTestApi; 200 friend class test::BridgedNativeWidgetTestApi;
201 friend class CocoaWindowMoveLoop;
190 202
191 // Closes all child windows. BridgedNativeWidget children will be destroyed. 203 // Closes all child windows. BridgedNativeWidget children will be destroyed.
192 void RemoveOrDestroyChildren(); 204 void RemoveOrDestroyChildren();
193 205
194 // Notify descendants of a visibility change. 206 // Notify descendants of a visibility change.
195 void NotifyVisibilityChangeDown(); 207 void NotifyVisibilityChangeDown();
196 208
197 // Essentially NativeWidgetMac::GetClientAreaBoundsInScreen().size(), but no 209 // Essentially NativeWidgetMac::GetClientAreaBoundsInScreen().size(), but no
198 // coordinate transformations are required from AppKit coordinates. 210 // coordinate transformations are required from AppKit coordinates.
199 gfx::Size GetClientAreaSize() const; 211 gfx::Size GetClientAreaSize() const;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 gfx::Vector2d GetChildWindowOffset() const override; 267 gfx::Vector2d GetChildWindowOffset() const override;
256 bool IsVisibleParent() const override; 268 bool IsVisibleParent() const override;
257 void RemoveChildWindow(BridgedNativeWidget* child) override; 269 void RemoveChildWindow(BridgedNativeWidget* child) override;
258 270
259 views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this. 271 views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this.
260 base::scoped_nsobject<NSWindow> window_; 272 base::scoped_nsobject<NSWindow> window_;
261 base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_; 273 base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_;
262 base::scoped_nsobject<BridgedContentView> bridged_view_; 274 base::scoped_nsobject<BridgedContentView> bridged_view_;
263 std::unique_ptr<ui::InputMethod> input_method_; 275 std::unique_ptr<ui::InputMethod> input_method_;
264 std::unique_ptr<CocoaMouseCapture> mouse_capture_; 276 std::unique_ptr<CocoaMouseCapture> mouse_capture_;
277 std::unique_ptr<CocoaWindowMoveLoop> window_move_loop_;
265 std::unique_ptr<TooltipManager> tooltip_manager_; 278 std::unique_ptr<TooltipManager> tooltip_manager_;
266 FocusManager* focus_manager_; // Weak. Owned by our Widget. 279 FocusManager* focus_manager_; // Weak. Owned by our Widget.
267 Widget::InitParams::Type widget_type_; 280 Widget::InitParams::Type widget_type_;
268 281
269 BridgedNativeWidgetOwner* parent_; // Weak. If non-null, owns this. 282 BridgedNativeWidgetOwner* parent_; // Weak. If non-null, owns this.
270 std::vector<BridgedNativeWidget*> child_windows_; 283 std::vector<BridgedNativeWidget*> child_windows_;
271 284
272 base::scoped_nsobject<NSView> compositor_superview_; 285 base::scoped_nsobject<NSView> compositor_superview_;
273 std::unique_ptr<ui::AcceleratedWidgetMac> compositor_widget_; 286 std::unique_ptr<ui::AcceleratedWidgetMac> compositor_widget_;
274 std::unique_ptr<ui::Compositor> compositor_; 287 std::unique_ptr<ui::Compositor> compositor_;
(...skipping 24 matching lines...) Expand all
299 bool invalidate_shadow_on_frame_swap_ = false; 312 bool invalidate_shadow_on_frame_swap_ = false;
300 313
301 AssociatedViews associated_views_; 314 AssociatedViews associated_views_;
302 315
303 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); 316 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget);
304 }; 317 };
305 318
306 } // namespace views 319 } // namespace views
307 320
308 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ 321 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698