aboutsummaryrefslogtreecommitdiff
path: root/src/libui_sdl/libui/unix/area.c
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2018-12-15 00:22:28 +0100
committerStapleButter <thetotalworm@gmail.com>2018-12-15 00:22:28 +0100
commit56c21608551381bd6ff41e9f5358f580b461b254 (patch)
tree5832dde75d3acbaa174e934f57f386a2e4406f0c /src/libui_sdl/libui/unix/area.c
parente6c03619a1a543c909db0c0436314d17e0322396 (diff)
attempting to fix some potential input dialog crashes
Diffstat (limited to 'src/libui_sdl/libui/unix/area.c')
-rw-r--r--src/libui_sdl/libui/unix/area.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/libui_sdl/libui/unix/area.c b/src/libui_sdl/libui/unix/area.c
index 40f8624..2da9bab 100644
--- a/src/libui_sdl/libui/unix/area.c
+++ b/src/libui_sdl/libui/unix/area.c
@@ -523,16 +523,26 @@ char* uiKeyName(int scancode)
{
scancode = scancode_normal2unix(scancode);
+ char* ret;
guint* keyvals; int num;
- GdkKeymap* keymap = gdk_keymap_get_default();
- gdk_keymap_get_entries_for_keycode(keymap, scancode, NULL, &keyvals, &num);
-
- // TODO: pick smarter??
- int keyval = keyvals[0];
-
- g_free(keyvals);
+ GdkKeymap* keymap = gdk_keymap_get_for_display(gdk_display_get_default());
+ if (gdk_keymap_get_entries_for_keycode(keymap, scancode, NULL, &keyvals, &num))
+ {
+ // TODO: pick smarter??
+ int keyval = keyvals[0];
+
+ g_free(keyvals);
+
+ ret = gdk_keyval_name(keyval);
+ }
+ else
+ {
+ char tmp[16];
+ sprintf(tmp, "#%03X", scancode);
+ ret = tmp;
+ }
- return uiUnixStrdupText(gdk_keyval_name(keyval));
+ return uiUnixStrdupText(ret);
}
enum {