aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fbcon.c19
-rw-r--r--logind.c37
-rw-r--r--logind.h1
3 files changed, 55 insertions, 2 deletions
diff --git a/fbcon.c b/fbcon.c
index d795b9f..8b8577f 100644
--- a/fbcon.c
+++ b/fbcon.c
@@ -56,6 +56,7 @@ static struct cairo_state {
static int dirty, pty;
static struct udev *udev;
static struct libinput *kbd;
+static bool logind = false;
static struct xkb_context *xkb;
static struct xkb_keymap *map;
@@ -171,11 +172,13 @@ static void cleanup_and_exit(int code)
static void console_switch_suspend(void)
{
libinput_suspend(kbd);
+ logind_release_control();
}
static void console_switch_resume(void)
{
gfx->restore_display();
+ logind_take_control();
libinput_resume(kbd);
state1.clear++;
state2.clear++;
@@ -436,6 +439,19 @@ static void fbcon_handle_keydown(struct xkb_state *state,
return;
}
+#if 0
+ /* WIP & broken */
+ if (logind && ctrlalt) {
+ if (sym >= XKB_KEY_F1 && sym <= XKB_KEY_F12) {
+ int vt = sym - XKB_KEY_F1 + 1;
+ fprintf(stderr, "console switch to vt %d\n", vt);
+ console_switch_suspend();
+ logind_switch_vt(vt);
+ return;
+ }
+ }
+#endif
+
/* scrollback */
if (shift && sym == XKB_KEY_Up) {
tsm_screen_sb_up(vts, 1);
@@ -520,8 +536,7 @@ int main(int argc, char *argv[])
const char *drm_node = NULL;
const char *fb_node = NULL;
const char *xdg_seat, *xdg_session_id;
- bool logind = false;
- int input, dbus;
+ int input, dbus = 0;
pid_t child;
setlocale(LC_ALL,"");
diff --git a/logind.c b/logind.c
index a2e9add..9e64013 100644
--- a/logind.c
+++ b/logind.c
@@ -69,6 +69,33 @@ void logind_dbus_input(void)
} while (ret > 0);
}
+int logind_switch_vt(int vt)
+{
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+ sd_bus_message *m = NULL;
+ int r;
+
+ if (!logind_dbus)
+ return -1;
+
+ r = sd_bus_call_method(logind_dbus,
+ "org.freedesktop.login1",
+ "/org/freedesktop/login1/seat/self",
+ "org.freedesktop.login1.Seat",
+ "SwitchTo",
+ &error,
+ &m,
+ "u",
+ vt);
+ if (r < 0) {
+ fprintf(stderr, "SwitchTo failed: %s\n", error.message);
+ sd_bus_error_free(&error);
+ }
+ sd_bus_message_unref(m);
+
+ return r;
+}
+
int logind_take_control(void)
{
sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -230,11 +257,21 @@ void logind_dbus_input(void)
{
}
+int logind_switch_vt(int vt)
+{
+ return -1;
+}
+
int logind_take_control(void)
{
return -1;
}
+int logind_release_control(void)
+{
+ return -1;
+}
+
int logind_open(const char *path, int flags, void *user_data)
{
fprintf(stderr, "error: compiled without logind support.\n");
diff --git a/logind.h b/logind.h
index e36a329..89c4c0c 100644
--- a/logind.h
+++ b/logind.h
@@ -9,6 +9,7 @@ extern const struct libinput_interface libinput_if_logind;
int logind_init(void);
int logind_dbus_fd(void);
void logind_dbus_input(void);
+int logind_switch_vt(int vt);
int logind_take_control(void);
int logind_release_control(void);
int logind_open(const char *path, int flags, void *user_data);