diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-05-31 10:27:32 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-05-31 10:27:32 +0200 |
commit | 00eac1ed9befc41712e431c7569e0e86e5dffccf (patch) | |
tree | 7e92e19bd0da539d79c109eea945c9f6fa85a8c6 | |
parent | bfd4dfe92ae0fafc1041c4a4d1024e8b0ef72443 (diff) |
Safe cleanup of redirect
-rw-r--r-- | window_texture.c | 7 | ||||
-rw-r--r-- | window_texture.h | 1 |
2 files changed, 7 insertions, 1 deletions
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 */ |