diff --git a/frame/popupwindow.cpp b/frame/popupwindow.cpp index a7425f9b9..2732c914e 100644 --- a/frame/popupwindow.cpp +++ b/frame/popupwindow.cpp @@ -32,6 +32,11 @@ PopupWindow::PopupWindow(QWindow *parent) }); } +void PopupWindow::setWindowGeometry(int px, int py, int pw, int ph) +{ + this->setGeometry(px, py, pw, ph); +} + void PopupWindow::mouseReleaseEvent(QMouseEvent *event) { QQuickApplicationWindow::mouseReleaseEvent(event); diff --git a/frame/popupwindow.h b/frame/popupwindow.h index 5c9925446..8a6eb2f54 100644 --- a/frame/popupwindow.h +++ b/frame/popupwindow.h @@ -17,7 +17,9 @@ class PopupWindow : public QQuickApplicationWindow public: PopupWindow(QWindow *parent = nullptr); + bool x11GrabFocusTransition() const { return m_x11GrabFocusTransition; } + Q_INVOKABLE void setWindowGeometry(int px, int py, int pw, int ph); protected: void mouseReleaseEvent(QMouseEvent *event) override; diff --git a/frame/qml/PanelPopup.qml b/frame/qml/PanelPopup.qml index b01c69b82..b0bdb8995 100644 --- a/frame/qml/PanelPopup.qml +++ b/frame/qml/PanelPopup.qml @@ -24,12 +24,12 @@ Item { Binding { when: readyBinding - target: popupWindow; property: "width" + target: popupWindow; property: "requestedWidth" value: popup.width } Binding { when: readyBinding - target: popupWindow; property: "height" + target: popupWindow; property: "requestedHeight" value: popup.height } Binding { diff --git a/frame/qml/PanelPopupWindow.qml b/frame/qml/PanelPopupWindow.qml index c4404dfa0..4de58dd69 100644 --- a/frame/qml/PanelPopupWindow.qml +++ b/frame/qml/PanelPopupWindow.qml @@ -15,14 +15,18 @@ PopupWindow { property real yOffset: 0 property int margins: 10 property Item currentItem + property int requestedWidth: 10 + property int requestedHeight: 10 signal requestUpdateGeometry() signal updateGeometryFinished() // order to update screen and (x,y) property var updateGeometryer : function updateGeometry() { - if (root.width <= 10 || root.height <= 10) { - return + if (root.requestedWidth <= 10 || root.requestedHeight <= 10) { + root.width = root.requestedWidth; + root.height = root.requestedHeight; + return; } if (!root.transientParent) return @@ -33,9 +37,11 @@ PopupWindow { let bounding = Qt.rect(root.screen.virtualX + margins, root.screen.virtualY + margins, root.screen.width - margins * 2, root.screen.height - margins * 2) let pos = Qt.point(transientParent ? transientParent.x + xOffset : xOffset, - transientParent ? transientParent.y + yOffset : YOffset) - x = selectValue(pos.x, bounding.left, bounding.right - root.width) - y = selectValue(pos.y, bounding.top, bounding.bottom - root.height) + transientParent ? transientParent.y + yOffset : yOffset) + let newX = selectValue(pos.x, bounding.left, bounding.right - root.requestedWidth) + let newY = selectValue(pos.y, bounding.top, bounding.bottom - root.requestedHeight) + + root.setWindowGeometry(newX, newY, root.requestedWidth, root.requestedHeight) } function selectValue(value, min, max) { @@ -84,6 +90,8 @@ PopupWindow { if(root.visible) return currentItem = null + root.requestedWidth = 10 + root.requestedHeight = 10 root.width = 10 root.height = 10 DS.closeChildrenWindows(root) @@ -117,8 +125,12 @@ PopupWindow { } } - onHeightChanged: requestUpdateGeometry() - onWidthChanged: requestUpdateGeometry() + onRequestedHeightChanged: { + requestUpdateGeometry() + } + onRequestedWidthChanged: { + requestUpdateGeometry() + } onXOffsetChanged: requestUpdateGeometry() onYOffsetChanged: requestUpdateGeometry()