| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 //////////////////////////////////////////////////////////////////////////////// | 38 //////////////////////////////////////////////////////////////////////////////// |
| 39 // WindowTreeHostMus, public: | 39 // WindowTreeHostMus, public: |
| 40 | 40 |
| 41 WindowTreeHostMus::WindowTreeHostMus( | 41 WindowTreeHostMus::WindowTreeHostMus( |
| 42 std::unique_ptr<WindowPortMus> window_port, | 42 std::unique_ptr<WindowPortMus> window_port, |
| 43 WindowTreeClient* window_tree_client, | 43 WindowTreeClient* window_tree_client, |
| 44 int64_t display_id, | 44 int64_t display_id, |
| 45 const cc::FrameSinkId& frame_sink_id, |
| 45 const std::map<std::string, std::vector<uint8_t>>* properties) | 46 const std::map<std::string, std::vector<uint8_t>>* properties) |
| 46 : WindowTreeHostPlatform(std::move(window_port)), | 47 : WindowTreeHostPlatform(std::move(window_port)), |
| 47 display_id_(display_id), | 48 display_id_(display_id), |
| 48 delegate_(window_tree_client) { | 49 delegate_(window_tree_client) { |
| 49 window()->SetProperty(kWindowTreeHostMusKey, this); | 50 window()->SetProperty(kWindowTreeHostMusKey, this); |
| 50 // 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 |
| 51 // have constructor take aura::Window. | 52 // have constructor take aura::Window. |
| 52 WindowPortMus::Get(window())->window_ = window(); | 53 WindowPortMus* window_mus = WindowPortMus::Get(window()); |
| 54 window_mus->window_ = window(); |
| 53 if (properties) { | 55 if (properties) { |
| 54 // Apply the properties before initializing the window, that way the | 56 // Apply the properties before initializing the window, that way the |
| 55 // server seems them at the time the window is created. | 57 // server seems them at the time the window is created. |
| 56 WindowMus* window_mus = WindowMus::Get(window()); | |
| 57 for (auto& pair : *properties) | 58 for (auto& pair : *properties) |
| 58 window_mus->SetPropertyFromServer(pair.first, &pair.second); | 59 window_mus->SetPropertyFromServer(pair.first, &pair.second); |
| 59 } | 60 } |
| 60 Id server_id = WindowMus::Get(window())->server_id(); | 61 // TODO(fsamuel): Once the display compositor is decoupled from the browser |
| 61 cc::FrameSinkId frame_sink_id(server_id, 0); | 62 // process then ui::Compositor will not a cc::FrameSinkId. |
| 62 DCHECK(frame_sink_id.is_valid()); | |
| 63 CreateCompositor(frame_sink_id); | 63 CreateCompositor(frame_sink_id); |
| 64 gfx::AcceleratedWidget accelerated_widget; | 64 gfx::AcceleratedWidget accelerated_widget; |
| 65 if (IsUsingTestContext()) { | 65 if (IsUsingTestContext()) { |
| 66 accelerated_widget = gfx::kNullAcceleratedWidget; | 66 accelerated_widget = gfx::kNullAcceleratedWidget; |
| 67 } else { | 67 } else { |
| 68 // We need accelerated widget numbers to be different for each | 68 // We need accelerated widget numbers to be different for each |
| 69 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t | 69 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t |
| 70 // has this property. | 70 // has this property. |
| 71 #if defined(OS_WIN) || defined(OS_ANDROID) | 71 #if defined(OS_WIN) || defined(OS_ANDROID) |
| 72 accelerated_widget = | 72 accelerated_widget = |
| (...skipping 13 matching lines...) Expand all Loading... |
| 86 false)); // Do not advertise accelerated widget; already set manually. | 86 false)); // Do not advertise accelerated widget; already set manually. |
| 87 | 87 |
| 88 input_method_ = base::MakeUnique<InputMethodMus>(this, window()); | 88 input_method_ = base::MakeUnique<InputMethodMus>(this, window()); |
| 89 input_method_->Init(window_tree_client->connector()); | 89 input_method_->Init(window_tree_client->connector()); |
| 90 SetSharedInputMethod(input_method_.get()); | 90 SetSharedInputMethod(input_method_.get()); |
| 91 | 91 |
| 92 compositor()->SetHostHasTransparentBackground(true); | 92 compositor()->SetHostHasTransparentBackground(true); |
| 93 | 93 |
| 94 // Mus windows are assumed hidden. | 94 // Mus windows are assumed hidden. |
| 95 compositor()->SetVisible(false); | 95 compositor()->SetVisible(false); |
| 96 |
| 97 if (frame_sink_id.is_valid()) |
| 98 window_mus->SetFrameSinkIdFromServer(frame_sink_id); |
| 96 } | 99 } |
| 97 | 100 |
| 98 // Pass |properties| to CreateWindowPortForTopLevel() so that |properties| | 101 // Pass |properties| to CreateWindowPortForTopLevel() so that |properties| |
| 99 // are passed to the server *and* pass |properties| to the WindowTreeHostMus | 102 // are passed to the server *and* pass |properties| to the WindowTreeHostMus |
| 100 // constructor (above) which applies the properties to the Window. Some of the | 103 // constructor (above) which applies the properties to the Window. Some of the |
| 101 // properties may be server specific and not applied to the Window. | 104 // properties may be server specific and not applied to the Window. |
| 102 WindowTreeHostMus::WindowTreeHostMus( | 105 WindowTreeHostMus::WindowTreeHostMus( |
| 103 WindowTreeClient* window_tree_client, | 106 WindowTreeClient* window_tree_client, |
| 107 const cc::FrameSinkId& frame_sink_id, |
| 104 const std::map<std::string, std::vector<uint8_t>>* properties) | 108 const std::map<std::string, std::vector<uint8_t>>* properties) |
| 105 : WindowTreeHostMus( | 109 : WindowTreeHostMus( |
| 106 static_cast<WindowTreeHostMusDelegate*>(window_tree_client) | 110 static_cast<WindowTreeHostMusDelegate*>(window_tree_client) |
| 107 ->CreateWindowPortForTopLevel(properties), | 111 ->CreateWindowPortForTopLevel(properties), |
| 108 window_tree_client, | 112 window_tree_client, |
| 109 display::Screen::GetScreen()->GetPrimaryDisplay().id(), | 113 display::Screen::GetScreen()->GetPrimaryDisplay().id(), |
| 114 frame_sink_id, |
| 110 properties) {} | 115 properties) {} |
| 111 | 116 |
| 112 WindowTreeHostMus::~WindowTreeHostMus() { | 117 WindowTreeHostMus::~WindowTreeHostMus() { |
| 113 DestroyCompositor(); | 118 DestroyCompositor(); |
| 114 DestroyDispatcher(); | 119 DestroyDispatcher(); |
| 115 } | 120 } |
| 116 | 121 |
| 117 // static | 122 // static |
| 118 WindowTreeHostMus* WindowTreeHostMus::ForWindow(aura::Window* window) { | 123 WindowTreeHostMus* WindowTreeHostMus::ForWindow(aura::Window* window) { |
| 119 if (!window) | 124 if (!window) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 void WindowTreeHostMus::MoveCursorToScreenLocationInPixels( | 224 void WindowTreeHostMus::MoveCursorToScreenLocationInPixels( |
| 220 const gfx::Point& location_in_pixels) { | 225 const gfx::Point& location_in_pixels) { |
| 221 // TODO: this needs to message the server http://crbug.com/693340. Setting | 226 // TODO: this needs to message the server http://crbug.com/693340. Setting |
| 222 // the location is really only appropriate in tests, outside of tests this | 227 // the location is really only appropriate in tests, outside of tests this |
| 223 // value is ignored. | 228 // value is ignored. |
| 224 NOTIMPLEMENTED(); | 229 NOTIMPLEMENTED(); |
| 225 Env::GetInstance()->set_last_mouse_location(location_in_pixels); | 230 Env::GetInstance()->set_last_mouse_location(location_in_pixels); |
| 226 } | 231 } |
| 227 | 232 |
| 228 } // namespace aura | 233 } // namespace aura |
| OLD | NEW |