summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2022-12-01 13:18:53 +0200
committerMarius Vlad <marius.vlad@collabora.com>2024-03-11 18:15:47 +0200
commit5921beed9208e15fa45c4bb719f667cdd50cd94c (patch)
treed7832a75a2d3654012d92caf8106ec3587576f25
parent9da16115b66545cd458729af23a690e907bd9094 (diff)
meson.build, src: update for weston 11
Bump Weston library dependencies to work with Weston 11.0.0. The following changes are needed to port the compositor to the latest changes from libweston 11. Specifically we now use weston_surface_unref() instead of weston_surface_destroy(). The weston_head parameter is now needed when creating an output in weston_compositor_create_output(). We now use weston_buffer_create_solid_rgba() instead of weston_surface_set_color() to create our black curtain. A further upstream updates has been added to include some of the shell-utils wrapper but we'll get those in the next release of libweston. Finally, in order to attach heads and enable the outputs, we need to start from 1, rather than 0, and we now need lazy output placement for multiple outputs, following basically what weston is doing. Bug-AGL: SPEC-4578 Bug-AGL: SPEC-4617 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Change-Id: Ie4aa7bc09b99d85b6bda49437c5f4789012244e1
-rw-r--r--meson.build4
-rw-r--r--src/compositor.c40
-rw-r--r--src/ivi-compositor.h1
-rw-r--r--src/screenshooter.c2
-rw-r--r--src/shell.c57
5 files changed, 86 insertions, 18 deletions
diff --git a/meson.build b/meson.build
index 65a55d6..55b68cb 100644
--- a/meson.build
+++ b/meson.build
@@ -11,7 +11,7 @@ project('agl-compositor',
)
config_h = configuration_data()
-libweston_version = 'libweston-10'
+libweston_version = 'libweston-11'
pkgconfig = import('pkgconfig')
fs = import('fs')
@@ -123,7 +123,7 @@ deps_libweston = [
dependency('wayland-server'),
dependency('weston'),
libweston_dep,
- dependency('libweston-desktop-10'),
+ dependency('libweston-desktop-11'),
]
diff --git a/src/compositor.c b/src/compositor.c
index 2c8c386..c38fb1c 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -199,7 +199,8 @@ handle_output_destroy(struct wl_listener *listener, void *data)
if (output->fullscreen_view.fs &&
output->fullscreen_view.fs->view) {
- weston_surface_destroy(output->fullscreen_view.fs->view->surface);
+ weston_surface_unref(output->fullscreen_view.fs->view->surface);
+ weston_buffer_destroy_solid(output->fullscreen_view.buffer_ref);
output->fullscreen_view.fs->view = NULL;
}
@@ -539,7 +540,7 @@ try_attach_heads(struct ivi_output *output)
{
size_t fail_len = 0;
- for (size_t i = 0; i < output->add_len; ++i) {
+ for (size_t i = 1; i < output->add_len; i++) {
if (weston_output_attach_head(output->output, output->add[i]) < 0) {
struct weston_head *tmp = output->add[i];
memmove(&output->add[fail_len + 1], output->add[fail_len],
@@ -550,6 +551,39 @@ try_attach_heads(struct ivi_output *output)
return fail_len;
}
+/* Place output exactly to the right of the most recently enabled output.
+ *
+ * Historically, we haven't given much thought to output placement,
+ * simply adding outputs in a horizontal line as they're enabled. This
+ * function simply sets an output's x coordinate to the right of the
+ * most recently enabled output, and its y to zero.
+ *
+ * If you're adding new calls to this function, you're also not giving
+ * much thought to output placement, so please consider carefully if
+ * it's really doing what you want.
+ *
+ * You especially don't want to use this for any code that won't
+ * immediately enable the passed output.
+ */
+static void
+weston_output_lazy_align(struct weston_output *output)
+{
+ struct weston_compositor *c;
+ struct weston_output *peer;
+ int next_x = 0;
+
+ /* Put this output to the right of the most recently enabled output */
+ c = output->compositor;
+ if (!wl_list_empty(&c->output_list)) {
+ peer = container_of(c->output_list.prev,
+ struct weston_output, link);
+ next_x = peer->x + peer->width;
+ }
+ output->x = next_x;
+ output->y = 0;
+}
+
+
/*
* Like try_attach_heads, this reorganizes the output's add array into a failed
* and successful section.
@@ -561,6 +595,8 @@ try_enable_output(struct ivi_output *output, size_t i)
for (; i < output->add_len; ++i) {
struct weston_head *head;
+ weston_output_lazy_align(output->output);
+
if (weston_output_enable(output->output) == 0)
break;
diff --git a/src/ivi-compositor.h b/src/ivi-compositor.h
index 62e70e1..a018676 100644
--- a/src/ivi-compositor.h
+++ b/src/ivi-compositor.h
@@ -169,6 +169,7 @@ struct ivi_output {
struct fullscreen_view {
struct ivi_surface *fs;
struct wl_listener fs_destroy;
+ struct weston_buffer_reference *buffer_ref;
} fullscreen_view;
struct wl_listener output_destroy;
diff --git a/src/screenshooter.c b/src/screenshooter.c
index ef3d32e..7d3edaa 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -59,7 +59,7 @@ screenshooter_shoot(struct wl_client *client,
struct weston_output *output =
weston_head_from_resource(output_resource)->output;
struct weston_buffer *buffer =
- weston_buffer_from_resource(buffer_resource);
+ weston_buffer_from_resource(output->compositor, buffer_resource);
if (buffer == NULL) {
wl_resource_post_no_memory(resource);
diff --git a/src/shell.c b/src/shell.c
index 16d924c..4fbd8d5 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -778,7 +778,7 @@ ivi_shell_finalize(struct ivi_compositor *ivi)
wl_list_for_each(output, &ivi->outputs, link) {
if (output->fullscreen_view.fs &&
output->fullscreen_view.fs->view) {
- weston_surface_destroy(output->fullscreen_view.fs->view->surface);
+ weston_surface_unref(output->fullscreen_view.fs->view->surface);
output->fullscreen_view.fs->view = NULL;
}
}
@@ -1022,41 +1022,72 @@ destroy_black_curtain_view(struct wl_listener *listener, void *data)
}
+int
+curtain_get_label(struct weston_surface *surface, char *buf, size_t len)
+{
+ return snprintf(buf, len, "%s", "black curtain");
+}
+
+static void
+curtain_surface_committed(struct weston_surface *es, int32_t sx, int32_t sy)
+{
+
+}
+
+
static void
create_black_curtain_view(struct ivi_output *output)
{
struct weston_surface *surface = NULL;
struct weston_view *view;
struct ivi_compositor *ivi = output->ivi;
- struct weston_compositor *wc= ivi->compositor;
+ struct weston_compositor *ec = ivi->compositor;
struct weston_output *woutput = output->output;
+ struct weston_buffer_reference *buffer_ref;
if (!woutput)
return;
- surface = weston_surface_create(wc);
+ surface = weston_surface_create(ec);
if (!surface)
return;
+
view = weston_view_create(surface);
- if (!view) {
- weston_surface_destroy(surface);
- return;
- }
+ if (!view)
+ goto err_surface;
+
+ buffer_ref = weston_buffer_create_solid_rgba(ec, 0.0, 0.0, 0.0, 1.0);
+ if (buffer_ref == NULL)
+ goto err_view;
- weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1);
+ surface->committed = curtain_surface_committed;
+ surface->committed_private = NULL;
weston_surface_set_size(surface, woutput->width, woutput->height);
+
+ weston_surface_attach_solid(surface, buffer_ref,
+ woutput->width, woutput->height);
+
+ weston_surface_set_label_func(surface, curtain_get_label);
weston_view_set_position(view, woutput->x, woutput->y);
output->fullscreen_view.fs = zalloc(sizeof(struct ivi_surface));
- if (!output->fullscreen_view.fs) {
- weston_surface_destroy(surface);
- return;
- }
+ if (!output->fullscreen_view.fs)
+ goto err_view;
+
output->fullscreen_view.fs->view = view;
+ output->fullscreen_view.buffer_ref = buffer_ref;
- output->fullscreen_view.fs_destroy.notify = destroy_black_curtain_view;
+ output->fullscreen_view.fs_destroy.notify =
+ destroy_black_curtain_view;
wl_signal_add(&woutput->destroy_signal,
&output->fullscreen_view.fs_destroy);
+
+ return;
+
+err_view:
+ weston_view_destroy(view);
+err_surface:
+ weston_surface_unref(surface);
}
bool