@@ -245,33 +245,6 @@ static void relay_send_im_state(struct sway_input_method_relay *relay,
245
245
// TODO: pass intent, display popup size
246
246
}
247
247
248
- static void handle_text_input_enable (struct wl_listener * listener , void * data ) {
249
- struct sway_text_input * text_input = wl_container_of (listener , text_input ,
250
- text_input_enable );
251
- if (text_input -> relay -> input_method == NULL ) {
252
- sway_log (SWAY_INFO , "Enabling text input when input method is gone" );
253
- return ;
254
- }
255
- wlr_input_method_v2_send_activate (text_input -> relay -> input_method );
256
- relay_send_im_state (text_input -> relay , text_input -> input );
257
- }
258
-
259
- static void handle_text_input_commit (struct wl_listener * listener ,
260
- void * data ) {
261
- struct sway_text_input * text_input = wl_container_of (listener , text_input ,
262
- text_input_commit );
263
- if (!text_input -> input -> current_enabled ) {
264
- sway_log (SWAY_INFO , "Inactive text input tried to commit an update" );
265
- return ;
266
- }
267
- sway_log (SWAY_DEBUG , "Text input committed update" );
268
- if (text_input -> relay -> input_method == NULL ) {
269
- sway_log (SWAY_INFO , "Text input committed, but input method is gone" );
270
- return ;
271
- }
272
- relay_send_im_state (text_input -> relay , text_input -> input );
273
- }
274
-
275
248
static void relay_disable_text_input (struct sway_input_method_relay * relay ,
276
249
struct sway_text_input * text_input ) {
277
250
if (relay -> input_method == NULL ) {
@@ -282,30 +255,53 @@ static void relay_disable_text_input(struct sway_input_method_relay *relay,
282
255
relay_send_im_state (relay , text_input -> input );
283
256
}
284
257
285
- static void handle_text_input_disable (struct wl_listener * listener ,
258
+ static void handle_text_input_commit (struct wl_listener * listener ,
286
259
void * data ) {
287
260
struct sway_text_input * text_input = wl_container_of (listener , text_input ,
288
- text_input_disable );
289
- if (text_input -> input -> focused_surface == NULL ) {
290
- sway_log (SWAY_DEBUG , "Disabling text input, but no longer focused" );
261
+ text_input_commit );
262
+ struct wlr_text_input_v3_commit_event * event = data ;
263
+
264
+ struct sway_input_method_relay * relay = text_input -> relay ;
265
+
266
+ if (relay -> input_method == NULL ) {
267
+ sway_log (SWAY_INFO , "Text input committed, but input method is gone" );
291
268
return ;
292
269
}
293
- relay_disable_text_input (text_input -> relay , text_input );
270
+
271
+ switch (event -> type ) {
272
+ case WLR_TEXT_INPUT_V3_COMMIT_TYPE_NONE :
273
+ if (!text_input -> input -> enabled ) {
274
+ sway_log (SWAY_INFO , "Inactive text input tried to commit an update" );
275
+ break ;
276
+ }
277
+ relay_send_im_state (relay , text_input -> input );
278
+ break ;
279
+ case WLR_TEXT_INPUT_V3_COMMIT_TYPE_ENABLE :
280
+ wlr_input_method_v2_send_activate (relay -> input_method );
281
+ relay_send_im_state (relay , text_input -> input );
282
+ break ;
283
+ case WLR_TEXT_INPUT_V3_COMMIT_TYPE_DISABLE :
284
+ if (text_input -> input -> focused_surface == NULL ) {
285
+ sway_log (SWAY_DEBUG , "Disabling text input, but no longer focused" );
286
+ break ;
287
+ }
288
+ wlr_input_method_v2_send_deactivate (relay -> input_method );
289
+ relay_disable_text_input (relay , text_input );
290
+ break ;
291
+ }
294
292
}
295
293
296
294
static void handle_text_input_destroy (struct wl_listener * listener ,
297
295
void * data ) {
298
296
struct sway_text_input * text_input = wl_container_of (listener , text_input ,
299
297
text_input_destroy );
300
298
301
- if (text_input -> input -> current_enabled ) {
299
+ if (text_input -> input -> enabled ) {
302
300
relay_disable_text_input (text_input -> relay , text_input );
303
301
}
304
302
text_input_set_pending_focused_surface (text_input , NULL );
305
303
wl_list_remove (& text_input -> text_input_commit .link );
306
304
wl_list_remove (& text_input -> text_input_destroy .link );
307
- wl_list_remove (& text_input -> text_input_disable .link );
308
- wl_list_remove (& text_input -> text_input_enable .link );
309
305
wl_list_remove (& text_input -> link );
310
306
free (text_input );
311
307
}
@@ -333,15 +329,9 @@ struct sway_text_input *sway_text_input_create(
333
329
334
330
wl_list_insert (& relay -> text_inputs , & input -> link );
335
331
336
- input -> text_input_enable .notify = handle_text_input_enable ;
337
- wl_signal_add (& text_input -> events .enable , & input -> text_input_enable );
338
-
339
332
input -> text_input_commit .notify = handle_text_input_commit ;
340
333
wl_signal_add (& text_input -> events .commit , & input -> text_input_commit );
341
334
342
- input -> text_input_disable .notify = handle_text_input_disable ;
343
- wl_signal_add (& text_input -> events .disable , & input -> text_input_disable );
344
-
345
335
input -> text_input_destroy .notify = handle_text_input_destroy ;
346
336
wl_signal_add (& text_input -> events .destroy , & input -> text_input_destroy );
347
337
0 commit comments