fix: fall back to Qt default drag for wayland quick panel#1625
Merged
Conversation
In Wayland environment, the custom DQuickDrag overlay window causes issues with the quick panel drag functionality. This change forces DQuickDrag to be inactive on non-X11 platforms, falling back to Qt's native drag which uses the automatic image source. Additionally, the Drag properties (imageSource and hotSpot) are only set when not on XCB, as Qt's automatic drag handles these correctly on Wayland. Log: Disable custom drag overlay on Wayland for quick panel items Influence: 1. Test quick panel item drag on X11 session to ensure custom overlay still works 2. Test quick panel item drag on Wayland session to verify Qt default drag works 3. Check that the drag image and hotspot are positioned correctly on both platforms 4. Verify no visual glitches or crashes during drag operations fix: wayland下快捷面板拖拽回退到qt默认拖拽 在wayland环境下,自定义DQuickDrag覆盖窗口会导致快捷面板拖拽功能出现问 题。此修改强制在非X11平台上禁用DQuickDrag,回退到使用自动图片源的Qt原生 拖拽。同时,Drag属性(imageSource和hotSpot)仅在不使用XCB时设置,因为Qt 的自动拖拽在wayland上能正确处理这些属性。 Log: 在wayland上禁用快捷面板项目的自定义拖拽覆盖 Influence: 1. 在X11会话中测试快捷面板项目拖拽,确保自定义覆盖仍正常工作 2. 在wayland会话中测试快捷面板项目拖拽,验证Qt默认拖拽功能正常 3. 检查两个平台下拖拽图片和热点位置是否正确 4. 验证拖拽操作过程中无视觉异常或崩溃 PMS: BUG-346735
There was a problem hiding this comment.
Sorry @18202781743, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
deepin pr auto review我来对这段代码进行审查,并提出改进意见: 语法逻辑
代码质量
代码性能
代码安全
改进建议
// 缓存平台判断结果
property bool isXcbPlatform: Qt.platform.pluginName === "xcb"
// 使用缓存的平台判断
if (!isXcbPlatform) {
dragItem.Drag.imageSource = Qt.binding(function () {
return root.draggingImage
})
dragItem.Drag.hotSpot.x = Qt.binding(function () {
return dragItem.width / 2
})
dragItem.Drag.hotSpot.y = Qt.binding(function () {
return dragItem.height / 2
})
}
// 使用缓存的平台判断
dragItem.DQuickDrag.active = Qt.binding(function () {
return dragItem.Drag.active && isXcbPlatform
})
// 添加注释说明平台相关代码的目的
// XCB平台特定的拖拽行为配置
if (!isXcbPlatform) {
// 配置拖拽图像和热点位置
dragItem.Drag.imageSource = Qt.binding(function () {
return root.draggingImage
})
dragItem.Drag.hotSpot.x = Qt.binding(function () {
return dragItem.width / 2
})
dragItem.Drag.hotSpot.y = Qt.binding(function () {
return dragItem.height / 2
})
}
// 仅在XCB平台启用拖拽
dragItem.DQuickDrag.active = Qt.binding(function () {
return dragItem.Drag.active && isXcbPlatform
})
// 添加错误处理
property bool isXcbPlatform: Qt.platform.pluginName === "xcb"
// 安全地访问root.draggingImage
function getDraggingImage() {
try {
return root ? root.draggingImage : null
} catch (e) {
console.error("Error accessing draggingImage:", e)
return null
}
}
if (!isXcbPlatform) {
dragItem.Drag.imageSource = Qt.binding(function () {
return getDraggingImage()
})
// ... 其他代码
}
// 将平台相关代码封装到单独的函数中
function setupDragForPlatform() {
if (isXcbPlatform) {
setupXcbDrag()
} else {
setupNonXcbDrag()
}
}
function setupXcbDrag() {
dragItem.DQuickDrag.active = Qt.binding(function () {
return dragItem.Drag.active
})
}
function setupNonXcbDrag() {
dragItem.Drag.imageSource = Qt.binding(function () {
return root.draggingImage
})
dragItem.Drag.hotSpot.x = Qt.binding(function () {
return dragItem.width / 2
})
dragItem.Drag.hotSpot.y = Qt.binding(function () {
return dragItem.height / 2
})
dragItem.DQuickDrag.active = Qt.binding(function () {
return dragItem.Drag.active
})
}
// 在组件加载时调用
Component.onCompleted: setupDragForPlatform()这些改进可以提高代码的性能、可读性和可维护性,同时保持原有的功能不变。 |
BLumia
approved these changes
Jun 9, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In Wayland environment, the custom DQuickDrag overlay window causes
issues with the quick panel drag functionality. This change forces
DQuickDrag to be inactive on non-X11 platforms, falling back to Qt's
native drag which uses the automatic image source. Additionally, the
Drag properties (imageSource and hotSpot) are only set when not on XCB,
as Qt's automatic drag handles these correctly on Wayland.
Log: Disable custom drag overlay on Wayland for quick panel items
Influence:
still works
drag works
both platforms
fix: wayland下快捷面板拖拽回退到qt默认拖拽
在wayland环境下,自定义DQuickDrag覆盖窗口会导致快捷面板拖拽功能出现问
题。此修改强制在非X11平台上禁用DQuickDrag,回退到使用自动图片源的Qt原生
拖拽。同时,Drag属性(imageSource和hotSpot)仅在不使用XCB时设置,因为Qt
的自动拖拽在wayland上能正确处理这些属性。
Log: 在wayland上禁用快捷面板项目的自定义拖拽覆盖
Influence:
PMS: BUG-346735