-
Notifications
You must be signed in to change notification settings - Fork 58
fix: improve notification center margin calculation #1363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,22 +12,51 @@ import org.deepin.ds.notificationcenter | |
|
|
||
| Window { | ||
| id: root | ||
|
|
||
| property var dockApplet: DS.applet("org.deepin.ds.dock") | ||
| property rect frontendRect: dockApplet ? dockApplet.frontendWindowRect : Qt.rect(0, 0, 0, 0) | ||
wjyrich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| function windowMargin(position) { | ||
| let dockApplet = DS.applet("org.deepin.ds.dock") | ||
wjyrich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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
|
||
|
|
||
| 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 | ||
wjyrich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
wjyrich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return 0 | ||
| } | ||
wjyrich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // visible: true | ||
|
|
@@ -78,6 +107,9 @@ Window { | |
| function onRequestClosePopup() { | ||
| Panel.close() | ||
| } | ||
| function onFrontendWindowRectChanged(frontendWindowRect) { | ||
| root.frontendRect = frontendWindowRect | ||
| } | ||
| } | ||
|
|
||
| Item { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你需要的只是个时机,不是真正的值,应该不需要保留这个dockApplet属性,第一次应该也不需要从dockApplet里去调用,这样绑定大概率是个空的,