diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-08-05 23:11:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-05 23:11:26 -0400 |
commit | f95c02eebe54785a4f64332f7e574dddff7e3669 (patch) | |
tree | 0e29dfa81a30d6172c558d2b5df6d95f31a32b20 /include/wlr/backend | |
parent | 41b98f21e50a6d57ba4b7fd8ba90066bba614e6a (diff) | |
parent | 5bf61ca7edb658737f3ccbaed0a99f4779d329bb (diff) |
Merge pull request #29 from ascent12/session
Moved session into backend/session and changed ownership
Diffstat (limited to 'include/wlr/backend')
-rw-r--r-- | include/wlr/backend/drm.h | 2 | ||||
-rw-r--r-- | include/wlr/backend/libinput.h | 2 | ||||
-rw-r--r-- | include/wlr/backend/multi.h | 9 | ||||
-rw-r--r-- | include/wlr/backend/session.h | 65 | ||||
-rw-r--r-- | include/wlr/backend/session/interface.h | 14 |
5 files changed, 89 insertions, 3 deletions
diff --git a/include/wlr/backend/drm.h b/include/wlr/backend/drm.h index a486757d..7332d608 100644 --- a/include/wlr/backend/drm.h +++ b/include/wlr/backend/drm.h @@ -2,7 +2,7 @@ #define WLR_BACKEND_DRM_H #include <wayland-server.h> -#include <wlr/session.h> +#include <wlr/backend/session.h> #include <wlr/backend.h> #include <wlr/backend/udev.h> diff --git a/include/wlr/backend/libinput.h b/include/wlr/backend/libinput.h index 29748b77..bba68888 100644 --- a/include/wlr/backend/libinput.h +++ b/include/wlr/backend/libinput.h @@ -3,7 +3,7 @@ #include <libinput.h> #include <wayland-server.h> -#include <wlr/session.h> +#include <wlr/backend/session.h> #include <wlr/backend.h> #include <wlr/backend/udev.h> #include <wlr/types/wlr_input_device.h> diff --git a/include/wlr/backend/multi.h b/include/wlr/backend/multi.h index a07ca770..e8e46bed 100644 --- a/include/wlr/backend/multi.h +++ b/include/wlr/backend/multi.h @@ -2,9 +2,16 @@ #define _WLR_BACKEND_MULTI_H #include <wlr/backend.h> +#include <wlr/backend/udev.h> +#include <wlr/backend/session.h> -struct wlr_backend *wlr_multi_backend_create(); +struct wlr_backend *wlr_multi_backend_create(struct wlr_session *session, + struct wlr_udev *udev); void wlr_multi_backend_add(struct wlr_backend *multi, struct wlr_backend *backend); +bool wlr_backend_is_multi(struct wlr_backend *backend); + +struct wlr_session *wlr_multi_get_session(struct wlr_backend *base); + #endif diff --git a/include/wlr/backend/session.h b/include/wlr/backend/session.h new file mode 100644 index 00000000..7961e620 --- /dev/null +++ b/include/wlr/backend/session.h @@ -0,0 +1,65 @@ +#ifndef WLR_SESSION_H +#define WLR_SESSION_H + +#include <stdbool.h> +#include <wayland-server.h> +#include <sys/types.h> + +struct session_impl; + +struct wlr_session { + const struct session_impl *impl; + /* + * Signal for when the session becomes active/inactive. + * It's called when we swap virtual terminal. + */ + struct wl_signal session_signal; + bool active; + + int drm_fd; + unsigned vtnr; + char seat[8]; +}; + +/* + * 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. + * It is safe to drop priviledges after this is called. + * + * Returns NULL on error. + */ +struct wlr_session *wlr_session_start(struct wl_display *disp); + +/* + * 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. + */ +void wlr_session_finish(struct wlr_session *session); + +/* + * 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. + */ +int 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); + +/* + * Changes the virtual terminal. + */ +bool wlr_session_change_vt(struct wlr_session *session, unsigned vt); + +#endif diff --git a/include/wlr/backend/session/interface.h b/include/wlr/backend/session/interface.h new file mode 100644 index 00000000..16814446 --- /dev/null +++ b/include/wlr/backend/session/interface.h @@ -0,0 +1,14 @@ +#ifndef WLR_SESSION_INTERFACE_H +#define WLR_SESSION_INTERFACE_H + +#include <wlr/backend/session.h> + +struct session_impl { + struct wlr_session *(*start)(struct wl_display *disp); + void (*finish)(struct wlr_session *session); + int (*open)(struct wlr_session *session, const char *path); + void (*close)(struct wlr_session *session, int fd); + bool (*change_vt)(struct wlr_session *session, unsigned vt); +}; + +#endif |