@@ -8,7 +8,7 @@ import type { JsonIPC } from 'launcher_service'
8
8
9
9
const GLib : GLib = imports . gi . GLib ;
10
10
11
- const { Clutter, Gio, Pango, Shell, St } = imports . gi ;
11
+ const { Clutter, Gio, Pango, Shell, St, Gdk } = imports . gi ;
12
12
const { ModalDialog } = imports . ui . modalDialog ;
13
13
14
14
const { overview, wm } = imports . ui . main ;
@@ -87,107 +87,109 @@ export class Search {
87
87
} ) ;
88
88
89
89
this . text . connect ( "key-press-event" , ( _ : any , event : any ) => {
90
- const c = event . get_key_symbol ( ) ;
91
- const s = event . get_state ( ) ;
90
+ const key = Gdk . keyval_name ( Gdk . keyval_to_upper ( event . get_key_symbol ( ) ) ) ;
91
+ const ctrlKey = Boolean ( event . get_state ( ) & Clutter . ModifierType . CONTROL_MASK ) ;
92
92
93
93
const is_down = ( ) : boolean => {
94
- return c == 65364 || ( s == Clutter . ModifierType . CONTROL_MASK && c == 106 )
95
- || ( s == Clutter . ModifierType . CONTROL_MASK && c == 110 )
94
+ return key === "Down" ||
95
+ ( ctrlKey && key === "J" ) ||
96
+ ( ctrlKey && key === "N" ) ;
96
97
}
97
98
98
99
const is_up = ( ) : boolean => {
99
- return c == 65362 || c == 65056 || ( s == Clutter . ModifierType . CONTROL_MASK && c == 107 )
100
- || ( s == Clutter . ModifierType . CONTROL_MASK && c == 112 )
100
+ return key === "Up" || key === "ISO_Left_Tab" ||
101
+ ( ctrlKey && key === "K" ) ||
102
+ ( ctrlKey && key === "P" ) ;
101
103
}
102
104
103
105
// Up arrow or left tab was pressed
104
106
const up_arrow = ( ) => {
105
107
if ( 0 < this . active_id ) {
106
- this . select_id ( this . active_id - 1 )
108
+ this . select_id ( this . active_id - 1 ) ;
107
109
} else if ( this . active_id == 0 ) {
108
- this . select_id ( this . widgets . length - 1 )
110
+ this . select_id ( this . widgets . length - 1 ) ;
109
111
}
110
112
}
111
113
112
114
// Down arrow or tab was pressed
113
115
const down_arrow = ( ) => {
114
116
if ( this . active_id + 1 < this . widgets . length ) {
115
- this . select_id ( this . active_id + 1 )
117
+ this . select_id ( this . active_id + 1 ) ;
116
118
} else if ( this . active_id + 1 == this . widgets . length ) {
117
- this . select_id ( 0 )
119
+ this . select_id ( 0 ) ;
118
120
}
119
121
}
120
122
121
123
// Delay key repeat events, and handle up/down arrow movements if on repeat.
122
124
if ( event . get_flags ( ) != Clutter . EventFlags . NONE ) {
123
- const now = global . get_current_time ( )
125
+ const now = global . get_current_time ( ) ;
124
126
125
127
if ( now - this . last_trigger < 100 ) {
126
- return
128
+ return ;
127
129
}
128
130
129
131
this . last_trigger = now ;
130
132
131
133
if ( is_up ( ) ) {
132
- up_arrow ( )
134
+ up_arrow ( ) ;
133
135
this . select ( this . active_id ) ;
134
136
} else if ( is_down ( ) ) {
135
- down_arrow ( )
137
+ down_arrow ( ) ;
136
138
this . select ( this . active_id ) ;
137
139
}
138
140
139
141
return ;
140
142
}
141
143
142
- this . last_trigger = global . get_current_time ( )
144
+ this . last_trigger = global . get_current_time ( ) ;
143
145
144
- if ( c === 65307 ) {
146
+ if ( key === "Escape" ) {
145
147
// Escape key was pressed
146
148
this . reset ( ) ;
147
149
this . close ( ) ;
148
150
this . cancel ( ) ;
149
151
return ;
150
- } else if ( c === 65289 ) {
152
+ } else if ( key === "Tab" ) {
151
153
// Tab was pressed, check for tab completion
152
- this . complete ( )
154
+ this . complete ( ) ;
153
155
return ;
154
156
}
155
157
156
158
if ( is_up ( ) ) {
157
- up_arrow ( )
159
+ up_arrow ( ) ;
158
160
} else if ( is_down ( ) ) {
159
- down_arrow ( )
160
- } else if ( s == Clutter . ModifierType . CONTROL_MASK && c == 49 ) {
161
- this . activate_id ( 0 )
162
- return
163
- } else if ( s == Clutter . ModifierType . CONTROL_MASK && c == 50 ) {
164
- this . activate_id ( 1 )
165
- return
166
- } else if ( s == Clutter . ModifierType . CONTROL_MASK && c == 51 ) {
167
- this . activate_id ( 2 )
168
- return
169
- } else if ( s == Clutter . ModifierType . CONTROL_MASK && c == 52 ) {
170
- this . activate_id ( 3 )
171
- return
172
- } else if ( s == Clutter . ModifierType . CONTROL_MASK && c == 53 ) {
173
- this . activate_id ( 4 )
174
- return
175
- } else if ( s == Clutter . ModifierType . CONTROL_MASK && c == 54 ) {
176
- this . activate_id ( 5 )
177
- return
178
- } else if ( s == Clutter . ModifierType . CONTROL_MASK && c == 55 ) {
179
- this . activate_id ( 6 )
180
- return
181
- } else if ( s == Clutter . ModifierType . CONTROL_MASK && c == 56 ) {
182
- this . activate_id ( 7 )
183
- return
184
- } else if ( s == Clutter . ModifierType . CONTROL_MASK && c == 57 ) {
185
- this . activate_id ( 8 )
186
- return
187
- } else if ( s == Clutter . ModifierType . CONTROL_MASK && c == 113 ) {
161
+ down_arrow ( ) ;
162
+ } else if ( ctrlKey && key === "1" ) {
163
+ this . activate_id ( 0 ) ;
164
+ return ;
165
+ } else if ( ctrlKey && key === "2" ) {
166
+ this . activate_id ( 1 ) ;
167
+ return ;
168
+ } else if ( ctrlKey && key === "3" ) {
169
+ this . activate_id ( 2 ) ;
170
+ return ;
171
+ } else if ( ctrlKey && key === "4" ) {
172
+ this . activate_id ( 3 ) ;
173
+ return ;
174
+ } else if ( ctrlKey && key === "5" ) {
175
+ this . activate_id ( 4 ) ;
176
+ return ;
177
+ } else if ( ctrlKey && key === "6" ) {
178
+ this . activate_id ( 5 ) ;
179
+ return ;
180
+ } else if ( ctrlKey && key === "7" ) {
181
+ this . activate_id ( 6 ) ;
182
+ return ;
183
+ } else if ( ctrlKey && key === "8" ) {
184
+ this . activate_id ( 7 ) ;
185
+ return ;
186
+ } else if ( ctrlKey && key === "9" ) {
187
+ this . activate_id ( 8 ) ;
188
+ return ;
189
+ } else if ( ctrlKey && key === "Q" ) {
188
190
// Ctrl + Q shall quit the selected application
189
- this . quit ( this . active_id )
190
- return
191
+ this . quit ( this . active_id ) ;
192
+ return ;
191
193
}
192
194
193
195
this . select ( this . active_id ) ;
0 commit comments