From 60e5d006d880bcf5d0da3504fa4b1fc6df547742 Mon Sep 17 00:00:00 2001 From: Ivy233 Date: Tue, 17 Mar 2026 17:36:17 +0800 Subject: [PATCH] fix(tray): pre-create stashed popup to eliminate first-open lag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pre-create the stashed tray popup during initialization to avoid lag when first opening it, especially noticeable at high DPI scales (225%). The popup is opened with zero opacity during startup and closed after 200ms, ensuring all components are fully initialized. This eliminates the frame drops and stuttering that occurred when hovering over or clicking the application tray button for the first time. 修复系统托盘折叠弹窗首次打开时的卡顿问题。在初始化时预创建弹窗, 通过设置透明度为0在后台完成组件初始化和渲染,避免首次打开时的 帧率下降和卡顿,特别是在高DPI缩放(225%)下的表现。 PMS: BUG-344705 --- panels/dock/tray/package/tray.qml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/panels/dock/tray/package/tray.qml b/panels/dock/tray/package/tray.qml index e6c9a0303..66e3abeff 100644 --- a/panels/dock/tray/package/tray.qml +++ b/panels/dock/tray/package/tray.qml @@ -43,6 +43,9 @@ AppletItem { property alias dropHover: stashContainer.dropHover property alias stashItemDragging: stashContainer.stashItemDragging + property bool preCreating: false + + opacity: preCreating ? 0 : 1 popupX: DockPanelPositioner.x popupY: DockPanelPositioner.y @@ -79,8 +82,25 @@ AppletItem { DockPanelPositioner.bounding = Qt.binding(function () { return Qt.rect(collapsedBtnCenterPoint.x, collapsedBtnCenterPoint.y, stashedPopup.width, stashedPopup.height) }) + // Pre-create popup to avoid first-open lag + Qt.callLater(function() { + stashedPopup.preCreating = true + stashedPopup.open() + preCreateCloseTimer.start() + }) } } + + Timer { + id: preCreateCloseTimer + interval: 200 + repeat: false + onTriggered: { + stashedPopup.close() + stashedPopup.preCreating = false + } + } + Connections { target: DDT.TraySortOrderModel function onActionsAlwaysVisibleChanged(val) {