libweston/launcher: Allow VT switch without get_vt

get_vt is used to check if VTs are enabled, by verifying that a VT greater than
0 is returned.

libseat always implements switching, with switch to an active session
currently being a noop in all backends. libseat does not currently have
a get_vt implementation. Make get_vt errors more explicit, and allow VT
switching anyway if the error is ENOSYS.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
This commit is contained in:
Kenny Levinsen 2020-11-22 14:52:14 +01:00 committed by Pekka Paalanen
parent 6c4a993a99
commit 97d421a7e8
2 changed files with 7 additions and 1 deletions

View file

@ -860,6 +860,9 @@ static int
launcher_logind_get_vt(struct weston_launcher *launcher)
{
struct launcher_logind *wl = wl_container_of(launcher, wl, base);
if (wl->vtnr <= 0) {
return -EINVAL;
}
return wl->vtnr;
}

View file

@ -31,6 +31,7 @@
#include "launcher-util.h"
#include "launcher-impl.h"
#include <errno.h>
#include <stdint.h>
#include <unistd.h>
#include <linux/input.h>
@ -107,10 +108,12 @@ switch_vt_binding(struct weston_keyboard *keyboard,
WL_EXPORT void
weston_setup_vt_switch_bindings(struct weston_compositor *compositor)
{
int ret;
uint32_t key;
struct weston_launcher *launcher = compositor->launcher;
if (launcher->iface->get_vt(launcher) <= 0)
ret = launcher->iface->get_vt(launcher);
if (ret < 0 && ret != -ENOSYS)
return;
if (compositor->vt_switching == false)