[gtk/gtk-4-6: 1/2] gdkkeys-win32: Only perform substitution as last-resort
- From: Luca Bacci <lbacci src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-4-6: 1/2] gdkkeys-win32: Only perform substitution as last-resort
- Date: Thu, 3 Mar 2022 09:33:28 +0000 (UTC)
commit cc561915b71eff788922df0f0fd4f3c3ea01ebe0
Author: Philip Zander <philip zander gmail com>
Date: Sun Feb 27 16:32:59 2022 +0100
gdkkeys-win32: Only perform substitution as last-resort
Instead of performing keyboard layout substitution whenever we find a matching
entry in the registry, first try to load the original layout and only attempt
substitution when that fails.
See #4724
gdk/win32/gdkkeys-win32.c | 49 ++++++++++++++++++++++++-----------------------
1 file changed, 25 insertions(+), 24 deletions(-)
---
diff --git a/gdk/win32/gdkkeys-win32.c b/gdk/win32/gdkkeys-win32.c
index caa170b20a..eed0d8fd23 100644
--- a/gdk/win32/gdkkeys-win32.c
+++ b/gdk/win32/gdkkeys-win32.c
@@ -229,14 +229,9 @@ fail1:
return NULL;
}
-/*
- * Get the file path of the keyboard layout dll.
- * The result is heap-allocated and should be freed with g_free().
- */
static char*
-get_keyboard_layout_file (const char *layout_name)
+_get_keyboard_layout_file (const char *layout_name)
{
- char *final_layout_name = NULL;
HKEY hkey = 0;
DWORD var_type = REG_SZ;
char *result = NULL;
@@ -249,24 +244,8 @@ get_keyboard_layout_file (const char *layout_name)
"Keyboard Layouts\\";
char kbdKeyPath[sizeof (prefix) + KL_NAMELENGTH];
- /* The user may have a keyboard substitute configured */
- final_layout_name = get_keyboard_layout_substituted_name (layout_name);
- if (final_layout_name != NULL)
- {
- g_debug ("Substituting keyboard layout name from '%s' to '%s'",
- layout_name, final_layout_name);
- g_snprintf (kbdKeyPath, sizeof (prefix) + KL_NAMELENGTH, "%s%s",
- prefix, final_layout_name);
- g_free (final_layout_name);
- final_layout_name = NULL;
- }
- else
- {
- g_debug ("Could not get substitute keyboard layout name for '%s', "
- "will use '%s' directly", layout_name, layout_name);
- g_snprintf (kbdKeyPath, sizeof (prefix) + KL_NAMELENGTH, "%s%s",
- prefix, layout_name);
- }
+ g_snprintf (kbdKeyPath, sizeof (prefix) + KL_NAMELENGTH, "%s%s",
+ prefix, layout_name);
status = RegOpenKeyExA (HKEY_LOCAL_MACHINE, (LPCSTR) kbdKeyPath, 0,
KEY_QUERY_VALUE, &hkey);
@@ -326,6 +305,28 @@ fail1:
return NULL;
}
+/*
+ * Get the file path of the keyboard layout dll.
+ * The result is heap-allocated and should be freed with g_free().
+ */
+static char*
+get_keyboard_layout_file (const char *layout_name)
+{
+ char *result = _get_keyboard_layout_file (layout_name);
+
+ /* If we could not retrieve a path, it may be that we need to perform layout
+ * substitution
+ */
+ if (result == NULL)
+ {
+ char *substituted = get_keyboard_layout_substituted_name (layout_name);
+ result = _get_keyboard_layout_file (substituted);
+ g_free (substituted);
+ }
+
+ return result;
+}
+
static void
clear_keyboard_layout_info (gpointer data)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]