Skip to content

Commit

Permalink
fix: jittering when draggin quick action applet
Browse files Browse the repository at this point in the history
修改后拖拽时将不会实时改变overlayWindow的尺寸,避免了拖拽时产生的不流畅效果。但旧的模糊效果将无法使用,模糊需求需要重新实现。

补充了部分关于开启模糊时拖拽事件不生效的原因的描述。

Log:
  • Loading branch information
RigoLigoRLC authored and BLumia committed Jan 17, 2025
1 parent 178d790 commit d83d3c6
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions panels/dock/tray/quickpanel/DragItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
}
}
Expand Down

0 comments on commit d83d3c6

Please sign in to comment.