diff --git a/src/wl_init.c b/src/wl_init.c index d32c4adf..a8a872ce 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -91,6 +91,19 @@ #include "idle-inhibit-unstable-v1-client-protocol-code.h" #undef types +static void xkbForwardError(struct xkb_context* context, + enum xkb_log_level level, + const char *format, + va_list args) +{ + if (level <= XKB_LOG_LEVEL_ERROR) + { + char description[_GLFW_MESSAGE_SIZE]; + vsnprintf(description, _GLFW_MESSAGE_SIZE, format, args); + _glfwInputError(GLFW_PLATFORM_ERROR, "xkbcommon: %s", description); + } +} + static void wmBaseHandlePing(void* userData, struct xdg_wm_base* wmBase, uint32_t serial) @@ -675,6 +688,8 @@ int _glfwInitWayland(void) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_context_new"); _glfw.wl.xkb.context_unref = (PFN_xkb_context_unref) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_context_unref"); + _glfw.wl.xkb.context_set_log_fn = (PFN_xkb_context_set_log_fn) + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_context_set_log_fn"); _glfw.wl.xkb.keymap_new_from_string = (PFN_xkb_keymap_new_from_string) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string"); _glfw.wl.xkb.keymap_unref = (PFN_xkb_keymap_unref) @@ -841,6 +856,7 @@ int _glfwInitWayland(void) "Wayland: Failed to initialize xkb context"); return GLFW_FALSE; } + xkb_context_set_log_fn(_glfw.wl.xkb.context, xkbForwardError); // Sync so we got all registry objects wl_display_roundtrip(_glfw.wl.display); diff --git a/src/wl_platform.h b/src/wl_platform.h index bdadb657..1f3c1d99 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -170,6 +170,7 @@ typedef void (* PFN_wl_egl_window_resize)(struct wl_egl_window*, int, int, int, typedef struct xkb_context* (* PFN_xkb_context_new)(enum xkb_context_flags); typedef void (* PFN_xkb_context_unref)(struct xkb_context*); +typedef void (* PFN_xkb_context_set_log_fn)(struct xkb_context*, void(* log_fn)(struct xkb_context *context, enum xkb_log_level level, const char *format, va_list args)); typedef struct xkb_keymap* (* PFN_xkb_keymap_new_from_string)(struct xkb_context*, const char*, enum xkb_keymap_format, enum xkb_keymap_compile_flags); typedef void (* PFN_xkb_keymap_unref)(struct xkb_keymap*); typedef xkb_mod_index_t (* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap*, const char*); @@ -185,6 +186,7 @@ typedef uint32_t (* PFN_xkb_keysym_to_utf32)(xkb_keysym_t); typedef int (* PFN_xkb_keysym_to_utf8)(xkb_keysym_t, char*, size_t); #define xkb_context_new _glfw.wl.xkb.context_new #define xkb_context_unref _glfw.wl.xkb.context_unref +#define xkb_context_set_log_fn _glfw.wl.xkb.context_set_log_fn #define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string #define xkb_keymap_unref _glfw.wl.xkb.keymap_unref #define xkb_keymap_mod_get_index _glfw.wl.xkb.keymap_mod_get_index @@ -492,6 +494,7 @@ typedef struct _GLFWlibraryWayland PFN_xkb_context_new context_new; PFN_xkb_context_unref context_unref; + PFN_xkb_context_set_log_fn context_set_log_fn; PFN_xkb_keymap_new_from_string keymap_new_from_string; PFN_xkb_keymap_unref keymap_unref; PFN_xkb_keymap_mod_get_index keymap_mod_get_index;