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

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

Issue 2392063003: mus: Use TooltipManagerAura in NativeWidgetMus. (Closed)
Patch Set: add braces 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
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 // 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
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
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
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 } 842 }
822 843
823 void NativeWidgetMus::ReorderNativeViews() { 844 void NativeWidgetMus::ReorderNativeViews() {
824 NOTIMPLEMENTED(); 845 NOTIMPLEMENTED();
825 } 846 }
826 847
827 void NativeWidgetMus::ViewRemoved(View* view) { 848 void NativeWidgetMus::ViewRemoved(View* view) {
828 NOTIMPLEMENTED(); 849 NOTIMPLEMENTED();
829 } 850 }
830 851
831 // These methods are wrong in mojo. They're not usually used to associate 852 // These methods are wrong in mojo. They're not usually used to associate data
832 // data with a window; they are used exclusively in chrome/ to unsafely pass 853 // with a window; they are used to pass data from one layer to another (and in
833 // raw pointers around. I can only find two places where we do the "safe" 854 // chrome/ to unsafely pass raw pointers around--I can only find two places
834 // thing (and even that requires casting an integer to a void*). They can't be 855 // where we do the "safe" thing and even that requires casting an integer to a
835 // used safely in a world where we separate things with mojo. They should be 856 // void*). They can't be used safely in a world where we separate things with
836 // removed; not ported. 857 // mojo.
858 //
859 // It's also used to communicate between views and aura; in views, we set
860 // properties on a widget, and read these properties directly in aura code.
837 void NativeWidgetMus::SetNativeWindowProperty(const char* name, void* value) { 861 void NativeWidgetMus::SetNativeWindowProperty(const char* name, void* value) {
838 native_window_properties_[name] = value; 862 if (content_)
863 content_->SetNativeWindowProperty(name, value);
839 } 864 }
840 865
841 void* NativeWidgetMus::GetNativeWindowProperty(const char* name) const { 866 void* NativeWidgetMus::GetNativeWindowProperty(const char* name) const {
842 auto it = native_window_properties_.find(name); 867 return content_ ? content_->GetNativeWindowProperty(name) : nullptr;
843 if (it == native_window_properties_.end())
844 return nullptr;
845 return it->second;
846 } 868 }
847 869
848 TooltipManager* NativeWidgetMus::GetTooltipManager() const { 870 TooltipManager* NativeWidgetMus::GetTooltipManager() const {
849 // NOTIMPLEMENTED(); 871 return tooltip_manager_.get();
850 return nullptr;
851 } 872 }
852 873
853 void NativeWidgetMus::SetCapture() { 874 void NativeWidgetMus::SetCapture() {
854 if (content_) 875 if (content_)
855 content_->SetCapture(); 876 content_->SetCapture();
856 } 877 }
857 878
858 void NativeWidgetMus::ReleaseCapture() { 879 void NativeWidgetMus::ReleaseCapture() {
859 if (content_) 880 if (content_)
860 content_->ReleaseCapture(); 881 content_->ReleaseCapture();
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 } 1427 }
1407 // Renderer may send a key event back to us if the key event wasn't handled, 1428 // 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. 1429 // and the window may be invisible by that time.
1409 if (!content_->IsVisible()) 1430 if (!content_->IsVisible())
1410 return; 1431 return;
1411 1432
1412 native_widget_delegate_->OnKeyEvent(event); 1433 native_widget_delegate_->OnKeyEvent(event);
1413 } 1434 }
1414 1435
1415 void NativeWidgetMus::OnMouseEvent(ui::MouseEvent* event) { 1436 void NativeWidgetMus::OnMouseEvent(ui::MouseEvent* event) {
1416 // TODO(sky): forward to tooltipmanager. See NativeWidgetDesktopAura.
1417 DCHECK(content_->IsVisible()); 1437 DCHECK(content_->IsVisible());
1438
1439 if (tooltip_manager_.get())
1440 tooltip_manager_->UpdateTooltip();
1441 TooltipManagerAura::UpdateTooltipManagerForCapture(GetWidget());
1442
1418 native_widget_delegate_->OnMouseEvent(event); 1443 native_widget_delegate_->OnMouseEvent(event);
1419 // WARNING: we may have been deleted. 1444 // WARNING: we may have been deleted.
1420 } 1445 }
1421 1446
1422 void NativeWidgetMus::OnScrollEvent(ui::ScrollEvent* event) { 1447 void NativeWidgetMus::OnScrollEvent(ui::ScrollEvent* event) {
1423 if (event->type() == ui::ET_SCROLL) { 1448 if (event->type() == ui::ET_SCROLL) {
1424 native_widget_delegate_->OnScrollEvent(event); 1449 native_widget_delegate_->OnScrollEvent(event);
1425 if (event->handled()) 1450 if (event->handled())
1426 return; 1451 return;
1427 1452
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 1561
1537 gfx::Path mask_path; 1562 gfx::Path mask_path;
1538 native_widget_delegate_->GetHitTestMask(&mask_path); 1563 native_widget_delegate_->GetHitTestMask(&mask_path);
1539 // TODO(jamescook): Use the full path for the mask. 1564 // TODO(jamescook): Use the full path for the mask.
1540 gfx::Rect mask_rect = 1565 gfx::Rect mask_rect =
1541 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); 1566 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds()));
1542 window_->SetHitTestMask(mask_rect); 1567 window_->SetHitTestMask(mask_rect);
1543 } 1568 }
1544 1569
1545 } // namespace views 1570 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698