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

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

Issue 2876203003: Make shelf item can be dragged when context menu is opened.
Patch Set: Fixed comments. Created 3 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
Index: ui/views/controls/menu/menu_host.cc
diff --git a/ui/views/controls/menu/menu_host.cc b/ui/views/controls/menu/menu_host.cc
index c6750a6e0cd51be18d9470a45969bed6b27c0e4c..48d262ba837cf69788fceee7943837c5e7f6985a 100644
--- a/ui/views/controls/menu/menu_host.cc
+++ b/ui/views/controls/menu/menu_host.cc
@@ -12,7 +12,6 @@
#include "ui/events/gestures/gesture_recognizer.h"
#include "ui/gfx/path.h"
#include "ui/native_theme/native_theme.h"
-#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/controls/menu/menu_host_root_view.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/menu_scroll_view_container.h"
@@ -82,6 +81,18 @@ class PreMenuEventDispatchHandler : public ui::EventHandler,
} // namespace internal
+namespace {
+
+#if defined(OS_CHROMEOS)
+void TransferGesture(Widget* source, Widget* target) {
+ ui::GestureRecognizer::Get()->TransferEventsTo(
+ source->GetNativeView(), target->GetNativeView(),
+ ui::GestureRecognizer::ShouldCancelTouches::DontCancel);
+}
+#endif
+
+} // namespace
xiyuan 2017/05/16 22:46:57 nit: We probably can put TransferGesture in the in
minch1 2017/05/17 16:55:38 Done.
+
////////////////////////////////////////////////////////////////////////////////
// MenuHost, public:
@@ -127,6 +138,13 @@ void MenuHost::InitMenuHost(Widget* parent,
menu_controller, submenu_, GetNativeView()));
#endif
+#if defined(OS_CHROMEOS)
xiyuan 2017/05/16 22:46:57 I wonder whether we should consider !defined(OS_MA
+ if (parent && controller && controller->owner_needs_gesture_events()) {
xiyuan 2017/05/16 22:46:57 Briefly document why we need to TransferGesture.
minch1 2017/05/17 16:55:37 Done.
+ owner_ = parent;
+ TransferGesture(owner_, this);
xiyuan 2017/05/16 22:46:57 Can we move this to ShowMenuHost so that it is sym
minch1 2017/05/17 16:55:37 Done.
+ }
+#endif
+
SetContentsView(contents_view);
ShowMenuHost(do_capture);
}
@@ -143,12 +161,24 @@ void MenuHost::ShowMenuHost(bool do_capture) {
if (do_capture) {
// Cancel existing touches, so we don't miss some touch release/cancel
// events due to the menu taking capture.
+#if defined(OS_CHROMEOS)
+ if (controller && !controller->owner_needs_gesture_events())
+ ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(nullptr);
+#else
ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(nullptr);
+#endif
native_widget_private()->SetCapture();
}
}
void MenuHost::HideMenuHost() {
+#if defined(OS_CHROMEOS)
+ if (owner_ && controller && controller->owner_needs_gesture_events()) {
+ TransferGesture(this, owner_);
+ owner_ = nullptr;
+ controller->set_owner_needs_gesture_events(false);
xiyuan 2017/05/16 22:46:57 Do we still need this after making the flag a memb
minch1 2017/05/17 16:55:38 Oh, yeap, we don't need to do this.
+ }
+#endif
ignore_capture_lost_ = true;
ReleaseMenuHostCapture();
Hide();

Powered by Google App Engine
This is Rietveld 408576698