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

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

Issue 1953753002: Turn RootWindowController Menus Async (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/widget/native_widget_private.h ('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 17675e73c44d8c90681eabff93600f6de4b5d1d4..a86fe4859ee53de5089e52fe04149fb172c35837 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -1171,19 +1171,23 @@ void Widget::OnMouseEvent(ui::MouseEvent* event) {
// use an observer to make sure we are still alive.
WidgetDeletionObserver widget_deletion_observer(this);
+ gfx::NativeView current_capture =
+ internal::NativeWidgetPrivate::GetGlobalCapture(
+ native_widget_->GetNativeView());
// Make sure we're still visible before we attempt capture as the mouse
// press processing may have made the window hide (as happens with menus).
-
- // It is possible for a View to show a context menu on mouse-press. Since
- // the menu does a capture and starts a nested message-loop, the release
- // would go to the menu. The next click (i.e. both mouse-press and release
- // events) also go to the menu. The menu (and the nested message-loop)
- // gets closed after this second release event. The code then resumes from
- // here. So make sure that the mouse-button is still down before doing a
- // capture.
+ //
+ // It is possible that capture has changed as a result of a mouse-press.
+ // In these cases do not update internal state.
+ //
+ // A mouse-press may trigger a nested message-loop, and absorb the paired
+ // release. If so the code returns here. So make sure that that
+ // mouse-button is still down before attempting to do a capture.
if (root_view && root_view->OnMousePressed(*event) &&
widget_deletion_observer.IsWidgetAlive() && IsVisible() &&
- internal::NativeWidgetPrivate::IsMouseButtonDown()) {
+ internal::NativeWidgetPrivate::IsMouseButtonDown() &&
+ current_capture == internal::NativeWidgetPrivate::GetGlobalCapture(
+ native_widget_->GetNativeView())) {
is_mouse_button_pressed_ = true;
if (!native_widget_->HasCapture())
native_widget_->SetCapture();
« no previous file with comments | « ui/views/widget/native_widget_private.h ('k') | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698