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

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