From 00eac1ed9befc41712e431c7569e0e86e5dffccf Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 31 May 2021 10:27:32 +0200 Subject: Safe cleanup of redirect --- window_texture.c | 7 ++++++- window_texture.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/window_texture.c b/window_texture.c index 67a0319..c40d4c4 100644 --- a/window_texture.c +++ b/window_texture.c @@ -19,11 +19,13 @@ int window_texture_init(WindowTexture *window_texture, Display *display, Window window_texture->pixmap = None; window_texture->glx_pixmap = None; window_texture->texture_id = 0; + window_texture->redirected = 0; if(!x11_supports_composite_named_window_pixmap(display)) return 1; XCompositeRedirectWindow(display, window, CompositeRedirectAutomatic); + window_texture->redirected = 1; return window_texture_on_resize(window_texture); } @@ -46,7 +48,10 @@ static void window_texture_cleanup(WindowTexture *self, int delete_texture) { } void window_texture_deinit(WindowTexture *self) { - XCompositeUnredirectWindow(self->display, self->window, CompositeRedirectAutomatic); + if(self->redirected) { + XCompositeUnredirectWindow(self->display, self->window, CompositeRedirectAutomatic); + self->redirected = 0; + } window_texture_cleanup(self, 1); } diff --git a/window_texture.h b/window_texture.h index d543a79..acf349a 100644 --- a/window_texture.h +++ b/window_texture.h @@ -13,6 +13,7 @@ typedef struct { Pixmap pixmap; GLXPixmap glx_pixmap; GLuint texture_id; + int redirected; } WindowTexture; /* Returns 0 on success */ -- cgit v1.2.3