@@ -37,12 +37,13 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
37
37
38
38
private bool installer_mode = false ;
39
39
40
+ private Gtk . EventControllerKey key_controller;
41
+
40
42
private const uint [] NAVIGATION_KEYS = {
41
43
Gdk . Key . Up ,
42
44
Gdk . Key . Down ,
43
45
Gdk . Key . Left ,
44
46
Gdk . Key . Right ,
45
- Gdk . Key . Return ,
46
47
Gdk . Key . Tab
47
48
};
48
49
@@ -178,11 +179,16 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
178
179
manual_card. do_connect_username. connect (do_connect_username);
179
180
manual_card. do_connect. connect (do_connect);
180
181
181
- key_press_event. connect ((event) = > {
182
- if (! (event. keyval in NAVIGATION_KEYS )) {
182
+ key_controller = new Gtk .EventControllerKey (this ) {
183
+ propagation_phase = CAPTURE
184
+ };
185
+ key_controller. key_pressed. connect ((keyval, keycode, state) = > {
186
+ var mods = state & Gtk . accelerator_get_default_mod_mask ();
187
+
188
+ if (! (keyval in NAVIGATION_KEYS )) {
183
189
// Don't focus if it is a modifier or if search_box is already focused
184
190
unowned var current_focus = get_focus ();
185
- if ((event . is_modifier == 0 ) && (current_focus == null || ! current_focus. is_ancestor (current_card))) {
191
+ if ((mods == 0 ) && (current_focus == null || ! current_focus. is_ancestor (current_card))) {
186
192
current_card. grab_focus ();
187
193
}
188
194
@@ -194,15 +200,15 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
194
200
unowned var focused_entry = (Gtk . Entry ) get_focus ();
195
201
if (focused_entry != null && focused_entry. is_ancestor (current_card)) {
196
202
if (focused_entry. text == " " ) {
197
- if (event . keyval == Gdk . Key . Left ) {
198
- if (get_style_context () . direction == LTR ) {
203
+ if (keyval == Gdk . Key . Left ) {
204
+ if (Gtk . StateFlags . DIR_LTR in get_state_flags () ) {
199
205
go_previous ();
200
206
} else {
201
207
go_next ();
202
208
}
203
209
return Gdk . EVENT_STOP ;
204
- } else if (event . keyval == Gdk . Key . Right ) {
205
- if (get_style_context () . direction == LTR ) {
210
+ } else if (keyval == Gdk . Key . Right ) {
211
+ if (Gtk . StateFlags . DIR_LTR in get_state_flags () ) {
206
212
go_next ();
207
213
} else {
208
214
go_previous ();
@@ -212,8 +218,6 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
212
218
}
213
219
}
214
220
}
215
-
216
- return Gdk . EVENT_PROPAGATE ;
217
221
});
218
222
219
223
carousel. page_changed. connect ((index) = > {
@@ -497,15 +501,15 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
497
501
});
498
502
499
503
user_card. go_left. connect (() = > {
500
- if (get_style_context () . direction == LTR ) {
504
+ if (Gtk . StateFlags . DIR_LTR in get_state_flags () ) {
501
505
go_previous ();
502
506
} else {
503
507
go_next ();
504
508
}
505
509
});
506
510
507
511
user_card. go_right. connect (() = > {
508
- if (get_style_context () . direction == LTR ) {
512
+ if (Gtk . StateFlags . DIR_LTR in get_state_flags () ) {
509
513
go_next ();
510
514
} else {
511
515
go_previous ();
0 commit comments