layer-shell: Make wlr_layer_surface_v1_from_resource public

This allows compositors to leverage the `wl_instance_of` based type
check.
master
Guido Günther 3 years ago committed by Simon Ser
parent aaf787ee56
commit 4cc2a03620

@ -178,4 +178,11 @@ struct wlr_surface *wlr_layer_surface_v1_popup_surface_at(
struct wlr_layer_surface_v1 *surface, double sx, double sy, struct wlr_layer_surface_v1 *surface, double sx, double sy,
double *sub_x, double *sub_y); double *sub_x, double *sub_y);
/** Get the corresponding wlr_layer_surface_v1 from a resource.
*
* Aborts if the resource doesn't have the correct type.
*/
struct wlr_layer_surface_v1 *wlr_layer_surface_v1_from_resource(
struct wl_resource *resource);
#endif #endif

@ -28,7 +28,7 @@ static struct wlr_layer_shell_v1 *layer_shell_from_resource(
return wl_resource_get_user_data(resource); return wl_resource_get_user_data(resource);
} }
static struct wlr_layer_surface_v1 *layer_surface_from_resource( struct wlr_layer_surface_v1 *wlr_layer_surface_v1_from_resource(
struct wl_resource *resource) { struct wl_resource *resource) {
assert(wl_resource_instance_of(resource, &zwlr_layer_surface_v1_interface, assert(wl_resource_instance_of(resource, &zwlr_layer_surface_v1_interface,
&layer_surface_implementation)); &layer_surface_implementation));
@ -58,7 +58,8 @@ static void layer_surface_configure_destroy(
static void layer_surface_handle_ack_configure(struct wl_client *client, static void layer_surface_handle_ack_configure(struct wl_client *client,
struct wl_resource *resource, uint32_t serial) { struct wl_resource *resource, uint32_t serial) {
struct wlr_layer_surface_v1 *surface = layer_surface_from_resource(resource); struct wlr_layer_surface_v1 *surface =
wlr_layer_surface_v1_from_resource(resource);
if (!surface) { if (!surface) {
return; return;
@ -98,7 +99,8 @@ static void layer_surface_handle_ack_configure(struct wl_client *client,
static void layer_surface_handle_set_size(struct wl_client *client, static void layer_surface_handle_set_size(struct wl_client *client,
struct wl_resource *resource, uint32_t width, uint32_t height) { struct wl_resource *resource, uint32_t width, uint32_t height) {
struct wlr_layer_surface_v1 *surface = layer_surface_from_resource(resource); struct wlr_layer_surface_v1 *surface =
wlr_layer_surface_v1_from_resource(resource);
if (!surface) { if (!surface) {
return; return;
@ -127,7 +129,8 @@ static void layer_surface_handle_set_anchor(struct wl_client *client,
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_ANCHOR, ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_ANCHOR,
"invalid anchor %" PRIu32, anchor); "invalid anchor %" PRIu32, anchor);
} }
struct wlr_layer_surface_v1 *surface = layer_surface_from_resource(resource); struct wlr_layer_surface_v1 *surface =
wlr_layer_surface_v1_from_resource(resource);
if (!surface) { if (!surface) {
return; return;
@ -144,7 +147,7 @@ static void layer_surface_handle_set_anchor(struct wl_client *client,
static void layer_surface_handle_set_exclusive_zone(struct wl_client *client, static void layer_surface_handle_set_exclusive_zone(struct wl_client *client,
struct wl_resource *resource, int32_t zone) { struct wl_resource *resource, int32_t zone) {
struct wlr_layer_surface_v1 *surface = layer_surface_from_resource(resource); struct wlr_layer_surface_v1 *surface = wlr_layer_surface_v1_from_resource(resource);
if (!surface) { if (!surface) {
return; return;
@ -162,7 +165,8 @@ static void layer_surface_handle_set_exclusive_zone(struct wl_client *client,
static void layer_surface_handle_set_margin( static void layer_surface_handle_set_margin(
struct wl_client *client, struct wl_resource *resource, struct wl_client *client, struct wl_resource *resource,
int32_t top, int32_t right, int32_t bottom, int32_t left) { int32_t top, int32_t right, int32_t bottom, int32_t left) {
struct wlr_layer_surface_v1 *surface = layer_surface_from_resource(resource); struct wlr_layer_surface_v1 *surface =
wlr_layer_surface_v1_from_resource(resource);
if (!surface) { if (!surface) {
return; return;
@ -186,7 +190,7 @@ static void layer_surface_handle_set_margin(
static void layer_surface_handle_set_keyboard_interactivity( static void layer_surface_handle_set_keyboard_interactivity(
struct wl_client *client, struct wl_resource *resource, struct wl_client *client, struct wl_resource *resource,
uint32_t interactive) { uint32_t interactive) {
struct wlr_layer_surface_v1 *surface = layer_surface_from_resource(resource); struct wlr_layer_surface_v1 *surface = wlr_layer_surface_v1_from_resource(resource);
if (!surface) { if (!surface) {
return; return;
@ -210,7 +214,7 @@ static void layer_surface_handle_get_popup(struct wl_client *client,
struct wl_resource *layer_resource, struct wl_resource *layer_resource,
struct wl_resource *popup_resource) { struct wl_resource *popup_resource) {
struct wlr_layer_surface_v1 *parent = struct wlr_layer_surface_v1 *parent =
layer_surface_from_resource(layer_resource); wlr_layer_surface_v1_from_resource(layer_resource);
struct wlr_xdg_popup *popup = struct wlr_xdg_popup *popup =
wlr_xdg_popup_from_resource(popup_resource); wlr_xdg_popup_from_resource(popup_resource);
@ -225,7 +229,7 @@ static void layer_surface_handle_get_popup(struct wl_client *client,
static void layer_surface_set_layer(struct wl_client *client, static void layer_surface_set_layer(struct wl_client *client,
struct wl_resource *surface_resource, uint32_t layer) { struct wl_resource *surface_resource, uint32_t layer) {
struct wlr_layer_surface_v1 *surface = struct wlr_layer_surface_v1 *surface =
layer_surface_from_resource(surface_resource); wlr_layer_surface_v1_from_resource(surface_resource);
if (!surface) { if (!surface) {
return; return;
} }
@ -288,7 +292,7 @@ static void layer_surface_destroy(struct wlr_layer_surface_v1 *surface) {
static void layer_surface_resource_destroy(struct wl_resource *resource) { static void layer_surface_resource_destroy(struct wl_resource *resource) {
struct wlr_layer_surface_v1 *surface = struct wlr_layer_surface_v1 *surface =
layer_surface_from_resource(resource); wlr_layer_surface_v1_from_resource(resource);
if (surface != NULL) { if (surface != NULL) {
layer_surface_destroy(surface); layer_surface_destroy(surface);
} }

Loading…
Cancel
Save