diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-07-31 17:34:29 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-07-31 17:34:29 +0200 |
commit | bff9b4c0ee5c943d3729006c8303bbde1e96742e (patch) | |
tree | 35f8d6c3ad3a78210ef22bf8257ad78f879eda83 | |
parent | b4799373f7fb9c8faec813e78a955438301cb9d1 (diff) |
Robustness
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | src/window/window.c | 12 |
2 files changed, 11 insertions, 4 deletions
@@ -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; |