| 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();
|
|
|