From e99ed2ad36befe9157eeef54a7458d5da212802a Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Mon, 18 Apr 2022 22:41:02 -0700 Subject: [PATCH] Defer launch input method with wl_event_loop_add_idle. Input method process may also be a XIM server which requires the correct DISPLAY to be set after xwayland start up. This helps input method to work for both wayland and Xwayland. Signed-off-by: Weng Xuetian --- compositor/text-backend.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/compositor/text-backend.c b/compositor/text-backend.c index 5cd994cb..94955bff 100644 --- a/compositor/text-backend.c +++ b/compositor/text-backend.c @@ -949,7 +949,7 @@ input_method_init_seat(struct weston_seat *seat) seat->input_method->focus_listener_initialized = true; } -static void launch_input_method(struct text_backend *text_backend); +static void launch_input_method(void *data); static void respawn_input_method_process(struct text_backend *text_backend) @@ -989,8 +989,10 @@ input_method_client_notifier(struct wl_listener *listener, void *data) } static void -launch_input_method(struct text_backend *text_backend) +launch_input_method(void *data) { + struct text_backend *text_backend = data; + if (!text_backend->input_method.path) return; @@ -1093,6 +1095,7 @@ text_backend_init(struct weston_compositor *ec) { struct text_backend *text_backend; struct weston_seat *seat; + struct wl_event_loop *loop; text_backend = zalloc(sizeof(*text_backend)); if (text_backend == NULL) @@ -1110,7 +1113,8 @@ text_backend_init(struct weston_compositor *ec) text_input_manager_create(ec); - launch_input_method(text_backend); + loop = wl_display_get_event_loop(ec->wl_display); + wl_event_loop_add_idle(loop, launch_input_method, text_backend); return text_backend; }