@@ -217,20 +217,6 @@ impl KimeContext {
217
217
} => {
218
218
// NOTE: Never read `serial` of KeyEvent. You should rely on serial of KimeContext
219
219
if state == KeyState :: Pressed {
220
- // Start waiting for the key hold timer event
221
- if let Some ( ( info, ref mut press_state) ) = self . repeat_state {
222
- if !press_state. is_pressing ( key) {
223
- let duration = Duration :: from_millis ( info. delay as u64 ) ;
224
- self . timer . set_timeout ( & duration) . unwrap ( ) ;
225
- * press_state = PressState :: Pressing {
226
- pressed_at : Instant :: now ( ) ,
227
- is_repeating : false ,
228
- key,
229
- wayland_time : time,
230
- } ;
231
- }
232
- }
233
-
234
220
let mut bypass = false ;
235
221
let ret = self
236
222
. engine
@@ -268,6 +254,25 @@ impl KimeContext {
268
254
269
255
if bypass {
270
256
self . vk . key ( time, key, state as _ ) ;
257
+ } else {
258
+ // If the key was not bypassed by IME, start waiting for the key hold timer
259
+ // event. Key repeat of bypassed key shouldn't be handled by IME.
260
+ //
261
+ // Reference:
262
+ // https://github.com/swaywm/sway/pull/4932#issuecomment-774113129
263
+ match self . repeat_state {
264
+ Some ( ( info, ref mut press_state) ) if !press_state. is_pressing ( key) => {
265
+ let duration = Duration :: from_millis ( info. delay as u64 ) ;
266
+ self . timer . set_timeout ( & duration) . unwrap ( ) ;
267
+ * press_state = PressState :: Pressing {
268
+ pressed_at : Instant :: now ( ) ,
269
+ is_repeating : false ,
270
+ key,
271
+ wayland_time : time,
272
+ } ;
273
+ }
274
+ _ => { }
275
+ }
271
276
}
272
277
} else {
273
278
// If user released the last pressed key, clear the timer and state
0 commit comments