lxde-overlay / x11-misc / pcmanfm / files / pcmanfm-kbshortcut.patch

--- src/ptk/ptk-file-browser.c
+++ src/ptk/ptk-file-browser.c
@@ -94,6 +94,9 @@
 static void
 ptk_file_browser_update_model( PtkFileBrowser* file_browser );
 
+static gboolean
+is_latin_shortcut_key( guint keyval );
+
 /* Get GtkTreePath of the item at coordinate x, y */
 static GtkTreePath*
 folder_view_get_tree_path_at_pos( PtkFileBrowser* file_browser, int x, int y );
@@ -964,8 +967,16 @@
     g_list_free( sel_files );
 
     g_signal_emit( file_browser, signals[ SEL_CHANGE_SIGNAL ], 0 );
+    
 }
 
+static gboolean
+is_latin_shortcut_key ( guint keyval )
+{
+	return ((GDK_0 <= keyval && keyval <= GDK_9) ||
+			(GDK_A <= keyval && keyval <= GDK_Z) ||
+			(GDK_a <= keyval && keyval <= GDK_z));
+}
 
 gboolean
 on_folder_view_key_press_event ( GtkWidget *widget,
@@ -975,6 +986,45 @@
     int modifier = ( event->state & ( GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK ) );
     if ( ! gtk_widget_is_focus( widget ) )
         return FALSE;
+        
+    // Make key bindings work when the current keyboard layout is not latin
+    if ( modifier != 0 && !is_latin_shortcut_key( event->keyval ) ) {
+        // We have a non-latin char, try other keyboard groups
+        GdkKeymapKey *keys;
+        guint *keyvals;
+        gint n_entries;
+        gint level;
+
+        if ( gdk_keymap_translate_keyboard_state( NULL,
+                                                  event->hardware_keycode,
+                                                  (GdkModifierType)event->state,
+                                                  event->group,
+                                                  NULL, NULL, &level, NULL )
+            && gdk_keymap_get_entries_for_keycode( NULL,
+                                                   event->hardware_keycode,
+                                                   &keys, &keyvals,
+                                                   &n_entries ) ) {
+            gint n;
+            for ( n=0; n<n_entries; n++ ) {
+                if ( keys[n].group == event->group ) {
+                    // Skip keys from the same group
+                    continue;
+                }
+                if ( keys[n].level != level ) {
+                    // Allow only same level keys
+                    continue;
+                }
+                if ( is_latin_shortcut_key( keyvals[n] ) ) {
+                    // Latin character found
+                    event->keyval = keyvals[n];
+                    break;
+                }
+            }
+            g_free( keys );
+            g_free( keyvals );
+        }
+    } 
+        
     if ( modifier == GDK_CONTROL_MASK )
     {
         switch ( event->keyval )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.