aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fbcon.c10
-rw-r--r--fbi.c2
-rw-r--r--fbpdf.c2
-rw-r--r--kbd.c8
-rw-r--r--kbd.h2
-rw-r--r--kbdtest.c13
-rw-r--r--meson.build15
7 files changed, 35 insertions, 17 deletions
diff --git a/fbcon.c b/fbcon.c
index 4965472..d17efeb 100644
--- a/fbcon.c
+++ b/fbcon.c
@@ -611,12 +611,12 @@ int main(int argc, char *argv[])
exit(1);
exit_signals_init();
signal(SIGTSTP,SIG_IGN);
-#if 0
- if (console_switch_init(console_switch_suspend,
- console_switch_resume) < 0) {
- fprintf(stderr, "NOTICE: No vt switching available on terminal.\n");
+ if (!logind) {
+ if (console_switch_init(console_switch_suspend,
+ console_switch_resume) < 0) {
+ fprintf(stderr, "NOTICE: No vt switching available on terminal.\n");
+ }
}
-#endif
active = true;
/* init cairo */
diff --git a/fbi.c b/fbi.c
index ce3464c..8e6a5e8 100644
--- a/fbi.c
+++ b/fbi.c
@@ -1333,7 +1333,7 @@ int main(int argc, char *argv[])
shadow_init(gfx);
extents = shadow_font_init(fontname);
- kbd_init(use_libinput, gfx->devnum);
+ kbd_init(use_libinput, false, gfx->devnum);
if (use_libinput && (libinput_deverror != 0 ||
libinput_devcount == 0)) {
fprintf(stderr, "ERROR: failed to open input devices (%d ok, %d failed)\n",
diff --git a/fbpdf.c b/fbpdf.c
index b43733b..12b0aee 100644
--- a/fbpdf.c
+++ b/fbpdf.c
@@ -349,7 +349,7 @@ int main(int argc, char *argv[])
gfx->stride);
}
- kbd_init(use_libinput, gfx->devnum);
+ kbd_init(use_libinput, false, gfx->devnum);
if (use_libinput && (libinput_deverror != 0 ||
libinput_devcount == 0)) {
fprintf(stderr, "ERROR: failed to open input devices (%d ok, %d failed)\n",
diff --git a/kbd.c b/kbd.c
index 6b3b207..83c32be 100644
--- a/kbd.c
+++ b/kbd.c
@@ -12,6 +12,7 @@
#include <sys/stat.h>
#include "kbd.h"
+#include "logind.h"
#ifdef SYSTEM_LINUX
# include <linux/input.h>
@@ -295,7 +296,7 @@ const struct libinput_interface libinput_if_default = {
static struct libinput *ctx;
-void kbd_init(int use_libinput, dev_t gfx)
+void kbd_init(bool use_libinput, bool use_logind, dev_t gfx)
{
struct udev *udev;
struct udev_device *ugfx;
@@ -308,7 +309,10 @@ void kbd_init(int use_libinput, dev_t gfx)
seat = udev_device_get_property_value(ugfx, "ID_SEAT");
if (!seat)
seat = "seat0";
- ctx = libinput_udev_create_context(&libinput_if_default, NULL, udev);
+ ctx = libinput_udev_create_context(use_logind
+ ? &libinput_if_logind
+ : &libinput_if_default,
+ NULL, udev);
libinput_udev_assign_seat(ctx, seat);
fprintf(stderr, "kbd: using libinput (%d devices, %s)\n",
libinput_devcount, seat);
diff --git a/kbd.h b/kbd.h
index 81e32d8..e8f4af8 100644
--- a/kbd.h
+++ b/kbd.h
@@ -20,7 +20,7 @@ extern struct xkb_rule_names xkb_layout;
void xkb_configure(void);
void xkb_init(void);
-void kbd_init(int use_libinput, dev_t gfx);
+void kbd_init(bool use_libinput, bool use_logind, dev_t gfx);
int kbd_wait(int timeout);
int kbd_read(char *buf, uint32_t len,
uint32_t *keycode, uint32_t *modifier);
diff --git a/kbdtest.c b/kbdtest.c
index 215a216..2483ae2 100644
--- a/kbdtest.c
+++ b/kbdtest.c
@@ -10,6 +10,7 @@
#include <termios.h>
#include "kbd.h"
+#include "logind.h"
/* ---------------------------------------------------------------------- */
@@ -45,9 +46,11 @@ static void usage(FILE *fp)
int main(int argc, char *argv[])
{
+ const char *xdg_seat, *xdg_session_id;
uint32_t code, mod;
char key[32];
bool use_libinput = false;
+ bool use_logind = false;
int rc, i, c;
for (;;) {
@@ -67,7 +70,15 @@ int main(int argc, char *argv[])
}
}
- kbd_init(use_libinput, 0);
+ xdg_seat = getenv("XDG_SEAT");
+ xdg_session_id = getenv("XDG_SESSION_ID");
+ if (use_libinput && xdg_seat && xdg_session_id) {
+ if (logind_init(true, NULL, NULL) == 0) {
+ use_logind = true;
+ }
+ }
+
+ kbd_init(use_libinput, use_logind, 0);
for (;;) {
kbd_wait(10);
diff --git a/meson.build b/meson.build
index 6516aae..590fed8 100644
--- a/meson.build
+++ b/meson.build
@@ -91,12 +91,13 @@ add_global_arguments(['-include', 'config.h'], language : 'c')
# build fbi
fbi_srcs = [ 'fbi.c', 'fb-gui.c', 'desktop.c',
'parseconfig.c', 'fbiconfig.c',
- 'vt.c', 'kbd.c', 'fbtools.c', 'drmtools.c', 'gfx.c',
+ 'vt.c', 'kbd.c', 'logind.c',
+ 'fbtools.c', 'drmtools.c', 'gfx.c',
'filter.c', 'op.c', 'jpegtools.c',
trans_src, read_srcs ]
fbi_deps = [ drm_dep, pixman_dep, cairo_dep,
exif_dep, image_deps,
- math_dep, udev_dep, input_dep, xkb_dep ]
+ math_dep, udev_dep, input_dep, xkb_dep, systemd_dep ]
executable('fbi',
sources : fbi_srcs,
@@ -125,10 +126,11 @@ executable('thumbnail.cgi',
# build fbpdf
fbpdf_srcs = [ 'fbpdf.c', 'parseconfig.c', 'fbiconfig.c',
- 'vt.c', 'kbd.c', 'fbtools.c', 'drmtools.c', 'gfx.c' ]
+ 'vt.c', 'kbd.c', 'logind.c',
+ 'fbtools.c', 'drmtools.c', 'gfx.c' ]
fbpdf_deps = [ drm_dep, gbm_dep, epoxy_dep,
pixman_dep, poppler_dep, cairo_dep,
- udev_dep, input_dep, xkb_dep ]
+ udev_dep, input_dep, xkb_dep, systemd_dep ]
executable('fbpdf',
sources : fbpdf_srcs,
@@ -136,7 +138,8 @@ executable('fbpdf',
install : true)
# build fbcon
-fbcon_srcs = [ 'fbcon.c', 'drmtools.c', 'fbtools.c', 'gfx.c', 'vt.c', 'kbd.c', 'logind.c' ]
+fbcon_srcs = [ 'fbcon.c', 'drmtools.c', 'fbtools.c', 'gfx.c',
+ 'vt.c', 'kbd.c', 'logind.c' ]
fbcon_deps = [ drm_dep, cairo_dep, util_dep, udev_dep, input_dep, xkb_dep, glib_dep,
tsm_dep, systemd_dep ]
@@ -151,7 +154,7 @@ endif
# build kbdtest
executable('kbdtest',
- sources : [ 'kbdtest.c', 'kbd.c' ],
+ sources : [ 'kbdtest.c', 'kbd.c', 'logind.c' ],
dependencies : [ udev_dep, input_dep, xkb_dep, systemd_dep ] )
# build vttest