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/wm.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "services/service_manager/public/cpp/connector.h" |
| 10 #include "services/service_manager/public/cpp/service_context.h" |
| 11 #include "services/service_manager/public/cpp/service_runner.h" |
| 12 #include "services/ui/public/cpp/window.h" |
| 13 #include "services/ui/public/cpp/window_tree_client.h" |
| 14 |
| 15 namespace mash { |
| 16 namespace wm { |
| 17 |
| 18 //////////////////////////////////////////////////////////////////////////////// |
| 19 // Service, public: |
| 20 |
| 21 WM::WM() {} |
| 22 WM::~WM() {} |
| 23 |
| 24 //////////////////////////////////////////////////////////////////////////////// |
| 25 // Service, service_manager::Service implementation: |
| 26 |
| 27 void WM::OnStart() { |
| 28 window_tree_client_.reset(new ui::WindowTreeClient(this, this)); |
| 29 window_tree_client_->ConnectAsWindowManager(context()->connector()); |
| 30 } |
| 31 |
| 32 bool WM::OnConnect(const service_manager::ServiceInfo& remote_info, |
| 33 service_manager::InterfaceRegistry* registry) { |
| 34 return true; |
| 35 } |
| 36 |
| 37 //////////////////////////////////////////////////////////////////////////////// |
| 38 // Service, ui::WindowTreeClientDelegate implementation: |
| 39 void WM::OnEmbed(ui::Window* root) { |
| 40 // WindowTreeClients configured as the window manager should never get |
| 41 // OnEmbed(). |
| 42 NOTREACHED(); |
| 43 } |
| 44 void WM::OnLostConnection(ui::WindowTreeClient* client) { |
| 45 window_tree_client_.reset(); |
| 46 } |
| 47 void WM::OnEmbedRootDestroyed(ui::Window* root) { |
| 48 // WindowTreeClients configured as the window manager should never get |
| 49 // OnEmbedRootDestroyed(). |
| 50 NOTREACHED(); |
| 51 } |
| 52 void WM::OnPointerEventObserved(const ui::PointerEvent& event, |
| 53 ui::Window* target) { |
| 54 // Don't care. |
| 55 } |
| 56 |
| 57 //////////////////////////////////////////////////////////////////////////////// |
| 58 // Service, ui::WindowManagerDelegate implementation: |
| 59 |
| 60 void WM::SetWindowManagerClient(ui::WindowManagerClient* client) { |
| 61 window_manager_client_ = client; |
| 62 } |
| 63 bool WM::OnWmSetBounds(ui::Window* window, gfx::Rect* bounds) { |
| 64 return true; |
| 65 } |
| 66 bool WM::OnWmSetProperty( |
| 67 ui::Window* window, |
| 68 const std::string& name, |
| 69 std::unique_ptr<std::vector<uint8_t>>* new_data) { |
| 70 return true; |
| 71 } |
| 72 ui::Window* WM::OnWmCreateTopLevelWindow( |
| 73 std::map<std::string, std::vector<uint8_t>>* properties) { |
| 74 ui::Window* window = root_->window_tree()->NewWindow(properties); |
| 75 window->SetBounds(gfx::Rect(10, 10, 500, 500)); |
| 76 root_->AddChild(window); |
| 77 return window; |
| 78 } |
| 79 void WM::OnWmClientJankinessChanged( |
| 80 const std::set<ui::Window*>& client_windows, bool janky) { |
| 81 // Don't care. |
| 82 } |
| 83 void WM::OnWmNewDisplay(ui::Window* window, |
| 84 const display::Display& display) { |
| 85 // Only handles a single root. |
| 86 DCHECK(!root_); |
| 87 root_ = window; |
| 88 DCHECK(window_manager_client_); |
| 89 window_manager_client_->AddActivationParent(root_); |
| 90 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = |
| 91 ui::mojom::FrameDecorationValues::New(); |
| 92 frame_decoration_values->max_title_bar_button_width = 0; |
| 93 window_manager_client_->SetFrameDecorationValues( |
| 94 std::move(frame_decoration_values)); |
| 95 } |
| 96 void WM::OnWmDisplayRemoved(ui::Window* window) { |
| 97 window->Destroy(); |
| 98 } |
| 99 void WM::OnWmDisplayModified(const display::Display& display) {} |
| 100 void WM::OnWmPerformMoveLoop(ui::Window* window, |
| 101 ui::mojom::MoveLoopSource source, |
| 102 const gfx::Point& cursor_location, |
| 103 const base::Callback<void(bool)>& on_done) { |
| 104 // Don't care. |
| 105 } |
| 106 void WM::OnWmCancelMoveLoop(ui::Window* window) {} |
| 107 |
| 108 } // namespace wm |
| 109 } // namespace mash |
OLD | NEW |