test/desktop-shell: Use weston_curtain
Use the helper we have for these, rather than open-coding. This commit is not believed to result in any functional changes. Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
parent
6cb2526b67
commit
577a832f41
@ -2,7 +2,7 @@ plugin_test_shell_desktop = shared_library(
|
||||
'weston-test-desktop-shell',
|
||||
'weston-test-desktop-shell.c',
|
||||
include_directories: common_inc,
|
||||
dependencies: [ dep_lib_desktop, dep_libweston_public, dep_libexec_weston ],
|
||||
dependencies: [ dep_lib_desktop, dep_libweston_public, dep_libexec_weston, dep_shell_utils ],
|
||||
name_prefix: '',
|
||||
install: false
|
||||
)
|
||||
|
@ -39,14 +39,14 @@
|
||||
#include "compositor/weston.h"
|
||||
#include <libweston/config-parser.h>
|
||||
#include "shared/helpers.h"
|
||||
#include "shell-utils.h"
|
||||
#include <libweston-desktop/libweston-desktop.h>
|
||||
|
||||
struct desktest_shell {
|
||||
struct wl_listener compositor_destroy_listener;
|
||||
struct weston_desktop *desktop;
|
||||
struct weston_layer background_layer;
|
||||
struct weston_surface *background_surface;
|
||||
struct weston_view *background_view;
|
||||
struct weston_curtain *background;
|
||||
struct weston_layer layer;
|
||||
struct weston_view *view;
|
||||
};
|
||||
@ -174,8 +174,7 @@ shell_destroy(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&dts->compositor_destroy_listener.link);
|
||||
|
||||
weston_desktop_destroy(dts->desktop);
|
||||
weston_view_destroy(dts->background_view);
|
||||
weston_surface_destroy(dts->background_surface);
|
||||
weston_curtain_destroy(dts->background);
|
||||
|
||||
weston_layer_fini(&dts->layer);
|
||||
weston_layer_fini(&dts->background_layer);
|
||||
@ -188,6 +187,14 @@ wet_shell_init(struct weston_compositor *ec,
|
||||
int *argc, char *argv[])
|
||||
{
|
||||
struct desktest_shell *dts;
|
||||
struct weston_curtain_params background_params = {
|
||||
.r = 0.16, .g = 0.32, .b = 0.48, .a = 1.0,
|
||||
.x = 0, .y = 0, .width = 2000, .height = 2000,
|
||||
.capture_input = true,
|
||||
.surface_committed = NULL,
|
||||
.get_label = background_get_label,
|
||||
.surface_private = NULL,
|
||||
};
|
||||
|
||||
dts = zalloc(sizeof *dts);
|
||||
if (!dts)
|
||||
@ -208,28 +215,16 @@ wet_shell_init(struct weston_compositor *ec,
|
||||
weston_layer_set_position(&dts->background_layer,
|
||||
WESTON_LAYER_POSITION_BACKGROUND);
|
||||
|
||||
dts->background_surface = weston_surface_create(ec);
|
||||
if (dts->background_surface == NULL)
|
||||
dts->background = weston_curtain_create(ec, &background_params);
|
||||
if (dts->background == NULL)
|
||||
goto out_free;
|
||||
|
||||
dts->background_view = weston_view_create(dts->background_surface);
|
||||
if (dts->background_view == NULL)
|
||||
goto out_surface;
|
||||
|
||||
weston_surface_set_role(dts->background_surface,
|
||||
weston_surface_set_role(dts->background->view->surface,
|
||||
"test-desktop background", NULL, 0);
|
||||
weston_surface_set_label_func(dts->background_surface,
|
||||
background_get_label);
|
||||
weston_surface_set_color(dts->background_surface, 0.16, 0.32, 0.48, 1.);
|
||||
pixman_region32_fini(&dts->background_surface->opaque);
|
||||
pixman_region32_init_rect(&dts->background_surface->opaque, 0, 0, 2000, 2000);
|
||||
pixman_region32_fini(&dts->background_surface->input);
|
||||
pixman_region32_init_rect(&dts->background_surface->input, 0, 0, 2000, 2000);
|
||||
|
||||
weston_surface_set_size(dts->background_surface, 2000, 2000);
|
||||
weston_view_set_position(dts->background_view, 0, 0);
|
||||
weston_layer_entry_insert(&dts->background_layer.view_list, &dts->background_view->layer_link);
|
||||
weston_view_update_transform(dts->background_view);
|
||||
weston_view_set_position(dts->background->view, 0, 0);
|
||||
weston_layer_entry_insert(&dts->background_layer.view_list,
|
||||
&dts->background->view->layer_link);
|
||||
weston_view_update_transform(dts->background->view);
|
||||
|
||||
dts->desktop = weston_desktop_create(ec, &shell_desktop_api, dts);
|
||||
if (dts->desktop == NULL)
|
||||
@ -240,10 +235,7 @@ wet_shell_init(struct weston_compositor *ec,
|
||||
return 0;
|
||||
|
||||
out_view:
|
||||
weston_view_destroy(dts->background_view);
|
||||
|
||||
out_surface:
|
||||
weston_surface_destroy(dts->background_surface);
|
||||
weston_curtain_destroy(dts->background);
|
||||
|
||||
out_free:
|
||||
wl_list_remove(&dts->compositor_destroy_listener.link);
|
||||
|
Loading…
Reference in New Issue
Block a user