From 5c3ad9bf9a20e7be2f5a0693e4005baf5ac75334 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Sun, 14 Nov 2021 12:50:06 +0100 Subject: [PATCH] Add autohide config option --- config.c | 10 +++++++--- config.h | 2 ++ main.c | 2 +- unl0kr.conf | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/config.c b/config.c index edb10b1..a0e8c5a 100644 --- a/config.c +++ b/config.c @@ -100,8 +100,8 @@ static int parsing_handler(void* user_data, const char* section, const char* key } } } else if (strcmp(section, "keyboard") == 0) { - if (strcmp(key, "popovers") == 0) { - if (parse_bool(value, &(opts->keyboard.popovers))) { + if (strcmp(key, "autohide") == 0) { + if (parse_bool(value, &(opts->keyboard.autohide))) { return 1; } } else if (strcmp(key, "layout") == 0) { @@ -110,7 +110,11 @@ static int parsing_handler(void* user_data, const char* section, const char* key opts->keyboard.layout_id = id; return 1; } - }; + } else if (strcmp(key, "popovers") == 0) { + if (parse_bool(value, &(opts->keyboard.popovers))) { + return 1; + } + } } ul_log(UL_LOG_LEVEL_ERROR, "Ignoring invalid config value \"%s\" for key \"%s\" in section \"%s\"", value, key, section); diff --git a/config.h b/config.h index 4e1ef0b..ba5e850 100644 --- a/config.h +++ b/config.h @@ -45,6 +45,8 @@ typedef struct { * Options related to the keyboard */ typedef struct { + /* If true, hide the keyboard on launch when a hardware keyboard is connected */ + bool autohide; /* Keyboard layout */ sq2lv_layout_id_t layout_id; /* If true, display key popovers on press */ diff --git a/main.c b/main.c index 07dac68..f5a0ac1 100644 --- a/main.c +++ b/main.c @@ -329,7 +329,7 @@ int main(int argc, char *argv[]) { ul_indev_set_up_mouse_cursor(); /* Hide the on-screen keyboard by default if a physical keyboard is connected */ - if (ul_indev_is_keyboard_connected()) { + if (conf_opts.keyboard.autohide && ul_indev_is_keyboard_connected()) { is_keyboard_hidden = true; } diff --git a/unl0kr.conf b/unl0kr.conf index 2c288a1..18ae55c 100644 --- a/unl0kr.conf +++ b/unl0kr.conf @@ -5,5 +5,6 @@ animations=true obscured=true [keyboard] -popovers=true +autohide=true layout=de +popovers=true