| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 ASH_MUS_BRIDGE_WM_WINDOW_MUS_H_ | 5 #ifndef ASH_MUS_BRIDGE_WM_WINDOW_MUS_H_ |
| 6 #define ASH_MUS_BRIDGE_WM_WINDOW_MUS_H_ | 6 #define ASH_MUS_BRIDGE_WM_WINDOW_MUS_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/aura/wm_window_aura.h" | 10 #include "ash/aura/wm_window_aura.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 | 12 |
| 13 namespace aura { | 13 namespace aura { |
| 14 class Window; | 14 class Window; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace views { | 17 namespace views { |
| 18 class Widget; | 18 class Widget; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 namespace mus { | 22 namespace mus { |
| 23 | 23 |
| 24 class WmRootWindowControllerMus; | 24 class WmRootWindowControllerMus; |
| 25 class WmWindowMusTestApi; | |
| 26 | 25 |
| 27 // WmWindow implementation for mus. | 26 // WmWindow implementation for mus. |
| 28 // | 27 // |
| 29 // WmWindowMus is tied to the life of the underlying aura::Window (it is stored | 28 // WmWindowMus is tied to the life of the underlying aura::Window (it is stored |
| 30 // as an owned property). | 29 // as an owned property). |
| 31 class WmWindowMus : public WmWindowAura { | 30 class WmWindowMus : public WmWindowAura { |
| 32 public: | 31 public: |
| 33 // Indicates the source of the widget creation. | |
| 34 enum class WidgetCreationType { | |
| 35 // The widget was created internally, and not at the request of a client. | |
| 36 // For example, overview mode creates a number of widgets. These widgets are | |
| 37 // created with a type of INTERNAL. | |
| 38 INTERNAL, | |
| 39 | |
| 40 // The widget was created for a client. In other words there is a client | |
| 41 // embedded in the aura::Window. For example, when Chrome creates a new | |
| 42 // browser window the window manager is asked to create the aura::Window. | |
| 43 // The window manager creates an aura::Window and a views::Widget to show | |
| 44 // the non-client frame decorations. In this case the creation type is | |
| 45 // FOR_CLIENT. | |
| 46 FOR_CLIENT, | |
| 47 }; | |
| 48 | |
| 49 explicit WmWindowMus(aura::Window* window); | 32 explicit WmWindowMus(aura::Window* window); |
| 50 // NOTE: this class is owned by the corresponding window. You shouldn't delete | 33 // NOTE: this class is owned by the corresponding window. You shouldn't delete |
| 51 // TODO(sky): friend deleter and make private. | 34 // TODO(sky): friend deleter and make private. |
| 52 ~WmWindowMus() override; | 35 ~WmWindowMus() override; |
| 53 | 36 |
| 54 // Returns a WmWindow for an aura::Window, creating if necessary. | 37 // Returns a WmWindow for an aura::Window, creating if necessary. |
| 55 static WmWindowMus* Get(aura::Window* window) { | 38 static WmWindowMus* Get(aura::Window* window) { |
| 56 return const_cast<WmWindowMus*>( | 39 return const_cast<WmWindowMus*>( |
| 57 Get(const_cast<const aura::Window*>(window))); | 40 Get(const_cast<const aura::Window*>(window))); |
| 58 } | 41 } |
| 59 static const WmWindowMus* Get(const aura::Window* window); | 42 static const WmWindowMus* Get(const aura::Window* window); |
| 60 | 43 |
| 61 static WmWindowMus* Get(views::Widget* widget); | 44 static WmWindowMus* Get(views::Widget* widget); |
| 62 | 45 |
| 63 // Sets the widget associated with the window. The widget is used to query | |
| 64 // state, such as min/max size. The widget is not owned by the WmWindowMus. | |
| 65 void set_widget(views::Widget* widget, WidgetCreationType type) { | |
| 66 widget_ = widget; | |
| 67 widget_creation_type_ = type; | |
| 68 } | |
| 69 | |
| 70 WmRootWindowControllerMus* GetRootWindowControllerMus() { | 46 WmRootWindowControllerMus* GetRootWindowControllerMus() { |
| 71 return const_cast<WmRootWindowControllerMus*>( | 47 return const_cast<WmRootWindowControllerMus*>( |
| 72 const_cast<const WmWindowMus*>(this)->GetRootWindowControllerMus()); | 48 const_cast<const WmWindowMus*>(this)->GetRootWindowControllerMus()); |
| 73 } | 49 } |
| 74 const WmRootWindowControllerMus* GetRootWindowControllerMus() const; | 50 const WmRootWindowControllerMus* GetRootWindowControllerMus() const; |
| 75 | 51 |
| 76 static WmWindowMus* AsWmWindowMus(WmWindow* window) { | 52 static WmWindowMus* AsWmWindowMus(WmWindow* window) { |
| 77 return static_cast<WmWindowMus*>(window); | 53 return static_cast<WmWindowMus*>(window); |
| 78 } | 54 } |
| 79 static const WmWindowMus* AsWmWindowMus(const WmWindow* window) { | 55 static const WmWindowMus* AsWmWindowMus(const WmWindow* window) { |
| 80 return static_cast<const WmWindowMus*>(window); | 56 return static_cast<const WmWindowMus*>(window); |
| 81 } | 57 } |
| 82 | 58 |
| 83 // See description of |children_use_extended_hit_region_|. | |
| 84 bool ShouldUseExtendedHitRegion() const; | |
| 85 | |
| 86 // Returns true if this window is considered a shell window container. | 59 // Returns true if this window is considered a shell window container. |
| 87 bool IsContainer() const; | 60 bool IsContainer() const; |
| 88 | 61 |
| 89 // WmWindow: | 62 // WmWindow: |
| 90 const WmWindow* GetRootWindow() const override; | |
| 91 WmRootWindowController* GetRootWindowController() override; | 63 WmRootWindowController* GetRootWindowController() override; |
| 92 WmShell* GetShell() const override; | 64 WmShell* GetShell() const override; |
| 93 bool IsBubble() override; | |
| 94 bool HasNonClientArea() override; | |
| 95 int GetNonClientComponent(const gfx::Point& location) override; | |
| 96 gfx::Size GetMinimumSize() const override; | |
| 97 gfx::Size GetMaximumSize() const override; | |
| 98 gfx::Rect GetMinimizeAnimationTargetBoundsInScreen() const override; | |
| 99 bool IsSystemModal() const override; | |
| 100 bool GetBoolProperty(WmWindowProperty key) override; | |
| 101 int GetIntProperty(WmWindowProperty key) override; | 65 int GetIntProperty(WmWindowProperty key) override; |
| 102 WmWindow* GetToplevelWindow() override; | |
| 103 WmWindow* GetToplevelWindowForFocus() override; | |
| 104 bool MoveToEventRoot(const ui::Event& event) override; | 66 bool MoveToEventRoot(const ui::Event& event) override; |
| 105 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen, | 67 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen, |
| 106 const display::Display& dst_display) override; | 68 const display::Display& dst_display) override; |
| 107 void SetPinned(bool trusted) override; | 69 void SetPinned(bool trusted) override; |
| 108 views::Widget* GetInternalWidget() override; | |
| 109 void CloseWidget() override; | 70 void CloseWidget() override; |
| 110 bool CanActivate() const override; | 71 bool CanActivate() const override; |
| 111 void ShowResizeShadow(int component) override; | 72 void ShowResizeShadow(int component) override; |
| 112 void HideResizeShadow() override; | 73 void HideResizeShadow() override; |
| 113 void InstallResizeHandleWindowTargeter( | 74 void InstallResizeHandleWindowTargeter( |
| 114 ImmersiveFullscreenController* immersive_fullscreen_controller) override; | 75 ImmersiveFullscreenController* immersive_fullscreen_controller) override; |
| 115 void SetBoundsInScreenBehaviorForChildren( | 76 void SetBoundsInScreenBehaviorForChildren( |
| 116 BoundsInScreenBehavior behavior) override; | 77 BoundsInScreenBehavior behavior) override; |
| 117 void SetSnapsChildrenToPhysicalPixelBoundary() override; | |
| 118 void SnapToPixelBoundaryIfNecessary() override; | |
| 119 void SetChildrenUseExtendedHitRegion() override; | |
| 120 void AddLimitedPreTargetHandler(ui::EventHandler* handler) override; | 78 void AddLimitedPreTargetHandler(ui::EventHandler* handler) override; |
| 121 | 79 |
| 122 private: | 80 private: |
| 123 friend class WmWindowMusTestApi; | |
| 124 | |
| 125 views::Widget* widget_ = nullptr; | |
| 126 | |
| 127 WidgetCreationType widget_creation_type_ = WidgetCreationType::INTERNAL; | |
| 128 | |
| 129 bool snap_children_to_pixel_boundary_ = false; | |
| 130 | |
| 131 // If true child windows should get a slightly larger hit region to make | |
| 132 // resizing easier. | |
| 133 bool children_use_extended_hit_region_ = false; | |
| 134 | |
| 135 // Default value for |use_empty_minimum_size_for_testing_|. | |
| 136 static bool default_use_empty_minimum_size_for_testing_; | |
| 137 | |
| 138 // If true the minimum size is 0x0, default is minimum size comes from widget. | |
| 139 bool use_empty_minimum_size_for_testing_ = false; | |
| 140 | |
| 141 BoundsInScreenBehavior child_bounds_in_screen_behavior_ = | 81 BoundsInScreenBehavior child_bounds_in_screen_behavior_ = |
| 142 BoundsInScreenBehavior::USE_LOCAL_COORDINATES; | 82 BoundsInScreenBehavior::USE_LOCAL_COORDINATES; |
| 143 | 83 |
| 144 DISALLOW_COPY_AND_ASSIGN(WmWindowMus); | 84 DISALLOW_COPY_AND_ASSIGN(WmWindowMus); |
| 145 }; | 85 }; |
| 146 | 86 |
| 147 } // namespace mus | 87 } // namespace mus |
| 148 } // namespace ash | 88 } // namespace ash |
| 149 | 89 |
| 150 #endif // ASH_MUS_BRIDGE_WM_WINDOW_MUS_H_ | 90 #endif // ASH_MUS_BRIDGE_WM_WINDOW_MUS_H_ |
| OLD | NEW |