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

Unified Diff: ui/views/widget/widget.cc

Issue 1297373004: Don't synthesize mousemove events if the mouse cursor is not on the widget (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Query the mouse location instead of caching Created 5 years, 4 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/message_center/views/notification_view_unittest.cc ('k') | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/widget.cc
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 280969a84e5e7d0067d1f10378dec9d6d15061fb..154d107a63b298fbb7f6d0eb764d924ecc1a734b 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -21,6 +21,7 @@
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/screen.h"
#include "ui/views/controls/menu/menu_controller.h"
+#include "ui/views/event_monitor.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/focus/focus_manager_factory.h"
#include "ui/views/focus/view_storage.h"
@@ -988,9 +989,16 @@ gfx::Rect Widget::GetWorkAreaBoundsInScreen() const {
}
void Widget::SynthesizeMouseMoveEvent() {
+ // In screen coordinate.
+ gfx::Point mouse_location = EventMonitor::GetLastMouseLocation();
+ if (!GetWindowBoundsInScreen().Contains(mouse_location))
+ return;
+
+ // Convert: screen coordinate -> widget coordinate.
+ View::ConvertPointFromScreen(root_view_.get(), &mouse_location);
last_mouse_event_was_move_ = false;
- ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, last_mouse_event_position_,
- last_mouse_event_position_, ui::EventTimeForNow(),
+ ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, mouse_location,
+ mouse_location, ui::EventTimeForNow(),
ui::EF_IS_SYNTHESIZED, 0);
root_view_->OnMouseMoved(mouse_event);
}
« no previous file with comments | « ui/message_center/views/notification_view_unittest.cc ('k') | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698