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

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

Issue 1462123002: views/mus: Set-up transient windows correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 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/views/mus/native_widget_mus.h" 5 #include "ui/views/mus/native_widget_mus.h"
6 6
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "components/mus/public/cpp/property_type_converters.h" 8 #include "components/mus/public/cpp/property_type_converters.h"
9 #include "components/mus/public/cpp/window.h" 9 #include "components/mus/public/cpp/window.h"
10 #include "components/mus/public/cpp/window_property.h" 10 #include "components/mus/public/cpp/window_property.h"
11 #include "mojo/converters/geometry/geometry_type_converters.h" 11 #include "mojo/converters/geometry/geometry_type_converters.h"
12 #include "ui/aura/client/default_capture_client.h" 12 #include "ui/aura/client/default_capture_client.h"
13 #include "ui/aura/client/window_tree_client.h" 13 #include "ui/aura/client/window_tree_client.h"
14 #include "ui/aura/env.h" 14 #include "ui/aura/env.h"
15 #include "ui/aura/layout_manager.h" 15 #include "ui/aura/layout_manager.h"
16 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
17 #include "ui/aura/window_property.h"
17 #include "ui/base/hit_test.h" 18 #include "ui/base/hit_test.h"
18 #include "ui/compositor/clip_transform_recorder.h" 19 #include "ui/compositor/clip_transform_recorder.h"
19 #include "ui/compositor/paint_recorder.h" 20 #include "ui/compositor/paint_recorder.h"
20 #include "ui/gfx/canvas.h" 21 #include "ui/gfx/canvas.h"
21 #include "ui/native_theme/native_theme_aura.h" 22 #include "ui/native_theme/native_theme_aura.h"
22 #include "ui/views/mus/platform_window_mus.h" 23 #include "ui/views/mus/platform_window_mus.h"
23 #include "ui/views/mus/surface_context_factory.h" 24 #include "ui/views/mus/surface_context_factory.h"
24 #include "ui/views/mus/window_manager_client_area_insets.h" 25 #include "ui/views/mus/window_manager_client_area_insets.h"
25 #include "ui/views/mus/window_tree_host_mus.h" 26 #include "ui/views/mus/window_tree_host_mus.h"
26 #include "ui/views/widget/widget_delegate.h" 27 #include "ui/views/widget/widget_delegate.h"
27 #include "ui/views/window/custom_frame_view.h" 28 #include "ui/views/window/custom_frame_view.h"
28 #include "ui/wm/core/base_focus_rules.h" 29 #include "ui/wm/core/base_focus_rules.h"
29 #include "ui/wm/core/capture_controller.h" 30 #include "ui/wm/core/capture_controller.h"
30 #include "ui/wm/core/focus_controller.h" 31 #include "ui/wm/core/focus_controller.h"
31 32
33 DECLARE_WINDOW_PROPERTY_TYPE(mus::Window*);
34
32 namespace views { 35 namespace views {
33 namespace { 36 namespace {
34 37
38 DEFINE_WINDOW_PROPERTY_KEY(mus::Window*, kMusWindow, nullptr);
39
35 WindowManagerClientAreaInsets* window_manager_client_area_insets = nullptr; 40 WindowManagerClientAreaInsets* window_manager_client_area_insets = nullptr;
36 41
37 // TODO: figure out what this should be. 42 // TODO: figure out what this should be.
38 class FocusRulesImpl : public wm::BaseFocusRules { 43 class FocusRulesImpl : public wm::BaseFocusRules {
39 public: 44 public:
40 FocusRulesImpl() {} 45 FocusRulesImpl() {}
41 ~FocusRulesImpl() override {} 46 ~FocusRulesImpl() override {}
42 47
43 bool SupportsChildActivation(aura::Window* window) const override { 48 bool SupportsChildActivation(aura::Window* window) const override {
44 return true; 49 return true;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 aura::Env::GetInstance()->context_factory(); 267 aura::Env::GetInstance()->context_factory();
263 // For Chrome, we need the GpuProcessTransportFactory so that renderer and 268 // For Chrome, we need the GpuProcessTransportFactory so that renderer and
264 // browser pixels are composited into a single backing 269 // browser pixels are composited into a single backing
265 // SoftwareOutputDeviceMus. 270 // SoftwareOutputDeviceMus.
266 if (!default_context_factory) 271 if (!default_context_factory)
267 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); 272 aura::Env::GetInstance()->set_context_factory(context_factory_.get());
268 window_tree_host_.reset( 273 window_tree_host_.reset(
269 new WindowTreeHostMus(shell_, this, window_, surface_type_)); 274 new WindowTreeHostMus(shell_, this, window_, surface_type_));
270 window_tree_host_->InitHost(); 275 window_tree_host_->InitHost();
271 aura::Env::GetInstance()->set_context_factory(default_context_factory); 276 aura::Env::GetInstance()->set_context_factory(default_context_factory);
277 window_tree_host_->window()->SetProperty(kMusWindow, window_);
272 278
273 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); 279 focus_client_.reset(new wm::FocusController(new FocusRulesImpl));
274 280
275 aura::client::SetFocusClient(window_tree_host_->window(), 281 aura::client::SetFocusClient(window_tree_host_->window(),
276 focus_client_.get()); 282 focus_client_.get());
277 aura::client::SetActivationClient(window_tree_host_->window(), 283 aura::client::SetActivationClient(window_tree_host_->window(),
278 focus_client_.get()); 284 focus_client_.get());
279 window_tree_client_.reset( 285 window_tree_client_.reset(
280 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); 286 new NativeWidgetMusWindowTreeClient(window_tree_host_->window()));
281 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); 287 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get());
282 window_tree_host_->window()->SetLayoutManager( 288 window_tree_host_->window()->SetLayoutManager(
283 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); 289 new ContentWindowLayoutManager(window_tree_host_->window(), content_));
284 capture_client_.reset( 290 capture_client_.reset(
285 new aura::client::DefaultCaptureClient(window_tree_host_->window())); 291 new aura::client::DefaultCaptureClient(window_tree_host_->window()));
286 292
287 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); 293 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL);
288 content_->Init(ui::LAYER_TEXTURED); 294 content_->Init(ui::LAYER_TEXTURED);
289 content_->Show(); 295 content_->Show();
290 content_->SetTransparent(true); 296 content_->SetTransparent(true);
291 content_->SetFillsBoundsCompletely(false); 297 content_->SetFillsBoundsCompletely(false);
298 window_tree_host_->window()->AddChild(content_);
292 299
293 window_tree_host_->window()->AddChild(content_); 300 // Set-up transiency if appropriate.
301 if (params.parent && !params.child) {
302 aura::Window* parent_root = params.parent->GetRootWindow();
303 mus::Window* parent_mus = parent_root->GetProperty(kMusWindow);
304 if (parent_mus)
305 parent_mus->AddTransientWindow(window_);
306 }
307
294 // TODO(beng): much else, see [Desktop]NativeWidgetAura. 308 // TODO(beng): much else, see [Desktop]NativeWidgetAura.
295 309
296 native_widget_delegate_->OnNativeWidgetCreated(false); 310 native_widget_delegate_->OnNativeWidgetCreated(false);
297 } 311 }
298 312
299 bool NativeWidgetMus::ShouldUseNativeFrame() const { 313 bool NativeWidgetMus::ShouldUseNativeFrame() const {
300 // NOTIMPLEMENTED(); 314 // NOTIMPLEMENTED();
301 return false; 315 return false;
302 } 316 }
303 317
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 } else { 789 } else {
776 native_widget_delegate_->OnScrollEvent(event); 790 native_widget_delegate_->OnScrollEvent(event);
777 } 791 }
778 } 792 }
779 793
780 void NativeWidgetMus::OnGestureEvent(ui::GestureEvent* event) { 794 void NativeWidgetMus::OnGestureEvent(ui::GestureEvent* event) {
781 native_widget_delegate_->OnGestureEvent(event); 795 native_widget_delegate_->OnGestureEvent(event);
782 } 796 }
783 797
784 } // namespace views 798 } // namespace views
OLDNEW
« components/mus/ws/default_access_policy.cc ('K') | « components/web_view/frame.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698