diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2018-06-19 15:00:20 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2018-10-09 07:00:31 +0000 |
commit | dc59e9decdaa5ca31b86f7fa63d088fefd35e645 (patch) | |
tree | 2ca37f5480d11c1ac5d6fe76053f6bc7ad0e569b | |
parent | eff85f5be4013c10753b3c7cb05e7c601fb600cd (diff) | |
download | qtwayland-dc59e9decdaa5ca31b86f7fa63d088fefd35e645.tar.gz |
Client (xdg-shell): Only restore normal size when not maximized
kwin and perhaps other compositors sometimes send questionable configure events
with state set to maximized and size == {0,0}.
Previously, we would then restore the m_normalSize, which would give us a
maximized window with the size of a windowed (normal) one.
A size of zero usually means that it's up to the client to decide, which makes
sense for non-maximized windows, but not so much for maximized ones. This is
what the protocol spec says about the maximized state:
The surface is maximized. The window geometry specified in the configure
event must be obeyed by the client.
It's fixed in the dev version of kwin, but until then, let's be on the safe
side and only resize the window if things make sense.
[ChangeLog][QPA plugin] Fixed a bug where maximized windows would resize to
their unmaximized size if the compositor sent an invalid configure event.
Change-Id: I2371b29c82426ac48cd1c18c14c3dd0fe4f2250e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r-- | src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp | 15 | ||||
-rw-r--r-- | src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp | 15 |
2 files changed, 22 insertions, 8 deletions
diff --git a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp index 1dc43b37..447e8fb6 100644 --- a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp +++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp @@ -72,9 +72,6 @@ void QWaylandXdgSurfaceV6::Toplevel::applyConfigure() if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen))) m_normalSize = m_xdgSurface->m_window->window()->frameGeometry().size(); - if (m_pending.size.isEmpty() && !m_normalSize.isEmpty()) - m_pending.size = m_normalSize; - if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)) m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window); @@ -85,10 +82,20 @@ void QWaylandXdgSurfaceV6::Toplevel::applyConfigure() Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive; m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive); - m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size); + + 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); + } else { + m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size); + } + QSize windowGeometrySize = m_xdgSurface->m_window->window()->frameGeometry().size(); m_xdgSurface->set_window_geometry(0, 0, windowGeometrySize.width(), windowGeometrySize.height()); m_applied = m_pending; + qCDebug(lcQpaWayland) << "Applied pending zxdg_toplevel_v6 configure event:" << m_applied.size << m_applied.states; } void QWaylandXdgSurfaceV6::Toplevel::zxdg_toplevel_v6_configure(int32_t width, int32_t height, wl_array *states) diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index 8b3d0748..0756e4d0 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -82,9 +82,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure() if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen))) m_normalSize = m_xdgSurface->m_window->window()->frameGeometry().size(); - if (m_pending.size.isEmpty() && !m_normalSize.isEmpty()) - m_pending.size = m_normalSize; - if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)) m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window); @@ -95,10 +92,20 @@ void QWaylandXdgSurface::Toplevel::applyConfigure() Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive; m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive); - m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size); + + 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); + } else { + m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size); + } + QSize windowGeometrySize = m_xdgSurface->m_window->window()->frameGeometry().size(); m_xdgSurface->set_window_geometry(0, 0, windowGeometrySize.width(), windowGeometrySize.height()); m_applied = m_pending; + qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states; } bool QWaylandXdgSurface::Toplevel::wantsDecorations() |