diff options
-rw-r--r-- | meson.build | 4 | ||||
-rw-r--r-- | src/compositor.c | 40 | ||||
-rw-r--r-- | src/ivi-compositor.h | 1 | ||||
-rw-r--r-- | src/screenshooter.c | 2 | ||||
-rw-r--r-- | src/shell.c | 57 |
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 |