diff options
author | Ilya Fedin <fedin-ilja2010@ya.ru> | 2022-08-08 03:56:07 +0400 |
---|---|---|
committer | Ilya Fedin <fedin-ilja2010@ya.ru> | 2022-08-23 01:22:59 +0400 |
commit | 2a4dc215756ff2f3fe966a689eea4cf4c7b11b7d (patch) | |
tree | aac657b423e5c8ddcef10719213040c9af7f6f49 /src | |
parent | e260392653d765d5e13765d0b8b1df9f316e7b77 (diff) | |
download | qtwayland-2a4dc215756ff2f3fe966a689eea4cf4c7b11b7d.tar.gz |
Client: add custom margins support to xdg popups
xdg_positioner operates in window content geometry (i.e. without shadows),
so it's necessary to remove popup's and parent's shadow from position and
size calculations.
Pick-to: 6.4
Change-Id: I997ba2c45ae341a09a8284226629e8107800e894
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/client/qwaylandwindow.cpp | 5 | ||||
-rw-r--r-- | src/client/qwaylandwindow_p.h | 1 | ||||
-rw-r--r-- | src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp | 8 |
3 files changed, 11 insertions, 3 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 53ebbe75..9c6ce91a 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -728,6 +728,11 @@ QMargins QWaylandWindow::clientSideMargins() const return mWindowDecorationEnabled ? mWindowDecoration->margins() : QMargins{}; } +QMargins QWaylandWindow::customMargins() const +{ + return mCustomMargins; +} + void QWaylandWindow::setCustomMargins(const QMargins &margins) { const QMargins oldMargins = mCustomMargins; mCustomMargins = margins; diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index ea30d9b8..298f3f2d 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -112,6 +112,7 @@ public: bool waitForFrameSync(int timeout); QMargins frameMargins() const override; + QMargins customMargins() const; void setCustomMargins(const QMargins &margins); QSize surfaceSize() const; QRect windowContentGeometry() const; diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index 87152fbd..bd5e3fe5 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -409,8 +409,10 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent) auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner()); // set_popup expects a position relative to the parent - QPoint transientPos = m_window->geometry().topLeft(); // this is absolute - transientPos -= parent->geometry().topLeft(); + QPoint topLeftMargins = QPoint(m_window->customMargins().left(), m_window->customMargins().top()); + QPoint parentMargins = QPoint(parent->customMargins().left(), parent->customMargins().top()); + QPoint transientPos = m_window->geometry().topLeft() + topLeftMargins; // this is absolute + transientPos -= parent->geometry().topLeft() + parentMargins; if (parent->decoration()) { transientPos.setX(transientPos.x() + parent->decoration()->margins(QWaylandAbstractDecoration::ShadowsExcluded).left()); transientPos.setY(transientPos.y() + parent->decoration()->margins(QWaylandAbstractDecoration::ShadowsExcluded).top()); @@ -418,7 +420,7 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent) positioner->set_anchor_rect(transientPos.x(), transientPos.y(), 1, 1); positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left); positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right); - positioner->set_size(m_window->geometry().width(), m_window->geometry().height()); + positioner->set_size(m_window->windowContentGeometry().width(), m_window->windowContentGeometry().height()); positioner->set_constraint_adjustment(QtWayland::xdg_positioner::constraint_adjustment_slide_x | QtWayland::xdg_positioner::constraint_adjustment_slide_y | QtWayland::xdg_positioner::constraint_adjustment_flip_x |