From 824cfd979affc41441cac7a5518e9c0a671c42a8 Mon Sep 17 00:00:00 2001 From: zhaoyingzhen Date: Thu, 26 Feb 2026 11:42:58 +0800 Subject: [PATCH] fix(bubble): use frontendWindowRect for dock margin to avoid overlap during animations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use frontendWindowRect instead of hideState to calculate the dock margin for the notification bubble window. This ensures the bubble's margin accurately tracks the dock's actual visual position during hide/show animations, preventing overlap between the bubble and the dock during state transitions (e.g., switching from KeepShowing to SmartHide). The margin is capped at dockSize to prevent incorrect values during dock position transitions, where frontendWindowRect may temporarily have wrong dimensions because position() changes immediately but the window geometry hasn't updated yet. 修复通知气泡窗口与 dock 动画过程中重叠的问题。 当 dock 从一直显示切换为智能隐藏时,hideState 在动画开始前就已经 变为 Hide,导致 bubble 的 windowMargin 立即变为 0,bubble 窗口 跳到屏幕底端,与仍在动画中的 dock 窗口产生重叠。 改为使用 frontendWindowRect 计算 dock 的实际可见区域,该属性在 动画过程中会实时更新,能准确反映 dock 的当前视觉位置。同时使用 dockSize 对 margin 进行封顶,防止 dock 切换位置时 frontendWindowRect 因时序问题产生错误的中间值。 Log: 修复通知气泡窗口与 dock 动画过程中重叠的问题。 Pms: BUG-350927 --- panels/notification/bubble/package/main.qml | 49 ++++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/panels/notification/bubble/package/main.qml b/panels/notification/bubble/package/main.qml index b538af501..80ccac395 100644 --- a/panels/notification/bubble/package/main.qml +++ b/panels/notification/bubble/package/main.qml @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later @@ -20,14 +20,51 @@ Window { let dockScreen = dockApplet.screenName let screen = root.screen.name - let dockHideState = dockApplet.hideState - let dockIsHide = dockHideState === 2 - if (dockScreen !== screen || dockIsHide) + if (dockScreen !== screen) return 0 - let dockSize = dockApplet.rootObject.dockSize let dockPosition = dockApplet.position - return dockPosition === position ? dockSize : 0 + if (dockPosition !== position) + return 0 + + // Use frontendWindowRect to calculate the actual visible dock area, + // so the margin accurately tracks dock position during hide/show animations + let frontendRect = dockApplet.frontendWindowRect + let dpr = root.screen.devicePixelRatio + let dockGeometry = Qt.rect( + frontendRect.x / dpr, + frontendRect.y / dpr, + frontendRect.width / dpr, + frontendRect.height / dpr + ) + + let screenGeometry = Qt.rect( + root.screen.virtualX, + root.screen.virtualY, + root.screen.width, + root.screen.height + ) + + // Cap margin at dockSize to prevent incorrect values during position transitions + // (when frontendWindowRect may temporarily have wrong dimensions because + // position() changes immediately but window geometry hasn't updated yet) + let dockSize = dockApplet.dockSize + + switch (position) { + case 0: { // DOCK_TOP + let visibleHeight = Math.max(0, dockGeometry.y + dockGeometry.height - screenGeometry.y) + return Math.min(visibleHeight, dockSize) + } + case 1: { // DOCK_RIGHT + let visibleWidth = Math.max(0, screenGeometry.x + screenGeometry.width - dockGeometry.x) + return Math.min(visibleWidth, dockSize) + } + case 2: { // DOCK_BOTTOM + let visibleHeight = Math.max(0, screenGeometry.y + screenGeometry.height - dockGeometry.y) + return Math.min(visibleHeight, dockSize) + } + return 0 + } } visible: Applet.visible