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
1=== modified file 'src/View/AbstractDirectoryView.vala'
2--- src/View/AbstractDirectoryView.vala 2015-07-22 14:46:48 +0000
3+++ src/View/AbstractDirectoryView.vala 2015-07-26 19:00:31 +0000
4@@ -2439,13 +2439,19 @@
5
6 /** Keyboard event handling **/
7
8- protected uint get_keycode (int keyval) {
9+ /** Returns true if the code parameter matches the keycode of the keyval parameter for
10+ * any keyboard group or level (in order to allow for non-QWERTY keyboards) **/
11+ protected bool match_keycode (int keyval, uint code) {
12 Gdk.KeymapKey [] keys;
13 Gdk.Keymap keymap = Gdk.Keymap.get_default ();
14 if (keymap.get_entries_for_keyval (keyval, out keys)) {
15- return keys[0].keycode;
16- } else
17- return 0;
18+ foreach (var key in keys) {
19+ if (code == key.keycode)
20+ return true;
21+ }
22+ }
23+
24+ return false;
25 }
26
27 protected virtual bool on_view_key_press_event (Gdk.EventKey event) {
28@@ -2567,7 +2573,7 @@
29 * is unaffected by internationalized layout */
30 if (only_control_pressed) {
31 uint keycode = event.hardware_keycode;
32- if (keycode == get_keycode (Gdk.Key.c)) {
33+ if (match_keycode (Gdk.Key.c, keycode)) {
34 /* Should not copy files in the trash - cut instead */
35 if (in_trash) {
36 Eel.show_warning_dialog (_("Cannot copy files that are in the trash"),
37@@ -2579,18 +2585,16 @@
38 common_actions.activate_action ("copy", null);
39
40 return true;
41- } else if (keycode == get_keycode (Gdk.Key.v)) {
42+ } else if (match_keycode (Gdk.Key.v, keycode)) {
43 if (!in_recent) {
44 /* Will drop any existing selection and paste into current directory */
45 action_set_enabled (common_actions, "paste_into", true);
46 unselect_all ();
47 common_actions.activate_action ("paste_into", null);
48-
49 return true;
50 }
51- } else if (keycode == get_keycode (Gdk.Key.x)) {
52+ } else if (match_keycode (Gdk.Key.x, keycode)) {
53 selection_actions.activate_action ("cut", null);
54-
55 return true;
56 }
57 }

Subscribers

People subscribed via source and target branches

to all changes: