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