diff options
author | headkaze <headkaze@gmail.com> | 2021-12-17 18:21:37 +0300 |
---|---|---|
committer | headkaze <headkaze@gmail.com> | 2021-12-17 18:21:37 +0300 |
commit | 470e517b31dd4eaf7ac53f7dfd8df91d44e64a96 (patch) | |
tree | 9252aa9aa2325fb3f25e2af6ac04a5b91c72557a | |
parent | 2143beac690d085506a02fd6038d5dae8e16e724 (diff) |
Add remmina_pref_keymap_get_table
-rw-r--r-- | plugins/rdp/rdp_plugin.c | 12 | ||||
-rw-r--r-- | src/include/remmina/plugin.h | 1 | ||||
-rw-r--r-- | src/remmina_plugin_manager.c | 1 | ||||
-rw-r--r-- | src/remmina_pref.c | 12 | ||||
-rw-r--r-- | src/remmina_pref.h | 2 |
5 files changed, 18 insertions, 10 deletions
diff --git a/plugins/rdp/rdp_plugin.c b/plugins/rdp/rdp_plugin.c index 6d33531ac..7d33cd2cd 100644 --- a/plugins/rdp/rdp_plugin.c +++ b/plugins/rdp/rdp_plugin.c @@ -80,7 +80,6 @@ #include <pthread_np.h> #endif -#include "../remmina_pref.h" #include <freerdp/locale/keyboard.h> #define REMMINA_RDP_FEATURE_TOOL_REFRESH 1 @@ -1299,21 +1298,17 @@ static gchar *remmina_get_rdp_kbd_remap(const gchar *keymap) gchar *rdp_kbd_remap = NULL; gint i; Display *display; - - if (!keymap || keymap[0] == '\0') - return rdp_kbd_remap; - table = (guint *)g_hash_table_lookup(remmina_keymap_table, keymap); + table = remmina_plugin_service->pref_keymap_get_table(keymap); if (!table) return rdp_kbd_remap; rdp_kbd_remap = g_malloc0(512); display = XOpenDisplay(0); for (i = 0; table[i] > 0; i += 2) { - g_snprintf(keys, sizeof(keys), "0x%02x=0x%02x", freerdp_keyboard_get_rdp_scancode_from_x11_keycode(XKeysymToKeycode(display, table[i])), freerdp_keyboard_get_rdp_scancode_from_x11_keycode(XKeysymToKeycode(display, table[i + 1]))); - + g_snprintf(keys, sizeof(keys), "0x%02x=0x%02x", freerdp_keyboard_get_rdp_scancode_from_x11_keycode(XKeysymToKeycode(display, table[i])), + freerdp_keyboard_get_rdp_scancode_from_x11_keycode(XKeysymToKeycode(display, table[i + 1]))); if (i > 0) g_strlcat(rdp_kbd_remap, ",", 512); - g_strlcat(rdp_kbd_remap, keys, 512); } XCloseDisplay(display); @@ -2775,6 +2770,7 @@ static const RemminaProtocolSetting remmina_rdp_basic_settings[] = { REMMINA_PROTOCOL_SETTING_TYPE_RESOLUTION, "resolution", NULL, FALSE, NULL, NULL, NULL, NULL }, { REMMINA_PROTOCOL_SETTING_TYPE_SELECT, "colordepth", N_("Colour depth"), FALSE, colordepth_list, NULL, NULL, NULL }, { REMMINA_PROTOCOL_SETTING_TYPE_SELECT, "network", N_("Network connection type"), FALSE, network_list, network_tooltip, NULL, NULL }, + { REMMINA_PROTOCOL_SETTING_TYPE_KEYMAP, "keymap", NULL, FALSE, NULL, NULL, NULL, NULL }, { REMMINA_PROTOCOL_SETTING_TYPE_END, NULL, NULL, FALSE, NULL, NULL, NULL, NULL } }; diff --git a/src/include/remmina/plugin.h b/src/include/remmina/plugin.h index 5c284f834..23bf2c189 100644 --- a/src/include/remmina/plugin.h +++ b/src/include/remmina/plugin.h @@ -214,6 +214,7 @@ typedef struct _RemminaPluginService { gint (*pref_get_sshtunnel_port)(void); gint (*pref_get_ssh_loglevel)(void); gboolean (*pref_get_ssh_parseconfig)(void); + guint *(*pref_keymap_get_table)(const gchar *keymap); guint (*pref_keymap_get_keyval)(const gchar *keymap, guint keyval); void (*_remmina_info)(const gchar *fmt, ...); diff --git a/src/remmina_plugin_manager.c b/src/remmina_plugin_manager.c index 08575db0e..842b847d5 100644 --- a/src/remmina_plugin_manager.c +++ b/src/remmina_plugin_manager.c @@ -236,6 +236,7 @@ RemminaPluginService remmina_plugin_manager_service = remmina_pref_get_sshtunnel_port, remmina_pref_get_ssh_loglevel, remmina_pref_get_ssh_parseconfig, + remmina_pref_keymap_get_table, remmina_pref_keymap_get_keyval, _remmina_info, diff --git a/src/remmina_pref.c b/src/remmina_pref.c index 4ef129e4c..c33c841d6 100644 --- a/src/remmina_pref.c +++ b/src/remmina_pref.c @@ -57,7 +57,7 @@ const gchar *default_resolutions = "640x480,800x600,1024x768,1152x864,1280x960,1 const gchar *default_keystrokes = "Send hello world§hello world\\n"; gchar *remmina_keymap_file; -GHashTable *remmina_keymap_table = NULL; +static GHashTable *remmina_keymap_table = NULL; /* We could customize this further if there are more requirements */ static const gchar *default_keymap_data = "# Please check gdk/gdkkeysyms.h for a full list of all key names or hex key values\n" @@ -969,6 +969,16 @@ void remmina_pref_clear_recent(void) g_key_file_free(gkeyfile); } +guint *remmina_pref_keymap_get_table(const gchar *keymap) +{ + TRACE_CALL(__func__); + + if (!keymap || keymap[0] == '\0') + return NULL; + + return (guint *)g_hash_table_lookup(remmina_keymap_table, keymap); +} + guint remmina_pref_keymap_get_keyval(const gchar *keymap, guint keyval) { TRACE_CALL(__func__); diff --git a/src/remmina_pref.h b/src/remmina_pref.h index fbb95f003..fe00f922c 100644 --- a/src/remmina_pref.h +++ b/src/remmina_pref.h @@ -229,7 +229,6 @@ typedef struct _RemminaPref { #define SSH_SOCKET_TCP_KEEPCNT 3 #define SSH_SOCKET_TCP_USER_TIMEOUT 60000 // 60 seconds -extern GHashTable *remmina_keymap_table; extern const gchar *default_resolutions; extern gchar *remmina_pref_file; extern gchar *remmina_colors_file; @@ -243,6 +242,7 @@ void remmina_pref_add_recent(const gchar *protocol, const gchar *server); gchar *remmina_pref_get_recent(const gchar *protocol); void remmina_pref_clear_recent(void); +guint *remmina_pref_keymap_get_table(const gchar *keymap); guint remmina_pref_keymap_get_keyval(const gchar *keymap, guint keyval); gchar **remmina_pref_keymap_groups(void); |