aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--src/window/window.c12
2 files changed, 11 insertions, 4 deletions
diff --git a/README.md b/README.md
index 601c0f5..97e4714 100644
--- a/README.md
+++ b/README.md
@@ -7,4 +7,5 @@ Right now mgl only supports x11.
## Runtime
`libglvnd (libGL.so)`
# Notes
-Every window _get_ function is cached from the last event poll, no calls to x11 is made.
+Every window _get_ function is cached from the last event poll, no calls to x11 is made.\
+Only one window can be created and used at once.
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;