Chromium Code Reviews| 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 #include "ash/mus/bridge/wm_root_window_controller_mus.h" | 5 #include "ash/mus/bridge/wm_root_window_controller_mus.h" |
| 6 | 6 |
| 7 #include "ash/mus/bridge/wm_shelf_mus.h" | 7 #include "ash/mus/bridge/wm_shelf_mus.h" |
| 8 #include "ash/mus/bridge/wm_shell_mus.h" | 8 #include "ash/mus/bridge/wm_shell_mus.h" |
| 9 #include "ash/mus/bridge/wm_window_mus.h" | 9 #include "ash/mus/bridge/wm_window_mus.h" |
| 10 #include "ash/mus/root_window_controller.h" | 10 #include "ash/mus/root_window_controller.h" |
| 11 #include "ash/mus/window_manager.h" | 11 #include "ash/mus/window_manager.h" |
| 12 #include "services/ui/public/cpp/window.h" | 12 #include "ui/aura/mus/window_mus.h" |
| 13 #include "services/ui/public/cpp/window_property.h" | 13 #include "ui/aura/mus/window_tree_client.h" |
| 14 #include "services/ui/public/cpp/window_tree_client.h" | 14 #include "ui/aura/window.h" |
| 15 #include "ui/aura/window_property.h" | |
| 15 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
| 16 #include "ui/views/mus/native_widget_mus.h" | 17 #include "ui/views/widget/native_widget_aura.h" |
| 17 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 18 | 19 |
| 19 MUS_DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::WmRootWindowControllerMus*); | 20 DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::WmRootWindowControllerMus*); |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 MUS_DEFINE_LOCAL_WINDOW_PROPERTY_KEY(ash::mus::WmRootWindowControllerMus*, | 24 DEFINE_LOCAL_WINDOW_PROPERTY_KEY(ash::mus::WmRootWindowControllerMus*, |
| 24 kWmRootWindowControllerKey, | 25 kWmRootWindowControllerKey, |
| 25 nullptr); | 26 nullptr); |
| 26 | 27 |
| 27 } // namespace | 28 } // namespace |
| 28 | 29 |
| 29 namespace ash { | 30 namespace ash { |
| 30 namespace mus { | 31 namespace mus { |
| 31 | 32 |
| 32 WmRootWindowControllerMus::WmRootWindowControllerMus( | 33 WmRootWindowControllerMus::WmRootWindowControllerMus( |
| 33 WmShellMus* shell, | 34 WmShellMus* shell, |
| 34 RootWindowController* root_window_controller) | 35 RootWindowController* root_window_controller) |
| 35 : WmRootWindowController(WmWindowMus::Get(root_window_controller->root())), | 36 : WmRootWindowController(WmWindowMus::Get(root_window_controller->root())), |
| 36 shell_(shell), | 37 shell_(shell), |
| 37 root_window_controller_(root_window_controller) { | 38 root_window_controller_(root_window_controller) { |
| 38 shell_->AddRootWindowController(this); | 39 shell_->AddRootWindowController(this); |
| 39 root_window_controller_->root()->SetLocalProperty(kWmRootWindowControllerKey, | 40 root_window_controller_->root()->SetProperty(kWmRootWindowControllerKey, |
| 40 this); | 41 this); |
| 41 } | 42 } |
| 42 | 43 |
| 43 WmRootWindowControllerMus::~WmRootWindowControllerMus() { | 44 WmRootWindowControllerMus::~WmRootWindowControllerMus() { |
| 44 shell_->RemoveRootWindowController(this); | 45 shell_->RemoveRootWindowController(this); |
| 45 } | 46 } |
| 46 | 47 |
| 47 // static | 48 // static |
| 48 const WmRootWindowControllerMus* WmRootWindowControllerMus::Get( | 49 const WmRootWindowControllerMus* WmRootWindowControllerMus::Get( |
| 49 const ui::Window* window) { | 50 const aura::Window* window) { |
| 50 if (!window) | 51 if (!window) |
| 51 return nullptr; | 52 return nullptr; |
| 52 | 53 |
| 53 return window->GetRoot()->GetLocalProperty(kWmRootWindowControllerKey); | 54 return window->GetRootWindow()->GetProperty(kWmRootWindowControllerKey); |
| 54 } | 55 } |
| 55 | 56 |
| 56 gfx::Point WmRootWindowControllerMus::ConvertPointToScreen( | 57 gfx::Point WmRootWindowControllerMus::ConvertPointToScreen( |
| 57 const WmWindowMus* source, | 58 const WmWindowMus* source, |
| 58 const gfx::Point& point) const { | 59 const gfx::Point& point) const { |
| 59 gfx::Point point_in_root = | 60 gfx::Point point_in_root = |
| 60 source->ConvertPointToTarget(source->GetRootWindow(), point); | 61 source->ConvertPointToTarget(source->GetRootWindow(), point); |
| 61 point_in_root += GetDisplay().bounds().OffsetFromOrigin(); | 62 point_in_root += GetDisplay().bounds().OffsetFromOrigin(); |
| 62 return point_in_root; | 63 return point_in_root; |
| 63 } | 64 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 87 } | 88 } |
| 88 | 89 |
| 89 WmShelf* WmRootWindowControllerMus::GetShelf() { | 90 WmShelf* WmRootWindowControllerMus::GetShelf() { |
| 90 return root_window_controller_->wm_shelf(); | 91 return root_window_controller_->wm_shelf(); |
| 91 } | 92 } |
| 92 | 93 |
| 93 WmWindow* WmRootWindowControllerMus::GetWindow() { | 94 WmWindow* WmRootWindowControllerMus::GetWindow() { |
| 94 return WmWindowMus::Get(root_window_controller_->root()); | 95 return WmWindowMus::Get(root_window_controller_->root()); |
| 95 } | 96 } |
| 96 | 97 |
| 97 void WmRootWindowControllerMus::ConfigureWidgetInitParamsForContainer( | 98 void WmRootWindowControllerMus::ConfigureWidgetInitParamsForContainer( |
|
James Cook
2016/12/05 19:21:43
Q: Will this eventually go away, since ash as the
sky
2016/12/05 21:39:19
The important thing is associating the widget with
| |
| 98 views::Widget* widget, | 99 views::Widget* widget, |
| 99 int shell_container_id, | 100 int shell_container_id, |
| 100 views::Widget::InitParams* init_params) { | 101 views::Widget::InitParams* init_params) { |
| 101 init_params->parent_mus = WmWindowMus::GetMusWindow( | 102 init_params->parent = WmWindowMus::GetAuraWindow( |
| 102 WmWindowMus::Get(root_window_controller_->root()) | 103 WmWindowMus::Get(root_window_controller_->root()) |
| 103 ->GetChildByShellWindowId(shell_container_id)); | 104 ->GetChildByShellWindowId(shell_container_id)); |
| 104 DCHECK(init_params->parent_mus); | 105 DCHECK(init_params->parent); |
| 105 ui::Window* new_window = | 106 views::NativeWidgetAura* native_widget_aura = |
| 106 root_window_controller_->root()->window_tree()->NewWindow( | 107 new views::NativeWidgetAura(widget); |
| 107 &(init_params->mus_properties)); | 108 init_params->native_widget = native_widget_aura; |
| 108 WmWindowMus::Get(new_window) | 109 WmWindowMus::Get(native_widget_aura->GetNativeView()) |
| 109 ->set_widget(widget, WmWindowMus::WidgetCreationType::INTERNAL); | 110 ->set_widget(widget, WmWindowMus::WidgetCreationType::INTERNAL); |
| 110 init_params->native_widget = new views::NativeWidgetMus( | |
| 111 widget, new_window, ui::mojom::CompositorFrameSinkType::DEFAULT); | |
| 112 } | 111 } |
| 113 | 112 |
| 114 WmWindow* WmRootWindowControllerMus::FindEventTarget( | 113 WmWindow* WmRootWindowControllerMus::FindEventTarget( |
| 115 const gfx::Point& location_in_screen) { | 114 const gfx::Point& location_in_screen) { |
| 116 NOTIMPLEMENTED(); | 115 NOTIMPLEMENTED(); |
| 117 return nullptr; | 116 return nullptr; |
| 118 } | 117 } |
| 119 | 118 |
| 120 gfx::Point WmRootWindowControllerMus::GetLastMouseLocationInRoot() { | 119 gfx::Point WmRootWindowControllerMus::GetLastMouseLocationInRoot() { |
| 121 gfx::Point location = root_window_controller_->window_manager() | 120 gfx::Point location = root_window_controller_->window_manager() |
| 122 ->window_tree_client() | 121 ->window_tree_client() |
| 123 ->GetCursorScreenPoint(); | 122 ->GetCursorScreenPoint(); |
| 124 location -= | 123 location -= |
| 125 root_window_controller_->display().bounds().origin().OffsetFromOrigin(); | 124 root_window_controller_->display().bounds().origin().OffsetFromOrigin(); |
| 126 return location; | 125 return location; |
| 127 } | 126 } |
| 128 | 127 |
| 129 bool WmRootWindowControllerMus::ShouldDestroyWindowInCloseChildWindows( | 128 bool WmRootWindowControllerMus::ShouldDestroyWindowInCloseChildWindows( |
| 130 WmWindow* window) { | 129 WmWindow* window) { |
| 131 ui::Window* ui_window = WmWindowMus::GetMusWindow(window); | 130 aura::WindowTreeClient* window_tree_client = |
| 132 return ui_window->WasCreatedByThisClient() || | 131 root_window_controller_->window_manager()->window_tree_client(); |
| 133 ui_window->window_tree()->GetRoots().count(ui_window); | 132 aura::Window* aura_window = WmWindowMus::GetAuraWindow(window); |
| 133 aura::WindowMus* window_mus = aura::WindowMus::Get(aura_window); | |
| 134 return window_tree_client->WasCreatedByThisClient(window_mus) || | |
| 135 window_tree_client->IsRoot(window_mus); | |
| 134 } | 136 } |
| 135 | 137 |
| 136 } // namespace mus | 138 } // namespace mus |
| 137 } // namespace ash | 139 } // namespace ash |
| OLD | NEW |