aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mgl/window/window.h3
-rw-r--r--src/window/window.c11
2 files changed, 7 insertions, 7 deletions
diff --git a/include/mgl/window/window.h b/include/mgl/window/window.h
index a5ccbf7..748e728 100644
--- a/include/mgl/window/window.h
+++ b/include/mgl/window/window.h
@@ -187,4 +187,7 @@ void mgl_window_flush(mgl_window *self);
void* mgl_window_get_egl_display(mgl_window *self);
void* mgl_window_get_egl_context(mgl_window *self);
+typedef void (*mgl_active_monitor_callback)(const mgl_monitor *monitor, void *userdata);
+void mgl_for_each_active_monitor_output(void *display, mgl_active_monitor_callback callback, void *userdata);
+
#endif /* MGL_WINDOW_H */
diff --git a/src/window/window.c b/src/window/window.c
index d931a9f..485e400 100644
--- a/src/window/window.c
+++ b/src/window/window.c
@@ -711,8 +711,7 @@ static const XRRModeInfo* get_mode_info(const XRRScreenResources *sr, RRMode id)
return NULL;
}
-typedef void (*active_monitor_callback)(const mgl_monitor *monitor, void *userdata);
-static void for_each_active_monitor_output(Display *display, active_monitor_callback callback, void *userdata) {
+void mgl_for_each_active_monitor_output(void *display, mgl_active_monitor_callback callback, void *userdata) {
XRRScreenResources *screen_res = XRRGetScreenResources(display, DefaultRootWindow(display));
if(!screen_res)
return;
@@ -724,10 +723,8 @@ static void for_each_active_monitor_output(Display *display, active_monitor_call
XRRCrtcInfo *crt_info = XRRGetCrtcInfo(display, screen_res, out_info->crtc);
if(crt_info && crt_info->mode) {
const XRRModeInfo *mode_info = get_mode_info(screen_res, crt_info->mode);
- if(mode_info && out_info->nameLen < (int)sizeof(display_name)) {
- memcpy(display_name, out_info->name, out_info->nameLen);
- display_name[out_info->nameLen] = '\0';
-
+ if(mode_info) {
+ snprintf(display_name, sizeof(display_name), "%s", out_info->name);
mgl_monitor monitor = {
.id = screen_res->outputs[i],
.crtc_id = out_info->crtc,
@@ -1044,7 +1041,7 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window
// 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);
+ mgl_for_each_active_monitor_output(context->connection, monitor_callback_add_to_x11_context, x11_context);
self->num_monitors = x11_context->num_monitors;
mgl_window_on_resize(self, self->size.x, self->size.y);