|
|
Chromium Code Reviews
DescriptionMake shelf item can be dragged when context menu is opened.
Current context menu of shelf,
1) Allow dragging before context menu is created.
2) No dragging after context menu is opened.
In order to keep the same as Android OS,
1) Allow dragging during the same press (don't release the finger)
after context menu is opened.
2) Close the context menu once start dragging.
Changes in this cl,
1. Add |SEND_UNHANDLED_GESTURES_TO_OWNER| in MenuRunner. This means the
owner hopes that menu can help send the unhandled gesture events to the
owner instead of dropping them. e.g, the context menu of the shelf
items, and this is only true if shelf is not autohide.
2. Transfer events from owner to menu host if the owner needs gesture
events. vice verse. e.g. Shelf items hope can be dragged after long
press which will create the context menu.
3. Handle the LONG_TAP events on shelf items. Since gesture events
been transferred from shelf to MenuHost, but we don't want it will show
the context menu again.
BUG=710601, 748253
Patch Set 1 #
Total comments: 7
Patch Set 2 : Transfer events only when the widget set capture. #Patch Set 3 : TransferEvents only if it is needed. #
Total comments: 20
Patch Set 4 : Fixed comments. #
Total comments: 23
Patch Set 5 : Fixed comments. #Patch Set 6 : Remove useless code. #Patch Set 7 : Remove useless include. #Patch Set 8 : Fixed comments. #
Total comments: 30
Patch Set 9 : Fixed comments. #Patch Set 10 : Stop listening events if sees GESTURE_END. #Patch Set 11 : Rebased and renamed. #
Total comments: 6
Patch Set 12 : Addressed xiyuan's comments. #Patch Set 13 : rebased #
Total comments: 18
Patch Set 14 : Add ut. #Patch Set 15 : Fixed comments and rebased. #Patch Set 16 : Fixed tests. #
Total comments: 10
Patch Set 17 : Fixed msw's comments. #
Total comments: 2
Patch Set 18 : Fixed nit. #
Total comments: 10
Patch Set 19 : Fixed comments. #Patch Set 20 : Add set_run_types() in ShelfView. #Patch Set 21 : Removed the logic for app list button. #Patch Set 22 : Remove run_types_ flag. #Patch Set 23 : Add widget observer for |owner_| in MenuHost. #Messages
Total messages: 157 (113 generated)
Description was changed from ========== Make shelf item can be dragged when context menu is opened. BUG=710601 ========== to ========== Make shelf item can be dragged when context menu is opened. This cl doesn't totally work currently. Long press the shelf item util the context menu is opened. 1. Try to drag the shelf item. The context menu will be closed, and can drop or put the item back to the shelf. 2. Or just release the press. Try to touch the items in the context menu. Seems all the items in the main menu works, but the shelf position submenu doesn't work (canot change the alignment of the shelf.) Touch anywhere else will make the context menu goes away. Drag and drop of the shelf items works well until one long press with none dragging (step 2 above). Seems that will make all the events cannot be captured. Nothing happend with following touch events. BUG=710601 ==========
minch@chromium.org changed reviewers: + xiyuan@chromium.org
Description was changed from ========== Make shelf item can be dragged when context menu is opened. This cl doesn't totally work currently. Long press the shelf item util the context menu is opened. 1. Try to drag the shelf item. The context menu will be closed, and can drop or put the item back to the shelf. 2. Or just release the press. Try to touch the items in the context menu. Seems all the items in the main menu works, but the shelf position submenu doesn't work (canot change the alignment of the shelf.) Touch anywhere else will make the context menu goes away. Drag and drop of the shelf items works well until one long press with none dragging (step 2 above). Seems that will make all the events cannot be captured. Nothing happend with following touch events. BUG=710601 ========== to ========== Make shelf item can be dragged when context menu is opened. This cl doesn't totally work currently. Long press the shelf item util the context menu is opened. 1. Try to drag the shelf item. The context menu will be closed, and can drop or put the item back to the shelf. 2. Or just release the press. Try to touch the items in the context menu. Seems all the items in the main menu works, but the shelf position submenu doesn't work (canot change the alignment of the shelf.) Touch anywhere else will make the context menu goes away. Drag and drop of the shelf items works well until one long press with none dragging (step 2 above). Seems that will make all the events cannot be captured. Nothing happend with following touch events. The same problem with all the other context menus. For example, the context menu opened when touch the wallpaper. It can be opened only once. Then the following touch events cannot be captured too. BUG=710601 ==========
https://codereview.chromium.org/2876203003/diff/1/ui/views/controls/menu/menu... File ui/views/controls/menu/menu_controller.cc (right): https://codereview.chromium.org/2876203003/diff/1/ui/views/controls/menu/menu... ui/views/controls/menu/menu_controller.cc:828: } nit: revist to something like if (part.submenu) { part.submenu->OnGestureEvent(event); return; } // Forwarding to owner if necessary. We might want to use // |cancel_active_touches_| as a flag as whether to do the // forwarding. https://codereview.chromium.org/2876203003/diff/1/ui/views/controls/menu/menu... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/1/ui/views/controls/menu/menu... ui/views/controls/menu/menu_host.cc:102: bool cancel_active_touches) { How about get this from MenuController instead of passing as an arg? https://codereview.chromium.org/2876203003/diff/1/ui/views/controls/menu/menu... ui/views/controls/menu/menu_host.cc:133: TransferEvents(owner_, this); We probably should only do this for the out-most menu. That is, sub menu such as shelf position should not do this. Also, |parent| could be nullptr and we need to handle that case. https://codereview.chromium.org/2876203003/diff/1/ui/views/controls/menu/menu... ui/views/controls/menu/menu_host.cc:154: if (cancel_active_touches) { This should probably be in the if (do_capture) down below. https://codereview.chromium.org/2876203003/diff/1/ui/views/controls/menu/menu... ui/views/controls/menu/menu_host.cc:166: TransferEvents(this, owner_); Similarly, we need to figure out how to do this only for the out-most menu. https://codereview.chromium.org/2876203003/diff/1/ui/views/controls/menu/menu... File ui/views/controls/menu/menu_runner_impl.cc (right): https://codereview.chromium.org/2876203003/diff/1/ui/views/controls/menu/menu... ui/views/controls/menu/menu_runner_impl.cc:125: if (run_types & MenuRunner::FIXED_ANCHOR) { We probably should make ShelfView to call set_cancel_active_touches instead of relying on |run_types|. https://codereview.chromium.org/2876203003/diff/1/ui/views/controls/menu/subm... File ui/views/controls/menu/submenu_view.cc (right): https://codereview.chromium.org/2876203003/diff/1/ui/views/controls/menu/subm... ui/views/controls/menu/submenu_view.cc:371: bool cancel_active_touches) { ditto, get |cancel_active_touches| from MenuController ?
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== Make shelf item can be dragged when context menu is opened. This cl doesn't totally work currently. Long press the shelf item util the context menu is opened. 1. Try to drag the shelf item. The context menu will be closed, and can drop or put the item back to the shelf. 2. Or just release the press. Try to touch the items in the context menu. Seems all the items in the main menu works, but the shelf position submenu doesn't work (canot change the alignment of the shelf.) Touch anywhere else will make the context menu goes away. Drag and drop of the shelf items works well until one long press with none dragging (step 2 above). Seems that will make all the events cannot be captured. Nothing happend with following touch events. The same problem with all the other context menus. For example, the context menu opened when touch the wallpaper. It can be opened only once. Then the following touch events cannot be captured too. BUG=710601 ========== to ========== Make shelf item can be dragged when context menu is opened. BUG=710601 ==========
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...) mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
Hi, xiyuan@, can you help review?
We probably can put added code in #if defined(OS_CHROMEOS) since they are chromeos specific and probably does not work elsewhere. https://codereview.chromium.org/2876203003/diff/40001/ash/shelf/shelf_view.cc File ash/shelf/shelf_view.cc (right): https://codereview.chromium.org/2876203003/diff/40001/ash/shelf/shelf_view.cc... ash/shelf/shelf_view.cc:1663: if (index == 0 || !item) { Why we need to include |index| == 0? Can you document it? https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... File ui/views/controls/menu/menu_controller.h (right): https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_controller.h:675: // cancel existing touch events. Can we make the document from the perspective of menu? Mentioning dragging shelf item etc does not make much sense in the context of menu. I would prefer something like // Whether the menu |owner_| needs gesture events. When set to true // MenuController forwards unhandled gesture events to |owner_|. bool owner_needs_gesture_events_ = false; Note the proposed |owner_needs_gesture_events_| is opposite of |do_cancel_|. https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_controller.h:676: static bool do_cancel_; Why this needs to be static? We already have a static getter for MenuController. Can we make it a regular member and use the getter to access it? https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:130: if (parent && !views::MenuController::DoCancel()) { nit: Use |menu_controller| instance after making DoCancel non-static. https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:166: views::MenuController::SetDoCancel(true); Is this call necessary? https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... File ui/views/controls/menu/menu_host.h (right): https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.h:70: void TransferEvents(Widget* source, Widget* target); This does not depend on any MenuHost state and not called externally. So let's put it in an anonymous namespace in cc file. Also maybe call it TransferGesture to be more accurate. https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.h:86: Widget* owner_ = NULL; NULL -> nullptr https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.h:86: Widget* owner_ = NULL; Document the member and insert an empty line after it.
xiyuan@, can you help check the comments? Thanks. https://codereview.chromium.org/2876203003/diff/40001/ash/shelf/shelf_view.cc File ash/shelf/shelf_view.cc (right): https://codereview.chromium.org/2876203003/diff/40001/ash/shelf/shelf_view.cc... ash/shelf/shelf_view.cc:1663: if (index == 0 || !item) { On 2017/05/15 19:20:52, xiyuan wrote: > Why we need to include |index| == 0? Can you document it? This is for the launcher icon (the first item in the shelf). The gesture events of this item will not go through ShelfButton's OnGestureEvent. This will produce a flash behavior if long press of the item. I think it is fine to make the context menu of this item the same as if touching empty space on the shelf. Since the contents of the context menu in these two situations are the same. https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... File ui/views/controls/menu/menu_controller.h (right): https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_controller.h:676: static bool do_cancel_; On 2017/05/15 19:20:52, xiyuan wrote: > Why this needs to be static? We already have a static getter for MenuController. > Can we make it a regular member and use the getter to access it? But in shelf_view.cc where where we want to set this variable. We have no MenuController instance yet. |active_instance_| returned by GetActiveInstance() in MenuController is initialized in the Constructor. https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:166: views::MenuController::SetDoCancel(true); On 2017/05/15 19:20:52, xiyuan wrote: > Is this call necessary? Yes. I think this is necessary. 1. Press the shelf items. This will set do_calcel_ to false. 2. Touch anywhere else except the shelf. If we don't set do_cancel_ back to true here. Then, for the LONG_PRESS events (open context menu) on the screen will do TransferEvents which is not what we want.
https://codereview.chromium.org/2876203003/diff/40001/ash/shelf/shelf_view.cc File ash/shelf/shelf_view.cc (right): https://codereview.chromium.org/2876203003/diff/40001/ash/shelf/shelf_view.cc... ash/shelf/shelf_view.cc:1663: if (index == 0 || !item) { On 2017/05/15 22:16:34, minch1 wrote: > On 2017/05/15 19:20:52, xiyuan wrote: > > Why we need to include |index| == 0? Can you document it? > > This is for the launcher icon (the first item in the shelf). The gesture events > of this item will not go through ShelfButton's OnGestureEvent. This will produce > a flash behavior if long press of the item. > I think it is fine to make the context menu of this item the same as if touching > empty space on the shelf. Since the contents of the context menu in these two > situations are the same. It is more accurate to check |item| type than the model index since model index might change in the future e.g. when UX allows launcher button to float. i.e. item.type == TYPE_APP_LIST https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... File ui/views/controls/menu/menu_controller.h (right): https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_controller.h:676: static bool do_cancel_; On 2017/05/15 22:16:34, minch1 wrote: > On 2017/05/15 19:20:52, xiyuan wrote: > > Why this needs to be static? We already have a static getter for > MenuController. > > Can we make it a regular member and use the getter to access it? > > But in shelf_view.cc where where we want to set this variable. We have no > MenuController instance yet. |active_instance_| returned by GetActiveInstance() > in MenuController is initialized in the Constructor. How about adding a new MenuRunner::RunTypes mask and MenuRunnerImpl sets this flag when it sees the new RunTypes bit is set ? https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:166: views::MenuController::SetDoCancel(true); On 2017/05/15 22:16:34, minch1 wrote: > On 2017/05/15 19:20:52, xiyuan wrote: > > Is this call necessary? > > Yes. I think this is necessary. > 1. Press the shelf items. This will set do_calcel_ to false. > 2. Touch anywhere else except the shelf. > If we don't set do_cancel_ back to true here. Then, for the LONG_PRESS events > (open context menu) on the screen will do TransferEvents which is not what we > want. That would be another reason to make |do_cancel_| non-static.
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...) win_chromium_x64_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
The CQ bit was checked by minch@chromium.org to run a CQ dry run
xiyuan@, could you help review? Thanks. https://codereview.chromium.org/2876203003/diff/40001/ash/shelf/shelf_view.cc File ash/shelf/shelf_view.cc (right): https://codereview.chromium.org/2876203003/diff/40001/ash/shelf/shelf_view.cc... ash/shelf/shelf_view.cc:1663: if (index == 0 || !item) { On 2017/05/15 22:41:10, xiyuan wrote: > On 2017/05/15 22:16:34, minch1 wrote: > > On 2017/05/15 19:20:52, xiyuan wrote: > > > Why we need to include |index| == 0? Can you document it? > > > > This is for the launcher icon (the first item in the shelf). The gesture > events > > of this item will not go through ShelfButton's OnGestureEvent. This will > produce > > a flash behavior if long press of the item. > > I think it is fine to make the context menu of this item the same as if > touching > > empty space on the shelf. Since the contents of the context menu in these two > > situations are the same. > > It is more accurate to check |item| type than the model index since model index > might change in the future e.g. when UX allows launcher button to float. > i.e. item.type == TYPE_APP_LIST Done. https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... File ui/views/controls/menu/menu_controller.h (right): https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_controller.h:675: // cancel existing touch events. On 2017/05/15 19:20:52, xiyuan wrote: > Can we make the document from the perspective of menu? Mentioning dragging shelf > item etc does not make much sense in the context of menu. I would prefer > something like > > // Whether the menu |owner_| needs gesture events. When set to true > // MenuController forwards unhandled gesture events to |owner_|. > bool owner_needs_gesture_events_ = false; > > Note the proposed |owner_needs_gesture_events_| is opposite of |do_cancel_|. Done. https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_controller.h:676: static bool do_cancel_; On 2017/05/15 22:41:10, xiyuan wrote: > On 2017/05/15 22:16:34, minch1 wrote: > > On 2017/05/15 19:20:52, xiyuan wrote: > > > Why this needs to be static? We already have a static getter for > > MenuController. > > > Can we make it a regular member and use the getter to access it? > > > > But in shelf_view.cc where where we want to set this variable. We have no > > MenuController instance yet. |active_instance_| returned by > GetActiveInstance() > > in MenuController is initialized in the Constructor. > > How about adding a new MenuRunner::RunTypes mask and MenuRunnerImpl sets this > flag when it sees the new RunTypes bit is set ? Done. https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:130: if (parent && !views::MenuController::DoCancel()) { On 2017/05/15 19:20:52, xiyuan wrote: > nit: Use |menu_controller| instance after making DoCancel non-static. Done. https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... File ui/views/controls/menu/menu_host.h (right): https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.h:70: void TransferEvents(Widget* source, Widget* target); On 2017/05/15 19:20:52, xiyuan wrote: > This does not depend on any MenuHost state and not called externally. So let's > put it in an anonymous namespace in cc file. Also maybe call it TransferGesture > to be more accurate. Done. https://codereview.chromium.org/2876203003/diff/40001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.h:86: Widget* owner_ = NULL; On 2017/05/15 19:20:52, xiyuan wrote: > NULL -> nullptr Done.
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2876203003/diff/60001/ash/shelf/shelf_button.cc File ash/shelf/shelf_button.cc (right): https://codereview.chromium.org/2876203003/diff/60001/ash/shelf/shelf_button.... ash/shelf/shelf_button.cc:29: #if defined(OS_CHROMEOS) Ash code is chromeos only now. So this is not needed. https://codereview.chromium.org/2876203003/diff/60001/ash/shelf/shelf_view.cc File ash/shelf/shelf_view.cc (right): https://codereview.chromium.org/2876203003/diff/60001/ash/shelf/shelf_view.cc... ash/shelf/shelf_view.cc:645: #if defined(OS_CHROMEOS) not needed https://codereview.chromium.org/2876203003/diff/60001/ash/shelf/shelf_view.cc... ash/shelf/shelf_view.cc:1695: #if defined(OS_CHROMEOS) not needed https://codereview.chromium.org/2876203003/diff/60001/ash/shelf/shelf_view.cc... ash/shelf/shelf_view.cc:1753: #if !defined(OS_CHROMEOS) remove the whole block if we don't need it on chromeos. https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:94: } // namespace nit: We probably can put TransferGesture in the internal namespace above. https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:141: #if defined(OS_CHROMEOS) I wonder whether we should consider !defined(OS_MACOSX) instead of defined(OS_CHROMEOS). The code probably can work on win/linux since those are aura based too. https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:142: if (parent && controller && controller->owner_needs_gesture_events()) { Briefly document why we need to TransferGesture. // TransferGesture when owner needs gesture events so that the // incoming touch events after MenuHost is created are properly // translated into gesture events instead of being dropped. https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:144: TransferGesture(owner_, this); Can we move this to ShowMenuHost so that it is symmetric with the TransferGesture in HideMenuHost? https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:179: controller->set_owner_needs_gesture_events(false); Do we still need this after making the flag a member of controller? https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... File ui/views/controls/menu/menu_host.h (right): https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.h:84: MenuController* controller = MenuController::GetActiveInstance(); This is not needed and should not be done here. We can get MenuController via submenu_->GetMenuItem()->GetMenuController() as in MenuHost::InitMenuHost [1] [1]: https://cs.chromium.org/chromium/src/ui/views/controls/menu/menu_host.cc?rcl=... https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.h:86: // The owner of child windows. This not exactly correct. It is "parent of the MenuHost widget". https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_runner.h:96: IS_DRAGGABLE = 1 << 7, IS_DRAGGABLE is confusing. On first read, I thought it means the menu item is draggable. How about call it OWNER_NEEDS_DRAG or something similar ?
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2876203003/diff/60001/ash/shelf/shelf_button.cc File ash/shelf/shelf_button.cc (right): https://codereview.chromium.org/2876203003/diff/60001/ash/shelf/shelf_button.... ash/shelf/shelf_button.cc:29: #if defined(OS_CHROMEOS) On 2017/05/16 22:46:56, xiyuan wrote: > Ash code is chromeos only now. So this is not needed. Done. https://codereview.chromium.org/2876203003/diff/60001/ash/shelf/shelf_view.cc File ash/shelf/shelf_view.cc (right): https://codereview.chromium.org/2876203003/diff/60001/ash/shelf/shelf_view.cc... ash/shelf/shelf_view.cc:645: #if defined(OS_CHROMEOS) On 2017/05/16 22:46:57, xiyuan wrote: > not needed Done. https://codereview.chromium.org/2876203003/diff/60001/ash/shelf/shelf_view.cc... ash/shelf/shelf_view.cc:1695: #if defined(OS_CHROMEOS) On 2017/05/16 22:46:56, xiyuan wrote: > not needed Done. https://codereview.chromium.org/2876203003/diff/60001/ash/shelf/shelf_view.cc... ash/shelf/shelf_view.cc:1753: #if !defined(OS_CHROMEOS) On 2017/05/16 22:46:57, xiyuan wrote: > remove the whole block if we don't need it on chromeos. Done. https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:94: } // namespace On 2017/05/16 22:46:57, xiyuan wrote: > nit: We probably can put TransferGesture in the internal namespace above. Done. https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:142: if (parent && controller && controller->owner_needs_gesture_events()) { On 2017/05/16 22:46:57, xiyuan wrote: > Briefly document why we need to TransferGesture. > > // TransferGesture when owner needs gesture events so that the > // incoming touch events after MenuHost is created are properly > // translated into gesture events instead of being dropped. Done. https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:144: TransferGesture(owner_, this); On 2017/05/16 22:46:57, xiyuan wrote: > Can we move this to ShowMenuHost so that it is symmetric with the > TransferGesture in HideMenuHost? Done. https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.cc:179: controller->set_owner_needs_gesture_events(false); On 2017/05/16 22:46:57, xiyuan wrote: > Do we still need this after making the flag a member of controller? Oh, yeap, we don't need to do this. https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... File ui/views/controls/menu/menu_host.h (right): https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.h:84: MenuController* controller = MenuController::GetActiveInstance(); On 2017/05/16 22:46:57, xiyuan wrote: > This is not needed and should not be done here. > > We can get MenuController via > submenu_->GetMenuItem()->GetMenuController() > > as in MenuHost::InitMenuHost [1] > > [1]: > https://cs.chromium.org/chromium/src/ui/views/controls/menu/menu_host.cc?rcl=... Done. https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_host.h:86: // The owner of child windows. On 2017/05/16 22:46:57, xiyuan wrote: > This not exactly correct. It is "parent of the MenuHost widget". Done. https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2876203003/diff/60001/ui/views/controls/menu/... ui/views/controls/menu/menu_runner.h:96: IS_DRAGGABLE = 1 << 7, On 2017/05/16 22:46:57, xiyuan wrote: > IS_DRAGGABLE is confusing. On first read, I thought it means the menu item is > draggable. How about call it OWNER_NEEDS_DRAG or something similar ? Done.
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
lgtm Cool. Let's get an owner to take a look. How feasible to write a test? You can check out menu_runner_unittest.cc and see if we can our test case there.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Description was changed from ========== Make shelf item can be dragged when context menu is opened. BUG=710601 ========== to ========== Make shelf item can be dragged when context menu is opened. Changes in this cl, 1. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press. 2. Handle the LONG_TAP events on shelf items. Make sure the events will not be transferred back in this situation which is not needed. 3. The context menu of the launcher item is changed to be the same as the context menu when touching white space on the shelf. Make sure the touch events on the launcher item will not influence the dragging of the shelf items. BUG=710601 ==========
Description was changed from ========== Make shelf item can be dragged when context menu is opened. Changes in this cl, 1. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press. 2. Handle the LONG_TAP events on shelf items. Make sure the events will not be transferred back in this situation which is not needed. 3. The context menu of the launcher item is changed to be the same as the context menu when touching white space on the shelf. Make sure the touch events on the launcher item will not influence the dragging of the shelf items. BUG=710601 ========== to ========== Make shelf item can be dragged when context menu is opened. Changes in this cl, 1. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press. 2. Handle the LONG_TAP events on shelf items. Make sure the events will not be transferred back in this situation which is not needed. 3. The context menu of the launcher item is changed to be the same as the context menu when touching white space on the shelf. Make sure the touch events on the launcher item will not influence the dragging of the shelf items. BUG=710601 ==========
minch@chromium.org changed reviewers: + msw@chromium.org
msw@, xiyuan@, could you help review? Thanks.
Description was changed from ========== Make shelf item can be dragged when context menu is opened. Changes in this cl, 1. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press. 2. Handle the LONG_TAP events on shelf items. Make sure the events will not be transferred back in this situation which is not needed. 3. The context menu of the launcher item is changed to be the same as the context menu when touching white space on the shelf. Make sure the touch events on the launcher item will not influence the dragging of the shelf items. BUG=710601 ========== to ========== Make shelf item can be dragged when context menu is opened. Changes in this cl, 1. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press. 2. Handle the LONG_TAP events on shelf items. Make sure the events will not be transferred back in this situation which is not needed. 3. The context menu of the launcher item is changed to be the same as the context menu when touching white space on the shelf. Make sure the touch events on the launcher item will not influence the dragging of the shelf items. 4. UT maybe later. BUG=710601 ==========
+CC sky for menu code, would you like to review? https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button.cc File ash/shelf/shelf_button.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button... ash/shelf/shelf_button.cc:466: views::MenuController* controller = Can you comment on what this is doing and why? https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_view.cc File ash/shelf/shelf_view.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_view.c... ash/shelf/shelf_view.cc:1693: // Shelf items can only be dragged if the shelf is not autohide. nit: s/autohide/in auto-hide/ (or 'is not auto-hidden') https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_view.c... ash/shelf/shelf_view.cc:1694: if (wm_shelf()->auto_hide_behavior() == SHELF_AUTO_HIDE_BEHAVIOR_NEVER) It's not clear to me how the comment above relates to this code... can you explain this a bit more? https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.h (right): https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.h:680: #if !defined(OS_MACOSX) Why is this non-mac? https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:84: void TransferGesture(Widget* source, Widget* target) { nit: comment, maybe seek menu review from sky@? https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:153: // Cancel existing touches, so we don't miss some touch release/cancel nit: move comment into else? https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... File ui/views/controls/menu/menu_host.h (right): https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_host.h:81: #if !defined(OS_MACOSX) ditto question. If you keep all these blocks, commend on the #else and #endif to point out what block it's part of (ie. #endif // !defined(OS_MACOSX)) https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:94: // Owner of the menu can be dragged after menu is created. For example the This is weird to me, I'd like to see it in action. Does dragging close the menu? https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:96: OWNER_NEEDS_DRAG = 1 << 7, nit: SEND_UNHANDLED_GESTURES_TO_OWNER or similar?
sky@chromium.org changed reviewers: + sky@chromium.org
Please add tests to cover what you are trying to accomplish. https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button.cc File ash/shelf/shelf_button.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button... ash/shelf/shelf_button.cc:469: controller->set_owner_needs_gesture_events(false); Instead of changing the menu code, could you accomplish what you need with a post target event handler? That said, I'm a bit hazy on why you need this. Why do you need to transfer events?
https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button.cc File ash/shelf/shelf_button.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button... ash/shelf/shelf_button.cc:466: views::MenuController* controller = On 2017/05/17 23:03:30, msw wrote: > Can you comment on what this is doing and why? 1.LONG_PRESS the shelf items until the context menu is opened. This will transfer events from owner(shelf_widget) to MenuHost. 2.Release LONG PRESS directly without dragging. The context menu is still opened. If we touch anywhere else at this time. The context menu will close. And MenuHost will transfer events back to the owner at this time. But Actually, we don't want events to be transferred back in this situation. Since there is a LONG_TAP events followed when release the press. We tried to |set_owner_needs_gesture_events| to false here. To make sure the events will not be transferred back in this situation. https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button... ash/shelf/shelf_button.cc:469: controller->set_owner_needs_gesture_events(false); On 2017/05/18 16:33:30, sky wrote: > Instead of changing the menu code, could you accomplish what you need with a > post target event handler? > > That said, I'm a bit hazy on why you need this. Why do you need to transfer > events? I think the reason we need to transfer events here is because the window of the menu capture all the events when the menu is created? But it did nothing for the gesture events of the shelf items. So we cannot dragged the shelf items when context menu is created. Transfer events from the owner to the menu. Then we can handle the events that not happened on the menu. Make sure it will not be dropped. Then, after menu is closed, if needed transfer the events back to make sure the owner can continue the events. xiyuan@, please help explain a little more if I made something wrong? Thanks. https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_view.cc File ash/shelf/shelf_view.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_view.c... ash/shelf/shelf_view.cc:1694: if (wm_shelf()->auto_hide_behavior() == SHELF_AUTO_HIDE_BEHAVIOR_NEVER) On 2017/05/17 23:03:30, msw wrote: > It's not clear to me how the comment above relates to this code... can you > explain this a bit more? We cannot drag the shelf items when the shelf is auto-hidden (for the SCROLL events, before open the context menu.) I want to keep the same behavior as SCROLL events. So, if shelf is auto-hidden, we will not transfer events from owner to the menu host. Then, shelf items can not be dragged after the context menu is created. Set |run_types| here, then, in menu_runner_impl.cc will |set_owner_needs_gesture_events| according to the |run_types|. Then, in MenuHost we can know whether we need to transfer events or not. https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.h (right): https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.h:680: #if !defined(OS_MACOSX) On 2017/05/17 23:03:30, msw wrote: > Why is this non-mac? Actually, I am not sure about this. xiyuan@, can you help explain a little bit? Thanks. https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:94: // Owner of the menu can be dragged after menu is created. For example the On 2017/05/17 23:03:30, msw wrote: > This is weird to me, I'd like to see it in action. Does dragging close the menu? Yes, dragging will close the menu.
https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button.cc File ash/shelf/shelf_button.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button... ash/shelf/shelf_button.cc:469: controller->set_owner_needs_gesture_events(false); On 2017/05/18 17:42:57, minch1 wrote: > On 2017/05/18 16:33:30, sky wrote: > > Instead of changing the menu code, could you accomplish what you need with a > > post target event handler? > > > > That said, I'm a bit hazy on why you need this. Why do you need to transfer > > events? > > I think the reason we need to transfer events here is because the window of the > menu capture all the events when the menu is created? But it did nothing for the > gesture events of the shelf items. So we cannot dragged the shelf items when > context menu is created. > > Transfer events from the owner to the menu. Then we can handle the events that > not happened on the menu. Make sure it will not be dropped. Then, after menu is > closed, if needed transfer the events back to make sure the owner can continue > the events. > xiyuan@, please help explain a little more if I made something wrong? Thanks. Each widget has a GestureProvider that translates touch events to gesture events. The GestureProvider starts the work when it sees a TAP_DOWN. When the context menu is created, it captures all touch events. But since we don't yet lift the fingure, it will not generate gestures and silently drop all touch events. By TransferGesture, we make MenuHost continue to translate the touch events to gesture events. We forward the unhandled gestures to Shelf widget so that the dragging can be continued after the menu is open. https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.h (right): https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.h:680: #if !defined(OS_MACOSX) On 2017/05/18 17:42:57, minch1 wrote: > On 2017/05/17 23:03:30, msw wrote: > > Why is this non-mac? > > Actually, I am not sure about this. xiyuan@, can you help explain a little bit? > Thanks. GestureRecognizer does not work on Mac. GestureRecognizerImplMac is currently a dummy impl to make compiler happy. Also Mac does not use Views code fully. Widget::GetNativeView gives NSView* and it would not compile with TransferEventsTo since NSView* is not a GestureConsumer*.
https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button.cc File ash/shelf/shelf_button.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button... ash/shelf/shelf_button.cc:469: controller->set_owner_needs_gesture_events(false); On 2017/05/18 17:42:57, minch1 wrote: > On 2017/05/18 16:33:30, sky wrote: > > Instead of changing the menu code, could you accomplish what you need with a > > post target event handler? > > > > That said, I'm a bit hazy on why you need this. Why do you need to transfer > > events? > > I think the reason we need to transfer events here is because the window of the > menu capture all the events when the menu is created? But it did nothing for the > gesture events of the shelf items. So we cannot dragged the shelf items when > context menu is created. Why is that a problem though? Shouldn't the user close the menu, and then attempt the gesture to do the drag? > > Transfer events from the owner to the menu. Then we can handle the events that > not happened on the menu. Make sure it will not be dropped. Then, after menu is > closed, if needed transfer the events back to make sure the owner can continue > the events. > xiyuan@, please help explain a little more if I made something wrong? Thanks.
https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button.cc File ash/shelf/shelf_button.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button... ash/shelf/shelf_button.cc:466: views::MenuController* controller = On 2017/05/18 17:42:57, minch1 wrote: > On 2017/05/17 23:03:30, msw wrote: > > Can you comment on what this is doing and why? > > 1.LONG_PRESS the shelf items until the context menu is opened. This will > transfer events from owner(shelf_widget) to MenuHost. > 2.Release LONG PRESS directly without dragging. The context menu is still > opened. If we touch anywhere else at this time. The context menu will close. And > MenuHost will transfer events back to the owner at this time. But Actually, we > don't want events to be transferred back in this situation. > Since there is a LONG_TAP events followed when release the press. We tried to > |set_owner_needs_gesture_events| to false here. To make sure the events will not > be transferred back in this situation. It's not clear to me (at least from that explanation) why we need to |set_owner_needs_gesture_events(false)| instead of just handling/ignoring this one LONG_TAP event. Also, I'm hoping that you'll add a comment in code, not just on this CL review, readers of this code probably won't understand what's happening or why here. https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_view.cc File ash/shelf/shelf_view.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_view.c... ash/shelf/shelf_view.cc:1694: if (wm_shelf()->auto_hide_behavior() == SHELF_AUTO_HIDE_BEHAVIOR_NEVER) On 2017/05/18 17:42:57, minch1 wrote: > On 2017/05/17 23:03:30, msw wrote: > > It's not clear to me how the comment above relates to this code... can you > > explain this a bit more? > > We cannot drag the shelf items when the shelf is auto-hidden (for the SCROLL > events, before open the context menu.) I want to keep the same behavior as > SCROLL events. So, if shelf is auto-hidden, we will not transfer events from > owner to the menu host. Then, shelf items can not be dragged after the context > menu is created. > Set |run_types| here, then, in menu_runner_impl.cc will > |set_owner_needs_gesture_events| according to the |run_types|. Then, in MenuHost > we can know whether we need to transfer events or not. Why won't the shelf itself correctly ignore drag touch events when it's in an auto-hide mode (ie. we shouldn't change the menu's run type based on shelf state, the shelf itself should handle/ignore gesture events correctly depending on its internal state). If you need to keep this, add an explanatory comment in code, like "Shelf items can not be dragged if the shelf is not autohide." https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.h (right): https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.h:680: #if !defined(OS_MACOSX) On 2017/05/18 18:00:47, xiyuan wrote: > On 2017/05/18 17:42:57, minch1 wrote: > > On 2017/05/17 23:03:30, msw wrote: > > > Why is this non-mac? > > > > Actually, I am not sure about this. xiyuan@, can you help explain a little > bit? > > Thanks. > > GestureRecognizer does not work on Mac. GestureRecognizerImplMac is currently a > dummy impl to make compiler happy. Also Mac does not use Views code fully. > Widget::GetNativeView gives NSView* and it would not compile with > TransferEventsTo since NSView* is not a GestureConsumer*. Can we try to reduce the preprocessor blocks a bit? (ie. just prevent the inapplicable code from compiling, and compile everything possible, like this flag, regardless).
https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button.cc File ash/shelf/shelf_button.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button... ash/shelf/shelf_button.cc:466: views::MenuController* controller = On 2017/05/18 20:42:20, msw wrote: > On 2017/05/18 17:42:57, minch1 wrote: > > On 2017/05/17 23:03:30, msw wrote: > > > Can you comment on what this is doing and why? > > > > 1.LONG_PRESS the shelf items until the context menu is opened. This will > > transfer events from owner(shelf_widget) to MenuHost. > > 2.Release LONG PRESS directly without dragging. The context menu is still > > opened. If we touch anywhere else at this time. The context menu will close. > And > > MenuHost will transfer events back to the owner at this time. But Actually, we > > don't want events to be transferred back in this situation. > > Since there is a LONG_TAP events followed when release the press. We tried to > > |set_owner_needs_gesture_events| to false here. To make sure the events will > not > > be transferred back in this situation. > > It's not clear to me (at least from that explanation) why we need to > |set_owner_needs_gesture_events(false)| instead of just handling/ignoring this > one LONG_TAP event. Also, I'm hoping that you'll add a comment in code, not just > on this CL review, readers of this code probably won't understand what's > happening or why here. We handled the LONG_TAP here to make it will not open a context menu again. Besides that we also want to make sure the MenuHost will not transfer events back in this situation. That is why |set_owner_needs_gesture_events(false)| here. https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button... ash/shelf/shelf_button.cc:469: controller->set_owner_needs_gesture_events(false); On 2017/05/18 19:43:12, sky wrote: > On 2017/05/18 17:42:57, minch1 wrote: > > On 2017/05/18 16:33:30, sky wrote: > > > Instead of changing the menu code, could you accomplish what you need with a > > > post target event handler? > > > > > > That said, I'm a bit hazy on why you need this. Why do you need to transfer > > > events? > > > > I think the reason we need to transfer events here is because the window of > the > > menu capture all the events when the menu is created? But it did nothing for > the > > gesture events of the shelf items. So we cannot dragged the shelf items when > > context menu is created. > > Why is that a problem though? Shouldn't the user close the menu, and then > attempt the gesture to do the drag? > > > > > Transfer events from the owner to the menu. Then we can handle the events that > > not happened on the menu. Make sure it will not be dropped. Then, after menu > is > > closed, if needed transfer the events back to make sure the owner can continue > > the events. > > xiyuan@, please help explain a little more if I made something wrong? Thanks. > I guess this is a requirement from UX?
https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button.cc File ash/shelf/shelf_button.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_button... ash/shelf/shelf_button.cc:466: views::MenuController* controller = On 2017/05/18 22:02:53, minch1 wrote: > On 2017/05/18 20:42:20, msw wrote: > > On 2017/05/18 17:42:57, minch1 wrote: > > > On 2017/05/17 23:03:30, msw wrote: > > > > Can you comment on what this is doing and why? > > > > > > 1.LONG_PRESS the shelf items until the context menu is opened. This will > > > transfer events from owner(shelf_widget) to MenuHost. > > > 2.Release LONG PRESS directly without dragging. The context menu is still > > > opened. If we touch anywhere else at this time. The context menu will close. > > And > > > MenuHost will transfer events back to the owner at this time. But Actually, > we > > > don't want events to be transferred back in this situation. > > > Since there is a LONG_TAP events followed when release the press. We tried > to > > > |set_owner_needs_gesture_events| to false here. To make sure the events will > > not > > > be transferred back in this situation. > > > > It's not clear to me (at least from that explanation) why we need to > > |set_owner_needs_gesture_events(false)| instead of just handling/ignoring this > > one LONG_TAP event. Also, I'm hoping that you'll add a comment in code, not > just > > on this CL review, readers of this code probably won't understand what's > > happening or why here. > > We handled the LONG_TAP here to make it will not open a context menu again. > Besides that we also want to make sure the MenuHost will not transfer events > back in this situation. That is why |set_owner_needs_gesture_events(false)| > here. Right, I don't understand *why* we don't want the MenuHost to transfer events back in this case.
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== Make shelf item can be dragged when context menu is opened. Changes in this cl, 1. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press. 2. Handle the LONG_TAP events on shelf items. Make sure the events will not be transferred back in this situation which is not needed. 3. The context menu of the launcher item is changed to be the same as the context menu when touching white space on the shelf. Make sure the touch events on the launcher item will not influence the dragging of the shelf items. 4. UT maybe later. BUG=710601 ========== to ========== Make shelf item can be dragged when context menu is opened. Current context menu of shelf, 1) Allow dragging before context menu is created. 2) No dragging after context menu is created. In order to keep the same as Android OS, 1) Allow dragging during the same press (don't release the finger) after context menu is created. 2) Close the context menu once start dragging. Changes in this cl, 1. Add |SEND_UNHANDLED_GESTURES_TO_OWNER| in MenuRunner. This means the owner hopes that menu can help send the unhandled gesture events to the owner instead of dropping them. e.g, the context menu of the shelf items, and this is only true if shelf is not autohide. 2. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press which will create the context menu. 3. Handle the LONG_TAP events on shelf items. Since gesture events are sent back from menu. LONG_TAP should be handled by the shelf to avoid to show context menu again. 4. The context menu of the launcher item is changed to be the same as the context menu when touching white space on the shelf. Make sure the touch events on the launcher item will not influence the dragging of the shelf items. 5. UT maybe later. BUG=710601 ==========
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...)
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...)
Description was changed from ========== Make shelf item can be dragged when context menu is opened. Current context menu of shelf, 1) Allow dragging before context menu is created. 2) No dragging after context menu is created. In order to keep the same as Android OS, 1) Allow dragging during the same press (don't release the finger) after context menu is created. 2) Close the context menu once start dragging. Changes in this cl, 1. Add |SEND_UNHANDLED_GESTURES_TO_OWNER| in MenuRunner. This means the owner hopes that menu can help send the unhandled gesture events to the owner instead of dropping them. e.g, the context menu of the shelf items, and this is only true if shelf is not autohide. 2. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press which will create the context menu. 3. Handle the LONG_TAP events on shelf items. Since gesture events are sent back from menu. LONG_TAP should be handled by the shelf to avoid to show context menu again. 4. The context menu of the launcher item is changed to be the same as the context menu when touching white space on the shelf. Make sure the touch events on the launcher item will not influence the dragging of the shelf items. 5. UT maybe later. BUG=710601 ========== to ========== Make shelf item can be dragged when context menu is opened. Current context menu of shelf, 1) Allow dragging before context menu is created. 2) No dragging after context menu is created. In order to keep the same as Android OS, 1) Allow dragging during the same press (don't release the finger) after context menu is created. 2) Close the context menu once start dragging. Changes in this cl, 1. Add |SEND_UNHANDLED_GESTURES_TO_OWNER| in MenuRunner. This means the owner hopes that menu can help send the unhandled gesture events to the owner instead of dropping them. e.g, the context menu of the shelf items, and this is only true if shelf is not autohide. 2. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press which will create the context menu. 3. Handle the LONG_TAP events on shelf items. Since gesture events been transferred from shelf to MenuHost, but we don't want it will show the context menu again. 4. The context menu of the launcher item is changed to be the same as the context menu when touching white space on the shelf. Make sure the touch events on the launcher item will not influence the dragging of the shelf items. 5. UT maybe later. BUG=710601 ==========
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
minch@chromium.org changed reviewers: + sadrul@chromium.org
Could you please help review? Thanks. https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_view.cc File ash/shelf/shelf_view.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_view.c... ash/shelf/shelf_view.cc:1693: // Shelf items can only be dragged if the shelf is not autohide. On 2017/05/17 23:03:30, msw wrote: > nit: s/autohide/in auto-hide/ (or 'is not auto-hidden') update the comment according to next comment. https://codereview.chromium.org/2876203003/diff/140001/ash/shelf/shelf_view.c... ash/shelf/shelf_view.cc:1694: if (wm_shelf()->auto_hide_behavior() == SHELF_AUTO_HIDE_BEHAVIOR_NEVER) On 2017/05/18 20:42:20, msw wrote: > On 2017/05/18 17:42:57, minch1 wrote: > > On 2017/05/17 23:03:30, msw wrote: > > > It's not clear to me how the comment above relates to this code... can you > > > explain this a bit more? > > > > We cannot drag the shelf items when the shelf is auto-hidden (for the SCROLL > > events, before open the context menu.) I want to keep the same behavior as > > SCROLL events. So, if shelf is auto-hidden, we will not transfer events from > > owner to the menu host. Then, shelf items can not be dragged after the context > > menu is created. > > Set |run_types| here, then, in menu_runner_impl.cc will > > |set_owner_needs_gesture_events| according to the |run_types|. Then, in > MenuHost > > we can know whether we need to transfer events or not. > > Why won't the shelf itself correctly ignore drag touch events when it's in an > auto-hide mode (ie. we shouldn't change the menu's run type based on shelf > state, the shelf itself should handle/ignore gesture events correctly depending > on its internal state). If you need to keep this, add an explanatory comment in > code, like "Shelf items can not be dragged if the shelf is not autohide." Done. https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.h (right): https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.h:680: #if !defined(OS_MACOSX) On 2017/05/18 20:42:20, msw wrote: > On 2017/05/18 18:00:47, xiyuan wrote: > > On 2017/05/18 17:42:57, minch1 wrote: > > > On 2017/05/17 23:03:30, msw wrote: > > > > Why is this non-mac? > > > > > > Actually, I am not sure about this. xiyuan@, can you help explain a little > > bit? > > > Thanks. > > > > GestureRecognizer does not work on Mac. GestureRecognizerImplMac is currently > a > > dummy impl to make compiler happy. Also Mac does not use Views code fully. > > Widget::GetNativeView gives NSView* and it would not compile with > > TransferEventsTo since NSView* is not a GestureConsumer*. > > Can we try to reduce the preprocessor blocks a bit? (ie. just prevent the > inapplicable code from compiling, and compile everything possible, like this > flag, regardless). Done. https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:153: // Cancel existing touches, so we don't miss some touch release/cancel On 2017/05/17 23:03:30, msw wrote: > nit: move comment into else? Done. https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... File ui/views/controls/menu/menu_host.h (right): https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_host.h:81: #if !defined(OS_MACOSX) On 2017/05/17 23:03:30, msw wrote: > ditto question. If you keep all these blocks, commend on the #else and #endif to > point out what block it's part of (ie. #endif // !defined(OS_MACOSX)) Done. https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2876203003/diff/140001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:96: OWNER_NEEDS_DRAG = 1 << 7, On 2017/05/17 23:03:30, msw wrote: > nit: SEND_UNHANDLED_GESTURES_TO_OWNER or similar? Done.
https://codereview.chromium.org/2876203003/diff/200001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.cc (right): https://codereview.chromium.org/2876203003/diff/200001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.cc:834: // gesture events on the shelf can be created correctly. Think it would be easier to understand if we rename owner_needs_gesture_events_ etc to prevserve_current_gesture_for_owner_. Then this comment can be something like: // Reset |prevserve_current_gesture_for_owner_| flag when the current // gesture ends. https://codereview.chromium.org/2876203003/diff/200001/ui/views/controls/menu... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/200001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:155: if (menu_controller->owner_needs_gesture_events()) { Combine this "if" with "if" on Line 154 and run the "else" when there is no |menu_controller| i.e. if (menu_controller && menu_controller->owner_needs_gesture_events()) { // TransferGesture } else { // CancelActiveTouchesExcept as before } https://codereview.chromium.org/2876203003/diff/200001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2876203003/diff/200001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:95: // context menu of the item is opened. nit: I would say something like // Owner of the menu could be in the middle of a gesture when the menu // opens and can use this flag to continue the gesture. For example, // shelf uses the flag to continue dragging an item without lifting the // finger after the context menu of the item is opened.
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_amd64-generic_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_amd64-...) chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...)
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2876203003/diff/200001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.cc (right): https://codereview.chromium.org/2876203003/diff/200001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.cc:834: // gesture events on the shelf can be created correctly. On 2017/05/26 23:13:37, xiyuan wrote: > Think it would be easier to understand if we rename owner_needs_gesture_events_ > etc to prevserve_current_gesture_for_owner_. > > Then this comment can be something like: > // Reset |prevserve_current_gesture_for_owner_| flag when the current > // gesture ends. Done. https://codereview.chromium.org/2876203003/diff/200001/ui/views/controls/menu... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/200001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:155: if (menu_controller->owner_needs_gesture_events()) { On 2017/05/26 23:13:38, xiyuan wrote: > Combine this "if" with "if" on Line 154 and run the "else" when there is no > |menu_controller| > > i.e. > > if (menu_controller && menu_controller->owner_needs_gesture_events()) { > // TransferGesture > } else { > // CancelActiveTouchesExcept as before > } Done. https://codereview.chromium.org/2876203003/diff/200001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2876203003/diff/200001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:95: // context menu of the item is opened. On 2017/05/26 23:13:38, xiyuan wrote: > nit: I would say something like > > // Owner of the menu could be in the middle of a gesture when the menu > // opens and can use this flag to continue the gesture. For example, > // shelf uses the flag to continue dragging an item without lifting the > // finger after the context menu of the item is opened. Done.
The approach looks fine to me. sky@, sadural@ what do you think? minch@, could you add a test, e.g. in menu_controller_unittest.cc ?
Nice, some comment nits. Tests seem like a very good idea. https://codereview.chromium.org/2876203003/diff/240001/ash/shelf/shelf_button.cc File ash/shelf/shelf_button.cc (right): https://codereview.chromium.org/2876203003/diff/240001/ash/shelf/shelf_button... ash/shelf/shelf_button.cc:465: event->SetHandled(); nit: comment why |event| is ignored (marked handled without any action)? https://codereview.chromium.org/2876203003/diff/240001/ash/shelf/shelf_view.cc File ash/shelf/shelf_view.cc (right): https://codereview.chromium.org/2876203003/diff/240001/ash/shelf/shelf_view.c... ash/shelf/shelf_view.cc:1693: // Shelf items can only be dragged if the shelf is not autohide. repeated nit: s/autohide/in auto-hide/ (or 'is not auto-hidden'). You said "update the comment according to next comment." but didn't fix this. https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.cc (right): https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.cc:833: // Reset |preserve_current_gesture_for_owner_| flag when the current gesture optional nit for one-liner: // Reset |preserve_current_gesture_for_owner_| when the first gesture ends. https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.cc:836: set_preserve_current_gesture_for_owner(false); optional nit: set the member directly instead of using the setter. https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.h (right): https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.h:679: // Whether the menu |owner_| needs gesture events. When set to true menu nit: "true, the menu" https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.h:683: bool preserve_current_gesture_for_owner_ = false; nit: sorry to bikeshed, but how about "send_gesture_events_to_owner_"? https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:93: // Owner of the menu could be in the middle of a gesture when the menu opens nit: "The menu's owner could" https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:94: // and can use this flag to continue the gesture. For example, shelf uses nit: "Chrome OS's shelf" https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:97: PRESERVE_CURRENT_GESTURE_FOR_OWNER = 1 << 7, optional nit: keep name in sync with MenuController's member (if renamed)
On 2017/06/01 20:24:28, msw wrote: > Nice, some comment nits. Tests seem like a very good idea. > > https://codereview.chromium.org/2876203003/diff/240001/ash/shelf/shelf_button.cc > File ash/shelf/shelf_button.cc (right): > > https://codereview.chromium.org/2876203003/diff/240001/ash/shelf/shelf_button... > ash/shelf/shelf_button.cc:465: event->SetHandled(); > nit: comment why |event| is ignored (marked handled without any action)? > > https://codereview.chromium.org/2876203003/diff/240001/ash/shelf/shelf_view.cc > File ash/shelf/shelf_view.cc (right): > > https://codereview.chromium.org/2876203003/diff/240001/ash/shelf/shelf_view.c... > ash/shelf/shelf_view.cc:1693: // Shelf items can only be dragged if the shelf is > not autohide. > repeated nit: s/autohide/in auto-hide/ (or 'is not auto-hidden'). > You said "update the comment according to next comment." but didn't fix this. > > https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... > File ui/views/controls/menu/menu_controller.cc (right): > > https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... > ui/views/controls/menu/menu_controller.cc:833: // Reset > |preserve_current_gesture_for_owner_| flag when the current gesture > optional nit for one-liner: > // Reset |preserve_current_gesture_for_owner_| when the first gesture ends. > > https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... > ui/views/controls/menu/menu_controller.cc:836: > set_preserve_current_gesture_for_owner(false); > optional nit: set the member directly instead of using the setter. > > https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... > File ui/views/controls/menu/menu_controller.h (right): > > https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... > ui/views/controls/menu/menu_controller.h:679: // Whether the menu |owner_| needs > gesture events. When set to true menu > nit: "true, the menu" > > https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... > ui/views/controls/menu/menu_controller.h:683: bool > preserve_current_gesture_for_owner_ = false; > nit: sorry to bikeshed, but how about "send_gesture_events_to_owner_"? > > https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... > File ui/views/controls/menu/menu_runner.h (right): > > https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... > ui/views/controls/menu/menu_runner.h:93: // Owner of the menu could be in the > middle of a gesture when the menu opens > nit: "The menu's owner could" > > https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... > ui/views/controls/menu/menu_runner.h:94: // and can use this flag to continue > the gesture. For example, shelf uses > nit: "Chrome OS's shelf" > > https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... > ui/views/controls/menu/menu_runner.h:97: PRESERVE_CURRENT_GESTURE_FOR_OWNER = 1 > << 7, > optional nit: keep name in sync with MenuController's member (if renamed) The approach here doesn't match what Sadrul recommended. In particular "The shelf can then install a pre-target handler on the menu, so that it can see when there are gesture-scroll-update events with sufficient delta from the originating location." I think this should be a lot simpler and very little change (if any) to menus. Is there a reason this can't work?
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Description was changed from ========== Make shelf item can be dragged when context menu is opened. Current context menu of shelf, 1) Allow dragging before context menu is created. 2) No dragging after context menu is created. In order to keep the same as Android OS, 1) Allow dragging during the same press (don't release the finger) after context menu is created. 2) Close the context menu once start dragging. Changes in this cl, 1. Add |SEND_UNHANDLED_GESTURES_TO_OWNER| in MenuRunner. This means the owner hopes that menu can help send the unhandled gesture events to the owner instead of dropping them. e.g, the context menu of the shelf items, and this is only true if shelf is not autohide. 2. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press which will create the context menu. 3. Handle the LONG_TAP events on shelf items. Since gesture events been transferred from shelf to MenuHost, but we don't want it will show the context menu again. 4. The context menu of the launcher item is changed to be the same as the context menu when touching white space on the shelf. Make sure the touch events on the launcher item will not influence the dragging of the shelf items. 5. UT maybe later. BUG=710601 ========== to ========== Make shelf item can be dragged when context menu is opened. Current context menu of shelf, 1) Allow dragging before context menu is created. 2) No dragging after context menu is created. In order to keep the same as Android OS, 1) Allow dragging during the same press (don't release the finger) after context menu is created. 2) Close the context menu once start dragging. Changes in this cl, 1. Add |SEND_UNHANDLED_GESTURES_TO_OWNER| in MenuRunner. This means the owner hopes that menu can help send the unhandled gesture events to the owner instead of dropping them. e.g, the context menu of the shelf items, and this is only true if shelf is not autohide. 2. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press which will create the context menu. 3. Handle the LONG_TAP events on shelf items. Since gesture events been transferred from shelf to MenuHost, but we don't want it will show the context menu again. 4. The context menu of the launcher item is changed to be the same as the context menu when touching white space on the shelf. Make sure the touch events on the launcher item will not influence the dragging of the shelf items. BUG=710601 ==========
Really sorry for the delay. For "The shelf can then install a pre-target handler on the menu, so that it can see when there are gesture-scroll-update events with sufficient delta from the originating location." Shelf should get the target before install the pre-target handler. But looks like we don't have the api to get the target MenuHost. And it is buried deeply in SubmenuView. One more concern it that is that good to expose MenuHost outside the menu system (eg, shelf)? One more thing is that since the MenuHost captures all the event. In order to make sure that gesture sequence remains alive. I think transfer events in menuhost is necessary? https://codereview.chromium.org/2876203003/diff/240001/ash/shelf/shelf_button.cc File ash/shelf/shelf_button.cc (right): https://codereview.chromium.org/2876203003/diff/240001/ash/shelf/shelf_button... ash/shelf/shelf_button.cc:465: event->SetHandled(); On 2017/06/01 20:24:27, msw wrote: > nit: comment why |event| is ignored (marked handled without any action)? Done. https://codereview.chromium.org/2876203003/diff/240001/ash/shelf/shelf_view.cc File ash/shelf/shelf_view.cc (right): https://codereview.chromium.org/2876203003/diff/240001/ash/shelf/shelf_view.c... ash/shelf/shelf_view.cc:1693: // Shelf items can only be dragged if the shelf is not autohide. On 2017/06/01 20:24:27, msw wrote: > repeated nit: s/autohide/in auto-hide/ (or 'is not auto-hidden'). > You said "update the comment according to next comment." but didn't fix this. Done. https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.cc (right): https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.cc:833: // Reset |preserve_current_gesture_for_owner_| flag when the current gesture On 2017/06/01 20:24:27, msw - vacation june 8-27 wrote: > optional nit for one-liner: > // Reset |preserve_current_gesture_for_owner_| when the first gesture ends. Done. https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.cc:836: set_preserve_current_gesture_for_owner(false); On 2017/06/01 20:24:27, msw wrote: > optional nit: set the member directly instead of using the setter. Done. https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.h (right): https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.h:679: // Whether the menu |owner_| needs gesture events. When set to true menu On 2017/06/01 20:24:27, msw wrote: > nit: "true, the menu" Done. https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.h:683: bool preserve_current_gesture_for_owner_ = false; On 2017/06/01 20:24:28, msw - vacation june 8-27 wrote: > nit: sorry to bikeshed, but how about "send_gesture_events_to_owner_"? Done. https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... File ui/views/controls/menu/menu_runner.h (right): https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:93: // Owner of the menu could be in the middle of a gesture when the menu opens On 2017/06/01 20:24:28, msw wrote: > nit: "The menu's owner could" Done. https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:94: // and can use this flag to continue the gesture. For example, shelf uses On 2017/06/01 20:24:28, msw wrote: > nit: "Chrome OS's shelf" Done. https://codereview.chromium.org/2876203003/diff/240001/ui/views/controls/menu... ui/views/controls/menu/menu_runner.h:97: PRESERVE_CURRENT_GESTURE_FOR_OWNER = 1 << 7, On 2017/06/01 20:24:28, msw - vacation june 8-27 wrote: > optional nit: keep name in sync with MenuController's member (if renamed) Done.
On 2017/06/23 23:13:03, minch1 wrote: > Really sorry for the delay. For "The shelf can then install a > pre-target handler on the menu, so that it can see when > there are gesture-scroll-update events with sufficient delta > from the originating location." > Shelf should get the target before install the pre-target handler. But looks > like we don't have the api to get the target MenuHost. And it is buried deeply > in SubmenuView. > One more concern it that is that good to expose MenuHost > outside the menu system (eg, shelf)? I don't think you need to get access to the MenuHost. You should be able to install a pre-target handler (or views::PointerWatcher) on ash::Shell, and that should be sufficient for you to decide when to close the menu and start the drag. > One more thing is that since the MenuHost captures all the event. In order to > make sure that gesture sequence remains alive. I think transfer events in > menuhost is necessary? I think so. The alternative would be to introduce some amount of complexity in menu so that it is possible to have some menus without having a capture, which I think would be more complex than we want it to be.
On 2017/06/27 03:05:13, sadrul wrote: > On 2017/06/23 23:13:03, minch1 wrote: > > Really sorry for the delay. For "The shelf can then install a > > pre-target handler on the menu, so that it can see when > > there are gesture-scroll-update events with sufficient delta > > from the originating location." > > Shelf should get the target before install the pre-target handler. But looks > > like we don't have the api to get the target MenuHost. And it is buried deeply > > in SubmenuView. > > One more concern it that is that good to expose MenuHost > > outside the menu system (eg, shelf)? > > I don't think you need to get access to the MenuHost. You should be able to > install a pre-target handler (or views::PointerWatcher) on ash::Shell, and that > should be sufficient for you to decide when to close the menu and start the > drag. > > > One more thing is that since the MenuHost captures all the event. In order to > > make sure that gesture sequence remains alive. I think transfer events in > > menuhost is necessary? > > I think so. The alternative would be to introduce some amount of complexity in > menu so that it is possible to have some menus without having a capture, which I > think would be more complex than we want it to be. Thanks. Let me try it.
On 2017/06/27 18:39:12, minch1 wrote: > On 2017/06/27 03:05:13, sadrul wrote: > > On 2017/06/23 23:13:03, minch1 wrote: > > > Really sorry for the delay. For "The shelf can then install a > > > pre-target handler on the menu, so that it can see when > > > there are gesture-scroll-update events with sufficient delta > > > from the originating location." > > > Shelf should get the target before install the pre-target handler. But looks > > > like we don't have the api to get the target MenuHost. And it is buried > deeply > > > in SubmenuView. > > > One more concern it that is that good to expose MenuHost > > > outside the menu system (eg, shelf)? > > > > I don't think you need to get access to the MenuHost. You should be able to > > install a pre-target handler (or views::PointerWatcher) on ash::Shell, and > that > > should be sufficient for you to decide when to close the menu and start the > > drag. > > > > > One more thing is that since the MenuHost captures all the event. In order > to > > > make sure that gesture sequence remains alive. I think transfer events in > > > menuhost is necessary? > > > > I think so. The alternative would be to introduce some amount of complexity in > > menu so that it is possible to have some menus without having a capture, which > I > > think would be more complex than we want it to be. > > Thanks. Let me try it. Just to clarify: I assume you mean you will try the pre-target handler/PointerWatcher on ash::Shell approach (as opposed to not transfering gesture sequence to menu)
On 2017/06/28 04:57:48, sadrul wrote: > On 2017/06/27 18:39:12, minch1 wrote: > > On 2017/06/27 03:05:13, sadrul wrote: > > > On 2017/06/23 23:13:03, minch1 wrote: > > > > Really sorry for the delay. For "The shelf can then install a > > > > pre-target handler on the menu, so that it can see when > > > > there are gesture-scroll-update events with sufficient delta > > > > from the originating location." > > > > Shelf should get the target before install the pre-target handler. But > looks > > > > like we don't have the api to get the target MenuHost. And it is buried > > deeply > > > > in SubmenuView. > > > > One more concern it that is that good to expose MenuHost > > > > outside the menu system (eg, shelf)? > > > > > > I don't think you need to get access to the MenuHost. You should be able to > > > install a pre-target handler (or views::PointerWatcher) on ash::Shell, and > > that > > > should be sufficient for you to decide when to close the menu and start the > > > drag. > > > > > > > One more thing is that since the MenuHost captures all the event. In order > > to > > > > make sure that gesture sequence remains alive. I think transfer events in > > > > menuhost is necessary? > > > > > > I think so. The alternative would be to introduce some amount of complexity > in > > > menu so that it is possible to have some menus without having a capture, > which > > I > > > think would be more complex than we want it to be. > > > > Thanks. Let me try it. > > Just to clarify: I assume you mean you will try the pre-target > handler/PointerWatcher on ash::Shell approach (as opposed to not transfering > gesture sequence to menu) I don't understand the benefits of using pre-target approach. To keep the gesture alive, we would need the MenuRunner flag so that MenuHost knows to TransferGesture during construction. So most of the menu code change would stay. Pre-target handler only saves the code to forward the gesture events out to the host/owner of the menu. What did I miss?
lgtm with test nits; follow up with xiyuan and sadrul, but fwiw, I think the current approach (*without* a pre-target handler) is okay. https://codereview.chromium.org/2876203003/diff/300001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller_unittest.cc (right): https://codereview.chromium.org/2876203003/diff/300001/ui/views/controls/menu... ui/views/controls/menu/menu_controller_unittest.cc:156: class TestWidget : public Widget { nit: |GestureTestWidget| and comment "A test widget that counts gesture events." https://codereview.chromium.org/2876203003/diff/300001/ui/views/controls/menu... ui/views/controls/menu/menu_controller_unittest.cc:535: owner_.reset(new TestWidget); nit: owner = base::MakeUnique<TestWidget>(); (optionally ditto elsewhere) https://codereview.chromium.org/2876203003/diff/300001/ui/views/controls/menu... ui/views/controls/menu/menu_controller_unittest.cc:1133: // Gesture triggered outside the menu. nit: "The menu's owner should receive gestures triggered outside the menu." (move this below the new section testing behavior when the flag is false) https://codereview.chromium.org/2876203003/diff/300001/ui/views/controls/menu... ui/views/controls/menu/menu_controller_unittest.cc:1138: controller->set_send_gesture_events_to_owner(true); optional nit: test that gesture events are not sent to the owner when the flag is not set, ie. before setting the flag, do something like this: // Gesture events should not be forwarded if the flag is not set. EXPECT_EQ(CountOwnerOnGestureEvent(), 0); EXPECT_FALSE(controller->send_gesture_events_to_owner()); controller->OnGestureEvent(sub_menu, &event); EXPECT_EQ(CountOwnerOnGestureEvent(), 0); https://codereview.chromium.org/2876203003/diff/300001/ui/views/controls/menu... ui/views/controls/menu/menu_controller_unittest.cc:1148: // ET_GESTURE_END disabled preserve_current_gesture_for_owner. Then nit: ET_GESTURE_END resets the |send_gesture_events_to_owner| flag, so further gesture events should not be sent to the owner.
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Thanks for your review. Fixed comments. And can I land it? https://codereview.chromium.org/2876203003/diff/300001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller_unittest.cc (right): https://codereview.chromium.org/2876203003/diff/300001/ui/views/controls/menu... ui/views/controls/menu/menu_controller_unittest.cc:156: class TestWidget : public Widget { On 2017/06/29 19:02:10, msw wrote: > nit: |GestureTestWidget| and comment "A test widget that counts gesture events." Done. https://codereview.chromium.org/2876203003/diff/300001/ui/views/controls/menu... ui/views/controls/menu/menu_controller_unittest.cc:535: owner_.reset(new TestWidget); On 2017/06/29 19:02:10, msw wrote: > nit: owner = base::MakeUnique<TestWidget>(); (optionally ditto elsewhere) Done. https://codereview.chromium.org/2876203003/diff/300001/ui/views/controls/menu... ui/views/controls/menu/menu_controller_unittest.cc:1133: // Gesture triggered outside the menu. On 2017/06/29 19:02:10, msw wrote: > nit: "The menu's owner should receive gestures triggered outside the menu." > (move this below the new section testing behavior when the flag is false) Done. https://codereview.chromium.org/2876203003/diff/300001/ui/views/controls/menu... ui/views/controls/menu/menu_controller_unittest.cc:1138: controller->set_send_gesture_events_to_owner(true); On 2017/06/29 19:02:10, msw wrote: > optional nit: test that gesture events are not sent to the owner when the flag > is not set, ie. before setting the flag, do something like this: > // Gesture events should not be forwarded if the flag is not set. > EXPECT_EQ(CountOwnerOnGestureEvent(), 0); > EXPECT_FALSE(controller->send_gesture_events_to_owner()); > controller->OnGestureEvent(sub_menu, &event); > EXPECT_EQ(CountOwnerOnGestureEvent(), 0); Done. https://codereview.chromium.org/2876203003/diff/300001/ui/views/controls/menu... ui/views/controls/menu/menu_controller_unittest.cc:1148: // ET_GESTURE_END disabled preserve_current_gesture_for_owner. Then On 2017/06/29 19:02:10, msw wrote: > nit: ET_GESTURE_END resets the |send_gesture_events_to_owner| flag, so further > gesture events should not be sent to the owner. Done.
lgtm with a nit; please wait for xiyuan or sadrul to reply before landing. https://codereview.chromium.org/2876203003/diff/320001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller_unittest.cc (right): https://codereview.chromium.org/2876203003/diff/320001/ui/views/controls/menu... ui/views/controls/menu/menu_controller_unittest.cc:1139: // Gesture events should not be forwarded if the flag it not set. nit: "flag is not set."
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Hi, sadrul@, xiyuan@, what's the further suggestion for this cl? https://codereview.chromium.org/2876203003/diff/320001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller_unittest.cc (right): https://codereview.chromium.org/2876203003/diff/320001/ui/views/controls/menu... ui/views/controls/menu/menu_controller_unittest.cc:1139: // Gesture events should not be forwarded if the flag it not set. On 2017/06/30 20:22:39, msw wrote: > nit: "flag is not set." Done.
lgtm Sadrul, can we go ahead and land with this?
https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.cc (right): https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.cc:840: if (send_gesture_events_to_owner()) { This should happen at the very beginning? https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:134: owner_ = parent; What if |owner_| is destroyed after the menu comes up? If we expect it won't happen, can we validate that (e.g. add some DCHECK()s somewhere)? https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:151: #if !defined(OS_MACOSX) Do we need the OS_MACOSX checks? https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:169: } An alternate approach, although probably hackier than this: internal::TransferGesture(owner_, this); SetCapture(); internal::TransformGesture(this, owner_); We shouldn't need to worry about owner_ going away, or transfering gesture events back to owner_ etc. that way.
Hi, Sadrul, please check the new ps. Thanks. https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... File ui/views/controls/menu/menu_controller.cc (right): https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... ui/views/controls/menu/menu_controller.cc:840: if (send_gesture_events_to_owner()) { On 2017/08/30 20:31:39, sadrul wrote: > This should happen at the very beginning? Removed to the entry of OnGestureEvent, then we can have a quick return if we need to send gesture events back to the owner. https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:134: owner_ = parent; On 2017/08/30 20:31:39, sadrul wrote: > What if |owner_| is destroyed after the menu comes up? If we expect it won't > happen, can we validate that (e.g. add some DCHECK()s somewhere)? Added DCHECK(owner()) when we need to send events back in MenuController::OnGestureEvent. In HideMenuHost checked the owner_ before transfer events back to the owner. https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:151: #if !defined(OS_MACOSX) On 2017/08/30 20:31:39, sadrul wrote: > Do we need the OS_MACOSX checks? I think so. Since GestureRecognizerImplMac currently is stub implementation of GestureRecognizer for Mac. https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:169: } On 2017/08/30 20:31:39, sadrul wrote: > An alternate approach, although probably hackier than this: > > internal::TransferGesture(owner_, this); > SetCapture(); > internal::TransformGesture(this, owner_); > > We shouldn't need to worry about owner_ going away, or transfering gesture > events back to owner_ etc. that way. Do you mean to do all of these in ShowMenuHost? Tried it. But it seems that if we transfer the events back to owner_ and keep MenuHost set capture at the same time. Both owner_ and MenuController will not receive the touch and gesture events.
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_headless_rel on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== Make shelf item can be dragged when context menu is opened. Current context menu of shelf, 1) Allow dragging before context menu is created. 2) No dragging after context menu is created. In order to keep the same as Android OS, 1) Allow dragging during the same press (don't release the finger) after context menu is created. 2) Close the context menu once start dragging. Changes in this cl, 1. Add |SEND_UNHANDLED_GESTURES_TO_OWNER| in MenuRunner. This means the owner hopes that menu can help send the unhandled gesture events to the owner instead of dropping them. e.g, the context menu of the shelf items, and this is only true if shelf is not autohide. 2. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press which will create the context menu. 3. Handle the LONG_TAP events on shelf items. Since gesture events been transferred from shelf to MenuHost, but we don't want it will show the context menu again. 4. The context menu of the launcher item is changed to be the same as the context menu when touching white space on the shelf. Make sure the touch events on the launcher item will not influence the dragging of the shelf items. BUG=710601 ========== to ========== Make shelf item can be dragged when context menu is opened. Current context menu of shelf, 1) Allow dragging before context menu is created. 2) No dragging after context menu is opened. In order to keep the same as Android OS, 1) Allow dragging during the same press (don't release the finger) after context menu is opened. 2) Close the context menu once start dragging. Changes in this cl, 1. Add |SEND_UNHANDLED_GESTURES_TO_OWNER| in MenuRunner. This means the owner hopes that menu can help send the unhandled gesture events to the owner instead of dropping them. e.g, the context menu of the shelf items, and this is only true if shelf is not autohide. 2. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press which will create the context menu. 3. Handle the LONG_TAP events on shelf items. Since gesture events been transferred from shelf to MenuHost, but we don't want it will show the context menu again. 4. Add set_run_types() in ShelfView, since only shelf button need to transfer events from menu back to the owner. BUG=710601,748253 ==========
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Hi, I just changed the logic in ShelfView. I think we only need to transfer the events for shelf button, so I removed the logic in ShelfView before to ShelfButton in the latest ps. And added set_run_types() in ShelfView.
On 2017/09/01 03:37:34, minch1 wrote: > Hi, I just changed the logic in ShelfView. I think we only need to transfer the > events for shelf button, so I removed the logic in ShelfView before to > ShelfButton in the latest ps. And added set_run_types() in ShelfView. I don't like having a run_types_ memeber and friends. It makes code hard to follow. What problems do you encounter when we set SEND_GESTURE_EVENTS_TO_OWNER for all menus? The forwarded gesture events should be ignore if we are not dragging an item, right?
On 2017/09/01 17:13:54, xiyuan wrote: > On 2017/09/01 03:37:34, minch1 wrote: > > Hi, I just changed the logic in ShelfView. I think we only need to transfer > the > > events for shelf button, so I removed the logic in ShelfView before to > > ShelfButton in the latest ps. And added set_run_types() in ShelfView. > > I don't like having a run_types_ memeber and friends. It makes code hard to > follow. What problems do you encounter when we set SEND_GESTURE_EVENTS_TO_OWNER > for all menus? The forwarded gesture events should be ignore if we are not > dragging an item, right? If we set SEND_GESTURE_EVENTS_TO_OWNER for all the shelf view context menus. Then if we long press the blank area of the shelf will show the context menu, and then continue to drag which will close the context menu and continue to drag the new launcher from the shelf. Since we don't require the feature currently, I made it to set the flag only for ShelfButton.
On 2017/09/01 17:55:20, minch1 wrote: > On 2017/09/01 17:13:54, xiyuan wrote: > > On 2017/09/01 03:37:34, minch1 wrote: > > > Hi, I just changed the logic in ShelfView. I think we only need to transfer > > the > > > events for shelf button, so I removed the logic in ShelfView before to > > > ShelfButton in the latest ps. And added set_run_types() in ShelfView. > > > > I don't like having a run_types_ memeber and friends. It makes code hard to > > follow. What problems do you encounter when we set > SEND_GESTURE_EVENTS_TO_OWNER > > for all menus? The forwarded gesture events should be ignore if we are not > > dragging an item, right? > > If we set SEND_GESTURE_EVENTS_TO_OWNER for all the shelf view context menus. > Then > if we long press the blank area of the shelf will show the context menu, and > then continue to drag which will close the context menu and continue to drag the > new > launcher from the shelf. Since we don't require the feature currently, I made it > to set the flag only for ShelfButton. Can you do a ShelfItemForView on the |source| arg for ShelfView::ShowMenu and only set the flag when we can get an underlying ShelfItem?
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2017/09/01 18:02:31, xiyuan wrote: > On 2017/09/01 17:55:20, minch1 wrote: > > On 2017/09/01 17:13:54, xiyuan wrote: > > > On 2017/09/01 03:37:34, minch1 wrote: > > > > Hi, I just changed the logic in ShelfView. I think we only need to > transfer > > > the > > > > events for shelf button, so I removed the logic in ShelfView before to > > > > ShelfButton in the latest ps. And added set_run_types() in ShelfView. > > > > > > I don't like having a run_types_ memeber and friends. It makes code hard to > > > follow. What problems do you encounter when we set > > SEND_GESTURE_EVENTS_TO_OWNER > > > for all menus? The forwarded gesture events should be ignore if we are not > > > dragging an item, right? > > > > If we set SEND_GESTURE_EVENTS_TO_OWNER for all the shelf view context menus. > > Then > > if we long press the blank area of the shelf will show the context menu, and > > then continue to drag which will close the context menu and continue to drag > the > > new > > launcher from the shelf. Since we don't require the feature currently, I made > it > > to set the flag only for ShelfButton. > > Can you do a ShelfItemForView on the |source| arg for ShelfView::ShowMenu and > only set the flag when we can get an underlying ShelfItem? Updated to check that only if selected item is ShelfButton and showing context menu, then we should set SEND_GESTURE_EVENTS_TO_OWNER.
PS22 lgtm
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Description was changed from ========== Make shelf item can be dragged when context menu is opened. Current context menu of shelf, 1) Allow dragging before context menu is created. 2) No dragging after context menu is opened. In order to keep the same as Android OS, 1) Allow dragging during the same press (don't release the finger) after context menu is opened. 2) Close the context menu once start dragging. Changes in this cl, 1. Add |SEND_UNHANDLED_GESTURES_TO_OWNER| in MenuRunner. This means the owner hopes that menu can help send the unhandled gesture events to the owner instead of dropping them. e.g, the context menu of the shelf items, and this is only true if shelf is not autohide. 2. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press which will create the context menu. 3. Handle the LONG_TAP events on shelf items. Since gesture events been transferred from shelf to MenuHost, but we don't want it will show the context menu again. 4. Add set_run_types() in ShelfView, since only shelf button need to transfer events from menu back to the owner. BUG=710601,748253 ========== to ========== Make shelf item can be dragged when context menu is opened. Current context menu of shelf, 1) Allow dragging before context menu is created. 2) No dragging after context menu is opened. In order to keep the same as Android OS, 1) Allow dragging during the same press (don't release the finger) after context menu is opened. 2) Close the context menu once start dragging. Changes in this cl, 1. Add |SEND_UNHANDLED_GESTURES_TO_OWNER| in MenuRunner. This means the owner hopes that menu can help send the unhandled gesture events to the owner instead of dropping them. e.g, the context menu of the shelf items, and this is only true if shelf is not autohide. 2. Transfer events from owner to menu host if the owner needs gesture events. vice verse. e.g. Shelf items hope can be dragged after long press which will create the context menu. 3. Handle the LONG_TAP events on shelf items. Since gesture events been transferred from shelf to MenuHost, but we don't want it will show the context menu again. BUG=710601,748253 ==========
Sorry, I do not actively look at rietveld anymore. Please feel free to ping over im when the CL is ready for review. https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:134: owner_ = parent; On 2017/08/31 23:21:02, minch1 wrote: > On 2017/08/30 20:31:39, sadrul wrote: > > What if |owner_| is destroyed after the menu comes up? If we expect it won't > > happen, can we validate that (e.g. add some DCHECK()s somewhere)? > > Added DCHECK(owner()) when we need to send events back in > MenuController::OnGestureEvent. In HideMenuHost checked the owner_ before > transfer events back to the owner. If |owner_| is destroyed, the DCHECK() won't hit though, right? So that DCHECK() is not really verifying that we are using an existing owner.
https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... File ui/views/controls/menu/menu_host.cc (right): https://codereview.chromium.org/2876203003/diff/340001/ui/views/controls/menu... ui/views/controls/menu/menu_host.cc:134: owner_ = parent; On 2017/09/07 19:58:28, sadrul wrote: > On 2017/08/31 23:21:02, minch1 wrote: > > On 2017/08/30 20:31:39, sadrul wrote: > > > What if |owner_| is destroyed after the menu comes up? If we expect it won't > > > happen, can we validate that (e.g. add some DCHECK()s somewhere)? > > > > Added DCHECK(owner()) when we need to send events back in > > MenuController::OnGestureEvent. In HideMenuHost checked the owner_ before > > transfer events back to the owner. > > If |owner_| is destroyed, the DCHECK() won't hit though, right? So that DCHECK() > is not really verifying that we are using an existing owner. Do you mean that |parent| is destroyed after assigned to |owner_| here? But in HideMenuHost we may still transfer events back to a not exist |parent|?
The CQ bit was checked by minch@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run. |
