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

Unified Diff: ui/aura/root_window.cc

Issue 7983039: Add support for MouseEnter/MouseExit event types to be sent to aura::Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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/aura/root_window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/root_window.cc
===================================================================
--- ui/aura/root_window.cc (revision 102135)
+++ ui/aura/root_window.cc (working copy)
@@ -17,6 +17,7 @@
RootWindow::RootWindow()
: Window(NULL),
mouse_pressed_handler_(NULL),
+ mouse_moved_handler_(NULL),
ALLOW_THIS_IN_INITIALIZER_LIST(focus_manager_(new FocusManager(this))),
capture_window_(NULL) {
set_name(ASCIIToUTF16("RootWindow"));
@@ -30,10 +31,20 @@
mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_;
if (!target)
target = GetEventHandlerForPoint(event.location());
- if (event.type() == ui::ET_MOUSE_PRESSED && !mouse_pressed_handler_)
- mouse_pressed_handler_ = target;
- if (event.type() == ui::ET_MOUSE_RELEASED)
- mouse_pressed_handler_ = NULL;
+ switch (event.type()) {
+ case ui::ET_MOUSE_MOVED:
+ HandleMouseMoved(event, target);
+ break;
+ case ui::ET_MOUSE_PRESSED:
+ if (!mouse_pressed_handler_)
+ mouse_pressed_handler_ = target;
+ break;
+ case ui::ET_MOUSE_RELEASED:
+ mouse_pressed_handler_ = NULL;
+ break;
+ default:
+ break;
+ }
if (target && target->delegate()) {
MouseEvent translated_event(event, this, target);
return target->OnMouseEvent(&translated_event);
@@ -85,6 +96,8 @@
// don't sent it release/capture lost events.
if (mouse_pressed_handler_ == window)
mouse_pressed_handler_ = NULL;
+ if (mouse_moved_handler_ == window)
+ mouse_moved_handler_ = NULL;
if (capture_window_ == window)
capture_window_ = NULL;
}
@@ -97,5 +110,24 @@
return this;
}
+void RootWindow::HandleMouseMoved(const MouseEvent& event, Window* target) {
+ if (target == mouse_moved_handler_)
+ return;
+
+ // Send an exited event.
+ if (mouse_moved_handler_ && mouse_moved_handler_->delegate()) {
+ MouseEvent translated_event(event, this, mouse_moved_handler_,
+ ui::ET_MOUSE_EXITED);
+ mouse_moved_handler_->OnMouseEvent(&translated_event);
+ }
+ mouse_moved_handler_ = target;
+ // Send an entered event.
+ if (mouse_moved_handler_ && mouse_moved_handler_->delegate()) {
+ MouseEvent translated_event(event, this, mouse_moved_handler_,
+ ui::ET_MOUSE_ENTERED);
+ mouse_moved_handler_->OnMouseEvent(&translated_event);
+ }
+}
+
} // namespace internal
} // namespace aura
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698