From 9ee297d7664d6abdb4d2c6a1c6dd72145fa43376 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sat, 17 Dec 2022 19:27:40 +0000 Subject: [PATCH] core: don't fully trust msc from present complete notify Sometimes X sends bogus complete notifies with invalid msc number. Instead use a saved msc number to get the next complete notify. Signed-off-by: Yuxuan Shui --- src/picom.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/picom.c b/src/picom.c index 9c81fd16..6d866123 100644 --- a/src/picom.c +++ b/src/picom.c @@ -1540,17 +1540,23 @@ handle_present_complete_notify(session_t *ps, xcb_present_complete_notify_event_ return; } + bool event_is_invalid = false; if (ps->frame_pacing) { + auto next_msc = cne->msc + 1; + if (cne->msc <= ps->last_msc || cne->ust == 0) { + // X sometimes sends duplicate/bogus MSC events, don't + // use the msc value. Also ignore these events. + // + // See: + // https://gitlab.freedesktop.org/xorg/xserver/-/issues/1418 + next_msc = ps->last_msc + 1; + event_is_invalid = true; + } auto cookie = xcb_present_notify_msc(ps->c, session_get_target_window(ps), - 0, cne->msc + 1, 0, 0); + 0, next_msc, 0, 0); set_cant_fail_cookie(ps, cookie); } - - if (cne->msc <= ps->last_msc || cne->ust == 0) { - // X sometimes sends duplicate/bogus MSC events, ignore them - // - // See: - // https://gitlab.freedesktop.org/xorg/xserver/-/issues/1418 + if (event_is_invalid) { return; }