summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2022-01-17 14:24:03 +0000
committerDaniel Stone <daniels@collabora.com>2022-03-31 17:15:55 +0000
commitdc0f73bcac9d485d73e437173f99050bc3c9e552 (patch)
treeb46aea98979ca8f9e6830999663f841020b275cd /shared
parente031397e09d8380d2c3281c1b95d34cc01f36da1 (diff)
downloadweston-dc0f73bcac9d485d73e437173f99050bc3c9e552.tar.gz
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>
Diffstat (limited to 'shared')
-rw-r--r--shared/shell-utils.c43
-rw-r--r--shared/shell-utils.h11
2 files changed, 40 insertions, 14 deletions
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);