From 1570ac24c8c2421843eb95c16a49ee3a6bc5e682 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Sat, 13 Jul 2024 22:16:13 -0400 Subject: [PATCH] homescreens/folio: Make it easier to click on delegate context menus without starting drag Dragging delegates on the homescreen involves holding onto it until the context menu pops up, and then dragging. We currently suppress swipe detection (physically swipe a few pixels before the swipe gets registered) when dragging a delegate so that dragging can start immediately. However, this doesn't make sense if a context menu gets involved, because it can be hard to "let go" to tap the context menu without accidentally triggering the drag action and closing the context menu. This MR re-enables swipe detection if a context menu is involved with delegate dragging. --- .../folio/package/contents/ui/AppDrawerGrid.qml | 2 +- .../homescreens/folio/package/contents/ui/HomeScreen.qml | 9 +++++++-- .../package/contents/ui/settings/AppletListViewer.qml | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/containments/homescreens/folio/package/contents/ui/AppDrawerGrid.qml b/containments/homescreens/folio/package/contents/ui/AppDrawerGrid.qml index dff54dec..04ee8813 100644 --- a/containments/homescreens/folio/package/contents/ui/AppDrawerGrid.qml +++ b/containments/homescreens/folio/package/contents/ui/AppDrawerGrid.qml @@ -91,7 +91,7 @@ MobileShell.GridView { height: root.cellHeight onPressAndHold: { - const mappedCoords = root.homeScreen.prepareStartDelegateDrag(model.delegate, appDelegate.delegateItem); + const mappedCoords = root.homeScreen.prepareStartDelegateDrag(model.delegate, appDelegate.delegateItem, true); folio.HomeScreenState.closeAppDrawer(); // we need to adjust because app drawer delegates have a different size than regular homescreen delegates diff --git a/containments/homescreens/folio/package/contents/ui/HomeScreen.qml b/containments/homescreens/folio/package/contents/ui/HomeScreen.qml index 5e9e7338..69f4b464 100644 --- a/containments/homescreens/folio/package/contents/ui/HomeScreen.qml +++ b/containments/homescreens/folio/package/contents/ui/HomeScreen.qml @@ -45,8 +45,13 @@ Item { // called by any delegates when starting drag // returns the mapped coordinates to be used in the home screen state - function prepareStartDelegateDrag(delegate, item) { - swipeArea.setSkipSwipeThreshold(true); + function prepareStartDelegateDrag(delegate, item, skipSwipeThreshold) { + + // If the user is prompted with a context menu, they may want to let go, and so we keep the detect swipe threshold. + // Otherwise, we want to skip detecting a swipe because we know we immediately go into delegate dragging. + if (skipSwipeThreshold) { + swipeArea.setSkipSwipeThreshold(true); + } if (delegate) { delegateDragItem.delegate = delegate; diff --git a/containments/homescreens/folio/package/contents/ui/settings/AppletListViewer.qml b/containments/homescreens/folio/package/contents/ui/settings/AppletListViewer.qml index b28301bd..ad5863a7 100644 --- a/containments/homescreens/folio/package/contents/ui/settings/AppletListViewer.qml +++ b/containments/homescreens/folio/package/contents/ui/settings/AppletListViewer.qml @@ -119,7 +119,7 @@ MouseArea { root.requestClose(); folio.HomeScreenState.closeSettingsView(); - let mappedCoords = root.homeScreen.prepareStartDelegateDrag(null, delegate); + let mappedCoords = root.homeScreen.prepareStartDelegateDrag(null, delegate, true); const widthOffset = folio.HomeScreenState.pageCellWidth / 2; const heightOffset = folio.HomeScreenState.pageCellHeight / 2;