Client: Avoid locking resizing in QWaylandShmBackingStore

QWaylandWindow::setCanResize(false) will block applying configure
events. QWaylandWindow::setCanResize(true) will unblock configure events
and potentially apply a scheduled configure event if there's one.

QWaylandWindow::setCanResize(true) has to be called **after** committing
the surface to ensure that the xdg window geometry matches the buffer.
We don't want the xdg window geometry change when painting.

Unfortunately, setCanResize(true) can be called before the surface is
committed when using a RasterSurface, for example

 - QWaylandShmBackingStore::beginPaint(): calls setCanResize(false)
 - QWaylandShmBackingStore::endPaint(): calls setCanResize(true)
 - QWaylandWindow::setCanResize(true): applies pending configure event
 - QWaylandShmBackingStore::flush(): commits the surface, but the xdg
   window geometry is wrong now

As is, beginPaint() and endPaint() are not entirely correct functions
where configure events can be blocked. We need functions that wrap both
painting and flushing, which are not feasible with the current backing
store design.

On the other hand, it's worth noting that blocking configure events in
the backing store is not necessary because painting happens on the main
thread unlike OpenGL or Vulkan code paths.

Given the lack of synchronization points and the fact that rendering
happens on the main thread, this change removes blocking configure
events in QWaylandShmBackingStore. It fixes dolphin and various other
applications that use QtWidgets jumping while being interactively
resized.

Change-Id: I156e4fd5e04a6bba7e8d48171510d5ab0ec89713
Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
Vlad Zahorodnii 2023-08-30 09:49:41 +03:00
parent 3783016b72
commit b59d243ce2

View File

@ -171,8 +171,6 @@ void QWaylandShmBackingStore::beginPaint(const QRegion &region)
mPainting = true;
ensureSize();
waylandWindow()->setCanResize(false);
if (mBackBuffer->image()->hasAlphaChannel()) {
QPainter p(paintDevice());
p.setCompositionMode(QPainter::CompositionMode_Source);
@ -187,7 +185,6 @@ void QWaylandShmBackingStore::endPaint()
mPainting = false;
if (mPendingFlush)
flush(window(), mPendingRegion, QPoint());
waylandWindow()->setCanResize(true);
}
void QWaylandShmBackingStore::ensureSize()