| 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/views_export.h" | 19 #include "ui/views/views_export.h" |
| 19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| 20 | 21 |
| 21 @class BridgedContentView; | 22 @class BridgedContentView; |
| 22 @class ViewsNSWindowDelegate; | 23 @class ViewsNSWindowDelegate; |
| 23 | 24 |
| 24 namespace ui { | 25 namespace ui { |
| 25 class InputMethod; | 26 class InputMethod; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace views { | 29 namespace views { |
| 29 | 30 |
| 30 class CocoaMouseCapture; | 31 class CocoaMouseCapture; |
| 31 class NativeWidgetMac; | 32 class NativeWidgetMac; |
| 32 class View; | 33 class View; |
| 33 | 34 |
| 34 // 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 |
| 35 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the | 36 // DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the |
| 36 // 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. |
| 37 class VIEWS_EXPORT BridgedNativeWidget : public ui::LayerDelegate, | 38 class VIEWS_EXPORT BridgedNativeWidget |
| 38 public ui::LayerOwner, | 39 : public ui::LayerDelegate, |
| 39 public CocoaMouseCaptureDelegate, | 40 public ui::LayerOwner, |
| 40 public FocusChangeListener, | 41 public ui::internal::InputMethodDelegate, |
| 41 public ui::AcceleratedWidgetMacNSView, | 42 public CocoaMouseCaptureDelegate, |
| 42 public BridgedNativeWidgetOwner { | 43 public FocusChangeListener, |
| 44 public ui::AcceleratedWidgetMacNSView, |
| 45 public BridgedNativeWidgetOwner { |
| 43 public: | 46 public: |
| 44 // Ways of changing the visibility of the bridged NSWindow. | 47 // Ways of changing the visibility of the bridged NSWindow. |
| 45 enum WindowVisibilityState { | 48 enum WindowVisibilityState { |
| 46 HIDE_WINDOW, // Hides with -[NSWindow orderOut:]. | 49 HIDE_WINDOW, // Hides with -[NSWindow orderOut:]. |
| 47 SHOW_AND_ACTIVATE_WINDOW, // Shows with -[NSWindow makeKeyAndOrderFront:]. | 50 SHOW_AND_ACTIVATE_WINDOW, // Shows with -[NSWindow makeKeyAndOrderFront:]. |
| 48 SHOW_INACTIVE, // Shows with -[NSWindow orderWindow:..]. Orders | 51 SHOW_INACTIVE, // Shows with -[NSWindow orderWindow:..]. Orders |
| 49 // the window above its parent if it has one. | 52 // the window above its parent if it has one. |
| 50 }; | 53 }; |
| 51 | 54 |
| 52 // 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // 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 |
| 159 // raised above their parent when window z-order changes. | 162 // raised above their parent when window z-order changes. |
| 160 BridgedNativeWidgetOwner* parent() { return parent_; } | 163 BridgedNativeWidgetOwner* parent() { return parent_; } |
| 161 const std::vector<BridgedNativeWidget*>& child_windows() { | 164 const std::vector<BridgedNativeWidget*>& child_windows() { |
| 162 return child_windows_; | 165 return child_windows_; |
| 163 } | 166 } |
| 164 | 167 |
| 165 bool target_fullscreen_state() const { return target_fullscreen_state_; } | 168 bool target_fullscreen_state() const { return target_fullscreen_state_; } |
| 166 bool window_visible() { return window_visible_; } | 169 bool window_visible() { return window_visible_; } |
| 167 | 170 |
| 171 // Overridden from ui::internal::InputMethodDelegate: |
| 172 bool DispatchKeyEventPostIME(const ui::KeyEvent& key) override; |
| 173 |
| 168 private: | 174 private: |
| 169 // Closes all child windows. BridgedNativeWidget children will be destroyed. | 175 // Closes all child windows. BridgedNativeWidget children will be destroyed. |
| 170 void RemoveOrDestroyChildren(); | 176 void RemoveOrDestroyChildren(); |
| 171 | 177 |
| 172 // Notify descendants of a visibility change. | 178 // Notify descendants of a visibility change. |
| 173 void NotifyVisibilityChangeDown(); | 179 void NotifyVisibilityChangeDown(); |
| 174 | 180 |
| 175 // Essentially NativeWidgetMac::GetClientAreaBoundsInScreen().size(), but no | 181 // Essentially NativeWidgetMac::GetClientAreaBoundsInScreen().size(), but no |
| 176 // coordinate transformations are required from AppKit coordinates. | 182 // coordinate transformations are required from AppKit coordinates. |
| 177 gfx::Size GetClientAreaSize() const; | 183 gfx::Size GetClientAreaSize() const; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 // 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 |
| 265 // currently hidden due to having a hidden parent. | 271 // currently hidden due to having a hidden parent. |
| 266 bool wants_to_be_visible_; | 272 bool wants_to_be_visible_; |
| 267 | 273 |
| 268 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); | 274 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidget); |
| 269 }; | 275 }; |
| 270 | 276 |
| 271 } // namespace views | 277 } // namespace views |
| 272 | 278 |
| 273 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ | 279 #endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_H_ |
| OLD | NEW |