Merge pull request #1116 from emersion/surface-role

surface: replace wlr_surface_set_role_committed with wlr_surface_role
This commit is contained in:
Drew DeVault 2018-07-11 15:27:42 -07:00 committed by GitHub
commit c0b4217fce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 256 additions and 167 deletions

View file

@ -13,6 +13,8 @@ struct wlr_client_data_source {
struct wl_resource *resource;
};
extern const struct wlr_surface_role drag_icon_surface_role;
struct wlr_data_offer *data_offer_create(struct wl_client *client,
struct wlr_data_source *source, uint32_t version);
void data_offer_update_action(struct wlr_data_offer *offer);

View file

@ -10,8 +10,8 @@ struct wlr_xdg_positioner_resource {
struct wlr_xdg_positioner attrs;
};
#define XDG_TOPLEVEL_ROLE "xdg_toplevel"
#define XDG_POPUP_ROLE "xdg_popup"
extern const struct wlr_surface_role xdg_toplevel_surface_role;
extern const struct wlr_surface_role xdg_popup_surface_role;
uint32_t schedule_xdg_surface_configure(struct wlr_xdg_surface *surface);
struct wlr_xdg_surface *create_xdg_surface(
@ -19,6 +19,7 @@ struct wlr_xdg_surface *create_xdg_surface(
uint32_t id);
void unmap_xdg_surface(struct wlr_xdg_surface *surface);
void destroy_xdg_surface(struct wlr_xdg_surface *surface);
void handle_xdg_surface_committed(struct wlr_surface *wlr_surface);
void create_xdg_positioner(struct wlr_xdg_client *client, uint32_t id);
struct wlr_xdg_positioner_resource *get_xdg_positioner_from_resource(

View file

@ -10,8 +10,8 @@ struct wlr_xdg_positioner_v6_resource {
struct wlr_xdg_positioner_v6 attrs;
};
#define XDG_TOPLEVEL_V6_ROLE "xdg_toplevel_v6"
#define XDG_POPUP_V6_ROLE "xdg_popup_v6"
extern const struct wlr_surface_role xdg_toplevel_v6_surface_role;
extern const struct wlr_surface_role xdg_popup_v6_surface_role;
uint32_t schedule_xdg_surface_v6_configure(struct wlr_xdg_surface_v6 *surface);
struct wlr_xdg_surface_v6 *create_xdg_surface_v6(
@ -19,6 +19,7 @@ struct wlr_xdg_surface_v6 *create_xdg_surface_v6(
uint32_t id);
void unmap_xdg_surface_v6(struct wlr_xdg_surface_v6 *surface);
void destroy_xdg_surface_v6(struct wlr_xdg_surface_v6 *surface);
void handle_xdg_surface_v6_committed(struct wlr_surface *wlr_surface);
void create_xdg_positioner_v6(struct wlr_xdg_client_v6 *client, uint32_t id);
struct wlr_xdg_positioner_v6_resource *get_xdg_positioner_v6_from_resource(

View file

@ -76,7 +76,7 @@ struct wlr_layer_surface {
struct wlr_layer_surface_state server_pending;
struct wlr_layer_surface_state current;
struct wl_listener surface_destroy_listener;
struct wl_listener surface_destroy;
struct {
struct wl_signal destroy;

View file

@ -540,4 +540,6 @@ bool wlr_seat_validate_grab_serial(struct wlr_seat *seat, uint32_t serial);
struct wlr_seat_client *wlr_seat_client_from_resource(
struct wl_resource *resource);
bool wlr_surface_is_pointer_cursor(struct wlr_surface *surface);
#endif

View file

@ -36,6 +36,11 @@ struct wlr_surface_state {
struct wl_listener buffer_destroy;
};
struct wlr_surface_role {
const char *name;
void (*commit)(struct wlr_surface *surface);
};
struct wlr_surface {
struct wl_resource *resource;
struct wlr_renderer *renderer;
@ -68,7 +73,9 @@ struct wlr_surface {
* the previous commit.
*/
struct wlr_surface_state current, pending, previous;
const char *role; // the lifetime-bound role or null
const struct wlr_surface_role *role; // the lifetime-bound role or NULL
void *role_data; // role-specific data
struct {
struct wl_signal commit;
@ -76,10 +83,6 @@ struct wlr_surface {
struct wl_signal destroy;
} events;
// surface commit callback for the role that runs before all others
void (*role_committed)(struct wlr_surface *surface, void *role_data);
void *role_data;
struct wl_list subsurfaces; // wlr_subsurface::parent_link
// wlr_subsurface::parent_pending_link
@ -137,7 +140,8 @@ struct wlr_surface *wlr_surface_create(struct wl_client *client,
* Set the lifetime role for this surface. Returns 0 on success or -1 if the
* role cannot be set.
*/
int wlr_surface_set_role(struct wlr_surface *surface, const char *role,
bool wlr_surface_set_role(struct wlr_surface *surface,
const struct wlr_surface_role *role, void *role_data,
struct wl_resource *error_resource, uint32_t error_code);
/**
@ -200,14 +204,6 @@ struct wlr_box;
*/
void wlr_surface_get_extends(struct wlr_surface *surface, struct wlr_box *box);
/**
* Set a callback for surface commit that runs before all the other callbacks.
* This is intended for use by the surface role.
*/
void wlr_surface_set_role_committed(struct wlr_surface *surface,
void (*role_committed)(struct wlr_surface *surface, void *role_data),
void *role_data);
struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource);
/**

View file

@ -69,7 +69,7 @@ struct wlr_wl_shell_surface {
char *title;
char *class;
struct wl_listener surface_destroy_listener;
struct wl_listener surface_destroy;
struct wlr_wl_shell_surface *parent;
struct wl_list popup_link;
@ -152,7 +152,7 @@ struct wlr_surface *wlr_wl_shell_surface_surface_at(
bool wlr_surface_is_wl_shell_surface(struct wlr_surface *surface);
struct wlr_wl_surface *wlr_wl_shell_surface_from_wlr_surface(
struct wlr_wl_shell_surface *wlr_wl_shell_surface_from_wlr_surface(
struct wlr_surface *surface);
/**

View file

@ -163,7 +163,8 @@ struct wlr_xdg_surface {
struct wlr_box next_geometry;
struct wlr_box geometry;
struct wl_listener surface_destroy_listener;
struct wl_listener surface_destroy;
struct wl_listener surface_commit;
struct {
struct wl_signal destroy;

View file

@ -161,7 +161,8 @@ struct wlr_xdg_surface_v6 {
struct wlr_box next_geometry;
struct wlr_box geometry;
struct wl_listener surface_destroy_listener;
struct wl_listener surface_destroy;
struct wl_listener surface_commit;
struct {
struct wl_signal destroy;