From ba2c0324d2ef21a5c42ec182e851a435180b51ac Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 18 Dec 2019 21:25:48 +0100 Subject: Reset buffer swap state on stop Summary: When the compositor is stopped there might still be a buffer swap ongoing, in particular when a client blocks compositing on X11. Depending on the backend the next buffer swap event might be handled in bufferSwapComplete (Wayland) or not be handled (X11 GLX, since a new GLX window will be created while the swap event is sent for the old one). With this patch the buffer swap state is reset on stop such that on later start no outdated data might create errors and instead a new repaint can be triggered with updated data. BUG: 415262 Test Plan: Manually on X11 and Wayland. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D26090 --- a/composite.cpp 2020-05-03 00:37:29.000000000 +0300 +++ b/composite.cpp 2020-05-03 00:45:28.824084430 +0300 @@ -451,6 +451,8 @@ delete m_scene; m_scene = nullptr; + m_bufferSwapPending = false; + m_composeAtSwapCompletion = false; compositeTimer.stop(); repaints_region = QRegion(); @@ -719,11 +721,8 @@ // is called the next time. If there would be nothing pending, it will not restart the timer and // scheduleRepaint() would restart it again somewhen later, called from functions that // would again add something pending. - if (m_bufferSwapPending && m_scene->syncsToVBlank()) { - m_composeAtSwapCompletion = true; - } else { - scheduleRepaint(); - } + Q_ASSERT(!m_bufferSwapPending); + scheduleRepaint(); } template