Skip to content

Commit e8a2e57

Browse files
committed
fix: resolve abnormal compositor window size due to popup panel height change
Refactored the QML bindings handling the width and height of the popup window. By introducing requestedWidth and requestedHeight and explicitly passing them to the native window bounds via setWindowGeometry, we prevent uncoordinated and recurrent Wayland resize events from corrupting the compositor window geometries during dynamic plugin panel dimension adjustments. 修复:解决因弹出面板尺寸变化导致顶层合成器显示窗口大小异常的缺陷 重构了处理弹出面板宽高的 QML 绑定逻辑。通过引入 requestedWidth 和 requestedHeight 参数,并通过 setWindowGeometry 显式设置底层原 生窗口状态,可以避免在插件动态调整面板尺寸时,高频和未协调的 Wayland 尺寸挂载事件破坏合成器渲染的窗口几何形状。 Log: resolve abnormal compositor window size due to popup panel height change Pms: BUG-307129 BUG-336777
1 parent c044407 commit e8a2e57

4 files changed

Lines changed: 27 additions & 9 deletions

File tree

frame/popupwindow.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ PopupWindow::PopupWindow(QWindow *parent)
2424
setMaximumSize();
2525
}
2626

27+
void PopupWindow::setWindowGeometry(int px, int py, int pw, int ph)
28+
{
29+
this->setGeometry(px, py, pw, ph);
30+
}
31+
2732
void PopupWindow::mouseReleaseEvent(QMouseEvent *event)
2833
{
2934
QQuickApplicationWindow::mouseReleaseEvent(event);

frame/popupwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class PopupWindow : public QQuickApplicationWindow
1616

1717
public:
1818
PopupWindow(QWindow *parent = nullptr);
19+
Q_INVOKABLE void setWindowGeometry(int px, int py, int pw, int ph);
1920

2021
protected:
2122
void mouseReleaseEvent(QMouseEvent *event) override;

frame/qml/PanelPopup.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ Item {
2020

2121
Binding {
2222
when: readyBinding
23-
target: popupWindow; property: "width"
23+
target: popupWindow; property: "requestedWidth"
2424
value: popup.width
2525
}
2626
Binding {
2727
when: readyBinding
28-
target: popupWindow; property: "height"
28+
target: popupWindow; property: "requestedHeight"
2929
value: popup.height
3030
}
3131
Binding {

frame/qml/PanelPopupWindow.qml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ PopupWindow {
1515
property real yOffset: 0
1616
property int margins: 10
1717
property Item currentItem
18+
property int requestedWidth: 10
19+
property int requestedHeight: 10
1820
signal requestUpdateGeometry()
1921
signal updateGeometryFinished()
2022

2123
// order to update screen and (x,y)
2224
property var updateGeometryer : function updateGeometry()
2325
{
24-
if (root.width <= 10 || root.height <= 10) {
25-
return
26+
if (root.requestedWidth <= 10 || root.requestedHeight <= 10) {
27+
root.width = root.requestedWidth;
28+
root.height = root.requestedHeight;
29+
return;
2630
}
2731
if (!root.transientParent)
2832
return
@@ -33,9 +37,11 @@ PopupWindow {
3337
let bounding = Qt.rect(root.screen.virtualX + margins, root.screen.virtualY + margins,
3438
root.screen.width - margins * 2, root.screen.height - margins * 2)
3539
let pos = Qt.point(transientParent ? transientParent.x + xOffset : xOffset,
36-
transientParent ? transientParent.y + yOffset : YOffset)
37-
x = selectValue(pos.x, bounding.left, bounding.right - root.width)
38-
y = selectValue(pos.y, bounding.top, bounding.bottom - root.height)
40+
transientParent ? transientParent.y + yOffset : yOffset)
41+
let newX = selectValue(pos.x, bounding.left, bounding.right - root.requestedWidth)
42+
let newY = selectValue(pos.y, bounding.top, bounding.bottom - root.requestedHeight)
43+
44+
root.setWindowGeometry(newX, newY, root.requestedWidth, root.requestedHeight)
3945
}
4046

4147
function selectValue(value, min, max) {
@@ -86,6 +92,8 @@ PopupWindow {
8692
if(root.visible)
8793
return
8894
currentItem = null
95+
root.requestedWidth = 10
96+
root.requestedHeight = 10
8997
root.width = 10
9098
root.height = 10
9199
DS.closeChildrenWindows(root)
@@ -119,8 +127,12 @@ PopupWindow {
119127
}
120128
}
121129

122-
onHeightChanged: requestUpdateGeometry()
123-
onWidthChanged: requestUpdateGeometry()
130+
onRequestedHeightChanged: {
131+
requestUpdateGeometry()
132+
}
133+
onRequestedWidthChanged: {
134+
requestUpdateGeometry()
135+
}
124136
onXOffsetChanged: requestUpdateGeometry()
125137
onYOffsetChanged: requestUpdateGeometry()
126138

0 commit comments

Comments
 (0)