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

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

Issue 2369793002: WIP: Propagate SurfaceID up window tree hierarchy
Patch Set: Fix input events: EventDispatcher ignores container windows Created 4 years, 2 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
« no previous file with comments | « ui/views/mus/native_widget_mus.h ('k') | ui/views/mus/surface_context_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/callback.h" 7 #include "base/callback.h"
8 #include "base/debug/stack_trace.h"
8 #include "base/macros.h" 9 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 11 #include "base/run_loop.h"
11 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
12 #include "services/ui/public/cpp/property_type_converters.h" 13 #include "services/ui/public/cpp/property_type_converters.h"
13 #include "services/ui/public/cpp/window.h" 14 #include "services/ui/public/cpp/window.h"
14 #include "services/ui/public/cpp/window_observer.h" 15 #include "services/ui/public/cpp/window_observer.h"
15 #include "services/ui/public/cpp/window_property.h" 16 #include "services/ui/public/cpp/window_property.h"
16 #include "services/ui/public/cpp/window_tree_client.h" 17 #include "services/ui/public/cpp/window_tree_client.h"
17 #include "services/ui/public/interfaces/cursor.mojom.h" 18 #include "services/ui/public/interfaces/cursor.mojom.h"
18 #include "services/ui/public/interfaces/window_manager.mojom.h" 19 #include "services/ui/public/interfaces/window_manager.mojom.h"
19 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" 20 #include "services/ui/public/interfaces/window_manager_constants.mojom.h"
20 #include "services/ui/public/interfaces/window_tree.mojom.h" 21 #include "services/ui/public/interfaces/window_tree.mojom.h"
21 #include "ui/aura/client/default_capture_client.h" 22 #include "ui/aura/client/default_capture_client.h"
22 #include "ui/aura/client/window_tree_client.h" 23 #include "ui/aura/client/window_tree_client.h"
23 #include "ui/aura/layout_manager.h" 24 #include "ui/aura/layout_manager.h"
24 #include "ui/aura/mus/mus_util.h" 25 #include "ui/aura/mus/mus_util.h"
25 #include "ui/aura/window.h" 26 #include "ui/aura/window.h"
26 #include "ui/aura/window_property.h" 27 #include "ui/aura/window_property.h"
27 #include "ui/base/hit_test.h" 28 #include "ui/base/hit_test.h"
28 #include "ui/display/display.h" 29 #include "ui/display/display.h"
29 #include "ui/display/screen.h" 30 #include "ui/display/screen.h"
30 #include "ui/events/event.h" 31 #include "ui/events/event.h"
31 #include "ui/gfx/canvas.h" 32 #include "ui/gfx/canvas.h"
33 #include "ui/gfx/geometry/dip_util.h"
32 #include "ui/gfx/path.h" 34 #include "ui/gfx/path.h"
33 #include "ui/native_theme/native_theme_aura.h" 35 #include "ui/native_theme/native_theme_aura.h"
34 #include "ui/platform_window/platform_window_delegate.h" 36 #include "ui/platform_window/platform_window_delegate.h"
35 #include "ui/views/mus/window_manager_connection.h" 37 #include "ui/views/mus/window_manager_connection.h"
36 #include "ui/views/mus/window_manager_constants_converters.h" 38 #include "ui/views/mus/window_manager_constants_converters.h"
37 #include "ui/views/mus/window_manager_frame_values.h" 39 #include "ui/views/mus/window_manager_frame_values.h"
38 #include "ui/views/mus/window_tree_host_mus.h" 40 #include "ui/views/mus/window_tree_host_mus.h"
39 #include "ui/views/widget/native_widget_aura.h" 41 #include "ui/views/widget/native_widget_aura.h"
40 #include "ui/views/widget/widget_delegate.h" 42 #include "ui/views/widget/widget_delegate.h"
41 #include "ui/views/window/custom_frame_view.h" 43 #include "ui/views/window/custom_frame_view.h"
42 #include "ui/wm/core/base_focus_rules.h" 44 #include "ui/wm/core/base_focus_rules.h"
43 #include "ui/wm/core/capture_controller.h" 45 #include "ui/wm/core/capture_controller.h"
44 #include "ui/wm/core/cursor_manager.h" 46 #include "ui/wm/core/cursor_manager.h"
45 #include "ui/wm/core/default_screen_position_client.h" 47 #include "ui/wm/core/default_screen_position_client.h"
46 #include "ui/wm/core/focus_controller.h" 48 #include "ui/wm/core/focus_controller.h"
47 #include "ui/wm/core/native_cursor_manager.h" 49 #include "ui/wm/core/native_cursor_manager.h"
48 50
49 DECLARE_WINDOW_PROPERTY_TYPE(ui::Window*); 51 DECLARE_WINDOW_PROPERTY_TYPE(ui::Window*);
50 52
51 using ui::mojom::EventResult; 53 using ui::mojom::EventResult;
52 54
53 namespace views { 55 namespace views {
54 namespace { 56 namespace {
55 57
56 DEFINE_WINDOW_PROPERTY_KEY(ui::Window*, kMusWindow, nullptr); 58 DEFINE_WINDOW_PROPERTY_KEY(ui::Window*, kMusWindow, nullptr);
57 59
58 MUS_DEFINE_WINDOW_PROPERTY_KEY(NativeWidgetMus*, kNativeWidgetMusKey, nullptr); 60 MUS_DEFINE_WINDOW_PROPERTY_KEY(NativeWidgetMus*, kNativeWidgetMusKey, nullptr);
59 61
62 void SatisfyCallback(const cc::SurfaceSequence& sequence) {
63 fprintf(stderr, ">>>%s\n", __PRETTY_FUNCTION__);
64 }
65
66 void RequireCallback(const cc::SurfaceId& id,
67 const cc::SurfaceSequence& sequence) {
68 fprintf(stderr, ">>>%s\n", __PRETTY_FUNCTION__);
69 }
70
60 // This ensures that only the top-level aura Window can be activated. 71 // This ensures that only the top-level aura Window can be activated.
61 class FocusRulesImpl : public wm::BaseFocusRules { 72 class FocusRulesImpl : public wm::BaseFocusRules {
62 public: 73 public:
63 explicit FocusRulesImpl(aura::Window* root) : root_(root) {} 74 explicit FocusRulesImpl(aura::Window* root) : root_(root) {}
64 ~FocusRulesImpl() override {} 75 ~FocusRulesImpl() override {}
65 76
66 bool SupportsChildActivation(aura::Window* window) const override { 77 bool SupportsChildActivation(aura::Window* window) const override {
67 return root_ == window; 78 return root_ == window;
68 } 79 }
69 80
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 mus_window()->RemoveObserver(this); 411 mus_window()->RemoveObserver(this);
401 } 412 }
402 413
403 // ui::WindowObserver: 414 // ui::WindowObserver:
404 void OnWindowVisibilityChanging(ui::Window* window) override { 415 void OnWindowVisibilityChanging(ui::Window* window) override {
405 native_widget_mus_->OnMusWindowVisibilityChanging(window); 416 native_widget_mus_->OnMusWindowVisibilityChanging(window);
406 } 417 }
407 void OnWindowVisibilityChanged(ui::Window* window) override { 418 void OnWindowVisibilityChanged(ui::Window* window) override {
408 native_widget_mus_->OnMusWindowVisibilityChanged(window); 419 native_widget_mus_->OnMusWindowVisibilityChanged(window);
409 } 420 }
421
422 void OnChildWindowSurfaceCreated(
423 ui::Window* window,
424 const gfx::Size& size,
425 float device_scale_factor,
426 const cc::SurfaceId& surface_id,
427 const cc::SurfaceSequence& surface_sequence) override {
428 //NativeWidgetMus* nwm = NativeWidgetMus::GetForWindow(window);
429 //fprintf(stderr, ">>>>%s nwm: %p\n", __PRETTY_FUNCTION__, nwm);
430 //if (nwm) {
431 // gfx::Size size_in_dip = gfx::ConvertSizeToDIP(device_scale_factor, size) ;
432 // nwm->GetNativeView()->layer()->SetShowSurface(
433 // surface_id, base::Bind(&SatisfyCallback),
434 // base::Bind(&RequireCallback), size, device_scale_factor, size_in_dip );
435 //}
436 }
437
410 void OnWindowPredefinedCursorChanged(ui::Window* window, 438 void OnWindowPredefinedCursorChanged(ui::Window* window,
411 ui::mojom::Cursor cursor) override { 439 ui::mojom::Cursor cursor) override {
412 DCHECK_EQ(window, mus_window()); 440 DCHECK_EQ(window, mus_window());
413 native_widget_mus_->set_last_cursor(cursor); 441 native_widget_mus_->set_last_cursor(cursor);
414 } 442 }
415 void OnWindowSharedPropertyChanged( 443 void OnWindowSharedPropertyChanged(
416 ui::Window* window, 444 ui::Window* window,
417 const std::string& name, 445 const std::string& name,
418 const std::vector<uint8_t>* old_data, 446 const std::vector<uint8_t>* old_data,
419 const std::vector<uint8_t>* new_data) override { 447 const std::vector<uint8_t>* new_data) override {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 ui::Window* window, 545 ui::Window* window,
518 ui::mojom::SurfaceType surface_type) 546 ui::mojom::SurfaceType surface_type)
519 : window_(window), 547 : window_(window),
520 last_cursor_(ui::mojom::Cursor::CURSOR_NULL), 548 last_cursor_(ui::mojom::Cursor::CURSOR_NULL),
521 native_widget_delegate_(delegate), 549 native_widget_delegate_(delegate),
522 surface_type_(surface_type), 550 surface_type_(surface_type),
523 show_state_before_fullscreen_(ui::mojom::ShowState::DEFAULT), 551 show_state_before_fullscreen_(ui::mojom::ShowState::DEFAULT),
524 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 552 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
525 content_(new aura::Window(this)), 553 content_(new aura::Window(this)),
526 close_widget_factory_(this) { 554 close_widget_factory_(this) {
555 // base::debug::StackTrace().Print();
527 window_->set_input_event_handler(this); 556 window_->set_input_event_handler(this);
528 mus_window_observer_.reset(new MusWindowObserver(this)); 557 mus_window_observer_.reset(new MusWindowObserver(this));
529 558
530 // TODO(fsamuel): Figure out lifetime of |window_|. 559 // TODO(fsamuel): Figure out lifetime of |window_|.
531 aura::SetMusWindow(content_, window_); 560 aura::SetMusWindow(content_, window_);
532 window->SetLocalProperty(kNativeWidgetMusKey, this); 561 window->SetLocalProperty(kNativeWidgetMusKey, this);
533 window_tree_host_.reset(new WindowTreeHostMus(this, window_)); 562 window_tree_host_.reset(new WindowTreeHostMus(this, window_));
534 } 563 }
535 564
536 NativeWidgetMus::~NativeWidgetMus() { 565 NativeWidgetMus::~NativeWidgetMus() {
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 1490
1462 gfx::Path mask_path; 1491 gfx::Path mask_path;
1463 native_widget_delegate_->GetHitTestMask(&mask_path); 1492 native_widget_delegate_->GetHitTestMask(&mask_path);
1464 // TODO(jamescook): Use the full path for the mask. 1493 // TODO(jamescook): Use the full path for the mask.
1465 gfx::Rect mask_rect = 1494 gfx::Rect mask_rect =
1466 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); 1495 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds()));
1467 window_->SetHitTestMask(mask_rect); 1496 window_->SetHitTestMask(mask_rect);
1468 } 1497 }
1469 1498
1470 } // namespace views 1499 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/native_widget_mus.h ('k') | ui/views/mus/surface_context_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698