aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--config.c3
-rw-r--r--config.h1
-rw-r--r--keyboard.c9
-rw-r--r--main.c3
5 files changed, 16 insertions, 5 deletions
diff --git a/README.md b/README.md
index 4ffab6a..f82451f 100644
--- a/README.md
+++ b/README.md
@@ -17,9 +17,10 @@ Q: What is an ENU?
## Configuration
Create your config file at `XDG_CONFIG_HOME/swenu/conf.ini` or `HOME/.config/swenu/conf.ini`.
-Example config file:
+Example config: (hex colors also supported!)
```ini
fancy_scroll = false
+exit_on_focus_lost = true
min_width = 500
font_size = 16
@@ -44,7 +45,7 @@ cursor_color = (0.9, 0.9, 0.9, 0.5)
- [x] "prompt"
- [x] fuzzy filter
- [x] config file
-- [ ] border, top padding in vertical and set exact height
+- [ ] border, top padding and set exact height
- [ ] unicode + text shaping
Stretch:
diff --git a/config.c b/config.c
index 4e6fbd0..33cf9cf 100644
--- a/config.c
+++ b/config.c
@@ -9,6 +9,7 @@
config_t config = {
// default config
.fancy_scroll = false,
+ .exit_on_focus_lost = true,
.min_width = 500,
.font_size = 16,
.text_color = {0.85, 0.85, 0.85, 1.0},
@@ -108,6 +109,8 @@ static int our_ini_handler(void* user, const char* section, const char* name, co
#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
if (MATCH("", "fancy_scroll")) {
config->fancy_scroll = parse_bool(value);
+ } else if (MATCH("", "exit_on_focus_lost")) {
+ config->exit_on_focus_lost = parse_bool(value);
} else if (MATCH("", "min_width")) {
config->min_width = atoi(value);
} else if (MATCH("", "font_size")) {
diff --git a/config.h b/config.h
index dd1488f..eba53ae 100644
--- a/config.h
+++ b/config.h
@@ -10,6 +10,7 @@ typedef struct {
typedef struct {
bool fancy_scroll;
+ bool exit_on_focus_lost;
uint32_t min_width;
uint32_t font_size;
color_t text_color;
diff --git a/keyboard.c b/keyboard.c
index 1ab8f9e..8341fd1 100644
--- a/keyboard.c
+++ b/keyboard.c
@@ -2,6 +2,7 @@
#include <unistd.h>
#include <locale.h>
+#include "config.h"
#include "state.h"
#include "input_field.h"
@@ -67,9 +68,11 @@ void wl_keyboard_leave(void *data, struct wl_keyboard *wl_keyboard,
uint32_t serial, struct wl_surface *surface) {
client_state *state = data;
- // close on focus lost
- state->running = false;
- state->exit_code = EXIT_FAILURE;
+ // exit on focus lost
+ if (config.exit_on_focus_lost) {
+ state->running = false;
+ state->exit_code = EXIT_FAILURE;
+ }
}
void wl_keyboard_key(void *data, struct wl_keyboard *wl_keyboard,
diff --git a/main.c b/main.c
index b9d6ff0..d6d71f4 100644
--- a/main.c
+++ b/main.c
@@ -115,6 +115,9 @@ int main(int argc, char* argv[]) {
wl_display_dispatch(state.display);
}
+ // leak 8 bytes of memory
+ malloc(8);
+
// cleanup (of course)
if (state.items) {
array_for_all(item_t, item, state.items) {