From 312643c4549cb3859744b6ef7830af09df175e8f Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 17 Mar 2019 00:55:04 +0000 Subject: [PATCH] win: clear STALE_IMAGE flag in map_win Clear the STALE_IMAGE flag set by win_update_bounding_shape to avoid an unnecessary image data invalidation. Mainly to workaround a NVIDIA bug. For more detailed explanation, see commit 8f67c6190c281955846589d8769385f30e7c5d23 Signed-off-by: Yuxuan Shui --- src/win.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/win.c b/src/win.c index 01335b0..7978884 100644 --- a/src/win.c +++ b/src/win.c @@ -1712,13 +1712,6 @@ void map_win(session_t *ps, win *w) { w->state = WSTATE_MAPPING; w->opacity_tgt = win_calc_opacity_target(ps, w); - // TODO win_update_bounding_shape below will immediately - // reinit w->win_data, not very efficient - if (ps->redirected && ps->o.experimental_backends) { - if (!win_bind_image(ps, w)) { - w->flags |= WIN_FLAGS_IMAGE_ERROR; - } - } log_debug("Window %#010x has opacity %f, opacity target is %f", w->id, w->opacity, w->opacity_tgt); @@ -1732,6 +1725,20 @@ void map_win(session_t *ps, win *w) { // update. (Issue #35) win_update_bounding_shape(ps, w); + // Reset the STALE_IMAGE flag set by win_update_bounding_shape. Because we are + // just about to bind the image, no way that's stale. + // + // Also because NVIDIA driver doesn't like seeing the same pixmap under different + // ids, so avoid naming the pixmap again when it didn't actually change. + w->flags &= ~WIN_FLAGS_STALE_IMAGE; + + // Bind image after update_bounding_shape, so the shadow has the correct size. + if (ps->redirected && ps->o.experimental_backends) { + if (!win_bind_image(ps, w)) { + w->flags |= WIN_FLAGS_IMAGE_ERROR; + } + } + #ifdef CONFIG_DBUS // Send D-Bus signal if (ps->o.dbus) {