diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index de8f374b..641254d3 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -121,7 +121,7 @@ struct shell_surface { struct { struct weston_transform transform; /* matrix from x, y */ - struct weston_view *black_view; + struct weston_curtain *black_view; } fullscreen; struct weston_transform workspace_transform; @@ -564,9 +564,9 @@ create_focus_surface(struct weston_compositor *ec, curtain_params.surface_private = fsurf; - fsurf->view = weston_curtain_create(ec, &curtain_params); - weston_view_set_output(fsurf->view, output); - fsurf->view->is_mapped = true; + fsurf->curtain = weston_curtain_create(ec, &curtain_params); + weston_view_set_output(fsurf->curtain->view, output); + fsurf->curtain->view->is_mapped = true; wl_list_init(&fsurf->workspace_transform.link); @@ -576,7 +576,7 @@ create_focus_surface(struct weston_compositor *ec, static void focus_surface_destroy(struct focus_surface *fsurf) { - weston_surface_destroy(fsurf->surface); + weston_curtain_destroy(fsurf->curtain); free(fsurf); } @@ -651,8 +651,8 @@ focus_state_surface_destroy(struct wl_listener *listener, void *data) weston_view_animation_destroy(state->ws->focus_animation); state->ws->focus_animation = weston_fade_run( - state->ws->fsurf_front->view, - state->ws->fsurf_front->view->alpha, 0.0, 300, + state->ws->fsurf_front->curtain->view, + state->ws->fsurf_front->curtain->view->alpha, 0.0, 300, focus_animation_done, state->ws); } @@ -804,19 +804,19 @@ animate_focus_change(struct desktop_shell *shell, struct workspace *ws, ws->fsurf_front = create_focus_surface(shell->compositor, output); if (ws->fsurf_front == NULL) return; - ws->fsurf_front->view->alpha = 0.0; + ws->fsurf_front->curtain->view->alpha = 0.0; ws->fsurf_back = create_focus_surface(shell->compositor, output); if (ws->fsurf_back == NULL) { focus_surface_destroy(ws->fsurf_front); return; } - ws->fsurf_back->view->alpha = 0.0; + ws->fsurf_back->curtain->view->alpha = 0.0; focus_surface_created = true; } else { - weston_layer_entry_remove(&ws->fsurf_front->view->layer_link); - weston_layer_entry_remove(&ws->fsurf_back->view->layer_link); + weston_layer_entry_remove(&ws->fsurf_front->curtain->view->layer_link); + weston_layer_entry_remove(&ws->fsurf_back->curtain->view->layer_link); } if (ws->focus_animation) { @@ -826,29 +826,29 @@ animate_focus_change(struct desktop_shell *shell, struct workspace *ws, if (to) weston_layer_entry_insert(&to->layer_link, - &ws->fsurf_front->view->layer_link); + &ws->fsurf_front->curtain->view->layer_link); else if (from) weston_layer_entry_insert(&ws->layer.view_list, - &ws->fsurf_front->view->layer_link); + &ws->fsurf_front->curtain->view->layer_link); if (focus_surface_created) { ws->focus_animation = weston_fade_run( - ws->fsurf_front->view, - ws->fsurf_front->view->alpha, 0.4, 300, + ws->fsurf_front->curtain->view, + ws->fsurf_front->curtain->view->alpha, 0.4, 300, focus_animation_done, ws); } else if (from) { weston_layer_entry_insert(&from->layer_link, - &ws->fsurf_back->view->layer_link); + &ws->fsurf_back->curtain->view->layer_link); ws->focus_animation = weston_stable_fade_run( - ws->fsurf_front->view, 0.0, - ws->fsurf_back->view, 0.4, + ws->fsurf_front->curtain->view, 0.0, + ws->fsurf_back->curtain->view, 0.4, focus_animation_done, ws); } else if (to) { weston_layer_entry_insert(&ws->layer.view_list, - &ws->fsurf_back->view->layer_link); + &ws->fsurf_back->curtain->view->layer_link); ws->focus_animation = weston_stable_fade_run( - ws->fsurf_front->view, 0.0, - ws->fsurf_back->view, 0.4, + ws->fsurf_front->curtain->view, 0.0, + ws->fsurf_back->curtain->view, 0.4, focus_animation_done, ws); } } @@ -1930,7 +1930,7 @@ unset_fullscreen(struct shell_surface *shsurf) wl_list_init(&shsurf->fullscreen.transform.link); if (shsurf->fullscreen.black_view) - weston_surface_destroy(shsurf->fullscreen.black_view->surface); + weston_curtain_destroy(shsurf->fullscreen.black_view); shsurf->fullscreen.black_view = NULL; if (shsurf->saved_position_valid) @@ -2071,6 +2071,7 @@ shell_ensure_fullscreen_black_view(struct shell_surface *shsurf) .surface_private = shsurf->view, .capture_input = true, }; + struct weston_view *view; assert(weston_desktop_surface_get_fullscreen(shsurf->desktop_surface)); @@ -2078,14 +2079,14 @@ shell_ensure_fullscreen_black_view(struct shell_surface *shsurf) shsurf->fullscreen.black_view = weston_curtain_create(ec, &curtain_params); } + view = shsurf->fullscreen.black_view->view; - weston_view_set_output(shsurf->fullscreen.black_view, output); - shsurf->fullscreen.black_view->is_mapped = true; + weston_view_set_output(view, output); + view->is_mapped = true; - weston_layer_entry_remove(&shsurf->fullscreen.black_view->layer_link); - weston_layer_entry_insert(&shsurf->view->layer_link, - &shsurf->fullscreen.black_view->layer_link); - weston_view_geometry_dirty(shsurf->fullscreen.black_view); + weston_layer_entry_remove(&view->layer_link); + weston_layer_entry_insert(&shsurf->view->layer_link, &view->layer_link); + weston_view_geometry_dirty(view); weston_surface_damage(surface); shsurf->state.lowered = false; @@ -2337,7 +2338,7 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface, } if (shsurf->fullscreen.black_view) - weston_surface_destroy(shsurf->fullscreen.black_view->surface); + weston_curtain_destroy(shsurf->fullscreen.black_view); weston_surface_set_label_func(surface, NULL); weston_desktop_surface_set_user_data(shsurf->desktop_surface, NULL); @@ -3620,9 +3621,9 @@ lower_fullscreen_layer(struct desktop_shell *shell, * in the fullscreen layer. */ if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface)) { /* Hide the black view */ - weston_layer_entry_remove(&shsurf->fullscreen.black_view->layer_link); - wl_list_init(&shsurf->fullscreen.black_view->layer_link.link); - weston_view_damage_below(shsurf->fullscreen.black_view); + weston_layer_entry_remove(&shsurf->fullscreen.black_view->view->layer_link); + wl_list_init(&shsurf->fullscreen.black_view->view->layer_link.link); + weston_view_damage_below(shsurf->fullscreen.black_view->view); } /* Lower the view to the workspace layer */ @@ -4323,7 +4324,7 @@ switcher_next(struct switcher *switcher) shsurf = get_shell_surface(switcher->current->surface); if (shsurf && weston_desktop_surface_get_fullscreen(shsurf->desktop_surface)) - shsurf->fullscreen.black_view->alpha = 1.0; + shsurf->fullscreen.black_view->view->alpha = 1.0; } static void diff --git a/desktop-shell/shell.h b/desktop-shell/shell.h index b06b9066..dc4fc9c0 100644 --- a/desktop-shell/shell.h +++ b/desktop-shell/shell.h @@ -91,8 +91,7 @@ struct exposay { }; struct focus_surface { - struct weston_surface *surface; - struct weston_view *view; + struct weston_curtain *curtain; struct weston_transform workspace_transform; }; diff --git a/kiosk-shell/kiosk-shell.c b/kiosk-shell/kiosk-shell.c index c8c2276d..66aa3910 100644 --- a/kiosk-shell/kiosk-shell.c +++ b/kiosk-shell/kiosk-shell.c @@ -486,8 +486,8 @@ kiosk_shell_output_recreate_background(struct kiosk_shell_output *shoutput) uint32_t bg_color = 0x0; struct weston_curtain_params curtain_params = {}; - if (shoutput->background_view) - weston_surface_destroy(shoutput->background_view->surface); + if (shoutput->curtain) + weston_curtain_destroy(shoutput->curtain); if (!output) return; @@ -514,18 +514,18 @@ kiosk_shell_output_recreate_background(struct kiosk_shell_output *shoutput) curtain_params.surface_committed = NULL; curtain_params.surface_private = NULL; - shoutput->background_view = weston_curtain_create(ec, &curtain_params); + shoutput->curtain = weston_curtain_create(ec, &curtain_params); - weston_surface_set_role(shoutput->background_view->surface, + weston_surface_set_role(shoutput->curtain->view->surface, "kiosk-shell-background", NULL, 0); weston_layer_entry_insert(&shell->background_layer.view_list, - &shoutput->background_view->layer_link); + &shoutput->curtain->view->layer_link); - shoutput->background_view->is_mapped = true; - shoutput->background_view->surface->is_mapped = true; - shoutput->background_view->surface->output = output; - weston_view_set_output(shoutput->background_view, output); + shoutput->curtain->view->is_mapped = true; + shoutput->curtain->view->surface->is_mapped = true; + shoutput->curtain->view->surface->output = output; + weston_view_set_output(shoutput->curtain->view, output); } static void @@ -534,8 +534,8 @@ kiosk_shell_output_destroy(struct kiosk_shell_output *shoutput) shoutput->output = NULL; shoutput->output_destroy_listener.notify = NULL; - if (shoutput->background_view) - weston_surface_destroy(shoutput->background_view->surface); + if (shoutput->curtain) + weston_curtain_destroy(shoutput->curtain); wl_list_remove(&shoutput->output_destroy_listener.link); wl_list_remove(&shoutput->link); diff --git a/kiosk-shell/kiosk-shell.h b/kiosk-shell/kiosk-shell.h index 070ba1ab..3eb82cd9 100644 --- a/kiosk-shell/kiosk-shell.h +++ b/kiosk-shell/kiosk-shell.h @@ -88,7 +88,7 @@ struct kiosk_shell_seat { struct kiosk_shell_output { struct weston_output *output; struct wl_listener output_destroy_listener; - struct weston_view *background_view; + struct weston_curtain *curtain; struct kiosk_shell *shell; struct wl_list link; diff --git a/shared/shell-utils.c b/shared/shell-utils.c index 58342f68..7a2f1df5 100644 --- a/shared/shell-utils.c +++ b/shared/shell-utils.c @@ -138,28 +138,31 @@ surface_get_label(struct weston_surface *surface, char *buf, size_t len) c ? " of " : "", c ?: ""); } -struct weston_view * +struct weston_curtain * weston_curtain_create(struct weston_compositor *compositor, struct weston_curtain_params *params) { + struct weston_curtain *curtain; struct weston_surface *surface = NULL; struct weston_view *view; + curtain = zalloc(sizeof(*curtain)); + if (curtain == NULL) + goto err; + surface = weston_surface_create(compositor); - if (surface == NULL) { - weston_log("no memory\n"); - return NULL; - } + if (surface == NULL) + goto err_curtain; + view = weston_view_create(surface); - if (view == NULL) { - weston_log("no memory\n"); - weston_surface_destroy(surface); - return NULL; - } + if (view == NULL) + goto err_surface; surface->committed = params->surface_committed; surface->committed_private = params->surface_private; + curtain->view = view; + weston_surface_set_color(surface, params->r, params->g, params->b, params->a); weston_surface_set_label_func(surface, params->get_label); @@ -183,5 +186,23 @@ weston_curtain_create(struct weston_compositor *compositor, weston_surface_set_size(surface, params->width, params->height); weston_view_set_position(view, params->x, params->y); - return view; + return curtain; + +err_surface: + weston_surface_destroy(surface); +err_curtain: + free(curtain); +err: + weston_log("no memory\n"); + return NULL; +} + +void +weston_curtain_destroy(struct weston_curtain *curtain) +{ + struct weston_surface *surface = curtain->view->surface; + + weston_view_destroy(curtain->view); + weston_surface_destroy(surface); + free(curtain); } diff --git a/shared/shell-utils.h b/shared/shell-utils.h index 33d93caa..8e2e5cb3 100644 --- a/shared/shell-utils.h +++ b/shared/shell-utils.h @@ -36,6 +36,10 @@ struct weston_curtain_params { bool capture_input; }; +struct weston_curtain { + struct weston_view *view; +}; + struct weston_output * get_default_output(struct weston_compositor *compositor); @@ -52,8 +56,9 @@ surface_subsurfaces_boundingbox(struct weston_surface *surface, int32_t *x, int surface_get_label(struct weston_surface *surface, char *buf, size_t len); -/* helper to create a view w/ a color - */ -struct weston_view * +/* helper to create a view w/ a color */ +struct weston_curtain * weston_curtain_create(struct weston_compositor *compositor, struct weston_curtain_params *params); +void +weston_curtain_destroy(struct weston_curtain *curtain); diff --git a/tests/safe-signal-output-removal-test.c b/tests/safe-signal-output-removal-test.c index 57268120..6eb28085 100644 --- a/tests/safe-signal-output-removal-test.c +++ b/tests/safe-signal-output-removal-test.c @@ -38,7 +38,7 @@ struct test_output { struct weston_compositor *compositor; struct weston_output *output; struct wl_listener output_destroy_listener; - struct weston_view *view; + struct weston_curtain *curtain; }; static enum test_result_code @@ -60,8 +60,8 @@ output_destroy(struct test_output *t_output) t_output->output = NULL; t_output->output_destroy_listener.notify = NULL; - if (t_output->view) - weston_surface_destroy(t_output->view->surface); + if (t_output->curtain) + weston_curtain_destroy(t_output->curtain); wl_list_remove(&t_output->output_destroy_listener.link); free(t_output); @@ -88,9 +88,9 @@ output_create_view(struct test_output *t_output) .surface_private = NULL, }; - t_output->view = weston_curtain_create(t_output->compositor, - &curtain_params); - weston_view_set_output(t_output->view, t_output->output); + t_output->curtain = weston_curtain_create(t_output->compositor, + &curtain_params); + weston_view_set_output(t_output->curtain->view, t_output->output); /* weston_compositor_remove_output() has to be patched with * weston_signal_emit_mutable() to avoid signal corruption */