summaryrefslogtreecommitdiffstats
path: root/swaylock
diff options
context:
space:
mode:
Diffstat (limited to 'swaylock')
-rw-r--r--swaylock/main.c33
-rw-r--r--swaylock/password.c8
-rw-r--r--swaylock/seat.c6
3 files changed, 19 insertions, 28 deletions
diff --git a/swaylock/main.c b/swaylock/main.c
index 9aeb4e64..9a4f3b58 100644
--- a/swaylock/main.c
+++ b/swaylock/main.c
@@ -23,7 +23,6 @@
23#include "cairo.h" 23#include "cairo.h"
24#include "log.h" 24#include "log.h"
25#include "loop.h" 25#include "loop.h"
26#include "readline.h"
27#include "stringop.h" 26#include "stringop.h"
28#include "util.h" 27#include "util.h"
29#include "wlr-input-inhibitor-unstable-v1-client-protocol.h" 28#include "wlr-input-inhibitor-unstable-v1-client-protocol.h"
@@ -808,36 +807,32 @@ static int load_config(char *path, struct swaylock_state *state,
808 wlr_log(WLR_ERROR, "Failed to read config. Running without it."); 807 wlr_log(WLR_ERROR, "Failed to read config. Running without it.");
809 return 0; 808 return 0;
810 } 809 }
811 char *line; 810 char *line = NULL;
811 size_t line_size = 0;
812 ssize_t nread;
812 int line_number = 0; 813 int line_number = 0;
813 while (!feof(config)) { 814 int result = 0;
814 line = read_line(config); 815 while ((nread = getline(&line, &line_size, config)) != -1) {
815 if (!line) {
816 continue;
817 }
818
819 line_number++; 816 line_number++;
820 if (line[0] == '#') { 817
821 free(line); 818 if (line[nread - 1] == '\n') {
822 continue; 819 line[--nread] = '\0';
823 } 820 }
824 if (strlen(line) == 0) { 821
825 free(line); 822 if (!*line || line[0] == '#') {
826 continue; 823 continue;
827 } 824 }
828 825
829 wlr_log(WLR_DEBUG, "Config Line #%d: %s", line_number, line); 826 wlr_log(WLR_DEBUG, "Config Line #%d: %s", line_number, line);
830 char flag[strlen(line) + 3]; 827 char flag[nread + 3];
831 sprintf(flag, "--%s", line); 828 sprintf(flag, "--%s", line);
832 char *argv[] = {"swaylock", flag}; 829 char *argv[] = {"swaylock", flag};
833 int result = parse_options(2, argv, state, line_mode, NULL); 830 result = parse_options(2, argv, state, line_mode, NULL);
834 if (result != 0) { 831 if (result != 0) {
835 free(line); 832 break;
836 fclose(config);
837 return result;
838 } 833 }
839 free(line);
840 } 834 }
835 free(line);
841 fclose(config); 836 fclose(config);
842 return 0; 837 return 0;
843} 838}
diff --git a/swaylock/password.c b/swaylock/password.c
index 3059203a..3bd113ad 100644
--- a/swaylock/password.c
+++ b/swaylock/password.c
@@ -146,14 +146,6 @@ void swaylock_handle_key(struct swaylock_state *state,
146 schedule_indicator_clear(state); 146 schedule_indicator_clear(state);
147 break; 147 break;
148 case XKB_KEY_Caps_Lock: 148 case XKB_KEY_Caps_Lock:
149 /* The state is getting active after this
150 * so we need to manually toggle it */
151 state->xkb.caps_lock = !state->xkb.caps_lock;
152 state->auth_state = AUTH_STATE_INPUT_NOP;
153 damage_state(state);
154 schedule_indicator_clear(state);
155 schedule_password_clear(state);
156 break;
157 case XKB_KEY_Shift_L: 149 case XKB_KEY_Shift_L:
158 case XKB_KEY_Shift_R: 150 case XKB_KEY_Shift_R:
159 case XKB_KEY_Control_L: 151 case XKB_KEY_Control_L:
diff --git a/swaylock/seat.c b/swaylock/seat.c
index 7b72114f..f0b1385e 100644
--- a/swaylock/seat.c
+++ b/swaylock/seat.c
@@ -63,8 +63,12 @@ static void keyboard_modifiers(void *data, struct wl_keyboard *wl_keyboard,
63 struct swaylock_state *state = data; 63 struct swaylock_state *state = data;
64 xkb_state_update_mask(state->xkb.state, 64 xkb_state_update_mask(state->xkb.state,
65 mods_depressed, mods_latched, mods_locked, 0, 0, group); 65 mods_depressed, mods_latched, mods_locked, 0, 0, group);
66 state->xkb.caps_lock = xkb_state_mod_name_is_active(state->xkb.state, 66 int caps_lock = xkb_state_mod_name_is_active(state->xkb.state,
67 XKB_MOD_NAME_CAPS, XKB_STATE_MODS_LOCKED); 67 XKB_MOD_NAME_CAPS, XKB_STATE_MODS_LOCKED);
68 if (caps_lock != state->xkb.caps_lock) {
69 state->xkb.caps_lock = caps_lock;
70 damage_state(state);
71 }
68 state->xkb.control = xkb_state_mod_name_is_active(state->xkb.state, 72 state->xkb.control = xkb_state_mod_name_is_active(state->xkb.state,
69 XKB_MOD_NAME_CTRL, 73 XKB_MOD_NAME_CTRL,
70 XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED); 74 XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED);