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>
This commit is contained in:
parent
fe52b009f3
commit
ad7245b942
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user