| 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/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 class WmLayoutManager; | 23 class WmLayoutManager; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace mus { | 26 namespace mus { |
| 27 | 27 |
| 28 class MusLayoutManagerAdapter; | 28 class MusLayoutManagerAdapter; |
| 29 class WmRootWindowControllerMus; | 29 class WmRootWindowControllerMus; |
| 30 | 30 |
| 31 // WmWindow implementation for mus. | 31 // WmWindow implementation for mus. |
| 32 // | 32 // |
| 33 // WmWindowMus is tied to the life of the underlying ::ui::Window (it is stored | 33 // WmWindowMus is tied to the life of the underlying ui::Window (it is stored |
| 34 // as an owned property). | 34 // as an owned property). |
| 35 class WmWindowMus : public WmWindow, public ::ui::WindowObserver { | 35 class WmWindowMus : public WmWindow, public ui::WindowObserver { |
| 36 public: | 36 public: |
| 37 // Indicates the source of the widget creation. | 37 // Indicates the source of the widget creation. |
| 38 enum class WidgetCreationType { | 38 enum class WidgetCreationType { |
| 39 // The widget was created internally, and not at the request of a client. | 39 // The widget was created internally, and not at the request of a client. |
| 40 // For example, overview mode creates a number of widgets. These widgets are | 40 // For example, overview mode creates a number of widgets. These widgets are |
| 41 // created with a type of INTERNAL. | 41 // created with a type of INTERNAL. |
| 42 INTERNAL, | 42 INTERNAL, |
| 43 | 43 |
| 44 // The widget was created for a client. In other words there is a client | 44 // The widget was created for a client. In other words there is a client |
| 45 // embedded in the ui::Window. For example, when Chrome creates a new | 45 // embedded in the ui::Window. For example, when Chrome creates a new |
| 46 // browser window the window manager is asked to create the ui::Window. | 46 // browser window the window manager is asked to create the ui::Window. |
| 47 // The window manager creates a ui::Window and a views::Widget to show the | 47 // The window manager creates a ui::Window and a views::Widget to show the |
| 48 // non-client frame decorations. In this case the creation type is | 48 // non-client frame decorations. In this case the creation type is |
| 49 // FOR_CLIENT. | 49 // FOR_CLIENT. |
| 50 FOR_CLIENT, | 50 FOR_CLIENT, |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 explicit WmWindowMus(::ui::Window* window); | 53 explicit WmWindowMus(ui::Window* window); |
| 54 // NOTE: this class is owned by the corresponding window. You shouldn't delete | 54 // NOTE: this class is owned by the corresponding window. You shouldn't delete |
| 55 // TODO(sky): friend deleter and make private. | 55 // TODO(sky): friend deleter and make private. |
| 56 ~WmWindowMus() override; | 56 ~WmWindowMus() override; |
| 57 | 57 |
| 58 // Returns a WmWindow for an ui::Window, creating if necessary. | 58 // Returns a WmWindow for an ui::Window, creating if necessary. |
| 59 static WmWindowMus* Get(::ui::Window* window); | 59 static WmWindowMus* Get(ui::Window* window); |
| 60 | 60 |
| 61 static WmWindowMus* Get(views::Widget* widget); | 61 static WmWindowMus* Get(views::Widget* widget); |
| 62 | 62 |
| 63 static ::ui::Window* GetMusWindow(WmWindow* wm_window) { | 63 static ui::Window* GetMusWindow(WmWindow* wm_window) { |
| 64 return const_cast<::ui::Window*>( | 64 return const_cast<ui::Window*>( |
| 65 GetMusWindow(const_cast<const WmWindow*>(wm_window))); | 65 GetMusWindow(const_cast<const WmWindow*>(wm_window))); |
| 66 } | 66 } |
| 67 static const ::ui::Window* GetMusWindow(const WmWindow* wm_window); | 67 static const ui::Window* GetMusWindow(const WmWindow* wm_window); |
| 68 | 68 |
| 69 static std::vector<WmWindow*> FromMusWindows( | 69 static std::vector<WmWindow*> FromMusWindows( |
| 70 const std::vector<::ui::Window*>& mus_windows); | 70 const std::vector<ui::Window*>& mus_windows); |
| 71 | 71 |
| 72 // Sets the widget associated with the window. The widget is used to query | 72 // Sets the widget associated with the window. The widget is used to query |
| 73 // state, such as min/max size. The widget is not owned by the WmWindowMus. | 73 // state, such as min/max size. The widget is not owned by the WmWindowMus. |
| 74 void set_widget(views::Widget* widget, WidgetCreationType type) { | 74 void set_widget(views::Widget* widget, WidgetCreationType type) { |
| 75 widget_ = widget; | 75 widget_ = widget; |
| 76 widget_creation_type_ = type; | 76 widget_creation_type_ = type; |
| 77 } | 77 } |
| 78 | 78 |
| 79 ::ui::Window* mus_window() { return window_; } | 79 ui::Window* mus_window() { return window_; } |
| 80 const ::ui::Window* mus_window() const { return window_; } | 80 const ui::Window* mus_window() const { return window_; } |
| 81 | 81 |
| 82 WmRootWindowControllerMus* GetRootWindowControllerMus() { | 82 WmRootWindowControllerMus* GetRootWindowControllerMus() { |
| 83 return const_cast<WmRootWindowControllerMus*>( | 83 return const_cast<WmRootWindowControllerMus*>( |
| 84 const_cast<const WmWindowMus*>(this)->GetRootWindowControllerMus()); | 84 const_cast<const WmWindowMus*>(this)->GetRootWindowControllerMus()); |
| 85 } | 85 } |
| 86 const WmRootWindowControllerMus* GetRootWindowControllerMus() const; | 86 const WmRootWindowControllerMus* GetRootWindowControllerMus() const; |
| 87 | 87 |
| 88 static WmWindowMus* AsWmWindowMus(WmWindow* window) { | 88 static WmWindowMus* AsWmWindowMus(WmWindow* window) { |
| 89 return static_cast<WmWindowMus*>(window); | 89 return static_cast<WmWindowMus*>(window); |
| 90 } | 90 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 void AddObserver(WmWindowObserver* observer) override; | 214 void AddObserver(WmWindowObserver* observer) override; |
| 215 void RemoveObserver(WmWindowObserver* observer) override; | 215 void RemoveObserver(WmWindowObserver* observer) override; |
| 216 bool HasObserver(const WmWindowObserver* observer) const override; | 216 bool HasObserver(const WmWindowObserver* observer) const override; |
| 217 void AddLimitedPreTargetHandler(ui::EventHandler* handler) override; | 217 void AddLimitedPreTargetHandler(ui::EventHandler* handler) override; |
| 218 void RemoveLimitedPreTargetHandler(ui::EventHandler* handler) override; | 218 void RemoveLimitedPreTargetHandler(ui::EventHandler* handler) override; |
| 219 | 219 |
| 220 private: | 220 private: |
| 221 // ui::WindowObserver: | 221 // ui::WindowObserver: |
| 222 void OnTreeChanging(const TreeChangeParams& params) override; | 222 void OnTreeChanging(const TreeChangeParams& params) override; |
| 223 void OnTreeChanged(const TreeChangeParams& params) override; | 223 void OnTreeChanged(const TreeChangeParams& params) override; |
| 224 void OnWindowReordered(::ui::Window* window, | 224 void OnWindowReordered(ui::Window* window, |
| 225 ::ui::Window* relative_window, | 225 ui::Window* relative_window, |
| 226 ::ui::mojom::OrderDirection direction) override; | 226 ui::mojom::OrderDirection direction) override; |
| 227 void OnWindowSharedPropertyChanged( | 227 void OnWindowSharedPropertyChanged( |
| 228 ::ui::Window* window, | 228 ui::Window* window, |
| 229 const std::string& name, | 229 const std::string& name, |
| 230 const std::vector<uint8_t>* old_data, | 230 const std::vector<uint8_t>* old_data, |
| 231 const std::vector<uint8_t>* new_data) override; | 231 const std::vector<uint8_t>* new_data) override; |
| 232 void OnWindowBoundsChanged(::ui::Window* window, | 232 void OnWindowBoundsChanged(ui::Window* window, |
| 233 const gfx::Rect& old_bounds, | 233 const gfx::Rect& old_bounds, |
| 234 const gfx::Rect& new_bounds) override; | 234 const gfx::Rect& new_bounds) override; |
| 235 void OnWindowDestroying(::ui::Window* window) override; | 235 void OnWindowDestroying(ui::Window* window) override; |
| 236 void OnWindowDestroyed(::ui::Window* window) override; | 236 void OnWindowDestroyed(ui::Window* window) override; |
| 237 | 237 |
| 238 ::ui::Window* window_; | 238 ui::Window* window_; |
| 239 | 239 |
| 240 // The shell window id of this window. Shell window ids are defined in | 240 // The shell window id of this window. Shell window ids are defined in |
| 241 // ash/common/shell_window_ids.h. | 241 // ash/common/shell_window_ids.h. |
| 242 int shell_window_id_ = kShellWindowId_Invalid; | 242 int shell_window_id_ = kShellWindowId_Invalid; |
| 243 | 243 |
| 244 std::unique_ptr<wm::WindowState> window_state_; | 244 std::unique_ptr<wm::WindowState> window_state_; |
| 245 | 245 |
| 246 views::Widget* widget_ = nullptr; | 246 views::Widget* widget_ = nullptr; |
| 247 | 247 |
| 248 WidgetCreationType widget_creation_type_ = WidgetCreationType::INTERNAL; | 248 WidgetCreationType widget_creation_type_ = WidgetCreationType::INTERNAL; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 261 // resizing easier. | 261 // resizing easier. |
| 262 bool children_use_extended_hit_region_ = false; | 262 bool children_use_extended_hit_region_ = false; |
| 263 | 263 |
| 264 DISALLOW_COPY_AND_ASSIGN(WmWindowMus); | 264 DISALLOW_COPY_AND_ASSIGN(WmWindowMus); |
| 265 }; | 265 }; |
| 266 | 266 |
| 267 } // namespace mus | 267 } // namespace mus |
| 268 } // namespace ash | 268 } // namespace ash |
| 269 | 269 |
| 270 #endif // ASH_MUS_BRIDGE_WM_WINDOW_MUS_H_ | 270 #endif // ASH_MUS_BRIDGE_WM_WINDOW_MUS_H_ |
| OLD | NEW |