From e0bfeb4f8faf2296ca09ece599999f241007195f Mon Sep 17 00:00:00 2001 From: "Joscha.Wloch" Date: Mon, 13 May 2024 15:10:00 +0200 Subject: [PATCH] clients: keyboard: fix resize on layput change If the content type changes, then the layout also changes, which means that the size must be adapted to the new layout and the widget must be redrawn. Signed-off-by: Joscha.Wloch --- clients/keyboard.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/clients/keyboard.c b/clients/keyboard.c index 7a267ca49..f1035c223 100644 --- a/clients/keyboard.c +++ b/clients/keyboard.c @@ -894,8 +894,28 @@ handle_content_type(void *data, { struct virtual_keyboard *keyboard = data; - keyboard->content_hint = hint; - keyboard->content_purpose = purpose; + if ((keyboard->content_hint != hint) || (keyboard->content_purpose != purpose)) + { + keyboard->content_hint = hint; + keyboard->content_purpose = purpose; + + // A change of the content type means a new layout. + // So we have to update. + const struct layout *layout = get_current_layout(keyboard); + + zwp_input_method_context_v1_language(context, + keyboard->serial, + layout->language); + zwp_input_method_context_v1_text_direction(context, + keyboard->serial, + layout->text_direction); + + window_schedule_resize(keyboard->keyboard->window, + layout->columns * key_width, + layout->rows * key_height); + + widget_schedule_redraw(keyboard->keyboard->widget); + } } static void