shell: Encapsulate weston_curtain in its own struct

This will allow us to create a solid weston_buffer as well, since we
need to store that separately.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone
2022-01-17 14:24:03 +00:00
parent e031397e09
commit dc0f73bcac
7 changed files with 93 additions and 67 deletions
+32 -11
View File
@@ -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);
}
+8 -3
View File
@@ -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);