From cc142e3e8223b6854ea08ba944c0a24905eedf88 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 30 Jun 2023 12:39:09 +0200 Subject: Cleanup window deinit --- include/mgl/window/event.h | 2 -- src/window/window.c | 14 ++++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/include/mgl/window/event.h b/include/mgl/window/event.h index 1e7cebf..31af4f1 100644 --- a/include/mgl/window/event.h +++ b/include/mgl/window/event.h @@ -1,8 +1,6 @@ #ifndef MGL_EVENT_H #define MGL_EVENT_H -#include "key.h" -#include "mouse_button.h" #include #include 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