From bd8a6da2f0dcee1c18e3b32653a861b1f7808b0b Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 21 Nov 2023 13:25:19 +0000 Subject: [PATCH] desktop-shell: Map input panel exactly once When the input panel surface gets something committed to it, we have content and thus the surface has become mapped. Do this from within the input-panel surface committed handler. When we want to show the input panel, this is when we map the view. Do this exactly once as well, and make sure that we don't attempt to map the view with an unmapped surface. This regularises the logic to be the same as almost all the other special surface users. Signed-off-by: Daniel Stone --- desktop-shell/input-panel.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/desktop-shell/input-panel.c b/desktop-shell/input-panel.c index 940d404e..9b5d3b20 100644 --- a/desktop-shell/input-panel.c +++ b/desktop-shell/input-panel.c @@ -92,6 +92,9 @@ show_input_panel_surface(struct input_panel_surface *ipsurf) if (!weston_surface_is_mapped(ipsurf->surface)) return; + if (weston_view_is_mapped(ipsurf->view)) + return; + wl_list_for_each(seat, &shell->compositor->seat_list, link) { struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat); @@ -106,11 +109,11 @@ show_input_panel_surface(struct input_panel_surface *ipsurf) continue; weston_view_set_position(ipsurf->view, pos); + weston_view_move_to_layer(ipsurf->view, + &shell->input_panel_layer.view_list); + break; } - weston_view_move_to_layer(ipsurf->view, - &shell->input_panel_layer.view_list); - if (ipsurf->anim) weston_view_animation_destroy(ipsurf->anim); @@ -189,22 +192,17 @@ input_panel_committed(struct weston_surface *surface, { struct input_panel_surface *ip_surface = surface->committed_private; struct desktop_shell *shell = ip_surface->shell; - struct weston_coord_global pos; if (!weston_surface_has_content(surface)) return; - if (calc_input_panel_position(ip_surface, &pos)) + if (weston_surface_is_mapped(surface)) return; - if (!weston_surface_is_mapped(surface)) { - weston_surface_map(surface); + weston_surface_map(surface); - if (shell->showing_input_panels) - show_input_panel_surface(ip_surface); - } - - weston_view_set_position(ip_surface->view, pos); + if (shell->showing_input_panels) + show_input_panel_surface(ip_surface); } static void