diff options
author | Vlad Zahorodnii <vlad.zahorodnii@kde.org> | 2022-01-19 12:33:19 +0200 |
---|---|---|
committer | Vlad Zahorodnii <vlad.zahorodnii@kde.org> | 2022-10-26 22:42:01 +0200 |
commit | da0ab40fe415e2c46edaeed90e52d801e4e5250f (patch) | |
tree | 6d2cb75f3c925b1eb193aeb2666bd060fff25ac2 /src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp | |
parent | f1e71327d462d2dae0b46677bbc478afb0d1b2f7 (diff) | |
download | qtwayland-da0ab40fe415e2c46edaeed90e52d801e4e5250f.tar.gz |
Client: Add support for xdg_toplevel.configure_bounds
Currently, QtWayland doesn't know about work area size, which can create
a problem where some windows don't fit into the screen area or work
area.
With the xdg_toplevel.configure_bounds event, the compositor can
indicate the client the recommended maximum window geometry size.
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/41
Change-Id: I5214aba9f144d091a2afe639de94b8d717c42fdc
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp')
-rw-r--r-- | src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index fad8b581..c0d7a7d4 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -61,8 +61,12 @@ void QWaylandXdgSurface::Toplevel::applyConfigure() if (m_pending.size.isEmpty()) { // An empty size in the configure means it's up to the client to choose the size bool normalPending = !(m_pending.states & (Qt::WindowMaximized|Qt::WindowFullScreen)); - if (normalPending && !m_normalSize.isEmpty()) - m_xdgSurface->m_window->resizeFromApplyConfigure(m_normalSize); + if (normalPending && !m_normalSize.isEmpty()) { + QSize size = m_normalSize; + if (!m_pending.bounds.isEmpty()) + size = size.boundedTo(m_pending.bounds); + m_xdgSurface->m_window->resizeFromApplyConfigure(size); + } } else { m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size); } @@ -80,6 +84,11 @@ bool QWaylandXdgSurface::Toplevel::wantsDecorations() return !(m_pending.states & Qt::WindowFullScreen); } +void QWaylandXdgSurface::Toplevel::xdg_toplevel_configure_bounds(int32_t width, int32_t height) +{ + m_pending.bounds = QSize(width, height); +} + void QWaylandXdgSurface::Toplevel::xdg_toplevel_configure(int32_t width, int32_t height, wl_array *states) { m_pending.size = QSize(width, height); @@ -578,7 +587,7 @@ QString QWaylandXdgSurface::externWindowHandle() } QWaylandXdgShell::QWaylandXdgShell(QWaylandDisplay *display, uint32_t id, uint32_t availableVersion) - : QtWayland::xdg_wm_base(display->wl_registry(), id, qMin(availableVersion, 2u)) + : QtWayland::xdg_wm_base(display->wl_registry(), id, qMin(availableVersion, 4u)) , m_display(display) { display->addRegistryListener(&QWaylandXdgShell::handleRegistryGlobal, this); |