diff --git a/glfw/backend_utils.c b/glfw/backend_utils.c index a079869df..e8ddd4f2b 100644 --- a/glfw/backend_utils.c +++ b/glfw/backend_utils.c @@ -44,9 +44,10 @@ update_fds(EventLoopData *eld) { static id_type watch_counter = 0; id_type -addWatch(EventLoopData *eld, int fd, int events, int enabled, watch_callback_func cb, void *cb_data) { +addWatch(EventLoopData *eld, const char* name, int fd, int events, int enabled, watch_callback_func cb, void *cb_data) { if (eld->watches_count >= sizeof(eld->watches)/sizeof(eld->watches[0])) return 0; Watch *w = eld->watches + eld->watches_count++; + w->name = name; w->fd = fd; w->events = events; w->enabled = enabled; w->callback = cb; w->callback_data = cb_data; @@ -97,10 +98,11 @@ update_timers(EventLoopData *eld) { } id_type -addTimer(EventLoopData *eld, double interval, int enabled, timer_callback_func cb, void *cb_data) { +addTimer(EventLoopData *eld, const char *name, double interval, int enabled, timer_callback_func cb, void *cb_data) { if (eld->timers_count >= sizeof(eld->timers)/sizeof(eld->timers[0])) return 0; Timer *t = eld->timers + eld->timers_count++; t->interval = interval; + t->name = name; t->trigger_at = enabled ? monotonic() + interval : DBL_MAX; t->callback = cb; t->callback_data = cb_data; @@ -199,8 +201,8 @@ drain_wakeup_fd(int fd, int events, void* data) { void initPollData(EventLoopData *eld, int wakeup_fd, int display_fd) { - addWatch(eld, display_fd, POLLIN, 1, NULL, NULL); - addWatch(eld, wakeup_fd, POLLIN, 1, drain_wakeup_fd, NULL); + addWatch(eld, "display", display_fd, POLLIN, 1, NULL, NULL); + addWatch(eld, "wakeup", wakeup_fd, POLLIN, 1, drain_wakeup_fd, NULL); } diff --git a/glfw/backend_utils.h b/glfw/backend_utils.h index 433f41bef..44c16384a 100644 --- a/glfw/backend_utils.h +++ b/glfw/backend_utils.h @@ -37,6 +37,7 @@ typedef struct { watch_callback_func callback; void *callback_data; id_type id; + const char *name; } Watch; typedef struct { @@ -44,6 +45,7 @@ typedef struct { double interval, trigger_at; timer_callback_func callback; void *callback_data; + const char *name; } Timer; @@ -56,10 +58,10 @@ typedef struct { } EventLoopData; -id_type addWatch(EventLoopData *eld, int fd, int events, int enabled, watch_callback_func cb, void *cb_data); +id_type addWatch(EventLoopData *eld, const char *name, int fd, int events, int enabled, watch_callback_func cb, void *cb_data); void removeWatch(EventLoopData *eld, id_type watch_id); void toggleWatch(EventLoopData *eld, id_type watch_id, int enabled); -id_type addTimer(EventLoopData *eld, double interval, int enabled, timer_callback_func cb, void *cb_data); +id_type addTimer(EventLoopData *eld, const char *name, double interval, int enabled, timer_callback_func cb, void *cb_data); void removeTimer(EventLoopData *eld, id_type timer_id); void toggleTimer(EventLoopData *eld, id_type timer_id, int enabled); void changeTimerInterval(EventLoopData *eld, id_type timer_id, double interval); diff --git a/glfw/dbus_glfw.c b/glfw/dbus_glfw.c index 43ba40311..b5a557016 100644 --- a/glfw/dbus_glfw.c +++ b/glfw/dbus_glfw.c @@ -28,6 +28,7 @@ #include "internal.h" #include "dbus_glfw.h" #include +#include static inline void report_error(DBusError *err, const char *fmt, ...) { @@ -72,7 +73,7 @@ events_for_watch(DBusWatch *watch) { static dbus_bool_t add_dbus_watch(DBusWatch *watch, void *data) { - id_type watch_id = addWatch(dbus_data->eld, dbus_watch_get_unix_fd(watch), events_for_watch(watch), dbus_watch_get_enabled(watch), on_dbus_watch_ready, watch); + id_type watch_id = addWatch(dbus_data->eld, data, dbus_watch_get_unix_fd(watch), events_for_watch(watch), dbus_watch_get_enabled(watch), on_dbus_watch_ready, watch); if (!watch_id) return FALSE; id_type *idp = malloc(sizeof(id_type)); if (!idp) return FALSE; @@ -105,7 +106,7 @@ add_dbus_timeout(DBusTimeout *timeout, void *data) { int enabled = dbus_timeout_get_enabled(timeout) ? 1 : 0; double interval = ((double)dbus_timeout_get_interval(timeout)) / 1000.0; if (interval < 0) return FALSE; - id_type timer_id = addTimer(dbus_data->eld, interval, enabled, on_dbus_timer_ready, timeout); + id_type timer_id = addTimer(dbus_data->eld, data, interval, enabled, on_dbus_timer_ready, timeout); if (!timer_id) return FALSE; id_type *idp = malloc(sizeof(id_type)); if (!idp) return FALSE; @@ -129,7 +130,7 @@ toggle_dbus_timeout(DBusTimeout *timeout, void *data) { DBusConnection* -glfw_dbus_connect_to(const char *path, const char* err_msg) { +glfw_dbus_connect_to(const char *path, const char* err_msg, const char *name) { DBusError err; dbus_error_init(&err); DBusConnection *ans = dbus_connection_open_private(path, &err); @@ -145,13 +146,13 @@ glfw_dbus_connect_to(const char *path, const char* err_msg) { return NULL; } dbus_connection_flush(ans); - if (!dbus_connection_set_watch_functions(ans, add_dbus_watch, remove_dbus_watch, toggle_dbus_watch, NULL, NULL)) { + if (!dbus_connection_set_watch_functions(ans, add_dbus_watch, remove_dbus_watch, toggle_dbus_watch, (void*)name, NULL)) { _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to set DBUS watches on connection to: %s", path); dbus_connection_close(ans); dbus_connection_unref(ans); return NULL; } - if (!dbus_connection_set_timeout_functions(ans, add_dbus_timeout, remove_dbus_timeout, toggle_dbus_timeout, NULL, NULL)) { + if (!dbus_connection_set_timeout_functions(ans, add_dbus_timeout, remove_dbus_timeout, toggle_dbus_timeout, (void*)name, NULL)) { _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to set DBUS timeout functions on connection to: %s", path); dbus_connection_close(ans); dbus_connection_unref(ans); diff --git a/glfw/dbus_glfw.h b/glfw/dbus_glfw.h index 141e02c78..589dd922e 100644 --- a/glfw/dbus_glfw.h +++ b/glfw/dbus_glfw.h @@ -39,7 +39,7 @@ typedef struct { GLFWbool glfw_dbus_init(_GLFWDBUSData *dbus, EventLoopData *eld); void glfw_dbus_terminate(_GLFWDBUSData *dbus); -DBusConnection* glfw_dbus_connect_to(const char *path, const char* err_msg); +DBusConnection* glfw_dbus_connect_to(const char *path, const char* err_msg, const char* name); void glfw_dbus_close_connection(DBusConnection *conn); GLFWbool glfw_dbus_call_void_method(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...); GLFWbool diff --git a/glfw/ibus_glfw.c b/glfw/ibus_glfw.c index b514e5475..b0503e729 100644 --- a/glfw/ibus_glfw.c +++ b/glfw/ibus_glfw.c @@ -186,7 +186,7 @@ setup_connection(_GLFWIBUSData *ibus) { ibus->conn = NULL; } debug("Connecting to IBUS daemon @ %s for IME input management\n", ibus->address); - ibus->conn = glfw_dbus_connect_to(ibus->address, "Failed to connect to the IBUS daemon, with error"); + ibus->conn = glfw_dbus_connect_to(ibus->address, "Failed to connect to the IBUS daemon, with error", "ibus"); if (!ibus->conn) return GLFW_FALSE; free((void*)ibus->input_ctx_path); ibus->input_ctx_path = NULL; if (!glfw_dbus_call_method_with_reply( diff --git a/glfw/wl_init.c b/glfw/wl_init.c index 32bdd0da2..b2192f39d 100644 --- a/glfw/wl_init.c +++ b/glfw/wl_init.c @@ -679,7 +679,7 @@ int _glfwPlatformInit(void) } initPollData(&_glfw.wl.eventLoopData, _glfw.wl.eventLoopData.wakeupFds[0], wl_display_get_fd(_glfw.wl.display)); glfw_dbus_init(&_glfw.wl.dbus, &_glfw.wl.eventLoopData); - _glfw.wl.keyRepeatInfo.keyRepeatTimer = addTimer(&_glfw.wl.eventLoopData, 0.5, 0, dispatchPendingKeyRepeats, NULL); + _glfw.wl.keyRepeatInfo.keyRepeatTimer = addTimer(&_glfw.wl.eventLoopData, "wayland-keyrepeat", 0.5, 0, dispatchPendingKeyRepeats, NULL); _glfw.wl.registry = wl_display_get_registry(_glfw.wl.display); wl_registry_add_listener(_glfw.wl.registry, ®istryListener, NULL); diff --git a/glfw/x11_init.c b/glfw/x11_init.c index f517ea2f9..39cea0736 100644 --- a/glfw/x11_init.c +++ b/glfw/x11_init.c @@ -661,7 +661,7 @@ int _glfwPlatformInit(void) if (!_glfwInitJoysticksLinux()) return GLFW_FALSE; if (_glfw.linjs.inotify > 0) - addWatch(&_glfw.x11.eventLoopData, _glfw.linjs.inotify, POLLIN, 1, NULL, NULL); + addWatch(&_glfw.x11.eventLoopData, "joystick", _glfw.linjs.inotify, POLLIN, 1, NULL, NULL); #endif _glfwInitTimerPOSIX();