Use WLR_PRIVATE for private fields

master
Kirill Primak 2 months ago committed by itycodes
parent 044f75f26f
commit 0c0628f43e

@ -237,6 +237,13 @@ used and `#undef` them after.
* Document the contents and container of a `struct wl_list` with a
`// content.link` and `// container.list` comment.
### Private fields
Wrap private fields of public structures with `struct { … } WLR_PRIVATE`. This
ensures that compositor authors don't use them by accident. Within wlroots
`WLR_PRIVATE` is expanded to nothing, so private fields are accessed in the same
way as public ones.
### Safety
* Avoid string manipulation functions which don't take the size of the
@ -325,12 +332,14 @@ struct wlr_compositor {
struct wl_global *global;
struct wl_listener display_destroy;
struct {
struct wl_signal new_surface;
struct wl_signal destroy;
} events;
struct {
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
```

@ -29,9 +29,9 @@ struct wlr_drm_syncobj_timeline {
int drm_fd;
uint32_t handle;
// private state
size_t n_refs;
struct {
size_t n_refs;
} WLR_PRIVATE;
};
struct wlr_drm_syncobj_timeline_waiter {
@ -39,10 +39,10 @@ struct wlr_drm_syncobj_timeline_waiter {
struct wl_signal ready;
} events;
// private state
int ev_fd;
struct wl_event_source *event_source;
struct {
int ev_fd;
struct wl_event_source *event_source;
} WLR_PRIVATE;
};
/**

@ -53,9 +53,9 @@ struct wlr_renderer {
bool timeline;
} features;
// private state
const struct wlr_renderer_impl *impl;
struct {
const struct wlr_renderer_impl *impl;
} WLR_PRIVATE;
};
/**

@ -20,9 +20,9 @@ struct wlr_alpha_modifier_surface_v1_state {
struct wlr_alpha_modifier_v1 {
struct wl_global *global;
// private state
struct wl_listener display_destroy;
struct {
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
struct wlr_alpha_modifier_v1 *wlr_alpha_modifier_v1_create(struct wl_display *display);

@ -148,12 +148,12 @@ struct wlr_client_buffer {
*/
struct wlr_buffer *source;
// private state
struct wl_listener source_destroy;
struct wl_listener renderer_destroy;
struct {
struct wl_listener source_destroy;
struct wl_listener renderer_destroy;
size_t n_ignore_locks;
size_t n_ignore_locks;
} WLR_PRIVATE;
};
/**

@ -236,33 +236,33 @@ struct wlr_surface {
struct wlr_addon_set addons;
void *data;
// private state
struct wl_listener role_resource_destroy;
struct {
int32_t scale;
enum wl_output_transform transform;
int width, height;
int buffer_width, buffer_height;
} previous;
struct wl_listener role_resource_destroy;
struct {
int32_t scale;
enum wl_output_transform transform;
int width, height;
int buffer_width, buffer_height;
} previous;
bool unmap_commit;
bool unmap_commit;
bool opaque;
bool opaque;
bool handling_commit;
bool pending_rejected;
bool handling_commit;
bool pending_rejected;
int32_t preferred_buffer_scale;
bool preferred_buffer_transform_sent;
enum wl_output_transform preferred_buffer_transform;
int32_t preferred_buffer_scale;
bool preferred_buffer_transform_sent;
enum wl_output_transform preferred_buffer_transform;
struct wl_list synced; // wlr_surface_synced.link
size_t synced_len;
struct wl_list synced; // wlr_surface_synced.link
size_t synced_len;
struct wl_resource *pending_buffer_resource;
struct wl_listener pending_buffer_resource_destroy;
struct wl_resource *pending_buffer_resource;
struct wl_listener pending_buffer_resource_destroy;
} WLR_PRIVATE;
};
struct wlr_renderer;

@ -23,9 +23,9 @@ struct wlr_content_type_manager_v1 {
void *data;
// private state
struct wl_listener display_destroy;
struct {
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
struct wlr_content_type_manager_v1 *wlr_content_type_manager_v1_create(

@ -28,9 +28,9 @@ struct wlr_cursor_shape_manager_v1 {
void *data;
// private state
struct wl_listener display_destroy;
struct {
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
enum wlr_cursor_shape_manager_v1_device_type {

@ -30,9 +30,9 @@ struct wlr_damage_ring {
// Difference between the current buffer and the previous one
pixman_region32_t current;
// private state
struct wl_list buffers; // wlr_damage_ring_buffer.link
struct {
struct wl_list buffers; // wlr_damage_ring_buffer.link
} WLR_PRIVATE;
};
void wlr_damage_ring_init(struct wlr_damage_ring *ring);

@ -40,12 +40,12 @@ struct wlr_drm {
struct wl_signal destroy;
} events;
// private state
char *node_name;
struct wlr_drm_format_set formats;
struct {
char *node_name;
struct wlr_drm_format_set formats;
struct wl_listener display_destroy;
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
struct wlr_drm_buffer *wlr_drm_buffer_try_from_resource(

@ -39,10 +39,10 @@ struct wlr_foreign_toplevel_handle_v1_output {
struct wlr_output *output;
struct wlr_foreign_toplevel_handle_v1 *toplevel;
// private state
struct wl_listener output_bind;
struct wl_listener output_destroy;
struct {
struct wl_listener output_bind;
struct wl_listener output_destroy;
} WLR_PRIVATE;
};
struct wlr_foreign_toplevel_handle_v1 {

@ -20,9 +20,9 @@ struct wlr_fractional_scale_manager_v1 {
struct wl_signal destroy;
} events;
// private state
struct wl_listener display_destroy;
struct {
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
void wlr_fractional_scale_v1_notify_scale(

@ -19,12 +19,12 @@ struct wlr_seat;
struct wlr_idle_notifier_v1 {
struct wl_global *global;
// private state
struct {
bool inhibited;
struct wl_list notifications; // wlr_idle_notification_v1.link
bool inhibited;
struct wl_list notifications; // wlr_idle_notification_v1.link
struct wl_listener display_destroy;
struct wl_listener display_destroy;
} WLR_PRIVATE;
};

@ -114,9 +114,9 @@ struct wlr_layer_surface_v1 {
void *data;
// private state
struct wlr_surface_synced synced;
struct {
struct wlr_surface_synced synced;
} WLR_PRIVATE;
};
struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display,

@ -24,9 +24,9 @@ struct wlr_dmabuf_v1_buffer {
struct wl_resource *resource; // can be NULL if the client destroyed it
struct wlr_dmabuf_attributes attributes;
// private state
struct wl_listener release;
struct {
struct wl_listener release;
} WLR_PRIVATE;
};
/**
@ -55,18 +55,18 @@ struct wlr_linux_dmabuf_v1 {
struct wl_signal destroy;
} events;
// private state
struct wlr_linux_dmabuf_feedback_v1_compiled *default_feedback;
struct wlr_drm_format_set default_formats; // for legacy clients
struct wl_list surfaces; // wlr_linux_dmabuf_v1_surface.link
struct {
struct wlr_linux_dmabuf_feedback_v1_compiled *default_feedback;
struct wlr_drm_format_set default_formats; // for legacy clients
struct wl_list surfaces; // wlr_linux_dmabuf_v1_surface.link
int main_device_fd; // to sanity check FDs sent by clients, -1 if unavailable
int main_device_fd; // to sanity check FDs sent by clients, -1 if unavailable
struct wl_listener display_destroy;
struct wl_listener display_destroy;
bool (*check_dmabuf_callback)(struct wlr_dmabuf_attributes *attribs, void *data);
void *check_dmabuf_callback_data;
bool (*check_dmabuf_callback)(struct wlr_dmabuf_attributes *attribs, void *data);
void *check_dmabuf_callback_data;
} WLR_PRIVATE;
};
/**

@ -26,11 +26,11 @@ struct wlr_linux_drm_syncobj_surface_v1_state {
struct wlr_linux_drm_syncobj_manager_v1 {
struct wl_global *global;
// private state
struct {
int drm_fd;
int drm_fd;
struct wl_listener display_destroy;
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
/**

@ -50,10 +50,10 @@ struct wlr_output_layer {
void *data;
// private state
struct wlr_fbox src_box;
struct wlr_box dst_box;
struct {
struct wlr_fbox src_box;
struct wlr_box dst_box;
} WLR_PRIVATE;
};
/**

@ -36,9 +36,9 @@ struct wlr_output_layout {
void *data;
// private state
struct wl_listener display_destroy;
struct {
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
struct wlr_output_layout_output {
@ -55,11 +55,11 @@ struct wlr_output_layout_output {
struct wl_signal destroy;
} events;
// private state
struct wlr_addon addon;
struct {
struct wlr_addon addon;
struct wl_listener commit;
struct wl_listener commit;
} WLR_PRIVATE;
};
struct wlr_output_layout *wlr_output_layout_create(struct wl_display *display);

@ -30,9 +30,9 @@ struct wlr_backend_output_state;
struct wlr_output_swapchain_manager {
struct wlr_backend *backend;
// private state
struct wl_array outputs; // struct wlr_output_swapchain_manager_output
struct {
struct wl_array outputs; // struct wlr_output_swapchain_manager_output
} WLR_PRIVATE;
};
/**

@ -64,13 +64,13 @@ struct wlr_pointer_constraint_v1 {
void *data;
// private state
struct wl_listener surface_commit;
struct wl_listener surface_destroy;
struct wl_listener seat_destroy;
struct {
struct wl_listener surface_commit;
struct wl_listener surface_destroy;
struct wl_listener seat_destroy;
struct wlr_surface_synced synced;
struct wlr_surface_synced synced;
} WLR_PRIVATE;
};
struct wlr_pointer_constraints_v1 {

@ -75,9 +75,9 @@ struct wlr_scene_node {
struct wlr_addon_set addons;
// private state
pixman_region32_t visible;
struct {
pixman_region32_t visible;
} WLR_PRIVATE;
};
enum wlr_scene_debug_damage_option {
@ -103,16 +103,16 @@ struct wlr_scene {
struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1;
struct wlr_gamma_control_manager_v1 *gamma_control_manager_v1;
// private state
struct wl_listener linux_dmabuf_v1_destroy;
struct wl_listener gamma_control_manager_v1_destroy;
struct wl_listener gamma_control_manager_v1_set_gamma;
enum wlr_scene_debug_damage_option debug_damage_option;
bool direct_scanout;
bool calculate_visibility;
bool highlight_transparent_region;
struct {
struct wl_listener linux_dmabuf_v1_destroy;
struct wl_listener gamma_control_manager_v1_destroy;
struct wl_listener gamma_control_manager_v1_set_gamma;
enum wlr_scene_debug_damage_option debug_damage_option;
bool direct_scanout;
bool calculate_visibility;
bool highlight_transparent_region;
} WLR_PRIVATE;
};
/** A scene-graph node displaying a single surface. */
@ -120,19 +120,19 @@ struct wlr_scene_surface {
struct wlr_scene_buffer *buffer;
struct wlr_surface *surface;
// private state
struct wlr_box clip;
struct wlr_addon addon;
struct wl_listener outputs_update;
struct wl_listener output_enter;
struct wl_listener output_leave;
struct wl_listener output_sample;
struct wl_listener frame_done;
struct wl_listener surface_destroy;
struct wl_listener surface_commit;
struct {
struct wlr_box clip;
struct wlr_addon addon;
struct wl_listener outputs_update;
struct wl_listener output_enter;
struct wl_listener output_leave;
struct wl_listener output_sample;
struct wl_listener frame_done;
struct wl_listener surface_destroy;
struct wl_listener surface_commit;
} WLR_PRIVATE;
};
/** A scene-graph node displaying a solid-colored rectangle */
@ -185,21 +185,21 @@ struct wlr_scene_buffer {
enum wl_output_transform transform;
pixman_region32_t opaque_region;
// private state
uint64_t active_outputs;
struct wlr_texture *texture;
struct wlr_linux_dmabuf_feedback_v1_init_options prev_feedback_options;
struct {
uint64_t active_outputs;
struct wlr_texture *texture;
struct wlr_linux_dmabuf_feedback_v1_init_options prev_feedback_options;
bool own_buffer;
int buffer_width, buffer_height;
bool buffer_is_opaque;
bool own_buffer;
int buffer_width, buffer_height;
bool buffer_is_opaque;
struct wlr_drm_syncobj_timeline *wait_timeline;
uint64_t wait_point;
struct wlr_drm_syncobj_timeline *wait_timeline;
uint64_t wait_point;
struct wl_listener buffer_release;
struct wl_listener renderer_destroy;
struct wl_listener buffer_release;
struct wl_listener renderer_destroy;
} WLR_PRIVATE;
};
/** A viewport for an output in the scene-graph */
@ -217,26 +217,26 @@ struct wlr_scene_output {
struct wl_signal destroy;
} events;
// private state
pixman_region32_t pending_commit_damage;
struct {
pixman_region32_t pending_commit_damage;
uint8_t index;
bool prev_scanout;
uint8_t index;
bool prev_scanout;
bool gamma_lut_changed;
struct wlr_gamma_control_v1 *gamma_lut;
bool gamma_lut_changed;
struct wlr_gamma_control_v1 *gamma_lut;
struct wl_listener output_commit;
struct wl_listener output_damage;
struct wl_listener output_needs_frame;
struct wl_listener output_commit;
struct wl_listener output_damage;
struct wl_listener output_needs_frame;
struct wl_list damage_highlight_regions;
struct wl_list damage_highlight_regions;
struct wl_array render_list;
struct wl_array render_list;
struct wlr_drm_syncobj_timeline *in_timeline;
uint64_t in_point;
struct wlr_drm_syncobj_timeline *in_timeline;
uint64_t in_point;
} WLR_PRIVATE;
};
struct wlr_scene_timer {
@ -249,12 +249,12 @@ struct wlr_scene_layer_surface_v1 {
struct wlr_scene_tree *tree;
struct wlr_layer_surface_v1 *layer_surface;
// private state
struct wl_listener tree_destroy;
struct wl_listener layer_surface_destroy;
struct wl_listener layer_surface_map;
struct wl_listener layer_surface_unmap;
struct {
struct wl_listener tree_destroy;
struct wl_listener layer_surface_destroy;
struct wl_listener layer_surface_map;
struct wl_listener layer_surface_unmap;
} WLR_PRIVATE;
};
/**

@ -28,11 +28,11 @@ struct wlr_security_context_manager_v1 {
void *data;
// private state
struct wl_list contexts; // wlr_security_context_v1.link
struct {
struct wl_list contexts; // wlr_security_context_v1.link
struct wl_listener display_destroy;
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
struct wlr_security_context_v1_state {

@ -24,9 +24,9 @@ struct wlr_session_lock_manager_v1 {
void *data;
// private state
struct wl_listener display_destroy;
struct {
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
struct wlr_session_lock_v1 {
@ -42,9 +42,9 @@ struct wlr_session_lock_v1 {
void *data;
// private state
bool locked_sent;
struct {
bool locked_sent;
} WLR_PRIVATE;
};
struct wlr_session_lock_surface_v1_state {
@ -79,11 +79,11 @@ struct wlr_session_lock_surface_v1 {
void *data;
// private state
struct wlr_surface_synced synced;
struct {
struct wlr_surface_synced synced;
struct wl_listener output_destroy;
struct wl_listener output_destroy;
} WLR_PRIVATE;
};
struct wlr_session_lock_manager_v1 *wlr_session_lock_manager_v1_create(

@ -25,12 +25,12 @@ struct wlr_renderer;
struct wlr_shm {
struct wl_global *global;
// private state
struct {
uint32_t *formats;
size_t formats_len;
uint32_t *formats;
size_t formats_len;
struct wl_listener display_destroy;
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
/**

@ -14,9 +14,9 @@
struct wlr_single_pixel_buffer_manager_v1 {
struct wl_global *global;
// private state
struct wl_listener display_destroy;
struct {
struct wl_listener display_destroy;
} WLR_PRIVATE;
};

@ -23,9 +23,9 @@ struct wlr_subsurface_parent_state {
int32_t x, y;
struct wl_list link;
// private state
struct wlr_surface_synced *synced;
struct {
struct wlr_surface_synced *synced;
} WLR_PRIVATE;
};
struct wlr_subsurface {
@ -50,9 +50,9 @@ struct wlr_subsurface {
void *data;
// private state
struct wlr_surface_synced parent_synced;
struct {
struct wlr_surface_synced parent_synced;
} WLR_PRIVATE;
};
struct wlr_subcompositor {

@ -30,13 +30,13 @@ struct wlr_tearing_control_v1 {
struct wlr_surface *surface;
// private state
enum wp_tearing_control_v1_presentation_hint previous;
struct wlr_addon addon;
struct wlr_surface_synced synced;
struct {
enum wp_tearing_control_v1_presentation_hint previous;
struct wlr_addon addon;
struct wlr_surface_synced synced;
struct wl_listener surface_commit;
struct wl_listener surface_commit;
} WLR_PRIVATE;
};
struct wlr_tearing_control_manager_v1 {

@ -17,8 +17,9 @@ struct wlr_transient_seat_v1 {
struct wl_resource *resource;
struct wlr_seat *seat;
// private state
struct wl_listener seat_destroy;
struct {
struct wl_listener seat_destroy;
} WLR_PRIVATE;
};
struct wlr_transient_seat_manager_v1 {

@ -28,14 +28,14 @@ struct wlr_xdg_activation_token_v1 {
struct wl_signal destroy;
} events;
// private state
char *token;
struct wl_resource *resource; // can be NULL
struct wl_event_source *timeout; // can be NULL
struct {
char *token;
struct wl_resource *resource; // can be NULL
struct wl_event_source *timeout; // can be NULL
struct wl_listener seat_destroy;
struct wl_listener surface_destroy;
struct wl_listener seat_destroy;
struct wl_listener surface_destroy;
} WLR_PRIVATE;
};
struct wlr_xdg_activation_v1 {
@ -49,13 +49,12 @@ struct wlr_xdg_activation_v1 {
struct wl_signal new_token; // struct wlr_xdg_activation_token_v1
} events;
// private state
struct wl_display *display;
struct wl_global *global;
struct {
struct wl_display *display;
struct wl_global *global;
struct wl_listener display_destroy;
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
struct wlr_xdg_activation_v1_request_activate_event {

@ -54,13 +54,13 @@ struct wlr_xdg_toplevel_decoration_v1 {
void *data;
// private state
struct wl_listener toplevel_destroy;
struct wl_listener surface_configure;
struct wl_listener surface_ack_configure;
struct {
struct wl_listener toplevel_destroy;
struct wl_listener surface_configure;
struct wl_listener surface_ack_configure;
struct wlr_surface_synced synced;
struct wlr_surface_synced synced;
} WLR_PRIVATE;
};
struct wlr_xdg_decoration_manager_v1 *

@ -110,9 +110,9 @@ struct wlr_xdg_popup {
struct wl_list grab_link; // wlr_xdg_popup_grab.popups
// private state
struct wlr_surface_synced synced;
struct {
struct wlr_surface_synced synced;
} WLR_PRIVATE;
};
// each seat gets a popup grab
@ -221,9 +221,9 @@ struct wlr_xdg_toplevel {
struct wl_signal set_app_id;
} events;
// private state
struct wlr_surface_synced synced;
struct {
struct wlr_surface_synced synced;
} WLR_PRIVATE;
};
struct wlr_xdg_surface_configure {
@ -304,11 +304,11 @@ struct wlr_xdg_surface {
void *data;
// private state
struct wlr_surface_synced synced;
struct {
struct wlr_surface_synced synced;
struct wl_listener role_resource_destroy;
struct wl_listener role_resource_destroy;
} WLR_PRIVATE;
};
struct wlr_xdg_toplevel_move_event {

@ -12,8 +12,9 @@
#include <wayland-server-core.h>
struct wlr_addon_set {
// private state
struct wl_list addons;
struct {
struct wl_list addons;
} WLR_PRIVATE;
};
struct wlr_addon;
@ -26,9 +27,11 @@ struct wlr_addon_interface {
struct wlr_addon {
const struct wlr_addon_interface *impl;
// private state
const void *owner;
struct wl_list link;
struct {
const void *owner;
struct wl_list link;
} WLR_PRIVATE;
};
void wlr_addon_set_init(struct wlr_addon_set *set);

@ -25,13 +25,13 @@ struct wlr_xwayland_shell_v1 {
struct wl_signal new_surface; // struct wlr_xwayland_surface_v1
} events;
// private state
struct wl_client *client;
struct wl_list surfaces; // wlr_xwayland_surface_v1.link
struct {
struct wl_client *client;
struct wl_list surfaces; // wlr_xwayland_surface_v1.link
struct wl_listener display_destroy;
struct wl_listener client_destroy;
struct wl_listener display_destroy;
struct wl_listener client_destroy;
} WLR_PRIVATE;
};
/**
@ -41,12 +41,12 @@ struct wlr_xwayland_surface_v1 {
struct wlr_surface *surface;
uint64_t serial;
// private state
struct wl_resource *resource;
struct wl_list link;
struct wlr_xwayland_shell_v1 *shell;
bool added;
struct {
struct wl_resource *resource;
struct wl_list link;
struct wlr_xwayland_shell_v1 *shell;
bool added;
} WLR_PRIVATE;
};
/**

@ -65,13 +65,13 @@ struct wlr_xwayland {
void *data;
// private state
struct wl_listener server_start;
struct wl_listener server_ready;
struct wl_listener server_destroy;
struct wl_listener seat_destroy;
struct wl_listener shell_destroy;
struct {
struct wl_listener server_start;
struct wl_listener server_ready;
struct wl_listener server_destroy;
struct wl_listener seat_destroy;
struct wl_listener shell_destroy;
} WLR_PRIVATE;
};
enum wlr_xwayland_surface_decorations {

@ -22,6 +22,7 @@ big_endian = target_machine.endian() == 'big'
add_project_arguments([
'-D_POSIX_C_SOURCE=200809L',
'-DWLR_USE_UNSTABLE',
'-DWLR_PRIVATE=',
'-DWLR_LITTLE_ENDIAN=@0@'.format(little_endian.to_int()),
'-DWLR_BIG_ENDIAN=@0@'.format(big_endian.to_int()),
], language: 'c')

Loading…
Cancel
Save