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

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