From 74f34056b2e31091e264b36c06856c14ac817ae6 Mon Sep 17 00:00:00 2001 From: RigoLigo Date: Mon, 21 Oct 2024 16:11:27 +0800 Subject: [PATCH] fix: jittering when draggin quick action applet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改后拖拽时将不会实时改变overlayWindow的尺寸,避免了拖拽时产生的不流畅效果。但旧的模糊效果将无法使用,模糊需求需要重新实现。 补充了部分关于开启模糊时拖拽事件不生效的原因的描述。 Log: --- panels/dock/tray/quickpanel/DragItem.qml | 32 +++++++++++++++++------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/panels/dock/tray/quickpanel/DragItem.qml b/panels/dock/tray/quickpanel/DragItem.qml index 18279b8a8..85f739a6e 100644 --- a/panels/dock/tray/quickpanel/DragItem.qml +++ b/panels/dock/tray/quickpanel/DragItem.qml @@ -43,24 +43,28 @@ Item { property size fallbackIconSize: Qt.size(16, 16) property Component overlayWindow: QuickDragWindow { + id: overlayWindow property size dragItemSize property point startDragPoint property point currentDragPoint property int endDragPointArea + // This no longer changes window size (due to visual artifacts), but rather controls component image size. + property real overlayWindowHeight: getHeight() property bool isFallbackIcon: { - return height <= root.fallbackIconSize.height + return overlayWindowHeight <= root.fallbackIconSize.height } startDragPoint: dragItem.DQuickDrag.startDragPoint currentDragPoint: dragItem.DQuickDrag.currentDragPoint dragItemSize: Qt.size(dragItem.width, dragItem.height) endDragPointArea: { - return Panel.rootObject.y - root.fallbackIconSize.height * dragItem.DQuickDrag.hotSpotScale.height + return Panel.rootObject.y - (root.fallbackIconSize.height + dragItem.height) * dragItem.DQuickDrag.hotSpotScale.height } // Height and position follow linear transformation, y = k * h + b. // and (y, h) exist two rules, (start.y, drag.h) and (end.y, 16) function getHeight() { + console.log(currentDragPoint) if (currentDragPoint.y < startDragPoint.y) return dragItemSize.height if (currentDragPoint.y > endDragPointArea) @@ -72,31 +76,41 @@ Item { return h } - // TODO: turn on this can cause DnD drag event get rejected, it's likely a dxcb bug. + // FIXME: Since we attempted fixing the drag jitter of quick controls (caused by the constantly changing window + // size & position, and the composition delays following that) by using a fixed window size and change only + // the drag image size, the old blur-behind implementation will no longer work (blur area will be larger than + // the drag image). Using StyledBehindWindowBlur to fill the Image component will result in inconsistent corner + // radius, so that part is also not enabled in the code. + // TODO: turning this on results in the input transparency property of the drag window not being respected, + // causing DnD events being delivered to not the tray, but the drag window itself. Using StyledBehindWindowBlur + // to fill the Image component also causes this bug, so blur-behind is currently not enabled. // DWindow.enabled: true // DWindow.enableBlurWindow: !isFallbackIcon // DWindow.shadowRadius: 0 // DWindow.borderWidth: 0 ColorSelector.family: Palette.CrystalColor - height: getHeight() - width: !isFallbackIcon ? (dragItemSize.width * 1.0 / dragItemSize.height) * height : root.fallbackIconSize.width + height: dragItemSize.height + width: dragItemSize.width + Loader { active: !isFallbackIcon - anchors.fill: parent - + anchors.centerIn: parent sourceComponent: Image { source: root.draggingImage + height: overlayWindow.overlayWindowHeight + width: (dragItemSize.width * 1.0 / dragItemSize.height) * height } } Loader { active: isFallbackIcon && root.dragItem.DQuickDrag.isDragging - anchors.fill: parent + anchors.centerIn: parent sourceComponent: ShellSurfaceItemProxy { - anchors.centerIn: parent shellSurface: root.fallbackDragImage + width: root.fallbackIconSize.width + height: root.fallbackIconSize.height } } }