xdg-positioner attrs
This commit is contained in:
parent
30b8fb5572
commit
4da18f7fc3
|
@ -88,6 +88,21 @@ enum wlr_positioner_v6_constraint_adjustment {
|
||||||
WLR_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32,
|
WLR_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wlr_xdg_positioner_v6_attributes {
|
||||||
|
struct wlr_box anchor_rect;
|
||||||
|
enum wlr_positioner_v6_anchor anchor;
|
||||||
|
enum wlr_positioner_v6_gravity gravity;
|
||||||
|
enum wlr_positioner_v6_constraint_adjustment constraint_adjustment;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int32_t width, height;
|
||||||
|
} size;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int32_t x, y;
|
||||||
|
} offset;
|
||||||
|
};
|
||||||
|
|
||||||
struct wlr_xdg_popup_v6 {
|
struct wlr_xdg_popup_v6 {
|
||||||
struct wlr_xdg_surface_v6 *base;
|
struct wlr_xdg_surface_v6 *base;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
|
@ -98,9 +113,16 @@ struct wlr_xdg_popup_v6 {
|
||||||
struct wlr_seat *seat;
|
struct wlr_seat *seat;
|
||||||
struct wlr_box geometry;
|
struct wlr_box geometry;
|
||||||
|
|
||||||
enum wlr_positioner_v6_anchor anchor;
|
struct wlr_xdg_positioner_v6_attributes positioner;
|
||||||
enum wlr_positioner_v6_gravity gravity;
|
struct wlr_box anchor_rect;
|
||||||
enum wlr_positioner_v6_constraint_adjustment constraint_adjustment;
|
|
||||||
|
struct {
|
||||||
|
int32_t width, height;
|
||||||
|
} size;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int32_t x, y;
|
||||||
|
} offset;
|
||||||
|
|
||||||
struct wl_list grab_link; // wlr_xdg_popup_grab_v6::popups
|
struct wl_list grab_link; // wlr_xdg_popup_grab_v6::popups
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,22 +18,9 @@ static const char *wlr_desktop_xdg_popup_role = "xdg_popup_v6";
|
||||||
|
|
||||||
struct wlr_xdg_positioner_v6 {
|
struct wlr_xdg_positioner_v6 {
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
|
struct wlr_xdg_positioner_v6_attributes *attrs;
|
||||||
struct wlr_box anchor_rect;
|
|
||||||
enum zxdg_positioner_v6_anchor anchor;
|
|
||||||
enum zxdg_positioner_v6_gravity gravity;
|
|
||||||
enum zxdg_positioner_v6_constraint_adjustment constraint_adjustment;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
int32_t width, height;
|
|
||||||
} size;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
int32_t x, y;
|
|
||||||
} offset;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void resource_handle_destroy(struct wl_client *client,
|
static void resource_handle_destroy(struct wl_client *client,
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
wl_resource_destroy(resource);
|
wl_resource_destroy(resource);
|
||||||
|
@ -279,6 +266,7 @@ static struct wlr_xdg_positioner_v6 *xdg_positioner_from_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 =
|
||||||
xdg_positioner_from_resource(resource);
|
xdg_positioner_from_resource(resource);
|
||||||
|
free(positioner->attrs);
|
||||||
free(positioner);
|
free(positioner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,8 +282,8 @@ static void xdg_positioner_handle_set_size(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
positioner->size.width = width;
|
positioner->attrs->size.width = width;
|
||||||
positioner->size.height = height;
|
positioner->attrs->size.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_positioner_handle_set_anchor_rect(struct wl_client *client,
|
static void xdg_positioner_handle_set_anchor_rect(struct wl_client *client,
|
||||||
|
@ -311,10 +299,10 @@ static void xdg_positioner_handle_set_anchor_rect(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
positioner->anchor_rect.x = x;
|
positioner->attrs->anchor_rect.x = x;
|
||||||
positioner->anchor_rect.y = y;
|
positioner->attrs->anchor_rect.y = y;
|
||||||
positioner->anchor_rect.width = width;
|
positioner->attrs->anchor_rect.width = width;
|
||||||
positioner->anchor_rect.height = height;
|
positioner->attrs->anchor_rect.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_positioner_handle_set_anchor(struct wl_client *client,
|
static void xdg_positioner_handle_set_anchor(struct wl_client *client,
|
||||||
|
@ -332,7 +320,7 @@ static void xdg_positioner_handle_set_anchor(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
positioner->anchor = anchor;
|
positioner->attrs->anchor = anchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_positioner_handle_set_gravity(struct wl_client *client,
|
static void xdg_positioner_handle_set_gravity(struct wl_client *client,
|
||||||
|
@ -350,7 +338,7 @@ static void xdg_positioner_handle_set_gravity(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
positioner->gravity = gravity;
|
positioner->attrs->gravity = gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_positioner_handle_set_constraint_adjustment(
|
static void xdg_positioner_handle_set_constraint_adjustment(
|
||||||
|
@ -359,7 +347,7 @@ static void xdg_positioner_handle_set_constraint_adjustment(
|
||||||
struct wlr_xdg_positioner_v6 *positioner =
|
struct wlr_xdg_positioner_v6 *positioner =
|
||||||
xdg_positioner_from_resource(resource);
|
xdg_positioner_from_resource(resource);
|
||||||
|
|
||||||
positioner->constraint_adjustment = constraint_adjustment;
|
positioner->attrs->constraint_adjustment = constraint_adjustment;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_positioner_handle_set_offset(struct wl_client *client,
|
static void xdg_positioner_handle_set_offset(struct wl_client *client,
|
||||||
|
@ -367,8 +355,8 @@ static void xdg_positioner_handle_set_offset(struct wl_client *client,
|
||||||
struct wlr_xdg_positioner_v6 *positioner =
|
struct wlr_xdg_positioner_v6 *positioner =
|
||||||
xdg_positioner_from_resource(resource);
|
xdg_positioner_from_resource(resource);
|
||||||
|
|
||||||
positioner->offset.x = x;
|
positioner->attrs->offset.x = x;
|
||||||
positioner->offset.y = y;
|
positioner->attrs->offset.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct zxdg_positioner_v6_interface
|
static const struct zxdg_positioner_v6_interface
|
||||||
|
@ -392,6 +380,10 @@ static void xdg_shell_handle_create_positioner(struct wl_client *wl_client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: allocate the positioner attrs?
|
||||||
|
positioner->attrs =
|
||||||
|
calloc(1, sizeof(struct wlr_xdg_positioner_v6_attributes));
|
||||||
|
|
||||||
positioner->resource = wl_resource_create(wl_client,
|
positioner->resource = wl_resource_create(wl_client,
|
||||||
&zxdg_positioner_v6_interface,
|
&zxdg_positioner_v6_interface,
|
||||||
wl_resource_get_version(resource),
|
wl_resource_get_version(resource),
|
||||||
|
@ -408,7 +400,7 @@ static void xdg_shell_handle_create_positioner(struct wl_client *wl_client,
|
||||||
}
|
}
|
||||||
|
|
||||||
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_attributes *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) {
|
||||||
struct wlr_box geometry = {
|
struct wlr_box geometry = {
|
||||||
.x = positioner->offset.x,
|
.x = positioner->offset.x,
|
||||||
|
@ -453,7 +445,7 @@ static struct wlr_box xdg_positioner_get_geometry(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (positioner->constraint_adjustment ==
|
if (positioner->constraint_adjustment ==
|
||||||
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE) {
|
WLR_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_NONE) {
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,7 +559,7 @@ static void xdg_surface_handle_get_popup(struct wl_client *client,
|
||||||
struct wlr_xdg_positioner_v6 *positioner =
|
struct wlr_xdg_positioner_v6 *positioner =
|
||||||
xdg_positioner_from_resource(positioner_resource);
|
xdg_positioner_from_resource(positioner_resource);
|
||||||
|
|
||||||
if (positioner->size.width == 0 || positioner->anchor_rect.width == 0) {
|
if (positioner->attrs->size.width == 0 || positioner->attrs->anchor_rect.width == 0) {
|
||||||
wl_resource_post_error(resource,
|
wl_resource_post_error(resource,
|
||||||
ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER,
|
ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER,
|
||||||
"positioner object is not complete");
|
"positioner object is not complete");
|
||||||
|
@ -598,12 +590,11 @@ static void xdg_surface_handle_get_popup(struct wl_client *client,
|
||||||
surface->popup->base = surface;
|
surface->popup->base = surface;
|
||||||
surface->popup->parent = parent;
|
surface->popup->parent = parent;
|
||||||
surface->popup->geometry =
|
surface->popup->geometry =
|
||||||
xdg_positioner_get_geometry(positioner, surface, parent);
|
xdg_positioner_get_geometry(positioner->attrs, surface, parent);
|
||||||
|
|
||||||
// positioner properties
|
// positioner properties
|
||||||
surface->popup->anchor = (uint32_t)positioner->anchor;
|
memcpy(&surface->popup->positioner, &positioner->attrs,
|
||||||
surface->popup->gravity = (uint32_t)positioner->gravity;
|
sizeof(struct wlr_xdg_positioner_v6_attributes));
|
||||||
surface->popup->constraint_adjustment = (uint32_t)positioner->constraint_adjustment;
|
|
||||||
|
|
||||||
wl_list_insert(&parent->popups, &surface->popup->link);
|
wl_list_insert(&parent->popups, &surface->popup->link);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue