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/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/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "ui/aura/client/default_capture_client.h" | 21 #include "ui/aura/client/default_capture_client.h" |
22 #include "ui/aura/client/window_tree_client.h" | 22 #include "ui/aura/client/window_tree_client.h" |
23 #include "ui/aura/env.h" | 23 #include "ui/aura/env.h" |
24 #include "ui/aura/layout_manager.h" | 24 #include "ui/aura/layout_manager.h" |
25 #include "ui/aura/mus/mus_util.h" | 25 #include "ui/aura/mus/mus_util.h" |
26 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
27 #include "ui/aura/window_property.h" | 27 #include "ui/aura/window_property.h" |
28 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
29 #include "ui/events/event.h" | 29 #include "ui/events/event.h" |
30 #include "ui/gfx/canvas.h" | 30 #include "ui/gfx/canvas.h" |
| 31 #include "ui/gfx/native_widget_types.h" |
31 #include "ui/gfx/path.h" | 32 #include "ui/gfx/path.h" |
32 #include "ui/native_theme/native_theme_aura.h" | 33 #include "ui/native_theme/native_theme_aura.h" |
33 #include "ui/platform_window/platform_window_delegate.h" | 34 #include "ui/platform_window/platform_window_delegate.h" |
34 #include "ui/views/mus/platform_window_mus.h" | |
35 #include "ui/views/mus/surface_context_factory.h" | 35 #include "ui/views/mus/surface_context_factory.h" |
36 #include "ui/views/mus/window_manager_constants_converters.h" | 36 #include "ui/views/mus/window_manager_constants_converters.h" |
37 #include "ui/views/mus/window_manager_frame_values.h" | 37 #include "ui/views/mus/window_manager_frame_values.h" |
38 #include "ui/views/mus/window_tree_host_mus.h" | 38 #include "ui/views/mus/window_tree_host_mus.h" |
39 #include "ui/views/widget/native_widget_aura.h" | 39 #include "ui/views/widget/native_widget_aura.h" |
40 #include "ui/views/widget/widget_delegate.h" | 40 #include "ui/views/widget/widget_delegate.h" |
41 #include "ui/views/window/custom_frame_view.h" | 41 #include "ui/views/window/custom_frame_view.h" |
42 #include "ui/wm/core/base_focus_rules.h" | 42 #include "ui/wm/core/base_focus_rules.h" |
43 #include "ui/wm/core/capture_controller.h" | 43 #include "ui/wm/core/capture_controller.h" |
44 #include "ui/wm/core/cursor_manager.h" | 44 #include "ui/wm/core/cursor_manager.h" |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 | 632 |
633 //////////////////////////////////////////////////////////////////////////////// | 633 //////////////////////////////////////////////////////////////////////////////// |
634 // NativeWidgetMus, internal::NativeWidgetPrivate implementation: | 634 // NativeWidgetMus, internal::NativeWidgetPrivate implementation: |
635 | 635 |
636 NonClientFrameView* NativeWidgetMus::CreateNonClientFrameView() { | 636 NonClientFrameView* NativeWidgetMus::CreateNonClientFrameView() { |
637 return new ClientSideNonClientFrameView(GetWidget()); | 637 return new ClientSideNonClientFrameView(GetWidget()); |
638 } | 638 } |
639 | 639 |
640 void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) { | 640 void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) { |
641 NativeWidgetAura::RegisterNativeWidgetForWindow(this, content_); | 641 NativeWidgetAura::RegisterNativeWidgetForWindow(this, content_); |
| 642 aura::Window* hosted_window = window_tree_host_->window(); |
642 | 643 |
643 ownership_ = params.ownership; | 644 ownership_ = params.ownership; |
644 window_->SetCanFocus(params.activatable == | 645 window_->SetCanFocus(params.activatable == |
645 Widget::InitParams::ACTIVATABLE_YES); | 646 Widget::InitParams::ACTIVATABLE_YES); |
646 | 647 |
647 window_tree_host_->AddObserver(this); | 648 window_tree_host_->AddObserver(this); |
648 window_tree_host_->InitHost(); | 649 window_tree_host_->InitHost(); |
649 window_tree_host_->window()->SetProperty(kMusWindow, window_); | 650 hosted_window->SetProperty(kMusWindow, window_); |
650 | 651 |
651 focus_client_.reset( | 652 focus_client_.reset( |
652 new wm::FocusController(new FocusRulesImpl(window_tree_host_->window()))); | 653 new wm::FocusController(new FocusRulesImpl(hosted_window))); |
653 | 654 |
654 aura::client::SetFocusClient(window_tree_host_->window(), | 655 aura::client::SetFocusClient(hosted_window, focus_client_.get()); |
655 focus_client_.get()); | 656 aura::client::SetActivationClient(hosted_window, |
656 aura::client::SetActivationClient(window_tree_host_->window(), | |
657 focus_client_.get()); | 657 focus_client_.get()); |
658 screen_position_client_.reset(new ScreenPositionClientMus(window_)); | 658 screen_position_client_.reset(new ScreenPositionClientMus(window_)); |
659 aura::client::SetScreenPositionClient(window_tree_host_->window(), | 659 aura::client::SetScreenPositionClient(hosted_window, |
660 screen_position_client_.get()); | 660 screen_position_client_.get()); |
661 | 661 |
662 // TODO(erg): Remove this check when mash/wm/frame/move_event_handler.cc's | 662 // TODO(erg): Remove this check when mash/wm/frame/move_event_handler.cc's |
663 // direct usage of mus::Window::SetPredefinedCursor() is switched to a | 663 // direct usage of mus::Window::SetPredefinedCursor() is switched to a |
664 // private method on WindowManagerClient. | 664 // private method on WindowManagerClient. |
665 if (surface_type_ == mus::mojom::SurfaceType::DEFAULT) { | 665 if (surface_type_ == mus::mojom::SurfaceType::DEFAULT) { |
666 cursor_manager_.reset(new wm::CursorManager( | 666 cursor_manager_.reset(new wm::CursorManager( |
667 base::WrapUnique(new NativeCursorManagerMus(window_)))); | 667 base::WrapUnique(new NativeCursorManagerMus(window_)))); |
668 aura::client::SetCursorClient(window_tree_host_->window(), | 668 aura::client::SetCursorClient(hosted_window, |
669 cursor_manager_.get()); | 669 cursor_manager_.get()); |
670 } | 670 } |
671 | 671 |
672 window_tree_client_.reset( | 672 window_tree_client_.reset( |
673 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); | 673 new NativeWidgetMusWindowTreeClient(hosted_window)); |
674 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); | 674 hosted_window->AddPreTargetHandler(focus_client_.get()); |
675 window_tree_host_->window()->SetLayoutManager( | 675 hosted_window->SetLayoutManager( |
676 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); | 676 new ContentWindowLayoutManager(hosted_window, content_)); |
677 capture_client_.reset( | 677 capture_client_.reset( |
678 new MusCaptureClient(window_tree_host_->window(), content_, window_)); | 678 new MusCaptureClient(hosted_window, content_, window_)); |
679 | 679 |
680 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 680 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
681 content_->Init(ui::LAYER_TEXTURED); | 681 content_->Init(ui::LAYER_TEXTURED); |
682 if (window_->visible()) | 682 if (window_->visible()) |
683 content_->Show(); | 683 content_->Show(); |
684 content_->SetTransparent(true); | 684 content_->SetTransparent(true); |
685 content_->SetFillsBoundsCompletely(false); | 685 content_->SetFillsBoundsCompletely(false); |
686 window_tree_host_->window()->AddChild(content_); | 686 hosted_window->AddChild(content_); |
687 | 687 |
688 // Set-up transiency if appropriate. | 688 // Set-up transiency if appropriate. |
689 if (params.parent && !params.child) { | 689 if (params.parent && !params.child) { |
690 aura::Window* parent_root = params.parent->GetRootWindow(); | 690 aura::Window* parent_root = params.parent->GetRootWindow(); |
691 mus::Window* parent_mus = parent_root->GetProperty(kMusWindow); | 691 mus::Window* parent_mus = parent_root->GetProperty(kMusWindow); |
692 if (parent_mus) | 692 if (parent_mus) |
693 parent_mus->AddTransientWindow(window_); | 693 parent_mus->AddTransientWindow(window_); |
694 } | 694 } |
695 | 695 |
696 if (params.parent_mus) | 696 if (params.parent_mus) |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 bool NativeWidgetMus::IsMinimized() const { | 1023 bool NativeWidgetMus::IsMinimized() const { |
1024 return mus_window_observer_ && | 1024 return mus_window_observer_ && |
1025 mus_window_observer_->show_state() == mus::mojom::ShowState::MINIMIZED; | 1025 mus_window_observer_->show_state() == mus::mojom::ShowState::MINIMIZED; |
1026 } | 1026 } |
1027 | 1027 |
1028 void NativeWidgetMus::Restore() { | 1028 void NativeWidgetMus::Restore() { |
1029 SetShowState(mus::mojom::ShowState::NORMAL); | 1029 SetShowState(mus::mojom::ShowState::NORMAL); |
1030 } | 1030 } |
1031 | 1031 |
1032 void NativeWidgetMus::SetFullscreen(bool fullscreen) { | 1032 void NativeWidgetMus::SetFullscreen(bool fullscreen) { |
1033 if (!window_tree_host_ || IsFullscreen() == fullscreen) | 1033 if (IsFullscreen() == fullscreen) |
1034 return; | 1034 return; |
1035 if (fullscreen) { | 1035 if (fullscreen) { |
1036 show_state_before_fullscreen_ = mus_window_observer_->show_state(); | 1036 show_state_before_fullscreen_ = mus_window_observer_->show_state(); |
1037 window_tree_host_->platform_window()->ToggleFullscreen(); | 1037 // TODO(markdittmer): Fullscreen not implemented in mus::Window. |
1038 } else { | 1038 } else { |
1039 switch (show_state_before_fullscreen_) { | 1039 switch (show_state_before_fullscreen_) { |
1040 case mus::mojom::ShowState::MAXIMIZED: | 1040 case mus::mojom::ShowState::MAXIMIZED: |
1041 Maximize(); | 1041 Maximize(); |
1042 break; | 1042 break; |
1043 case mus::mojom::ShowState::MINIMIZED: | 1043 case mus::mojom::ShowState::MINIMIZED: |
1044 Minimize(); | 1044 Minimize(); |
1045 break; | 1045 break; |
1046 case mus::mojom::ShowState::DEFAULT: | 1046 case mus::mojom::ShowState::DEFAULT: |
1047 case mus::mojom::ShowState::NORMAL: | 1047 case mus::mojom::ShowState::NORMAL: |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 | 1359 |
1360 gfx::Path mask_path; | 1360 gfx::Path mask_path; |
1361 native_widget_delegate_->GetHitTestMask(&mask_path); | 1361 native_widget_delegate_->GetHitTestMask(&mask_path); |
1362 // TODO(jamescook): Use the full path for the mask. | 1362 // TODO(jamescook): Use the full path for the mask. |
1363 gfx::Rect mask_rect = | 1363 gfx::Rect mask_rect = |
1364 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1364 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
1365 window_->SetHitTestMask(mask_rect); | 1365 window_->SetHitTestMask(mask_rect); |
1366 } | 1366 } |
1367 | 1367 |
1368 } // namespace views | 1368 } // namespace views |
OLD | NEW |