Send the initial sync request before mapping the frame window

When the wl_surface commits are blocked by the initial sync request, it
is really important that Xwayland doesn't commit the surface until the
sync request is acked. However, with the current arrangement of the code,
Xwayland may render something before the sync request is acked.

It can happen because the frame window is mapped before the initial sync
request is sent. There are many places where it can happen, e.g. in the
setupCompositing() function, or the setMinimized() function, etc.

In order to ensure that Xwayland won't render the wl_surface while we
are waiting for the sync request to get acked, this change moves the initial
sync request all the way to the top of the manage() function so the
surface commits are blocked before the frame window is mapped.
wilder/Plasma/6.3
Vlad Zahorodnii 1 year ago
parent edf4e2e050
commit 883f95d272
  1. 20
      src/x11window.cpp

@ -656,6 +656,18 @@ bool X11Window::manage(xcb_window_t w, bool isMapped)
getSyncCounter();
setCaption(readName());
if (Compositor::compositing()) {
// Sending ConfigureNotify is done when setting mapping state below, getting the
// first sync response means window is ready for compositing.
//
// The sync request will block wl_surface commits, and with Xwayland, it is really
// important that wl_surfaces commits are blocked before the frame window is mapped.
// Otherwise Xwayland can attach a buffer before the sync request is acked.
sendSyncRequest();
} else {
ready_for_painting = true; // set to true in case compositing is turned on later
}
setupWindowRules();
connect(this, &X11Window::windowClassChanged, this, &X11Window::evaluateWindowRules);
@ -1103,14 +1115,6 @@ bool X11Window::manage(xcb_window_t w, bool isMapped)
workspace()->restoreSessionStackingOrder(this);
}
if (Compositor::compositing()) {
// Sending ConfigureNotify is done when setting mapping state below,
// Getting the first sync response means window is ready for compositing
sendSyncRequest();
} else {
ready_for_painting = true; // set to true in case compositing is turned on later. bug #160393
}
if (isShown()) {
bool allow;
if (session) {

Loading…
Cancel
Save