aboutsummaryrefslogtreecommitdiff
path: root/src/window
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-07-31 17:34:29 +0200
committerdec05eba <dec05eba@protonmail.com>2024-07-31 17:34:29 +0200
commitbff9b4c0ee5c943d3729006c8303bbde1e96742e (patch)
tree35f8d6c3ad3a78210ef22bf8257ad78f879eda83 /src/window
parentb4799373f7fb9c8faec813e78a955438301cb9d1 (diff)
Robustness
Diffstat (limited to 'src/window')
-rw-r--r--src/window/window.c12
1 files changed, 9 insertions, 3 deletions
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;