From b7affdd92de9ea4b55cc8d7bb8b3c27e4e96a66f Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 20 Dec 2022 21:55:31 +0100 Subject: [PATCH] Create XKB compose table/state. --- profiler/src/BackendWayland.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/profiler/src/BackendWayland.cpp b/profiler/src/BackendWayland.cpp index 4ffb96ea..02a1ad9b 100644 --- a/profiler/src/BackendWayland.cpp +++ b/profiler/src/BackendWayland.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +55,8 @@ static struct wl_keyboard* s_keyboard; static struct xkb_context* s_xkbCtx; static struct xkb_keymap* s_xkbKeymap; static struct xkb_state* s_xkbState; +static struct xkb_compose_table* s_xkbComposeTable; +static struct xkb_compose_state* s_xkbComposeState; struct Output { @@ -175,6 +178,26 @@ static void KeyboardKeymap( void*, struct wl_keyboard* kbd, uint32_t format, int if( s_xkbState ) xkb_state_unref( s_xkbState ); s_xkbState = xkb_state_new( s_xkbKeymap ); + + const char* locale = getenv( "LC_ALL" ); + if( !locale ) + { + locale = getenv( "LC_CTYPE" ); + if( !locale ) + { + locale = getenv( "LANG" ); + if( !locale ) + { + locale = "C"; + } + } + } + + if( s_xkbComposeTable ) xkb_compose_table_unref( s_xkbComposeTable ); + s_xkbComposeTable = xkb_compose_table_new_from_locale( s_xkbCtx, locale, XKB_COMPOSE_COMPILE_NO_FLAGS ); + + if( s_xkbComposeState ) xkb_compose_state_unref( s_xkbComposeState ); + s_xkbComposeState = xkb_compose_state_new( s_xkbComposeTable, XKB_COMPOSE_STATE_NO_FLAGS ); } static void KeyboardEnter( void*, struct wl_keyboard* kbd, uint32_t serial, struct wl_surface* surf, struct wl_array* keys ) @@ -532,6 +555,8 @@ Backend::~Backend() xdg_wm_base_destroy( s_wm ); wl_shm_destroy( s_shm ); wl_compositor_destroy( s_comp ); + if( s_xkbComposeState ) xkb_compose_state_unref( s_xkbComposeState ); + if( s_xkbComposeTable ) xkb_compose_table_unref( s_xkbComposeTable ); if( s_xkbState ) xkb_state_unref( s_xkbState ); if( s_xkbKeymap ) xkb_keymap_unref( s_xkbKeymap ); xkb_context_unref( s_xkbCtx );