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

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

Issue 1177503003: Remove the 2-level input method system & InputMethodBridge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: makes trybots green. Created 5 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 #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/bridged_native_widget_owner.h" 15 #import "ui/views/cocoa/bridged_native_widget_owner.h"
16 #import "ui/views/cocoa/cocoa_mouse_capture_delegate.h" 16 #import "ui/views/cocoa/cocoa_mouse_capture_delegate.h"
17 #import "ui/views/focus/focus_manager.h" 17 #import "ui/views/focus/focus_manager.h"
18 #include "ui/views/ime/input_method_delegate.h"
19 #include "ui/views/views_export.h" 18 #include "ui/views/views_export.h"
20 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
21 20
22 @class BridgedContentView; 21 @class BridgedContentView;
23 @class ViewsNSWindowDelegate; 22 @class ViewsNSWindowDelegate;
24 23
25 namespace ui { 24 namespace ui {
26 class InputMethod; 25 class InputMethod;
27 } 26 }
28 27
29 namespace views { 28 namespace views {
30 29
31 class CocoaMouseCapture; 30 class CocoaMouseCapture;
32 class InputMethod;
33 class NativeWidgetMac; 31 class NativeWidgetMac;
34 class View; 32 class View;
35 33
36 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or 34 // A bridge to an NSWindow managed by an instance of NativeWidgetMac or
37 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the 35 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the
38 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window. 36 // NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window.
39 class VIEWS_EXPORT BridgedNativeWidget : public ui::LayerDelegate, 37 class VIEWS_EXPORT BridgedNativeWidget : public ui::LayerDelegate,
40 public ui::LayerOwner, 38 public ui::LayerOwner,
41 public internal::InputMethodDelegate,
42 public CocoaMouseCaptureDelegate, 39 public CocoaMouseCaptureDelegate,
43 public FocusChangeListener, 40 public FocusChangeListener,
44 public ui::AcceleratedWidgetMacNSView, 41 public ui::AcceleratedWidgetMacNSView,
45 public BridgedNativeWidgetOwner { 42 public BridgedNativeWidgetOwner {
46 public: 43 public:
47 // Ways of changing the visibility of the bridged NSWindow. 44 // Ways of changing the visibility of the bridged NSWindow.
48 enum WindowVisibilityState { 45 enum WindowVisibilityState {
49 HIDE_WINDOW, // Hides with -[NSWindow orderOut:]. 46 HIDE_WINDOW, // Hides with -[NSWindow orderOut:].
50 SHOW_AND_ACTIVATE_WINDOW, // Shows with -[NSWindow makeKeyAndOrderFront:]. 47 SHOW_AND_ACTIVATE_WINDOW, // Shows with -[NSWindow makeKeyAndOrderFront:].
51 SHOW_INACTIVE, // Shows with -[NSWindow orderWindow:..]. Orders 48 SHOW_INACTIVE, // Shows with -[NSWindow orderWindow:..]. Orders
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // Called by NSWindowDelegate when the application receives a mouse-down, but 132 // Called by NSWindowDelegate when the application receives a mouse-down, but
136 // before the event is processed by NSWindows. Returning true here will cause 133 // before the event is processed by NSWindows. Returning true here will cause
137 // the event to be cancelled and reposted at the CGSessionEventTap level. This 134 // the event to be cancelled and reposted at the CGSessionEventTap level. This
138 // is used to determine whether a mouse-down should drag the window. 135 // is used to determine whether a mouse-down should drag the window.
139 virtual bool ShouldRepostPendingLeftMouseDown(NSPoint location_in_window); 136 virtual bool ShouldRepostPendingLeftMouseDown(NSPoint location_in_window);
140 137
141 // Called by NativeWidgetMac when the window size constraints change. 138 // Called by NativeWidgetMac when the window size constraints change.
142 void OnSizeConstraintsChanged(); 139 void OnSizeConstraintsChanged();
143 140
144 // See widget.h for documentation. 141 // See widget.h for documentation.
145 InputMethod* CreateInputMethod(); 142 ui::InputMethod* GetInputMethod();
146 ui::InputMethod* GetHostInputMethod();
147 143
148 // The restored bounds will be derived from the current NSWindow frame unless 144 // The restored bounds will be derived from the current NSWindow frame unless
149 // fullscreen or transitioning between fullscreen states. 145 // fullscreen or transitioning between fullscreen states.
150 gfx::Rect GetRestoredBounds() const; 146 gfx::Rect GetRestoredBounds() const;
151 147
152 // Creates a ui::Compositor which becomes responsible for drawing the window. 148 // Creates a ui::Compositor which becomes responsible for drawing the window.
153 void CreateLayer(ui::LayerType layer_type, bool translucent); 149 void CreateLayer(ui::LayerType layer_type, bool translucent);
154 150
155 NativeWidgetMac* native_widget_mac() { return native_widget_mac_; } 151 NativeWidgetMac* native_widget_mac() { return native_widget_mac_; }
156 BridgedContentView* ns_view() { return bridged_view_; } 152 BridgedContentView* ns_view() { return bridged_view_; }
157 NSWindow* ns_window() { return window_; } 153 NSWindow* ns_window() { return window_; }
158 154
159 TooltipManager* tooltip_manager() { return tooltip_manager_.get(); } 155 TooltipManager* tooltip_manager() { return tooltip_manager_.get(); }
160 156
161 // The parent widget specified in Widget::InitParams::parent. If non-null, the 157 // The parent widget specified in Widget::InitParams::parent. If non-null, the
162 // parent will close children before the parent closes, and children will be 158 // parent will close children before the parent closes, and children will be
163 // raised above their parent when window z-order changes. 159 // raised above their parent when window z-order changes.
164 BridgedNativeWidgetOwner* parent() { return parent_; } 160 BridgedNativeWidgetOwner* parent() { return parent_; }
165 const std::vector<BridgedNativeWidget*>& child_windows() { 161 const std::vector<BridgedNativeWidget*>& child_windows() {
166 return child_windows_; 162 return child_windows_;
167 } 163 }
168 164
169 bool target_fullscreen_state() const { return target_fullscreen_state_; } 165 bool target_fullscreen_state() const { return target_fullscreen_state_; }
170 bool window_visible() { return window_visible_; } 166 bool window_visible() { return window_visible_; }
171 167
172 // Overridden from internal::InputMethodDelegate:
173 void DispatchKeyEventPostIME(const ui::KeyEvent& key) override;
174
175 private: 168 private:
176 // Closes all child windows. BridgedNativeWidget children will be destroyed. 169 // Closes all child windows. BridgedNativeWidget children will be destroyed.
177 void RemoveOrDestroyChildren(); 170 void RemoveOrDestroyChildren();
178 171
179 // Notify descendants of a visibility change. 172 // Notify descendants of a visibility change.
180 void NotifyVisibilityChangeDown(); 173 void NotifyVisibilityChangeDown();
181 174
182 // Essentially NativeWidgetMac::GetClientAreaBoundsInScreen().size(), but no 175 // Essentially NativeWidgetMac::GetClientAreaBoundsInScreen().size(), but no
183 // coordinate transformations are required from AppKit coordinates. 176 // coordinate transformations are required from AppKit coordinates.
184 gfx::Size GetClientAreaSize() const; 177 gfx::Size GetClientAreaSize() const;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // If true, the window is either visible, or wants to be visible but is 264 // If true, the window is either visible, or wants to be visible but is
272 // currently hidden due to having a hidden parent. 265 // currently hidden due to having a hidden parent.
273 bool wants_to_be_visible_; 266 bool wants_to_be_visible_;
274 267
275 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); 268 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget);
276 }; 269 };
277 270
278 } // namespace views 271 } // namespace views
279 272
280 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ 273 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698