Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions panels/notification/center/package/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,51 @@ import org.deepin.ds.notificationcenter

Window {
id: root

property var dockApplet: DS.applet("org.deepin.ds.dock")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你需要的只是个时机,不是真正的值,应该不需要保留这个dockApplet属性,第一次应该也不需要从dockApplet里去调用,这样绑定大概率是个空的,

property rect frontendRect: dockApplet ? dockApplet.frontendWindowRect : Qt.rect(0, 0, 0, 0)
function windowMargin(position) {
let dockApplet = DS.applet("org.deepin.ds.dock")
if (!dockApplet)
return 0

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.dockSize
let dockPosition = dockApplet.position
return dockPosition === position ? dockSize : 0
if (dockPosition !== position)
return 0

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
)
Comment on lines +39 to +44
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The screen geometry is recalculated every time updateMargins is called, even when only the dock's frontendRect changes. Since screen geometry changes are rare, consider caching the screen geometry and only recalculating it when the screen actually changes to improve performance.

Copilot uses AI. Check for mistakes.

switch (position) {
case 0: { // DOCK_TOP
let visibleHeight = Math.max(0, dockGeometry.y + dockGeometry.height - screenGeometry.y)
return Math.min(visibleHeight, dockGeometry.height)
}
case 1: { // DOCK_RIGHT
let visibleWidth = Math.max(0, screenGeometry.x + screenGeometry.width - dockGeometry.x)
return Math.min(visibleWidth, dockGeometry.width)
}
case 2: { // DOCK_BOTTOM
return dockApplet.dockSize
}
return 0
}
}

// visible: true
Expand Down Expand Up @@ -78,6 +107,9 @@ Window {
function onRequestClosePopup() {
Panel.close()
}
function onFrontendWindowRectChanged(frontendWindowRect) {
root.frontendRect = frontendWindowRect
}
}

Item {
Expand Down