|
|
@ -223,9 +223,19 @@ static void xdg_surface_destroy(struct wlr_xdg_surface_v6 *surface) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const struct zxdg_positioner_v6_interface
|
|
|
|
|
|
|
|
zxdg_positioner_v6_implementation;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct wlr_xdg_positioner_v6 *xdg_positioner_from_resource(
|
|
|
|
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
|
|
|
|
assert(wl_resource_instance_of(resource, &zxdg_positioner_v6_interface,
|
|
|
|
|
|
|
|
&zxdg_positioner_v6_implementation));
|
|
|
|
|
|
|
|
return wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_positioner_destroy(struct wl_resource *resource) {
|
|
|
|
static void xdg_positioner_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
xdg_positioner_from_resource(resource);
|
|
|
|
free(positioner);
|
|
|
|
free(positioner);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -233,7 +243,7 @@ static void xdg_positioner_destroy(struct wl_resource *resource) {
|
|
|
|
static void xdg_positioner_protocol_set_size(struct wl_client *client,
|
|
|
|
static void xdg_positioner_protocol_set_size(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, int32_t width, int32_t height) {
|
|
|
|
struct wl_resource *resource, int32_t width, int32_t height) {
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
xdg_positioner_from_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (width < 1 || height < 1) {
|
|
|
|
if (width < 1 || height < 1) {
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
wl_resource_post_error(resource,
|
|
|
@ -250,7 +260,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,
|
|
|
|
struct wl_resource *resource, int32_t x, int32_t y, int32_t width,
|
|
|
|
int32_t height) {
|
|
|
|
int32_t height) {
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
xdg_positioner_from_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (width < 1 || height < 1) {
|
|
|
|
if (width < 1 || height < 1) {
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
wl_resource_post_error(resource,
|
|
|
@ -268,7 +278,7 @@ static void xdg_positioner_protocol_set_anchor_rect(struct wl_client *client,
|
|
|
|
static void xdg_positioner_protocol_set_anchor(struct wl_client *client,
|
|
|
|
static void xdg_positioner_protocol_set_anchor(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, uint32_t anchor) {
|
|
|
|
struct wl_resource *resource, uint32_t anchor) {
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
xdg_positioner_from_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (((anchor & ZXDG_POSITIONER_V6_ANCHOR_TOP ) &&
|
|
|
|
if (((anchor & ZXDG_POSITIONER_V6_ANCHOR_TOP ) &&
|
|
|
|
(anchor & ZXDG_POSITIONER_V6_ANCHOR_BOTTOM)) ||
|
|
|
|
(anchor & ZXDG_POSITIONER_V6_ANCHOR_BOTTOM)) ||
|
|
|
@ -286,7 +296,7 @@ static void xdg_positioner_protocol_set_anchor(struct wl_client *client,
|
|
|
|
static void xdg_positioner_protocol_set_gravity(struct wl_client *client,
|
|
|
|
static void xdg_positioner_protocol_set_gravity(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, uint32_t gravity) {
|
|
|
|
struct wl_resource *resource, uint32_t gravity) {
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
xdg_positioner_from_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (((gravity & ZXDG_POSITIONER_V6_GRAVITY_TOP) &&
|
|
|
|
if (((gravity & ZXDG_POSITIONER_V6_GRAVITY_TOP) &&
|
|
|
|
(gravity & ZXDG_POSITIONER_V6_GRAVITY_BOTTOM)) ||
|
|
|
|
(gravity & ZXDG_POSITIONER_V6_GRAVITY_BOTTOM)) ||
|
|
|
@ -305,7 +315,7 @@ static void xdg_positioner_protocol_set_constraint_adjustment(
|
|
|
|
struct wl_client *client, struct wl_resource *resource,
|
|
|
|
struct wl_client *client, struct wl_resource *resource,
|
|
|
|
uint32_t constraint_adjustment) {
|
|
|
|
uint32_t constraint_adjustment) {
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
xdg_positioner_from_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
positioner->constraint_adjustment = constraint_adjustment;
|
|
|
|
positioner->constraint_adjustment = constraint_adjustment;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -313,7 +323,7 @@ static void xdg_positioner_protocol_set_constraint_adjustment(
|
|
|
|
static void xdg_positioner_protocol_set_offset(struct wl_client *client,
|
|
|
|
static void xdg_positioner_protocol_set_offset(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, int32_t x, int32_t y) {
|
|
|
|
struct wl_resource *resource, int32_t x, int32_t y) {
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
xdg_positioner_from_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
positioner->offset.x = x;
|
|
|
|
positioner->offset.x = x;
|
|
|
|
positioner->offset.y = y;
|
|
|
|
positioner->offset.y = y;
|
|
|
@ -355,52 +365,6 @@ static void xdg_shell_create_positioner(struct wl_client *wl_client,
|
|
|
|
positioner, xdg_positioner_destroy);
|
|
|
|
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_v6 *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,
|
|
|
|
|
|
|
|
ZXDG_POPUP_V6_ERROR_INVALID_GRAB,
|
|
|
|
|
|
|
|
"xdg_popup is already mapped");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_xdg_popup_grab_v6 *popup_grab =
|
|
|
|
|
|
|
|
xdg_shell_popup_grab_from_seat(surface->client->shell,
|
|
|
|
|
|
|
|
seat_client->seat);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_xdg_surface_v6 *topmost = xdg_popup_grab_get_topmost(popup_grab);
|
|
|
|
|
|
|
|
bool parent_is_toplevel =
|
|
|
|
|
|
|
|
surface->popup_state->parent->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((topmost == NULL && !parent_is_toplevel) ||
|
|
|
|
|
|
|
|
(topmost != NULL && topmost != surface->popup_state->parent)) {
|
|
|
|
|
|
|
|
wl_resource_post_error(surface->client->resource,
|
|
|
|
|
|
|
|
ZXDG_SHELL_V6_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 zxdg_popup_v6_interface zxdg_popup_v6_implementation = {
|
|
|
|
|
|
|
|
.destroy = resource_destroy,
|
|
|
|
|
|
|
|
.grab = xdg_popup_protocol_grab,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct wlr_box xdg_positioner_get_geometry(
|
|
|
|
static struct wlr_box xdg_positioner_get_geometry(
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner,
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner,
|
|
|
|
struct wlr_xdg_surface_v6 *surface, struct wlr_xdg_surface_v6 *parent) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface, struct wlr_xdg_surface_v6 *parent) {
|
|
|
@ -456,23 +420,89 @@ static struct wlr_box xdg_positioner_get_geometry(
|
|
|
|
return geometry;
|
|
|
|
return geometry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const struct zxdg_popup_v6_interface zxdg_popup_v6_implementation;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct wlr_xdg_surface_v6 *xdg_surface_from_xdg_popup_resource(
|
|
|
|
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
|
|
|
|
assert(wl_resource_instance_of(resource, &zxdg_popup_v6_interface,
|
|
|
|
|
|
|
|
&zxdg_popup_v6_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_v6 *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,
|
|
|
|
|
|
|
|
ZXDG_POPUP_V6_ERROR_INVALID_GRAB,
|
|
|
|
|
|
|
|
"xdg_popup is already mapped");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_xdg_popup_grab_v6 *popup_grab =
|
|
|
|
|
|
|
|
xdg_shell_popup_grab_from_seat(surface->client->shell,
|
|
|
|
|
|
|
|
seat_client->seat);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_xdg_surface_v6 *topmost = xdg_popup_grab_get_topmost(popup_grab);
|
|
|
|
|
|
|
|
bool parent_is_toplevel =
|
|
|
|
|
|
|
|
surface->popup_state->parent->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((topmost == NULL && !parent_is_toplevel) ||
|
|
|
|
|
|
|
|
(topmost != NULL && topmost != surface->popup_state->parent)) {
|
|
|
|
|
|
|
|
wl_resource_post_error(surface->client->resource,
|
|
|
|
|
|
|
|
ZXDG_SHELL_V6_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 zxdg_popup_v6_interface zxdg_popup_v6_implementation = {
|
|
|
|
|
|
|
|
.destroy = resource_destroy,
|
|
|
|
|
|
|
|
.grab = xdg_popup_protocol_grab,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_popup_resource_destroy(struct wl_resource *resource) {
|
|
|
|
static void xdg_popup_resource_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
|
|
|
|
xdg_surface_from_xdg_popup_resource(resource);
|
|
|
|
if (surface != NULL) {
|
|
|
|
if (surface != NULL) {
|
|
|
|
xdg_surface_destroy(surface);
|
|
|
|
xdg_surface_destroy(surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
assert(wl_resource_instance_of(resource, &zxdg_surface_v6_interface,
|
|
|
|
|
|
|
|
&zxdg_surface_v6_implementation));
|
|
|
|
|
|
|
|
return wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_surface_get_popup(struct wl_client *client,
|
|
|
|
static void xdg_surface_get_popup(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, uint32_t id,
|
|
|
|
struct wl_resource *resource, uint32_t id,
|
|
|
|
struct wl_resource *parent_resource,
|
|
|
|
struct wl_resource *parent_resource,
|
|
|
|
struct wl_resource *positioner_resource) {
|
|
|
|
struct wl_resource *positioner_resource) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
xdg_surface_from_resource(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *parent =
|
|
|
|
struct wlr_xdg_surface_v6 *parent =
|
|
|
|
wl_resource_get_user_data(parent_resource);
|
|
|
|
xdg_surface_from_resource(parent_resource);
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
struct wlr_xdg_positioner_v6 *positioner =
|
|
|
|
wl_resource_get_user_data(positioner_resource);
|
|
|
|
xdg_positioner_from_resource(positioner_resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (positioner->size.width == 0 || positioner->anchor_rect.width == 0) {
|
|
|
|
if (positioner->size.width == 0 || positioner->anchor_rect.width == 0) {
|
|
|
|
wl_resource_post_error(resource,
|
|
|
|
wl_resource_post_error(resource,
|
|
|
@ -516,13 +546,23 @@ static void xdg_surface_get_popup(struct wl_client *client,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const struct zxdg_toplevel_v6_interface zxdg_toplevel_v6_implementation;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct wlr_xdg_surface_v6 *xdg_surface_from_xdg_toplevel_resource(
|
|
|
|
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
|
|
|
|
assert(wl_resource_instance_of(resource, &zxdg_toplevel_v6_interface,
|
|
|
|
|
|
|
|
&zxdg_toplevel_v6_implementation));
|
|
|
|
|
|
|
|
return wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_protocol_set_parent(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_protocol_set_parent(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, struct wl_resource *parent_resource) {
|
|
|
|
struct wl_resource *resource, struct wl_resource *parent_resource) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
struct wlr_xdg_surface_v6 *parent = NULL;
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_xdg_surface_v6 *parent = NULL;
|
|
|
|
if (parent_resource != 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;
|
|
|
|
surface->toplevel_state->parent = parent;
|
|
|
@ -530,10 +570,10 @@ static void xdg_toplevel_protocol_set_parent(struct wl_client *client,
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_protocol_set_title(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_protocol_set_title(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, const char *title) {
|
|
|
|
struct wl_resource *resource, const char *title) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
char *tmp;
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
tmp = strdup(title);
|
|
|
|
char *tmp = strdup(title);
|
|
|
|
if (tmp == NULL) {
|
|
|
|
if (tmp == NULL) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -544,10 +584,10 @@ static void xdg_toplevel_protocol_set_title(struct wl_client *client,
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_protocol_set_app_id(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 wl_resource *resource, const char *app_id) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
char *tmp;
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
tmp = strdup(app_id);
|
|
|
|
char *tmp = strdup(app_id);
|
|
|
|
if (tmp == NULL) {
|
|
|
|
if (tmp == NULL) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -559,9 +599,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,
|
|
|
|
static void xdg_toplevel_protocol_show_window_menu(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, struct wl_resource *seat_resource,
|
|
|
|
struct wl_resource *resource, struct wl_resource *seat_resource,
|
|
|
|
uint32_t serial, int32_t x, int32_t y) {
|
|
|
|
uint32_t serial, int32_t x, int32_t y) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
struct wlr_seat_client *seat =
|
|
|
|
struct wlr_seat_client *seat =
|
|
|
|
wl_resource_get_user_data(seat_resource);
|
|
|
|
wlr_seat_client_from_resource(seat_resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (!surface->configured) {
|
|
|
|
if (!surface->configured) {
|
|
|
|
wl_resource_post_error(surface->toplevel_state->resource,
|
|
|
|
wl_resource_post_error(surface->toplevel_state->resource,
|
|
|
@ -589,9 +630,10 @@ static void xdg_toplevel_protocol_show_window_menu(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_protocol_move(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_protocol_move(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, struct wl_resource *seat_resource,
|
|
|
|
struct wl_resource *resource, struct wl_resource *seat_resource,
|
|
|
|
uint32_t serial) {
|
|
|
|
uint32_t serial) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
struct wlr_seat_client *seat =
|
|
|
|
struct wlr_seat_client *seat =
|
|
|
|
wl_resource_get_user_data(seat_resource);
|
|
|
|
wlr_seat_client_from_resource(seat_resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (!surface->configured) {
|
|
|
|
if (!surface->configured) {
|
|
|
|
wl_resource_post_error(surface->toplevel_state->resource,
|
|
|
|
wl_resource_post_error(surface->toplevel_state->resource,
|
|
|
@ -617,9 +659,10 @@ static void xdg_toplevel_protocol_move(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_protocol_resize(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_protocol_resize(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, struct wl_resource *seat_resource,
|
|
|
|
struct wl_resource *resource, struct wl_resource *seat_resource,
|
|
|
|
uint32_t serial, uint32_t edges) {
|
|
|
|
uint32_t serial, uint32_t edges) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
struct wlr_seat_client *seat =
|
|
|
|
struct wlr_seat_client *seat =
|
|
|
|
wl_resource_get_user_data(seat_resource);
|
|
|
|
wlr_seat_client_from_resource(seat_resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (!surface->configured) {
|
|
|
|
if (!surface->configured) {
|
|
|
|
wl_resource_post_error(surface->toplevel_state->resource,
|
|
|
|
wl_resource_post_error(surface->toplevel_state->resource,
|
|
|
@ -645,39 +688,44 @@ static void xdg_toplevel_protocol_resize(struct wl_client *client,
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_protocol_set_max_size(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 wl_resource *resource, int32_t width, int32_t height) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
surface->toplevel_state->next.max_width = width;
|
|
|
|
surface->toplevel_state->next.max_width = width;
|
|
|
|
surface->toplevel_state->next.max_height = height;
|
|
|
|
surface->toplevel_state->next.max_height = height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_protocol_set_min_size(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_protocol_set_min_size(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, int32_t width, int32_t height) {
|
|
|
|
struct wl_resource *resource, int32_t width, int32_t height) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
surface->toplevel_state->next.min_width = width;
|
|
|
|
surface->toplevel_state->next.min_width = width;
|
|
|
|
surface->toplevel_state->next.min_height = height;
|
|
|
|
surface->toplevel_state->next.min_height = height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_protocol_set_maximized(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_protocol_set_maximized(struct wl_client *client,
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
surface->toplevel_state->next.maximized = true;
|
|
|
|
surface->toplevel_state->next.maximized = true;
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_maximize, surface);
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_maximize, surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_protocol_unset_maximized(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_protocol_unset_maximized(struct wl_client *client,
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
surface->toplevel_state->next.maximized = false;
|
|
|
|
surface->toplevel_state->next.maximized = false;
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_maximize, surface);
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_maximize, surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, struct wl_resource *output_resource) {
|
|
|
|
struct wl_resource *resource, struct wl_resource *output_resource) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_output *output = NULL;
|
|
|
|
struct wlr_output *output = NULL;
|
|
|
|
if (output_resource != 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;
|
|
|
|
surface->toplevel_state->next.fullscreen = true;
|
|
|
@ -693,7 +741,8 @@ static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
surface->toplevel_state->next.fullscreen = false;
|
|
|
|
surface->toplevel_state->next.fullscreen = false;
|
|
|
|
|
|
|
|
|
|
|
@ -708,7 +757,8 @@ static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_protocol_set_minimized(struct wl_client *client,
|
|
|
|
static void xdg_toplevel_protocol_set_minimized(struct wl_client *client,
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_minimize, surface);
|
|
|
|
wlr_signal_emit_safe(&surface->events.request_minimize, surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -731,14 +781,15 @@ static const struct zxdg_toplevel_v6_interface zxdg_toplevel_v6_implementation =
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_surface_resource_destroy(struct wl_resource *resource) {
|
|
|
|
static void xdg_surface_resource_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface = xdg_surface_from_resource(resource);
|
|
|
|
if (surface != NULL) {
|
|
|
|
if (surface != NULL) {
|
|
|
|
xdg_surface_destroy(surface);
|
|
|
|
xdg_surface_destroy(surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_resource_destroy(struct wl_resource *resource) {
|
|
|
|
static void xdg_toplevel_resource_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface =
|
|
|
|
|
|
|
|
xdg_surface_from_xdg_toplevel_resource(resource);
|
|
|
|
if (surface != NULL) {
|
|
|
|
if (surface != NULL) {
|
|
|
|
xdg_surface_destroy(surface);
|
|
|
|
xdg_surface_destroy(surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -746,7 +797,7 @@ static void xdg_toplevel_resource_destroy(struct wl_resource *resource) {
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_surface_get_toplevel(struct wl_client *client,
|
|
|
|
static void xdg_surface_get_toplevel(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, uint32_t id) {
|
|
|
|
struct wl_resource *resource, uint32_t id) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface = xdg_surface_from_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (wlr_surface_set_role(surface->surface, wlr_desktop_xdg_toplevel_role,
|
|
|
|
if (wlr_surface_set_role(surface->surface, wlr_desktop_xdg_toplevel_role,
|
|
|
|
resource, ZXDG_SHELL_V6_ERROR_ROLE)) {
|
|
|
|
resource, ZXDG_SHELL_V6_ERROR_ROLE)) {
|
|
|
@ -788,7 +839,7 @@ static void wlr_xdg_toplevel_v6_ack_configure(
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_surface_ack_configure(struct wl_client *client,
|
|
|
|
static void xdg_surface_ack_configure(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, uint32_t serial) {
|
|
|
|
struct wl_resource *resource, uint32_t serial) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface = xdg_surface_from_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (surface->role == WLR_XDG_SURFACE_V6_ROLE_NONE) {
|
|
|
|
if (surface->role == WLR_XDG_SURFACE_V6_ROLE_NONE) {
|
|
|
|
wl_resource_post_error(surface->resource,
|
|
|
|
wl_resource_post_error(surface->resource,
|
|
|
@ -838,7 +889,7 @@ static void xdg_surface_ack_configure(struct wl_client *client,
|
|
|
|
static void xdg_surface_set_window_geometry(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,
|
|
|
|
struct wl_resource *resource, int32_t x, int32_t y, int32_t width,
|
|
|
|
int32_t height) {
|
|
|
|
int32_t height) {
|
|
|
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_surface_v6 *surface = xdg_surface_from_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (surface->role == WLR_XDG_SURFACE_V6_ROLE_NONE) {
|
|
|
|
if (surface->role == WLR_XDG_SURFACE_V6_ROLE_NONE) {
|
|
|
|
wl_resource_post_error(surface->resource,
|
|
|
|
wl_resource_post_error(surface->resource,
|
|
|
@ -1128,11 +1179,20 @@ static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const struct zxdg_shell_v6_interface xdg_shell_impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct wlr_xdg_client_v6 *xdg_client_from_resource(
|
|
|
|
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
|
|
|
|
assert(wl_resource_instance_of(resource, &zxdg_shell_v6_interface,
|
|
|
|
|
|
|
|
&xdg_shell_impl));
|
|
|
|
|
|
|
|
return wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
|
|
|
static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
|
|
|
struct wl_resource *client_resource, uint32_t id,
|
|
|
|
struct wl_resource *client_resource, uint32_t id,
|
|
|
|
struct wl_resource *surface_resource) {
|
|
|
|
struct wl_resource *surface_resource) {
|
|
|
|
struct wlr_xdg_client_v6 *client =
|
|
|
|
struct wlr_xdg_client_v6 *client =
|
|
|
|
wl_resource_get_user_data(client_resource);
|
|
|
|
xdg_client_from_resource(client_resource);
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_xdg_surface_v6 *surface;
|
|
|
|
struct wlr_xdg_surface_v6 *surface;
|
|
|
|
if (!(surface = calloc(1, sizeof(struct wlr_xdg_surface_v6)))) {
|
|
|
|
if (!(surface = calloc(1, sizeof(struct wlr_xdg_surface_v6)))) {
|
|
|
@ -1155,7 +1215,7 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
|
|
|
|
|
|
|
|
|
|
|
surface->client = client;
|
|
|
|
surface->client = client;
|
|
|
|
surface->role = WLR_XDG_SURFACE_V6_ROLE_NONE;
|
|
|
|
surface->role = WLR_XDG_SURFACE_V6_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,
|
|
|
|
surface->resource = wl_resource_create(wl_client,
|
|
|
|
&zxdg_surface_v6_interface, wl_resource_get_version(client_resource),
|
|
|
|
&zxdg_surface_v6_interface, wl_resource_get_version(client_resource),
|
|
|
|
id);
|
|
|
|
id);
|
|
|
@ -1206,7 +1266,7 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_shell_pong(struct wl_client *wl_client,
|
|
|
|
static void xdg_shell_pong(struct wl_client *wl_client,
|
|
|
|
struct wl_resource *resource, uint32_t serial) {
|
|
|
|
struct wl_resource *resource, uint32_t serial) {
|
|
|
|
struct wlr_xdg_client_v6 *client = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_client_v6 *client = xdg_client_from_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
if (client->ping_serial != serial) {
|
|
|
|
if (client->ping_serial != serial) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -1216,7 +1276,7 @@ static void xdg_shell_pong(struct wl_client *wl_client,
|
|
|
|
client->ping_serial = 0;
|
|
|
|
client->ping_serial = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct zxdg_shell_v6_interface xdg_shell_impl = {
|
|
|
|
static const struct zxdg_shell_v6_interface xdg_shell_impl = {
|
|
|
|
.destroy = resource_destroy,
|
|
|
|
.destroy = resource_destroy,
|
|
|
|
.create_positioner = xdg_shell_create_positioner,
|
|
|
|
.create_positioner = xdg_shell_create_positioner,
|
|
|
|
.get_xdg_surface = xdg_shell_get_xdg_surface,
|
|
|
|
.get_xdg_surface = xdg_shell_get_xdg_surface,
|
|
|
@ -1224,7 +1284,7 @@ static struct zxdg_shell_v6_interface xdg_shell_impl = {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void wlr_xdg_client_v6_destroy(struct wl_resource *resource) {
|
|
|
|
static void wlr_xdg_client_v6_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_xdg_client_v6 *client = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_xdg_client_v6 *client = xdg_client_from_resource(resource);
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_xdg_surface_v6 *surface, *tmp = NULL;
|
|
|
|
struct wlr_xdg_surface_v6 *surface, *tmp = NULL;
|
|
|
|
wl_list_for_each_safe(surface, tmp, &client->surfaces, link) {
|
|
|
|
wl_list_for_each_safe(surface, tmp, &client->surfaces, link) {
|
|
|
|