Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mash/wm/bridge/wm_root_window_controller_mus.h" | |
| 6 | |
| 7 #include "ash/wm/common/wm_root_window_controller_observer.h" | |
| 8 #include "components/mus/public/cpp/window.h" | |
| 9 #include "components/mus/public/cpp/window_property.h" | |
| 10 #include "components/mus/public/cpp/window_tree_connection.h" | |
| 11 #include "mash/wm/bridge/wm_globals_mus.h" | |
| 12 #include "mash/wm/bridge/wm_window_mus.h" | |
| 13 #include "mash/wm/root_window_controller.h" | |
| 14 #include "ui/gfx/display.h" | |
| 15 #include "ui/views/mus/native_widget_mus.h" | |
| 16 #include "ui/views/widget/widget.h" | |
| 17 | |
| 18 MUS_DECLARE_WINDOW_PROPERTY_TYPE(mash::wm::WmRootWindowControllerMus*); | |
| 19 | |
| 20 namespace mash { | |
| 21 namespace wm { | |
| 22 | |
| 23 // TODO(sky): it likely makes more sense to hang this off RootWindowSettings. | |
| 24 MUS_DEFINE_OWNED_WINDOW_PROPERTY_KEY(mash::wm::WmRootWindowControllerMus, | |
| 25 kWmRootWindowControllerKey, | |
| 26 nullptr); | |
| 27 | |
| 28 WmRootWindowControllerMus::WmRootWindowControllerMus( | |
|
James Cook
2016/05/06 19:46:46
JAMES - ownership, who creates?
James Cook
2016/05/06 19:47:46
Whoops, didn't mean to leave this in. Strike it fr
| |
| 29 WmGlobalsMus* globals, | |
| 30 RootWindowController* root_window_controller) | |
| 31 : globals_(globals), root_window_controller_(root_window_controller) { | |
| 32 globals_->AddRootWindowController(this); | |
| 33 root_window_controller_->root()->SetLocalProperty(kWmRootWindowControllerKey, | |
| 34 this); | |
| 35 } | |
| 36 | |
| 37 WmRootWindowControllerMus::~WmRootWindowControllerMus() { | |
| 38 globals_->RemoveRootWindowController(this); | |
| 39 } | |
| 40 | |
| 41 // static | |
| 42 const WmRootWindowControllerMus* WmRootWindowControllerMus::Get( | |
| 43 const mus::Window* window) { | |
| 44 if (!window) | |
| 45 return nullptr; | |
| 46 | |
| 47 return window->GetRoot()->GetLocalProperty(kWmRootWindowControllerKey); | |
| 48 } | |
| 49 | |
| 50 gfx::Point WmRootWindowControllerMus::ConvertPointToScreen( | |
| 51 const WmWindowMus* source, | |
| 52 const gfx::Point& point) const { | |
| 53 gfx::Point point_in_root = | |
| 54 source->ConvertPointToTarget(source->GetRootWindow(), point); | |
| 55 point_in_root += GetDisplay().bounds().OffsetFromOrigin(); | |
| 56 return point_in_root; | |
| 57 } | |
| 58 | |
| 59 gfx::Point WmRootWindowControllerMus::ConvertPointFromScreen( | |
| 60 const WmWindowMus* target, | |
| 61 const gfx::Point& point) const { | |
| 62 gfx::Point result = point; | |
| 63 result -= GetDisplay().bounds().OffsetFromOrigin(); | |
| 64 return target->GetRootWindow()->ConvertPointToTarget(target, result); | |
| 65 } | |
| 66 | |
| 67 const gfx::Display& WmRootWindowControllerMus::GetDisplay() const { | |
| 68 return root_window_controller_->display(); | |
| 69 } | |
| 70 | |
| 71 bool WmRootWindowControllerMus::HasShelf() { | |
| 72 NOTIMPLEMENTED(); | |
| 73 return false; | |
| 74 } | |
| 75 | |
| 76 ash::wm::WmGlobals* WmRootWindowControllerMus::GetGlobals() { | |
| 77 return globals_; | |
| 78 } | |
| 79 | |
| 80 ash::wm::WorkspaceWindowState | |
| 81 WmRootWindowControllerMus::GetWorkspaceWindowState() { | |
| 82 NOTIMPLEMENTED(); | |
| 83 return ash::wm::WORKSPACE_WINDOW_STATE_DEFAULT; | |
| 84 } | |
| 85 | |
| 86 ash::AlwaysOnTopController* | |
| 87 WmRootWindowControllerMus::GetAlwaysOnTopController() { | |
| 88 NOTIMPLEMENTED(); | |
| 89 return nullptr; | |
| 90 } | |
| 91 | |
| 92 ash::wm::WmShelf* WmRootWindowControllerMus::GetShelf() { | |
| 93 NOTIMPLEMENTED(); | |
| 94 return nullptr; | |
| 95 } | |
| 96 | |
| 97 ash::wm::WmWindow* WmRootWindowControllerMus::GetWindow() { | |
| 98 return WmWindowMus::Get(root_window_controller_->root()); | |
| 99 } | |
| 100 | |
| 101 void WmRootWindowControllerMus::ConfigureWidgetInitParamsForContainer( | |
| 102 views::Widget* widget, | |
| 103 int shell_container_id, | |
| 104 views::Widget::InitParams* init_params) { | |
| 105 init_params->parent_mus = | |
| 106 root_window_controller_->root()->GetChildByLocalId(shell_container_id); | |
| 107 DCHECK(init_params->parent_mus); | |
| 108 mus::Window* new_window = | |
| 109 root_window_controller_->root()->connection()->NewWindow(nullptr); | |
|
James Cook
2016/05/06 19:46:46
optional: Maybe just NewWindow() so the reader doe
sky
2016/05/06 22:12:57
Done.
| |
| 110 init_params->native_widget = new views::NativeWidgetMus( | |
| 111 widget, root_window_controller_->GetConnector(), new_window, | |
| 112 mus::mojom::SurfaceType::DEFAULT); | |
| 113 } | |
| 114 | |
| 115 ash::wm::WmWindow* WmRootWindowControllerMus::FindEventTarget( | |
| 116 const gfx::Point& location_in_screen) { | |
| 117 NOTIMPLEMENTED(); | |
| 118 return nullptr; | |
| 119 } | |
| 120 | |
| 121 void WmRootWindowControllerMus::AddObserver( | |
| 122 ash::wm::WmRootWindowControllerObserver* observer) { | |
| 123 NOTIMPLEMENTED(); | |
| 124 } | |
| 125 | |
| 126 void WmRootWindowControllerMus::RemoveObserver( | |
| 127 ash::wm::WmRootWindowControllerObserver* observer) { | |
| 128 NOTIMPLEMENTED(); | |
| 129 } | |
| 130 | |
| 131 } // namespace wm | |
| 132 } // namespace mash | |
| OLD | NEW |