attempting to fix some potential input dialog crashes

This commit is contained in:
StapleButter 2018-12-15 00:22:28 +01:00
parent e6c03619a1
commit 56c2160855
1 changed files with 18 additions and 8 deletions

View File

@ -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);
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;
}
// TODO: pick smarter??
int keyval = keyvals[0];
g_free(keyvals);
return uiUnixStrdupText(gdk_keyval_name(keyval));
return uiUnixStrdupText(ret);
}
enum {