From bff9b4c0ee5c943d3729006c8303bbde1e96742e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 31 Jul 2024 17:34:29 +0200 Subject: Robustness --- src/window/window.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/window') diff --git a/src/window/window.c b/src/window/window.c index 8681db9..7c28d8a 100644 --- a/src/window/window.c +++ b/src/window/window.c @@ -220,9 +220,7 @@ static int x11_context_init(x11_context *self, bool alpha) { return 0; } -void x11_context_deinit(x11_context *self) { - mgl_context *context = mgl_get_context(); - +static void x11_context_clear_monitors(x11_context *self) { for(int i = 0; i < self->num_monitors; ++i) { mgl_monitor *monitor = &self->monitors[i]; if(monitor->name) { @@ -231,6 +229,12 @@ void x11_context_deinit(x11_context *self) { } } self->num_monitors = 0; +} + +void x11_context_deinit(x11_context *self) { + mgl_context *context = mgl_get_context(); + + x11_context_clear_monitors(self); if(self->color_map) { XFreeColormap(context->connection, self->color_map); @@ -721,6 +725,8 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window return -1; } + // TODO: This should be done once and monitor events should be done once, no matter how many windows you have + x11_context_clear_monitors(x11_context); for_each_active_monitor_output(context->connection, monitor_callback_add_to_x11_context, x11_context); self->num_monitors = x11_context->num_monitors; -- cgit v1.2.3