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

Unified Diff: ui/views/controls/menu/menu_runner.cc

Issue 2450903002: MacViews: Clear mouse handler when showing context menus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test. Created 4 years, 2 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
Index: ui/views/controls/menu/menu_runner.cc
diff --git a/ui/views/controls/menu/menu_runner.cc b/ui/views/controls/menu/menu_runner.cc
index bd07a839aefec3cd9f3e1492de5ff5ff2ebb904d..ac6fe60c76a383074178100f9d8fef5be0334ab8 100644
--- a/ui/views/controls/menu/menu_runner.cc
+++ b/ui/views/controls/menu/menu_runner.cc
@@ -8,6 +8,7 @@
#include "ui/views/controls/menu/menu_runner_handler.h"
#include "ui/views/controls/menu/menu_runner_impl.h"
+#include "ui/views/widget/widget.h"
namespace views {
@@ -27,6 +28,12 @@ MenuRunner::RunResult MenuRunner::RunMenuAt(Widget* parent,
const gfx::Rect& bounds,
MenuAnchorPosition anchor,
ui::MenuSourceType source_type) {
+ // If we are shown on mouse press, we will eat the subsequent mouse down and
+ // the parent widget will not be able to reset its state (it might have mouse
+ // capture from the mouse down). So we clear its state here.
+ if (parent && parent->GetRootView())
+ parent->GetRootView()->SetMouseHandler(nullptr);
+
if (runner_handler_.get()) {
return runner_handler_->RunMenuAt(
parent, button, bounds, anchor, source_type, run_types_);

Powered by Google App Engine
This is Rietveld 408576698