diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2016-06-08 17:40:25 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2016-06-16 08:23:14 +0000 |
commit | a76e98dea9646dea2592e4699f13d9b4706c68f1 (patch) | |
tree | d3605a196764bb4b95e30043395a702d2b0c76bd /src/client/qwaylandxdgsurface.cpp | |
parent | 5392343491e93952b520ad43d164dfbe1e550d58 (diff) |
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 <giulio.camuffo@kdab.com>
Diffstat (limited to 'src/client/qwaylandxdgsurface.cpp')
-rw-r--r-- | src/client/qwaylandxdgsurface.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/client/qwaylandxdgsurface.cpp b/src/client/qwaylandxdgsurface.cpp index 202ac50bb..8852d2dfb 100644 --- a/src/client/qwaylandxdgsurface.cpp +++ b/src/client/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); |