diff options
-rw-r--r-- | sway/commands.c | 19 | ||||
-rw-r--r-- | sway/handlers.c | 10 |
2 files changed, 22 insertions, 7 deletions
diff --git a/sway/commands.c b/sway/commands.c index cc51717b..37bd9b00 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -240,7 +240,24 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv) | |||
240 | if (!checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1)) { | 240 | if (!checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1)) { |
241 | return false; | 241 | return false; |
242 | } | 242 | } |
243 | config->floating_mod = xkb_keysym_from_name(argv[0], XKB_KEYSYM_CASE_INSENSITIVE); | 243 | int i, j; |
244 | list_t *split = split_string(argv[0], "+"); | ||
245 | fprintf(stderr,"%s, %d,%d\n",argv[0], split->length,split->items); | ||
246 | config->floating_mod = 0; | ||
247 | |||
248 | //set modifer keys | ||
249 | for (i = 0; i < split->length; ++i) { | ||
250 | for (j = 0; j < sizeof(modifiers) / sizeof(struct modifier_key); ++j) { | ||
251 | if (strcasecmp(modifiers[j].name, split->items[i]) == 0) { | ||
252 | config->floating_mod |= modifiers[j].mod; | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | list_free(split); | ||
257 | if (!config->floating_mod) { | ||
258 | sway_log(L_ERROR, "bindsym - unknown keys %s", argv[0]); | ||
259 | return false; | ||
260 | } | ||
244 | return true; | 261 | return true; |
245 | } | 262 | } |
246 | 263 | ||
diff --git a/sway/handlers.c b/sway/handlers.c index 3ae33294..670569cb 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -15,8 +15,10 @@ | |||
15 | #include "focus.h" | 15 | #include "focus.h" |
16 | 16 | ||
17 | uint32_t keys_pressed[32]; | 17 | uint32_t keys_pressed[32]; |
18 | uint32_t key_modifiers; | ||
18 | int keys_pressed_length = 0; | 19 | int keys_pressed_length = 0; |
19 | 20 | ||
21 | |||
20 | static struct wlc_origin mouse_origin; | 22 | static struct wlc_origin mouse_origin; |
21 | 23 | ||
22 | static bool m1_held = false; | 24 | static bool m1_held = false; |
@@ -25,12 +27,7 @@ static bool m2_held = false; | |||
25 | static bool resizing = false; | 27 | static bool resizing = false; |
26 | 28 | ||
27 | static bool floating_mod_pressed(void) { | 29 | static bool floating_mod_pressed(void) { |
28 | int i = 0; | 30 | return key_modifiers & config->floating_mod; |
29 | while (i < keys_pressed_length) { | ||
30 | if (keys_pressed[i++] == config->floating_mod) | ||
31 | return true; | ||
32 | } | ||
33 | return false; | ||
34 | } | 31 | } |
35 | 32 | ||
36 | static bool pointer_test(swayc_t *view, void *_origin) { | 33 | static bool pointer_test(swayc_t *view, void *_origin) { |
@@ -297,6 +294,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
297 | return false; | 294 | return false; |
298 | } | 295 | } |
299 | bool cmd_success = false; | 296 | bool cmd_success = false; |
297 | key_modifiers = modifiers->mods; | ||
300 | 298 | ||
301 | struct sway_mode *mode = config->current_mode; | 299 | struct sway_mode *mode = config->current_mode; |
302 | // Lowercase if necessary | 300 | // Lowercase if necessary |