xdg-positioner: rename structs

To be consistent with other wlr_xdg_* structs,
wlr_xdg_positioner_resource is renamed to wlr_xdg_positioner and made
public, and wlr_xdg_positioner is renamed to wlr_xdg_positioner_rules.
Functions which operated on wlr_xdg_positioner were renamed and updated
accordingly.
This commit is contained in:
Kirill Primak 2022-02-06 23:39:50 +03:00 committed by Simon Ser
parent b5b15b2625
commit 5879e77d68
5 changed files with 109 additions and 125 deletions

View file

@ -5,11 +5,6 @@
#include <wlr/types/wlr_xdg_shell.h>
#include "xdg-shell-protocol.h"
struct wlr_xdg_positioner_resource {
struct wl_resource *resource;
struct wlr_xdg_positioner attrs;
};
extern const struct wlr_surface_role xdg_toplevel_surface_role;
extern const struct wlr_surface_role xdg_popup_surface_role;
@ -24,12 +19,10 @@ void xdg_surface_role_precommit(struct wlr_surface *wlr_surface,
const struct wlr_surface_state *state);
void create_xdg_positioner(struct wlr_xdg_client *client, uint32_t id);
struct wlr_xdg_positioner_resource *get_xdg_positioner_from_resource(
struct wl_resource *resource);
void create_xdg_popup(struct wlr_xdg_surface *surface,
struct wlr_xdg_surface *parent,
struct wlr_xdg_positioner_resource *positioner, uint32_t id);
struct wlr_xdg_positioner *positioner, uint32_t id);
void unmap_xdg_popup(struct wlr_xdg_popup *popup);
void destroy_xdg_popup(struct wlr_xdg_popup *popup);
void handle_xdg_popup_committed(struct wlr_xdg_popup *popup);

View file

@ -49,7 +49,7 @@ struct wlr_xdg_client {
struct wl_event_source *ping_timer;
};
struct wlr_xdg_positioner {
struct wlr_xdg_positioner_rules {
struct wlr_box anchor_rect;
enum xdg_positioner_anchor anchor;
enum xdg_positioner_gravity gravity;
@ -64,6 +64,11 @@ struct wlr_xdg_positioner {
} offset;
};
struct wlr_xdg_positioner {
struct wl_resource *resource;
struct wlr_xdg_positioner_rules rules;
};
struct wlr_xdg_popup {
struct wlr_xdg_surface *base;
struct wl_list link;
@ -77,7 +82,7 @@ struct wlr_xdg_popup {
// geometry of the parent surface
struct wlr_box geometry;
struct wlr_xdg_positioner positioner;
struct wlr_xdg_positioner_rules positioner_rules;
struct wl_list grab_link; // wlr_xdg_popup_grab::popups
};
@ -276,6 +281,13 @@ struct wlr_xdg_popup *wlr_xdg_popup_from_resource(
struct wlr_xdg_toplevel *wlr_xdg_toplevel_from_resource(
struct wl_resource *resource);
/** Get the corresponding wlr_xdg_positioner from a resource.
*
* Aborts if the resource doesn't have the correct type.
*/
struct wlr_xdg_positioner *wlr_xdg_positioner_from_resource(
struct wl_resource *resource);
/**
* Send a ping to the surface. If the surface does not respond in a reasonable
* amount of time, the ping_timeout event will be emitted.
@ -346,12 +358,12 @@ void wlr_xdg_popup_destroy(struct wlr_xdg_popup *popup);
*/
void wlr_xdg_popup_get_position(struct wlr_xdg_popup *popup,
double *popup_sx, double *popup_sy);
/**
* Get the geometry for this positioner based on the anchor rect, gravity, and
* size of this positioner.
* Get the geometry based on positioner rules.
*/
struct wlr_box wlr_xdg_positioner_get_geometry(
struct wlr_xdg_positioner *positioner);
void wlr_xdg_positioner_rules_get_geometry(
struct wlr_xdg_positioner_rules *rules, struct wlr_box *box);
/**
* Get the anchor point for this popup in the toplevel parent's coordinate system.
@ -375,16 +387,18 @@ void wlr_xdg_popup_unconstrain_from_box(struct wlr_xdg_popup *popup,
const struct wlr_box *toplevel_sx_box);
/**
Invert the right/left anchor and gravity for this positioner. This can be
used to "flip" the positioner around the anchor rect in the x direction.
Invert the top/bottom anchor and gravity for those positioner rules.
This can be used to "flip" the positioner around the anchor rect in
the x direction.
*/
void wlr_positioner_invert_x(struct wlr_xdg_positioner *positioner);
void wlr_xdg_positioner_rules_invert_x(struct wlr_xdg_positioner_rules *rules);
/**
Invert the top/bottom anchor and gravity for this positioner. This can be
used to "flip" the positioner around the anchor rect in the y direction.
Invert the top/bottom anchor and gravity for those positioner rules.
This can be used to "flip" the positioner around the anchor rect in
the y direction.
*/
void wlr_positioner_invert_y(struct wlr_xdg_positioner *positioner);
void wlr_xdg_positioner_rules_invert_y(struct wlr_xdg_positioner_rules *rules);
/**
* Find a surface within this xdg-surface tree at the given surface-local