qt5-qtwayland/SOURCES/0003-Client-Send-exposeEven...

98 lines
3.7 KiB
Diff
Raw Normal View History

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