2017-09-23 08:26:01 +00:00
|
|
|
#ifndef WLR_BACKEND_SESSION_H
|
|
|
|
#define WLR_BACKEND_SESSION_H
|
2017-05-03 02:11:22 +00:00
|
|
|
|
2017-08-26 02:02:04 +00:00
|
|
|
#include <libudev.h>
|
2018-02-12 20:29:23 +00:00
|
|
|
#include <stdbool.h>
|
2017-05-14 01:07:34 +00:00
|
|
|
#include <sys/types.h>
|
2019-07-27 08:53:54 +00:00
|
|
|
#include <wayland-server-core.h>
|
2017-05-13 11:56:40 +00:00
|
|
|
|
2017-06-04 23:30:37 +00:00
|
|
|
struct session_impl;
|
2017-05-13 13:12:47 +00:00
|
|
|
|
2017-08-26 02:50:16 +00:00
|
|
|
struct wlr_device {
|
|
|
|
int fd;
|
|
|
|
dev_t dev;
|
|
|
|
struct wl_list link;
|
2020-11-06 09:16:07 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal change;
|
|
|
|
} events;
|
2017-08-26 02:50:16 +00:00
|
|
|
};
|
|
|
|
|
2017-05-13 13:12:47 +00:00
|
|
|
struct wlr_session {
|
2017-06-04 23:30:37 +00:00
|
|
|
const struct session_impl *impl;
|
2017-07-09 11:02:41 +00:00
|
|
|
/*
|
|
|
|
* Signal for when the session becomes active/inactive.
|
|
|
|
* It's called when we swap virtual terminal.
|
|
|
|
*/
|
2017-07-09 05:53:13 +00:00
|
|
|
bool active;
|
|
|
|
|
2018-06-14 08:46:16 +00:00
|
|
|
/*
|
|
|
|
* 0 if virtual terminals are not supported
|
|
|
|
* i.e. seat != "seat0"
|
|
|
|
*/
|
2017-07-09 05:53:13 +00:00
|
|
|
unsigned vtnr;
|
2018-06-14 08:46:16 +00:00
|
|
|
char seat[256];
|
2017-08-26 02:02:04 +00:00
|
|
|
|
|
|
|
struct udev *udev;
|
|
|
|
struct udev_monitor *mon;
|
|
|
|
struct wl_event_source *udev_event;
|
|
|
|
|
|
|
|
struct wl_list devices;
|
2017-12-08 10:17:56 +00:00
|
|
|
|
2020-11-06 10:14:49 +00:00
|
|
|
struct wl_display *display;
|
2017-12-08 10:17:56 +00:00
|
|
|
struct wl_listener display_destroy;
|
2018-08-26 21:23:12 +00:00
|
|
|
|
|
|
|
struct {
|
2020-11-06 10:34:55 +00:00
|
|
|
struct wl_signal active;
|
2020-11-06 09:56:13 +00:00
|
|
|
struct wl_signal add_drm_card; // struct wlr_session_add_event
|
2018-08-26 21:23:12 +00:00
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
2017-05-13 13:12:47 +00:00
|
|
|
};
|
2017-05-03 02:11:22 +00:00
|
|
|
|
2020-11-06 09:56:13 +00:00
|
|
|
struct wlr_session_add_event {
|
|
|
|
const char *path;
|
|
|
|
};
|
|
|
|
|
2017-07-09 11:02:41 +00:00
|
|
|
/*
|
|
|
|
* Opens a session, taking control of the current virtual terminal.
|
|
|
|
* This should not be called if another program is already in control
|
|
|
|
* of the terminal (Xorg, another Wayland compositor, etc.).
|
|
|
|
*
|
|
|
|
* If logind support is not enabled, you must have CAP_SYS_ADMIN or be root.
|
2018-05-03 20:59:43 +00:00
|
|
|
* It is safe to drop privileges after this is called.
|
2017-07-09 11:02:41 +00:00
|
|
|
*
|
|
|
|
* Returns NULL on error.
|
|
|
|
*/
|
2017-08-25 23:56:43 +00:00
|
|
|
struct wlr_session *wlr_session_create(struct wl_display *disp);
|
2017-07-09 11:02:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Closes a previously opened session and restores the virtual terminal.
|
|
|
|
* You should call wlr_session_close_file on each files you opened
|
|
|
|
* with wlr_session_open_file before you call this.
|
|
|
|
*/
|
2017-08-25 23:56:43 +00:00
|
|
|
void wlr_session_destroy(struct wlr_session *session);
|
2017-07-09 11:02:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Opens the file at path.
|
|
|
|
* This can only be used to open DRM or evdev (input) devices.
|
|
|
|
*
|
|
|
|
* When the session becomes inactive:
|
|
|
|
* - DRM files lose their DRM master status
|
|
|
|
* - evdev files become invalid and should be closed
|
|
|
|
*
|
|
|
|
* Returns -errno on error.
|
|
|
|
*/
|
2020-11-06 09:16:07 +00:00
|
|
|
struct wlr_device *wlr_session_open_file(struct wlr_session *session,
|
|
|
|
const char *path);
|
2017-07-09 11:02:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Closes a file previously opened with wlr_session_open_file.
|
|
|
|
*/
|
2020-11-06 09:16:07 +00:00
|
|
|
void wlr_session_close_file(struct wlr_session *session,
|
|
|
|
struct wlr_device *device);
|
2017-07-09 11:02:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Changes the virtual terminal.
|
|
|
|
*/
|
2017-07-09 05:53:13 +00:00
|
|
|
bool wlr_session_change_vt(struct wlr_session *session, unsigned vt);
|
2017-05-03 02:11:22 +00:00
|
|
|
|
2017-10-01 03:47:05 +00:00
|
|
|
size_t wlr_session_find_gpus(struct wlr_session *session,
|
2020-11-06 09:16:07 +00:00
|
|
|
size_t ret_len, struct wlr_device **ret);
|
2017-08-26 02:02:04 +00:00
|
|
|
|
2017-05-03 02:11:22 +00:00
|
|
|
#endif
|