| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mash/wm/window_manager_application.h" | 5 #include "mash/wm/window_manager_application.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 7 #include "components/mus/common/util.h" | 8 #include "components/mus/common/util.h" |
| 8 #include "components/mus/public/cpp/event_matcher.h" | 9 #include "components/mus/public/cpp/event_matcher.h" |
| 9 #include "components/mus/public/cpp/window.h" | 10 #include "components/mus/public/cpp/window.h" |
| 10 #include "components/mus/public/cpp/window_tree_connection.h" | 11 #include "components/mus/public/cpp/window_tree_connection.h" |
| 11 #include "components/mus/public/cpp/window_tree_host_factory.h" | 12 #include "components/mus/public/cpp/window_tree_host_factory.h" |
| 12 #include "mash/wm/background_layout.h" | 13 #include "mash/wm/background_layout.h" |
| 13 #include "mash/wm/shelf_layout.h" | 14 #include "mash/wm/shelf_layout.h" |
| 14 #include "mash/wm/window_layout.h" | 15 #include "mash/wm/window_layout.h" |
| 15 #include "mash/wm/window_manager_impl.h" | 16 #include "mash/wm/window_manager_impl.h" |
| 16 #include "mojo/application/public/cpp/application_connection.h" | 17 #include "mojo/application/public/cpp/application_connection.h" |
| 17 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 18 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
| 18 #include "ui/mojo/init/ui_init.h" | 19 #include "ui/mojo/init/ui_init.h" |
| 19 #include "ui/views/mus/aura_init.h" | 20 #include "ui/views/mus/aura_init.h" |
| 20 #include "ui/views/mus/display_converter.h" | 21 #include "ui/views/mus/display_converter.h" |
| 21 | 22 |
| 22 namespace mash { | 23 namespace mash { |
| 23 namespace wm { | 24 namespace wm { |
| 24 namespace { | 25 namespace { |
| 25 const uint32_t kWindowSwitchCmd = 1; | 26 const uint32_t kWindowSwitchCmd = 1; |
| 27 |
| 28 void AssertTrue(bool success) { |
| 29 DCHECK(success); |
| 30 } |
| 31 |
| 26 } // namespace | 32 } // namespace |
| 27 | 33 |
| 28 WindowManagerApplication::WindowManagerApplication() | 34 WindowManagerApplication::WindowManagerApplication() |
| 29 : root_(nullptr), | 35 : root_(nullptr), |
| 30 window_count_(0), | 36 window_count_(0), |
| 31 app_(nullptr), | 37 app_(nullptr), |
| 32 host_client_binding_(this) {} | 38 host_client_binding_(this) {} |
| 33 | 39 |
| 34 WindowManagerApplication::~WindowManagerApplication() {} | 40 WindowManagerApplication::~WindowManagerApplication() {} |
| 35 | 41 |
| 36 mus::Window* WindowManagerApplication::GetWindowForContainer( | 42 mus::Window* WindowManagerApplication::GetWindowForContainer( |
| 37 mojom::Container container) { | 43 mojom::Container container) { |
| 38 const mus::Id window_id = root_->connection()->GetConnectionId() << 16 | | 44 const mus::Id window_id = root_->connection()->GetConnectionId() << 16 | |
| 39 static_cast<uint16_t>(container); | 45 static_cast<uint16_t>(container); |
| 40 return root_->GetChildById(window_id); | 46 return root_->GetChildById(window_id); |
| 41 } | 47 } |
| 42 | 48 |
| 43 mus::Window* WindowManagerApplication::GetWindowById(mus::Id id) { | 49 mus::Window* WindowManagerApplication::GetWindowById(mus::Id id) { |
| 44 return root_->GetChildById(id); | 50 return root_->GetChildById(id); |
| 45 } | 51 } |
| 46 | 52 |
| 47 void WindowManagerApplication::AddAccelerators() { | 53 void WindowManagerApplication::AddAccelerators() { |
| 48 window_tree_host_->AddAccelerator( | 54 window_tree_host_->AddAccelerator( |
| 49 kWindowSwitchCmd, | 55 kWindowSwitchCmd, |
| 50 mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_TAB, | 56 mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_TAB, |
| 51 mus::mojom::EVENT_FLAGS_CONTROL_DOWN)); | 57 mus::mojom::EVENT_FLAGS_CONTROL_DOWN), |
| 58 base::Bind(&AssertTrue)); |
| 52 } | 59 } |
| 53 | 60 |
| 54 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) { | 61 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) { |
| 55 app_ = app; | 62 app_ = app; |
| 56 tracing_.Initialize(app); | 63 tracing_.Initialize(app); |
| 57 window_manager_.reset(new WindowManagerImpl()); | 64 window_manager_.reset(new WindowManagerImpl()); |
| 58 // Don't bind to the WindowManager immediately. Wait for OnEmbed() first. | 65 // Don't bind to the WindowManager immediately. Wait for OnEmbed() first. |
| 59 mus::mojom::WindowManagerPtr window_manager; | 66 mus::mojom::WindowManagerPtr window_manager; |
| 60 requests_.push_back(new mojo::InterfaceRequest<mus::mojom::WindowManager>( | 67 requests_.push_back(new mojo::InterfaceRequest<mus::mojom::WindowManager>( |
| 61 mojo::GetProxy(&window_manager))); | 68 mojo::GetProxy(&window_manager))); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 DCHECK_EQ(mus::LoWord(window->id()), container) | 149 DCHECK_EQ(mus::LoWord(window->id()), container) |
| 143 << "Containers must be created before other windows!"; | 150 << "Containers must be created before other windows!"; |
| 144 window->SetBounds(root_->bounds()); | 151 window->SetBounds(root_->bounds()); |
| 145 window->SetVisible(true); | 152 window->SetVisible(true); |
| 146 root_->AddChild(window); | 153 root_->AddChild(window); |
| 147 } | 154 } |
| 148 } | 155 } |
| 149 | 156 |
| 150 } // namespace wm | 157 } // namespace wm |
| 151 } // namespace mash | 158 } // namespace mash |
| OLD | NEW |