Merge upstream

This commit is contained in:
Christian Kröner 2022-02-23 21:43:41 +01:00
commit c673b684a0
203 changed files with 6752 additions and 4861 deletions

View file

@ -10,10 +10,4 @@
*/
uint32_t backend_get_buffer_caps(struct wlr_backend *backend);
/**
* Get the backend's allocator. Automatically creates the allocator if
* necessary.
*/
struct wlr_allocator *backend_get_allocator(struct wlr_backend *backend);
#endif

View file

@ -36,7 +36,7 @@ struct wlr_drm_plane {
struct wlr_drm_crtc {
uint32_t id;
uint32_t lessee_id;
struct wlr_drm_lease *lease;
// Atomic modesetting only
uint32_t mode_id;
@ -118,7 +118,7 @@ struct wlr_drm_connector {
enum wlr_drm_connector_status status;
bool desired_enabled;
uint32_t id;
uint32_t lessee_id;
struct wlr_drm_lease *lease;
struct wlr_drm_crtc *crtc;
uint32_t possible_crtcs;
@ -149,6 +149,7 @@ bool init_drm_resources(struct wlr_drm_backend *drm);
void finish_drm_resources(struct wlr_drm_backend *drm);
void scan_drm_connectors(struct wlr_drm_backend *state,
struct wlr_device_hotplug_event *event);
void scan_drm_leases(struct wlr_drm_backend *drm);
int handle_drm_event(int fd, uint32_t mask, void *data);
void destroy_drm_connector(struct wlr_drm_connector *conn);
bool drm_connector_commit_state(struct wlr_drm_connector *conn,
@ -157,6 +158,7 @@ bool drm_connector_is_cursor_visible(struct wlr_drm_connector *conn);
bool drm_connector_supports_vrr(struct wlr_drm_connector *conn);
size_t drm_crtc_get_gamma_lut_size(struct wlr_drm_backend *drm,
struct wlr_drm_crtc *crtc);
void drm_lease_destroy(struct wlr_drm_lease *lease);
struct wlr_drm_fb *plane_get_next_fb(struct wlr_drm_plane *plane);

View file

@ -0,0 +1,24 @@
#ifndef BACKEND_DRM_MONITOR_H
#define BACKEND_DRM_MONITOR_H
#include <wlr/backend/drm.h>
/**
* Helper to create new DRM sub-backends on GPU hotplug.
*/
struct wlr_drm_backend_monitor {
struct wlr_backend *multi;
struct wlr_backend *primary_drm;
struct wlr_session *session;
struct wl_listener multi_destroy;
struct wl_listener primary_drm_destroy;
struct wl_listener session_destroy;
struct wl_listener session_add_drm_card;
};
struct wlr_drm_backend_monitor *drm_backend_monitor_create(
struct wlr_backend *multi, struct wlr_backend *primary_drm,
struct wlr_session *session);
#endif

View file

@ -39,11 +39,4 @@ size_t match_obj(size_t num_objs, const uint32_t objs[static restrict num_objs],
size_t num_res, const uint32_t res[static restrict num_res],
uint32_t out[static restrict num_res]);
/**
* Close a GEM buffer handle.
*
* TODO: replace with drmCloseBufferHandle.
*/
void close_bo_handle(int drm_fd, uint32_t handle);
#endif

View file

@ -8,14 +8,10 @@
struct wlr_headless_backend {
struct wlr_backend backend;
int drm_fd;
struct wl_display *display;
struct wl_list outputs;
size_t last_output_num;
struct wl_list input_devices;
struct wl_listener display_destroy;
struct wlr_renderer *parent_renderer;
struct wl_listener parent_renderer_destroy;
bool started;
};
@ -29,12 +25,6 @@ struct wlr_headless_output {
int frame_delay; // ms
};
struct wlr_headless_input_device {
struct wlr_input_device wlr_input_device;
struct wlr_headless_backend *backend;
};
struct wlr_headless_backend *headless_backend_from_backend(
struct wlr_backend *wlr_backend);

View file

@ -5,7 +5,12 @@
#include <wayland-server-core.h>
#include <wlr/backend/interface.h>
#include <wlr/backend/libinput.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/interfaces/wlr_switch.h>
#include <wlr/interfaces/wlr_tablet_pad.h>
#include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/interfaces/wlr_touch.h>
#include <wlr/types/wlr_input_device.h>
struct wlr_libinput_backend {
@ -26,7 +31,7 @@ struct wlr_libinput_backend {
struct wlr_libinput_input_device {
struct wlr_input_device wlr_input_device;
struct wl_list link;
struct libinput_device *handle;
};
@ -39,6 +44,15 @@ struct wlr_input_device *get_appropriate_device(
enum wlr_input_device_type desired_type,
struct libinput_device *device);
void destroy_libinput_input_device(struct wlr_libinput_input_device *dev);
extern const struct wlr_keyboard_impl libinput_keyboard_impl;
extern const struct wlr_pointer_impl libinput_pointer_impl;
extern const struct wlr_switch_impl libinput_switch_impl;
extern const struct wlr_tablet_impl libinput_tablet_impl;
extern const struct wlr_tablet_pad_impl libinput_tablet_pad_impl;
extern const struct wlr_touch_impl libinput_touch_impl;
struct wlr_keyboard *create_libinput_keyboard(
struct libinput_device *device);
void handle_keyboard_key(struct libinput_event *event,

View file

@ -1,27 +0,0 @@
#ifndef BACKEND_NOOP_H
#define BACKEND_NOOP_H
#include <wlr/backend/noop.h>
#include <wlr/backend/interface.h>
struct wlr_noop_backend {
struct wlr_backend backend;
struct wl_display *display;
struct wl_list outputs;
size_t last_output_num;
bool started;
struct wl_listener display_destroy;
};
struct wlr_noop_output {
struct wlr_output wlr_output;
struct wlr_noop_backend *backend;
struct wl_list link;
};
struct wlr_noop_backend *noop_backend_from_backend(
struct wlr_backend *wlr_backend);
#endif

View file

@ -11,4 +11,7 @@ bool libseat_change_vt(struct wlr_session *base, unsigned vt);
void session_init(struct wlr_session *session);
struct wlr_device *session_open_if_kms(struct wlr_session *restrict session,
const char *restrict path);
#endif

View file

@ -40,6 +40,7 @@ struct wlr_wl_backend {
struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1;
struct wl_list seats; // wlr_wl_seat.link
struct zwp_tablet_manager_v2 *tablet_manager;
clockid_t presentation_clock;
struct wlr_drm_format_set shm_formats;
struct wlr_drm_format_set linux_dmabuf_v1_formats;
struct wl_drm *legacy_drm;
@ -86,6 +87,7 @@ struct wlr_wl_output {
struct wlr_wl_input_device {
struct wlr_input_device wlr_input_device;
struct wl_list link;
uint32_t fingers;
struct wlr_wl_backend *backend;
@ -132,9 +134,12 @@ struct wlr_wl_input_device *create_wl_input_device(
struct wlr_wl_seat *seat, enum wlr_input_device_type type);
bool create_wl_seat(struct wl_seat *wl_seat, struct wlr_wl_backend *wl);
void destroy_wl_seats(struct wlr_wl_backend *wl);
void destroy_wl_input_device(struct wlr_wl_input_device *dev);
void destroy_wl_buffer(struct wlr_wl_buffer *buffer);
extern const struct wl_seat_listener seat_listener;
extern const struct wlr_tablet_pad_impl tablet_pad_impl;
extern const struct wlr_tablet_impl tablet_impl;
struct wlr_wl_tablet_seat *wl_add_tablet_seat(
struct zwp_tablet_manager_v2 *manager,

View file

@ -15,11 +15,10 @@
#include <pixman.h>
#include <wlr/backend/x11.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/interfaces/wlr_touch.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/render/drm_format_set.h>
#define XCB_EVENT_RESPONSE_TYPE_MASK 0x7f
@ -35,10 +34,8 @@ struct wlr_x11_output {
xcb_present_event_t present_event_id;
struct wlr_pointer pointer;
struct wlr_input_device pointer_dev;
struct wlr_touch touch;
struct wlr_input_device touch_dev;
struct wl_list touchpoints; // wlr_x11_touchpoint::link
struct wl_list buffers; // wlr_x11_buffer::link
@ -81,7 +78,6 @@ struct wlr_x11_backend {
struct wl_list outputs; // wlr_x11_output::link
struct wlr_keyboard keyboard;
struct wlr_input_device keyboard_dev;
int drm_fd;
struct wlr_drm_format_set dri3_formats;
@ -130,10 +126,9 @@ struct wlr_x11_backend *get_x11_backend_from_backend(
struct wlr_x11_output *get_x11_output_from_window_id(
struct wlr_x11_backend *x11, xcb_window_t window);
extern const struct wlr_keyboard_impl keyboard_impl;
extern const struct wlr_pointer_impl pointer_impl;
extern const struct wlr_touch_impl touch_impl;
extern const struct wlr_input_device_impl input_device_impl;
extern const struct wlr_keyboard_impl x11_keyboard_impl;
extern const struct wlr_pointer_impl x11_pointer_impl;
extern const struct wlr_touch_impl x11_touch_impl;
void handle_x11_xinput_event(struct wlr_x11_backend *x11,
xcb_ge_generic_event_t *event);

View file

@ -4,6 +4,7 @@
#include <wlr/render/drm_format_set.h>
struct wlr_drm_format *wlr_drm_format_create(uint32_t format);
bool wlr_drm_format_has(const struct wlr_drm_format *fmt, uint64_t modifier);
bool wlr_drm_format_add(struct wlr_drm_format **fmt_ptr, uint64_t modifier);
struct wlr_drm_format *wlr_drm_format_dup(const struct wlr_drm_format *format);
/**

View file

@ -24,7 +24,6 @@ struct wlr_gles2_pixel_format {
struct wlr_gles2_tex_shader {
GLuint program;
GLint proj;
GLint invert_y;
GLint tex;
GLint alpha;
GLint pos_attrib;
@ -101,7 +100,6 @@ struct wlr_gles2_texture {
EGLImageKHR image;
bool inverted_y;
bool has_alpha;
// Only affects target == GL_TEXTURE_2D

View file

@ -246,7 +246,6 @@ struct wlr_vk_texture {
bool dmabuf_imported;
bool owned; // if dmabuf_imported: whether we have ownership of the image
bool transitioned; // if dma_imported: whether we transitioned it away from preinit
bool invert_y; // if dma_imported: whether we must flip y
struct wl_list foreign_link;
struct wl_list destroy_link;
struct wl_list link; // wlr_gles2_renderer.textures

View file

@ -8,7 +8,7 @@ void output_pending_resolution(struct wlr_output *output, int *width,
int *height);
struct wlr_drm_format *output_pick_format(struct wlr_output *output,
const struct wlr_drm_format_set *display_formats);
const struct wlr_drm_format_set *display_formats, uint32_t format);
void output_clear_back_buffer(struct wlr_output *output);
bool output_ensure_buffer(struct wlr_output *output);

View file

@ -1,20 +0,0 @@
#ifndef TYPES_WLR_SURFACE_H
#define TYPES_WLR_SURFACE_H
#include <wlr/types/wlr_surface.h>
struct wlr_renderer;
/**
* Create a new surface resource with the provided new ID.
*/
struct wlr_surface *surface_create(struct wl_client *client,
uint32_t version, uint32_t id, struct wlr_renderer *renderer);
/**
* Create a new subsurface resource with the provided new ID.
*/
struct wlr_subsurface *subsurface_create(struct wlr_surface *surface,
struct wlr_surface *parent, uint32_t version, uint32_t id);
#endif

View file

@ -5,41 +5,36 @@
#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;
struct wlr_xdg_surface *create_xdg_surface(
struct wlr_xdg_client *client, struct wlr_surface *surface,
struct wlr_xdg_client *client, struct wlr_surface *wlr_surface,
uint32_t id);
void unmap_xdg_surface(struct wlr_xdg_surface *surface);
void reset_xdg_surface(struct wlr_xdg_surface *xdg_surface);
void reset_xdg_surface(struct wlr_xdg_surface *surface);
void destroy_xdg_surface(struct wlr_xdg_surface *surface);
void handle_xdg_surface_commit(struct wlr_surface *wlr_surface);
void handle_xdg_surface_precommit(struct wlr_surface *wlr_surface);
void xdg_surface_role_commit(struct wlr_surface *wlr_surface);
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 *xdg_surface,
void create_xdg_popup(struct wlr_xdg_surface *surface,
struct wlr_xdg_surface *parent,
struct wlr_xdg_positioner_resource *positioner, int32_t id);
void handle_xdg_surface_popup_committed(struct wlr_xdg_surface *surface);
struct wlr_xdg_popup_grab *get_xdg_shell_popup_grab_from_seat(
struct wlr_xdg_shell *shell, struct wlr_seat *seat);
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);
void create_xdg_toplevel(struct wlr_xdg_surface *xdg_surface,
void create_xdg_toplevel(struct wlr_xdg_surface *surface,
uint32_t id);
void handle_xdg_surface_toplevel_committed(struct wlr_xdg_surface *surface);
void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface,
struct wlr_xdg_surface_configure *configure);
void handle_xdg_toplevel_ack_configure(struct wlr_xdg_surface *surface,
struct wlr_xdg_surface_configure *configure);
void destroy_xdg_toplevel(struct wlr_xdg_surface *surface);
void unmap_xdg_toplevel(struct wlr_xdg_toplevel *toplevel);
void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel);
void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel);
struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure(
struct wlr_xdg_toplevel *toplevel);
void handle_xdg_toplevel_ack_configure(struct wlr_xdg_toplevel *toplevel,
struct wlr_xdg_toplevel_configure *configure);
#endif

View file

@ -9,7 +9,6 @@
* Globals that are created and destroyed on the fly need special handling to
* prevent race conditions with wl_registry. Use this function to destroy them.
*/
void wlr_global_destroy_safe(struct wl_global *global,
struct wl_display *display);
void wlr_global_destroy_safe(struct wl_global *global);
#endif

View file

@ -25,12 +25,6 @@ struct wlr_backend {
/** Raised when new outputs are added, passed the wlr_output */
struct wl_signal new_output;
} events;
// Private state
bool has_own_renderer;
struct wlr_renderer *renderer;
struct wlr_allocator *allocator;
};
/**
@ -50,10 +44,6 @@ bool wlr_backend_start(struct wlr_backend *backend);
* automatically when the wl_display is destroyed.
*/
void wlr_backend_destroy(struct wlr_backend *backend);
/**
* Obtains the wlr_renderer reference this backend is using.
*/
struct wlr_renderer *wlr_backend_get_renderer(struct wlr_backend *backend);
/**
* Obtains the wlr_session reference from this backend if there is any.
* Might return NULL for backends that don't use a session.

View file

@ -14,6 +14,20 @@
#include <wlr/backend/session.h>
#include <wlr/types/wlr_output.h>
struct wlr_drm_backend;
struct wlr_drm_lease {
int fd;
uint32_t lessee_id;
struct wlr_drm_backend *backend;
struct {
struct wl_signal destroy;
} events;
void *data;
};
/**
* Creates a DRM backend using the specified GPU file descriptor (typically from
* a device node in /dev/dri).
@ -41,18 +55,20 @@ uint32_t wlr_drm_connector_get_id(struct wlr_output *output);
int wlr_drm_backend_get_non_master_fd(struct wlr_backend *backend);
/**
* Leases a given output to the caller. The output must be from the associated
* DRM backend.
* Returns a valid opened DRM FD or -1 on error.
* Leases the given outputs to the caller. The outputs must be from the
* associated DRM backend.
*
* Returns NULL on error.
*/
int wlr_drm_create_lease(struct wlr_output **outputs, size_t n_outputs,
uint32_t *lessee_id);
struct wlr_drm_lease *wlr_drm_create_lease(struct wlr_output **outputs,
size_t n_outputs, int *lease_fd);
/**
* Terminates a given lease. The output will be owned again by the backend
* Terminates and destroys a given lease.
*
* The outputs will be owned again by the backend.
*/
bool wlr_drm_backend_terminate_lease(struct wlr_backend *backend,
uint32_t lessee_id);
void wlr_drm_lease_terminate(struct wlr_drm_lease *lease);
/**
* Add mode to the list of available modes

View file

@ -18,11 +18,6 @@
* default.
*/
struct wlr_backend *wlr_headless_backend_create(struct wl_display *display);
/**
* Creates a headless backend with an existing renderer.
*/
struct wlr_backend *wlr_headless_backend_create_with_renderer(
struct wl_display *display, struct wlr_renderer *renderer);
/**
* Create a new headless output backed by an in-memory EGL framebuffer. You can
* read pixels from this framebuffer via wlr_renderer_read_pixels but it is
@ -30,15 +25,8 @@ struct wlr_backend *wlr_headless_backend_create_with_renderer(
*/
struct wlr_output *wlr_headless_add_output(struct wlr_backend *backend,
unsigned int width, unsigned int height);
/**
* Creates a new input device. The caller is responsible for manually raising
* any event signals on the new input device if it wants to simulate input
* events.
*/
struct wlr_input_device *wlr_headless_add_input_device(
struct wlr_backend *backend, enum wlr_input_device_type type);
bool wlr_backend_is_headless(struct wlr_backend *backend);
bool wlr_input_device_is_headless(struct wlr_input_device *device);
bool wlr_output_is_headless(struct wlr_output *output);
#endif

View file

@ -16,7 +16,6 @@
struct wlr_backend_impl {
bool (*start)(struct wlr_backend *backend);
void (*destroy)(struct wlr_backend *backend);
struct wlr_renderer *(*get_renderer)(struct wlr_backend *backend);
struct wlr_session *(*get_session)(struct wlr_backend *backend);
clockid_t (*get_presentation_clock)(struct wlr_backend *backend);
int (*get_drm_fd)(struct wlr_backend *backend);

View file

@ -1,31 +0,0 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_BACKEND_NOOP_H
#define WLR_BACKEND_NOOP_H
#include <wlr/backend.h>
#include <wlr/types/wlr_output.h>
/**
* Creates a noop backend. Noop backends do not have a framebuffer and are not
* capable of rendering anything. They are useful for when there's no real
* outputs connected; you can stash your views on a noop output until an output
* is connected.
*/
struct wlr_backend *wlr_noop_backend_create(struct wl_display *display);
/**
* Create a new noop output.
*/
struct wlr_output *wlr_noop_add_output(struct wlr_backend *backend);
bool wlr_backend_is_noop(struct wlr_backend *backend);
bool wlr_output_is_noop(struct wlr_output *output);
#endif

View file

@ -59,6 +59,7 @@ struct wlr_session_add_event {
enum wlr_device_change_type {
WLR_DEVICE_HOTPLUG = 1,
WLR_DEVICE_LEASE,
};
struct wlr_device_hotplug_event {

View file

@ -1,25 +0,0 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_INTERFACES_WLR_INPUT_DEVICE_H
#define WLR_INTERFACES_WLR_INPUT_DEVICE_H
#include <wlr/types/wlr_input_device.h>
struct wlr_input_device_impl {
void (*destroy)(struct wlr_input_device *wlr_device);
};
void wlr_input_device_init(
struct wlr_input_device *wlr_device,
enum wlr_input_device_type type,
const struct wlr_input_device_impl *impl,
const char *name, int vendor, int product);
void wlr_input_device_destroy(struct wlr_input_device *dev);
#endif

View file

@ -18,7 +18,7 @@ struct wlr_keyboard_impl {
};
void wlr_keyboard_init(struct wlr_keyboard *keyboard,
const struct wlr_keyboard_impl *impl);
const struct wlr_keyboard_impl *impl, const char *name);
void wlr_keyboard_destroy(struct wlr_keyboard *keyboard);
void wlr_keyboard_notify_key(struct wlr_keyboard *keyboard,
struct wlr_event_keyboard_key *event);

View file

@ -21,6 +21,7 @@
(WLR_OUTPUT_STATE_DAMAGE | \
WLR_OUTPUT_STATE_SCALE | \
WLR_OUTPUT_STATE_TRANSFORM | \
WLR_OUTPUT_STATE_RENDER_FORMAT | \
WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED)
/**
@ -85,7 +86,7 @@ struct wlr_output_impl {
*/
void (*get_cursor_size)(struct wlr_output *output, int *width, int *height);
/**
* Get the list of DMA-BUF formats suitable for the primary buffer,
* Get the list of DRM formats suitable for the primary buffer,
* assuming a buffer with the specified capabilities.
*
* If unimplemented, the primary buffer has no format constraint. If NULL

View file

@ -16,7 +16,7 @@ struct wlr_pointer_impl {
};
void wlr_pointer_init(struct wlr_pointer *pointer,
const struct wlr_pointer_impl *impl);
const struct wlr_pointer_impl *impl, const char *name);
void wlr_pointer_destroy(struct wlr_pointer *pointer);
#endif

View file

@ -16,7 +16,7 @@ struct wlr_switch_impl {
};
void wlr_switch_init(struct wlr_switch *switch_device,
struct wlr_switch_impl *impl);
const struct wlr_switch_impl *impl, const char *name);
void wlr_switch_destroy(struct wlr_switch *switch_device);
#endif

View file

@ -16,7 +16,7 @@ struct wlr_tablet_pad_impl {
};
void wlr_tablet_pad_init(struct wlr_tablet_pad *pad,
struct wlr_tablet_pad_impl *impl);
const struct wlr_tablet_pad_impl *impl, const char *name);
void wlr_tablet_pad_destroy(struct wlr_tablet_pad *pad);
#endif

View file

@ -16,7 +16,7 @@ struct wlr_tablet_impl {
};
void wlr_tablet_init(struct wlr_tablet *tablet,
const struct wlr_tablet_impl *impl);
const struct wlr_tablet_impl *impl, const char *name);
void wlr_tablet_destroy(struct wlr_tablet *tablet);
#endif

View file

@ -16,7 +16,7 @@ struct wlr_touch_impl {
};
void wlr_touch_init(struct wlr_touch *touch,
const struct wlr_touch_impl *impl);
const struct wlr_touch_impl *impl, const char *name);
void wlr_touch_destroy(struct wlr_touch *touch);
#endif

View file

@ -51,6 +51,18 @@ void wlr_allocator_destroy(struct wlr_allocator *alloc);
*
* When the caller is done with it, they must unreference it by calling
* wlr_buffer_drop.
*
* The `format` passed in indicates the format to use and the list of
* acceptable modifiers. The order in which modifiers are listed is not
* significant.
*
* When running with legacy drivers which don't support explicit modifiers, the
* allocator must recognize two modifiers: INVALID (for implicit tiling and/or
* compression) and LINEAR.
*
* The allocator must return a buffer using one of the modifiers listed. In
* particular, allocators must not return a buffer with an implicit modifier
* unless the user has allowed it by passing INVALID in the modifier list.
*/
struct wlr_buffer *wlr_allocator_create_buffer(struct wlr_allocator *alloc,
int width, int height, const struct wlr_drm_format *format);

View file

@ -14,17 +14,27 @@
#define WLR_DMABUF_MAX_PLANES 4
enum wlr_dmabuf_attributes_flags {
WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT = 1 << 0,
WLR_DMABUF_ATTRIBUTES_FLAGS_INTERLACED = 1 << 1,
WLR_DMABUF_ATTRIBUTES_FLAGS_BOTTOM_FIRST = 1 << 2,
};
/**
* A Linux DMA-BUF pixel buffer.
*
* If the buffer was allocated with explicit modifiers enabled, the `modifier`
* field must not be INVALID.
*
* If the buffer was allocated with explicit modifiers disabled (either because
* the driver doesn't support it, or because the user didn't specify a valid
* modifier list), the `modifier` field can have two values: INVALID means that
* an implicit vendor-defined modifier is in use, LINEAR means that the buffer
* is linear. The `modifier` field must not have any other value.
*
* When importing a DMA-BUF, users must not ignore the modifier unless it's
* INVALID or LINEAR. In particular, users must not import a DMA-BUF to a
* legacy API which doesn't support specifying an explicit modifier unless the
* modifier is set to INVALID or LINEAR.
*/
struct wlr_dmabuf_attributes {
int32_t width, height;
uint32_t format;
uint32_t flags; // enum wlr_dmabuf_attributes_flags
uint64_t modifier;
uint32_t format; // FourCC code, see DRM_FORMAT_* in <drm_fourcc.h>
uint64_t modifier; // see DRM_FORMAT_MOD_* in <drm_fourcc.h>
int n_planes;
uint32_t offset[WLR_DMABUF_MAX_PLANES];

View file

@ -5,19 +5,55 @@
#include <stddef.h>
#include <stdint.h>
/** A single DRM format, with a set of modifiers attached. */
struct wlr_drm_format {
// The actual DRM format, from `drm_fourcc.h`
uint32_t format;
size_t len, cap;
// The number of modifiers
size_t len;
// The capacity of the array; do not use.
size_t capacity;
// The actual modifiers
uint64_t modifiers[];
};
/**
* A set of DRM formats and modifiers.
*
* This is used to describe the supported format + modifier combinations. For
* instance, backends will report the set they can display, and renderers will
* report the set they can render to. For a more general overview of formats
* and modifiers, see:
* https://lore.kernel.org/dri-devel/20210905122742.86029-1-daniels@collabora.com/
*
* For compatibility with legacy drivers which don't support explicit
* modifiers, the special modifier DRM_FORMAT_MOD_INVALID is used to indicate
* that implicit modifiers are supported. Legacy drivers can also support the
* DRM_FORMAT_MOD_LINEAR modifier, which forces the buffer to have a linear
* layout.
*
* Users must not assume that implicit modifiers are supported unless INVALID
* is listed in the modifier list.
*/
struct wlr_drm_format_set {
size_t len, cap;
// The number of formats
size_t len;
// The capacity of the array; private to wlroots
size_t capacity;
// A pointer to an array of `struct wlr_drm_format *` of length `len`.
struct wlr_drm_format **formats;
};
/**
* Free all of the DRM formats in the set, making the set empty. Does not
* free the set itself.
*/
void wlr_drm_format_set_finish(struct wlr_drm_format_set *set);
/**
* Return a pointer to a member of this `wlr_drm_format_set` of format
* `format`, or NULL if none exists.
*/
const struct wlr_drm_format *wlr_drm_format_set_get(
const struct wlr_drm_format_set *set, uint32_t format);
@ -27,4 +63,13 @@ bool wlr_drm_format_set_has(const struct wlr_drm_format_set *set,
bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format,
uint64_t modifier);
/**
* Intersect two DRM format sets `a` and `b`, storing in the destination set
* `dst` the format + modifier pairs which are in both source sets.
*
* Returns false on failure or when the intersection is empty.
*/
bool wlr_drm_format_set_intersect(struct wlr_drm_format_set *dst,
const struct wlr_drm_format_set *a, const struct wlr_drm_format_set *b);
#endif

View file

@ -40,6 +40,7 @@ struct wlr_egl {
bool KHR_image_base;
bool EXT_image_dma_buf_import;
bool EXT_image_dma_buf_import_modifiers;
bool IMG_context_priority;
// Device extensions
bool EXT_device_drm;
@ -64,10 +65,14 @@ struct wlr_egl {
PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT;
} procs;
bool has_modifiers;
struct wlr_drm_format_set dmabuf_texture_formats;
struct wlr_drm_format_set dmabuf_render_formats;
};
struct wlr_egl *wlr_egl_create_with_context(EGLDisplay display,
EGLContext context);
/**
* Make the EGL context current.
*

View file

@ -30,7 +30,6 @@ struct wlr_gles2_texture_attribs {
GLenum target; /* either GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES */
GLuint tex;
bool inverted_y;
bool has_alpha;
};

View file

@ -99,13 +99,19 @@ bool wlr_renderer_read_pixels(struct wlr_renderer *r, uint32_t fmt,
uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, void *data);
/**
* Creates necessary shm and invokes the initialization of the implementation.
* Initializes wl_shm, linux-dmabuf and other buffer factory protocols.
*
* Returns false on failure.
*/
bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
struct wl_display *wl_display);
/**
* Initializes wl_shm on the provided wl_display.
*/
bool wlr_renderer_init_wl_shm(struct wlr_renderer *r,
struct wl_display *wl_display);
/**
* Obtains the FD of the DRM device used for rendering, or -1 if unavailable.
*

View file

@ -33,16 +33,6 @@ struct wlr_texture *wlr_texture_from_pixels(struct wlr_renderer *renderer,
uint32_t fmt, uint32_t stride, uint32_t width, uint32_t height,
const void *data);
/**
* Create a new texture from a wl_drm resource. The returned texture is
* immutable.
*
* Should not be called in a rendering block like renderer_begin()/end() or
* between attaching a renderer to an output and committing it.
*/
struct wlr_texture *wlr_texture_from_wl_drm(struct wlr_renderer *renderer,
struct wl_resource *data);
/**
* Create a new texture from a DMA-BUF. The returned texture is immutable.
*

View file

@ -1,7 +0,0 @@
#ifndef WLR_TYPES_WLR_BOX_H
#define WLR_TYPES_WLR_BOX_H
#warning "wlr_box has been moved to wlr/util/box.h"
#include <wlr/util/box.h>
#endif

View file

@ -9,21 +9,167 @@
#ifndef WLR_TYPES_WLR_COMPOSITOR_H
#define WLR_TYPES_WLR_COMPOSITOR_H
#include <pixman.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#include <wayland-server-core.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_output.h>
#include <wlr/util/addon.h>
#include <wlr/util/box.h>
struct wlr_surface;
struct wlr_subcompositor {
struct wl_global *global;
enum wlr_surface_state_field {
WLR_SURFACE_STATE_BUFFER = 1 << 0,
WLR_SURFACE_STATE_SURFACE_DAMAGE = 1 << 1,
WLR_SURFACE_STATE_BUFFER_DAMAGE = 1 << 2,
WLR_SURFACE_STATE_OPAQUE_REGION = 1 << 3,
WLR_SURFACE_STATE_INPUT_REGION = 1 << 4,
WLR_SURFACE_STATE_TRANSFORM = 1 << 5,
WLR_SURFACE_STATE_SCALE = 1 << 6,
WLR_SURFACE_STATE_FRAME_CALLBACK_LIST = 1 << 7,
WLR_SURFACE_STATE_VIEWPORT = 1 << 8,
};
struct wlr_surface_state {
uint32_t committed; // enum wlr_surface_state_field
// Sequence number of the surface state. Incremented on each commit, may
// overflow.
uint32_t seq;
struct wlr_buffer *buffer;
int32_t dx, dy; // relative to previous position
pixman_region32_t surface_damage, buffer_damage; // clipped to bounds
pixman_region32_t opaque, input;
enum wl_output_transform transform;
int32_t scale;
struct wl_list frame_callback_list; // wl_resource
int width, height; // in surface-local coordinates
int buffer_width, buffer_height;
struct wl_list subsurfaces_below;
struct wl_list subsurfaces_above;
/**
* The viewport is applied after the surface transform and scale.
*
* If has_src is true, the surface content is cropped to the provided
* rectangle. If has_dst is true, the surface content is scaled to the
* provided rectangle.
*/
struct {
bool has_src, has_dst;
// In coordinates after scale/transform are applied, but before the
// destination rectangle is applied
struct wlr_fbox src;
int dst_width, dst_height; // in surface-local coordinates
} viewport;
// Number of locks that prevent this surface state from being committed.
size_t cached_state_locks;
struct wl_list cached_state_link; // wlr_surface.cached
};
struct wlr_surface_role {
const char *name;
void (*commit)(struct wlr_surface *surface);
void (*precommit)(struct wlr_surface *surface,
const struct wlr_surface_state *state);
};
struct wlr_surface_output {
struct wlr_surface *surface;
struct wlr_output *output;
struct wl_list link; // wlr_surface::current_outputs
struct wl_listener bind;
struct wl_listener destroy;
};
struct wlr_surface {
struct wl_resource *resource;
struct wlr_renderer *renderer;
/**
* The surface's buffer, if any. A surface has an attached buffer when it
* commits with a non-null buffer in its pending state. A surface will not
* have a buffer if it has never committed one, has committed a null buffer,
* or something went wrong with uploading the buffer.
*/
struct wlr_client_buffer *buffer;
/**
* The buffer position, in surface-local units.
*/
int sx, sy;
/**
* The last commit's buffer damage, in buffer-local coordinates. This
* contains both the damage accumulated by the client via
* `wlr_surface_state.surface_damage` and `wlr_surface_state.buffer_damage`.
* If the buffer has been resized, the whole buffer is damaged.
*
* This region needs to be scaled and transformed into output coordinates,
* just like the buffer's texture. In addition, if the buffer has shrunk the
* old size needs to be damaged and if the buffer has moved the old and new
* positions need to be damaged.
*/
pixman_region32_t buffer_damage;
/**
* The last commit's damage caused by surface and its subsurfaces'
* movement, in surface-local coordinates.
*/
pixman_region32_t external_damage;
/**
* The current opaque region, in surface-local coordinates. It is clipped to
* the surface bounds. If the surface's buffer is using a fully opaque
* format, this is set to the whole surface.
*/
pixman_region32_t opaque_region;
/**
* The current input region, in surface-local coordinates. It is clipped to
* the surface bounds.
*/
pixman_region32_t input_region;
/**
* `current` contains the current, committed surface state. `pending`
* accumulates state changes from the client between commits and shouldn't
* be accessed by the compositor directly.
*/
struct wlr_surface_state current, pending;
struct wl_list cached; // wlr_surface_state.cached_link
const struct wlr_surface_role *role; // the lifetime-bound role or NULL
void *role_data; // role-specific data
struct {
struct wl_signal client_commit;
struct wl_signal commit;
struct wl_signal new_subsurface;
struct wl_signal destroy;
} events;
struct wl_list current_outputs; // wlr_surface_output::link
struct wlr_addon_set addons;
void *data;
// private state
struct wl_listener renderer_destroy;
struct {
int32_t scale;
enum wl_output_transform transform;
int width, height;
int buffer_width, buffer_height;
} previous;
};
struct wlr_renderer;
struct wlr_compositor {
struct wl_global *global;
struct wlr_renderer *renderer;
struct wlr_subcompositor subcompositor;
struct wl_listener display_destroy;
struct {
@ -32,16 +178,125 @@ struct wlr_compositor {
} events;
};
typedef void (*wlr_surface_iterator_func_t)(struct wlr_surface *surface,
int sx, int sy, void *data);
/**
* Set the lifetime role for this surface. Returns 0 on success or -1 if the
* role cannot be set.
*/
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);
/**
* Whether or not this surface currently has an attached buffer. A surface has
* an attached buffer when it commits with a non-null buffer in its pending
* state. A surface will not have a buffer if it has never committed one, has
* committed a null buffer, or something went wrong with uploading the buffer.
*/
bool wlr_surface_has_buffer(struct wlr_surface *surface);
/**
* Get the texture of the buffer currently attached to this surface. Returns
* NULL if no buffer is currently attached or if something went wrong with
* uploading the buffer.
*/
struct wlr_texture *wlr_surface_get_texture(struct wlr_surface *surface);
/**
* Get the root of the subsurface tree for this surface. Can return NULL if
* a surface in the tree has been destroyed.
*/
struct wlr_surface *wlr_surface_get_root_surface(struct wlr_surface *surface);
/**
* Check if the surface accepts input events at the given surface-local
* coordinates. Does not check the surface's subsurfaces.
*/
bool wlr_surface_point_accepts_input(struct wlr_surface *surface,
double sx, double sy);
/**
* Find a surface in this surface's tree that accepts input events and has all
* parents mapped (except this surface, which can be unmapped) at the given
* surface-local coordinates. Returns the surface and coordinates in the leaf
* surface coordinate system or NULL if no surface is found at that location.
*/
struct wlr_surface *wlr_surface_surface_at(struct wlr_surface *surface,
double sx, double sy, double *sub_x, double *sub_y);
void wlr_surface_send_enter(struct wlr_surface *surface,
struct wlr_output *output);
void wlr_surface_send_leave(struct wlr_surface *surface,
struct wlr_output *output);
void wlr_surface_send_frame_done(struct wlr_surface *surface,
const struct timespec *when);
/**
* Get the bounding box that contains the surface and all subsurfaces in
* surface coordinates.
* X and y may be negative, if there are subsurfaces with negative position.
*/
void wlr_surface_get_extends(struct wlr_surface *surface, struct wlr_box *box);
/**
* Get the wlr_surface corresponding to a wl_surface resource. This asserts
* that the resource is a valid wl_surface resource created by wlroots and
* will never return NULL.
*/
struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource);
/**
* Call `iterator` on each mapped surface in the surface tree (whether or not
* this surface is mapped), with the surface's position relative to the root
* surface. The function is called from root to leaves (in rendering order).
*/
void wlr_surface_for_each_surface(struct wlr_surface *surface,
wlr_surface_iterator_func_t iterator, void *user_data);
/**
* Get the effective surface damage in surface-local coordinate space. Besides
* buffer damage, this includes damage induced by resizing and moving the
* surface and its subsurfaces. The resulting damage is not expected to be
* bounded by the surface itself.
*/
void wlr_surface_get_effective_damage(struct wlr_surface *surface,
pixman_region32_t *damage);
/**
* Get the source rectangle describing the region of the buffer that needs to
* be sampled to render this surface's current state. The box is in
* buffer-local coordinates.
*
* If the viewport's source rectangle is unset, the position is zero and the
* size is the buffer's.
*/
void wlr_surface_get_buffer_source_box(struct wlr_surface *surface,
struct wlr_fbox *box);
/**
* Acquire a lock for the pending surface state.
*
* The state won't be committed before the caller releases the lock. Instead,
* the state becomes cached. The caller needs to use wlr_surface_unlock_cached
* to release the lock.
*
* Returns a surface commit sequence number for the cached state.
*/
uint32_t wlr_surface_lock_pending(struct wlr_surface *surface);
/**
* Release a lock for a cached state.
*
* Callers should not assume that the cached state will immediately be
* committed. Another caller may still have an active lock.
*/
void wlr_surface_unlock_cached(struct wlr_surface *surface, uint32_t seq);
struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
struct wlr_renderer *renderer);
bool wlr_surface_is_subsurface(struct wlr_surface *surface);
/**
* Get a subsurface from a surface. Can return NULL if the subsurface has been
* destroyed.
*/
struct wlr_subsurface *wlr_subsurface_from_wlr_surface(
struct wlr_surface *surface);
#endif

View file

@ -192,13 +192,13 @@ void wlr_cursor_map_input_to_output(struct wlr_cursor *cur,
/**
* Maps this cursor to an arbitrary region on the associated wlr_output_layout.
*/
void wlr_cursor_map_to_region(struct wlr_cursor *cur, struct wlr_box *box);
void wlr_cursor_map_to_region(struct wlr_cursor *cur, const struct wlr_box *box);
/**
* Maps inputs from this input device to an arbitrary region on the associated
* wlr_output_layout.
*/
void wlr_cursor_map_input_to_region(struct wlr_cursor *cur,
struct wlr_input_device *dev, struct wlr_box *box);
struct wlr_input_device *dev, const struct wlr_box *box);
#endif

View file

@ -81,16 +81,17 @@ struct wlr_drm_lease_request_v1 {
struct wlr_drm_lease_v1 {
struct wl_resource *resource;
struct wlr_drm_lease *drm_lease;
struct wlr_drm_lease_device_v1 *device;
struct wlr_drm_lease_connector_v1 **connectors;
size_t n_connectors;
uint32_t lessee_id;
struct wl_list link; // wlr_drm_lease_device_v1::leases
struct wl_listener destroy;
void *data;
};

View file

@ -36,10 +36,13 @@ enum wlr_foreign_toplevel_handle_v1_state {
struct wlr_foreign_toplevel_handle_v1_output {
struct wl_list link; // wlr_foreign_toplevel_handle_v1::outputs
struct wl_listener output_destroy;
struct wlr_output *output;
struct wlr_foreign_toplevel_handle_v1 *toplevel;
// private state
struct wl_listener output_bind;
struct wl_listener output_destroy;
};
struct wlr_foreign_toplevel_handle_v1 {

View file

@ -28,8 +28,6 @@ enum wlr_input_device_type {
struct wlr_input_device_impl;
struct wlr_input_device {
const struct wlr_input_device_impl *impl;
enum wlr_input_device_type type;
unsigned int vendor, product;
char *name;
@ -53,8 +51,21 @@ struct wlr_input_device {
} events;
void *data;
struct wl_list link;
};
void wlr_input_device_init(struct wlr_input_device *wlr_device,
enum wlr_input_device_type type, const char *name);
/**
* Clean up all of the provided wlr_input_device resources
*/
void wlr_input_device_finish(struct wlr_input_device *wlr_device);
/**
* Calls the specialized input device destroy function.
* If the wlr_input_device is not owned by a specialized input device, the
* function will finish the wlr_input_device and free it.
*/
void wlr_input_device_destroy(struct wlr_input_device *dev);
#endif

View file

@ -13,6 +13,7 @@
#include <stdint.h>
#include <wayland-server-core.h>
#include <wayland-server-protocol.h>
#include <wlr/types/wlr_input_device.h>
#include <xkbcommon/xkbcommon.h>
#define WLR_LED_COUNT 3
@ -48,6 +49,8 @@ struct wlr_keyboard_modifiers {
};
struct wlr_keyboard {
struct wlr_input_device base;
const struct wlr_keyboard_impl *impl;
struct wlr_keyboard_group *group;

View file

@ -11,11 +11,9 @@
#include <wayland-server-core.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_input_device.h>
struct wlr_keyboard_group {
struct wlr_keyboard keyboard;
struct wlr_input_device *input_device;
struct wl_list devices; // keyboard_group_device::link
struct wl_list keys; // keyboard_group_key::link

View file

@ -12,7 +12,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_compositor.h>
#include "wlr-layer-shell-unstable-v1-protocol.h"
/**
@ -58,7 +58,7 @@ struct wlr_layer_surface_v1_state {
uint32_t anchor;
int32_t exclusive_zone;
struct {
uint32_t top, right, bottom, left;
int32_t top, right, bottom, left;
} margin;
enum zwlr_layer_surface_v1_keyboard_interactivity keyboard_interactive;
uint32_t desired_width, desired_height;

View file

@ -10,16 +10,21 @@
#define WLR_TYPES_WLR_LINUX_DMABUF_H
#include <stdint.h>
#include <sys/stat.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_buffer.h>
#include <wlr/render/dmabuf.h>
struct wlr_surface;
struct wlr_dmabuf_v1_buffer {
struct wlr_buffer base;
struct wl_resource *resource; // can be NULL if the client destroyed it
struct wlr_dmabuf_attributes attributes;
// private state
struct wl_listener release;
};
@ -36,11 +41,16 @@ bool wlr_dmabuf_v1_resource_is_buffer(struct wl_resource *buffer_resource);
struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_from_buffer_resource(
struct wl_resource *buffer_resource);
struct wlr_linux_buffer_params_v1 {
struct wl_resource *resource;
struct wlr_linux_dmabuf_v1 *linux_dmabuf;
struct wlr_dmabuf_attributes attributes;
bool has_modifier;
struct wlr_linux_dmabuf_feedback_v1 {
dev_t main_device;
size_t tranches_len;
const struct wlr_linux_dmabuf_feedback_v1_tranche *tranches;
};
struct wlr_linux_dmabuf_feedback_v1_tranche {
dev_t target_device;
uint32_t flags; // bitfield of enum zwp_linux_dmabuf_feedback_v1_tranche_flags
const struct wlr_drm_format_set *formats;
};
/* the protocol interface */
@ -52,6 +62,11 @@ struct wlr_linux_dmabuf_v1 {
struct wl_signal destroy;
} events;
// private state
struct wlr_linux_dmabuf_feedback_v1_compiled *default_feedback;
struct wl_list surfaces; // wlr_linux_dmabuf_v1_surface.link
struct wl_listener display_destroy;
struct wl_listener renderer_destroy;
};
@ -62,4 +77,13 @@ struct wlr_linux_dmabuf_v1 {
struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(struct wl_display *display,
struct wlr_renderer *renderer);
/**
* Set a surface's DMA-BUF feedback.
*
* Passing a NULL feedback resets it to the default feedback.
*/
bool wlr_linux_dmabuf_v1_set_surface_feedback(
struct wlr_linux_dmabuf_v1 *linux_dmabuf, struct wlr_surface *surface,
const struct wlr_linux_dmabuf_feedback_v1 *feedback);
#endif

View file

@ -73,7 +73,8 @@ enum wlr_output_state_field {
WLR_OUTPUT_STATE_TRANSFORM = 1 << 5,
WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED = 1 << 6,
WLR_OUTPUT_STATE_GAMMA_LUT = 1 << 7,
WLR_OUTPUT_STATE_SOURCE_BOX = 1 << 8,
WLR_OUTPUT_STATE_RENDER_FORMAT = 1 << 8,
WLR_OUTPUT_STATE_SOURCE_BOX = 1 << 9,
};
enum wlr_output_state_mode_type {
@ -94,6 +95,7 @@ struct wlr_output_state {
/* allow partial buffer scanout for tiling displays
* only valid if WLR_OUTPUT_STATE_SOURCE_BOX */
struct wlr_box source_box; // source box for respective output
uint32_t render_format;
// only valid if WLR_OUTPUT_STATE_BUFFER
struct wlr_buffer *buffer;
@ -132,7 +134,7 @@ struct wlr_output {
struct wl_global *global;
struct wl_list resources;
char name[24];
char *name;
char *description; // may be NULL
char make[56];
char model[16];
@ -151,6 +153,7 @@ struct wlr_output {
enum wl_output_subpixel subpixel;
enum wl_output_transform transform;
enum wlr_output_adaptive_sync_status adaptive_sync_status;
uint32_t render_format;
bool needs_frame;
// damage for cursors and fullscreen surface, in output-local coordinates
@ -199,8 +202,10 @@ struct wlr_output {
struct wlr_buffer *cursor_front_buffer;
int software_cursor_locks; // number of locks forcing software cursors
struct wlr_allocator *allocator;
struct wlr_renderer *renderer;
struct wlr_swapchain *swapchain;
struct wlr_buffer *back_buffer, *front_buffer;
struct wlr_buffer *back_buffer;
struct wl_listener display_destroy;
@ -223,6 +228,7 @@ struct wlr_output_event_commit {
struct wlr_output *output;
uint32_t committed; // bitmask of enum wlr_output_state_field
struct timespec *when;
struct wlr_buffer *buffer; // NULL if no buffer is committed
};
enum wlr_output_present_flag {
@ -273,6 +279,18 @@ struct wlr_surface;
void wlr_output_enable(struct wlr_output *output, bool enable);
void wlr_output_create_global(struct wlr_output *output);
void wlr_output_destroy_global(struct wlr_output *output);
/**
* Initialize the output's rendering subsystem with the provided allocator and
* renderer. Can only be called once.
*
* Call this function prior to any call to wlr_output_attach_render,
* wlr_output_commit or wlr_output_cursor_create.
*
* The buffer capabilities of the provided must match the capabilities of the
* output's backend. Returns false otherwise.
*/
bool wlr_output_init_render(struct wlr_output *output,
struct wlr_allocator *allocator, struct wlr_renderer *renderer);
/**
* Returns the preferred mode for this output. If the output doesn't support
* modes, returns NULL.
@ -311,6 +329,22 @@ void wlr_output_set_transform(struct wlr_output *output,
* Adaptive sync is double-buffered state, see `wlr_output_commit`.
*/
void wlr_output_enable_adaptive_sync(struct wlr_output *output, bool enabled);
/**
* Set the output buffer render format. Default value: DRM_FORMAT_XRGB8888
*
* While high bit depth render formats are necessary for a monitor to receive
* useful high bit data, they do not guarantee it; a DRM_FORMAT_XBGR2101010
* buffer will only lead to sending 10-bpc image data to the monitor if
* hardware and software permit this.
*
* This only affects the format of the output buffer used when rendering,
* as with `wlr_output_attach_render`. It has no impact on the cursor buffer
* format, or on the formats supported for direct scan-out (see also
* `wlr_output_attach_buffer`).
*
* This format is double-buffered state, see `wlr_output_commit`.
*/
void wlr_output_set_render_format(struct wlr_output *output, uint32_t format);
/**
* Sets a scale for the output.
*
@ -319,6 +353,17 @@ void wlr_output_enable_adaptive_sync(struct wlr_output *output, bool enabled);
void wlr_output_set_scale(struct wlr_output *output, float scale);
void wlr_output_set_subpixel(struct wlr_output *output,
enum wl_output_subpixel subpixel);
/**
* Set the output name.
*
* Output names are subject to the following rules:
*
* - Each output name must be unique.
* - The name cannot change after the output has been advertised to clients.
*
* For more details, see the protocol documentation for wl_output.name.
*/
void wlr_output_set_name(struct wlr_output *output, const char *name);
void wlr_output_set_description(struct wlr_output *output, const char *desc);
/**
* Schedule a done event.
@ -452,6 +497,16 @@ void wlr_output_lock_software_cursors(struct wlr_output *output, bool lock);
*/
void wlr_output_render_software_cursors(struct wlr_output *output,
pixman_region32_t *damage);
/**
* Get the set of DRM formats suitable for the primary buffer, assuming a
* buffer with the specified capabilities.
*
* NULL is returned if the backend doesn't have any format constraint, ie. all
* formats are supported. An empty set is returned if the backend doesn't
* support any format.
*/
const struct wlr_drm_format_set *wlr_output_get_primary_formats(
struct wlr_output *output, uint32_t buffer_caps);
struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output);

View file

@ -15,7 +15,6 @@
#include <wlr/util/addon.h>
struct wlr_box;
struct wlr_output_layout_state;
/**
* Helper to arrange outputs in a 2D coordinate space. The output effective
@ -27,7 +26,6 @@ struct wlr_output_layout_state;
*/
struct wlr_output_layout {
struct wl_list outputs;
struct wlr_output_layout_state *state;
struct {
struct wl_signal add;
@ -107,10 +105,10 @@ void wlr_output_layout_closest_point(struct wlr_output_layout *layout,
/**
* Get the box of the layout for the given reference output in layout
* coordinates. If `reference` is NULL, the box will be for the extents of the
* entire layout.
* entire layout. If the output isn't in the layout, the box will be empty.
*/
struct wlr_box *wlr_output_layout_get_box(
struct wlr_output_layout *layout, struct wlr_output *reference);
void wlr_output_layout_get_box(struct wlr_output_layout *layout,
struct wlr_output *reference, struct wlr_box *dest_box);
/**
* Add an auto configured output to the layout. This will place the output in a

View file

@ -17,6 +17,8 @@
struct wlr_pointer_impl;
struct wlr_pointer {
struct wlr_input_device base;
const struct wlr_pointer_impl *impl;
struct {

View file

@ -11,7 +11,8 @@
#include <wayland-server-core.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_surface.h>
struct wlr_surface;
struct wlr_pointer_gestures_v1 {
struct wl_global *global;

View file

@ -21,10 +21,12 @@
#include <pixman.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_compositor.h>
struct wlr_output;
struct wlr_output_layout;
struct wlr_xdg_surface;
struct wlr_layer_surface_v1;
enum wlr_scene_node_type {
WLR_SCENE_NODE_ROOT,
@ -61,6 +63,15 @@ struct wlr_scene {
struct wlr_scene_node node;
struct wl_list outputs; // wlr_scene_output.link
// private state
// May be NULL
struct wlr_presentation *presentation;
struct wl_listener presentation_destroy;
// List of buffers which need to be imported as textures
struct wl_list pending_buffers; // wlr_scene_buffer.pending_link
};
/** A sub-tree in the scene-graph. */
@ -73,8 +84,18 @@ struct wlr_scene_surface {
struct wlr_scene_node node;
struct wlr_surface *surface;
/**
* The output that the largest area of this surface is displayed on.
* This may be NULL if the surface is not currently displayed on any
* outputs. This is the output that should be used for frame callbacks,
* presentation feedback, etc.
*/
struct wlr_output *primary_output;
// private state
int prev_width, prev_height;
struct wl_listener surface_destroy;
struct wl_listener surface_commit;
};
@ -97,6 +118,7 @@ struct wlr_scene_buffer {
struct wlr_fbox src_box;
int dst_width, dst_height;
enum wl_output_transform transform;
struct wl_list pending_link; // wlr_scene.pending_buffers
};
/** A viewport for an output in the scene-graph */
@ -115,6 +137,19 @@ struct wlr_scene_output {
bool prev_scanout;
};
/** A layer shell scene helper */
struct wlr_scene_layer_surface_v1 {
struct wlr_scene_node *node;
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;
};
typedef void (*wlr_scene_node_iterator_func_t)(struct wlr_scene_node *node,
int sx, int sy, void *data);
@ -190,6 +225,14 @@ struct wlr_scene *wlr_scene_create(void);
*/
void wlr_scene_render_output(struct wlr_scene *scene, struct wlr_output *output,
int lx, int ly, pixman_region32_t *damage);
/**
* Handle presentation feedback for all surfaces in the scene, assuming that
* scene outputs and the scene rendering functions are used.
*
* Asserts that a wlr_presentation hasn't already been set for the scene.
*/
void wlr_scene_set_presentation(struct wlr_scene *scene,
struct wlr_presentation *presentation);
/**
* Add a node displaying nothing but its children.
@ -200,6 +243,10 @@ struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_node *parent);
* Add a node displaying a single surface to the scene-graph.
*
* The child sub-surfaces are ignored.
*
* wlr_surface_send_enter()/wlr_surface_send_leave() will be called
* automatically based on the position of the surface and outputs in
* the scene.
*/
struct wlr_scene_surface *wlr_scene_surface_create(struct wlr_scene_node *parent,
struct wlr_surface *surface);
@ -273,7 +320,13 @@ void wlr_scene_output_set_position(struct wlr_scene_output *scene_output,
* Render and commit an output.
*/
bool wlr_scene_output_commit(struct wlr_scene_output *scene_output);
/**
* Call wlr_surface_send_frame_done() on all surfaces in the scene rendered by
* wlr_scene_output_commit() for which wlr_scene_surface->primary_output
* matches the given scene_output.
*/
void wlr_scene_output_send_frame_done(struct wlr_scene_output *scene_output,
struct timespec *now);
/**
* Call `iterator` on each surface in the scene-graph visible on the output,
* with the surface's position in layout coordinates. The function is called
@ -281,6 +334,13 @@ bool wlr_scene_output_commit(struct wlr_scene_output *scene_output);
*/
void wlr_scene_output_for_each_surface(struct wlr_scene_output *scene_output,
wlr_surface_iterator_func_t iterator, void *user_data);
/**
* Get a scene-graph output from a wlr_output.
*
* If the output hasn't been added to the scene-graph, returns NULL.
*/
struct wlr_scene_output *wlr_scene_get_scene_output(struct wlr_scene *scene,
struct wlr_output *output);
/**
* Attach an output layout to a scene.
@ -298,4 +358,38 @@ bool wlr_scene_attach_output_layout(struct wlr_scene *scene,
struct wlr_scene_node *wlr_scene_subsurface_tree_create(
struct wlr_scene_node *parent, struct wlr_surface *surface);
/**
* Add a node displaying an xdg_surface and all of its sub-surfaces to the
* scene-graph.
*
* The origin of the returned scene-graph node will match the top-left corner
* of the xdg_surface window geometry.
*/
struct wlr_scene_node *wlr_scene_xdg_surface_create(
struct wlr_scene_node *parent, struct wlr_xdg_surface *xdg_surface);
/**
* Add a node displaying a layer_surface_v1 and all of its sub-surfaces to the
* scene-graph.
*
* The origin of the returned scene-graph node will match the top-left corner
* of the layer surface.
*/
struct wlr_scene_layer_surface_v1 *wlr_scene_layer_surface_v1_create(
struct wlr_scene_node *parent, struct wlr_layer_surface_v1 *layer_surface);
/**
* Configure a layer_surface_v1, position its scene node in accordance to its
* current state, and update the remaining usable area.
*
* full_area represents the entire area that may be used by the layer surface
* if its exclusive_zone is -1, and is usually the output dimensions.
* usable_area represents what remains of full_area that can be used if
* exclusive_zone is >= 0. usable_area is updated if the surface has a positive
* exclusive_zone, so that it can be used for the next layer surface.
*/
void wlr_scene_layer_surface_v1_configure(
struct wlr_scene_layer_surface_v1 *scene_layer_surface,
const struct wlr_box *full_area, struct wlr_box *usable_area);
#endif

View file

@ -14,7 +14,8 @@
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_surface.h>
struct wlr_surface;
#define WLR_SERIAL_RINGSET_SIZE 128

View file

@ -0,0 +1,98 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_TYPES_WLR_SESSION_LOCK_H
#define WLR_TYPES_WLR_SESSION_LOCK_H
#include <stdbool.h>
#include <stdint.h>
#include <wayland-server-core.h>
struct wlr_session_lock_manager_v1 {
struct wl_global *global;
struct {
struct wl_signal new_lock; // struct wlr_session_lock_v1 *
struct wl_signal destroy;
} events;
void *data;
// private state
struct wl_listener display_destroy;
};
struct wlr_session_lock_v1 {
struct wl_resource *resource;
struct wl_list surfaces; // struct wlr_session_lock_surface_v1::link
struct {
struct wl_signal new_surface; // struct wlr_session_lock_surface_v1 *
struct wl_signal unlock;
struct wl_signal destroy;
} events;
void *data;
};
struct wlr_session_lock_surface_v1_state {
uint32_t width, height;
uint32_t configure_serial;
};
struct wlr_session_lock_surface_v1_configure {
struct wl_list link; // wlr_session_lock_surface_v1::configure_list
uint32_t serial;
uint32_t width, height;
};
struct wlr_session_lock_surface_v1 {
struct wl_resource *resource;
struct wl_list link; // wlr_session_lock_v1::surfaces
struct wlr_output *output;
struct wlr_surface *surface;
bool configured, mapped;
struct wl_list configure_list; // wlr_session_lock_surface_v1_configure::link
struct wlr_session_lock_surface_v1_state current;
struct wlr_session_lock_surface_v1_state pending;
struct {
struct wl_signal map;
struct wl_signal destroy;
} events;
void *data;
// private state
struct wl_listener output_destroy;
struct wl_listener surface_destroy;
};
struct wlr_session_lock_manager_v1 *wlr_session_lock_manager_v1_create(
struct wl_display *display);
void wlr_session_lock_v1_send_locked(struct wlr_session_lock_v1 *lock);
void wlr_session_lock_v1_destroy(struct wlr_session_lock_v1 *lock);
uint32_t wlr_session_lock_surface_v1_configure(
struct wlr_session_lock_surface_v1 *lock_surface,
uint32_t width, uint32_t height);
bool wlr_surface_is_session_lock_surface_v1(struct wlr_surface *surface);
struct wlr_session_lock_surface_v1 *wlr_session_lock_surface_v1_from_wlr_surface(
struct wlr_surface *surface);
#endif

View file

@ -0,0 +1,77 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_TYPES_WLR_SUBCOMPOSITOR_H
#define WLR_TYPES_WLR_SUBCOMPOSITOR_H
#include <stdbool.h>
#include <stdint.h>
#include <wayland-server-core.h>
struct wlr_surface;
/**
* The sub-surface state describing the sub-surface's relationship with its
* parent. Contrary to other states, this one is not applied on surface commit.
* Instead, it's applied on parent surface commit.
*/
struct wlr_subsurface_parent_state {
int32_t x, y;
struct wl_list link;
};
struct wlr_subsurface {
struct wl_resource *resource;
struct wlr_surface *surface;
struct wlr_surface *parent;
struct wlr_subsurface_parent_state current, pending;
uint32_t cached_seq;
bool has_cache;
bool synchronized;
bool reordered;
bool mapped;
bool added;
struct wl_listener surface_destroy;
struct wl_listener surface_client_commit;
struct wl_listener parent_destroy;
struct {
struct wl_signal destroy;
struct wl_signal map;
struct wl_signal unmap;
} events;
void *data;
};
struct wlr_subcompositor {
struct wl_global *global;
struct wl_listener display_destroy;
struct {
struct wl_signal destroy;
} events;
};
bool wlr_surface_is_subsurface(struct wlr_surface *surface);
/**
* Get a subsurface from a surface. Can return NULL if the subsurface has been
* destroyed.
*/
struct wlr_subsurface *wlr_subsurface_from_wlr_surface(
struct wlr_surface *surface);
struct wlr_subcompositor *wlr_subcompositor_create(struct wl_display *display);
#endif

View file

@ -1,313 +1,4 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#warning "wlr/types/wlr_surface.h has been deprecated and will be removed in the future. Use wlr/types/wlr_compositor.h and wlr/types/wlr_subcompositor.h."
#ifndef WLR_TYPES_WLR_SURFACE_H
#define WLR_TYPES_WLR_SURFACE_H
#include <pixman.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_output.h>
#include <wlr/util/addon.h>
#include <wlr/util/box.h>
enum wlr_surface_state_field {
WLR_SURFACE_STATE_BUFFER = 1 << 0,
WLR_SURFACE_STATE_SURFACE_DAMAGE = 1 << 1,
WLR_SURFACE_STATE_BUFFER_DAMAGE = 1 << 2,
WLR_SURFACE_STATE_OPAQUE_REGION = 1 << 3,
WLR_SURFACE_STATE_INPUT_REGION = 1 << 4,
WLR_SURFACE_STATE_TRANSFORM = 1 << 5,
WLR_SURFACE_STATE_SCALE = 1 << 6,
WLR_SURFACE_STATE_FRAME_CALLBACK_LIST = 1 << 7,
WLR_SURFACE_STATE_VIEWPORT = 1 << 8,
};
struct wlr_surface_state {
uint32_t committed; // enum wlr_surface_state_field
// Sequence number of the surface state. Incremented on each commit, may
// overflow.
uint32_t seq;
struct wlr_buffer *buffer;
int32_t dx, dy; // relative to previous position
pixman_region32_t surface_damage, buffer_damage; // clipped to bounds
pixman_region32_t opaque, input;
enum wl_output_transform transform;
int32_t scale;
struct wl_list frame_callback_list; // wl_resource
int width, height; // in surface-local coordinates
int buffer_width, buffer_height;
struct wl_list subsurfaces_below;
struct wl_list subsurfaces_above;
/**
* The viewport is applied after the surface transform and scale.
*
* If has_src is true, the surface content is cropped to the provided
* rectangle. If has_dst is true, the surface content is scaled to the
* provided rectangle.
*/
struct {
bool has_src, has_dst;
// In coordinates after scale/transform are applied, but before the
// destination rectangle is applied
struct wlr_fbox src;
int dst_width, dst_height; // in surface-local coordinates
} viewport;
// Number of locks that prevent this surface state from being committed.
size_t cached_state_locks;
struct wl_list cached_state_link; // wlr_surface.cached
};
struct wlr_surface_role {
const char *name;
void (*commit)(struct wlr_surface *surface);
void (*precommit)(struct wlr_surface *surface);
};
struct wlr_surface_output {
struct wlr_surface *surface;
struct wlr_output *output;
struct wl_list link; // wlr_surface::current_outputs
struct wl_listener bind;
struct wl_listener destroy;
};
struct wlr_surface {
struct wl_resource *resource;
struct wlr_renderer *renderer;
/**
* The surface's buffer, if any. A surface has an attached buffer when it
* commits with a non-null buffer in its pending state. A surface will not
* have a buffer if it has never committed one, has committed a null buffer,
* or something went wrong with uploading the buffer.
*/
struct wlr_client_buffer *buffer;
/**
* The buffer position, in surface-local units.
*/
int sx, sy;
/**
* The last commit's buffer damage, in buffer-local coordinates. This
* contains both the damage accumulated by the client via
* `wlr_surface_state.surface_damage` and `wlr_surface_state.buffer_damage`.
* If the buffer has been resized, the whole buffer is damaged.
*
* This region needs to be scaled and transformed into output coordinates,
* just like the buffer's texture. In addition, if the buffer has shrunk the
* old size needs to be damaged and if the buffer has moved the old and new
* positions need to be damaged.
*/
pixman_region32_t buffer_damage;
/**
* The current opaque region, in surface-local coordinates. It is clipped to
* the surface bounds. If the surface's buffer is using a fully opaque
* format, this is set to the whole surface.
*/
pixman_region32_t opaque_region;
/**
* The current input region, in surface-local coordinates. It is clipped to
* the surface bounds.
*/
pixman_region32_t input_region;
/**
* `current` contains the current, committed surface state. `pending`
* accumulates state changes from the client between commits and shouldn't
* be accessed by the compositor directly.
*/
struct wlr_surface_state current, pending;
struct wl_list cached; // wlr_surface_state.cached_link
const struct wlr_surface_role *role; // the lifetime-bound role or NULL
void *role_data; // role-specific data
struct {
struct wl_signal commit;
struct wl_signal new_subsurface;
struct wl_signal destroy;
} events;
struct wl_list current_outputs; // wlr_surface_output::link
struct wlr_addon_set addons;
void *data;
// private state
struct wl_listener renderer_destroy;
struct {
int32_t scale;
enum wl_output_transform transform;
int width, height;
int buffer_width, buffer_height;
} previous;
};
/**
* The sub-surface state describing the sub-surface's relationship with its
* parent. Contrary to other states, this one is not applied on surface commit.
* Instead, it's applied on parent surface commit.
*/
struct wlr_subsurface_parent_state {
int32_t x, y;
struct wl_list link;
};
struct wlr_subsurface {
struct wl_resource *resource;
struct wlr_surface *surface;
struct wlr_surface *parent;
struct wlr_subsurface_parent_state current, pending;
uint32_t cached_seq;
bool has_cache;
bool synchronized;
bool reordered;
bool mapped;
struct wl_listener surface_destroy;
struct wl_listener parent_destroy;
struct {
struct wl_signal destroy;
struct wl_signal map;
struct wl_signal unmap;
} events;
void *data;
};
typedef void (*wlr_surface_iterator_func_t)(struct wlr_surface *surface,
int sx, int sy, void *data);
/**
* Set the lifetime role for this surface. Returns 0 on success or -1 if the
* role cannot be set.
*/
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);
/**
* Whether or not this surface currently has an attached buffer. A surface has
* an attached buffer when it commits with a non-null buffer in its pending
* state. A surface will not have a buffer if it has never committed one, has
* committed a null buffer, or something went wrong with uploading the buffer.
*/
bool wlr_surface_has_buffer(struct wlr_surface *surface);
/**
* Get the texture of the buffer currently attached to this surface. Returns
* NULL if no buffer is currently attached or if something went wrong with
* uploading the buffer.
*/
struct wlr_texture *wlr_surface_get_texture(struct wlr_surface *surface);
/**
* Get the root of the subsurface tree for this surface. Can return NULL if
* a surface in the tree has been destroyed.
*/
struct wlr_surface *wlr_surface_get_root_surface(struct wlr_surface *surface);
/**
* Check if the surface accepts input events at the given surface-local
* coordinates. Does not check the surface's subsurfaces.
*/
bool wlr_surface_point_accepts_input(struct wlr_surface *surface,
double sx, double sy);
/**
* Find a surface in this surface's tree that accepts input events and has all
* parents mapped (except this surface, which can be unmapped) at the given
* surface-local coordinates. Returns the surface and coordinates in the leaf
* surface coordinate system or NULL if no surface is found at that location.
*/
struct wlr_surface *wlr_surface_surface_at(struct wlr_surface *surface,
double sx, double sy, double *sub_x, double *sub_y);
void wlr_surface_send_enter(struct wlr_surface *surface,
struct wlr_output *output);
void wlr_surface_send_leave(struct wlr_surface *surface,
struct wlr_output *output);
void wlr_surface_send_frame_done(struct wlr_surface *surface,
const struct timespec *when);
/**
* Get the bounding box that contains the surface and all subsurfaces in
* surface coordinates.
* X and y may be negative, if there are subsurfaces with negative position.
*/
void wlr_surface_get_extends(struct wlr_surface *surface, struct wlr_box *box);
/**
* Get the wlr_surface corresponding to a wl_surface resource. This asserts
* that the resource is a valid wl_surface resource created by wlroots and
* will never return NULL.
*/
struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource);
/**
* Call `iterator` on each mapped surface in the surface tree (whether or not
* this surface is mapped), with the surface's position relative to the root
* surface. The function is called from root to leaves (in rendering order).
*/
void wlr_surface_for_each_surface(struct wlr_surface *surface,
wlr_surface_iterator_func_t iterator, void *user_data);
/**
* Get the effective damage to the surface in terms of surface local
* coordinates. This includes damage induced by resizing and moving the
* surface. The damage is not expected to be bounded by the surface itself.
*/
void wlr_surface_get_effective_damage(struct wlr_surface *surface,
pixman_region32_t *damage);
/**
* Get the source rectangle describing the region of the buffer that needs to
* be sampled to render this surface's current state. The box is in
* buffer-local coordinates.
*
* If the viewport's source rectangle is unset, the position is zero and the
* size is the buffer's.
*/
void wlr_surface_get_buffer_source_box(struct wlr_surface *surface,
struct wlr_fbox *box);
/**
* Acquire a lock for the pending surface state.
*
* The state won't be committed before the caller releases the lock. Instead,
* the state becomes cached. The caller needs to use wlr_surface_unlock_cached
* to release the lock.
*
* Returns a surface commit sequence number for the cached state.
*/
uint32_t wlr_surface_lock_pending(struct wlr_surface *surface);
/**
* Release a lock for a cached state.
*
* Callers should not assume that the cached state will immediately be
* committed. Another caller may still have an active lock.
*/
void wlr_surface_unlock_cached(struct wlr_surface *surface, uint32_t seq);
#endif
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_subcompositor.h>

View file

@ -16,7 +16,9 @@
struct wlr_switch_impl;
struct wlr_switch {
struct wlr_switch_impl *impl;
struct wlr_input_device base;
const struct wlr_switch_impl *impl;
struct {
struct wl_signal toggle;

View file

@ -22,7 +22,9 @@
struct wlr_tablet_pad_impl;
struct wlr_tablet_pad {
struct wlr_tablet_pad_impl *impl;
struct wlr_input_device base;
const struct wlr_tablet_pad_impl *impl;
struct {
struct wl_signal button;

View file

@ -60,6 +60,8 @@ struct wlr_tablet_tool {
struct wlr_tablet_impl;
struct wlr_tablet {
struct wlr_input_device base;
const struct wlr_tablet_impl *impl;
struct {

View file

@ -11,9 +11,10 @@
#include <wayland-server-core.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/util/box.h>
struct wlr_surface;
enum wlr_text_input_v3_features {
WLR_TEXT_INPUT_V3_FEATURE_SURROUNDING_TEXT = 1 << 0,
WLR_TEXT_INPUT_V3_FEATURE_CONTENT_TYPE = 1 << 1,

View file

@ -10,11 +10,14 @@
#define WLR_TYPES_WLR_TOUCH_H
#include <stdint.h>
#include <wlr/types/wlr_input_device.h>
#include <wayland-server-core.h>
struct wlr_touch_impl;
struct wlr_touch {
struct wlr_input_device base;
const struct wlr_touch_impl *impl;
struct {

View file

@ -10,8 +10,7 @@
#define WLR_TYPES_WLR_VIRTUAL_KEYBOARD_V1_H
#include <wayland-server-core.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/types/wlr_keyboard.h>
struct wlr_virtual_keyboard_manager_v1 {
struct wl_global *global;
@ -26,7 +25,7 @@ struct wlr_virtual_keyboard_manager_v1 {
};
struct wlr_virtual_keyboard_v1 {
struct wlr_input_device input_device;
struct wlr_keyboard keyboard;
struct wl_resource *resource;
struct wlr_seat *seat;
bool has_keymap;

View file

@ -11,7 +11,6 @@
#include <wayland-server-core.h>
#include <wayland-server-protocol.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/interfaces/wlr_output.h>
@ -28,7 +27,7 @@ struct wlr_virtual_pointer_manager_v1 {
};
struct wlr_virtual_pointer_v1 {
struct wlr_input_device input_device;
struct wlr_pointer pointer;
struct wl_resource *resource;
/* Vertical and horizontal */
struct wlr_event_pointer_axis axis_event[2];

View file

@ -81,4 +81,8 @@ struct wlr_xdg_activation_token_v1 *wlr_xdg_activation_v1_find_token(
const char *wlr_xdg_activation_token_v1_get_name(
struct wlr_xdg_activation_token_v1 *token);
// Add a token to the pool of known tokens
struct wlr_xdg_activation_token_v1 *wlr_xdg_activation_v1_add_token(
struct wlr_xdg_activation_v1 *activation, const char *token_str);
#endif

View file

@ -10,6 +10,7 @@
#define WLR_TYPES_WLR_XDG_SHELL_H
#include <wayland-server-core.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/util/box.h>
#include "xdg-shell-protocol.h"
@ -48,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;
@ -63,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;
@ -76,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
};
@ -124,7 +130,7 @@ struct wlr_xdg_toplevel {
struct wlr_xdg_surface *base;
bool added;
struct wlr_xdg_surface *parent;
struct wlr_xdg_toplevel *parent;
struct wl_listener parent_unmap;
struct wlr_xdg_toplevel_state current, pending;
@ -133,8 +139,8 @@ struct wlr_xdg_toplevel {
struct wlr_xdg_toplevel_configure scheduled;
// Properties that the client has requested. Intended to be checked
// by the compositor on surface map and handled accordingly
// (e.g. a client might want to start already in a fullscreen state).
// by the compositor on surface map and state change requests (such as
// xdg_toplevel::set_fullscreen) and handled accordingly.
struct wlr_xdg_toplevel_requested requested;
char *title;
@ -230,26 +236,20 @@ struct wlr_xdg_surface {
};
struct wlr_xdg_toplevel_move_event {
struct wlr_xdg_surface *surface;
struct wlr_xdg_toplevel *toplevel;
struct wlr_seat_client *seat;
uint32_t serial;
};
struct wlr_xdg_toplevel_resize_event {
struct wlr_xdg_surface *surface;
struct wlr_xdg_toplevel *toplevel;
struct wlr_seat_client *seat;
uint32_t serial;
uint32_t edges;
};
struct wlr_xdg_toplevel_set_fullscreen_event {
struct wlr_xdg_surface *surface;
bool fullscreen;
struct wlr_output *output;
};
struct wlr_xdg_toplevel_show_window_menu_event {
struct wlr_xdg_surface *surface;
struct wlr_xdg_toplevel *toplevel;
struct wlr_seat_client *seat;
uint32_t serial;
uint32_t x, y;
@ -257,16 +257,35 @@ struct wlr_xdg_toplevel_show_window_menu_event {
struct wlr_xdg_shell *wlr_xdg_shell_create(struct wl_display *display);
/** Returns the wlr_xdg_surface from an xdg_surface resource.
/** Get the corresponding wlr_xdg_surface from a resource.
*
* Aborts if the resource doesn't have the correct type. Returns NULL if the
* resource is inert.
*/
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);
struct wlr_xdg_surface *wlr_xdg_surface_from_toplevel_resource(
/** Get the corresponding wlr_xdg_toplevel from a resource.
*
* Aborts if the resource doesn't have the correct type. Returns NULL if the
* resource is inert.
*/
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);
/**
@ -279,78 +298,79 @@ void wlr_xdg_surface_ping(struct wlr_xdg_surface *surface);
* Request that this toplevel surface be the given size. Returns the associated
* configure serial.
*/
uint32_t wlr_xdg_toplevel_set_size(struct wlr_xdg_surface *surface,
uint32_t wlr_xdg_toplevel_set_size(struct wlr_xdg_toplevel *toplevel,
uint32_t width, uint32_t height);
/**
* Request that this toplevel surface show itself in an activated or deactivated
* Request that this toplevel show itself in an activated or deactivated
* state. Returns the associated configure serial.
*/
uint32_t wlr_xdg_toplevel_set_activated(struct wlr_xdg_surface *surface,
uint32_t wlr_xdg_toplevel_set_activated(struct wlr_xdg_toplevel *toplevel,
bool activated);
/**
* Request that this toplevel surface consider itself maximized or not
* Request that this toplevel consider itself maximized or not
* maximized. Returns the associated configure serial.
*/
uint32_t wlr_xdg_toplevel_set_maximized(struct wlr_xdg_surface *surface,
uint32_t wlr_xdg_toplevel_set_maximized(struct wlr_xdg_toplevel *toplevel,
bool maximized);
/**
* Request that this toplevel surface consider itself fullscreen or not
* Request that this toplevel consider itself fullscreen or not
* fullscreen. Returns the associated configure serial.
*/
uint32_t wlr_xdg_toplevel_set_fullscreen(struct wlr_xdg_surface *surface,
uint32_t wlr_xdg_toplevel_set_fullscreen(struct wlr_xdg_toplevel *toplevel,
bool fullscreen);
/**
* Request that this toplevel surface consider itself to be resizing or not
* Request that this toplevel consider itself to be resizing or not
* resizing. Returns the associated configure serial.
*/
uint32_t wlr_xdg_toplevel_set_resizing(struct wlr_xdg_surface *surface,
uint32_t wlr_xdg_toplevel_set_resizing(struct wlr_xdg_toplevel *toplevel,
bool resizing);
/**
* Request that this toplevel surface consider itself in a tiled layout and some
* Request that this toplevel consider itself in a tiled layout and some
* edges are adjacent to another part of the tiling grid. `tiled_edges` is a
* bitfield of `enum wlr_edges`. Returns the associated configure serial.
*/
uint32_t wlr_xdg_toplevel_set_tiled(struct wlr_xdg_surface *surface,
uint32_t wlr_xdg_toplevel_set_tiled(struct wlr_xdg_toplevel *toplevel,
uint32_t tiled_edges);
/**
* Request that this xdg toplevel closes.
* Request that this toplevel closes.
*/
void wlr_xdg_toplevel_send_close(struct wlr_xdg_surface *surface);
void wlr_xdg_toplevel_send_close(struct wlr_xdg_toplevel *toplevel);
/**
* Sets the parent of this toplevel. Parent can be NULL.
*/
void wlr_xdg_toplevel_set_parent(struct wlr_xdg_surface *surface,
struct wlr_xdg_surface *parent);
void wlr_xdg_toplevel_set_parent(struct wlr_xdg_toplevel *toplevel,
struct wlr_xdg_toplevel *parent);
/**
* Request that this xdg popup closes.
* Request that this 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.
*/
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.
*/
struct wlr_box wlr_xdg_positioner_get_geometry(
struct wlr_xdg_positioner *positioner);
/**
* Get the anchor point for this popup in the toplevel parent's coordinate system.
* Get the geometry based on positioner rules.
*/
void wlr_xdg_popup_get_anchor_point(struct wlr_xdg_popup *popup,
int *toplevel_sx, int *toplevel_sy);
void wlr_xdg_positioner_rules_get_geometry(
const struct wlr_xdg_positioner_rules *rules, struct wlr_box *box);
/**
* Unconstrain the box from the constraint area according to positioner rules.
*/
void wlr_xdg_positioner_rules_unconstrain_box(
const struct wlr_xdg_positioner_rules *rules,
const struct wlr_box *constraint, struct wlr_box *box);
/**
* Convert the given coordinates in the popup coordinate system to the toplevel
@ -365,19 +385,7 @@ void wlr_xdg_popup_get_toplevel_coords(struct wlr_xdg_popup *popup,
* surface coordinate system.
*/
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.
*/
void wlr_positioner_invert_x(struct wlr_xdg_positioner *positioner);
/**
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.
*/
void wlr_positioner_invert_y(struct wlr_xdg_positioner *positioner);
const struct wlr_box *toplevel_space_box);
/**
* Find a surface within this xdg-surface tree at the given surface-local

View file

@ -54,9 +54,6 @@ typedef struct _XcursorImages {
char *name; /* name used to load images */
} XcursorImages;
XcursorImages *
XcursorLibraryLoadImages (const char *file, const char *theme, int size);
void
XcursorImagesDestroy (XcursorImages *images);