From cc142e3e8223b6854ea08ba944c0a24905eedf88 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 30 Jun 2023 12:39:09 +0200 Subject: Cleanup window deinit --- src/window/window.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/window/window.c') diff --git a/src/window/window.c b/src/window/window.c index abeca8e..0654e85 100644 --- a/src/window/window.c +++ b/src/window/window.c @@ -452,13 +452,9 @@ int mgl_window_init_from_existing_window(mgl_window *self, mgl_window_handle exi } void mgl_window_deinit(mgl_window *self) { - mgl_context *context = mgl_get_context(); x11_context *x11_context = self->context; - if(self->window) { - XDestroyWindow(context->connection, self->window); - self->window = 0; - } + mgl_window_close(self); if(x11_context) { x11_context_deinit(x11_context); @@ -953,9 +949,11 @@ bool mgl_window_is_mouse_button_pressed(const mgl_window *self, mgl_mouse_button void mgl_window_close(mgl_window *self) { mgl_context *context = mgl_get_context(); - XDestroyWindow(context->connection, self->window); - XSync(context->connection, False); - self->window = None; + if(self->window) { + XDestroyWindow(context->connection, self->window); + XSync(context->connection, False); + self->window = None; + } self->open = false; } -- cgit v1.2.3