6cb2526b67
shell-utils contains a number of helpers which are currently in use by both desktop-shell and kiosk-shell. In order to extend this use to fullscreen-shell as well (which can benefit from reusing the weston_curtain infrastructure to be able to create solid-colour views which may or may not be opaque, as well as one function within fullscreen-shell which was copied wholesale to shell-utils), we need to create a separate Meson dependency object, and avoid the existing pattern of including the source from shared/ within the source list for each shell. This requires creating a new top-level directory for these shared helper functions which are required by each shell, but are not part of libweston in and of itself. shell-utils depends on libweston-desktop; libweston-desktop depends on libweston; libweston depends on shared. Thus it is not possible to expose a dependency object from the shared/ directory which declares a dependency on the libweston-desktop dependency, as Meson processes directories in order and resolves variable references as they are parsed. In order to break this deadlock, this commit creates a new top-level directory called 'shell-utils' containing only this file, which can be parsed by Meson after libweston-desktop (making the libweston-desktop Meson dependency variable available to the build file to declare a dependency on that), but before the shells (making the new Meson depenendency object available to each shell which wishes to use it). This commit contains no functional changes to any observable code. Signed-off-by: Daniel Stone <daniels@collabora.com>
132 lines
3.9 KiB
C
132 lines
3.9 KiB
C
/*
|
|
* Copyright 2021 Collabora, Ltd.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
* a copy of this software and associated documentation files (the
|
|
* "Software"), to deal in the Software without restriction, including
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
* the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the
|
|
* next paragraph) shall be included in all copies or substantial
|
|
* portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
#include "config.h"
|
|
|
|
#include <unistd.h>
|
|
#include <assert.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
#include "../shared/signal.h"
|
|
#include "shell-utils.h"
|
|
#include "weston-test-client-helper.h"
|
|
#include "weston-test-fixture-compositor.h"
|
|
|
|
struct test_output {
|
|
struct weston_compositor *compositor;
|
|
struct weston_output *output;
|
|
struct wl_listener output_destroy_listener;
|
|
struct weston_curtain *curtain;
|
|
};
|
|
|
|
static enum test_result_code
|
|
fixture_setup(struct weston_test_harness *harness)
|
|
{
|
|
struct compositor_setup setup;
|
|
|
|
compositor_setup_defaults(&setup);
|
|
setup.shell = SHELL_TEST_DESKTOP;
|
|
|
|
return weston_test_harness_execute_as_plugin(harness, &setup);
|
|
}
|
|
|
|
DECLARE_FIXTURE_SETUP(fixture_setup);
|
|
|
|
static void
|
|
output_destroy(struct test_output *t_output)
|
|
{
|
|
t_output->output = NULL;
|
|
t_output->output_destroy_listener.notify = NULL;
|
|
|
|
if (t_output->curtain)
|
|
weston_curtain_destroy(t_output->curtain);
|
|
|
|
wl_list_remove(&t_output->output_destroy_listener.link);
|
|
free(t_output);
|
|
}
|
|
|
|
static void
|
|
notify_output_destroy(struct wl_listener *listener, void *data)
|
|
{
|
|
struct test_output *t_output =
|
|
container_of(listener, struct test_output, output_destroy_listener);
|
|
|
|
output_destroy(t_output);
|
|
}
|
|
|
|
static void
|
|
output_create_view(struct test_output *t_output)
|
|
{
|
|
struct weston_curtain_params curtain_params = {
|
|
.r = 0.5, .g = 0.5, .b = 0.5, .a = 1.0,
|
|
.x = 0, .y = 0,
|
|
.width = 320, .height = 240,
|
|
.get_label = NULL,
|
|
.surface_committed = NULL,
|
|
.surface_private = NULL,
|
|
};
|
|
|
|
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 */
|
|
weston_output_destroy(t_output->output);
|
|
}
|
|
|
|
static void
|
|
output_create(struct weston_output *output)
|
|
{
|
|
struct test_output *t_output;
|
|
|
|
t_output = zalloc(sizeof *t_output);
|
|
if (t_output == NULL)
|
|
return;
|
|
|
|
t_output->output = output;
|
|
t_output->compositor = output->compositor;
|
|
|
|
t_output->output_destroy_listener.notify = notify_output_destroy;
|
|
wl_signal_add(&t_output->output->destroy_signal,
|
|
&t_output->output_destroy_listener);
|
|
|
|
output_create_view(t_output);
|
|
}
|
|
|
|
static void
|
|
create_outputs(struct weston_compositor *compositor)
|
|
{
|
|
struct weston_output *output, *output_next;
|
|
|
|
wl_list_for_each_safe(output, output_next, &compositor->output_list, link)
|
|
output_create(output);
|
|
}
|
|
|
|
PLUGIN_TEST(real_usecase_one)
|
|
{
|
|
create_outputs(compositor);
|
|
}
|