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

Side by Side Diff: ui/views/mus/native_widget_mus.cc

Issue 1645503004: [exp] ash: sysui for mash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ash-in-mus
Patch Set: . Created 4 years, 10 months 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/views/mus/native_widget_mus.h" 5 #include "ui/views/mus/native_widget_mus.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "components/mus/public/cpp/property_type_converters.h" 9 #include "components/mus/public/cpp/property_type_converters.h"
10 #include "components/mus/public/cpp/window.h" 10 #include "components/mus/public/cpp/window.h"
(...skipping 12 matching lines...) Expand all
23 #include "ui/native_theme/native_theme_aura.h" 23 #include "ui/native_theme/native_theme_aura.h"
24 #include "ui/views/mus/platform_window_mus.h" 24 #include "ui/views/mus/platform_window_mus.h"
25 #include "ui/views/mus/surface_context_factory.h" 25 #include "ui/views/mus/surface_context_factory.h"
26 #include "ui/views/mus/window_manager_constants_converters.h" 26 #include "ui/views/mus/window_manager_constants_converters.h"
27 #include "ui/views/mus/window_manager_frame_values.h" 27 #include "ui/views/mus/window_manager_frame_values.h"
28 #include "ui/views/mus/window_tree_host_mus.h" 28 #include "ui/views/mus/window_tree_host_mus.h"
29 #include "ui/views/widget/widget_delegate.h" 29 #include "ui/views/widget/widget_delegate.h"
30 #include "ui/views/window/custom_frame_view.h" 30 #include "ui/views/window/custom_frame_view.h"
31 #include "ui/wm/core/base_focus_rules.h" 31 #include "ui/wm/core/base_focus_rules.h"
32 #include "ui/wm/core/capture_controller.h" 32 #include "ui/wm/core/capture_controller.h"
33 #include "ui/wm/core/default_screen_position_client.h"
33 #include "ui/wm/core/focus_controller.h" 34 #include "ui/wm/core/focus_controller.h"
34 35
35 DECLARE_WINDOW_PROPERTY_TYPE(mus::Window*); 36 DECLARE_WINDOW_PROPERTY_TYPE(mus::Window*);
36 37
37 namespace views { 38 namespace views {
38 namespace { 39 namespace {
39 40
40 DEFINE_WINDOW_PROPERTY_KEY(mus::Window*, kMusWindow, nullptr); 41 DEFINE_WINDOW_PROPERTY_KEY(mus::Window*, kMusWindow, nullptr);
41 42
42 MUS_DEFINE_WINDOW_PROPERTY_KEY(NativeWidgetMus*, kNativeWidgetMusKey, nullptr); 43 MUS_DEFINE_WINDOW_PROPERTY_KEY(NativeWidgetMus*, kNativeWidgetMusKey, nullptr);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } // namespace 173 } // namespace
173 174
174 //////////////////////////////////////////////////////////////////////////////// 175 ////////////////////////////////////////////////////////////////////////////////
175 // NativeWidgetMus, public: 176 // NativeWidgetMus, public:
176 177
177 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, 178 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate,
178 mojo::Shell* shell, 179 mojo::Shell* shell,
179 mus::Window* window, 180 mus::Window* window,
180 mus::mojom::SurfaceType surface_type) 181 mus::mojom::SurfaceType surface_type)
181 : window_(window), 182 : window_(window),
182 shell_(shell),
183 native_widget_delegate_(delegate), 183 native_widget_delegate_(delegate),
184 surface_type_(surface_type), 184 surface_type_(surface_type),
185 show_state_before_fullscreen_(ui::PLATFORM_WINDOW_STATE_UNKNOWN), 185 show_state_before_fullscreen_(ui::PLATFORM_WINDOW_STATE_UNKNOWN),
186 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 186 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
187 content_(new aura::Window(this)), 187 content_(new aura::Window(this)),
188 close_widget_factory_(this) { 188 close_widget_factory_(this) {
189 // TODO(fsamuel): Figure out lifetime of |window_|. 189 // TODO(fsamuel): Figure out lifetime of |window_|.
190 aura::SetMusWindow(content_, window_); 190 aura::SetMusWindow(content_, window_);
191 191
192 window->SetLocalProperty(kNativeWidgetMusKey, this); 192 window->SetLocalProperty(kNativeWidgetMusKey, this);
193
194 // WindowTreeHost creates the compositor using the ContextFactory from
195 // aura::Env. Install |context_factory_| there so that |context_factory_| is
196 // picked up.
197 ui::ContextFactory* default_context_factory =
198 aura::Env::GetInstance()->context_factory();
199 // For Chrome, we need the GpuProcessTransportFactory so that renderer and
200 // browser pixels are composited into a single backing
201 // SoftwareOutputDeviceMus.
202 if (!default_context_factory) {
203 if (!context_factory_) {
204 context_factory_.reset(new SurfaceContextFactory(shell, window_,
205 surface_type_));
206 }
207 aura::Env::GetInstance()->set_context_factory(context_factory_.get());
208 }
209 window_tree_host_.reset(new WindowTreeHostMus(shell, this, window_));
210 window_tree_host_->AddObserver(this);
211 window_tree_host_->InitHost();
212 aura::Env::GetInstance()->set_context_factory(default_context_factory);
213 window_tree_host_->window()->SetProperty(kMusWindow, window_);
193 } 214 }
194 215
195 NativeWidgetMus::~NativeWidgetMus() { 216 NativeWidgetMus::~NativeWidgetMus() {
196 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 217 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
197 delete native_widget_delegate_; 218 delete native_widget_delegate_;
198 else 219 else
199 CloseNow(); 220 CloseNow();
200 } 221 }
201 222
202 // static 223 // static
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 306
286 NonClientFrameView* NativeWidgetMus::CreateNonClientFrameView() { 307 NonClientFrameView* NativeWidgetMus::CreateNonClientFrameView() {
287 return new ClientSideNonClientFrameView(GetWidget()); 308 return new ClientSideNonClientFrameView(GetWidget());
288 } 309 }
289 310
290 void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) { 311 void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) {
291 ownership_ = params.ownership; 312 ownership_ = params.ownership;
292 window_->SetCanFocus(params.activatable == 313 window_->SetCanFocus(params.activatable ==
293 Widget::InitParams::ACTIVATABLE_YES); 314 Widget::InitParams::ACTIVATABLE_YES);
294 315
295 // WindowTreeHost creates the compositor using the ContextFactory from
296 // aura::Env. Install |context_factory_| there so that |context_factory_| is
297 // picked up.
298 ui::ContextFactory* default_context_factory =
299 aura::Env::GetInstance()->context_factory();
300 // For Chrome, we need the GpuProcessTransportFactory so that renderer and
301 // browser pixels are composited into a single backing
302 // SoftwareOutputDeviceMus.
303 if (!default_context_factory) {
304 if (!context_factory_) {
305 context_factory_.reset(new SurfaceContextFactory(shell_, window_,
306 surface_type_));
307 }
308 aura::Env::GetInstance()->set_context_factory(context_factory_.get());
309 }
310 window_tree_host_.reset(new WindowTreeHostMus(shell_, this, window_));
311 window_tree_host_->AddObserver(this);
312 window_tree_host_->InitHost();
313 aura::Env::GetInstance()->set_context_factory(default_context_factory);
314 window_tree_host_->window()->SetProperty(kMusWindow, window_);
315
316 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); 316 focus_client_.reset(new wm::FocusController(new FocusRulesImpl));
317 317
318 aura::client::SetFocusClient(window_tree_host_->window(), 318 aura::client::SetFocusClient(window_tree_host_->window(),
319 focus_client_.get()); 319 focus_client_.get());
320 aura::client::SetActivationClient(window_tree_host_->window(), 320 aura::client::SetActivationClient(window_tree_host_->window(),
321 focus_client_.get()); 321 focus_client_.get());
322 screen_position_client_.reset(new wm::DefaultScreenPositionClient());
323 aura::client::SetScreenPositionClient(window_tree_host_->window(),
324 screen_position_client_.get());
325
322 window_tree_client_.reset( 326 window_tree_client_.reset(
323 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); 327 new NativeWidgetMusWindowTreeClient(window_tree_host_->window()));
324 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); 328 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get());
325 window_tree_host_->window()->SetLayoutManager( 329 window_tree_host_->window()->SetLayoutManager(
326 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); 330 new ContentWindowLayoutManager(window_tree_host_->window(), content_));
327 capture_client_.reset( 331 capture_client_.reset(
328 new aura::client::DefaultCaptureClient(window_tree_host_->window())); 332 new aura::client::DefaultCaptureClient(window_tree_host_->window()));
329 333
330 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); 334 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL);
331 content_->Init(ui::LAYER_TEXTURED); 335 content_->Init(ui::LAYER_TEXTURED);
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 852
849 void NativeWidgetMus::OnGestureEvent(ui::GestureEvent* event) { 853 void NativeWidgetMus::OnGestureEvent(ui::GestureEvent* event) {
850 native_widget_delegate_->OnGestureEvent(event); 854 native_widget_delegate_->OnGestureEvent(event);
851 } 855 }
852 856
853 void NativeWidgetMus::OnHostCloseRequested(const aura::WindowTreeHost* host) { 857 void NativeWidgetMus::OnHostCloseRequested(const aura::WindowTreeHost* host) {
854 GetWidget()->Close(); 858 GetWidget()->Close();
855 } 859 }
856 860
857 } // namespace views 861 } // namespace views
OLDNEW
« components/mus/public/cpp/lib/window_tree_client_impl.cc ('K') | « ui/views/mus/native_widget_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698