Skip to content

Commit 2fb8456

Browse files
committed
fix: incorrect position of panel for notification
Using screenName instead of position to adjust dock and notification is on the same screen. Bug: https://pms.uniontech.com/bug-view-284191.html
1 parent 8bb8dab commit 2fb8456

File tree

4 files changed

+21
-26
lines changed

4 files changed

+21
-26
lines changed

panels/dock/dockpanel.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,14 @@ void DockPanel::setDockScreen(QScreen *screen)
382382
m_dockScreen = screen;
383383
window()->setScreen(m_dockScreen);
384384
Q_EMIT dockScreenChanged(m_dockScreen);
385+
Q_EMIT screenNameChanged();
386+
}
387+
388+
QString DockPanel::screenName() const
389+
{
390+
if (!m_dockScreen)
391+
return {};
392+
return m_dockScreen->name();
385393
}
386394
}
387395

panels/dock/dockpanel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
3131
Q_PROPERTY(ItemAlignment itemAlignment READ itemAlignment WRITE setItemAlignment NOTIFY itemAlignmentChanged FINAL)
3232
Q_PROPERTY(IndicatorStyle indicatorStyle READ indicatorStyle WRITE setIndicatorStyle NOTIFY indicatorStyleChanged FINAL)
3333
Q_PROPERTY(bool showInPrimary READ showInPrimary WRITE setShowInPrimary NOTIFY showInPrimaryChanged FINAL)
34+
Q_PROPERTY(QString screenName READ screenName NOTIFY screenNameChanged FINAL)
3435

3536
Q_PROPERTY(bool debugMode READ debugMode FINAL CONSTANT)
3637

@@ -79,6 +80,7 @@ class DockPanel : public DS_NAMESPACE::DPanel, public QDBusContext
7980
void setHideState(HideState newHideState);
8081
QScreen* dockScreen();
8182
void setDockScreen(QScreen *screen);
83+
QString screenName() const;
8284

8385
private Q_SLOTS:
8486
void onWindowGeometryChanged();
@@ -99,6 +101,7 @@ private Q_SLOTS:
99101
void indicatorStyleChanged(IndicatorStyle style);
100102
void showInPrimaryChanged(bool showInPrimary);
101103
void dockScreenChanged(QScreen *screen);
104+
void screenNameChanged();
102105
void requestClosePopup();
103106

104107
private:

panels/notification/bubble/package/main.qml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,18 @@ Window {
1818
if (!dockApplet)
1919
return 0
2020

21-
let dockRect = dockApplet.frontendWindowRect
22-
let rect = Qt.rect(root.screen.virtualX, root.screen.virtualY, root.screen.width, root.screen.height)
23-
if (!containsPos(rect, Qt.point(dockRect.x, dockRect.y)))
21+
let dockScreen = dockApplet.screenName
22+
let screen = root.screen.name
23+
let dockHideState = dockApplet.hideState
24+
let dockIsHide = dockHideState === 2
25+
if (dockScreen !== screen || dockIsHide)
2426
return 0
2527

2628
let dockSize = dockApplet.dockSize
2729
let dockPosition = dockApplet.position
2830
return dockPosition === position ? dockSize : 0
2931
}
3032

31-
function containsPos(rect1, pos) {
32-
if (rect1.x <= pos.x &&
33-
rect1.y <= pos.y &&
34-
(rect1.x + rect1.width > pos.x) &&
35-
(rect1.y + rect1.height > pos.y)) {
36-
return true
37-
}
38-
return false
39-
}
40-
4133
visible: Applet.visible
4234
width: 380
4335
height: Math.max(10, bubbleView.height + bubbleView.anchors.topMargin + bubbleView.anchors.bottomMargin)

panels/notification/center/package/main.qml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,18 @@ Window {
1717
if (!dockApplet)
1818
return 0
1919

20-
let dockRect = dockApplet.frontendWindowRect
21-
let rect = Qt.rect(root.screen.virtualX, root.screen.virtualY, root.screen.width, root.screen.height)
22-
if (!containsPos(rect, Qt.point(dockRect.x, dockRect.y)))
20+
let dockScreen = dockApplet.screenName
21+
let screen = root.screen.name
22+
let dockHideState = dockApplet.hideState
23+
let dockIsHide = dockHideState === 2
24+
if (dockScreen !== screen || dockIsHide)
2325
return 0
2426

2527
let dockSize = dockApplet.dockSize
2628
let dockPosition = dockApplet.position
2729
return dockPosition === position ? dockSize : 0
2830
}
2931

30-
function containsPos(rect1, pos) {
31-
if (rect1.x <= pos.x &&
32-
rect1.y <= pos.y &&
33-
(rect1.x + rect1.width > pos.x) &&
34-
(rect1.y + rect1.height > pos.y)) {
35-
return true
36-
}
37-
return false
38-
}
39-
4032
// visible: true
4133
visible: Panel.visible
4234
flags: Qt.Tool

0 commit comments

Comments
 (0)