desktop-shell, kiosk-shell: Migrate helpers to create a view to shell-utils
Incidentally fixes #553 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "shared/shell-utils.h"
|
||||
#include <libweston-desktop/libweston-desktop.h>
|
||||
|
||||
struct weston_output *
|
||||
get_default_output(struct weston_compositor *compositor)
|
||||
@@ -120,3 +121,55 @@ center_on_output(struct weston_view *view, struct weston_output *output)
|
||||
|
||||
weston_view_set_position(view, x, y);
|
||||
}
|
||||
|
||||
int
|
||||
surface_get_label(struct weston_surface *surface, char *buf, size_t len)
|
||||
{
|
||||
const char *t, *c;
|
||||
struct weston_desktop_surface *desktop_surface =
|
||||
weston_surface_get_desktop_surface(surface);
|
||||
|
||||
t = weston_desktop_surface_get_title(desktop_surface);
|
||||
c = weston_desktop_surface_get_app_id(desktop_surface);
|
||||
|
||||
return snprintf(buf, len, "%s window%s%s%s%s%s",
|
||||
"top-level",
|
||||
t ? " '" : "", t ?: "", t ? "'" : "",
|
||||
c ? " of " : "", c ?: "");
|
||||
}
|
||||
|
||||
struct weston_view *
|
||||
create_solid_color_surface(struct weston_compositor *compositor,
|
||||
struct weston_solid_color_surface *ss,
|
||||
float x, float y, int w, int h)
|
||||
{
|
||||
struct weston_surface *surface = NULL;
|
||||
struct weston_view *view;
|
||||
|
||||
surface = weston_surface_create(compositor);
|
||||
if (surface == NULL) {
|
||||
weston_log("no memory\n");
|
||||
return NULL;
|
||||
}
|
||||
view = weston_view_create(surface);
|
||||
if (view == NULL) {
|
||||
weston_log("no memory\n");
|
||||
weston_surface_destroy(surface);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
surface->committed = ss->surface_committed;
|
||||
surface->committed_private = ss->surface_private;
|
||||
|
||||
weston_surface_set_color(surface, ss->r, ss->g, ss->b, 1.0);
|
||||
weston_surface_set_label_func(surface, ss->get_label);
|
||||
pixman_region32_fini(&surface->opaque);
|
||||
pixman_region32_init_rect(&surface->opaque, 0, 0, w, h);
|
||||
pixman_region32_fini(&surface->input);
|
||||
pixman_region32_init_rect(&surface->input, 0, 0, w, h);
|
||||
|
||||
weston_surface_set_size(surface, w, h);
|
||||
weston_view_set_position(view, x, y);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,14 @@
|
||||
#include "shared/helpers.h"
|
||||
#include <libweston/libweston.h>
|
||||
|
||||
/* parameter for create_solid_color_surface() */
|
||||
struct weston_solid_color_surface {
|
||||
int (*get_label)(struct weston_surface *es, char *buf, size_t len);
|
||||
void (*surface_committed)(struct weston_surface *es, int32_t sx, int32_t sy);
|
||||
void *surface_private;
|
||||
float r, g, b;
|
||||
};
|
||||
|
||||
struct weston_output *
|
||||
get_default_output(struct weston_compositor *compositor);
|
||||
|
||||
@@ -38,3 +46,13 @@ center_on_output(struct weston_view *view, struct weston_output *output);
|
||||
void
|
||||
surface_subsurfaces_boundingbox(struct weston_surface *surface, int32_t *x,
|
||||
int32_t *y, int32_t *w, int32_t *h);
|
||||
|
||||
int
|
||||
surface_get_label(struct weston_surface *surface, char *buf, size_t len);
|
||||
|
||||
/* helper to create a view w/ a color
|
||||
*/
|
||||
struct weston_view *
|
||||
create_solid_color_surface(struct weston_compositor *compositor,
|
||||
struct weston_solid_color_surface *ss,
|
||||
float x, float y, int w, int h);
|
||||
|
||||
Reference in New Issue
Block a user