Merge lp:~jeremywootten/pantheon-files/fix-1477663-match-keycodes-for-non-QWERTY-keyboards into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Cody Garver
Approved revision: 1900
Merged at revision: 1902
Proposed branch: lp:~jeremywootten/pantheon-files/fix-1477663-match-keycodes-for-non-QWERTY-keyboards
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 57 lines (+13/-9)
1 file modified
src/View/AbstractDirectoryView.vala (+13/-9)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-1477663-match-keycodes-for-non-QWERTY-keyboards
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+265917@code.launchpad.net

Commit message

Match keycodes for Ctrl-c, Ctrl-v and Ctrl-x on non-QUERTY keyboards (lp:1477663)

Description of the change

When using a non-QUERTY keyboard (e.g. Dvorak), the hardware keycode and group of the EventKey event do not necessarily match those returned by keymap.get_entries_for_keyval (), nor is the correct match first in the list of KeymapKeys returned.

This branch searches the whole list for a match (disregarding whether the keyboard group matches).

Keyboard Copy, Cut and Paste now work correctly with a Dvorak keyboard (only tested with a UK Dvorak keyboard).

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/View/AbstractDirectoryView.vala'
--- src/View/AbstractDirectoryView.vala 2015-07-22 14:46:48 +0000
+++ src/View/AbstractDirectoryView.vala 2015-07-26 19:00:31 +0000
@@ -2439,13 +2439,19 @@
24392439
2440/** Keyboard event handling **/2440/** Keyboard event handling **/
24412441
2442 protected uint get_keycode (int keyval) {2442 /** Returns true if the code parameter matches the keycode of the keyval parameter for
2443 * any keyboard group or level (in order to allow for non-QWERTY keyboards) **/
2444 protected bool match_keycode (int keyval, uint code) {
2443 Gdk.KeymapKey [] keys;2445 Gdk.KeymapKey [] keys;
2444 Gdk.Keymap keymap = Gdk.Keymap.get_default ();2446 Gdk.Keymap keymap = Gdk.Keymap.get_default ();
2445 if (keymap.get_entries_for_keyval (keyval, out keys)) {2447 if (keymap.get_entries_for_keyval (keyval, out keys)) {
2446 return keys[0].keycode;2448 foreach (var key in keys) {
2447 } else2449 if (code == key.keycode)
2448 return 0;2450 return true;
2451 }
2452 }
2453
2454 return false;
2449 }2455 }
24502456
2451 protected virtual bool on_view_key_press_event (Gdk.EventKey event) {2457 protected virtual bool on_view_key_press_event (Gdk.EventKey event) {
@@ -2567,7 +2573,7 @@
2567 * is unaffected by internationalized layout */2573 * is unaffected by internationalized layout */
2568 if (only_control_pressed) {2574 if (only_control_pressed) {
2569 uint keycode = event.hardware_keycode;2575 uint keycode = event.hardware_keycode;
2570 if (keycode == get_keycode (Gdk.Key.c)) {2576 if (match_keycode (Gdk.Key.c, keycode)) {
2571 /* Should not copy files in the trash - cut instead */2577 /* Should not copy files in the trash - cut instead */
2572 if (in_trash) {2578 if (in_trash) {
2573 Eel.show_warning_dialog (_("Cannot copy files that are in the trash"),2579 Eel.show_warning_dialog (_("Cannot copy files that are in the trash"),
@@ -2579,18 +2585,16 @@
2579 common_actions.activate_action ("copy", null);2585 common_actions.activate_action ("copy", null);
25802586
2581 return true;2587 return true;
2582 } else if (keycode == get_keycode (Gdk.Key.v)) {2588 } else if (match_keycode (Gdk.Key.v, keycode)) {
2583 if (!in_recent) {2589 if (!in_recent) {
2584 /* Will drop any existing selection and paste into current directory */2590 /* Will drop any existing selection and paste into current directory */
2585 action_set_enabled (common_actions, "paste_into", true);2591 action_set_enabled (common_actions, "paste_into", true);
2586 unselect_all ();2592 unselect_all ();
2587 common_actions.activate_action ("paste_into", null);2593 common_actions.activate_action ("paste_into", null);
2588
2589 return true;2594 return true;
2590 }2595 }
2591 } else if (keycode == get_keycode (Gdk.Key.x)) {2596 } else if (match_keycode (Gdk.Key.x, keycode)) {
2592 selection_actions.activate_action ("cut", null);2597 selection_actions.activate_action ("cut", null);
2593
2594 return true;2598 return true;
2595 }2599 }
2596 }2600 }

Subscribers

People subscribed via source and target branches

to all changes: