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

Unified Diff: views/widget/tooltip_manager_views.cc

Issue 8417025: aura: Update how the tooltip manager works. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile fixes Created 9 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
Index: views/widget/tooltip_manager_views.cc
diff --git a/views/widget/tooltip_manager_views.cc b/views/widget/tooltip_manager_views.cc
index a8b6d975d8852898a715d07d465747265714acae..9c16779282fe7d3e7608a6a571296ba03ada4d5e 100644
--- a/views/widget/tooltip_manager_views.cc
+++ b/views/widget/tooltip_manager_views.cc
@@ -82,17 +82,34 @@ TooltipManagerViews::TooltipManagerViews(views::View* root_view)
tooltip_widget_->SetContentsView(&tooltip_label_);
tooltip_widget_->Activate();
tooltip_widget_->SetAlwaysOnTop(true);
- tooltip_timer_.Start(FROM_HERE,
- base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs),
- this, &TooltipManagerViews::TooltipTimerFired);
- MessageLoopForUI::current()->AddObserver(this);
}
TooltipManagerViews::~TooltipManagerViews() {
- MessageLoopForUI::current()->RemoveObserver(this);
tooltip_widget_->CloseNow();
}
+void TooltipManagerViews::UpdateForMouseEvent(const MouseEvent& event) {
+ if (event.type() == ui::ET_MOUSE_EXITED) {
sky 2011/10/28 17:47:27 nit: use a switch statement.
sadrul 2011/10/28 21:42:52 Done.
+ // Mouse is exiting this widget. Stop showing the tooltip and the timer.
+ if (tooltip_timer_.IsRunning())
+ tooltip_timer_.Stop();
+ if (tooltip_widget_->IsVisible())
+ tooltip_widget_->Hide();
+ } else if (event.type() == ui::ET_MOUSE_ENTERED) {
+ // Mouse just entered this widget. Start the timer to show the tooltip.
+ CHECK(!tooltip_timer_.IsRunning());
+ tooltip_timer_.Start(FROM_HERE,
+ base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs),
+ this, &TooltipManagerViews::TooltipTimerFired);
+ } else if (event.type() == ui::ET_MOUSE_MOVED) {
+ OnMouseMoved(event.location().x(), event.location().y());
+ } else {
+ // Hide the tooltip for click, release, wheel events.
+ if (tooltip_widget_->IsVisible())
+ tooltip_widget_->Hide();
+ }
+}
+
void TooltipManagerViews::UpdateTooltip() {
UpdateIfRequired(curr_mouse_pos_.x(), curr_mouse_pos_.y(), false);
}
@@ -110,46 +127,6 @@ void TooltipManagerViews::HideKeyboardTooltip() {
NOTREACHED();
}
-#if defined(USE_WAYLAND)
-base::MessagePumpObserver::EventStatus TooltipManagerViews::WillProcessEvent(
- ui::WaylandEvent* event) {
- if (event->type == ui::WAYLAND_MOTION)
- OnMouseMoved(event->motion.x, event->motion.y);
- return base::MessagePumpObserver::EVENT_CONTINUE;
-}
-#elif defined(USE_X11)
-base::EventStatus TooltipManagerViews::WillProcessEvent(
- const base::NativeEvent& native_event) {
- if (!ui::IsMouseEvent(native_event))
- return base::EVENT_CONTINUE;
-#if defined(USE_AURA)
- aura::MouseEvent event(native_event);
-#else
- MouseEvent event(native_event);
-#endif
- switch (event.type()) {
- case ui::ET_MOUSE_MOVED:
- OnMouseMoved(event.x(), event.y());
- default:
- break;
- }
- return base::EVENT_CONTINUE;
-}
-
-void TooltipManagerViews::DidProcessEvent(const base::NativeEvent& event) {
-}
-#elif defined(OS_WIN)
-base::EventStatus TooltipManagerViews::WillProcessEvent(
- const base::NativeEvent& event) {
- if (event.message == WM_MOUSEMOVE)
- OnMouseMoved(GET_X_LPARAM(event.lParam), GET_Y_LPARAM(event.lParam));
- return base::EVENT_CONTINUE;
-}
-
-void TooltipManagerViews::DidProcessEvent(const base::NativeEvent& event) {
-}
-#endif
-
void TooltipManagerViews::TooltipTimerFired() {
UpdateIfRequired(curr_mouse_pos_.x(), curr_mouse_pos_.y(), false);
}
@@ -159,8 +136,6 @@ View* TooltipManagerViews::GetViewForTooltip(int x, int y, bool for_keyboard) {
if (!for_keyboard) {
// Convert x,y from screen coordinates to |root_view_| coordinates.
gfx::Point point(x, y);
- gfx::Rect r = root_view_->GetWidget()->GetClientAreaScreenBounds();
- point.SetPoint(point.x() - r.x(), point.y() - r.y());
View::ConvertPointFromWidget(root_view_, &point);
view = root_view_->GetEventHandlerForPoint(point);
} else {
« views/widget/tooltip_manager_views.h ('K') | « views/widget/tooltip_manager_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698