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

Unified Diff: ui/aura/window_event_dispatcher.cc

Issue 344793013: Dispatch a synthetic mouse exit to the widget handling mouse events when a widget grabs capture (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/window_event_dispatcher.h ('k') | ui/views/widget/widget_interactive_uitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window_event_dispatcher.cc
diff --git a/ui/aura/window_event_dispatcher.cc b/ui/aura/window_event_dispatcher.cc
index 0f4715066fad90842b2a2f2eea23251e15ad2909..36f75a45e3c2b9eed2e67bd64ea2f8b3b1d7bb5a 100644
--- a/ui/aura/window_event_dispatcher.cc
+++ b/ui/aura/window_event_dispatcher.cc
@@ -150,13 +150,11 @@ void WindowEventDispatcher::DispatchGestureEvent(ui::GestureEvent* event) {
}
}
-void WindowEventDispatcher::DispatchMouseExitAtPoint(const gfx::Point& point) {
+DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint(
+ const gfx::Point& point) {
ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EF_NONE,
ui::EF_NONE);
- DispatchDetails details =
- DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED);
- if (details.dispatcher_destroyed)
- return;
+ return DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED);
}
void WindowEventDispatcher::ProcessedTouchEvent(ui::TouchEvent* event,
@@ -242,8 +240,11 @@ void WindowEventDispatcher::DispatchMouseExitToHidingWindow(Window* window) {
// |window| is the capture window.
gfx::Point last_mouse_location = GetLastMouseLocationInRoot();
if (window->Contains(mouse_moved_handler_) &&
- window->ContainsPointInRoot(last_mouse_location))
- DispatchMouseExitAtPoint(last_mouse_location);
+ window->ContainsPointInRoot(last_mouse_location)) {
+ DispatchDetails details = DispatchMouseExitAtPoint(last_mouse_location);
+ if (details.dispatcher_destroyed)
+ return;
+ }
}
ui::EventDispatchDetails WindowEventDispatcher::DispatchMouseEnterOrExit(
@@ -366,27 +367,47 @@ void WindowEventDispatcher::UpdateCapture(Window* old_capture,
gfx::Point(), 0, 0);
DispatchDetails details = DispatchEvent(old_capture, &event);
- if (details.dispatcher_destroyed)
+ if (details.dispatcher_destroyed || details.target_destroyed)
return;
old_capture->delegate()->OnCaptureLost();
+
+ if (!new_capture) {
+ // Make sure |mouse_moved_handler_| gets updated.
+ DispatchDetails details = SynthesizeMouseMoveEvent();
+ if (details.dispatcher_destroyed)
+ return;
+ }
+ } else if (mouse_moved_handler_ &&
+ mouse_moved_handler_ != new_capture) {
sadrul 2014/06/24 18:33:09 Should you check for a non-null |new_capture| here
+ // Dispatch a mouse exit to reset any state associated with hover. This is
+ // important when going from no window having capture to a window having
+ // capture because we do not dispatch ET_MOUSE_CAPTURE_CHANGED in this case.
+ DispatchDetails details = DispatchMouseExitAtPoint(
+ GetLastMouseLocationInRoot());
+ if (details.dispatcher_destroyed)
+ return;
}
if (new_capture) {
- // Make all subsequent mouse events go to the capture window. We shouldn't
- // need to send an event here as OnCaptureLost() should take care of that.
+ // Make all subsequent mouse events go to the capture window.
if (mouse_moved_handler_ || Env::GetInstance()->IsMouseButtonDown())
mouse_moved_handler_ = new_capture;
- } else {
- // Make sure mouse_moved_handler gets updated.
- DispatchDetails details = SynthesizeMouseMoveEvent();
- if (details.dispatcher_destroyed)
- return;
}
mouse_pressed_handler_ = NULL;
}
void WindowEventDispatcher::OnOtherRootGotCapture() {
+ if (mouse_moved_handler_) {
+ // Dispatch a mouse exit to reset any state associated with hover. This is
+ // important when going from no window having capture to a window having
+ // capture because we do not dispatch ET_MOUSE_CAPTURE_CHANGED in this case.
+ DispatchDetails details = DispatchMouseExitAtPoint(
+ GetLastMouseLocationInRoot());
+ if (details.dispatcher_destroyed)
+ return;
+ }
+
mouse_moved_handler_ = NULL;
mouse_pressed_handler_ = NULL;
}
« no previous file with comments | « ui/aura/window_event_dispatcher.h ('k') | ui/views/widget/widget_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698