| 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 // This has to be before any other includes, else default is picked up. | 5 // This has to be before any other includes, else default is picked up. |
| 6 // See base/logging for details on this. | 6 // See base/logging for details on this. |
| 7 #define NOTIMPLEMENTED_POLICY 5 | 7 #define NOTIMPLEMENTED_POLICY 5 |
| 8 | 8 |
| 9 #include "ui/views/mus/native_widget_mus.h" | 9 #include "ui/views/mus/native_widget_mus.h" |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "ui/aura/window.h" | 32 #include "ui/aura/window.h" |
| 33 #include "ui/aura/window_property.h" | 33 #include "ui/aura/window_property.h" |
| 34 #include "ui/base/hit_test.h" | 34 #include "ui/base/hit_test.h" |
| 35 #include "ui/display/display.h" | 35 #include "ui/display/display.h" |
| 36 #include "ui/display/screen.h" | 36 #include "ui/display/screen.h" |
| 37 #include "ui/events/event.h" | 37 #include "ui/events/event.h" |
| 38 #include "ui/gfx/canvas.h" | 38 #include "ui/gfx/canvas.h" |
| 39 #include "ui/gfx/path.h" | 39 #include "ui/gfx/path.h" |
| 40 #include "ui/native_theme/native_theme_aura.h" | 40 #include "ui/native_theme/native_theme_aura.h" |
| 41 #include "ui/platform_window/platform_window_delegate.h" | 41 #include "ui/platform_window/platform_window_delegate.h" |
| 42 #include "ui/views/corewm/tooltip.h" |
| 43 #include "ui/views/corewm/tooltip_aura.h" |
| 44 #include "ui/views/corewm/tooltip_controller.h" |
| 42 #include "ui/views/drag_utils.h" | 45 #include "ui/views/drag_utils.h" |
| 43 #include "ui/views/mus/drag_drop_client_mus.h" | 46 #include "ui/views/mus/drag_drop_client_mus.h" |
| 44 #include "ui/views/mus/drop_target_mus.h" | 47 #include "ui/views/mus/drop_target_mus.h" |
| 45 #include "ui/views/mus/window_manager_connection.h" | 48 #include "ui/views/mus/window_manager_connection.h" |
| 46 #include "ui/views/mus/window_manager_constants_converters.h" | 49 #include "ui/views/mus/window_manager_constants_converters.h" |
| 47 #include "ui/views/mus/window_manager_frame_values.h" | 50 #include "ui/views/mus/window_manager_frame_values.h" |
| 48 #include "ui/views/mus/window_tree_host_mus.h" | 51 #include "ui/views/mus/window_tree_host_mus.h" |
| 49 #include "ui/views/widget/drop_helper.h" | 52 #include "ui/views/widget/drop_helper.h" |
| 50 #include "ui/views/widget/native_widget_aura.h" | 53 #include "ui/views/widget/native_widget_aura.h" |
| 54 #include "ui/views/widget/tooltip_manager_aura.h" |
| 51 #include "ui/views/widget/widget_delegate.h" | 55 #include "ui/views/widget/widget_delegate.h" |
| 52 #include "ui/views/window/custom_frame_view.h" | 56 #include "ui/views/window/custom_frame_view.h" |
| 53 #include "ui/wm/core/base_focus_rules.h" | 57 #include "ui/wm/core/base_focus_rules.h" |
| 54 #include "ui/wm/core/capture_controller.h" | 58 #include "ui/wm/core/capture_controller.h" |
| 55 #include "ui/wm/core/cursor_manager.h" | 59 #include "ui/wm/core/cursor_manager.h" |
| 56 #include "ui/wm/core/default_screen_position_client.h" | 60 #include "ui/wm/core/default_screen_position_client.h" |
| 57 #include "ui/wm/core/focus_controller.h" | 61 #include "ui/wm/core/focus_controller.h" |
| 58 #include "ui/wm/core/native_cursor_manager.h" | 62 #include "ui/wm/core/native_cursor_manager.h" |
| 59 | 63 |
| 60 DECLARE_WINDOW_PROPERTY_TYPE(ui::Window*); | 64 DECLARE_WINDOW_PROPERTY_TYPE(ui::Window*); |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 return native_widget->GetWidget(); | 590 return native_widget->GetWidget(); |
| 587 } | 591 } |
| 588 | 592 |
| 589 aura::Window* NativeWidgetMus::GetRootWindow() { | 593 aura::Window* NativeWidgetMus::GetRootWindow() { |
| 590 return window_tree_host_->window(); | 594 return window_tree_host_->window(); |
| 591 } | 595 } |
| 592 | 596 |
| 593 void NativeWidgetMus::OnPlatformWindowClosed() { | 597 void NativeWidgetMus::OnPlatformWindowClosed() { |
| 594 native_widget_delegate_->OnNativeWidgetDestroying(); | 598 native_widget_delegate_->OnNativeWidgetDestroying(); |
| 595 | 599 |
| 600 tooltip_manager_.reset(); |
| 601 if (tooltip_controller_.get()) { |
| 602 window_tree_host_->window()->RemovePreTargetHandler( |
| 603 tooltip_controller_.get()); |
| 604 aura::client::SetTooltipClient(window_tree_host_->window(), NULL); |
| 605 tooltip_controller_.reset(); |
| 606 } |
| 607 |
| 596 window_tree_client_.reset(); // Uses |content_|. | 608 window_tree_client_.reset(); // Uses |content_|. |
| 597 capture_client_.reset(); // Uses |content_|. | 609 capture_client_.reset(); // Uses |content_|. |
| 598 | 610 |
| 599 window_tree_host_->RemoveObserver(this); | 611 window_tree_host_->RemoveObserver(this); |
| 600 window_tree_host_.reset(); | 612 window_tree_host_.reset(); |
| 601 | 613 |
| 602 cursor_manager_.reset(); // Uses |window_|. | 614 cursor_manager_.reset(); // Uses |window_|. |
| 603 | 615 |
| 604 mus_window_observer_.reset(nullptr); | 616 mus_window_observer_.reset(nullptr); |
| 605 | 617 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 aura::client::SetScreenPositionClient(hosted_window, | 728 aura::client::SetScreenPositionClient(hosted_window, |
| 717 screen_position_client_.get()); | 729 screen_position_client_.get()); |
| 718 | 730 |
| 719 drag_drop_client_ = base::MakeUnique<DragDropClientMus>(window_); | 731 drag_drop_client_ = base::MakeUnique<DragDropClientMus>(window_); |
| 720 aura::client::SetDragDropClient(hosted_window, drag_drop_client_.get()); | 732 aura::client::SetDragDropClient(hosted_window, drag_drop_client_.get()); |
| 721 drop_target_ = base::MakeUnique<DropTargetMus>(content_); | 733 drop_target_ = base::MakeUnique<DropTargetMus>(content_); |
| 722 window_->SetCanAcceptDrops(drop_target_.get()); | 734 window_->SetCanAcceptDrops(drop_target_.get()); |
| 723 drop_helper_ = base::MakeUnique<DropHelper>(GetWidget()->GetRootView()); | 735 drop_helper_ = base::MakeUnique<DropHelper>(GetWidget()->GetRootView()); |
| 724 aura::client::SetDragDropDelegate(content_, this); | 736 aura::client::SetDragDropDelegate(content_, this); |
| 725 | 737 |
| 738 if (params.type != Widget::InitParams::TYPE_TOOLTIP) { |
| 739 tooltip_manager_ = base::MakeUnique<TooltipManagerAura>(GetWidget()); |
| 740 tooltip_controller_ = base::MakeUnique<corewm::TooltipController>( |
| 741 base::MakeUnique<corewm::TooltipAura>()); |
| 742 aura::client::SetTooltipClient(window_tree_host_->window(), |
| 743 tooltip_controller_.get()); |
| 744 window_tree_host_->window()->AddPreTargetHandler(tooltip_controller_.get()); |
| 745 } |
| 746 |
| 726 // TODO(erg): Remove this check when ash/mus/move_event_handler.cc's | 747 // TODO(erg): Remove this check when ash/mus/move_event_handler.cc's |
| 727 // direct usage of ui::Window::SetPredefinedCursor() is switched to a | 748 // direct usage of ui::Window::SetPredefinedCursor() is switched to a |
| 728 // private method on WindowManagerClient. | 749 // private method on WindowManagerClient. |
| 729 if (!is_parallel_widget_in_window_manager()) { | 750 if (!is_parallel_widget_in_window_manager()) { |
| 730 cursor_manager_ = base::MakeUnique<wm::CursorManager>( | 751 cursor_manager_ = base::MakeUnique<wm::CursorManager>( |
| 731 base::MakeUnique<NativeCursorManagerMus>(window_)); | 752 base::MakeUnique<NativeCursorManagerMus>(window_)); |
| 732 aura::client::SetCursorClient(hosted_window, cursor_manager_.get()); | 753 aura::client::SetCursorClient(hosted_window, cursor_manager_.get()); |
| 733 } | 754 } |
| 734 | 755 |
| 735 window_tree_client_ = | 756 window_tree_client_ = |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 } | 860 } |
| 840 | 861 |
| 841 void* NativeWidgetMus::GetNativeWindowProperty(const char* name) const { | 862 void* NativeWidgetMus::GetNativeWindowProperty(const char* name) const { |
| 842 auto it = native_window_properties_.find(name); | 863 auto it = native_window_properties_.find(name); |
| 843 if (it == native_window_properties_.end()) | 864 if (it == native_window_properties_.end()) |
| 844 return nullptr; | 865 return nullptr; |
| 845 return it->second; | 866 return it->second; |
| 846 } | 867 } |
| 847 | 868 |
| 848 TooltipManager* NativeWidgetMus::GetTooltipManager() const { | 869 TooltipManager* NativeWidgetMus::GetTooltipManager() const { |
| 849 // NOTIMPLEMENTED(); | 870 return tooltip_manager_.get(); |
| 850 return nullptr; | |
| 851 } | 871 } |
| 852 | 872 |
| 853 void NativeWidgetMus::SetCapture() { | 873 void NativeWidgetMus::SetCapture() { |
| 854 if (content_) | 874 if (content_) |
| 855 content_->SetCapture(); | 875 content_->SetCapture(); |
| 856 } | 876 } |
| 857 | 877 |
| 858 void NativeWidgetMus::ReleaseCapture() { | 878 void NativeWidgetMus::ReleaseCapture() { |
| 859 if (content_) | 879 if (content_) |
| 860 content_->ReleaseCapture(); | 880 content_->ReleaseCapture(); |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 } | 1426 } |
| 1407 // Renderer may send a key event back to us if the key event wasn't handled, | 1427 // Renderer may send a key event back to us if the key event wasn't handled, |
| 1408 // and the window may be invisible by that time. | 1428 // and the window may be invisible by that time. |
| 1409 if (!content_->IsVisible()) | 1429 if (!content_->IsVisible()) |
| 1410 return; | 1430 return; |
| 1411 | 1431 |
| 1412 native_widget_delegate_->OnKeyEvent(event); | 1432 native_widget_delegate_->OnKeyEvent(event); |
| 1413 } | 1433 } |
| 1414 | 1434 |
| 1415 void NativeWidgetMus::OnMouseEvent(ui::MouseEvent* event) { | 1435 void NativeWidgetMus::OnMouseEvent(ui::MouseEvent* event) { |
| 1416 // TODO(sky): forward to tooltipmanager. See NativeWidgetDesktopAura. | |
| 1417 DCHECK(content_->IsVisible()); | 1436 DCHECK(content_->IsVisible()); |
| 1437 |
| 1438 if (tooltip_manager_.get()) |
| 1439 tooltip_manager_->UpdateTooltip(); |
| 1440 TooltipManagerAura::UpdateTooltipManagerForCapture(GetWidget()); |
| 1441 |
| 1418 native_widget_delegate_->OnMouseEvent(event); | 1442 native_widget_delegate_->OnMouseEvent(event); |
| 1419 // WARNING: we may have been deleted. | 1443 // WARNING: we may have been deleted. |
| 1420 } | 1444 } |
| 1421 | 1445 |
| 1422 void NativeWidgetMus::OnScrollEvent(ui::ScrollEvent* event) { | 1446 void NativeWidgetMus::OnScrollEvent(ui::ScrollEvent* event) { |
| 1423 if (event->type() == ui::ET_SCROLL) { | 1447 if (event->type() == ui::ET_SCROLL) { |
| 1424 native_widget_delegate_->OnScrollEvent(event); | 1448 native_widget_delegate_->OnScrollEvent(event); |
| 1425 if (event->handled()) | 1449 if (event->handled()) |
| 1426 return; | 1450 return; |
| 1427 | 1451 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 | 1560 |
| 1537 gfx::Path mask_path; | 1561 gfx::Path mask_path; |
| 1538 native_widget_delegate_->GetHitTestMask(&mask_path); | 1562 native_widget_delegate_->GetHitTestMask(&mask_path); |
| 1539 // TODO(jamescook): Use the full path for the mask. | 1563 // TODO(jamescook): Use the full path for the mask. |
| 1540 gfx::Rect mask_rect = | 1564 gfx::Rect mask_rect = |
| 1541 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1565 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
| 1542 window_->SetHitTestMask(mask_rect); | 1566 window_->SetHitTestMask(mask_rect); |
| 1543 } | 1567 } |
| 1544 | 1568 |
| 1545 } // namespace views | 1569 } // namespace views |
| OLD | NEW |