summaryrefslogtreecommitdiff
path: root/i3lock.c
diff options
context:
space:
mode:
authorSimeon Simeonov2023-03-14 23:30:32 +0100
committerSimeon Simeonov2023-03-18 13:37:27 +0100
commit66bd7af3e59e509000b8a55a9429e7a8e133fd81 (patch)
tree9eca5fe6eb76bb639fde682131c654eef17212df /i3lock.c
parentffc15cad8238b101203147d4c9da64ee8e5a05b8 (diff)
Sync with upstream 2.14.1 and update the documentation2.2.14
Diffstat (limited to 'i3lock.c')
-rw-r--r--i3lock.c47
1 files changed, 6 insertions, 41 deletions
diff --git a/i3lock.c b/i3lock.c
index 48edddb..aee9b2a 100644
--- a/i3lock.c
+++ b/i3lock.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * This file is part of i3lock-extended 2 * This file is part of i3lock-extended
3 * Copyright (C) 2020 Simeon Simeonov 3 * Copyright (C) 2020-2023 Simeon Simeonov
4 4
5 * i3lock-extended is free software: you can redistribute it and/or modify 5 * i3lock-extended is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -106,7 +106,7 @@ i3lock_led_clock_t i3lock_led_clock = {"ffff00",
106char *display_text = NULL; 106char *display_text = NULL;
107#endif 107#endif
108 108
109char color[7] = "ffffff"; 109char color[7] = "a3a3a3";
110uint32_t last_resolution[2]; 110uint32_t last_resolution[2];
111xcb_window_t win; 111xcb_window_t win;
112static xcb_cursor_t cursor; 112static xcb_cursor_t cursor;
@@ -132,9 +132,9 @@ int failed_attempts = 0;
132bool show_failed_attempts = false; 132bool show_failed_attempts = false;
133bool retry_verification = false; 133bool retry_verification = false;
134 134
135static struct xkb_state *xkb_state; 135struct xkb_state *xkb_state;
136static struct xkb_context *xkb_context; 136static struct xkb_context *xkb_context;
137static struct xkb_keymap *xkb_keymap; 137struct xkb_keymap *xkb_keymap;
138static struct xkb_compose_table *xkb_compose_table; 138static struct xkb_compose_table *xkb_compose_table;
139static struct xkb_compose_state *xkb_compose_state; 139static struct xkb_compose_state *xkb_compose_state;
140static uint8_t xkb_base_event; 140static uint8_t xkb_base_event;
@@ -360,41 +360,6 @@ static void input_done(void) {
360 if (debug_mode) 360 if (debug_mode)
361 fprintf(stderr, "Authentication failure\n"); 361 fprintf(stderr, "Authentication failure\n");
362 362
363 /* Get state of Caps and Num lock modifiers, to be displayed in
364 * STATE_AUTH_WRONG state */
365 xkb_mod_index_t idx, num_mods;
366 const char *mod_name;
367
368 num_mods = xkb_keymap_num_mods(xkb_keymap);
369
370 for (idx = 0; idx < num_mods; idx++) {
371 if (!xkb_state_mod_index_is_active(xkb_state, idx, XKB_STATE_MODS_EFFECTIVE))
372 continue;
373
374 mod_name = xkb_keymap_mod_get_name(xkb_keymap, idx);
375 if (mod_name == NULL)
376 continue;
377
378 /* Replace certain xkb names with nicer, human-readable ones. */
379 if (strcmp(mod_name, XKB_MOD_NAME_CAPS) == 0)
380 mod_name = "Caps Lock";
381 else if (strcmp(mod_name, XKB_MOD_NAME_ALT) == 0)
382 mod_name = "Alt";
383 else if (strcmp(mod_name, XKB_MOD_NAME_NUM) == 0)
384 mod_name = "Num Lock";
385 else if (strcmp(mod_name, XKB_MOD_NAME_LOGO) == 0)
386 mod_name = "Super";
387
388 char *tmp;
389 if (modifier_string == NULL) {
390 if (asprintf(&tmp, "%s", mod_name) != -1)
391 modifier_string = tmp;
392 } else if (asprintf(&tmp, "%s, %s", modifier_string, mod_name) != -1) {
393 free(modifier_string);
394 modifier_string = tmp;
395 }
396 }
397
398 auth_state = STATE_AUTH_WRONG; 363 auth_state = STATE_AUTH_WRONG;
399 failed_attempts += 1; 364 failed_attempts += 1;
400 clear_input(); 365 clear_input();
@@ -459,7 +424,7 @@ static void handle_key_press(xcb_key_press_event_t *event) {
459 return; 424 return;
460 case XKB_COMPOSE_COMPOSED: 425 case XKB_COMPOSE_COMPOSED:
461 /* xkb_compose_state_get_utf8 doesn't include the terminating byte in the return value 426 /* xkb_compose_state_get_utf8 doesn't include the terminating byte in the return value
462 * as xkb_keysym_to_utf8 does. Adding one makes the variable n consistent. */ 427 * as xkb_keysym_to_utf8 does. Adding one makes the variable n consistent. */
463 n = xkb_compose_state_get_utf8(xkb_compose_state, buffer, sizeof(buffer)) + 1; 428 n = xkb_compose_state_get_utf8(xkb_compose_state, buffer, sizeof(buffer)) + 1;
464 ksym = xkb_compose_state_get_one_sym(xkb_compose_state); 429 ksym = xkb_compose_state_get_one_sym(xkb_compose_state);
465 composed = true; 430 composed = true;
@@ -1131,7 +1096,7 @@ int main(int argc, char *argv[]) {
1131 while ((o = getopt_long(argc, argv, optstring, longopts, &longoptind)) != -1) { 1096 while ((o = getopt_long(argc, argv, optstring, longopts, &longoptind)) != -1) {
1132 switch (o) { 1097 switch (o) {
1133 case 'v': 1098 case 'v':
1134 errx(EXIT_SUCCESS, "version " I3LOCK_VERSION " © 2010 Michael Stapelberg, 2017-2020 Simeon Simeonov"); 1099 errx(EXIT_SUCCESS, "version " I3LOCK_VERSION " © 2010 Michael Stapelberg, 2020-2023 Simeon Simeonov");
1135 case 'n': 1100 case 'n':
1136 dont_fork = true; 1101 dont_fork = true;
1137 break; 1102 break;