Merge branch 'wscons' into 'master'

Draft: Add OpenBSD/wscons support

See merge request wlroots/wlroots!5378
This commit is contained in:
illiliti 2026-06-13 10:25:16 +00:00
commit 90cf273319
24 changed files with 1531 additions and 179 deletions

View file

@ -2,6 +2,31 @@
#define BACKEND_SESSION_SESSION_H
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
#include <xf86drm.h>
// for some reason libdrm does not define MAX3, but has defs that depend on it
#define MAX3(a, b, c) ((a) > (b) && (a) > (c) ? (a) : \
(b) > (c) ? (b) : (c))
struct drm_event_monitor;
enum drm_event_action {
DRM_EVENT_ACTION_NONE,
DRM_EVENT_ACTION_ADD,
DRM_EVENT_ACTION_CHANGE,
DRM_EVENT_ACTION_REMOVE,
};
struct drm_event_content {
char devnode[DRM_NODE_NAME_MAX];
dev_t devnum;
enum drm_event_action type;
int16_t conn_id;
int16_t prop_id;
bool has_lease;
};
struct wl_display;
struct wlr_session;
@ -17,4 +42,13 @@ void session_init(struct wlr_session *session);
struct wlr_device *session_open_if_kms(struct wlr_session *session,
const char *path);
struct drm_event_monitor *monitor_drm_events(int *fd);
void drm_event_monitor_free(struct drm_event_monitor *ctx);
int receive_drm_device(struct drm_event_monitor *ctx,
struct drm_event_content *ev);
const char *get_device_seat(struct drm_event_monitor *ctx, const char *devnode);
bool is_drm_device_primary(struct drm_event_monitor *ctx, const char *devnode);
#endif

32
include/backend/wscons.h Normal file
View file

@ -0,0 +1,32 @@
#ifndef BACKEND_WSCONS_H
#define BACKEND_WSCONS_H
#include <wayland-server-core.h>
#include <wlr/backend/interface.h>
#include <wlr/backend/wscons.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/backend/session.h>
struct wlr_wscons_backend {
struct wlr_backend backend;
struct wlr_device *mouse_dev;
struct wlr_device *kbd_dev;
struct wlr_keyboard kbd;
struct wlr_pointer mouse;
unsigned kbd_type;
int kqueue_fd;
struct wlr_session *session;
struct wl_event_source *input_event;
struct wl_listener session_destroy;
};
extern const struct wlr_keyboard_impl wscons_keyboard_impl;
extern const struct wlr_pointer_impl wscons_pointer_impl;
#endif

View file

@ -23,6 +23,9 @@ endif
if not features.get('session')
exclude_files += 'backend/session.h'
endif
if not features.get('wscons-backend')
exclude_files += 'backend/wscons.h'
endif
install_subdir('wlr',
install_dir: get_option('includedir') / versioned_name,

View file

@ -6,6 +6,7 @@
#include <wayland-server-core.h>
struct libseat;
struct drm_event_monitor;
/**
* An opened physical device.
@ -45,9 +46,8 @@ struct wlr_session {
char seat[256];
struct udev *udev;
struct udev_monitor *mon;
struct wl_event_source *udev_event;
struct drm_event_monitor *drm_handle;
struct wl_event_source *drm_event;
struct libseat *seat_handle;
struct wl_event_source *libseat_event;

View file

@ -0,0 +1,23 @@
/*
* 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_WSCONS_H
#define WLR_BACKEND_WSCONS_H
#include <wayland-server-core.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
struct wlr_input_device;
struct wlr_backend *wlr_wscons_backend_create(struct wlr_session *session);
bool wlr_backend_is_wscons(const struct wlr_backend *backend);
bool wlr_input_device_is_wscons(struct wlr_input_device *device);
#endif

View file

@ -15,6 +15,13 @@
* Required for <wlr/backend/libinput.h>.
*/
#mesondefine WLR_HAS_LIBINPUT_BACKEND
/**
* Whether the wscons backend is compile-time enabled. Equivalent to the
* pkg-config "have_wscons_backend" vartiable.
*
* Required for <wlr/backend/wscons.h>.
*/
#mesondefine WLR_HAS_WSCONS_BACKEND
/**
* Whether the X11 backend is compile-time enabled. Equivalent to the
* pkg-config "have_x11_backend" variable.