diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 52 |
1 files changed, 11 insertions, 41 deletions
diff --git a/sway/commands.c b/sway/commands.c index f748a969..963d8f12 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -99,22 +99,6 @@ static sway_cmd bar_colors_cmd_urgent_workspace; | |||
99 | swayc_t *sp_view; | 99 | swayc_t *sp_view; |
100 | int sp_index = 0; | 100 | int sp_index = 0; |
101 | 101 | ||
102 | static struct modifier_key { | ||
103 | char *name; | ||
104 | uint32_t mod; | ||
105 | } modifiers[] = { | ||
106 | { XKB_MOD_NAME_SHIFT, WLC_BIT_MOD_SHIFT }, | ||
107 | { XKB_MOD_NAME_CAPS, WLC_BIT_MOD_CAPS }, | ||
108 | { XKB_MOD_NAME_CTRL, WLC_BIT_MOD_CTRL }, | ||
109 | { "Ctrl", WLC_BIT_MOD_CTRL }, | ||
110 | { XKB_MOD_NAME_ALT, WLC_BIT_MOD_ALT }, | ||
111 | { "Alt", WLC_BIT_MOD_ALT }, | ||
112 | { XKB_MOD_NAME_NUM, WLC_BIT_MOD_MOD2 }, | ||
113 | { "Mod3", WLC_BIT_MOD_MOD3 }, | ||
114 | { XKB_MOD_NAME_LOGO, WLC_BIT_MOD_LOGO }, | ||
115 | { "Mod5", WLC_BIT_MOD_MOD5 }, | ||
116 | }; | ||
117 | |||
118 | static char *bg_options[] = { | 102 | static char *bg_options[] = { |
119 | "stretch", | 103 | "stretch", |
120 | "center", | 104 | "center", |
@@ -187,16 +171,11 @@ static struct cmd_results *cmd_bindsym(int argc, char **argv) { | |||
187 | list_t *split = split_string(argv[0], "+"); | 171 | list_t *split = split_string(argv[0], "+"); |
188 | for (int i = 0; i < split->length; ++i) { | 172 | for (int i = 0; i < split->length; ++i) { |
189 | // Check for a modifier key | 173 | // Check for a modifier key |
190 | int j; | 174 | uint32_t mod; |
191 | bool is_mod = false; | 175 | if ((mod = get_modifier_mask_by_name(split->items[i])) > 0) { |
192 | for (j = 0; j < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++j) { | 176 | binding->modifiers |= mod; |
193 | if (strcasecmp(modifiers[j].name, split->items[i]) == 0) { | 177 | continue; |
194 | binding->modifiers |= modifiers[j].mod; | ||
195 | is_mod = true; | ||
196 | break; | ||
197 | } | ||
198 | } | 178 | } |
199 | if (is_mod) continue; | ||
200 | // Check for xkb key | 179 | // Check for xkb key |
201 | xkb_keysym_t sym = xkb_keysym_from_name(split->items[i], XKB_KEYSYM_CASE_INSENSITIVE); | 180 | xkb_keysym_t sym = xkb_keysym_from_name(split->items[i], XKB_KEYSYM_CASE_INSENSITIVE); |
202 | if (!sym) { | 181 | if (!sym) { |
@@ -408,17 +387,13 @@ static struct cmd_results *cmd_floating_mod(int argc, char **argv) { | |||
408 | if ((error = checkarg(argc, "floating_modifier", EXPECTED_AT_LEAST, 1))) { | 387 | if ((error = checkarg(argc, "floating_modifier", EXPECTED_AT_LEAST, 1))) { |
409 | return error; | 388 | return error; |
410 | } | 389 | } |
411 | int i, j; | 390 | int i; |
412 | list_t *split = split_string(argv[0], "+"); | 391 | list_t *split = split_string(argv[0], "+"); |
413 | config->floating_mod = 0; | 392 | config->floating_mod = 0; |
414 | 393 | ||
415 | // set modifier keys | 394 | // set modifier keys |
416 | for (i = 0; i < split->length; ++i) { | 395 | for (i = 0; i < split->length; ++i) { |
417 | for (j = 0; j < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++j) { | 396 | config->floating_mod |= get_modifier_mask_by_name(split->items[i]); |
418 | if (strcasecmp(modifiers[j].name, split->items[i]) == 0) { | ||
419 | config->floating_mod |= modifiers[j].mod; | ||
420 | } | ||
421 | } | ||
422 | } | 397 | } |
423 | free_flat_list(split); | 398 | free_flat_list(split); |
424 | if (!config->floating_mod) { | 399 | if (!config->floating_mod) { |
@@ -1893,16 +1868,11 @@ static struct cmd_results *bar_cmd_modifier(int argc, char **argv) { | |||
1893 | 1868 | ||
1894 | list_t *split = split_string(argv[0], "+"); | 1869 | list_t *split = split_string(argv[0], "+"); |
1895 | for (int i = 0; i < split->length; ++i) { | 1870 | for (int i = 0; i < split->length; ++i) { |
1896 | int j; | 1871 | uint32_t tmp_mod; |
1897 | bool is_mod = false; | 1872 | if ((tmp_mod = get_modifier_mask_by_name(split->items[i])) > 0) { |
1898 | for (j = 0; j < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++j) { | 1873 | mod |= tmp_mod; |
1899 | if (strcasecmp(modifiers[j].name, split->items[i]) == 0) { | 1874 | continue; |
1900 | mod = modifiers[j].mod; | 1875 | } else { |
1901 | is_mod = true; | ||
1902 | break; | ||
1903 | } | ||
1904 | } | ||
1905 | if (!is_mod) { | ||
1906 | free_flat_list(split); | 1876 | free_flat_list(split); |
1907 | return cmd_results_new(CMD_INVALID, "modifier", "Unknown modifier '%s'", split->items[i]); | 1877 | return cmd_results_new(CMD_INVALID, "modifier", "Unknown modifier '%s'", split->items[i]); |
1908 | } | 1878 | } |