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

Proposed by Kirill Romanov
Status: Merged
Approved by: Leonardo Lemos
Approved revision: 925
Merged at revision: 928
Proposed branch: lp:~djaler1/maya/fix-1235489
Merge into: lp:~elementary-apps/maya/trunk
Diff against target: 50 lines (+22/-10)
1 file modified
src/Application.vala (+22/-10)
To merge this branch: bzr merge lp:~djaler1/maya/fix-1235489
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+300270@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/Application.vala'
2--- src/Application.vala 2016-01-18 23:25:24 +0000
3+++ src/Application.vala 2016-07-17 09:16:19 +0000
4@@ -246,6 +246,21 @@
5 dialog.present ();
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 /**
24 * Creates the main window.
25 */
26@@ -264,17 +279,14 @@
27 window.delete_event.connect (on_window_delete_event);
28 window.destroy.connect (on_quit);
29 window.key_press_event.connect ((e) => {
30- switch (e.keyval) {
31- case Gdk.Key.@q:
32- case Gdk.Key.@w:
33- if ((e.state & Gdk.ModifierType.CONTROL_MASK) != 0) {
34- window.destroy ();
35- }
36-
37- break;
38+ uint keycode = e.hardware_keycode;
39+ if ((e.state & Gdk.ModifierType.CONTROL_MASK) != 0) {
40+ if (match_keycode (Gdk.Key.q, keycode) || match_keycode (Gdk.Key.w, keycode)) {
41+ window.destroy ();
42 }
43-
44- return false;
45+ }
46+
47+ return false;
48 });
49
50 toolbar = new View.MayaToolbar ();

Subscribers

People subscribed via source and target branches