| 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace aura { | 24 namespace aura { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 DEFINE_UI_CLASS_PROPERTY_KEY( | 28 DEFINE_UI_CLASS_PROPERTY_KEY( |
| 29 WindowTreeHostMus*, kWindowTreeHostMusKey, nullptr); | 29 WindowTreeHostMus*, kWindowTreeHostMusKey, nullptr); |
| 30 | 30 |
| 31 static uint32_t accelerated_widget_count = 1; | 31 static uint32_t accelerated_widget_count = 1; |
| 32 | 32 |
| 33 bool IsUsingTestContext() { | |
| 34 return aura::Env::GetInstance()->context_factory()->DoesCreateTestContexts(); | |
| 35 } | |
| 36 | |
| 37 } // namespace | 33 } // namespace |
| 38 | 34 |
| 39 //////////////////////////////////////////////////////////////////////////////// | 35 //////////////////////////////////////////////////////////////////////////////// |
| 40 // WindowTreeHostMus, public: | 36 // WindowTreeHostMus, public: |
| 41 | 37 |
| 42 WindowTreeHostMus::WindowTreeHostMus(WindowTreeHostMusInitParams init_params) | 38 WindowTreeHostMus::WindowTreeHostMus(WindowTreeHostMusInitParams init_params) |
| 43 : WindowTreeHostPlatform(std::move(init_params.window_port)), | 39 : WindowTreeHostPlatform(std::move(init_params.window_port)), |
| 44 display_id_(init_params.display_id), | 40 display_id_(init_params.display_id), |
| 45 delegate_(init_params.window_tree_client) { | 41 delegate_(init_params.window_tree_client) { |
| 46 gfx::Rect bounds_in_pixels; | 42 gfx::Rect bounds_in_pixels; |
| 47 display_init_params_ = std::move(init_params.display_init_params); | 43 display_init_params_ = std::move(init_params.display_init_params); |
| 48 if (display_init_params_) | 44 if (display_init_params_) |
| 49 bounds_in_pixels = display_init_params_->viewport_metrics.bounds_in_pixels; | 45 bounds_in_pixels = display_init_params_->viewport_metrics.bounds_in_pixels; |
| 50 window()->SetProperty(kWindowTreeHostMusKey, this); | 46 window()->SetProperty(kWindowTreeHostMusKey, this); |
| 51 // TODO(sky): find a cleaner way to set this! Better solution is to likely | 47 // TODO(sky): find a cleaner way to set this! Better solution is to likely |
| 52 // have constructor take aura::Window. | 48 // have constructor take aura::Window. |
| 53 WindowPortMus* window_mus = WindowPortMus::Get(window()); | 49 WindowPortMus* window_mus = WindowPortMus::Get(window()); |
| 54 window_mus->window_ = window(); | 50 window_mus->window_ = window(); |
| 55 // Apply the properties before initializing the window, that way the server | 51 // Apply the properties before initializing the window, that way the server |
| 56 // seems them at the time the window is created. | 52 // seems them at the time the window is created. |
| 57 for (auto& pair : init_params.properties) | 53 for (auto& pair : init_params.properties) |
| 58 window_mus->SetPropertyFromServer(pair.first, &pair.second); | 54 window_mus->SetPropertyFromServer(pair.first, &pair.second); |
| 59 // TODO(fsamuel): Once the display compositor is decoupled from the browser | 55 // TODO(fsamuel): Once the display compositor is decoupled from the browser |
| 60 // process then ui::Compositor will not a cc::FrameSinkId. | 56 // process then ui::Compositor will not a cc::FrameSinkId. |
| 61 CreateCompositor(init_params.frame_sink_id); | 57 CreateCompositor(init_params.frame_sink_id); |
| 62 gfx::AcceleratedWidget accelerated_widget; | 58 gfx::AcceleratedWidget accelerated_widget; |
| 63 if (IsUsingTestContext()) { | |
| 64 accelerated_widget = gfx::kNullAcceleratedWidget; | |
| 65 } else { | |
| 66 // We need accelerated widget numbers to be different for each | 59 // We need accelerated widget numbers to be different for each |
| 67 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t | 60 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t |
| 68 // has this property. | 61 // has this property. |
| 69 #if defined(OS_WIN) || defined(OS_ANDROID) | 62 #if defined(OS_WIN) || defined(OS_ANDROID) |
| 70 accelerated_widget = | 63 accelerated_widget = |
| 71 reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); | 64 reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); |
| 72 #else | 65 #else |
| 73 accelerated_widget = | 66 accelerated_widget = |
| 74 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); | 67 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); |
| 75 #endif | 68 #endif |
| 76 } | |
| 77 OnAcceleratedWidgetAvailable(accelerated_widget, | 69 OnAcceleratedWidgetAvailable(accelerated_widget, |
| 78 GetDisplay().device_scale_factor()); | 70 GetDisplay().device_scale_factor()); |
| 79 | 71 |
| 80 delegate_->OnWindowTreeHostCreated(this); | 72 delegate_->OnWindowTreeHostCreated(this); |
| 81 | 73 |
| 82 // Do not advertise accelerated widget; already set manually. | 74 // Do not advertise accelerated widget; already set manually. |
| 83 const bool use_default_accelerated_widget = false; | 75 const bool use_default_accelerated_widget = false; |
| 84 SetPlatformWindow(base::MakeUnique<ui::StubWindow>( | 76 SetPlatformWindow(base::MakeUnique<ui::StubWindow>( |
| 85 this, use_default_accelerated_widget, bounds_in_pixels)); | 77 this, use_default_accelerated_widget, bounds_in_pixels)); |
| 86 | 78 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 void WindowTreeHostMus::MoveCursorToScreenLocationInPixels( | 206 void WindowTreeHostMus::MoveCursorToScreenLocationInPixels( |
| 215 const gfx::Point& location_in_pixels) { | 207 const gfx::Point& location_in_pixels) { |
| 216 // TODO: this needs to message the server http://crbug.com/693340. Setting | 208 // TODO: this needs to message the server http://crbug.com/693340. Setting |
| 217 // the location is really only appropriate in tests, outside of tests this | 209 // the location is really only appropriate in tests, outside of tests this |
| 218 // value is ignored. | 210 // value is ignored. |
| 219 NOTIMPLEMENTED(); | 211 NOTIMPLEMENTED(); |
| 220 Env::GetInstance()->set_last_mouse_location(location_in_pixels); | 212 Env::GetInstance()->set_last_mouse_location(location_in_pixels); |
| 221 } | 213 } |
| 222 | 214 |
| 223 } // namespace aura | 215 } // namespace aura |
| OLD | NEW |