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

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

Issue 2392063003: mus: Use TooltipManagerAura in NativeWidgetMus. (Closed)
Patch Set: Add comment 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/screen_mus.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 // 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
11 #include <map>
11 #include <utility> 12 #include <utility>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/callback.h" 15 #include "base/callback.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
17 #include "base/run_loop.h" 18 #include "base/run_loop.h"
18 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
19 #include "services/ui/public/cpp/property_type_converters.h" 20 #include "services/ui/public/cpp/property_type_converters.h"
20 #include "services/ui/public/cpp/window.h" 21 #include "services/ui/public/cpp/window.h"
(...skipping 11 matching lines...) Expand all
32 #include "ui/aura/window.h" 33 #include "ui/aura/window.h"
33 #include "ui/aura/window_property.h" 34 #include "ui/aura/window_property.h"
34 #include "ui/base/hit_test.h" 35 #include "ui/base/hit_test.h"
35 #include "ui/display/display.h" 36 #include "ui/display/display.h"
36 #include "ui/display/screen.h" 37 #include "ui/display/screen.h"
37 #include "ui/events/event.h" 38 #include "ui/events/event.h"
38 #include "ui/gfx/canvas.h" 39 #include "ui/gfx/canvas.h"
39 #include "ui/gfx/path.h" 40 #include "ui/gfx/path.h"
40 #include "ui/native_theme/native_theme_aura.h" 41 #include "ui/native_theme/native_theme_aura.h"
41 #include "ui/platform_window/platform_window_delegate.h" 42 #include "ui/platform_window/platform_window_delegate.h"
43 #include "ui/views/corewm/tooltip.h"
44 #include "ui/views/corewm/tooltip_aura.h"
45 #include "ui/views/corewm/tooltip_controller.h"
42 #include "ui/views/drag_utils.h" 46 #include "ui/views/drag_utils.h"
43 #include "ui/views/mus/drag_drop_client_mus.h" 47 #include "ui/views/mus/drag_drop_client_mus.h"
44 #include "ui/views/mus/drop_target_mus.h" 48 #include "ui/views/mus/drop_target_mus.h"
45 #include "ui/views/mus/window_manager_connection.h" 49 #include "ui/views/mus/window_manager_connection.h"
46 #include "ui/views/mus/window_manager_constants_converters.h" 50 #include "ui/views/mus/window_manager_constants_converters.h"
47 #include "ui/views/mus/window_manager_frame_values.h" 51 #include "ui/views/mus/window_manager_frame_values.h"
48 #include "ui/views/mus/window_tree_host_mus.h" 52 #include "ui/views/mus/window_tree_host_mus.h"
49 #include "ui/views/widget/drop_helper.h" 53 #include "ui/views/widget/drop_helper.h"
50 #include "ui/views/widget/native_widget_aura.h" 54 #include "ui/views/widget/native_widget_aura.h"
55 #include "ui/views/widget/tooltip_manager_aura.h"
51 #include "ui/views/widget/widget_delegate.h" 56 #include "ui/views/widget/widget_delegate.h"
52 #include "ui/views/window/custom_frame_view.h" 57 #include "ui/views/window/custom_frame_view.h"
53 #include "ui/wm/core/base_focus_rules.h" 58 #include "ui/wm/core/base_focus_rules.h"
54 #include "ui/wm/core/capture_controller.h" 59 #include "ui/wm/core/capture_controller.h"
55 #include "ui/wm/core/cursor_manager.h" 60 #include "ui/wm/core/cursor_manager.h"
56 #include "ui/wm/core/default_screen_position_client.h" 61 #include "ui/wm/core/default_screen_position_client.h"
57 #include "ui/wm/core/focus_controller.h" 62 #include "ui/wm/core/focus_controller.h"
58 #include "ui/wm/core/native_cursor_manager.h" 63 #include "ui/wm/core/native_cursor_manager.h"
59 64
60 DECLARE_WINDOW_PROPERTY_TYPE(ui::Window*); 65 DECLARE_WINDOW_PROPERTY_TYPE(ui::Window*);
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 return native_widget->GetWidget(); 591 return native_widget->GetWidget();
587 } 592 }
588 593
589 aura::Window* NativeWidgetMus::GetRootWindow() { 594 aura::Window* NativeWidgetMus::GetRootWindow() {
590 return window_tree_host_->window(); 595 return window_tree_host_->window();
591 } 596 }
592 597
593 void NativeWidgetMus::OnPlatformWindowClosed() { 598 void NativeWidgetMus::OnPlatformWindowClosed() {
594 native_widget_delegate_->OnNativeWidgetDestroying(); 599 native_widget_delegate_->OnNativeWidgetDestroying();
595 600
601 tooltip_manager_.reset();
602 if (tooltip_controller_.get()) {
603 window_tree_host_->window()->RemovePreTargetHandler(
604 tooltip_controller_.get());
605 aura::client::SetTooltipClient(window_tree_host_->window(), NULL);
606 tooltip_controller_.reset();
607 }
608
596 window_tree_client_.reset(); // Uses |content_|. 609 window_tree_client_.reset(); // Uses |content_|.
597 capture_client_.reset(); // Uses |content_|. 610 capture_client_.reset(); // Uses |content_|.
598 611
599 window_tree_host_->RemoveObserver(this); 612 window_tree_host_->RemoveObserver(this);
600 window_tree_host_.reset(); 613 window_tree_host_.reset();
601 614
602 cursor_manager_.reset(); // Uses |window_|. 615 cursor_manager_.reset(); // Uses |window_|.
603 616
604 mus_window_observer_.reset(nullptr); 617 mus_window_observer_.reset(nullptr);
605 618
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 aura::client::SetScreenPositionClient(hosted_window, 729 aura::client::SetScreenPositionClient(hosted_window,
717 screen_position_client_.get()); 730 screen_position_client_.get());
718 731
719 drag_drop_client_ = base::MakeUnique<DragDropClientMus>(window_); 732 drag_drop_client_ = base::MakeUnique<DragDropClientMus>(window_);
720 aura::client::SetDragDropClient(hosted_window, drag_drop_client_.get()); 733 aura::client::SetDragDropClient(hosted_window, drag_drop_client_.get());
721 drop_target_ = base::MakeUnique<DropTargetMus>(content_); 734 drop_target_ = base::MakeUnique<DropTargetMus>(content_);
722 window_->SetCanAcceptDrops(drop_target_.get()); 735 window_->SetCanAcceptDrops(drop_target_.get());
723 drop_helper_ = base::MakeUnique<DropHelper>(GetWidget()->GetRootView()); 736 drop_helper_ = base::MakeUnique<DropHelper>(GetWidget()->GetRootView());
724 aura::client::SetDragDropDelegate(content_, this); 737 aura::client::SetDragDropDelegate(content_, this);
725 738
739 if (params.type != Widget::InitParams::TYPE_TOOLTIP) {
740 tooltip_manager_ = base::MakeUnique<TooltipManagerAura>(GetWidget());
741 tooltip_controller_ = base::MakeUnique<corewm::TooltipController>(
742 base::MakeUnique<corewm::TooltipAura>());
743 aura::client::SetTooltipClient(window_tree_host_->window(),
744 tooltip_controller_.get());
745 window_tree_host_->window()->AddPreTargetHandler(tooltip_controller_.get());
746 }
747
726 // TODO(erg): Remove this check when ash/mus/move_event_handler.cc's 748 // TODO(erg): Remove this check when ash/mus/move_event_handler.cc's
727 // direct usage of ui::Window::SetPredefinedCursor() is switched to a 749 // direct usage of ui::Window::SetPredefinedCursor() is switched to a
728 // private method on WindowManagerClient. 750 // private method on WindowManagerClient.
729 if (!is_parallel_widget_in_window_manager()) { 751 if (!is_parallel_widget_in_window_manager()) {
730 cursor_manager_ = base::MakeUnique<wm::CursorManager>( 752 cursor_manager_ = base::MakeUnique<wm::CursorManager>(
731 base::MakeUnique<NativeCursorManagerMus>(window_)); 753 base::MakeUnique<NativeCursorManagerMus>(window_));
732 aura::client::SetCursorClient(hosted_window, cursor_manager_.get()); 754 aura::client::SetCursorClient(hosted_window, cursor_manager_.get());
733 } 755 }
734 756
735 window_tree_client_ = 757 window_tree_client_ =
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 } 843 }
822 844
823 void NativeWidgetMus::ReorderNativeViews() { 845 void NativeWidgetMus::ReorderNativeViews() {
824 NOTIMPLEMENTED(); 846 NOTIMPLEMENTED();
825 } 847 }
826 848
827 void NativeWidgetMus::ViewRemoved(View* view) { 849 void NativeWidgetMus::ViewRemoved(View* view) {
828 NOTIMPLEMENTED(); 850 NOTIMPLEMENTED();
829 } 851 }
830 852
831 // These methods are wrong in mojo. They're not usually used to associate 853 // 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 854 // 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" 855 // 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 856 // 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 857 // void*). They can't be used safely in a world where we separate things with
836 // removed; not ported. 858 // mojo.
859 //
860 // It's also used to communicate between views and aura; in views, we set
861 // properties on a widget, and read these properties directly in aura code.
837 void NativeWidgetMus::SetNativeWindowProperty(const char* name, void* value) { 862 void NativeWidgetMus::SetNativeWindowProperty(const char* name, void* value) {
838 native_window_properties_[name] = value; 863 if (content_)
864 content_->SetNativeWindowProperty(name, value);
839 } 865 }
840 866
841 void* NativeWidgetMus::GetNativeWindowProperty(const char* name) const { 867 void* NativeWidgetMus::GetNativeWindowProperty(const char* name) const {
842 auto it = native_window_properties_.find(name); 868 return content_ ? content_->GetNativeWindowProperty(name) : nullptr;
843 if (it == native_window_properties_.end())
844 return nullptr;
845 return it->second;
846 } 869 }
847 870
848 TooltipManager* NativeWidgetMus::GetTooltipManager() const { 871 TooltipManager* NativeWidgetMus::GetTooltipManager() const {
849 // NOTIMPLEMENTED(); 872 return tooltip_manager_.get();
850 return nullptr;
851 } 873 }
852 874
853 void NativeWidgetMus::SetCapture() { 875 void NativeWidgetMus::SetCapture() {
854 if (content_) 876 if (content_)
855 content_->SetCapture(); 877 content_->SetCapture();
856 } 878 }
857 879
858 void NativeWidgetMus::ReleaseCapture() { 880 void NativeWidgetMus::ReleaseCapture() {
859 if (content_) 881 if (content_)
860 content_->ReleaseCapture(); 882 content_->ReleaseCapture();
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 } 1428 }
1407 // Renderer may send a key event back to us if the key event wasn't handled, 1429 // 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. 1430 // and the window may be invisible by that time.
1409 if (!content_->IsVisible()) 1431 if (!content_->IsVisible())
1410 return; 1432 return;
1411 1433
1412 native_widget_delegate_->OnKeyEvent(event); 1434 native_widget_delegate_->OnKeyEvent(event);
1413 } 1435 }
1414 1436
1415 void NativeWidgetMus::OnMouseEvent(ui::MouseEvent* event) { 1437 void NativeWidgetMus::OnMouseEvent(ui::MouseEvent* event) {
1416 // TODO(sky): forward to tooltipmanager. See NativeWidgetDesktopAura.
1417 DCHECK(content_->IsVisible()); 1438 DCHECK(content_->IsVisible());
1439
1440 if (tooltip_manager_.get())
1441 tooltip_manager_->UpdateTooltip();
1442 TooltipManagerAura::UpdateTooltipManagerForCapture(GetWidget());
1443
1418 native_widget_delegate_->OnMouseEvent(event); 1444 native_widget_delegate_->OnMouseEvent(event);
1419 // WARNING: we may have been deleted. 1445 // WARNING: we may have been deleted.
1420 } 1446 }
1421 1447
1422 void NativeWidgetMus::OnScrollEvent(ui::ScrollEvent* event) { 1448 void NativeWidgetMus::OnScrollEvent(ui::ScrollEvent* event) {
1423 if (event->type() == ui::ET_SCROLL) { 1449 if (event->type() == ui::ET_SCROLL) {
1424 native_widget_delegate_->OnScrollEvent(event); 1450 native_widget_delegate_->OnScrollEvent(event);
1425 if (event->handled()) 1451 if (event->handled())
1426 return; 1452 return;
1427 1453
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 1562
1537 gfx::Path mask_path; 1563 gfx::Path mask_path;
1538 native_widget_delegate_->GetHitTestMask(&mask_path); 1564 native_widget_delegate_->GetHitTestMask(&mask_path);
1539 // TODO(jamescook): Use the full path for the mask. 1565 // TODO(jamescook): Use the full path for the mask.
1540 gfx::Rect mask_rect = 1566 gfx::Rect mask_rect =
1541 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); 1567 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds()));
1542 window_->SetHitTestMask(mask_rect); 1568 window_->SetHitTestMask(mask_rect);
1543 } 1569 }
1544 1570
1545 } // namespace views 1571 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/native_widget_mus.h ('k') | ui/views/mus/screen_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698