aboutsummaryrefslogtreecommitdiff
path: root/src/window/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/window/window.c')
-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;