mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-12 16:35:58 +01:00
layer-shell: Make wlr_layer_surface_v1_from_resource public
This allows compositors to leverage the `wl_instance_of` based type check.
This commit is contained in:
parent
aaf787ee56
commit
4cc2a03620
2 changed files with 21 additions and 10 deletions
|
@ -178,4 +178,11 @@ struct wlr_surface *wlr_layer_surface_v1_popup_surface_at(
|
|||
struct wlr_layer_surface_v1 *surface, double sx, double sy,
|
||||
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
|
||||
|
|
|
@ -28,7 +28,7 @@ static struct wlr_layer_shell_v1 *layer_shell_from_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) {
|
||||
assert(wl_resource_instance_of(resource, &zwlr_layer_surface_v1_interface,
|
||||
&layer_surface_implementation));
|
||||
|
@ -58,7 +58,8 @@ static void layer_surface_configure_destroy(
|
|||
|
||||
static void layer_surface_handle_ack_configure(struct wl_client *client,
|
||||
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) {
|
||||
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,
|
||||
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) {
|
||||
return;
|
||||
|
@ -127,7 +129,8 @@ static void layer_surface_handle_set_anchor(struct wl_client *client,
|
|||
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_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) {
|
||||
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,
|
||||
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) {
|
||||
return;
|
||||
|
@ -162,7 +165,8 @@ static void layer_surface_handle_set_exclusive_zone(struct wl_client *client,
|
|||
static void layer_surface_handle_set_margin(
|
||||
struct wl_client *client, struct wl_resource *resource,
|
||||
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) {
|
||||
return;
|
||||
|
@ -186,7 +190,7 @@ static void layer_surface_handle_set_margin(
|
|||
static void layer_surface_handle_set_keyboard_interactivity(
|
||||
struct wl_client *client, struct wl_resource *resource,
|
||||
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) {
|
||||
return;
|
||||
|
@ -210,7 +214,7 @@ static void layer_surface_handle_get_popup(struct wl_client *client,
|
|||
struct wl_resource *layer_resource,
|
||||
struct wl_resource *popup_resource) {
|
||||
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 =
|
||||
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,
|
||||
struct wl_resource *surface_resource, uint32_t layer) {
|
||||
struct wlr_layer_surface_v1 *surface =
|
||||
layer_surface_from_resource(surface_resource);
|
||||
wlr_layer_surface_v1_from_resource(surface_resource);
|
||||
if (!surface) {
|
||||
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) {
|
||||
struct wlr_layer_surface_v1 *surface =
|
||||
layer_surface_from_resource(resource);
|
||||
wlr_layer_surface_v1_from_resource(resource);
|
||||
if (surface != NULL) {
|
||||
layer_surface_destroy(surface);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue