From 0c69688aa238c3576f99486b177f527f668ee704 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Sun, 12 Jun 2022 20:51:45 +0100 Subject: [PATCH] libweston: Add weston_surface_map() wrapper Change all instances of surface->is_mapped = true, to a specialised function. Signed-off-by: Daniel Stone --- desktop-shell/input-panel.c | 2 +- desktop-shell/shell.c | 6 ++--- fullscreen-shell/fullscreen-shell.c | 2 +- include/libweston/libweston.h | 3 +++ ivi-shell/ivi-layout.c | 2 +- kiosk-shell/kiosk-shell.c | 4 ++-- libweston-desktop/xwayland.c | 2 +- libweston/compositor.c | 35 ++++++++++++++++------------- libweston/data-device.c | 2 +- libweston/input.c | 2 +- libweston/touch-calibration.c | 2 +- tests/weston-test-desktop-shell.c | 2 +- tests/weston-test.c | 2 +- 13 files changed, 37 insertions(+), 29 deletions(-) diff --git a/desktop-shell/input-panel.c b/desktop-shell/input-panel.c index 0897ffde..6dc2e427 100644 --- a/desktop-shell/input-panel.c +++ b/desktop-shell/input-panel.c @@ -103,8 +103,8 @@ show_input_panel_surface(struct input_panel_surface *ipsurf) &ipsurf->view->layer_link); weston_view_geometry_dirty(ipsurf->view); weston_view_update_transform(ipsurf->view); - ipsurf->surface->is_mapped = true; ipsurf->view->is_mapped = true; + weston_surface_map(ipsurf->surface); weston_surface_damage(ipsurf->surface); if (ipsurf->anim) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 87bcae3d..73dbdce7 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -2501,7 +2501,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface, if (!weston_surface_is_mapped(surface)) { map(shell, shsurf, sx, sy); - surface->is_mapped = true; + weston_surface_map(surface); /* as we need to survive the weston_surface destruction we'll * need to take another reference */ if (shsurf->shell->win_close_animation_type == ANIMATION_FADE) { @@ -2914,7 +2914,7 @@ configure_static_view(struct weston_view *ev, struct weston_layer *layer, int x, } weston_view_set_position(ev, ev->output->x + x, ev->output->y + y); - ev->surface->is_mapped = true; + weston_surface_map(ev->surface); ev->is_mapped = true; if (wl_list_empty(&ev->layer_link.link)) { @@ -3136,7 +3136,7 @@ lock_surface_committed(struct weston_surface *surface, int32_t sx, int32_t sy) weston_layer_entry_insert(&shell->lock_layer.view_list, &view->layer_link); weston_view_update_transform(view); - surface->is_mapped = true; + weston_surface_map(surface); view->is_mapped = true; shell_fade(shell, FADE_IN); } diff --git a/fullscreen-shell/fullscreen-shell.c b/fullscreen-shell/fullscreen-shell.c index c02ac1c3..dbec02cf 100644 --- a/fullscreen-shell/fullscreen-shell.c +++ b/fullscreen-shell/fullscreen-shell.c @@ -327,7 +327,7 @@ fs_output_create(struct fullscreen_shell *shell, struct weston_output *output) fsout->curtain = create_curtain(shell->compositor, fsout, output->x, output->y, output->width, output->height); - fsout->curtain->view->surface->is_mapped = true; + weston_surface_map(fsout->curtain->view->surface); fsout->curtain->view->is_mapped = true; weston_layer_entry_insert(&shell->layer.view_list, &fsout->curtain->view->layer_link); diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 552652fa..acfad1b3 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -1971,6 +1971,9 @@ weston_view_damage_below(struct weston_view *view); void weston_view_unmap(struct weston_view *view); +void +weston_surface_map(struct weston_surface *surface); + void weston_surface_unmap(struct weston_surface *surface); diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c index e685e356..1c42d636 100644 --- a/ivi-shell/ivi-layout.c +++ b/ivi-shell/ivi-layout.c @@ -835,7 +835,7 @@ build_view_list(struct ivi_layout *layout) weston_layer_entry_insert(&layout->layout_layer.view_list, &ivi_view->view->layer_link); - ivi_view->ivisurf->surface->is_mapped = true; + weston_surface_map(ivi_view->ivisurf->surface); ivi_view->view->is_mapped = true; } } diff --git a/kiosk-shell/kiosk-shell.c b/kiosk-shell/kiosk-shell.c index 950e5811..c109e31f 100644 --- a/kiosk-shell/kiosk-shell.c +++ b/kiosk-shell/kiosk-shell.c @@ -523,7 +523,7 @@ kiosk_shell_output_recreate_background(struct kiosk_shell_output *shoutput) &shoutput->curtain->view->layer_link); shoutput->curtain->view->is_mapped = true; - shoutput->curtain->view->surface->is_mapped = true; + weston_surface_map(shoutput->curtain->view->surface); shoutput->curtain->view->surface->output = output; weston_view_set_output(shoutput->curtain->view, output); } @@ -799,7 +799,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface, struct kiosk_shell_seat *kiosk_seat; shsurf->view->is_mapped = true; - surface->is_mapped = true; + weston_surface_map(surface); kiosk_seat = get_kiosk_shell_seat(seat); if (seat && kiosk_seat) diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c index 9d4d22b4..057fdfd5 100644 --- a/libweston-desktop/xwayland.c +++ b/libweston-desktop/xwayland.c @@ -122,7 +122,7 @@ weston_desktop_xwayland_surface_change_state(struct weston_desktop_xwayland_surf weston_layer_entry_insert(&surface->xwayland->layer.view_list, &surface->view->layer_link); surface->view->is_mapped = true; - wsurface->is_mapped = true; + weston_surface_map(wsurface); } surface->state = state; diff --git a/libweston/compositor.c b/libweston/compositor.c index a176626e..47226f73 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -2261,6 +2261,12 @@ weston_view_unmap(struct weston_view *view) } } +WL_EXPORT void +weston_surface_map(struct weston_surface *surface) +{ + surface->is_mapped = true; +} + WL_EXPORT void weston_surface_unmap(struct weston_surface *surface) { @@ -4529,22 +4535,21 @@ subsurface_committed(struct weston_surface *surface, int32_t dx, int32_t dy) * mapped, parent is not in a visible layer, so this sub-surface * will not be drawn either. */ - - if (!weston_surface_is_mapped(surface)) { - surface->is_mapped = weston_surface_has_content(surface); - - /* Cannot call weston_view_update_transform(), - * because that would call it also for the parent surface, - * which might not be mapped yet. That would lead to - * inconsistent state, where the window could never be - * mapped. - * - * Instead just force the is_mapped flag on, to make - * weston_surface_is_mapped() return true, so that when the - * parent surface does get mapped, this one will get - * included, too. See view_list_add(). - */ + if (!weston_surface_is_mapped(surface) && + weston_surface_has_content(surface)) { + weston_surface_map(surface); } + + /* Cannot call weston_view_update_transform() here, because that would + * call it also for the parent surface, which might not be mapped yet. + * That would lead to inconsistent state, where the window could never + * be mapped. + * + * Instead just force the child surface to appear mapped, to make + * weston_surface_is_mapped() return true, so that when the parent + * surface does get mapped, this one will get included, too. See + * view_list_add(). + */ } static struct weston_subsurface * diff --git a/libweston/data-device.c b/libweston/data-device.c index 3506454c..2042cce4 100644 --- a/libweston/data-device.c +++ b/libweston/data-device.c @@ -431,7 +431,7 @@ drag_surface_configure(struct weston_drag *drag, weston_layer_entry_insert(list, &drag->icon->layer_link); weston_view_update_transform(drag->icon); pixman_region32_clear(&es->pending.input); - es->is_mapped = true; + weston_surface_map(es); drag->icon->is_mapped = true; } diff --git a/libweston/input.c b/libweston/input.c index 7c8559ae..ead4b79e 100644 --- a/libweston/input.c +++ b/libweston/input.c @@ -2697,7 +2697,7 @@ pointer_cursor_surface_committed(struct weston_surface *es, weston_layer_entry_insert(&es->compositor->cursor_layer.view_list, &pointer->sprite->layer_link); weston_view_update_transform(pointer->sprite); - es->is_mapped = true; + weston_surface_map(es); pointer->sprite->is_mapped = true; } } diff --git a/libweston/touch-calibration.c b/libweston/touch-calibration.c index 11e59386..72a114a6 100644 --- a/libweston/touch-calibration.c +++ b/libweston/touch-calibration.c @@ -206,7 +206,7 @@ map_calibrator(struct weston_touch_calibrator *calibrator) calibrator->view->is_mapped = true; calibrator->surface->output = calibrator->output; - calibrator->surface->is_mapped = true; + weston_surface_map(calibrator->surface); weston_output_schedule_repaint(calibrator->output); diff --git a/tests/weston-test-desktop-shell.c b/tests/weston-test-desktop-shell.c index e6e208e6..2fb6d4b2 100644 --- a/tests/weston-test-desktop-shell.c +++ b/tests/weston-test-desktop-shell.c @@ -92,7 +92,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface, if (weston_surface_is_mapped(surface)) return; - surface->is_mapped = true; + weston_surface_map(surface); weston_layer_entry_insert(&dts->layer.view_list, &dts->view->layer_link); weston_view_set_position(dts->view, 0 - geometry.x, 0 - geometry.y); weston_view_update_transform(dts->view); diff --git a/tests/weston-test.c b/tests/weston-test.c index f8db286b..58f27a04 100644 --- a/tests/weston-test.c +++ b/tests/weston-test.c @@ -164,7 +164,7 @@ test_surface_committed(struct weston_surface *surface, int32_t sx, int32_t sy) weston_view_update_transform(test_surface->view); - test_surface->surface->is_mapped = true; + weston_surface_map(test_surface->surface); test_surface->view->is_mapped = true; }