Blame SOURCES/0015-Client-Send-exposeEvent-to-parent-on-subsurface-posi.patch

429548
From 2073ff99e62d4f99ed3f1f45559c5b68a61c5f66 Mon Sep 17 00:00:00 2001
89d4c9
From: David Edmundson <davidedmundson@kde.org>
89d4c9
Date: Mon, 14 Sep 2020 17:08:39 +0100
429548
Subject: [PATCH 15/36] Client: Send exposeEvent to parent on subsurface
429548
 position 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
429548
index 2af39977..e96d8fe9 100644
89d4c9
--- a/src/client/qwaylandwindow.cpp
89d4c9
+++ b/src/client/qwaylandwindow.cpp
429548
@@ -342,7 +342,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
429548
index b8a65f15..95e4e609 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)
429548
-- 
429548
2.33.1
429548