merge in upstream

This commit is contained in:
DerVerruckteFuchs 2020-12-22 05:57:05 -05:00
commit 3576eec3cf
154 changed files with 4860 additions and 4410 deletions

View file

@ -32,7 +32,6 @@ struct wlr_drm_plane {
/* Buffer currently displayed on screen */
struct wlr_drm_fb current_fb;
uint32_t drm_format; // ARGB2101010, XRGB2101010, ARGB8888, or XRGB8888
struct wlr_drm_format_set formats;
// Only used by cursor
@ -63,13 +62,6 @@ struct wlr_drm_crtc {
struct wlr_drm_plane *primary;
struct wlr_drm_plane *cursor;
/*
* We don't support overlay planes yet, but we keep track of them to
* give to DRM lease clients.
*/
size_t num_overlays;
uint32_t *overlays;
union wlr_drm_crtc_props props;
};
@ -82,6 +74,8 @@ struct wlr_drm_backend {
bool addfb2_modifiers;
int fd;
char *name;
struct wlr_device *dev;
size_t num_crtcs;
struct wlr_drm_crtc *crtcs;
@ -115,8 +109,10 @@ struct wlr_drm_mode {
};
struct wlr_drm_connector {
struct wlr_output output;
struct wlr_output output; // only valid if state != DISCONNECTED
struct wlr_drm_backend *backend;
char name[24];
enum wlr_drm_connector_state state;
struct wlr_output_mode *desired_mode;
bool desired_enabled;
@ -134,7 +130,7 @@ struct wlr_drm_connector {
struct wl_list link;
/*
* We've asked for a state change in the kernel, and yet to recieve a
* We've asked for a state change in the kernel, and yet to receive a
* notification for its completion. Currently, the kernel only has a
* queue length of 1, and no way to modify your submissions after
* they're sent.
@ -150,6 +146,7 @@ void finish_drm_resources(struct wlr_drm_backend *drm);
void restore_drm_outputs(struct wlr_drm_backend *drm);
void scan_drm_connectors(struct wlr_drm_backend *state);
int handle_drm_event(int fd, uint32_t mask, void *data);
void destroy_drm_connector(struct wlr_drm_connector *conn);
bool drm_connector_set_mode(struct wlr_drm_connector *conn,
struct wlr_output_mode *mode);
bool drm_connector_is_cursor_visible(struct wlr_drm_connector *conn);
@ -159,4 +156,9 @@ size_t drm_crtc_get_gamma_lut_size(struct wlr_drm_backend *drm,
struct wlr_drm_fb *plane_get_next_fb(struct wlr_drm_plane *plane);
#define wlr_drm_conn_log(conn, verb, fmt, ...) \
wlr_log(verb, "connector %s: " fmt, conn->name, ##__VA_ARGS__)
#define wlr_drm_conn_log_errno(conn, verb, fmt, ...) \
wlr_log_errno(verb, "connector %s: " fmt, conn->name, ##__VA_ARGS__)
#endif

View file

@ -28,8 +28,6 @@ union wlr_drm_connector_props {
union wlr_drm_crtc_props {
struct {
// Neither of these are guaranteed to exist
uint32_t rotation;
uint32_t scaling_mode;
uint32_t vrr_enabled;
uint32_t gamma_lut;
uint32_t gamma_lut_size;

View file

@ -17,9 +17,8 @@ struct wlr_drm_renderer {
struct gbm_device *gbm;
struct wlr_egl egl;
uint32_t gbm_format;
struct wlr_renderer *wlr_rend;
struct wlr_gbm_allocator *allocator;
};
struct wlr_drm_surface {
@ -28,27 +27,17 @@ struct wlr_drm_surface {
uint32_t width;
uint32_t height;
struct gbm_surface *gbm;
EGLSurface egl;
};
enum wlr_drm_fb_type {
WLR_DRM_FB_TYPE_NONE,
WLR_DRM_FB_TYPE_SURFACE,
WLR_DRM_FB_TYPE_WLR_BUFFER
struct wlr_swapchain *swapchain;
struct wlr_buffer *back_buffer;
};
struct wlr_drm_fb {
enum wlr_drm_fb_type type;
struct gbm_bo *bo;
struct wlr_buffer *wlr_buf;
struct wlr_drm_surface *mgpu_surf;
struct gbm_bo *mgpu_bo;
union {
struct wlr_drm_surface *surf;
struct wlr_buffer *wlr_buf;
};
struct wlr_buffer *mgpu_wlr_buf;
};
bool init_drm_renderer(struct wlr_drm_backend *drm,
@ -56,6 +45,7 @@ bool init_drm_renderer(struct wlr_drm_backend *drm,
void finish_drm_renderer(struct wlr_drm_renderer *renderer);
bool drm_surface_make_current(struct wlr_drm_surface *surf, int *buffer_age);
void drm_surface_unset_current(struct wlr_drm_surface *surf);
bool export_drm_bo(struct gbm_bo *bo, struct wlr_dmabuf_attributes *attribs);
void drm_fb_clear(struct wlr_drm_fb *fb);
@ -71,7 +61,7 @@ struct gbm_bo *drm_fb_acquire(struct wlr_drm_fb *fb, struct wlr_drm_backend *drm
bool drm_plane_init_surface(struct wlr_drm_plane *plane,
struct wlr_drm_backend *drm, int32_t width, uint32_t height,
uint32_t format, uint32_t flags, bool with_modifiers);
uint32_t format, bool force_linear, bool with_modifiers);
void drm_plane_finish_surface(struct wlr_drm_plane *plane);
#endif

View file

@ -3,7 +3,6 @@
#include <wlr/backend/headless.h>
#include <wlr/backend/interface.h>
#include <wlr/render/gles2.h>
#define HEADLESS_DEFAULT_REFRESH (60 * 1000) // 60 Hz
@ -12,6 +11,8 @@ struct wlr_headless_backend {
struct wlr_egl priv_egl; // may be uninitialized
struct wlr_egl *egl;
struct wlr_renderer *renderer;
struct wlr_allocator *allocator;
struct wlr_drm_format *format;
struct wl_display *display;
struct wl_list outputs;
size_t last_output_num;
@ -19,7 +20,6 @@ struct wlr_headless_backend {
struct wl_listener display_destroy;
struct wl_listener renderer_destroy;
bool started;
GLenum internal_format;
};
struct wlr_headless_output {
@ -28,7 +28,8 @@ struct wlr_headless_output {
struct wlr_headless_backend *backend;
struct wl_list link;
GLuint fbo, rbo;
struct wlr_swapchain *swapchain;
struct wlr_buffer *back_buffer, *front_buffer;
struct wl_event_source *frame_timer;
int frame_delay; // ms

View file

@ -0,0 +1,8 @@
#ifndef BACKEND_SESSION_SESSION_H
#define BACKEND_SESSION_SESSION_H
struct wlr_session;
void session_init(struct wlr_session *session);
#endif

View file

@ -4,14 +4,13 @@
#include <stdbool.h>
#include <wayland-client.h>
#include <wayland-egl.h>
#include <wayland-server-core.h>
#include <wayland-util.h>
#include <wlr/backend/wayland.h>
#include <wlr/render/egl.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/render/drm_format_set.h>
struct wlr_wl_backend {
@ -24,9 +23,13 @@ struct wlr_wl_backend {
struct wl_list outputs;
struct wlr_egl egl;
struct wlr_renderer *renderer;
struct wlr_drm_format *format;
struct wlr_allocator *allocator;
struct wl_list buffers; // wlr_wl_buffer.link
size_t requested_outputs;
size_t last_output_num;
struct wl_listener local_display_destroy;
/* remote state */
struct wl_display *remote_display;
struct wl_event_source *remote_display_src;
@ -38,18 +41,17 @@ struct wlr_wl_backend {
struct wp_presentation *presentation;
struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf_v1;
struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1;
struct wl_seat *seat;
struct wl_pointer *pointer;
struct wl_keyboard *keyboard;
struct wlr_wl_pointer *current_pointer;
struct wl_list seats; // wlr_wl_seat.link
struct zwp_tablet_manager_v2 *tablet_manager;
char *seat_name;
struct wlr_drm_format_set linux_dmabuf_v1_formats;
};
struct wlr_wl_buffer {
struct wlr_buffer *buffer;
struct wl_buffer *wl_buffer;
bool released;
struct wl_list link; // wlr_wl_backend.buffers
struct wl_listener buffer_destroy;
};
struct wlr_wl_presentation_feedback {
@ -70,15 +72,17 @@ struct wlr_wl_output {
struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel;
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1;
struct wl_egl_window *egl_window;
EGLSurface egl_surface;
struct wl_list presentation_feedbacks;
struct wlr_swapchain *swapchain;
struct wlr_buffer *back_buffer;
uint32_t enter_serial;
struct {
struct wlr_wl_pointer *pointer;
struct wl_surface *surface;
struct wl_egl_window *egl_window;
struct wlr_swapchain *swapchain;
int32_t hotspot_x, hotspot_y;
int32_t width, height;
} cursor;
@ -89,6 +93,7 @@ struct wlr_wl_input_device {
uint32_t fingers;
struct wlr_wl_backend *backend;
struct wlr_wl_seat *seat;
void *resource;
};
@ -107,18 +112,35 @@ struct wlr_wl_pointer {
struct wl_listener output_destroy;
};
struct wlr_wl_seat {
struct wl_seat *wl_seat;
struct wl_list link; // wlr_wl_backend.seats
char *name;
struct wl_touch *touch;
struct wl_pointer *pointer;
struct wl_keyboard *keyboard;
struct wlr_wl_backend *backend;
struct wlr_wl_pointer *active_pointer;
};
struct wlr_wl_backend *get_wl_backend_from_backend(struct wlr_backend *backend);
void update_wl_output_cursor(struct wlr_wl_output *output);
struct wlr_wl_pointer *pointer_get_wl(struct wlr_pointer *wlr_pointer);
void create_wl_pointer(struct wl_pointer *wl_pointer, struct wlr_wl_output *output);
void create_wl_keyboard(struct wl_keyboard *wl_keyboard, struct wlr_wl_backend *wl);
void create_wl_pointer(struct wlr_wl_seat *seat, struct wlr_wl_output *output);
void create_wl_keyboard(struct wlr_wl_seat *seat);
void create_wl_touch(struct wlr_wl_seat *seat);
struct wlr_wl_input_device *create_wl_input_device(
struct wlr_wl_backend *backend, enum wlr_input_device_type type);
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_buffer(struct wlr_wl_buffer *buffer);
extern const struct wl_seat_listener seat_listener;
struct wlr_wl_tablet_seat *wl_add_tablet_seat(
struct zwp_tablet_manager_v2 *manager,
struct wl_seat *seat, struct wlr_wl_backend *backend);
struct wlr_wl_seat *seat);
#endif

View file

@ -1,16 +1,26 @@
#ifndef BACKEND_X11_H
#define BACKEND_X11_H
#include <wlr/config.h>
#include <stdbool.h>
#include <X11/Xlib-xcb.h>
#include <wayland-server-core.h>
#include <xcb/xcb.h>
#include <xcb/present.h>
#if WLR_HAS_XCB_ERRORS
#include <xcb/xcb_errors.h>
#endif
#include <wlr/backend/x11.h>
#include <wlr/config.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/render/drm_format_set.h>
#include <wlr/render/egl.h>
#include <wlr/render/wlr_renderer.h>
@ -26,7 +36,9 @@ struct wlr_x11_output {
struct wl_list link; // wlr_x11_backend::outputs
xcb_window_t win;
EGLSurface surf;
struct wlr_swapchain *swapchain;
struct wlr_buffer *back_buffer;
struct wlr_pointer pointer;
struct wlr_input_device pointer_dev;
@ -38,6 +50,8 @@ struct wlr_x11_output {
struct wl_event_source *frame_timer;
int frame_delay;
struct wl_list buffers; // wlr_x11_buffer::link
bool cursor_hidden;
};
@ -55,6 +69,10 @@ struct wlr_x11_backend {
Display *xlib_conn;
xcb_connection_t *xcb;
xcb_screen_t *screen;
xcb_depth_t *depth;
xcb_visualid_t visualid;
xcb_colormap_t colormap;
xcb_present_event_t present_event_id;
size_t requested_outputs;
size_t last_output_num;
@ -65,6 +83,10 @@ struct wlr_x11_backend {
struct wlr_egl egl;
struct wlr_renderer *renderer;
struct wlr_drm_format_set dri3_formats;
const struct wlr_x11_format *x11_format;
struct wlr_drm_format *drm_format;
struct wlr_allocator *allocator;
struct wl_event_source *event_source;
struct {
@ -78,11 +100,29 @@ struct wlr_x11_backend {
// The time we last received an event
xcb_timestamp_t time;
#if WLR_HAS_XCB_ERRORS
xcb_errors_context_t *errors_context;
#endif
uint8_t present_opcode;
uint8_t xinput_opcode;
struct wl_listener display_destroy;
};
struct wlr_x11_buffer {
struct wlr_x11_backend *x11;
struct wlr_buffer *buffer;
xcb_pixmap_t pixmap;
struct wl_list link; // wlr_x11_output::buffers
struct wl_listener buffer_destroy;
};
struct wlr_x11_format {
uint32_t drm;
uint8_t depth, bpp;
};
struct wlr_x11_backend *get_x11_backend_from_backend(
struct wlr_backend *wlr_backend);
struct wlr_x11_output *get_x11_output_from_window_id(
@ -100,5 +140,7 @@ void update_x11_pointer_position(struct wlr_x11_output *output,
void handle_x11_configure_notify(struct wlr_x11_output *output,
xcb_configure_notify_event_t *event);
void handle_x11_present_event(struct wlr_x11_backend *x11,
xcb_ge_generic_event_t *event);
#endif

View file

@ -0,0 +1,42 @@
#ifndef RENDER_ALLOCATOR
#define RENDER_ALLOCATOR
#include <stdbool.h>
#include <wayland-server-core.h>
#include <wlr/render/dmabuf.h>
#include <wlr/render/drm_format_set.h>
struct wlr_allocator;
struct wlr_allocator_interface {
struct wlr_buffer *(*create_buffer)(struct wlr_allocator *alloc,
int width, int height, const struct wlr_drm_format *format);
void (*destroy)(struct wlr_allocator *alloc);
};
struct wlr_allocator {
const struct wlr_allocator_interface *impl;
struct {
struct wl_signal destroy;
} events;
};
/**
* Destroy the allocator.
*/
void wlr_allocator_destroy(struct wlr_allocator *alloc);
/**
* Allocate a new buffer.
*
* When the caller is done with it, they must unreference it by calling
* wlr_buffer_drop.
*/
struct wlr_buffer *wlr_allocator_create_buffer(struct wlr_allocator *alloc,
int width, int height, const struct wlr_drm_format *format);
// For wlr_allocator implementors
void wlr_allocator_init(struct wlr_allocator *alloc,
const struct wlr_allocator_interface *impl);
#endif

View file

@ -0,0 +1,19 @@
#ifndef RENDER_DRM_FORMAT_SET_H
#define RENDER_DRM_FORMAT_SET_H
#include <wlr/render/drm_format_set.h>
struct wlr_drm_format *wlr_drm_format_create(uint32_t format);
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);
/**
* Intersect modifiers for two DRM formats.
*
* Both arguments must have the same format field. If the formats aren't
* compatible, NULL is returned. If either format doesn't support any modifier,
* a format that doesn't support any modifier is returned.
*/
struct wlr_drm_format *wlr_drm_format_intersect(
const struct wlr_drm_format *a, const struct wlr_drm_format *b);
#endif

View file

@ -0,0 +1,29 @@
#ifndef RENDER_GBM_ALLOCATOR_H
#define RENDER_GBM_ALLOCATOR_H
#include <gbm.h>
#include <wlr/types/wlr_buffer.h>
#include "render/allocator.h"
struct wlr_gbm_buffer {
struct wlr_buffer base;
struct gbm_bo *gbm_bo;
struct wlr_dmabuf_attributes dmabuf;
};
struct wlr_gbm_allocator {
struct wlr_allocator base;
int fd;
struct gbm_device *gbm_device;
};
/**
* Creates a new GBM allocator from a render FD.
*
* Takes ownership over the FD.
*/
struct wlr_gbm_allocator *wlr_gbm_allocator_create(int render_fd);
#endif

View file

@ -14,17 +14,6 @@
#include <wlr/render/wlr_texture.h>
#include <wlr/util/log.h>
struct wlr_gles2_procs {
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
PFNGLDEBUGMESSAGECALLBACKKHRPROC glDebugMessageCallbackKHR;
PFNGLDEBUGMESSAGECONTROLKHRPROC glDebugMessageControlKHR;
PFNGLPOPDEBUGGROUPKHRPROC glPopDebugGroupKHR;
PFNGLPUSHDEBUGGROUPKHRPROC glPushDebugGroupKHR;
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES;
};
extern struct wlr_gles2_procs gles2_procs;
struct wlr_gles2_pixel_format {
enum wl_shm_format wl_format;
GLint gl_format, gl_type;
@ -46,6 +35,7 @@ struct wlr_gles2_renderer {
struct wlr_renderer wlr_renderer;
struct wlr_egl *egl;
int drm_fd;
const char *exts_str;
struct {
@ -55,6 +45,15 @@ struct wlr_gles2_renderer {
bool egl_image_oes;
} exts;
struct {
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
PFNGLDEBUGMESSAGECALLBACKKHRPROC glDebugMessageCallbackKHR;
PFNGLDEBUGMESSAGECONTROLKHRPROC glDebugMessageControlKHR;
PFNGLPOPDEBUGGROUPKHRPROC glPopDebugGroupKHR;
PFNGLPUSHDEBUGGROUPKHRPROC glPushDebugGroupKHR;
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES;
} procs;
struct {
struct {
GLuint program;
@ -74,12 +73,27 @@ struct wlr_gles2_renderer {
struct wlr_gles2_tex_shader tex_ext;
} shaders;
struct wl_list buffers; // wlr_gles2_buffer.link
struct wlr_gles2_buffer *current_buffer;
uint32_t viewport_width, viewport_height;
};
struct wlr_gles2_buffer {
struct wlr_buffer *buffer;
struct wlr_gles2_renderer *renderer;
struct wl_list link; // wlr_gles2_renderer.buffers
EGLImageKHR image;
GLuint rbo;
GLuint fbo;
struct wl_listener buffer_destroy;
};
struct wlr_gles2_texture {
struct wlr_texture wlr_texture;
struct wlr_egl *egl;
struct wlr_gles2_renderer *renderer;
// Basically:
// GL_TEXTURE_2D == mutable
@ -102,12 +116,22 @@ const struct wlr_gles2_pixel_format *get_gles2_format_from_gl(
GLint gl_format, GLint gl_type, bool alpha);
const enum wl_shm_format *get_gles2_wl_formats(size_t *len);
struct wlr_gles2_renderer *gles2_get_renderer(
struct wlr_renderer *wlr_renderer);
struct wlr_gles2_texture *gles2_get_texture(
struct wlr_texture *wlr_texture);
void push_gles2_marker(const char *file, const char *func);
void pop_gles2_marker(void);
#define PUSH_GLES2_DEBUG push_gles2_marker(_WLR_FILENAME, __func__)
#define POP_GLES2_DEBUG pop_gles2_marker()
struct wlr_texture *gles2_texture_from_pixels(struct wlr_renderer *wlr_renderer,
enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width, uint32_t height,
const void *data);
struct wlr_texture *gles2_texture_from_wl_drm(struct wlr_renderer *wlr_renderer,
struct wl_resource *data);
struct wlr_texture *gles2_texture_from_dmabuf(struct wlr_renderer *wlr_renderer,
struct wlr_dmabuf_attributes *attribs);
void push_gles2_debug_(struct wlr_gles2_renderer *renderer,
const char *file, const char *func);
#define push_gles2_debug(renderer) push_gles2_debug_(renderer, _WLR_FILENAME, __func__)
void pop_gles2_debug(struct wlr_gles2_renderer *renderer);
#endif

View file

@ -0,0 +1,50 @@
#ifndef RENDER_SWAPCHAIN_H
#define RENDER_SWAPCHAIN_H
#include <stdbool.h>
#include <wayland-server-core.h>
#include <wlr/render/drm_format_set.h>
#define WLR_SWAPCHAIN_CAP 4
struct wlr_swapchain_slot {
struct wlr_buffer *buffer;
bool acquired; // waiting for release
int age;
struct wl_listener release;
};
struct wlr_swapchain {
struct wlr_allocator *allocator; // NULL if destroyed
int width, height;
struct wlr_drm_format *format;
struct wlr_swapchain_slot slots[WLR_SWAPCHAIN_CAP];
struct wl_listener allocator_destroy;
};
struct wlr_swapchain *wlr_swapchain_create(
struct wlr_allocator *alloc, int width, int height,
const struct wlr_drm_format *format);
void wlr_swapchain_destroy(struct wlr_swapchain *swapchain);
/**
* Acquire a buffer from the swap chain.
*
* The returned buffer is locked. When the caller is done with it, they must
* unlock it by calling wlr_buffer_unlock.
*/
struct wlr_buffer *wlr_swapchain_acquire(struct wlr_swapchain *swapchain,
int *age);
/**
* Mark the buffer as submitted for presentation. This needs to be called by
* swap chain users on frame boundaries.
*
* If the buffer hasn't been created via the swap chain, the call is ignored.
*/
void wlr_swapchain_set_buffer_submitted(struct wlr_swapchain *swapchain,
struct wlr_buffer *buffer);
#endif

View file

@ -0,0 +1,14 @@
#ifndef RENDER_WLR_RENDERER_H
#define RENDER_WLR_RENDERER_H
#include <wlr/render/wlr_renderer.h>
bool wlr_renderer_bind_buffer(struct wlr_renderer *r, struct wlr_buffer *buffer);
/**
* Get the DMA-BUF formats supporting rendering usage. Buffers allocated with
* a format from this list may be attached via wlr_renderer_bind_buffer.
*/
const struct wlr_drm_format_set *wlr_renderer_get_dmabuf_render_formats(
struct wlr_renderer *renderer);
#endif

View file

@ -1,47 +0,0 @@
#ifndef TYPES_WLR_XDG_SHELL_V6_H
#define TYPES_WLR_XDG_SHELL_V6_H
#include <wayland-server-core.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
#include "xdg-shell-unstable-v6-protocol.h"
struct wlr_xdg_positioner_v6_resource {
struct wl_resource *resource;
struct wlr_xdg_positioner_v6 attrs;
};
extern const struct wlr_surface_role xdg_toplevel_v6_surface_role;
extern const struct wlr_surface_role xdg_popup_v6_surface_role;
uint32_t schedule_xdg_surface_v6_configure(struct wlr_xdg_surface_v6 *surface);
struct wlr_xdg_surface_v6 *create_xdg_surface_v6(
struct wlr_xdg_client_v6 *client, struct wlr_surface *surface,
uint32_t id);
void unmap_xdg_surface_v6(struct wlr_xdg_surface_v6 *surface);
void destroy_xdg_surface_v6(struct wlr_xdg_surface_v6 *surface);
void handle_xdg_surface_v6_commit(struct wlr_surface *wlr_surface);
void handle_xdg_surface_v6_precommit(struct wlr_surface *wlr_surface);
void create_xdg_positioner_v6(struct wlr_xdg_client_v6 *client, uint32_t id);
struct wlr_xdg_positioner_v6_resource *get_xdg_positioner_v6_from_resource(
struct wl_resource *resource);
void create_xdg_popup_v6(struct wlr_xdg_surface_v6 *xdg_surface,
struct wlr_xdg_surface_v6 *parent,
struct wlr_xdg_positioner_v6_resource *positioner, int32_t id);
void handle_xdg_surface_v6_popup_committed(struct wlr_xdg_surface_v6 *surface);
struct wlr_xdg_popup_grab_v6 *get_xdg_shell_v6_popup_grab_from_seat(
struct wlr_xdg_shell_v6 *shell, struct wlr_seat *seat);
void destroy_xdg_popup_v6(struct wlr_xdg_surface_v6 *surface);
void create_xdg_toplevel_v6(struct wlr_xdg_surface_v6 *xdg_surface,
uint32_t id);
void handle_xdg_surface_v6_toplevel_committed(struct wlr_xdg_surface_v6 *surface);
void send_xdg_toplevel_v6_configure(struct wlr_xdg_surface_v6 *surface,
struct wlr_xdg_surface_v6_configure *configure);
void handle_xdg_toplevel_v6_ack_configure(struct wlr_xdg_surface_v6 *surface,
struct wlr_xdg_surface_v6_configure *configure);
bool compare_xdg_surface_v6_toplevel_state(struct wlr_xdg_toplevel_v6 *state);
void destroy_xdg_toplevel_v6(struct wlr_xdg_surface_v6 *surface);
#endif

View file

@ -13,6 +13,11 @@ uint32_t get_current_time_msec(void);
*/
int64_t timespec_to_msec(const struct timespec *a);
/**
* Convert nanoseconds to a timespec.
*/
void timespec_from_nsec(struct timespec *r, int64_t nsec);
/**
* Subtracts timespec `b` from timespec `a`, and stores the difference in `r`.
*/

View file

@ -22,7 +22,8 @@
* a DRM backend, other kinds of backends raise SIGABRT).
*/
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
struct wlr_session *session, int gpu_fd, struct wlr_backend *parent,
struct wlr_session *session, struct wlr_device *dev,
struct wlr_backend *parent,
wlr_renderer_create_func_t create_renderer_func);
bool wlr_backend_is_drm(struct wlr_backend *backend);

View file

@ -11,9 +11,11 @@ struct session_impl;
struct wlr_device {
int fd;
dev_t dev;
struct wl_signal signal;
struct wl_list link;
struct {
struct wl_signal change;
} events;
};
struct wlr_session {
@ -22,7 +24,6 @@ struct wlr_session {
* Signal for when the session becomes active/inactive.
* It's called when we swap virtual terminal.
*/
struct wl_signal session_signal;
bool active;
/*
@ -38,13 +39,20 @@ struct wlr_session {
struct wl_list devices;
struct wl_display *display;
struct wl_listener display_destroy;
struct {
struct wl_signal active;
struct wl_signal add_drm_card; // struct wlr_session_add_event
struct wl_signal destroy;
} events;
};
struct wlr_session_add_event {
const char *path;
};
/*
* Opens a session, taking control of the current virtual terminal.
* This should not be called if another program is already in control
@ -74,21 +82,21 @@ void wlr_session_destroy(struct wlr_session *session);
*
* Returns -errno on error.
*/
int wlr_session_open_file(struct wlr_session *session, const char *path);
struct wlr_device *wlr_session_open_file(struct wlr_session *session,
const char *path);
/*
* Closes a file previously opened with wlr_session_open_file.
*/
void wlr_session_close_file(struct wlr_session *session, int fd);
void wlr_session_close_file(struct wlr_session *session,
struct wlr_device *device);
void wlr_session_signal_add(struct wlr_session *session, int fd,
struct wl_listener *listener);
/*
* Changes the virtual terminal.
*/
bool wlr_session_change_vt(struct wlr_session *session, unsigned vt);
size_t wlr_session_find_gpus(struct wlr_session *session,
size_t ret_len, int *ret);
size_t ret_len, struct wlr_device **ret);
#endif

View file

@ -1,13 +1,11 @@
#ifndef WLR_CONFIG_H
#define WLR_CONFIG_H
#mesondefine WLR_HAS_EGLMESAEXT_H
#mesondefine WLR_HAS_LIBCAP
#mesondefine WLR_HAS_SYSTEMD
#mesondefine WLR_HAS_ELOGIND
#mesondefine WLR_HAS_LIBSEAT
#mesondefine WLR_HAS_X11_BACKEND
#mesondefine WLR_HAS_XWAYLAND

View file

@ -15,9 +15,9 @@
#define WLR_DMABUF_MAX_PLANES 4
enum wlr_dmabuf_attributes_flags {
WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT = 1,
WLR_DMABUF_ATTRIBUTES_FLAGS_INTERLACED = 2,
WLR_DMABUF_ATTRIBUTES_FLAGS_BOTTOM_FIRST = 4,
WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT = 1 << 0,
WLR_DMABUF_ATTRIBUTES_FLAGS_INTERLACED = 1 << 1,
WLR_DMABUF_ATTRIBUTES_FLAGS_BOTTOM_FIRST = 1 << 2,
};
struct wlr_dmabuf_attributes {

View file

@ -15,15 +15,14 @@
#ifndef EGL_NO_X11
#define EGL_NO_X11
#endif
#ifndef EGL_NO_PLATFORM_SPECIFIC_TYPES
#define EGL_NO_PLATFORM_SPECIFIC_TYPES
#endif
#include <wlr/config.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#if WLR_HAS_EGLMESAEXT_H
// TODO: remove eglmesaext.h
#include <EGL/eglmesaext.h>
#endif
#include <pixman.h>
#include <stdbool.h>
#include <wayland-server-core.h>
@ -42,8 +41,10 @@ struct wlr_egl {
EGLDisplay display;
EGLConfig config;
EGLContext context;
EGLDeviceEXT device; // may be EGL_NO_DEVICE_EXT
struct {
// Display extensions
bool bind_wayland_display_wl;
bool buffer_age_ext;
bool image_base_khr;
@ -51,6 +52,9 @@ struct wlr_egl {
bool image_dmabuf_import_ext;
bool image_dmabuf_import_modifiers_ext;
bool swap_buffers_with_damage;
// Device extensions
bool device_drm_ext;
} exts;
struct {
@ -67,12 +71,14 @@ struct wlr_egl {
PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC eglExportDMABUFImageQueryMESA;
PFNEGLEXPORTDMABUFIMAGEMESAPROC eglExportDMABUFImageMESA;
PFNEGLDEBUGMESSAGECONTROLKHRPROC eglDebugMessageControlKHR;
PFNEGLQUERYDISPLAYATTRIBEXTPROC eglQueryDisplayAttribEXT;
PFNEGLQUERYDEVICESTRINGEXTPROC eglQueryDeviceStringEXT;
} procs;
struct wl_display *wl_display;
struct wlr_drm_format_set dmabuf_formats;
EGLBoolean **external_only_dmabuf_formats;
struct wlr_drm_format_set dmabuf_texture_formats;
struct wlr_drm_format_set dmabuf_render_formats;
};
// TODO: Allocate and return a wlr_egl
@ -117,9 +123,15 @@ EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl,
struct wlr_dmabuf_attributes *attributes, bool *external_only);
/**
* Get the available dmabuf formats
* Get DMA-BUF formats suitable for sampling usage.
*/
const struct wlr_drm_format_set *wlr_egl_get_dmabuf_formats(struct wlr_egl *egl);
const struct wlr_drm_format_set *wlr_egl_get_dmabuf_texture_formats(
struct wlr_egl *egl);
/**
* Get DMA-BUF formats suitable for rendering usage.
*/
const struct wlr_drm_format_set *wlr_egl_get_dmabuf_render_formats(
struct wlr_egl *egl);
bool wlr_egl_export_image_to_dmabuf(struct wlr_egl *egl, EGLImageKHR image,
int32_t width, int32_t height, uint32_t flags,
@ -161,4 +173,6 @@ bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface,
bool wlr_egl_destroy_surface(struct wlr_egl *egl, EGLSurface surface);
int wlr_egl_dup_drm_fd(struct wlr_egl *egl);
#endif

View file

@ -21,14 +21,6 @@ struct wlr_egl *wlr_gles2_renderer_get_egl(struct wlr_renderer *renderer);
bool wlr_gles2_renderer_check_ext(struct wlr_renderer *renderer,
const char *ext);
struct wlr_texture *wlr_gles2_texture_from_pixels(struct wlr_egl *egl,
enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width, uint32_t height,
const void *data);
struct wlr_texture *wlr_gles2_texture_from_wl_drm(struct wlr_egl *egl,
struct wl_resource *data);
struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl,
struct wlr_dmabuf_attributes *attribs);
struct wlr_gles2_texture_attribs {
GLenum target; /* either GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES */
GLuint tex;

View file

@ -15,6 +15,9 @@
#ifndef EGL_NO_X11
#define EGL_NO_X11
#endif
#ifndef EGL_NO_PLATFORM_SPECIFIC_TYPES
#define EGL_NO_PLATFORM_SPECIFIC_TYPES
#endif
#include <EGL/egl.h>
#include <EGL/eglext.h>
@ -27,6 +30,8 @@
#include <wlr/render/dmabuf.h>
struct wlr_renderer_impl {
bool (*bind_buffer)(struct wlr_renderer *renderer,
struct wlr_buffer *buffer);
void (*begin)(struct wlr_renderer *renderer, uint32_t width,
uint32_t height);
void (*end)(struct wlr_renderer *renderer);
@ -39,15 +44,15 @@ struct wlr_renderer_impl {
const float color[static 4], const float matrix[static 9]);
void (*render_ellipse_with_matrix)(struct wlr_renderer *renderer,
const float color[static 4], const float matrix[static 9]);
const enum wl_shm_format *(*formats)(
const enum wl_shm_format *(*get_shm_texture_formats)(
struct wlr_renderer *renderer, size_t *len);
bool (*format_supported)(struct wlr_renderer *renderer,
enum wl_shm_format fmt);
bool (*resource_is_wl_drm_buffer)(struct wlr_renderer *renderer,
struct wl_resource *resource);
void (*wl_drm_buffer_get_size)(struct wlr_renderer *renderer,
struct wl_resource *buffer, int *width, int *height);
const struct wlr_drm_format_set *(*get_dmabuf_formats)(
const struct wlr_drm_format_set *(*get_dmabuf_texture_formats)(
struct wlr_renderer *renderer);
const struct wlr_drm_format_set *(*get_dmabuf_render_formats)(
struct wlr_renderer *renderer);
enum wl_shm_format (*preferred_read_format)(struct wlr_renderer *renderer);
bool (*read_pixels)(struct wlr_renderer *renderer, enum wl_shm_format fmt,
@ -67,6 +72,7 @@ struct wlr_renderer_impl {
bool (*blit_dmabuf)(struct wlr_renderer *renderer,
struct wlr_dmabuf_attributes *dst,
struct wlr_dmabuf_attributes *src);
int (*get_drm_fd)(struct wlr_renderer *renderer);
};
void wlr_renderer_init(struct wlr_renderer *renderer,

View file

@ -21,6 +21,7 @@ enum wlr_renderer_read_pixels_flags {
struct wlr_renderer_impl;
struct wlr_drm_format_set;
struct wlr_buffer;
struct wlr_renderer {
const struct wlr_renderer_impl *impl;
@ -35,7 +36,7 @@ struct wlr_renderer {
struct wlr_renderer *wlr_renderer_autocreate(struct wlr_egl *egl, EGLenum platform,
void *remote_display, EGLint *config_attribs, EGLint visual_id);
void wlr_renderer_begin(struct wlr_renderer *r, int width, int height);
void wlr_renderer_begin(struct wlr_renderer *r, uint32_t width, uint32_t height);
void wlr_renderer_end(struct wlr_renderer *r);
void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]);
/**
@ -82,10 +83,11 @@ void wlr_render_ellipse(struct wlr_renderer *r, const struct wlr_box *box,
void wlr_render_ellipse_with_matrix(struct wlr_renderer *r,
const float color[static 4], const float matrix[static 9]);
/**
* Returns a list of pixel formats supported by this renderer.
* Get the shared-memory formats supporting import usage. Buffers allocated
* with a format from this list may be imported via wlr_texture_from_pixels.
*/
const enum wl_shm_format *wlr_renderer_get_formats(struct wlr_renderer *r,
size_t *len);
const enum wl_shm_format *wlr_renderer_get_shm_texture_formats(
struct wlr_renderer *r, size_t *len);
/**
* Returns true if this wl_buffer is a wl_drm buffer.
*/
@ -97,9 +99,10 @@ bool wlr_renderer_resource_is_wl_drm_buffer(struct wlr_renderer *renderer,
void wlr_renderer_wl_drm_buffer_get_size(struct wlr_renderer *renderer,
struct wl_resource *buffer, int *width, int *height);
/**
* Get the available DMA-BUF formats.
* Get the DMA-BUF formats supporting sampling usage. Buffers allocated with
* a format from this list may be imported via wlr_texture_from_dmabuf.
*/
const struct wlr_drm_format_set *wlr_renderer_get_dmabuf_formats(
const struct wlr_drm_format_set *wlr_renderer_get_dmabuf_texture_formats(
struct wlr_renderer *renderer);
/**
* Reads out of pixels of the currently bound surface into data. `stride` is in
@ -117,11 +120,6 @@ bool wlr_renderer_read_pixels(struct wlr_renderer *r, enum wl_shm_format fmt,
*/
bool wlr_renderer_blit_dmabuf(struct wlr_renderer *r,
struct wlr_dmabuf_attributes *dst, struct wlr_dmabuf_attributes *src);
/**
* Checks if a format is supported.
*/
bool wlr_renderer_format_supported(struct wlr_renderer *r,
enum wl_shm_format fmt);
/**
* Creates necessary shm and invokes the initialization of the implementation.
*
@ -130,6 +128,13 @@ bool wlr_renderer_format_supported(struct wlr_renderer *r,
bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
struct wl_display *wl_display);
/**
* Obtains the FD of the DRM device used for rendering, or -1 if unavailable.
*
* The caller doesn't have ownership of the FD, it must not close it.
*/
int wlr_renderer_get_drm_fd(struct wlr_renderer *r);
/**
* Destroys this wlr_renderer. Textures must be destroyed separately.
*/

View file

@ -24,6 +24,9 @@ struct wlr_texture {
/**
* Create a new texture from raw pixel data. `stride` is in bytes. The returned
* texture is mutable.
*
* 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_pixels(struct wlr_renderer *renderer,
enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width, uint32_t height,
@ -32,12 +35,18 @@ struct wlr_texture *wlr_texture_from_pixels(struct wlr_renderer *renderer,
/**
* 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.
*
* 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_dmabuf(struct wlr_renderer *renderer,
struct wlr_dmabuf_attributes *attribs);
@ -58,6 +67,9 @@ bool wlr_texture_is_opaque(struct wlr_texture *texture);
/**
* Update a texture with raw pixels. The texture must be mutable, and the input
* data must have the same pixel format that the texture was created with.
*
* Should not be called in a rendering block like renderer_begin()/end() or
* between attaching a renderer to an output and committing it.
*/
bool wlr_texture_write_pixels(struct wlr_texture *texture,
uint32_t stride, uint32_t width, uint32_t height,

View file

@ -103,6 +103,11 @@ struct wlr_client_buffer {
struct wlr_renderer;
/**
* Get a client buffer from a generic buffer. If the buffer isn't a client
* buffer, returns NULL.
*/
struct wlr_client_buffer *wlr_client_buffer_get(struct wlr_buffer *buffer);
/**
* Check if a resource is a wl_buffer resource.
*/

View file

@ -136,7 +136,6 @@ struct wlr_drag {
struct wl_signal destroy;
} events;
struct wl_listener point_destroy;
struct wl_listener source_destroy;
struct wl_listener seat_client_destroy;
struct wl_listener icon_destroy;

View file

@ -29,12 +29,11 @@ struct wlr_export_dmabuf_frame_v1 {
struct wlr_export_dmabuf_manager_v1 *manager;
struct wl_list link; // wlr_export_dmabuf_manager_v1::frames
struct wlr_dmabuf_attributes attribs;
struct wlr_output *output;
bool cursor_locked;
struct wl_listener output_precommit;
struct wl_listener output_commit;
};
struct wlr_export_dmabuf_manager_v1 *wlr_export_dmabuf_manager_v1_create(

View file

@ -50,6 +50,7 @@ struct wlr_foreign_toplevel_handle_v1 {
char *title;
char *app_id;
struct wlr_foreign_toplevel_handle_v1 *parent;
struct wl_list outputs; // wlr_foreign_toplevel_v1_output
uint32_t state; // wlr_foreign_toplevel_v1_state
@ -104,6 +105,12 @@ struct wlr_foreign_toplevel_manager_v1 *wlr_foreign_toplevel_manager_v1_create(
struct wlr_foreign_toplevel_handle_v1 *wlr_foreign_toplevel_handle_v1_create(
struct wlr_foreign_toplevel_manager_v1 *manager);
/* Destroy the given toplevel handle, sending the closed event to any
* client. Also, if the destroyed toplevel is set as a parent of any
* other valid toplevel, clients still holding a handle to both are
* sent a parent signal with NULL parent. If this is not desired, the
* caller should ensure that any child toplevels are destroyed before
* the parent. */
void wlr_foreign_toplevel_handle_v1_destroy(
struct wlr_foreign_toplevel_handle_v1 *toplevel);
@ -126,4 +133,14 @@ void wlr_foreign_toplevel_handle_v1_set_activated(
void wlr_foreign_toplevel_handle_v1_set_fullscreen(
struct wlr_foreign_toplevel_handle_v1* toplevel, bool fullscreen);
/* Set the parent of a toplevel. If the parent changed from its previous
* value, also sends a parent event to all clients that hold handles to
* both toplevel and parent (no message is sent to clients that have
* previously destroyed their parent handle). NULL is allowed as the
* parent, meaning no parent exists. */
void wlr_foreign_toplevel_handle_v1_set_parent(
struct wlr_foreign_toplevel_handle_v1 *toplevel,
struct wlr_foreign_toplevel_handle_v1 *parent);
#endif

View file

@ -21,6 +21,10 @@ struct wlr_gamma_control_v1 {
struct wlr_output *output;
struct wl_list link;
uint16_t *table;
size_t ramp_size;
struct wl_listener output_commit_listener;
struct wl_listener output_destroy_listener;
void *data;

View file

@ -9,6 +9,8 @@
#ifndef WLR_TYPES_WLR_INPUT_DEVICE_H
#define WLR_TYPES_WLR_INPUT_DEVICE_H
#include <wayland-server-core.h>
enum wlr_button_state {
WLR_BUTTON_RELEASED,
WLR_BUTTON_PRESSED,
@ -23,14 +25,6 @@ enum wlr_input_device_type {
WLR_INPUT_DEVICE_SWITCH,
};
/* Note: these are circular dependencies */
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_touch.h>
#include <wlr/types/wlr_tablet_tool.h>
#include <wlr/types/wlr_tablet_pad.h>
#include <wlr/types/wlr_switch.h>
struct wlr_input_device_impl;
struct wlr_input_device {

View file

@ -12,28 +12,28 @@
#include <stdbool.h>
#include <stdint.h>
#include <wayland-server-core.h>
#include <wayland-server-core.h>
#include <wayland-server-protocol.h>
#include <xkbcommon/xkbcommon.h>
#define WLR_LED_COUNT 3
enum wlr_keyboard_led {
WLR_LED_NUM_LOCK = 1,
WLR_LED_CAPS_LOCK = 2,
WLR_LED_SCROLL_LOCK = 4,
WLR_LED_NUM_LOCK = 1 << 0,
WLR_LED_CAPS_LOCK = 1 << 1,
WLR_LED_SCROLL_LOCK = 1 << 2,
};
#define WLR_MODIFIER_COUNT 8
enum wlr_keyboard_modifier {
WLR_MODIFIER_SHIFT = 1,
WLR_MODIFIER_CAPS = 2,
WLR_MODIFIER_CTRL = 4,
WLR_MODIFIER_ALT = 8,
WLR_MODIFIER_MOD2 = 16,
WLR_MODIFIER_MOD3 = 32,
WLR_MODIFIER_LOGO = 64,
WLR_MODIFIER_MOD5 = 128,
WLR_MODIFIER_SHIFT = 1 << 0,
WLR_MODIFIER_CAPS = 1 << 1,
WLR_MODIFIER_CTRL = 1 << 2,
WLR_MODIFIER_ALT = 1 << 3,
WLR_MODIFIER_MOD2 = 1 << 4,
WLR_MODIFIER_MOD3 = 1 << 5,
WLR_MODIFIER_LOGO = 1 << 6,
WLR_MODIFIER_MOD5 = 1 << 7,
};
#define WLR_KEYBOARD_KEYS_CAP 32
@ -91,16 +91,11 @@ struct wlr_keyboard {
void *data;
};
enum wlr_key_state {
WLR_KEY_RELEASED,
WLR_KEY_PRESSED,
};
struct wlr_event_keyboard_key {
uint32_t time_msec;
uint32_t keycode;
bool update_state; // if backend doesn't update modifiers on its own
enum wlr_key_state state;
enum wl_keyboard_key_state state;
};
bool wlr_keyboard_set_keymap(struct wlr_keyboard *kb,

View file

@ -138,6 +138,10 @@ struct wlr_layer_surface_v1 *wlr_layer_surface_v1_from_wlr_surface(
void wlr_layer_surface_v1_for_each_surface(struct wlr_layer_surface_v1 *surface,
wlr_surface_iterator_func_t iterator, void *user_data);
/* Calls the iterator function for each popup of this surface */
void wlr_layer_surface_v1_for_each_popup(struct wlr_layer_surface_v1 *surface,
wlr_surface_iterator_func_t iterator, void *user_data);
/**
* Find a surface within this layer-surface tree at the given surface-local
* coordinates. Returns the surface and coordinates in the leaf surface

View file

@ -164,9 +164,11 @@ struct wlr_output {
// Emitted right before commit
struct wl_signal precommit; // wlr_output_event_precommit
// Emitted right after commit
struct wl_signal commit;
struct wl_signal commit; // wlr_output_event_commit
// Emitted right after the buffer has been presented to the user
struct wl_signal present; // wlr_output_event_present
// Emitted after a client bound the wl_output global
struct wl_signal bind; // wlr_output_event_bind
struct wl_signal enable;
struct wl_signal mode;
struct wl_signal scale;
@ -199,6 +201,12 @@ struct wlr_output_event_precommit {
struct timespec *when;
};
struct wlr_output_event_commit {
struct wlr_output *output;
uint32_t committed; // bitmask of enum wlr_output_state_field
struct timespec *when;
};
enum wlr_output_present_flag {
// The presentation was synchronized to the "vertical retrace" by the
// display hardware such that tearing does not happen.
@ -228,6 +236,11 @@ struct wlr_output_event_present {
uint32_t flags; // enum wlr_output_present_flag
};
struct wlr_output_event_bind {
struct wlr_output *output;
struct wl_resource *resource;
};
struct wlr_surface;
/**
@ -342,8 +355,7 @@ bool wlr_output_preferred_read_format(struct wlr_output *output,
* the screen that has changed since the last frame.
*
* Compositors implementing damage tracking should call this function with the
* damaged region in output-buffer-local coordinates (ie. scaled and
* transformed).
* damaged region in output-buffer-local coordinates.
*
* This region is not to be confused with the renderer's buffer damage, ie. the
* region compositors need to repaint. Compositors usually need to repaint more
@ -392,8 +404,7 @@ size_t wlr_output_get_gamma_size(struct wlr_output *output);
void wlr_output_set_gamma(struct wlr_output *output, size_t size,
const uint16_t *r, const uint16_t *g, const uint16_t *b);
/**
* Exports the output's current back-buffer as a DMA-BUF (ie. the buffer that
* will be displayed on next commit).
* Exports the last committed buffer as a DMA-BUF.
*
* The caller is responsible for cleaning up the DMA-BUF attributes.
*/

View file

@ -124,10 +124,10 @@ struct wlr_output *wlr_output_layout_get_center_output(
struct wlr_output_layout *layout);
enum wlr_direction {
WLR_DIRECTION_UP = 1,
WLR_DIRECTION_DOWN = 2,
WLR_DIRECTION_LEFT = 4,
WLR_DIRECTION_RIGHT = 8,
WLR_DIRECTION_UP = 1 << 0,
WLR_DIRECTION_DOWN = 1 << 1,
WLR_DIRECTION_LEFT = 1 << 2,
WLR_DIRECTION_RIGHT = 1 << 3,
};
/**

View file

@ -25,7 +25,7 @@ struct wlr_output_power_v1 {
struct wl_list link;
struct wl_listener output_destroy_listener;
struct wl_listener output_enable_listener;
struct wl_listener output_commit_listener;
void *data;
};

View file

@ -11,6 +11,7 @@
#include <stdint.h>
#include <wayland-server-core.h>
#include <wayland-server-protocol.h>
#include <wlr/types/wlr_input_device.h>
struct wlr_pointer_impl;

View file

@ -53,6 +53,7 @@ struct wlr_screencopy_frame_v1 {
struct wlr_output *output;
struct wl_listener output_precommit;
struct wl_listener output_commit;
struct wl_listener output_destroy;
struct wl_listener output_enable;

View file

@ -13,6 +13,7 @@
#include <wayland-server-core.h>
#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>
#define WLR_SERIAL_RINGSET_SIZE 128

View file

@ -67,6 +67,15 @@ struct wlr_surface_role {
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;
@ -126,6 +135,8 @@ struct wlr_surface {
// wlr_subsurface::parent_pending_link
struct wl_list subsurface_pending_list;
struct wl_list current_outputs; // wlr_surface_output::link
struct wl_listener renderer_destroy;
void *data;

View file

@ -48,8 +48,6 @@ struct wlr_xdg_client {
};
struct wlr_xdg_positioner {
struct wl_resource *resource;
struct wlr_box anchor_rect;
enum xdg_positioner_anchor anchor;
enum xdg_positioner_gravity gravity;
@ -124,6 +122,7 @@ struct wlr_xdg_toplevel {
struct wlr_xdg_toplevel_state client_pending;
struct wlr_xdg_toplevel_state server_pending;
struct wlr_xdg_toplevel_state last_acked;
struct wlr_xdg_toplevel_state current;
char *title;

View file

@ -1,374 +0,0 @@
/*
* This protocol is obsolete and will be removed in a future version. The
* recommended replacement is xdg-shell.
*/
/*
* 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_XDG_SHELL_V6_H
#define WLR_TYPES_WLR_XDG_SHELL_V6_H
#include <wayland-server-core.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_seat.h>
#include "xdg-shell-unstable-v6-protocol.h"
/**
* An interface enabling clients to turn their wl_surfaces into windows in a
* desktop environment.
*/
struct wlr_xdg_shell_v6 {
struct wl_global *global;
struct wl_list clients;
struct wl_list popup_grabs;
uint32_t ping_timeout;
struct wl_listener display_destroy;
struct {
/**
* The `new_surface` event signals that a client has requested to
* create a new shell surface. At this point, the surface is ready to
* be configured but is not mapped or ready receive input events. The
* surface will be ready to be managed on the `map` event.
*/
struct wl_signal new_surface;
struct wl_signal destroy;
} events;
void *data;
};
struct wlr_xdg_client_v6 {
struct wlr_xdg_shell_v6 *shell;
struct wl_resource *resource;
struct wl_client *client;
struct wl_list surfaces;
struct wl_list link; // wlr_xdg_shell_v6::clients
uint32_t ping_serial;
struct wl_event_source *ping_timer;
};
struct wlr_xdg_positioner_v6 {
struct wlr_box anchor_rect;
enum zxdg_positioner_v6_anchor anchor;
enum zxdg_positioner_v6_gravity gravity;
enum zxdg_positioner_v6_constraint_adjustment constraint_adjustment;
struct {
int32_t width, height;
} size;
struct {
int32_t x, y;
} offset;
};
struct wlr_xdg_popup_v6 {
struct wlr_xdg_surface_v6 *base;
struct wl_list link;
struct wl_resource *resource;
bool committed;
struct wlr_xdg_surface_v6 *parent;
struct wlr_seat *seat;
// Position of the popup relative to the upper left corner of the window
// geometry of the parent surface
struct wlr_box geometry;
struct wlr_xdg_positioner_v6 positioner;
struct wl_list grab_link; // wlr_xdg_popup_grab_v6::popups
};
// each seat gets a popup grab
struct wlr_xdg_popup_grab_v6 {
struct wl_client *client;
struct wlr_seat_pointer_grab pointer_grab;
struct wlr_seat_keyboard_grab keyboard_grab;
struct wlr_seat_touch_grab touch_grab;
struct wlr_seat *seat;
struct wl_list popups;
struct wl_list link; // wlr_xdg_shell_v6::popup_grabs
struct wl_listener seat_destroy;
};
enum wlr_xdg_surface_v6_role {
WLR_XDG_SURFACE_V6_ROLE_NONE,
WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL,
WLR_XDG_SURFACE_V6_ROLE_POPUP,
};
struct wlr_xdg_toplevel_v6_state {
bool maximized, fullscreen, resizing, activated;
uint32_t width, height;
uint32_t max_width, max_height;
uint32_t min_width, min_height;
// Since the fullscreen request may be made before the toplevel's surface
// is mapped, this is used to store the requested fullscreen output (if
// any) for wlr_xdg_toplevel_v6::client_pending.
struct wlr_output *fullscreen_output;
struct wl_listener fullscreen_output_destroy;
};
/**
* An xdg-surface is a user interface element requiring management by the
* compositor. An xdg-surface alone isn't useful, a role should be assigned to
* it in order to map it.
*
* When a surface has a role and is ready to be displayed, the `map` event is
* emitted. When a surface should no longer be displayed, the `unmap` event is
* emitted. The `unmap` event is guaranteed to be emitted before the `destroy`
* event if the view is destroyed when mapped.
*/
struct wlr_xdg_toplevel_v6 {
struct wl_resource *resource;
struct wlr_xdg_surface_v6 *base;
struct wlr_xdg_surface_v6 *parent;
bool added;
struct wlr_xdg_toplevel_v6_state client_pending;
struct wlr_xdg_toplevel_v6_state server_pending;
struct wlr_xdg_toplevel_v6_state current;
char *title;
char *app_id;
struct {
struct wl_signal request_maximize;
struct wl_signal request_fullscreen;
struct wl_signal request_minimize;
struct wl_signal request_move;
struct wl_signal request_resize;
struct wl_signal request_show_window_menu;
struct wl_signal set_parent;
struct wl_signal set_title;
struct wl_signal set_app_id;
} events;
};
struct wlr_xdg_surface_v6_configure {
struct wl_list link; // wlr_xdg_surface_v6::configure_list
uint32_t serial;
struct wlr_xdg_toplevel_v6_state *toplevel_state;
};
struct wlr_xdg_surface_v6 {
struct wlr_xdg_client_v6 *client;
struct wl_resource *resource;
struct wlr_surface *surface;
struct wl_list link; // wlr_xdg_client_v6::surfaces
enum wlr_xdg_surface_v6_role role;
union {
struct wlr_xdg_toplevel_v6 *toplevel;
struct wlr_xdg_popup_v6 *popup;
};
struct wl_list popups; // wlr_xdg_popup_v6::link
bool added, configured, mapped;
uint32_t configure_serial;
struct wl_event_source *configure_idle;
uint32_t configure_next_serial;
struct wl_list configure_list;
bool has_next_geometry;
struct wlr_box next_geometry;
struct wlr_box geometry;
struct wl_listener surface_destroy;
struct wl_listener surface_commit;
struct {
struct wl_signal destroy;
struct wl_signal ping_timeout;
struct wl_signal new_popup;
/**
* The `map` event signals that the shell surface is ready to be
* managed by the compositor and rendered on the screen. At this point,
* the surface has configured its properties, has had the opportunity
* to bind to the seat to receive input events, and has a buffer that
* is ready to be rendered. You can now safely add this surface to a
* list of views.
*/
struct wl_signal map;
/**
* The `unmap` event signals that the surface is no longer in a state
* where it should be shown on the screen. This might happen if the
* surface no longer has a displayable buffer because either the
* surface has been hidden or is about to be destroyed.
*/
struct wl_signal unmap;
} events;
void *data;
};
struct wlr_xdg_toplevel_v6_move_event {
struct wlr_xdg_surface_v6 *surface;
struct wlr_seat_client *seat;
uint32_t serial;
};
struct wlr_xdg_toplevel_v6_resize_event {
struct wlr_xdg_surface_v6 *surface;
struct wlr_seat_client *seat;
uint32_t serial;
uint32_t edges;
};
struct wlr_xdg_toplevel_v6_set_fullscreen_event {
struct wlr_xdg_surface_v6 *surface;
bool fullscreen;
struct wlr_output *output;
};
struct wlr_xdg_toplevel_v6_show_window_menu_event {
struct wlr_xdg_surface_v6 *surface;
struct wlr_seat_client *seat;
uint32_t serial;
uint32_t x, y;
};
struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display);
/**
* Send a ping to the surface. If the surface does not respond in a reasonable
* amount of time, the ping_timeout event will be emitted.
*/
void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface);
/**
* Request that this toplevel surface be the given size. Returns the associated
* configure serial.
*/
uint32_t wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface,
uint32_t width, uint32_t height);
/**
* Request that this toplevel surface show itself in an activated or deactivated
* state. Returns the associated configure serial.
*/
uint32_t wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface,
bool activated);
/**
* Request that this toplevel surface consider itself maximized or not
* maximized. Returns the associated configure serial.
*/
uint32_t wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface,
bool maximized);
/**
* Request that this toplevel surface consider itself fullscreen or not
* fullscreen. Returns the associated configure serial.
*/
uint32_t wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface,
bool fullscreen);
/**
* Request that this toplevel surface consider itself to be resizing or not
* resizing. Returns the associated configure serial.
*/
uint32_t wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface,
bool resizing);
/**
* Request that this xdg surface closes.
*/
void wlr_xdg_surface_v6_send_close(struct wlr_xdg_surface_v6 *surface);
/**
* Find a surface within this xdg-surface tree 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_xdg_surface_v6_surface_at(
struct wlr_xdg_surface_v6 *surface, double sx, double sy,
double *sub_x, double *sub_y);
/**
* Get the geometry for this positioner based on the anchor rect, gravity, and
* size of this positioner.
*/
struct wlr_box wlr_xdg_positioner_v6_get_geometry(
struct wlr_xdg_positioner_v6 *positioner);
/**
* Get the anchor point for this popup in the toplevel parent's coordinate system.
*/
void wlr_xdg_popup_v6_get_anchor_point(struct wlr_xdg_popup_v6 *popup,
int *toplevel_sx, int *toplevel_sy);
/**
* Convert the given coordinates in the popup coordinate system to the toplevel
* surface coordinate system.
*/
void wlr_xdg_popup_v6_get_toplevel_coords(struct wlr_xdg_popup_v6 *popup,
int popup_sx, int popup_sy, int *toplevel_sx, int *toplevel_sy);
/**
* Set the geometry of this popup to unconstrain it according to its
* xdg-positioner rules. The box should be in the popup's root toplevel parent
* surface coordinate system.
*/
void wlr_xdg_popup_v6_unconstrain_from_box(struct wlr_xdg_popup_v6 *popup,
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_v6_invert_x(
struct wlr_xdg_positioner_v6 *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_v6_invert_y(
struct wlr_xdg_positioner_v6 *positioner);
bool wlr_surface_is_xdg_surface_v6(struct wlr_surface *surface);
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_from_wlr_surface(
struct wlr_surface *surface);
/**
* Get the surface geometry.
* This is either the geometry as set by the client, or defaulted to the bounds
* of the surface + the subsurfaces (as specified by the protocol).
*
* The x and y value can be <0
*/
void wlr_xdg_surface_v6_get_geometry(struct wlr_xdg_surface_v6 *surface, struct wlr_box *box);
/**
* Call `iterator` on each surface and popup in the xdg-surface tree, with the
* surface's position relative to the root xdg-surface. The function is called
* from root to leaves (in rendering order).
*/
void wlr_xdg_surface_v6_for_each_surface(struct wlr_xdg_surface_v6 *surface,
wlr_surface_iterator_func_t iterator, void *user_data);
/**
* Call `iterator` on each popup in the xdg-surface tree, with the popup's
* position relative to the root xdg-surface. The function is called from root
* to leaves (in rendering order).
*/
void wlr_xdg_surface_v6_for_each_popup(struct wlr_xdg_surface_v6 *surface,
wlr_surface_iterator_func_t iterator, void *user_data);
#endif

View file

@ -19,10 +19,10 @@
enum wlr_edges {
WLR_EDGE_NONE = 0,
WLR_EDGE_TOP = 1,
WLR_EDGE_BOTTOM = 2,
WLR_EDGE_LEFT = 4,
WLR_EDGE_RIGHT = 8,
WLR_EDGE_TOP = 1 << 0,
WLR_EDGE_BOTTOM = 1 << 1,
WLR_EDGE_LEFT = 1 << 2,
WLR_EDGE_RIGHT = 1 << 3,
};
#endif

View file

@ -22,7 +22,7 @@ struct wlr_xwayland_cursor;
struct wlr_xwayland_server {
pid_t pid;
struct wl_client *client;
struct wl_event_source *sigusr1_source;
struct wl_event_source *pipe_source;
int wm_fd[2], wl_fd[2];
time_t server_start;
@ -84,7 +84,6 @@ struct wlr_xwayland {
struct wl_listener server_ready;
struct wl_listener server_destroy;
struct wl_listener client_destroy;
struct wl_listener seat_destroy;
void *data;
@ -173,6 +172,7 @@ struct wlr_xwayland_surface {
bool modal;
bool fullscreen;
bool maximized_vert, maximized_horz;
bool minimized;
bool has_alpha;
@ -181,6 +181,7 @@ struct wlr_xwayland_surface {
struct wl_signal request_configure;
struct wl_signal request_move;
struct wl_signal request_resize;
struct wl_signal request_minimize;
struct wl_signal request_maximize;
struct wl_signal request_fullscreen;
struct wl_signal request_activate;
@ -196,6 +197,7 @@ struct wlr_xwayland_surface {
struct wl_signal set_hints;
struct wl_signal set_decorations;
struct wl_signal set_override_redirect;
struct wl_signal set_geometry;
struct wl_signal ping_timeout;
} events;
@ -221,6 +223,11 @@ struct wlr_xwayland_resize_event {
uint32_t edges;
};
struct wlr_xwayland_minimize_event {
struct wlr_xwayland_surface *surface;
bool minimize;
};
struct wlr_xwayland_server *wlr_xwayland_server_create(
struct wl_display *display, struct wlr_xwayland_server_options *options);
void wlr_xwayland_server_destroy(struct wlr_xwayland_server *server);
@ -229,9 +236,6 @@ void wlr_xwayland_server_destroy(struct wlr_xwayland_server *server);
*
* The server supports a lazy mode in which Xwayland is only started when a
* client tries to connect.
*
* Note: wlr_xwayland will setup a global SIGUSR1 handler on the compositor
* process.
*/
struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display,
struct wlr_compositor *compositor, bool lazy);
@ -245,11 +249,22 @@ void wlr_xwayland_set_cursor(struct wlr_xwayland *wlr_xwayland,
void wlr_xwayland_surface_activate(struct wlr_xwayland_surface *surface,
bool activated);
/**
* Restack surface relative to sibling.
* If sibling is NULL, then the surface is moved to the top or the bottom
* of the stack (depending on the mode).
*/
void wlr_xwayland_surface_restack(struct wlr_xwayland_surface *surface,
struct wlr_xwayland_surface *sibling, enum xcb_stack_mode_t mode);
void wlr_xwayland_surface_configure(struct wlr_xwayland_surface *surface,
int16_t x, int16_t y, uint16_t width, uint16_t height);
void wlr_xwayland_surface_close(struct wlr_xwayland_surface *surface);
void wlr_xwayland_surface_set_minimized(struct wlr_xwayland_surface *surface,
bool minimized);
void wlr_xwayland_surface_set_maximized(struct wlr_xwayland_surface *surface,
bool maximized);

View file

@ -26,8 +26,10 @@
#ifndef XCURSOR_H
#define XCURSOR_H
typedef int XcursorBool;
typedef unsigned int XcursorUInt;
#include <stdint.h>
typedef int XcursorBool;
typedef uint32_t XcursorUInt;
typedef XcursorUInt XcursorDim;
typedef XcursorUInt XcursorPixel;

View file

@ -40,11 +40,14 @@ enum atom_name {
NET_ACTIVE_WINDOW,
NET_WM_MOVERESIZE,
NET_SUPPORTING_WM_CHECK,
NET_WM_STATE_FOCUSED,
NET_WM_STATE_MODAL,
NET_WM_STATE_FULLSCREEN,
NET_WM_STATE_MAXIMIZED_VERT,
NET_WM_STATE_MAXIMIZED_HORZ,
NET_WM_STATE_HIDDEN,
NET_WM_PING,
WM_CHANGE_STATE,
WM_STATE,
CLIPBOARD,
PRIMARY,
@ -125,6 +128,7 @@ struct wlr_xwm {
#if WLR_HAS_XCB_ERRORS
xcb_errors_context_t *errors_context;
#endif
unsigned int last_focus_seq;
struct wl_listener compositor_new_surface;
struct wl_listener compositor_destroy;