Introduce libweston-desktop
libweston-desktop is an abstraction library for compositors wanting to support desktop-like shells. The API is designed from xdg_shell features, as it will eventually be the recommended shell for modern applications to use. In the future, adding new shell protocols support will be easier, as limited to libweston-desktop. The library versioning is the same as libweston. If one of them break ABI compatibility, the other will too. The compositor will only ever see toplevel surfaces (“windows”), with all the other being internal implementation details. Thus, popups and associated grabs are handled entirely in libweston-desktop. Xwayland special surfaces (override-redirect) are special-cased to a dedicated layer, as the compositor should not know about them. All the shell error checking is taken care of too, as well as some specification rules (e.g. sizes constraint for maximized and fullscreen surfaces). All the compositor has to do is define a few callbacks in the interface struct, and manage toplevel surfaces. Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net> Reviewed-by: Jonas Ådahl <jadahl@gmail.com> Acked-by: Giulio Camuffo <giulio.camuffo@kdab.com> Differential Revision: https://phabricator.freedesktop.org/D1207
This commit is contained in:
@@ -3382,6 +3382,43 @@ weston_surface_get_content_size(struct weston_surface *surface,
|
||||
rer->surface_get_content_size(surface, width, height);
|
||||
}
|
||||
|
||||
/** Get the bounding box of a surface and its subsurfaces
|
||||
*
|
||||
* \param surface The surface to query.
|
||||
* \return The bounding box relative to the surface origin.
|
||||
*
|
||||
*/
|
||||
WL_EXPORT struct weston_geometry
|
||||
weston_surface_get_bounding_box(struct weston_surface *surface)
|
||||
{
|
||||
pixman_region32_t region;
|
||||
pixman_box32_t *box;
|
||||
struct weston_subsurface *subsurface;
|
||||
|
||||
pixman_region32_init_rect(®ion,
|
||||
0, 0,
|
||||
surface->width, surface->height);
|
||||
|
||||
wl_list_for_each(subsurface, &surface->subsurface_list, parent_link)
|
||||
pixman_region32_union_rect(®ion, ®ion,
|
||||
subsurface->position.x,
|
||||
subsurface->position.y,
|
||||
subsurface->surface->width,
|
||||
subsurface->surface->height);
|
||||
|
||||
box = pixman_region32_extents(®ion);
|
||||
struct weston_geometry geometry = {
|
||||
.x = box->x1,
|
||||
.y = box->y1,
|
||||
.width = box->x2 - box->x1,
|
||||
.height = box->y2 - box->y1,
|
||||
};
|
||||
|
||||
pixman_region32_fini(®ion);
|
||||
|
||||
return geometry;
|
||||
}
|
||||
|
||||
/** Copy surface contents to system memory.
|
||||
*
|
||||
* \param surface The surface to copy from.
|
||||
|
||||
@@ -46,6 +46,19 @@ extern "C" {
|
||||
#include "zalloc.h"
|
||||
#include "timeline-object.h"
|
||||
|
||||
struct weston_geometry {
|
||||
int32_t x, y;
|
||||
int32_t width, height;
|
||||
};
|
||||
|
||||
struct weston_position {
|
||||
int32_t x, y;
|
||||
};
|
||||
|
||||
struct weston_size {
|
||||
int32_t width, height;
|
||||
};
|
||||
|
||||
struct weston_transform {
|
||||
struct weston_matrix matrix;
|
||||
struct wl_list link;
|
||||
@@ -1547,6 +1560,9 @@ void
|
||||
weston_surface_get_content_size(struct weston_surface *surface,
|
||||
int *width, int *height);
|
||||
|
||||
struct weston_geometry
|
||||
weston_surface_get_bounding_box(struct weston_surface *surface);
|
||||
|
||||
int
|
||||
weston_surface_copy_content(struct weston_surface *surface,
|
||||
void *target, size_t size,
|
||||
|
||||
Reference in New Issue
Block a user