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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/native_widget_mus.cc
diff --git a/ui/views/mus/native_widget_mus.cc b/ui/views/mus/native_widget_mus.cc
index d0b9349b68eba292f6413805bbad5b5d63d54b90..d38e0203d4c2df0a2394d04fd0393edb7bfde30f 100644
--- a/ui/views/mus/native_widget_mus.cc
+++ b/ui/views/mus/native_widget_mus.cc
@@ -8,6 +8,7 @@
#include "ui/views/mus/native_widget_mus.h"
+#include <map>
#include <utility>
#include <vector>
@@ -39,6 +40,9 @@
#include "ui/gfx/path.h"
#include "ui/native_theme/native_theme_aura.h"
#include "ui/platform_window/platform_window_delegate.h"
+#include "ui/views/corewm/tooltip.h"
+#include "ui/views/corewm/tooltip_aura.h"
+#include "ui/views/corewm/tooltip_controller.h"
#include "ui/views/drag_utils.h"
#include "ui/views/mus/drag_drop_client_mus.h"
#include "ui/views/mus/drop_target_mus.h"
@@ -48,6 +52,7 @@
#include "ui/views/mus/window_tree_host_mus.h"
#include "ui/views/widget/drop_helper.h"
#include "ui/views/widget/native_widget_aura.h"
+#include "ui/views/widget/tooltip_manager_aura.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/window/custom_frame_view.h"
#include "ui/wm/core/base_focus_rules.h"
@@ -593,6 +598,14 @@ aura::Window* NativeWidgetMus::GetRootWindow() {
void NativeWidgetMus::OnPlatformWindowClosed() {
native_widget_delegate_->OnNativeWidgetDestroying();
+ tooltip_manager_.reset();
+ if (tooltip_controller_.get()) {
+ window_tree_host_->window()->RemovePreTargetHandler(
+ tooltip_controller_.get());
+ aura::client::SetTooltipClient(window_tree_host_->window(), NULL);
+ tooltip_controller_.reset();
+ }
+
window_tree_client_.reset(); // Uses |content_|.
capture_client_.reset(); // Uses |content_|.
@@ -723,6 +736,15 @@ void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) {
drop_helper_ = base::MakeUnique<DropHelper>(GetWidget()->GetRootView());
aura::client::SetDragDropDelegate(content_, this);
+ if (params.type != Widget::InitParams::TYPE_TOOLTIP) {
+ tooltip_manager_ = base::MakeUnique<TooltipManagerAura>(GetWidget());
+ tooltip_controller_ = base::MakeUnique<corewm::TooltipController>(
+ base::MakeUnique<corewm::TooltipAura>());
+ aura::client::SetTooltipClient(window_tree_host_->window(),
+ tooltip_controller_.get());
+ window_tree_host_->window()->AddPreTargetHandler(tooltip_controller_.get());
+ }
+
// TODO(erg): Remove this check when ash/mus/move_event_handler.cc's
// direct usage of ui::Window::SetPredefinedCursor() is switched to a
// private method on WindowManagerClient.
@@ -828,26 +850,26 @@ void NativeWidgetMus::ViewRemoved(View* view) {
NOTIMPLEMENTED();
}
-// These methods are wrong in mojo. They're not usually used to associate
-// data with a window; they are used exclusively in chrome/ to unsafely pass
-// raw pointers around. I can only find two places where we do the "safe"
-// thing (and even that requires casting an integer to a void*). They can't be
-// used safely in a world where we separate things with mojo. They should be
-// removed; not ported.
+// These methods are wrong in mojo. They're not usually used to associate data
+// with a window; they are used to pass data from one layer to another (and in
+// chrome/ to unsafely pass raw pointers around--I can only find two places
+// where we do the "safe" thing and even that requires casting an integer to a
+// void*). They can't be used safely in a world where we separate things with
+// mojo.
+//
+// It's also used to communicate between views and aura; in views, we set
+// properties on a widget, and read these properties directly in aura code.
void NativeWidgetMus::SetNativeWindowProperty(const char* name, void* value) {
- native_window_properties_[name] = value;
+ if (content_)
+ content_->SetNativeWindowProperty(name, value);
}
void* NativeWidgetMus::GetNativeWindowProperty(const char* name) const {
- auto it = native_window_properties_.find(name);
- if (it == native_window_properties_.end())
- return nullptr;
- return it->second;
+ return content_ ? content_->GetNativeWindowProperty(name) : nullptr;
}
TooltipManager* NativeWidgetMus::GetTooltipManager() const {
- // NOTIMPLEMENTED();
- return nullptr;
+ return tooltip_manager_.get();
}
void NativeWidgetMus::SetCapture() {
@@ -1413,8 +1435,12 @@ void NativeWidgetMus::OnKeyEvent(ui::KeyEvent* event) {
}
void NativeWidgetMus::OnMouseEvent(ui::MouseEvent* event) {
- // TODO(sky): forward to tooltipmanager. See NativeWidgetDesktopAura.
DCHECK(content_->IsVisible());
+
+ if (tooltip_manager_.get())
+ tooltip_manager_->UpdateTooltip();
+ TooltipManagerAura::UpdateTooltipManagerForCapture(GetWidget());
+
native_widget_delegate_->OnMouseEvent(event);
// WARNING: we may have been deleted.
}
« 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