Merge lp:~djaler1/noise/fix-1235489 into lp:~elementary-apps/noise/trunk

Proposed by Kirill Romanov
Status: Merged
Approved by: Leonardo Lemos
Approved revision: 1958
Merged at revision: 1963
Proposed branch: lp:~djaler1/noise/fix-1235489
Merge into: lp:~elementary-apps/noise/trunk
Diff against target: 47 lines (+24/-7)
1 file modified
src/LibraryWindow.vala (+24/-7)
To merge this branch: bzr merge lp:~djaler1/noise/fix-1235489
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+300271@code.launchpad.net

Commit message

Fix Ctrl+Q support for non-Latin keyboard layouts

Description of the change

Fix bug#1235489

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/LibraryWindow.vala'
2--- src/LibraryWindow.vala 2016-02-07 16:33:45 +0000
3+++ src/LibraryWindow.vala 2016-07-17 09:35:14 +0000
4@@ -152,6 +152,21 @@
5 }
6 }
7
8+ /** Returns true if the code parameter matches the keycode of the keyval parameter for
9+ * any keyboard group or level (in order to allow for non-QWERTY keyboards) **/
10+ protected bool match_keycode (int keyval, uint code) {
11+ Gdk.KeymapKey [] keys;
12+ Gdk.Keymap keymap = Gdk.Keymap.get_default ();
13+ if (keymap.get_entries_for_keyval (keyval, out keys)) {
14+ foreach (var key in keys) {
15+ if (code == key.keycode)
16+ return true;
17+ }
18+ }
19+
20+ return false;
21+ }
22+
23 public override bool key_press_event (Gdk.EventKey event) {
24 // when typing in an editable widget, such as Gtk.Entry, don't block the event
25 var focus_widget = get_focus ();
26@@ -191,13 +206,15 @@
27 }
28
29 break;
30- case Gdk.Key.f:
31- searchField.grab_focus ();
32- return false;
33- case Gdk.Key.q:
34- case Gdk.Key.w:
35- this.destroy ();
36- return true;
37+ }
38+
39+ uint keycode = event.hardware_keycode;
40+ if (match_keycode (Gdk.Key.f, keycode)) {
41+ searchField.grab_focus ();
42+ return false;
43+ } else if (match_keycode (Gdk.Key.q, keycode) || match_keycode (Gdk.Key.w, keycode)) {
44+ this.destroy ();
45+ return true;
46 }
47 }
48

Subscribers

People subscribed via source and target branches