From b3214db0b7aff89a82dbc4769f22c548f55863cf Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 5 Oct 2022 10:04:11 +0300 Subject: [PATCH] x11: Make damage region fetching code more robust to errors With DamageReportNonEmpty damage report level, the x server will send kwin a DamageNotify when the damage region changes from empty to not empty. The damage region will be made empty when SurfaceItemX11 calls xcb_damage_subtract(). It appears like xcb_generate_id() can return us an already associated XID, which eventually results in xcb_damage_subtract() failing and breaking state tracking in SurfaceItemX11. KWin will no longer receive DamageNotify events and some windows will freeze. In order to make getting BadIdChoice less catastrophic, this change makes the SurfaceItemX11 reset m_isDamaged after successfully fetching the damage region. If xcb_generate_id() returns us a bad id, kwin will try to fetch the damage again in the next frame. BUG: 456511 --- src/surfaceitem_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/surfaceitem_x11.cpp b/src/surfaceitem_x11.cpp index 6de9a73479..fef00eb73e 100644 --- a/src/surfaceitem_x11.cpp +++ b/src/surfaceitem_x11.cpp @@ -54,7 +54,6 @@ bool SurfaceItemX11::fetchDamage() if (!m_isDamaged) { return false; } - m_isDamaged = false; if (m_damageHandle == XCB_NONE) { return true; @@ -105,6 +104,7 @@ void SurfaceItemX11::waitForDamage() free(reply); addDamage(region); + m_isDamaged = false; } void SurfaceItemX11::destroyDamage()