From f086d9603559f1aaa0300b8ecf7878b89f095872 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 2 Oct 2018 13:54:59 +0200 Subject: [PATCH 1/4] Client: Remove failing assert on compositors without wl_data_device Some compositors don't advertise wl_data_device_manager support, and the client has no control over this, so the assertion doesn't make sense. Returning nullptr in that case should be fine. Change-Id: If0b145326d074ea4ebf8f5a12654962d56012a2d Reviewed-by: Paul Olav Tvete --- src/plugins/platforms/wayland/qwaylandinputdevice.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index b4b7c4ef323..37c6fbe9fd0 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -297,7 +297,6 @@ void QWaylandInputDevice::setDataDevice(QWaylandDataDevice *device) QWaylandDataDevice *QWaylandInputDevice::dataDevice() const { - Q_ASSERT(mDataDevice); return mDataDevice; } #endif From b25af2c7687b5802b48076ba1a885cc986084629 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Sun, 30 Sep 2018 11:30:18 +0300 Subject: [PATCH 2/4] Avoid spurious move events after configure call Whilst wayland can't actually move the window in a QWindow::setGeometry call the previous behavior was to keep it so that it appeared to the client that it had moved. The new behavior is non-consistent, QWindow::setPosition will update QWindow::position until the first configure call is received at which point it will move back to 0,0. This then generates a QMoveEvent for the window that hasn't moved. This patch keeps the QWindow::position consistent with the user request and doesn't generate move events. Change-Id: Ifb1433b3902d44c1b2e43036bc1805a6e00128fb Reviewed-by: Johan Helsing --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index cc69fac95d9..52bee6ae318 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -345,7 +345,7 @@ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, cons QMargins margins = frameMargins(); int widthWithoutMargins = qMax(sizeWithMargins.width() - (margins.left()+margins.right()), 1); int heightWithoutMargins = qMax(sizeWithMargins.height() - (margins.top()+margins.bottom()), 1); - QRect geometry(QPoint(), QSize(widthWithoutMargins, heightWithoutMargins)); + QRect geometry(windowGeometry().topLeft(), QSize(widthWithoutMargins, heightWithoutMargins)); mOffset += offset; setGeometry(geometry); From e71099c07e23d1ed1776caa432c4207b0d535885 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 8 Oct 2018 11:25:32 +0200 Subject: [PATCH 3/4] Client: Fix cursor size becoming bigger and bigger when switching screens cursorSize was a static which was multiplied with the dpr each time loadCursorSize was called resulting in a bigger and bigger cursor size. Fix it by making the static constant. Change-Id: Ie23cf0cc0d6c13721feecebe214d7c794be35077 Reviewed-by: Paul Olav Tvete Reviewed-by: David Edmundson --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index c57dc13add2..a2957e0dd3d 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -526,9 +526,10 @@ void QWaylandDisplay::setCursor(const QSharedPointer &buffer, co QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(qreal devicePixelRatio) { - static int cursorSize = qEnvironmentVariableIntValue("XCURSOR_SIZE"); - if (cursorSize <= 0) - cursorSize = 32; + constexpr int defaultCursorSize = 32; + static const int xCursorSize = qEnvironmentVariableIntValue("XCURSOR_SIZE"); + int cursorSize = xCursorSize > 0 ? xCursorSize : defaultCursorSize; + if (compositorVersion() >= 3) // set_buffer_scale is not supported on earlier versions cursorSize *= devicePixelRatio; From 6f183c7db7a91a05ef463031dd2a9521ef1e081d Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 19 Jun 2018 15:00:20 +0200 Subject: [PATCH 4/4] 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 Reviewed-by: Paul Olav Tvete --- .../xdg-shell-v6/qwaylandxdgshellv6.cpp | 15 +++++++++++---- .../xdg-shell/qwaylandxdgshell.cpp | 15 +++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp index 1dc43b371fd..447e8fb6a5f 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp +++ b/src/plugins/platforms/wayland/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/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index 8b3d07481cb..0756e4d020c 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/platforms/wayland/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()