Blame SOURCES/qtwayland-send-exposeevent-to-parent-on-subsurface-position.patch

89d4c9
From b36a345d727eab37ee4ec4c2dc4674d5971c81d8 Mon Sep 17 00:00:00 2001
89d4c9
From: David Edmundson <davidedmundson@kde.org>
89d4c9
Date: Mon, 14 Sep 2020 17:08:39 +0100
89d4c9
Subject: [PATCH] Client: Send exposeEvent to parent on subsurface position
89d4c9
 changes
89d4c9
89d4c9
When a subsurface is moved, we need the parent window to commit to apply
89d4c9
that move. Ideally we want this in sync with any potential rendering on
89d4c9
the parent window.
89d4c9
89d4c9
Currently the code calls requestUpdate() which acts more like a frame
89d4c9
callback; it will only do something if the main QWindow considers itself
89d4c9
dirty.
89d4c9
89d4c9
We want to force a repaint, which is semantically more similar to an
89d4c9
ExposeEvent.
89d4c9
89d4c9
Fixes: QTBUG-86177
89d4c9
Pick-to: 5.15
89d4c9
Change-Id: I30bdfa357beee860ce2b00a256eaea6d040dd55c
89d4c9
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
89d4c9
---
89d4c9
 src/client/qwaylandwindow.cpp             |  7 ++++-
89d4c9
 tests/auto/client/surface/tst_surface.cpp | 33 +++++++++++++++++++----
89d4c9
 2 files changed, 34 insertions(+), 6 deletions(-)
89d4c9
89d4c9
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
89d4c9
index 3e26384..3cf1326 100644
89d4c9
--- a/src/client/qwaylandwindow.cpp
89d4c9
+++ b/src/client/qwaylandwindow.cpp
89d4c9
@@ -339,7 +339,12 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
89d4c9
     if (mSubSurfaceWindow) {
89d4c9
         QMargins m = QPlatformWindow::parent()->frameMargins();
89d4c9
         mSubSurfaceWindow->set_position(rect.x() + m.left(), rect.y() + m.top());
89d4c9
-        mSubSurfaceWindow->parent()->window()->requestUpdate();
89d4c9
+
89d4c9
+        QWaylandWindow *parentWindow = mSubSurfaceWindow->parent();
89d4c9
+        if (parentWindow && parentWindow->isExposed()) {
89d4c9
+            QRect parentExposeGeometry(QPoint(), parentWindow->geometry().size());
89d4c9
+            parentWindow->sendExposeEvent(parentExposeGeometry);
89d4c9
+        }
89d4c9
     }
89d4c9
 }
89d4c9
 
89d4c9
diff --git a/tests/auto/client/surface/tst_surface.cpp b/tests/auto/client/surface/tst_surface.cpp
89d4c9
index b8a65f1..95e4e60 100644
89d4c9
--- a/tests/auto/client/surface/tst_surface.cpp
89d4c9
+++ b/tests/auto/client/surface/tst_surface.cpp
89d4c9
@@ -167,17 +167,40 @@ void tst_surface::negotiateShmFormat()
89d4c9
 void tst_surface::createSubsurface()
89d4c9
 {
89d4c9
     QRasterWindow window;
89d4c9
-    window.resize(64, 64);
89d4c9
-    window.show();
89d4c9
-    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
89d4c9
-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
89d4c9
-    QCOMPOSITOR_TRY_VERIFY(xdgSurface()->m_committedConfigureSerial);
89d4c9
+    window.setObjectName("main");
89d4c9
+    window.resize(200, 200);
89d4c9
 
89d4c9
     QRasterWindow subWindow;
89d4c9
+    subWindow.setObjectName("subwindow");
89d4c9
     subWindow.setParent(&window);
89d4c9
     subWindow.resize(64, 64);
89d4c9
+
89d4c9
+    window.show();
89d4c9
     subWindow.show();
89d4c9
+
89d4c9
     QCOMPOSITOR_TRY_VERIFY(subSurface());
89d4c9
+    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
89d4c9
+    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
89d4c9
+    QCOMPOSITOR_TRY_VERIFY(xdgSurface()->m_committedConfigureSerial);
89d4c9
+
89d4c9
+    const Surface *mainSurface = exec([=] {return surface(0);});
89d4c9
+    const Surface *childSurface = exec([=] {return surface(1);});
89d4c9
+    QSignalSpy  mainSurfaceCommitSpy(mainSurface, &Surface::commit);
89d4c9
+    QSignalSpy childSurfaceCommitSpy(childSurface, &Surface::commit);
89d4c9
+
89d4c9
+    // Move subsurface. The parent should redraw and commit
89d4c9
+    subWindow.setGeometry(100, 100, 64, 64);
89d4c9
+    // the toplevel should commit to indicate the subsurface moved
89d4c9
+    QCOMPOSITOR_TRY_COMPARE(mainSurfaceCommitSpy.count(), 1);
89d4c9
+    mainSurfaceCommitSpy.clear();
89d4c9
+    childSurfaceCommitSpy.clear();
89d4c9
+
89d4c9
+    // Move and resize the subSurface. The parent should redraw and commit
89d4c9
+    // The child should also redraw
89d4c9
+    subWindow.setGeometry(50, 50, 80, 80);
89d4c9
+    QCOMPOSITOR_TRY_COMPARE(mainSurfaceCommitSpy.count(), 1);
89d4c9
+    QCOMPOSITOR_TRY_COMPARE(childSurfaceCommitSpy.count(), 1);
89d4c9
+
89d4c9
 }
89d4c9
 
89d4c9
 // Used to cause a crash in libwayland (QTBUG-79674)