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

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

Issue 1877043003: [EXPERIMENT] MacViews: Implement Tab Dragging Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 4 years, 8 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
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | ui/views/cocoa/bridged_native_widget.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 10 #include <vector>
11 11
12 #import "base/mac/scoped_nsobject.h" 12 #import "base/mac/scoped_nsobject.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #import "ui/accelerated_widget_mac/accelerated_widget_mac.h" 15 #import "ui/accelerated_widget_mac/accelerated_widget_mac.h"
16 #include "ui/base/ime/input_method_delegate.h" 16 #include "ui/base/ime/input_method_delegate.h"
17 #include "ui/compositor/layer_owner.h" 17 #include "ui/compositor/layer_owner.h"
18 #import "ui/views/cocoa/bridged_native_widget_owner.h" 18 #import "ui/views/cocoa/bridged_native_widget_owner.h"
19 #import "ui/views/cocoa/cocoa_mouse_capture_delegate.h" 19 #import "ui/views/cocoa/cocoa_mouse_capture_delegate.h"
20 #import "ui/views/cocoa/cocoa_window_move_loop.h"
20 #import "ui/views/focus/focus_manager.h" 21 #import "ui/views/focus/focus_manager.h"
21 #include "ui/views/views_export.h" 22 #include "ui/views/views_export.h"
22 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
23 24
24 @class BridgedContentView; 25 @class BridgedContentView;
25 @class ViewsNSWindowDelegate; 26 @class ViewsNSWindowDelegate;
26 27
27 namespace ui { 28 namespace ui {
28 class InputMethod; 29 class InputMethod;
29 } 30 }
30 31
31 namespace views { 32 namespace views {
32 namespace test { 33 namespace test {
33 class BridgedNativeWidgetTestApi; 34 class BridgedNativeWidgetTestApi;
34 } 35 }
35 36
36 class CocoaMouseCapture; 37 class CocoaMouseCapture;
38 class CocoaWindowMoveLoop;
37 class NativeWidgetMac; 39 class NativeWidgetMac;
38 class View; 40 class View;
39 41
40 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or 42 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or
41 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the 43 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the
42 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window. 44 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window.
43 class VIEWS_EXPORT BridgedNativeWidget 45 class VIEWS_EXPORT BridgedNativeWidget
44 : public ui::LayerDelegate, 46 : public ui::LayerDelegate,
45 public ui::LayerOwner, 47 public ui::LayerOwner,
46 public ui::internal::InputMethodDelegate, 48 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 94 // Sets the desired visibility of the window and updates the visibility of
93 // descendant windows where necessary. 95 // descendant windows where necessary.
94 void SetVisibilityState(WindowVisibilityState new_state); 96 void SetVisibilityState(WindowVisibilityState new_state);
95 97
96 // Acquiring mouse capture first steals capture from any existing 98 // Acquiring mouse capture first steals capture from any existing
97 // CocoaMouseCaptureDelegate, then captures all mouse events until released. 99 // CocoaMouseCaptureDelegate, then captures all mouse events until released.
98 void AcquireCapture(); 100 void AcquireCapture();
99 void ReleaseCapture(); 101 void ReleaseCapture();
100 bool HasCapture(); 102 bool HasCapture();
101 103
104 // Start moving the window, pinned to the mouse cursor, and monitor events.
105 // Return MOVE_LOOP_SUCCESSFUL on mouse up or MOVE_LOOP_CANCELED on escape.
106 Widget::MoveLoopResult RunMoveLoop(const gfx::Vector2d& drag_offset);
107 void EndMoveLoop();
108 bool IsRunMoveLoopActive() const;
109
102 // See views::Widget. 110 // See views::Widget.
103 void SetNativeWindowProperty(const char* key, void* value); 111 void SetNativeWindowProperty(const char* key, void* value);
104 void* GetNativeWindowProperty(const char* key) const; 112 void* GetNativeWindowProperty(const char* key) const;
105 113
106 // Sets the cursor associated with the NSWindow. Retains |cursor|. 114 // Sets the cursor associated with the NSWindow. Retains |cursor|.
107 void SetCursor(NSCursor* cursor); 115 void SetCursor(NSCursor* cursor);
108 116
109 // Called internally by the NSWindowDelegate when the window is closing. 117 // Called internally by the NSWindowDelegate when the window is closing.
110 void OnWindowWillClose(); 118 void OnWindowWillClose();
111 119
112 // Called by the NSWindowDelegate when a fullscreen operation begins. If 120 // Called by the NSWindowDelegate when a fullscreen operation begins. If
113 // |target_fullscreen_state| is true, the target state is fullscreen. 121 // |target_fullscreen_state| is true, the target state is fullscreen.
114 // Otherwise, a transition has begun to come out of fullscreen. 122 // Otherwise, a transition has begun to come out of fullscreen.
115 void OnFullscreenTransitionStart(bool target_fullscreen_state); 123 void OnFullscreenTransitionStart(bool target_fullscreen_state);
116 124
117 // Called when a fullscreen transition completes. If target_fullscreen_state() 125 // Called when a fullscreen transition completes. If target_fullscreen_state()
118 // does not match |actual_fullscreen_state|, a new transition will begin. 126 // does not match |actual_fullscreen_state|, a new transition will begin.
119 void OnFullscreenTransitionComplete(bool actual_fullscreen_state); 127 void OnFullscreenTransitionComplete(bool actual_fullscreen_state);
120 128
121 // Transition the window into or out of fullscreen. This will immediately 129 // Transition the window into or out of fullscreen. This will immediately
122 // invert the value of target_fullscreen_state(). 130 // invert the value of target_fullscreen_state().
123 void ToggleDesiredFullscreenState(); 131 void ToggleDesiredFullscreenState();
124 132
125 // Called by the NSWindowDelegate when the size of the window changes. 133 // Called by the NSWindowDelegate when the size of the window changes.
126 void OnSizeChanged(); 134 void OnSizeChanged();
127 135
136 // Called once by the NSWindowDelegate when the position of the window has
137 // changed. Called for each mouse event during RunMoveLoop().
138 void OnPositionChanged();
139
128 // Called by the NSWindowDelegate when the visibility of the window may have 140 // 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 141 // changed. For example, due to a (de)miniaturize operation, or the window
130 // being reordered in (or out of) the screen list. 142 // being reordered in (or out of) the screen list.
131 void OnVisibilityChanged(); 143 void OnVisibilityChanged();
132 144
133 // Explicitly set the visibility. This is called when Cocoa requests a draw, 145 // Explicitly set the visibility. This is called when Cocoa requests a draw,
134 // but hasn't updated the value of -[NSWindow isVisible] yet. 146 // but hasn't updated the value of -[NSWindow isVisible] yet.
135 void OnVisibilityChangedTo(bool new_visibility); 147 void OnVisibilityChangedTo(bool new_visibility);
136 148
137 // Called by the NSWindowDelegate on a scale factor or color space change. 149 // Called by the NSWindowDelegate on a scale factor or color space change.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 const std::vector<BridgedNativeWidget*>& child_windows() { 190 const std::vector<BridgedNativeWidget*>& child_windows() {
179 return child_windows_; 191 return child_windows_;
180 } 192 }
181 193
182 bool target_fullscreen_state() const { return target_fullscreen_state_; } 194 bool target_fullscreen_state() const { return target_fullscreen_state_; }
183 bool window_visible() { return window_visible_; } 195 bool window_visible() { return window_visible_; }
184 196
185 // Overridden from ui::internal::InputMethodDelegate: 197 // Overridden from ui::internal::InputMethodDelegate:
186 ui::EventDispatchDetails DispatchKeyEventPostIME(ui::KeyEvent* key) override; 198 ui::EventDispatchDetails DispatchKeyEventPostIME(ui::KeyEvent* key) override;
187 199
200 static void IgnoreNextMouseDownForDraggableRegions();
201
188 private: 202 private:
189 friend class test::BridgedNativeWidgetTestApi; 203 friend class test::BridgedNativeWidgetTestApi;
204 friend class CocoaWindowMoveLoop;
190 205
191 // Closes all child windows. BridgedNativeWidget children will be destroyed. 206 // Closes all child windows. BridgedNativeWidget children will be destroyed.
192 void RemoveOrDestroyChildren(); 207 void RemoveOrDestroyChildren();
193 208
194 // Notify descendants of a visibility change. 209 // Notify descendants of a visibility change.
195 void NotifyVisibilityChangeDown(); 210 void NotifyVisibilityChangeDown();
196 211
197 // Essentially NativeWidgetMac::GetClientAreaBoundsInScreen().size(), but no 212 // Essentially NativeWidgetMac::GetClientAreaBoundsInScreen().size(), but no
198 // coordinate transformations are required from AppKit coordinates. 213 // coordinate transformations are required from AppKit coordinates.
199 gfx::Size GetClientAreaSize() const; 214 gfx::Size GetClientAreaSize() const;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 gfx::Vector2d GetChildWindowOffset() const override; 270 gfx::Vector2d GetChildWindowOffset() const override;
256 bool IsVisibleParent() const override; 271 bool IsVisibleParent() const override;
257 void RemoveChildWindow(BridgedNativeWidget* child) override; 272 void RemoveChildWindow(BridgedNativeWidget* child) override;
258 273
259 views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this. 274 views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this.
260 base::scoped_nsobject<NSWindow> window_; 275 base::scoped_nsobject<NSWindow> window_;
261 base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_; 276 base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_;
262 base::scoped_nsobject<BridgedContentView> bridged_view_; 277 base::scoped_nsobject<BridgedContentView> bridged_view_;
263 scoped_ptr<ui::InputMethod> input_method_; 278 scoped_ptr<ui::InputMethod> input_method_;
264 scoped_ptr<CocoaMouseCapture> mouse_capture_; 279 scoped_ptr<CocoaMouseCapture> mouse_capture_;
280 scoped_ptr<CocoaWindowMoveLoop> window_move_loop_;
265 scoped_ptr<TooltipManager> tooltip_manager_; 281 scoped_ptr<TooltipManager> tooltip_manager_;
266 FocusManager* focus_manager_; // Weak. Owned by our Widget. 282 FocusManager* focus_manager_; // Weak. Owned by our Widget.
267 Widget::InitParams::Type widget_type_; 283 Widget::InitParams::Type widget_type_;
268 284
269 BridgedNativeWidgetOwner* parent_; // Weak. If non-null, owns this. 285 BridgedNativeWidgetOwner* parent_; // Weak. If non-null, owns this.
270 std::vector<BridgedNativeWidget*> child_windows_; 286 std::vector<BridgedNativeWidget*> child_windows_;
271 287
272 base::scoped_nsobject<NSView> compositor_superview_; 288 base::scoped_nsobject<NSView> compositor_superview_;
273 scoped_ptr<ui::AcceleratedWidgetMac> compositor_widget_; 289 scoped_ptr<ui::AcceleratedWidgetMac> compositor_widget_;
274 scoped_ptr<ui::Compositor> compositor_; 290 scoped_ptr<ui::Compositor> compositor_;
275 291
276 // Tracks the bounds when the window last started entering fullscreen. Used to 292 // Tracks the bounds when the window last started entering fullscreen. Used to
277 // provide an answer for GetRestoredBounds(), but not ever sent to Cocoa (it 293 // provide an answer for GetRestoredBounds(), but not ever sent to Cocoa (it
278 // has its own copy, but doesn't provide access to it). 294 // has its own copy, but doesn't provide access to it).
279 gfx::Rect bounds_before_fullscreen_; 295 gfx::Rect bounds_before_fullscreen_;
280 296
297 base::RunLoop* drag_run_loop_ = nullptr;
298
281 // Whether this window wants to be fullscreen. If a fullscreen animation is in 299 // Whether this window wants to be fullscreen. If a fullscreen animation is in
282 // progress then it might not be actually fullscreen. 300 // progress then it might not be actually fullscreen.
283 bool target_fullscreen_state_; 301 bool target_fullscreen_state_;
284 302
285 // Whether this window is in a fullscreen transition, and the fullscreen state 303 // Whether this window is in a fullscreen transition, and the fullscreen state
286 // can not currently be changed. 304 // can not currently be changed.
287 bool in_fullscreen_transition_; 305 bool in_fullscreen_transition_;
288 306
289 // Stores the value last read from -[NSWindow isVisible], to detect visibility 307 // Stores the value last read from -[NSWindow isVisible], to detect visibility
290 // changes. 308 // changes.
291 bool window_visible_; 309 bool window_visible_;
292 310
293 // If true, the window is either visible, or wants to be visible but is 311 // If true, the window is either visible, or wants to be visible but is
294 // currently hidden due to having a hidden parent. 312 // currently hidden due to having a hidden parent.
295 bool wants_to_be_visible_; 313 bool wants_to_be_visible_;
296 314
297 // If true, the window has been made visible or changed shape and the window 315 // If true, the window has been made visible or changed shape and the window
298 // shadow needs to be invalidated when a frame is received for the new shape. 316 // shadow needs to be invalidated when a frame is received for the new shape.
299 bool invalidate_shadow_on_frame_swap_ = false; 317 bool invalidate_shadow_on_frame_swap_ = false;
300 318
301 AssociatedViews associated_views_; 319 AssociatedViews associated_views_;
302 320
303 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); 321 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget);
304 }; 322 };
305 323
306 } // namespace views 324 } // namespace views
307 325
308 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ 326 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_
OLDNEW
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | ui/views/cocoa/bridged_native_widget.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698