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

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

Issue 2876203003: Make shelf item can be dragged when context menu is opened.
Patch Set: TransferEvents only if it is needed. 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
« ui/views/controls/menu/menu_host.h ('K') | « ui/views/controls/menu/menu_host.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d3d7b2dc680c3c7d49c25c7eeaecd86871d15646 100644
--- a/ui/views/controls/menu/menu_host.cc
+++ b/ui/views/controls/menu/menu_host.cc
@@ -127,10 +127,20 @@ void MenuHost::InitMenuHost(Widget* parent,
menu_controller, submenu_, GetNativeView()));
#endif
+ if (parent && !views::MenuController::DoCancel()) {
xiyuan 2017/05/15 19:20:52 nit: Use |menu_controller| instance after making D
minch1 2017/05/16 22:13:39 Done.
+ owner_ = parent;
+ TransferEvents(owner_, this);
+ }
SetContentsView(contents_view);
ShowMenuHost(do_capture);
}
+void MenuHost::TransferEvents(Widget* source, Widget* target) {
+ ui::GestureRecognizer::Get()->TransferEventsTo(
+ source->GetNativeView(), target->GetNativeView(),
+ ui::GestureRecognizer::ShouldCancelTouches::DontCancel);
+}
+
bool MenuHost::IsMenuHostVisible() {
return IsVisible();
}
@@ -143,12 +153,18 @@ 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.
- ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(nullptr);
+ if (views::MenuController::DoCancel())
+ ui::GestureRecognizer::Get()->CancelActiveTouchesExcept(nullptr);
native_widget_private()->SetCapture();
}
}
void MenuHost::HideMenuHost() {
+ if (owner_ && !views::MenuController::DoCancel()) {
+ TransferEvents(this, owner_);
+ owner_ = NULL;
+ views::MenuController::SetDoCancel(true);
xiyuan 2017/05/15 19:20:52 Is this call necessary?
minch1 2017/05/15 22:16:34 Yes. I think this is necessary. 1. Press the shel
xiyuan 2017/05/15 22:41:10 That would be another reason to make |do_cancel_|
+ }
ignore_capture_lost_ = true;
ReleaseMenuHostCapture();
Hide();
« ui/views/controls/menu/menu_host.h ('K') | « ui/views/controls/menu/menu_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698