From 80cd403825219c3bdfe10d896964d2d5d310eae6 Mon Sep 17 00:00:00 2001 From: reionwong Date: Sun, 30 Aug 2026 11:30:25 -0400 Subject: [PATCH] fix: adapt the desktop and the path bar to Wayland --- model/foldermodel.cpp | 1 - qml/Desktop/Wallpaper.qml | 1 + qml/FolderGridView.qml | 4 --- qml/PathBar.qml | 61 +++++++++++++++++++++++++++++++++++++-- 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/model/foldermodel.cpp b/model/foldermodel.cpp index e07af5f..30cc5d0 100644 --- a/model/foldermodel.cpp +++ b/model/foldermodel.cpp @@ -1341,7 +1341,6 @@ void FolderModel::openContextMenu(QQuickItem *visualParent, Qt::KeyboardModifier menu->installEventFilter(this); menu->setAttribute(Qt::WA_TranslucentBackground); - menu->winId(); m_contextMenu = menu; menu->popup(position); diff --git a/qml/Desktop/Wallpaper.qml b/qml/Desktop/Wallpaper.qml index f52664a..4f3077a 100644 --- a/qml/Desktop/Wallpaper.qml +++ b/qml/Desktop/Wallpaper.qml @@ -35,6 +35,7 @@ Item { id: wallpaper Image { + anchors.fill: parent source: "file://" + settings.wallpaper sourceSize: Qt.size(width * Screen.devicePixelRatio, height * Screen.devicePixelRatio) diff --git a/qml/FolderGridView.qml b/qml/FolderGridView.qml index 622863a..247e8fd 100644 --- a/qml/FolderGridView.qml +++ b/qml/FolderGridView.qml @@ -470,10 +470,6 @@ GridView { onClicked: { clearPressState() - - if (mouse.buttons & Qt.RightButton) { - dirModel.openContextMenu(null, mouse.modifiers) - } } onDoubleClicked: { diff --git a/qml/PathBar.qml b/qml/PathBar.qml index 24ef2dd..34c743b 100644 --- a/qml/PathBar.qml +++ b/qml/PathBar.qml @@ -19,6 +19,7 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 +import QtQuick.Window 2.12 import Qt5Compat.GraphicalEffects import Cutefish.FileManager 1.0 @@ -32,6 +33,17 @@ Item { signal itemClicked(string path) signal editorAccepted(string path) + // The path bar is part of the title bar. Start the Wayland move on the + // initial press, while retaining the single-click path editor behavior. + property bool _dragged: false + property real _pressX: 0 + property real _pressY: 0 + + function startWindowMove() { + if (Window.window && Window.window.helper) + Window.window.helper.startSystemMove(Window.window) + } + Rectangle { anchors.fill: parent color: FishUI.Theme.darkMode ? Qt.lighter(FishUI.Theme.secondBackgroundColor, 1.3) @@ -45,7 +57,34 @@ Item { MouseArea { anchors.fill: parent acceptedButtons: Qt.LeftButton - onClicked: openEditor() + onPressed: { + _dragged = false + _pressX = mouse.x + _pressY = mouse.y + control.startWindowMove() + } + onPositionChanged: { + if (Math.abs(mouse.x - _pressX) > 4 || Math.abs(mouse.y - _pressY) > 4) + _dragged = true + } + onCanceled: _dragged = true + onClicked: { + if (!_dragged) + openEditor() + } + } + + // Keep the original title-bar behavior: once the pointer crosses the + // drag threshold, take over from a breadcrumb MouseArea and cancel its + // click. The immediate move request above is still needed by Wayland; + // the handler provides the same click-vs-drag semantics as X11. + DragHandler { + target: null + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad + grabPermissions: PointerHandler.CanTakeOverFromItems + | PointerHandler.CanTakeOverFromHandlersOfDifferentType + | PointerHandler.ApprovesTakeOverByAnything + onActiveChanged: if (active) _dragged = true } ListView { @@ -85,7 +124,25 @@ Item { property bool selected: index === _pathView.count - 1 - onClicked: control.itemClicked(model.path) + property bool dragged: false + property real pressX: 0 + property real pressY: 0 + + onPressed: { + dragged = false + pressX = mouse.x + pressY = mouse.y + control.startWindowMove() + } + onPositionChanged: { + if (Math.abs(mouse.x - pressX) > 4 || Math.abs(mouse.y - pressY) > 4) + dragged = true + } + onCanceled: dragged = true + onClicked: { + if (!dragged) + control.itemClicked(model.path) + } Rectangle { anchors.fill: parent