| 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 "ui/aura/mus/window_tree_host_mus.h" | 5 #include "ui/aura/mus/window_tree_host_mus.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/aura/env.h" | 8 #include "ui/aura/env.h" |
| 9 #include "ui/aura/mus/input_method_mus.h" | 9 #include "ui/aura/mus/input_method_mus.h" |
| 10 #include "ui/aura/mus/window_port_mus.h" | 10 #include "ui/aura/mus/window_port_mus.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 //////////////////////////////////////////////////////////////////////////////// | 39 //////////////////////////////////////////////////////////////////////////////// |
| 40 // WindowTreeHostMus, public: | 40 // WindowTreeHostMus, public: |
| 41 | 41 |
| 42 WindowTreeHostMus::WindowTreeHostMus(WindowTreeHostMusInitParams init_params) | 42 WindowTreeHostMus::WindowTreeHostMus(WindowTreeHostMusInitParams init_params) |
| 43 : WindowTreeHostPlatform(std::move(init_params.window_port)), | 43 : WindowTreeHostPlatform(std::move(init_params.window_port)), |
| 44 display_id_(init_params.display_id), | 44 display_id_(init_params.display_id), |
| 45 delegate_(init_params.window_tree_client) { | 45 delegate_(init_params.window_tree_client) { |
| 46 gfx::Rect bounds_in_pixels; |
| 47 display_init_params_ = std::move(init_params.display_init_params); |
| 48 if (display_init_params_) |
| 49 bounds_in_pixels = display_init_params_->viewport_metrics.bounds_in_pixels; |
| 46 window()->SetProperty(kWindowTreeHostMusKey, this); | 50 window()->SetProperty(kWindowTreeHostMusKey, this); |
| 47 // TODO(sky): find a cleaner way to set this! Better solution is to likely | 51 // TODO(sky): find a cleaner way to set this! Better solution is to likely |
| 48 // have constructor take aura::Window. | 52 // have constructor take aura::Window. |
| 49 WindowPortMus* window_mus = WindowPortMus::Get(window()); | 53 WindowPortMus* window_mus = WindowPortMus::Get(window()); |
| 50 window_mus->window_ = window(); | 54 window_mus->window_ = window(); |
| 51 // Apply the properties before initializing the window, that way the server | 55 // Apply the properties before initializing the window, that way the server |
| 52 // seems them at the time the window is created. | 56 // seems them at the time the window is created. |
| 53 for (auto& pair : init_params.properties) | 57 for (auto& pair : init_params.properties) |
| 54 window_mus->SetPropertyFromServer(pair.first, &pair.second); | 58 window_mus->SetPropertyFromServer(pair.first, &pair.second); |
| 55 // TODO(fsamuel): Once the display compositor is decoupled from the browser | 59 // TODO(fsamuel): Once the display compositor is decoupled from the browser |
| (...skipping 14 matching lines...) Expand all Loading... |
| 70 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); | 74 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); |
| 71 #endif | 75 #endif |
| 72 } | 76 } |
| 73 OnAcceleratedWidgetAvailable(accelerated_widget, | 77 OnAcceleratedWidgetAvailable(accelerated_widget, |
| 74 GetDisplay().device_scale_factor()); | 78 GetDisplay().device_scale_factor()); |
| 75 | 79 |
| 76 delegate_->OnWindowTreeHostCreated(this); | 80 delegate_->OnWindowTreeHostCreated(this); |
| 77 | 81 |
| 78 // Do not advertise accelerated widget; already set manually. | 82 // Do not advertise accelerated widget; already set manually. |
| 79 const bool use_default_accelerated_widget = false; | 83 const bool use_default_accelerated_widget = false; |
| 80 SetPlatformWindow( | 84 SetPlatformWindow(base::MakeUnique<ui::StubWindow>( |
| 81 base::MakeUnique<ui::StubWindow>(this, use_default_accelerated_widget)); | 85 this, use_default_accelerated_widget, bounds_in_pixels)); |
| 82 | 86 |
| 83 input_method_ = base::MakeUnique<InputMethodMus>(this, window()); | 87 input_method_ = base::MakeUnique<InputMethodMus>(this, window()); |
| 84 input_method_->Init(init_params.window_tree_client->connector()); | 88 input_method_->Init(init_params.window_tree_client->connector()); |
| 85 SetSharedInputMethod(input_method_.get()); | 89 SetSharedInputMethod(input_method_.get()); |
| 86 | 90 |
| 87 compositor()->SetHostHasTransparentBackground(true); | 91 compositor()->SetHostHasTransparentBackground(true); |
| 88 | 92 |
| 89 // Mus windows are assumed hidden. | 93 // Mus windows are assumed hidden. |
| 90 compositor()->SetVisible(false); | 94 compositor()->SetVisible(false); |
| 91 | 95 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 void WindowTreeHostMus::CancelWindowMove() { | 161 void WindowTreeHostMus::CancelWindowMove() { |
| 158 delegate_->OnWindowTreeHostCancelWindowMove(this); | 162 delegate_->OnWindowTreeHostCancelWindowMove(this); |
| 159 } | 163 } |
| 160 | 164 |
| 161 display::Display WindowTreeHostMus::GetDisplay() const { | 165 display::Display WindowTreeHostMus::GetDisplay() const { |
| 162 display::Display display; | 166 display::Display display; |
| 163 display::Screen::GetScreen()->GetDisplayWithDisplayId(display_id_, &display); | 167 display::Screen::GetScreen()->GetDisplayWithDisplayId(display_id_, &display); |
| 164 return display; | 168 return display; |
| 165 } | 169 } |
| 166 | 170 |
| 171 std::unique_ptr<DisplayInitParams> |
| 172 WindowTreeHostMus::ReleaseDisplayInitParams() { |
| 173 return std::move(display_init_params_); |
| 174 } |
| 175 |
| 167 void WindowTreeHostMus::HideImpl() { | 176 void WindowTreeHostMus::HideImpl() { |
| 168 WindowTreeHostPlatform::HideImpl(); | 177 WindowTreeHostPlatform::HideImpl(); |
| 169 window()->Hide(); | 178 window()->Hide(); |
| 170 } | 179 } |
| 171 | 180 |
| 172 void WindowTreeHostMus::SetBoundsInPixels(const gfx::Rect& bounds) { | 181 void WindowTreeHostMus::SetBoundsInPixels(const gfx::Rect& bounds) { |
| 173 if (!in_set_bounds_from_server_) | 182 if (!in_set_bounds_from_server_) |
| 174 delegate_->OnWindowTreeHostBoundsWillChange(this, bounds); | 183 delegate_->OnWindowTreeHostBoundsWillChange(this, bounds); |
| 175 WindowTreeHostPlatform::SetBoundsInPixels(bounds); | 184 WindowTreeHostPlatform::SetBoundsInPixels(bounds); |
| 176 } | 185 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 203 void WindowTreeHostMus::MoveCursorToScreenLocationInPixels( | 212 void WindowTreeHostMus::MoveCursorToScreenLocationInPixels( |
| 204 const gfx::Point& location_in_pixels) { | 213 const gfx::Point& location_in_pixels) { |
| 205 // TODO: this needs to message the server http://crbug.com/693340. Setting | 214 // TODO: this needs to message the server http://crbug.com/693340. Setting |
| 206 // the location is really only appropriate in tests, outside of tests this | 215 // the location is really only appropriate in tests, outside of tests this |
| 207 // value is ignored. | 216 // value is ignored. |
| 208 NOTIMPLEMENTED(); | 217 NOTIMPLEMENTED(); |
| 209 Env::GetInstance()->set_last_mouse_location(location_in_pixels); | 218 Env::GetInstance()->set_last_mouse_location(location_in_pixels); |
| 210 } | 219 } |
| 211 | 220 |
| 212 } // namespace aura | 221 } // namespace aura |
| OLD | NEW |