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

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

Issue 789763002: MacViews: Implement capture using NSEvent local+global monitors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20140812-MacViews-LAYERS2-PRESQUASH
Patch Set: fix sorting Created 6 years 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 #include <vector> 9 #include <vector>
10 10
11 #import "base/mac/scoped_nsobject.h" 11 #import "base/mac/scoped_nsobject.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "ui/compositor/layer_owner.h" 13 #include "ui/compositor/layer_owner.h"
14 #import "ui/accelerated_widget_mac/accelerated_widget_mac.h" 14 #import "ui/accelerated_widget_mac/accelerated_widget_mac.h"
15 #import "ui/views/cocoa/cocoa_mouse_capture_delegate.h"
15 #import "ui/views/focus/focus_manager.h" 16 #import "ui/views/focus/focus_manager.h"
16 #include "ui/views/ime/input_method_delegate.h" 17 #include "ui/views/ime/input_method_delegate.h"
17 #include "ui/views/views_export.h" 18 #include "ui/views/views_export.h"
18 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
19 20
20 @class BridgedContentView; 21 @class BridgedContentView;
21 @class ViewsNSWindowDelegate; 22 @class ViewsNSWindowDelegate;
22 23
23 namespace ui { 24 namespace ui {
24 class InputMethod; 25 class InputMethod;
25 } 26 }
26 27
27 namespace views { 28 namespace views {
28 29
30 class CocoaMouseCapture;
29 class InputMethod; 31 class InputMethod;
30 class NativeWidgetMac; 32 class NativeWidgetMac;
31 class View; 33 class View;
32 34
33 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or 35 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or
34 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the 36 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the
35 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window. 37 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window.
36 class VIEWS_EXPORT BridgedNativeWidget : public ui::LayerDelegate, 38 class VIEWS_EXPORT BridgedNativeWidget : public ui::LayerDelegate,
37 public ui::LayerOwner, 39 public ui::LayerOwner,
38 public internal::InputMethodDelegate, 40 public internal::InputMethodDelegate,
41 public CocoaMouseCaptureDelegate,
39 public FocusChangeListener, 42 public FocusChangeListener,
40 public ui::AcceleratedWidgetMacNSView { 43 public ui::AcceleratedWidgetMacNSView {
41 public: 44 public:
42 // Ways of changing the visibility of the bridged NSWindow. 45 // Ways of changing the visibility of the bridged NSWindow.
43 enum WindowVisibilityState { 46 enum WindowVisibilityState {
44 HIDE_WINDOW, // Hides with -[NSWindow orderOut:]. 47 HIDE_WINDOW, // Hides with -[NSWindow orderOut:].
45 SHOW_AND_ACTIVATE_WINDOW, // Shows with -[NSWindow makeKeyAndOrderFront:]. 48 SHOW_AND_ACTIVATE_WINDOW, // Shows with -[NSWindow makeKeyAndOrderFront:].
46 SHOW_INACTIVE, // Shows with -[NSWindow orderWindow:..]. Orders 49 SHOW_INACTIVE, // Shows with -[NSWindow orderWindow:..]. Orders
47 // the window above its parent if it has one. 50 // the window above its parent if it has one.
48 }; 51 };
(...skipping 14 matching lines...) Expand all
63 void SetBounds(const gfx::Rect& new_bounds); 66 void SetBounds(const gfx::Rect& new_bounds);
64 67
65 // Set or clears the views::View bridged by the content view. This does NOT 68 // Set or clears the views::View bridged by the content view. This does NOT
66 // take ownership of |view|. 69 // take ownership of |view|.
67 void SetRootView(views::View* view); 70 void SetRootView(views::View* view);
68 71
69 // Sets the desired visibility of the window and updates the visibility of 72 // Sets the desired visibility of the window and updates the visibility of
70 // descendant windows where necessary. 73 // descendant windows where necessary.
71 void SetVisibilityState(WindowVisibilityState new_state); 74 void SetVisibilityState(WindowVisibilityState new_state);
72 75
76 // Acquiring mouse capture first steals capture from any existing
77 // CocoaMouseCaptureDelegate, then captures all mouse events until released.
78 void AcquireCapture();
79 void ReleaseCapture();
80 bool HasCapture();
81
73 // Called internally by the NSWindowDelegate when the window is closing. 82 // Called internally by the NSWindowDelegate when the window is closing.
74 void OnWindowWillClose(); 83 void OnWindowWillClose();
75 84
76 // Called by the NSWindowDelegate when a fullscreen operation begins. If 85 // Called by the NSWindowDelegate when a fullscreen operation begins. If
77 // |target_fullscreen_state| is true, the target state is fullscreen. 86 // |target_fullscreen_state| is true, the target state is fullscreen.
78 // Otherwise, a transition has begun to come out of fullscreen. 87 // Otherwise, a transition has begun to come out of fullscreen.
79 void OnFullscreenTransitionStart(bool target_fullscreen_state); 88 void OnFullscreenTransitionStart(bool target_fullscreen_state);
80 89
81 // Called when a fullscreen transition completes. If target_fullscreen_state() 90 // Called when a fullscreen transition completes. If target_fullscreen_state()
82 // does not match |actual_fullscreen_state|, a new transition will begin. 91 // does not match |actual_fullscreen_state|, a new transition will begin.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 void DestroyCompositor(); 160 void DestroyCompositor();
152 161
153 // Installs the NSView for hosting the composited layer. It is later provided 162 // Installs the NSView for hosting the composited layer. It is later provided
154 // to |compositor_widget_| via AcceleratedWidgetGetNSView(). 163 // to |compositor_widget_| via AcceleratedWidgetGetNSView().
155 void AddCompositorSuperview(); 164 void AddCompositorSuperview();
156 165
157 // Size the layer to match the client area bounds, taking into account display 166 // Size the layer to match the client area bounds, taking into account display
158 // scale factor. 167 // scale factor.
159 void UpdateLayerProperties(); 168 void UpdateLayerProperties();
160 169
170 // Overridden from CocoaMouseCaptureDelegate:
171 void PostCapturedEvent(NSEvent* event) override;
172 void OnMouseCaptureLost() override;
173
161 // Overridden from FocusChangeListener: 174 // Overridden from FocusChangeListener:
162 void OnWillChangeFocus(View* focused_before, 175 void OnWillChangeFocus(View* focused_before,
163 View* focused_now) override; 176 View* focused_now) override;
164 void OnDidChangeFocus(View* focused_before, 177 void OnDidChangeFocus(View* focused_before,
165 View* focused_now) override; 178 View* focused_now) override;
166 179
167 // Overridden from ui::LayerDelegate: 180 // Overridden from ui::LayerDelegate:
168 void OnPaintLayer(gfx::Canvas* canvas) override; 181 void OnPaintLayer(gfx::Canvas* canvas) override;
169 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; 182 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override;
170 void OnDeviceScaleFactorChanged(float device_scale_factor) override; 183 void OnDeviceScaleFactorChanged(float device_scale_factor) override;
171 base::Closure PrepareForLayerBoundsChange() override; 184 base::Closure PrepareForLayerBoundsChange() override;
172 185
173 // Overridden from ui::AcceleratedWidgetMac: 186 // Overridden from ui::AcceleratedWidgetMac:
174 NSView* AcceleratedWidgetGetNSView() const override; 187 NSView* AcceleratedWidgetGetNSView() const override;
175 bool AcceleratedWidgetShouldIgnoreBackpressure() const override; 188 bool AcceleratedWidgetShouldIgnoreBackpressure() const override;
176 void AcceleratedWidgetSwapCompleted( 189 void AcceleratedWidgetSwapCompleted(
177 const std::vector<ui::LatencyInfo>& latency_info) override; 190 const std::vector<ui::LatencyInfo>& latency_info) override;
178 void AcceleratedWidgetHitError() override; 191 void AcceleratedWidgetHitError() override;
179 192
180 views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this. 193 views::NativeWidgetMac* native_widget_mac_; // Weak. Owns this.
181 base::scoped_nsobject<NSWindow> window_; 194 base::scoped_nsobject<NSWindow> window_;
182 base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_; 195 base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_;
183 base::scoped_nsobject<BridgedContentView> bridged_view_; 196 base::scoped_nsobject<BridgedContentView> bridged_view_;
184 scoped_ptr<ui::InputMethod> input_method_; 197 scoped_ptr<ui::InputMethod> input_method_;
198 scoped_ptr<CocoaMouseCapture> mouse_capture_;
185 FocusManager* focus_manager_; // Weak. Owned by our Widget. 199 FocusManager* focus_manager_; // Weak. Owned by our Widget.
186 200
187 BridgedNativeWidget* parent_; // Weak. If non-null, owns this. 201 BridgedNativeWidget* parent_; // Weak. If non-null, owns this.
188 std::vector<BridgedNativeWidget*> child_windows_; 202 std::vector<BridgedNativeWidget*> child_windows_;
189 203
190 base::scoped_nsobject<NSView> compositor_superview_; 204 base::scoped_nsobject<NSView> compositor_superview_;
191 scoped_ptr<ui::AcceleratedWidgetMac> compositor_widget_; 205 scoped_ptr<ui::AcceleratedWidgetMac> compositor_widget_;
192 scoped_ptr<ui::Compositor> compositor_; 206 scoped_ptr<ui::Compositor> compositor_;
193 207
194 // Tracks the bounds when the window last started entering fullscreen. Used to 208 // Tracks the bounds when the window last started entering fullscreen. Used to
(...skipping 16 matching lines...) Expand all
211 // If true, the window is either visible, or wants to be visible but is 225 // If true, the window is either visible, or wants to be visible but is
212 // currently hidden due to having a hidden parent. 226 // currently hidden due to having a hidden parent.
213 bool wants_to_be_visible_; 227 bool wants_to_be_visible_;
214 228
215 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); 229 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget);
216 }; 230 };
217 231
218 } // namespace views 232 } // namespace views
219 233
220 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ 234 #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