From ad7245b942279c69c683aaeabf83f29c8b344962 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 8 Jun 2016 17:40:25 +0200 Subject: [PATCH] Client: Fix incorrect size when maximizing using xdg_shell When maximizing xdg_shell clients, the clients would call QPlatformWindow::setGeometry() with frame margins included, resulting in a window that was bigger than what was requested by the compositor. The reason for this, was that QWaylandXdgSurface would subtract the frame margins from the width and height only when the resizing state was set, not when the maximized state was set. Later, margins were added again before QWaylandWindow::configure was called. This resulted in margins being subtracted and then added back for the resizing state, while for the maximized state margins were only added and never subtracted. This behavior has now been simplified so only size including window frame is tracked. This is what we receive in the XdgSurface::configure event anyway, and also what QWaylandWindow::configure expects. Change-Id: I0629e7e79a5367fa872743c6d025bfab8a4f2866 Reviewed-by: Giulio Camuffo --- .../platforms/wayland/qwaylandxdgsurface.cpp | 23 ++++++++----------- .../platforms/wayland/qwaylandxdgsurface_p.h | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandxdgsurface.cpp b/src/plugins/platforms/wayland/qwaylandxdgsurface.cpp index 202ac50bb67..8852d2dfb81 100644 --- a/src/plugins/platforms/wayland/qwaylandxdgsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandxdgsurface.cpp @@ -56,7 +56,6 @@ QWaylandXdgSurface::QWaylandXdgSurface(struct ::xdg_surface *xdg_surface, QWayla { if (window->display()->windowExtension()) m_extendedWindow = new QWaylandExtendedSurface(window); - m_size = m_window->window()->geometry().size(); } QWaylandXdgSurface::~QWaylandXdgSurface() @@ -187,10 +186,7 @@ void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, st aboutToFullScreen = true; break; case XDG_SURFACE_STATE_RESIZING: - m_margins = m_window->frameMargins(); - width -= m_margins.left() + m_margins.right(); - height -= m_margins.top() + m_margins.bottom(); - m_size = m_window->window()->geometry().size(); + m_normalSize = QSize(width, height); break; case XDG_SURFACE_STATE_ACTIVATED: // TODO: here about the missing window activation @@ -201,6 +197,8 @@ void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, st } if (!m_fullscreen && aboutToFullScreen) { + if (!m_maximized) + m_normalSize = m_window->window()->frameGeometry().size(); m_fullscreen = true; m_window->window()->showFullScreen(); } else if (m_fullscreen && !aboutToFullScreen) { @@ -211,6 +209,8 @@ void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, st m_window->window()->showNormal(); } } else if (!m_maximized && aboutToMaximize) { + if (!m_fullscreen) + m_normalSize = m_window->window()->frameGeometry().size(); m_maximized = true; m_window->window()->showMaximized(); } else if (m_maximized && !aboutToMaximize) { @@ -218,14 +218,11 @@ void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, st m_window->window()->showNormal(); } - if (width == 0 || height == 0) { - width = m_size.width(); - height = m_size.height(); - } - - if (width > 0 && height > 0) { - m_margins = m_window->frameMargins(); - m_window->configure(0, width + m_margins.left() + m_margins.right(), height + m_margins.top() + m_margins.bottom()); + if (width <= 0 || height <= 0) { + if (!m_normalSize.isEmpty()) + m_window->configure(0, m_normalSize.width(), m_normalSize.height()); + } else { + m_window->configure(0, width, height); } ack_configure(serial); diff --git a/src/plugins/platforms/wayland/qwaylandxdgsurface_p.h b/src/plugins/platforms/wayland/qwaylandxdgsurface_p.h index 8deafef7756..d4380d25fbb 100644 --- a/src/plugins/platforms/wayland/qwaylandxdgsurface_p.h +++ b/src/plugins/platforms/wayland/qwaylandxdgsurface_p.h @@ -106,7 +106,7 @@ private: bool m_maximized; bool m_minimized; bool m_fullscreen; - QSize m_size; + QSize m_normalSize; QMargins m_margins; QWaylandExtendedSurface *m_extendedWindow;