mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-13 00:45:58 +01:00
xdg-shell: wrap wl_resource_get_user_data
This commit is contained in:
parent
717bdccb6e
commit
4b354745fe
2 changed files with 153 additions and 95 deletions
|
@ -223,17 +223,25 @@ static void xdg_surface_destroy(struct wlr_xdg_surface *surface) {
|
|||
}
|
||||
|
||||
|
||||
static const struct xdg_positioner_interface xdg_positioner_implementation;
|
||||
|
||||
static struct wlr_xdg_positioner *xdg_positioner_from_resource(
|
||||
struct wl_resource *resource) {
|
||||
assert(wl_resource_instance_of(resource, &xdg_positioner_interface,
|
||||
&xdg_positioner_implementation));
|
||||
return wl_resource_get_user_data(resource);
|
||||
}
|
||||
|
||||
static void xdg_positioner_destroy(struct wl_resource *resource) {
|
||||
struct wlr_xdg_positioner *positioner =
|
||||
wl_resource_get_user_data(resource);
|
||||
xdg_positioner_from_resource(resource);
|
||||
free(positioner);
|
||||
|
||||
}
|
||||
|
||||
static void xdg_positioner_protocol_set_size(struct wl_client *client,
|
||||
struct wl_resource *resource, int32_t width, int32_t height) {
|
||||
struct wlr_xdg_positioner *positioner =
|
||||
wl_resource_get_user_data(resource);
|
||||
xdg_positioner_from_resource(resource);
|
||||
|
||||
if (width < 1 || height < 1) {
|
||||
wl_resource_post_error(resource,
|
||||
|
@ -250,7 +258,7 @@ static void xdg_positioner_protocol_set_anchor_rect(struct wl_client *client,
|
|||
struct wl_resource *resource, int32_t x, int32_t y, int32_t width,
|
||||
int32_t height) {
|
||||
struct wlr_xdg_positioner *positioner =
|
||||
wl_resource_get_user_data(resource);
|
||||
xdg_positioner_from_resource(resource);
|
||||
|
||||
if (width < 0 || height < 0) {
|
||||
wl_resource_post_error(resource,
|
||||
|
@ -268,7 +276,7 @@ static void xdg_positioner_protocol_set_anchor_rect(struct wl_client *client,
|
|||
static void xdg_positioner_protocol_set_anchor(struct wl_client *client,
|
||||
struct wl_resource *resource, uint32_t anchor) {
|
||||
struct wlr_xdg_positioner *positioner =
|
||||
wl_resource_get_user_data(resource);
|
||||
xdg_positioner_from_resource(resource);
|
||||
|
||||
if (anchor > XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT) {
|
||||
wl_resource_post_error(resource,
|
||||
|
@ -283,7 +291,7 @@ static void xdg_positioner_protocol_set_anchor(struct wl_client *client,
|
|||
static void xdg_positioner_protocol_set_gravity(struct wl_client *client,
|
||||
struct wl_resource *resource, uint32_t gravity) {
|
||||
struct wlr_xdg_positioner *positioner =
|
||||
wl_resource_get_user_data(resource);
|
||||
xdg_positioner_from_resource(resource);
|
||||
|
||||
if (gravity > XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT) {
|
||||
wl_resource_post_error(resource,
|
||||
|
@ -299,7 +307,7 @@ static void xdg_positioner_protocol_set_constraint_adjustment(
|
|||
struct wl_client *client, struct wl_resource *resource,
|
||||
uint32_t constraint_adjustment) {
|
||||
struct wlr_xdg_positioner *positioner =
|
||||
wl_resource_get_user_data(resource);
|
||||
xdg_positioner_from_resource(resource);
|
||||
|
||||
positioner->constraint_adjustment = constraint_adjustment;
|
||||
}
|
||||
|
@ -307,7 +315,7 @@ static void xdg_positioner_protocol_set_constraint_adjustment(
|
|||
static void xdg_positioner_protocol_set_offset(struct wl_client *client,
|
||||
struct wl_resource *resource, int32_t x, int32_t y) {
|
||||
struct wlr_xdg_positioner *positioner =
|
||||
wl_resource_get_user_data(resource);
|
||||
xdg_positioner_from_resource(resource);
|
||||
|
||||
positioner->offset.x = x;
|
||||
positioner->offset.y = y;
|
||||
|
@ -353,52 +361,6 @@ static void xdg_shell_create_positioner(struct wl_client *wl_client,
|
|||
positioner, xdg_positioner_destroy);
|
||||
}
|
||||
|
||||
static void xdg_popup_protocol_grab(struct wl_client *client,
|
||||
struct wl_resource *resource, struct wl_resource *seat_resource,
|
||||
uint32_t serial) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_seat_client *seat_client = wl_resource_get_user_data(seat_resource);
|
||||
|
||||
if (surface->popup_state->committed) {
|
||||
wl_resource_post_error(surface->popup_state->resource,
|
||||
XDG_POPUP_ERROR_INVALID_GRAB,
|
||||
"xdg_popup is already mapped");
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_xdg_popup_grab *popup_grab =
|
||||
xdg_shell_popup_grab_from_seat(surface->client->shell,
|
||||
seat_client->seat);
|
||||
|
||||
struct wlr_xdg_surface *topmost = xdg_popup_grab_get_topmost(popup_grab);
|
||||
bool parent_is_toplevel =
|
||||
surface->popup_state->parent->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL;
|
||||
|
||||
if ((topmost == NULL && !parent_is_toplevel) ||
|
||||
(topmost != NULL && topmost != surface->popup_state->parent)) {
|
||||
wl_resource_post_error(surface->client->resource,
|
||||
XDG_WM_BASE_ERROR_NOT_THE_TOPMOST_POPUP,
|
||||
"xdg_popup was not created on the topmost popup");
|
||||
return;
|
||||
}
|
||||
|
||||
popup_grab->client = surface->client->client;
|
||||
surface->popup_state->seat = seat_client->seat;
|
||||
|
||||
wl_list_insert(&popup_grab->popups, &surface->popup_state->grab_link);
|
||||
|
||||
wlr_seat_pointer_start_grab(seat_client->seat,
|
||||
&popup_grab->pointer_grab);
|
||||
wlr_seat_keyboard_start_grab(seat_client->seat,
|
||||
&popup_grab->keyboard_grab);
|
||||
}
|
||||
|
||||
static const struct xdg_popup_interface xdg_popup_implementation = {
|
||||
.destroy = resource_destroy,
|
||||
.grab = xdg_popup_protocol_grab,
|
||||
};
|
||||
|
||||
|
||||
static struct wlr_box xdg_positioner_get_geometry(
|
||||
struct wlr_xdg_positioner *positioner,
|
||||
struct wlr_xdg_surface *surface, struct wlr_xdg_surface *parent) {
|
||||
|
@ -486,23 +448,90 @@ static struct wlr_box xdg_positioner_get_geometry(
|
|||
return geometry;
|
||||
}
|
||||
|
||||
|
||||
static const struct xdg_popup_interface xdg_popup_implementation;
|
||||
|
||||
static struct wlr_xdg_surface *xdg_surface_from_xdg_popup_resource(
|
||||
struct wl_resource *resource) {
|
||||
assert(wl_resource_instance_of(resource, &xdg_popup_interface,
|
||||
&xdg_popup_implementation));
|
||||
return wl_resource_get_user_data(resource);
|
||||
}
|
||||
|
||||
static void xdg_popup_protocol_grab(struct wl_client *client,
|
||||
struct wl_resource *resource, struct wl_resource *seat_resource,
|
||||
uint32_t serial) {
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_popup_resource(resource);
|
||||
struct wlr_seat_client *seat_client =
|
||||
wlr_seat_client_from_resource(seat_resource);
|
||||
|
||||
if (surface->popup_state->committed) {
|
||||
wl_resource_post_error(surface->popup_state->resource,
|
||||
XDG_POPUP_ERROR_INVALID_GRAB,
|
||||
"xdg_popup is already mapped");
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_xdg_popup_grab *popup_grab =
|
||||
xdg_shell_popup_grab_from_seat(surface->client->shell,
|
||||
seat_client->seat);
|
||||
|
||||
struct wlr_xdg_surface *topmost = xdg_popup_grab_get_topmost(popup_grab);
|
||||
bool parent_is_toplevel =
|
||||
surface->popup_state->parent->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL;
|
||||
|
||||
if ((topmost == NULL && !parent_is_toplevel) ||
|
||||
(topmost != NULL && topmost != surface->popup_state->parent)) {
|
||||
wl_resource_post_error(surface->client->resource,
|
||||
XDG_WM_BASE_ERROR_NOT_THE_TOPMOST_POPUP,
|
||||
"xdg_popup was not created on the topmost popup");
|
||||
return;
|
||||
}
|
||||
|
||||
popup_grab->client = surface->client->client;
|
||||
surface->popup_state->seat = seat_client->seat;
|
||||
|
||||
wl_list_insert(&popup_grab->popups, &surface->popup_state->grab_link);
|
||||
|
||||
wlr_seat_pointer_start_grab(seat_client->seat,
|
||||
&popup_grab->pointer_grab);
|
||||
wlr_seat_keyboard_start_grab(seat_client->seat,
|
||||
&popup_grab->keyboard_grab);
|
||||
}
|
||||
|
||||
static const struct xdg_popup_interface xdg_popup_implementation = {
|
||||
.destroy = resource_destroy,
|
||||
.grab = xdg_popup_protocol_grab,
|
||||
};
|
||||
|
||||
static void xdg_popup_resource_destroy(struct wl_resource *resource) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_popup_resource(resource);
|
||||
if (surface != NULL) {
|
||||
xdg_surface_destroy(surface);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct xdg_surface_interface xdg_surface_implementation;
|
||||
|
||||
static struct wlr_xdg_surface *xdg_surface_from_resource(
|
||||
struct wl_resource *resource) {
|
||||
assert(wl_resource_instance_of(resource, &xdg_surface_interface,
|
||||
&xdg_surface_implementation));
|
||||
return wl_resource_get_user_data(resource);
|
||||
}
|
||||
|
||||
static void xdg_surface_get_popup(struct wl_client *client,
|
||||
struct wl_resource *resource, uint32_t id,
|
||||
struct wl_resource *parent_resource,
|
||||
struct wl_resource *positioner_resource) {
|
||||
struct wlr_xdg_surface *surface =
|
||||
wl_resource_get_user_data(resource);
|
||||
xdg_surface_from_resource(resource);
|
||||
struct wlr_xdg_surface *parent =
|
||||
wl_resource_get_user_data(parent_resource);
|
||||
xdg_surface_from_resource(parent_resource);
|
||||
struct wlr_xdg_positioner *positioner =
|
||||
wl_resource_get_user_data(positioner_resource);
|
||||
xdg_positioner_from_resource(positioner_resource);
|
||||
|
||||
if (positioner->size.width == -1 || positioner->anchor_rect.width == -1) {
|
||||
wl_resource_post_error(resource,
|
||||
|
@ -546,13 +575,23 @@ static void xdg_surface_get_popup(struct wl_client *client,
|
|||
}
|
||||
|
||||
|
||||
static const struct xdg_toplevel_interface xdg_toplevel_implementation;
|
||||
|
||||
static struct wlr_xdg_surface *xdg_surface_from_xdg_toplevel_resource(
|
||||
struct wl_resource *resource) {
|
||||
assert(wl_resource_instance_of(resource, &xdg_toplevel_interface,
|
||||
&xdg_toplevel_implementation));
|
||||
return wl_resource_get_user_data(resource);
|
||||
}
|
||||
|
||||
static void xdg_toplevel_protocol_set_parent(struct wl_client *client,
|
||||
struct wl_resource *resource, struct wl_resource *parent_resource) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
struct wlr_xdg_surface *parent = NULL;
|
||||
|
||||
if (parent_resource != NULL) {
|
||||
parent = wl_resource_get_user_data(parent_resource);
|
||||
parent = xdg_surface_from_xdg_toplevel_resource(parent_resource);
|
||||
}
|
||||
|
||||
surface->toplevel_state->parent = parent;
|
||||
|
@ -560,7 +599,8 @@ static void xdg_toplevel_protocol_set_parent(struct wl_client *client,
|
|||
|
||||
static void xdg_toplevel_protocol_set_title(struct wl_client *client,
|
||||
struct wl_resource *resource, const char *title) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
char *tmp;
|
||||
|
||||
tmp = strdup(title);
|
||||
|
@ -574,7 +614,8 @@ static void xdg_toplevel_protocol_set_title(struct wl_client *client,
|
|||
|
||||
static void xdg_toplevel_protocol_set_app_id(struct wl_client *client,
|
||||
struct wl_resource *resource, const char *app_id) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
char *tmp;
|
||||
|
||||
tmp = strdup(app_id);
|
||||
|
@ -589,9 +630,10 @@ static void xdg_toplevel_protocol_set_app_id(struct wl_client *client,
|
|||
static void xdg_toplevel_protocol_show_window_menu(struct wl_client *client,
|
||||
struct wl_resource *resource, struct wl_resource *seat_resource,
|
||||
uint32_t serial, int32_t x, int32_t y) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
struct wlr_seat_client *seat =
|
||||
wl_resource_get_user_data(seat_resource);
|
||||
wlr_seat_client_from_resource(seat_resource);
|
||||
|
||||
if (!surface->configured) {
|
||||
wl_resource_post_error(surface->toplevel_state->resource,
|
||||
|
@ -619,9 +661,10 @@ static void xdg_toplevel_protocol_show_window_menu(struct wl_client *client,
|
|||
static void xdg_toplevel_protocol_move(struct wl_client *client,
|
||||
struct wl_resource *resource, struct wl_resource *seat_resource,
|
||||
uint32_t serial) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
struct wlr_seat_client *seat =
|
||||
wl_resource_get_user_data(seat_resource);
|
||||
wlr_seat_client_from_resource(seat_resource);
|
||||
|
||||
if (!surface->configured) {
|
||||
wl_resource_post_error(surface->toplevel_state->resource,
|
||||
|
@ -647,9 +690,10 @@ static void xdg_toplevel_protocol_move(struct wl_client *client,
|
|||
static void xdg_toplevel_protocol_resize(struct wl_client *client,
|
||||
struct wl_resource *resource, struct wl_resource *seat_resource,
|
||||
uint32_t serial, uint32_t edges) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
struct wlr_seat_client *seat =
|
||||
wl_resource_get_user_data(seat_resource);
|
||||
wlr_seat_client_from_resource(seat_resource);
|
||||
|
||||
if (!surface->configured) {
|
||||
wl_resource_post_error(surface->toplevel_state->resource,
|
||||
|
@ -675,39 +719,44 @@ static void xdg_toplevel_protocol_resize(struct wl_client *client,
|
|||
|
||||
static void xdg_toplevel_protocol_set_max_size(struct wl_client *client,
|
||||
struct wl_resource *resource, int32_t width, int32_t height) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
surface->toplevel_state->next.max_width = width;
|
||||
surface->toplevel_state->next.max_height = height;
|
||||
}
|
||||
|
||||
static void xdg_toplevel_protocol_set_min_size(struct wl_client *client,
|
||||
struct wl_resource *resource, int32_t width, int32_t height) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
surface->toplevel_state->next.min_width = width;
|
||||
surface->toplevel_state->next.min_height = height;
|
||||
}
|
||||
|
||||
static void xdg_toplevel_protocol_set_maximized(struct wl_client *client,
|
||||
struct wl_resource *resource) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
surface->toplevel_state->next.maximized = true;
|
||||
wlr_signal_emit_safe(&surface->events.request_maximize, surface);
|
||||
}
|
||||
|
||||
static void xdg_toplevel_protocol_unset_maximized(struct wl_client *client,
|
||||
struct wl_resource *resource) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
surface->toplevel_state->next.maximized = false;
|
||||
wlr_signal_emit_safe(&surface->events.request_maximize, surface);
|
||||
}
|
||||
|
||||
static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
|
||||
struct wl_resource *resource, struct wl_resource *output_resource) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
|
||||
struct wlr_output *output = NULL;
|
||||
if (output_resource != NULL) {
|
||||
output = wl_resource_get_user_data(output_resource);
|
||||
output = wlr_output_from_resource(output_resource);
|
||||
}
|
||||
|
||||
surface->toplevel_state->next.fullscreen = true;
|
||||
|
@ -723,7 +772,8 @@ static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
|
|||
|
||||
static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
|
||||
struct wl_resource *resource) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
|
||||
surface->toplevel_state->next.fullscreen = false;
|
||||
|
||||
|
@ -738,12 +788,12 @@ static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
|
|||
|
||||
static void xdg_toplevel_protocol_set_minimized(struct wl_client *client,
|
||||
struct wl_resource *resource) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
wlr_signal_emit_safe(&surface->events.request_minimize, surface);
|
||||
}
|
||||
|
||||
static const struct xdg_toplevel_interface xdg_toplevel_implementation =
|
||||
{
|
||||
static const struct xdg_toplevel_interface xdg_toplevel_implementation = {
|
||||
.destroy = resource_destroy,
|
||||
.set_parent = xdg_toplevel_protocol_set_parent,
|
||||
.set_title = xdg_toplevel_protocol_set_title,
|
||||
|
@ -761,14 +811,16 @@ static const struct xdg_toplevel_interface xdg_toplevel_implementation =
|
|||
};
|
||||
|
||||
static void xdg_surface_resource_destroy(struct wl_resource *resource) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_resource(resource);
|
||||
if (surface != NULL) {
|
||||
xdg_surface_destroy(surface);
|
||||
}
|
||||
}
|
||||
|
||||
static void xdg_toplevel_resource_destroy(struct wl_resource *resource) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface =
|
||||
xdg_surface_from_xdg_toplevel_resource(resource);
|
||||
if (surface != NULL) {
|
||||
xdg_surface_destroy(surface);
|
||||
}
|
||||
|
@ -776,7 +828,7 @@ static void xdg_toplevel_resource_destroy(struct wl_resource *resource) {
|
|||
|
||||
static void xdg_surface_get_toplevel(struct wl_client *client,
|
||||
struct wl_resource *resource, uint32_t id) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface = xdg_surface_from_resource(resource);
|
||||
|
||||
if (wlr_surface_set_role(surface->surface, wlr_desktop_xdg_toplevel_role,
|
||||
resource, XDG_WM_BASE_ERROR_ROLE)) {
|
||||
|
@ -818,7 +870,7 @@ static void wlr_xdg_toplevel_ack_configure(
|
|||
|
||||
static void xdg_surface_ack_configure(struct wl_client *client,
|
||||
struct wl_resource *resource, uint32_t serial) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface = xdg_surface_from_resource(resource);
|
||||
|
||||
if (surface->role == WLR_XDG_SURFACE_ROLE_NONE) {
|
||||
wl_resource_post_error(surface->resource,
|
||||
|
@ -868,7 +920,7 @@ static void xdg_surface_ack_configure(struct wl_client *client,
|
|||
static void xdg_surface_set_window_geometry(struct wl_client *client,
|
||||
struct wl_resource *resource, int32_t x, int32_t y, int32_t width,
|
||||
int32_t height) {
|
||||
struct wlr_xdg_surface *surface = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_surface *surface = xdg_surface_from_resource(resource);
|
||||
|
||||
if (surface->role == WLR_XDG_SURFACE_ROLE_NONE) {
|
||||
wl_resource_post_error(surface->resource,
|
||||
|
@ -897,9 +949,7 @@ static bool wlr_xdg_surface_toplevel_state_compare(
|
|||
struct wlr_xdg_toplevel *state) {
|
||||
struct {
|
||||
struct wlr_xdg_toplevel_state state;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
|
||||
uint32_t width, height;
|
||||
} configured;
|
||||
|
||||
// is pending state different from current state?
|
||||
|
@ -1158,11 +1208,20 @@ static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface,
|
|||
}
|
||||
}
|
||||
|
||||
static const struct xdg_wm_base_interface xdg_shell_impl;
|
||||
|
||||
static struct wlr_xdg_client *xdg_client_from_resource(
|
||||
struct wl_resource *resource) {
|
||||
assert(wl_resource_instance_of(resource, &xdg_wm_base_interface,
|
||||
&xdg_shell_impl));
|
||||
return wl_resource_get_user_data(resource);
|
||||
}
|
||||
|
||||
static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
||||
struct wl_resource *client_resource, uint32_t id,
|
||||
struct wl_resource *surface_resource) {
|
||||
struct wlr_xdg_client *client =
|
||||
wl_resource_get_user_data(client_resource);
|
||||
xdg_client_from_resource(client_resource);
|
||||
|
||||
struct wlr_xdg_surface *surface;
|
||||
if (!(surface = calloc(1, sizeof(struct wlr_xdg_surface)))) {
|
||||
|
@ -1185,7 +1244,7 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
|||
|
||||
surface->client = client;
|
||||
surface->role = WLR_XDG_SURFACE_ROLE_NONE;
|
||||
surface->surface = wl_resource_get_user_data(surface_resource);
|
||||
surface->surface = wlr_surface_from_resource(surface_resource);
|
||||
surface->resource = wl_resource_create(wl_client,
|
||||
&xdg_surface_interface, wl_resource_get_version(client_resource),
|
||||
id);
|
||||
|
@ -1236,7 +1295,7 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
|||
|
||||
static void xdg_shell_pong(struct wl_client *wl_client,
|
||||
struct wl_resource *resource, uint32_t serial) {
|
||||
struct wlr_xdg_client *client = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_client *client = xdg_client_from_resource(resource);
|
||||
|
||||
if (client->ping_serial != serial) {
|
||||
return;
|
||||
|
@ -1246,7 +1305,7 @@ static void xdg_shell_pong(struct wl_client *wl_client,
|
|||
client->ping_serial = 0;
|
||||
}
|
||||
|
||||
static struct xdg_wm_base_interface xdg_shell_impl = {
|
||||
static const struct xdg_wm_base_interface xdg_shell_impl = {
|
||||
.destroy = resource_destroy,
|
||||
.create_positioner = xdg_shell_create_positioner,
|
||||
.get_xdg_surface = xdg_shell_get_xdg_surface,
|
||||
|
@ -1254,7 +1313,7 @@ static struct xdg_wm_base_interface xdg_shell_impl = {
|
|||
};
|
||||
|
||||
static void wlr_xdg_client_destroy(struct wl_resource *resource) {
|
||||
struct wlr_xdg_client *client = wl_resource_get_user_data(resource);
|
||||
struct wlr_xdg_client *client = xdg_client_from_resource(resource);
|
||||
|
||||
struct wlr_xdg_surface *surface, *tmp = NULL;
|
||||
wl_list_for_each_safe(surface, tmp, &client->surfaces, link) {
|
||||
|
|
|
@ -487,7 +487,8 @@ static void xdg_popup_resource_destroy(struct wl_resource *resource) {
|
|||
|
||||
static const struct zxdg_surface_v6_interface zxdg_surface_v6_implementation;
|
||||
|
||||
static struct wlr_xdg_surface_v6 *xdg_surface_from_resource(struct wl_resource *resource) {
|
||||
static struct wlr_xdg_surface_v6 *xdg_surface_from_resource(
|
||||
struct wl_resource *resource) {
|
||||
assert(wl_resource_instance_of(resource, &zxdg_surface_v6_interface,
|
||||
&zxdg_surface_v6_implementation));
|
||||
return wl_resource_get_user_data(resource);
|
||||
|
@ -918,9 +919,7 @@ static bool wlr_xdg_surface_v6_toplevel_state_compare(
|
|||
struct wlr_xdg_toplevel_v6 *state) {
|
||||
struct {
|
||||
struct wlr_xdg_toplevel_v6_state state;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
|
||||
uint32_t width, height;
|
||||
} configured;
|
||||
|
||||
// is pending state different from current state?
|
||||
|
|
Loading…
Reference in a new issue