mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
xdg-popup: fix functions' main argument type
With this commit, `wlr_xdg_popup_*()` functions now expect a `wlr_xdg_popup` instead of a `wlr_xdg_surface`.
This commit is contained in:
parent
affe0d8713
commit
41412cadbe
5 changed files with 58 additions and 58 deletions
|
@ -30,7 +30,7 @@ struct wlr_xdg_positioner_resource *get_xdg_positioner_from_resource(
|
|||
void create_xdg_popup(struct wlr_xdg_surface *xdg_surface,
|
||||
struct wlr_xdg_surface *parent,
|
||||
struct wlr_xdg_positioner_resource *positioner, uint32_t id);
|
||||
void handle_xdg_surface_popup_committed(struct wlr_xdg_surface *surface);
|
||||
void handle_xdg_popup_committed(struct wlr_xdg_popup *popup);
|
||||
struct wlr_xdg_popup_grab *get_xdg_shell_popup_grab_from_seat(
|
||||
struct wlr_xdg_shell *shell, struct wlr_seat *seat);
|
||||
|
||||
|
|
|
@ -265,7 +265,13 @@ struct wlr_xdg_shell *wlr_xdg_shell_create(struct wl_display *display);
|
|||
*/
|
||||
struct wlr_xdg_surface *wlr_xdg_surface_from_resource(
|
||||
struct wl_resource *resource);
|
||||
struct wlr_xdg_surface *wlr_xdg_surface_from_popup_resource(
|
||||
|
||||
/** Get the corresponding wlr_xdg_popup from a resource.
|
||||
*
|
||||
* Aborts if the resource doesn't have the correct type. Returns NULL if the
|
||||
* resource is inert.
|
||||
*/
|
||||
struct wlr_xdg_popup *wlr_xdg_popup_from_resource(
|
||||
struct wl_resource *resource);
|
||||
|
||||
/** Get the corresponding wlr_xdg_toplevel from a resource.
|
||||
|
@ -339,7 +345,7 @@ void wlr_xdg_toplevel_set_parent(struct wlr_xdg_toplevel *toplevel,
|
|||
/**
|
||||
* Request that this xdg popup closes.
|
||||
**/
|
||||
void wlr_xdg_popup_destroy(struct wlr_xdg_surface *surface);
|
||||
void wlr_xdg_popup_destroy(struct wlr_xdg_popup *popup);
|
||||
|
||||
/**
|
||||
* Get the position for this popup in the surface parent's coordinate system.
|
||||
|
|
|
@ -211,14 +211,12 @@ static void layer_surface_handle_get_popup(struct wl_client *client,
|
|||
struct wl_resource *popup_resource) {
|
||||
struct wlr_layer_surface_v1 *parent =
|
||||
layer_surface_from_resource(layer_resource);
|
||||
struct wlr_xdg_surface *popup_surface =
|
||||
wlr_xdg_surface_from_popup_resource(popup_resource);
|
||||
struct wlr_xdg_popup *popup =
|
||||
wlr_xdg_popup_from_resource(popup_resource);
|
||||
|
||||
if (!parent) {
|
||||
return;
|
||||
}
|
||||
assert(popup_surface->role == WLR_XDG_SURFACE_ROLE_POPUP);
|
||||
struct wlr_xdg_popup *popup = popup_surface->popup;
|
||||
popup->parent = parent->surface;
|
||||
wl_list_insert(&parent->popups, &popup->link);
|
||||
wlr_signal_emit_safe(&parent->events.new_popup, popup);
|
||||
|
@ -265,7 +263,7 @@ static void layer_surface_unmap(struct wlr_layer_surface_v1 *surface) {
|
|||
|
||||
struct wlr_xdg_popup *popup, *popup_tmp;
|
||||
wl_list_for_each_safe(popup, popup_tmp, &surface->popups, link) {
|
||||
wlr_xdg_popup_destroy(popup->base);
|
||||
wlr_xdg_popup_destroy(popup);
|
||||
}
|
||||
|
||||
struct wlr_layer_surface_v1_configure *configure, *tmp;
|
||||
|
|
|
@ -196,25 +196,23 @@ struct wlr_xdg_popup_grab *get_xdg_shell_popup_grab_from_seat(
|
|||
return xdg_grab;
|
||||
}
|
||||
|
||||
void handle_xdg_surface_popup_committed(struct wlr_xdg_surface *surface) {
|
||||
assert(surface->role == WLR_XDG_SURFACE_ROLE_POPUP);
|
||||
|
||||
if (!surface->popup->parent) {
|
||||
wl_resource_post_error(surface->resource,
|
||||
void handle_xdg_popup_committed(struct wlr_xdg_popup *popup) {
|
||||
if (!popup->parent) {
|
||||
wl_resource_post_error(popup->base->resource,
|
||||
XDG_SURFACE_ERROR_NOT_CONSTRUCTED,
|
||||
"xdg_popup has no parent");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!surface->popup->committed) {
|
||||
wlr_xdg_surface_schedule_configure(surface);
|
||||
surface->popup->committed = true;
|
||||
if (!popup->committed) {
|
||||
wlr_xdg_surface_schedule_configure(popup->base);
|
||||
popup->committed = true;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct xdg_popup_interface xdg_popup_implementation;
|
||||
|
||||
struct wlr_xdg_surface *wlr_xdg_surface_from_popup_resource(
|
||||
struct wlr_xdg_popup *wlr_xdg_popup_from_resource(
|
||||
struct wl_resource *resource) {
|
||||
assert(wl_resource_instance_of(resource, &xdg_popup_interface,
|
||||
&xdg_popup_implementation));
|
||||
|
@ -224,35 +222,35 @@ struct wlr_xdg_surface *wlr_xdg_surface_from_popup_resource(
|
|||
static void xdg_popup_handle_grab(struct wl_client *client,
|
||||
struct wl_resource *resource, struct wl_resource *seat_resource,
|
||||
uint32_t serial) {
|
||||
struct wlr_xdg_surface *surface =
|
||||
wlr_xdg_surface_from_popup_resource(resource);
|
||||
struct wlr_seat_client *seat_client =
|
||||
wlr_seat_client_from_resource(seat_resource);
|
||||
if (!surface) {
|
||||
struct wlr_xdg_popup *popup =
|
||||
wlr_xdg_popup_from_resource(resource);
|
||||
if (!popup) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (surface->popup->committed) {
|
||||
wl_resource_post_error(surface->popup->resource,
|
||||
struct wlr_seat_client *seat_client =
|
||||
wlr_seat_client_from_resource(seat_resource);
|
||||
if (popup->committed) {
|
||||
wl_resource_post_error(popup->resource,
|
||||
XDG_POPUP_ERROR_INVALID_GRAB,
|
||||
"xdg_popup is already mapped");
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_xdg_popup_grab *popup_grab = get_xdg_shell_popup_grab_from_seat(
|
||||
surface->client->shell, seat_client->seat);
|
||||
popup->base->client->shell, seat_client->seat);
|
||||
|
||||
if (!wl_list_empty(&surface->popups)) {
|
||||
wl_resource_post_error(surface->client->resource,
|
||||
if (!wl_list_empty(&popup->base->popups)) {
|
||||
wl_resource_post_error(popup->base->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->seat = seat_client->seat;
|
||||
popup_grab->client = popup->base->client->client;
|
||||
popup->seat = seat_client->seat;
|
||||
|
||||
wl_list_insert(&popup_grab->popups, &surface->popup->grab_link);
|
||||
wl_list_insert(&popup_grab->popups, &popup->grab_link);
|
||||
|
||||
wlr_seat_pointer_start_grab(seat_client->seat,
|
||||
&popup_grab->pointer_grab);
|
||||
|
@ -264,11 +262,11 @@ static void xdg_popup_handle_grab(struct wl_client *client,
|
|||
|
||||
static void xdg_popup_handle_destroy(struct wl_client *client,
|
||||
struct wl_resource *resource) {
|
||||
struct wlr_xdg_surface *surface =
|
||||
wlr_xdg_surface_from_popup_resource(resource);
|
||||
struct wlr_xdg_popup *popup =
|
||||
wlr_xdg_popup_from_resource(resource);
|
||||
|
||||
if (surface && !wl_list_empty(&surface->popups)) {
|
||||
wl_resource_post_error(surface->client->resource,
|
||||
if (popup && !wl_list_empty(&popup->base->popups)) {
|
||||
wl_resource_post_error(popup->base->client->resource,
|
||||
XDG_WM_BASE_ERROR_NOT_THE_TOPMOST_POPUP,
|
||||
"xdg_popup was destroyed while it was not the topmost popup");
|
||||
return;
|
||||
|
@ -283,12 +281,12 @@ static const struct xdg_popup_interface xdg_popup_implementation = {
|
|||
};
|
||||
|
||||
static void xdg_popup_handle_resource_destroy(struct wl_resource *resource) {
|
||||
struct wlr_xdg_surface *xdg_surface =
|
||||
wlr_xdg_surface_from_popup_resource(resource);
|
||||
if (xdg_surface == NULL) {
|
||||
struct wlr_xdg_popup *popup =
|
||||
wlr_xdg_popup_from_resource(resource);
|
||||
if (popup == NULL) {
|
||||
return;
|
||||
}
|
||||
wlr_xdg_popup_destroy(xdg_surface);
|
||||
wlr_xdg_popup_destroy(popup);
|
||||
}
|
||||
|
||||
const struct wlr_surface_role xdg_popup_surface_role = {
|
||||
|
@ -337,7 +335,7 @@ void create_xdg_popup(struct wlr_xdg_surface *xdg_surface,
|
|||
return;
|
||||
}
|
||||
wl_resource_set_implementation(xdg_surface->popup->resource,
|
||||
&xdg_popup_implementation, xdg_surface,
|
||||
&xdg_popup_implementation, xdg_surface->popup,
|
||||
xdg_popup_handle_resource_destroy);
|
||||
|
||||
xdg_surface->role = WLR_XDG_SURFACE_ROLE_POPUP;
|
||||
|
@ -357,6 +355,21 @@ void create_xdg_popup(struct wlr_xdg_surface *xdg_surface,
|
|||
}
|
||||
}
|
||||
|
||||
void wlr_xdg_popup_destroy(struct wlr_xdg_popup *popup) {
|
||||
if (popup == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_xdg_popup *child, *child_tmp;
|
||||
wl_list_for_each_safe(child, child_tmp, &popup->base->popups, link) {
|
||||
wlr_xdg_popup_destroy(child);
|
||||
}
|
||||
|
||||
xdg_popup_send_popup_done(popup->resource);
|
||||
wl_resource_set_user_data(popup->resource, NULL);
|
||||
reset_xdg_surface(popup->base);
|
||||
}
|
||||
|
||||
void wlr_xdg_popup_get_anchor_point(struct wlr_xdg_popup *popup,
|
||||
int *root_sx, int *root_sy) {
|
||||
struct wlr_box rect = popup->positioner.anchor_rect;
|
||||
|
|
|
@ -32,7 +32,7 @@ void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
|
|||
|
||||
struct wlr_xdg_popup *popup, *popup_tmp;
|
||||
wl_list_for_each_safe(popup, popup_tmp, &surface->popups, link) {
|
||||
wlr_xdg_popup_destroy(popup->base);
|
||||
wlr_xdg_popup_destroy(popup);
|
||||
}
|
||||
|
||||
// TODO: probably need to ungrab before this event
|
||||
|
@ -324,7 +324,7 @@ void xdg_surface_role_commit(struct wlr_surface *wlr_surface) {
|
|||
handle_xdg_toplevel_committed(surface->toplevel);
|
||||
break;
|
||||
case WLR_XDG_SURFACE_ROLE_POPUP:
|
||||
handle_xdg_surface_popup_committed(surface);
|
||||
handle_xdg_popup_committed(surface->popup);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -495,23 +495,6 @@ void wlr_xdg_surface_ping(struct wlr_xdg_surface *surface) {
|
|||
surface->client->ping_serial);
|
||||
}
|
||||
|
||||
void wlr_xdg_popup_destroy(struct wlr_xdg_surface *surface) {
|
||||
if (surface == NULL) {
|
||||
return;
|
||||
}
|
||||
assert(surface->popup);
|
||||
assert(surface->role == WLR_XDG_SURFACE_ROLE_POPUP);
|
||||
|
||||
struct wlr_xdg_popup *popup, *popup_tmp;
|
||||
wl_list_for_each_safe(popup, popup_tmp, &surface->popups, link) {
|
||||
wlr_xdg_popup_destroy(popup->base);
|
||||
}
|
||||
|
||||
xdg_popup_send_popup_done(surface->popup->resource);
|
||||
wl_resource_set_user_data(surface->popup->resource, NULL);
|
||||
reset_xdg_surface(surface);
|
||||
}
|
||||
|
||||
void wlr_xdg_popup_get_position(struct wlr_xdg_popup *popup,
|
||||
double *popup_sx, double *popup_sy) {
|
||||
struct wlr_xdg_surface *parent =
|
||||
|
|
Loading…
Reference in a new issue