Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: ui/aura/mus/window_tree_host_mus.cc

Issue 2495423005: Enables passing initial properties to top level window creation (Closed)
Patch Set: cleanup Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 24
25 bool IsUsingTestContext() { 25 bool IsUsingTestContext() {
26 return aura::Env::GetInstance()->context_factory()->DoesCreateTestContexts(); 26 return aura::Env::GetInstance()->context_factory()->DoesCreateTestContexts();
27 } 27 }
28 28
29 } // namespace 29 } // namespace
30 30
31 //////////////////////////////////////////////////////////////////////////////// 31 ////////////////////////////////////////////////////////////////////////////////
32 // WindowTreeHostMus, public: 32 // WindowTreeHostMus, public:
33 33
34 WindowTreeHostMus::WindowTreeHostMus(std::unique_ptr<WindowPortMus> window_port, 34 WindowTreeHostMus::WindowTreeHostMus(
35 WindowTreeHostMusDelegate* delegate, 35 std::unique_ptr<WindowPortMus> window_port,
36 int64_t display_id) 36 WindowTreeHostMusDelegate* delegate,
37 int64_t display_id,
38 const std::map<std::string, std::vector<uint8_t>>* properties)
37 : WindowTreeHostPlatform(std::move(window_port)), 39 : WindowTreeHostPlatform(std::move(window_port)),
38 display_id_(display_id), 40 display_id_(display_id),
39 delegate_(delegate) { 41 delegate_(delegate) {
42 // TODO(sky): find a cleaner way to set this! Better solution is to likely
43 // have constructor take aura::Window.
44 WindowPortMus::Get(window())->window_ = window();
45 if (properties) {
46 // Apply the properties before initializing the window, that way the
47 // server seems them at the time the window is created.
48 WindowMus* window_mus = WindowMus::Get(window());
49 for (auto& pair : *properties)
50 window_mus->SetPropertyFromServer(pair.first, &pair.second);
51 }
52 CreateCompositor();
40 gfx::AcceleratedWidget accelerated_widget; 53 gfx::AcceleratedWidget accelerated_widget;
41 if (IsUsingTestContext()) { 54 if (IsUsingTestContext()) {
42 accelerated_widget = gfx::kNullAcceleratedWidget; 55 accelerated_widget = gfx::kNullAcceleratedWidget;
43 } else { 56 } else {
44 // We need accelerated widget numbers to be different for each 57 // We need accelerated widget numbers to be different for each
45 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t 58 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t
46 // has this property. 59 // has this property.
47 #if defined(OS_WIN) || defined(OS_ANDROID) 60 #if defined(OS_WIN) || defined(OS_ANDROID)
48 accelerated_widget = 61 accelerated_widget =
49 reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); 62 reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
(...skipping 12 matching lines...) Expand all
62 false)); // Do not advertise accelerated widget; already set manually. 75 false)); // Do not advertise accelerated widget; already set manually.
63 76
64 input_method_ = base::MakeUnique<InputMethodMus>(this, window()); 77 input_method_ = base::MakeUnique<InputMethodMus>(this, window());
65 78
66 compositor()->SetHostHasTransparentBackground(true); 79 compositor()->SetHostHasTransparentBackground(true);
67 80
68 // Mus windows are assumed hidden. 81 // Mus windows are assumed hidden.
69 compositor()->SetVisible(false); 82 compositor()->SetVisible(false);
70 } 83 }
71 84
72 WindowTreeHostMus::WindowTreeHostMus(WindowTreeClient* window_tree_client) 85 WindowTreeHostMus::WindowTreeHostMus(
86 WindowTreeClient* window_tree_client,
87 const std::map<std::string, std::vector<uint8_t>>* properties)
73 : WindowTreeHostMus( 88 : WindowTreeHostMus(
74 static_cast<WindowTreeHostMusDelegate*>(window_tree_client) 89 static_cast<WindowTreeHostMusDelegate*>(window_tree_client)
75 ->CreateWindowPortForTopLevel(), 90 ->CreateWindowPortForTopLevel(),
76 window_tree_client, 91 window_tree_client,
77 display::Screen::GetScreen()->GetPrimaryDisplay().id()) {} 92 display::Screen::GetScreen()->GetPrimaryDisplay().id(),
93 properties) {}
78 94
79 WindowTreeHostMus::~WindowTreeHostMus() { 95 WindowTreeHostMus::~WindowTreeHostMus() {
80 DestroyCompositor(); 96 DestroyCompositor();
81 DestroyDispatcher(); 97 DestroyDispatcher();
82 } 98 }
83 99
84 void WindowTreeHostMus::SetBoundsFromServer(const gfx::Rect& bounds) { 100 void WindowTreeHostMus::SetBoundsFromServer(const gfx::Rect& bounds) {
85 base::AutoReset<bool> resetter(&in_set_bounds_from_server_, true); 101 base::AutoReset<bool> resetter(&in_set_bounds_from_server_, true);
86 SetBounds(bounds); 102 SetBounds(bounds);
87 } 103 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void WindowTreeHostMus::OnCloseRequest() { 146 void WindowTreeHostMus::OnCloseRequest() {
131 OnHostCloseRequested(); 147 OnHostCloseRequested();
132 } 148 }
133 149
134 gfx::ICCProfile WindowTreeHostMus::GetICCProfileForCurrentDisplay() { 150 gfx::ICCProfile WindowTreeHostMus::GetICCProfileForCurrentDisplay() {
135 // TODO: This should read the profile from mus. crbug.com/647510 151 // TODO: This should read the profile from mus. crbug.com/647510
136 return gfx::ICCProfile(); 152 return gfx::ICCProfile();
137 } 153 }
138 154
139 } // namespace aura 155 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698