From cce40848ce89df2b3a68cbda2aae3e03feee3cfa Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sun, 26 Mar 2023 17:38:44 +0200 Subject: Improve methods Fl_Wayland_Screen_Driver::en/disable_im() --- src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 35 ++++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src/drivers/Wayland') diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index ef19578cf..2eaa69b0d 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -802,16 +802,6 @@ static const struct wl_keyboard_listener wl_keyboard_listener = { }; -void Fl_Wayland_Screen_Driver::enable_im() { - if (seat->text_input) zwp_text_input_v3_enable(seat->text_input); -} - - -void Fl_Wayland_Screen_Driver::disable_im() { - if (seat->text_input) zwp_text_input_v3_disable(seat->text_input); -} - - void text_input_enter(void *data, struct zwp_text_input_v3 *zwp_text_input_v3, struct wl_surface *surface) { //puts("text_input_enter"); @@ -883,6 +873,25 @@ static const struct zwp_text_input_v3_listener text_input_listener = { }; +void Fl_Wayland_Screen_Driver::enable_im() { + if (text_input_base && !seat->text_input) { + seat->text_input = zwp_text_input_manager_v3_get_text_input(text_input_base, seat->wl_seat); + //printf("seat->text_input=%p\n",seat->text_input); + zwp_text_input_v3_add_listener(seat->text_input, &text_input_listener, NULL); + } +} + + +void Fl_Wayland_Screen_Driver::disable_im() { + if (seat->text_input) { + zwp_text_input_v3_disable(seat->text_input); + zwp_text_input_v3_commit(seat->text_input); + zwp_text_input_v3_destroy(seat->text_input); + seat->text_input = NULL; + } +} + + static void seat_capabilities(void *data, struct wl_seat *wl_seat, uint32_t capabilities) { struct seat *seat = (struct seat*)data; @@ -908,11 +917,7 @@ static void seat_capabilities(void *data, struct wl_seat *wl_seat, uint32_t capa seat->wl_keyboard = NULL; } Fl_Wayland_Screen_Driver *scr_driver = (Fl_Wayland_Screen_Driver*)Fl::screen_driver(); - if (scr_driver->text_input_base) { - seat->text_input = zwp_text_input_manager_v3_get_text_input(scr_driver->text_input_base, seat->wl_seat); -//printf("seat->text_input=%p\n",seat->text_input); - zwp_text_input_v3_add_listener(seat->text_input, &text_input_listener, NULL); - } + scr_driver->enable_im(); } static void seat_name(void *data, struct wl_seat *wl_seat, const char *name) { -- cgit v1.2.3