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

Unified Diff: ui/views/corewm/tooltip_controller.cc

Issue 274753002: Ignores mouse motion events when mouse is pressed or drag and drop is in progress (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/corewm/tooltip_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/corewm/tooltip_controller.cc
diff --git a/ui/views/corewm/tooltip_controller.cc b/ui/views/corewm/tooltip_controller.cc
index 500466fdf4d646c69ccba8f31c98ef85a8f9496c..9cb56c2cf76f4e732dcb2bb91722c8b6c20db02d 100644
--- a/ui/views/corewm/tooltip_controller.cc
+++ b/ui/views/corewm/tooltip_controller.cc
@@ -28,6 +28,10 @@ namespace {
const int kTooltipTimeoutMs = 500;
const int kDefaultTooltipShownTimeoutMs = 10000;
+// Delay mouse events so that they are dispatched if there are no mouse location
+// events pending. Even a short delay delays them until the mouse is steady.
+const int kMouseMoveDelay = 10;
+
// Returns true if |target| is a valid window to get the tooltip from.
// |event_target| is the original target from the event and |target| the window
// at the same location.
@@ -46,9 +50,10 @@ bool IsValidTarget(aura::Window* event_target, aura::Window* target) {
// Returns the target (the Window tooltip text comes from) based on the event.
// If a Window other than event.target() is returned, |location| is adjusted
// to be in the coordinates of the returned Window.
-aura::Window* GetTooltipTarget(const ui::MouseEvent& event,
+aura::Window* GetTooltipTarget(ui::EventType event_type,
+ aura::Window* target,
gfx::Point* location) {
- switch (event.type()) {
+ switch (event_type) {
case ui::ET_MOUSE_CAPTURE_CHANGED:
// On windows we can get a capture changed without an exit. We need to
// reset state when this happens else the tooltip may incorrectly show.
@@ -57,7 +62,7 @@ aura::Window* GetTooltipTarget(const ui::MouseEvent& event,
return NULL;
case ui::ET_MOUSE_MOVED:
case ui::ET_MOUSE_DRAGGED: {
- aura::Window* event_target = static_cast<aura::Window*>(event.target());
+ aura::Window* event_target = target;
if (!event_target)
return NULL;
@@ -83,7 +88,7 @@ aura::Window* GetTooltipTarget(const ui::MouseEvent& event,
// If |target| has capture all events go to it, even if the mouse is
// really over another window. Find the real window the mouse is over.
- gfx::Point screen_loc(event.location());
+ gfx::Point screen_loc(*location);
aura::client::GetScreenPositionClient(event_target->GetRootWindow())->
ConvertPointToScreen(event_target, &screen_loc);
gfx::Screen* screen = gfx::Screen::GetScreenFor(event_target);
@@ -185,14 +190,14 @@ void TooltipController::OnMouseEvent(ui::MouseEvent* event) {
case ui::ET_MOUSE_EXITED:
case ui::ET_MOUSE_MOVED:
case ui::ET_MOUSE_DRAGGED: {
- curr_mouse_loc_ = event->location();
- aura::Window* target = GetTooltipTarget(*event, &curr_mouse_loc_);
- SetTooltipWindow(target);
- if (tooltip_timer_.IsRunning())
- tooltip_timer_.Reset();
-
- if (tooltip_->IsVisible())
- UpdateIfRequired();
+ last_mouse_location_ = event->location();
+ mouse_event_timer_.Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(kMouseMoveDelay),
+ base::Bind(&TooltipController::DispatchMouseEvent,
sky 2014/05/08 19:05:55 What happens if we enter some sort of nested messa
varkha 2014/05/13 19:30:55 We would need to synchronously process any pending
+ base::Unretained(this),
+ event->type(),
+ static_cast<aura::Window*>(event->target())));
sky 2014/05/08 19:05:55 What if window is destroyed between now and when t
varkha 2014/05/13 19:30:55 We could maintain a set of windows for which we ha
break;
}
case ui::ET_MOUSE_PRESSED:
@@ -239,6 +244,18 @@ void TooltipController::OnWindowDestroyed(aura::Window* window) {
////////////////////////////////////////////////////////////////////////////////
// TooltipController private:
+void TooltipController::DispatchMouseEvent(ui::EventType event_type,
+ aura::Window* target) {
+ curr_mouse_loc_ = last_mouse_location_;
+ target = GetTooltipTarget(event_type, target, &curr_mouse_loc_);
+ SetTooltipWindow(target);
+ if (tooltip_timer_.IsRunning())
+ tooltip_timer_.Reset();
+
+ if (tooltip_->IsVisible())
+ UpdateIfRequired();
+}
+
void TooltipController::TooltipTimerFired() {
UpdateIfRequired();
}
« no previous file with comments | « ui/views/corewm/tooltip_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698