Skip to content

Commit 3b69176

Browse files
committed
fix(notification): fall back to dockSize when frontendWindowRect is not ready
When frontendWindowRect is (0,0,0,0) (not yet computed), use dockSize as margin instead of returning 0. This ensures the notification window has the correct margin from the first display, without relying on timers. The Connections block will later refresh with the precise value once frontendWindowRect becomes available.
1 parent 8432d1d commit 3b69176

1 file changed

Lines changed: 9 additions & 29 deletions

File tree

  • panels/notification/bubble/package

panels/notification/bubble/package/main.qml

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ Window {
3131
if (dockPosition !== position)
3232
return 0
3333

34-
// Use frontendWindowRect to calculate the actual visible dock area,
35-
// so the margin accurately tracks dock position during hide/show animations
34+
let dockSize = dockApplet.dockSize
35+
36+
// When frontendWindowRect is not yet computed (0,0,0,0), fall back to
37+
// dockSize. The Connections block will refresh margins once the rect
38+
// becomes available, giving the precise value.
3639
let frontendRect = dockApplet.frontendWindowRect
40+
if (frontendRect.width === 0 && frontendRect.height === 0)
41+
return dockSize
42+
3743
let dpr = root.screen.devicePixelRatio
3844
let dockGeometry = Qt.rect(
3945
frontendRect.x / dpr,
@@ -49,11 +55,6 @@ Window {
4955
root.screen.height
5056
)
5157

52-
// Cap margin at dockSize to prevent incorrect values during position transitions
53-
// (when frontendWindowRect may temporarily have wrong dimensions because
54-
// position() changes immediately but window geometry hasn't updated yet)
55-
let dockSize = dockApplet.dockSize
56-
5758
switch (position) {
5859
case 0: { // DOCK_TOP
5960
let visibleHeight = Math.max(0, dockGeometry.y + dockGeometry.height - screenGeometry.y)
@@ -90,29 +91,8 @@ Window {
9091
onDockAppletChanged: refreshDockMargins()
9192
Component.onCompleted: refreshDockMargins()
9293
onVisibleChanged: {
93-
if (visible) {
94+
if (visible)
9495
refreshDockMargins()
95-
// The dock's frontendWindowRect is computed asynchronously via
96-
// QMetaObject::invokeMethod, so it may not be ready when we first
97-
// become visible. Poll until margins are non-zero or timeout.
98-
if (dockMarginTop === 0 && dockMarginRight === 0 && dockMarginBottom === 0)
99-
startupMarginTimer.start()
100-
}
101-
}
102-
103-
Timer {
104-
id: startupMarginTimer
105-
interval: 200
106-
repeat: true
107-
property int attempts: 0
108-
onTriggered: {
109-
root.refreshDockMargins()
110-
attempts++
111-
if ((root.dockMarginTop !== 0 || root.dockMarginRight !== 0 || root.dockMarginBottom !== 0) || attempts >= 15) {
112-
stop()
113-
attempts = 0
114-
}
115-
}
11696
}
11797

11898
visible: Applet.visible

0 commit comments

Comments
 (0)