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 <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
29 #include "ui/aura/window_property.h" | 29 #include "ui/aura/window_property.h" |
30 #include "ui/base/hit_test.h" | 30 #include "ui/base/hit_test.h" |
31 #include "ui/display/display.h" | 31 #include "ui/display/display.h" |
32 #include "ui/display/screen.h" | 32 #include "ui/display/screen.h" |
33 #include "ui/events/event.h" | 33 #include "ui/events/event.h" |
34 #include "ui/gfx/canvas.h" | 34 #include "ui/gfx/canvas.h" |
35 #include "ui/gfx/path.h" | 35 #include "ui/gfx/path.h" |
36 #include "ui/native_theme/native_theme_aura.h" | 36 #include "ui/native_theme/native_theme_aura.h" |
37 #include "ui/platform_window/platform_window_delegate.h" | 37 #include "ui/platform_window/platform_window_delegate.h" |
38 #include "ui/views/corewm/tooltip.h" | |
39 #include "ui/views/corewm/tooltip_aura.h" | |
40 #include "ui/views/corewm/tooltip_controller.h" | |
38 #include "ui/views/drag_utils.h" | 41 #include "ui/views/drag_utils.h" |
39 #include "ui/views/mus/drag_drop_client_mus.h" | 42 #include "ui/views/mus/drag_drop_client_mus.h" |
40 #include "ui/views/mus/drop_target_mus.h" | 43 #include "ui/views/mus/drop_target_mus.h" |
41 #include "ui/views/mus/window_manager_connection.h" | 44 #include "ui/views/mus/window_manager_connection.h" |
42 #include "ui/views/mus/window_manager_constants_converters.h" | 45 #include "ui/views/mus/window_manager_constants_converters.h" |
43 #include "ui/views/mus/window_manager_frame_values.h" | 46 #include "ui/views/mus/window_manager_frame_values.h" |
44 #include "ui/views/mus/window_tree_host_mus.h" | 47 #include "ui/views/mus/window_tree_host_mus.h" |
45 #include "ui/views/widget/drop_helper.h" | 48 #include "ui/views/widget/drop_helper.h" |
46 #include "ui/views/widget/native_widget_aura.h" | 49 #include "ui/views/widget/native_widget_aura.h" |
50 #include "ui/views/widget/tooltip_manager_aura.h" | |
47 #include "ui/views/widget/widget_delegate.h" | 51 #include "ui/views/widget/widget_delegate.h" |
48 #include "ui/views/window/custom_frame_view.h" | 52 #include "ui/views/window/custom_frame_view.h" |
49 #include "ui/wm/core/base_focus_rules.h" | 53 #include "ui/wm/core/base_focus_rules.h" |
50 #include "ui/wm/core/capture_controller.h" | 54 #include "ui/wm/core/capture_controller.h" |
51 #include "ui/wm/core/cursor_manager.h" | 55 #include "ui/wm/core/cursor_manager.h" |
52 #include "ui/wm/core/default_screen_position_client.h" | 56 #include "ui/wm/core/default_screen_position_client.h" |
53 #include "ui/wm/core/focus_controller.h" | 57 #include "ui/wm/core/focus_controller.h" |
54 #include "ui/wm/core/native_cursor_manager.h" | 58 #include "ui/wm/core/native_cursor_manager.h" |
55 | 59 |
56 DECLARE_WINDOW_PROPERTY_TYPE(ui::Window*); | 60 DECLARE_WINDOW_PROPERTY_TYPE(ui::Window*); |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 return native_widget->GetWidget(); | 586 return native_widget->GetWidget(); |
583 } | 587 } |
584 | 588 |
585 aura::Window* NativeWidgetMus::GetRootWindow() { | 589 aura::Window* NativeWidgetMus::GetRootWindow() { |
586 return window_tree_host_->window(); | 590 return window_tree_host_->window(); |
587 } | 591 } |
588 | 592 |
589 void NativeWidgetMus::OnPlatformWindowClosed() { | 593 void NativeWidgetMus::OnPlatformWindowClosed() { |
590 native_widget_delegate_->OnNativeWidgetDestroying(); | 594 native_widget_delegate_->OnNativeWidgetDestroying(); |
591 | 595 |
596 tooltip_manager_.reset(); | |
597 if (tooltip_controller_.get()) { | |
598 window_tree_host_->window()->RemovePreTargetHandler( | |
599 tooltip_controller_.get()); | |
600 aura::client::SetTooltipClient(window_tree_host_->window(), NULL); | |
sky
2016/09/30 15:15:30
nullptr
| |
601 tooltip_controller_.reset(); | |
602 } | |
603 | |
592 window_tree_client_.reset(); // Uses |content_|. | 604 window_tree_client_.reset(); // Uses |content_|. |
593 capture_client_.reset(); // Uses |content_|. | 605 capture_client_.reset(); // Uses |content_|. |
594 | 606 |
595 window_tree_host_->RemoveObserver(this); | 607 window_tree_host_->RemoveObserver(this); |
596 window_tree_host_.reset(); | 608 window_tree_host_.reset(); |
597 | 609 |
598 cursor_manager_.reset(); // Uses |window_|. | 610 cursor_manager_.reset(); // Uses |window_|. |
599 | 611 |
600 mus_window_observer_.reset(nullptr); | 612 mus_window_observer_.reset(nullptr); |
601 | 613 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 aura::client::SetScreenPositionClient(hosted_window, | 724 aura::client::SetScreenPositionClient(hosted_window, |
713 screen_position_client_.get()); | 725 screen_position_client_.get()); |
714 | 726 |
715 drag_drop_client_ = base::MakeUnique<DragDropClientMus>(window_); | 727 drag_drop_client_ = base::MakeUnique<DragDropClientMus>(window_); |
716 aura::client::SetDragDropClient(hosted_window, drag_drop_client_.get()); | 728 aura::client::SetDragDropClient(hosted_window, drag_drop_client_.get()); |
717 drop_target_ = base::MakeUnique<DropTargetMus>(content_); | 729 drop_target_ = base::MakeUnique<DropTargetMus>(content_); |
718 window_->SetCanAcceptDrops(drop_target_.get()); | 730 window_->SetCanAcceptDrops(drop_target_.get()); |
719 drop_helper_ = base::MakeUnique<DropHelper>(GetWidget()->GetRootView()); | 731 drop_helper_ = base::MakeUnique<DropHelper>(GetWidget()->GetRootView()); |
720 aura::client::SetDragDropDelegate(content_, this); | 732 aura::client::SetDragDropDelegate(content_, this); |
721 | 733 |
734 if (params.type != Widget::InitParams::TYPE_TOOLTIP) { | |
735 tooltip_manager_ = base::MakeUnique<TooltipManagerAura>(GetWidget()); | |
736 tooltip_controller_ = base::MakeUnique<corewm::TooltipController>( | |
737 base::MakeUnique<corewm::TooltipAura>()); | |
738 aura::client::SetTooltipClient(window_tree_host_->window(), | |
739 tooltip_controller_.get()); | |
740 window_tree_host_->window()->AddPreTargetHandler(tooltip_controller_.get()); | |
741 } | |
742 | |
722 // TODO(erg): Remove this check when ash/mus/move_event_handler.cc's | 743 // TODO(erg): Remove this check when ash/mus/move_event_handler.cc's |
723 // direct usage of ui::Window::SetPredefinedCursor() is switched to a | 744 // direct usage of ui::Window::SetPredefinedCursor() is switched to a |
724 // private method on WindowManagerClient. | 745 // private method on WindowManagerClient. |
725 if (!is_parallel_widget_in_window_manager()) { | 746 if (!is_parallel_widget_in_window_manager()) { |
726 cursor_manager_ = base::MakeUnique<wm::CursorManager>( | 747 cursor_manager_ = base::MakeUnique<wm::CursorManager>( |
727 base::MakeUnique<NativeCursorManagerMus>(window_)); | 748 base::MakeUnique<NativeCursorManagerMus>(window_)); |
728 aura::client::SetCursorClient(hosted_window, cursor_manager_.get()); | 749 aura::client::SetCursorClient(hosted_window, cursor_manager_.get()); |
729 } | 750 } |
730 | 751 |
731 window_tree_client_ = | 752 window_tree_client_ = |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 } | 856 } |
836 | 857 |
837 void* NativeWidgetMus::GetNativeWindowProperty(const char* name) const { | 858 void* NativeWidgetMus::GetNativeWindowProperty(const char* name) const { |
838 auto it = native_window_properties_.find(name); | 859 auto it = native_window_properties_.find(name); |
839 if (it == native_window_properties_.end()) | 860 if (it == native_window_properties_.end()) |
840 return nullptr; | 861 return nullptr; |
841 return it->second; | 862 return it->second; |
842 } | 863 } |
843 | 864 |
844 TooltipManager* NativeWidgetMus::GetTooltipManager() const { | 865 TooltipManager* NativeWidgetMus::GetTooltipManager() const { |
845 // NOTIMPLEMENTED(); | 866 return tooltip_manager_.get(); |
846 return nullptr; | |
847 } | 867 } |
848 | 868 |
849 void NativeWidgetMus::SetCapture() { | 869 void NativeWidgetMus::SetCapture() { |
850 if (content_) | 870 if (content_) |
851 content_->SetCapture(); | 871 content_->SetCapture(); |
852 } | 872 } |
853 | 873 |
854 void NativeWidgetMus::ReleaseCapture() { | 874 void NativeWidgetMus::ReleaseCapture() { |
855 if (content_) | 875 if (content_) |
856 content_->ReleaseCapture(); | 876 content_->ReleaseCapture(); |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1378 } | 1398 } |
1379 // Renderer may send a key event back to us if the key event wasn't handled, | 1399 // Renderer may send a key event back to us if the key event wasn't handled, |
1380 // and the window may be invisible by that time. | 1400 // and the window may be invisible by that time. |
1381 if (!content_->IsVisible()) | 1401 if (!content_->IsVisible()) |
1382 return; | 1402 return; |
1383 | 1403 |
1384 native_widget_delegate_->OnKeyEvent(event); | 1404 native_widget_delegate_->OnKeyEvent(event); |
1385 } | 1405 } |
1386 | 1406 |
1387 void NativeWidgetMus::OnMouseEvent(ui::MouseEvent* event) { | 1407 void NativeWidgetMus::OnMouseEvent(ui::MouseEvent* event) { |
1388 // TODO(sky): forward to tooltipmanager. See NativeWidgetDesktopAura. | |
1389 DCHECK(content_->IsVisible()); | 1408 DCHECK(content_->IsVisible()); |
1409 | |
1410 if (tooltip_manager_.get()) | |
1411 tooltip_manager_->UpdateTooltip(); | |
1412 TooltipManagerAura::UpdateTooltipManagerForCapture(GetWidget()); | |
1413 | |
1390 native_widget_delegate_->OnMouseEvent(event); | 1414 native_widget_delegate_->OnMouseEvent(event); |
1391 // WARNING: we may have been deleted. | 1415 // WARNING: we may have been deleted. |
1392 } | 1416 } |
1393 | 1417 |
1394 void NativeWidgetMus::OnScrollEvent(ui::ScrollEvent* event) { | 1418 void NativeWidgetMus::OnScrollEvent(ui::ScrollEvent* event) { |
1395 if (event->type() == ui::ET_SCROLL) { | 1419 if (event->type() == ui::ET_SCROLL) { |
1396 native_widget_delegate_->OnScrollEvent(event); | 1420 native_widget_delegate_->OnScrollEvent(event); |
1397 if (event->handled()) | 1421 if (event->handled()) |
1398 return; | 1422 return; |
1399 | 1423 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1508 | 1532 |
1509 gfx::Path mask_path; | 1533 gfx::Path mask_path; |
1510 native_widget_delegate_->GetHitTestMask(&mask_path); | 1534 native_widget_delegate_->GetHitTestMask(&mask_path); |
1511 // TODO(jamescook): Use the full path for the mask. | 1535 // TODO(jamescook): Use the full path for the mask. |
1512 gfx::Rect mask_rect = | 1536 gfx::Rect mask_rect = |
1513 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1537 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
1514 window_->SetHitTestMask(mask_rect); | 1538 window_->SetHitTestMask(mask_rect); |
1515 } | 1539 } |
1516 | 1540 |
1517 } // namespace views | 1541 } // namespace views |
OLD | NEW |