diff options
-rw-r--r-- | sway/commands.c | 18 | ||||
-rw-r--r-- | sway/handlers.c | 28 |
2 files changed, 30 insertions, 16 deletions
diff --git a/sway/commands.c b/sway/commands.c index cc51717b..aafa51f3 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -240,7 +240,23 @@ 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 | config->floating_mod = 0; | ||
246 | |||
247 | //set modifer keys | ||
248 | for (i = 0; i < split->length; ++i) { | ||
249 | for (j = 0; j < sizeof(modifiers) / sizeof(struct modifier_key); ++j) { | ||
250 | if (strcasecmp(modifiers[j].name, split->items[i]) == 0) { | ||
251 | config->floating_mod |= modifiers[j].mod; | ||
252 | } | ||
253 | } | ||
254 | } | ||
255 | list_free(split); | ||
256 | if (!config->floating_mod) { | ||
257 | sway_log(L_ERROR, "bindsym - unknown keys %s", argv[0]); | ||
258 | return false; | ||
259 | } | ||
244 | return true; | 260 | return true; |
245 | } | 261 | } |
246 | 262 | ||
diff --git a/sway/handlers.c b/sway/handlers.c index 00f10a0c..5e8e05b8 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; |
@@ -293,6 +295,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
293 | return false; | 295 | return false; |
294 | } | 296 | } |
295 | bool cmd_success = false; | 297 | bool cmd_success = false; |
298 | key_modifiers = modifiers->mods; | ||
296 | 299 | ||
297 | struct sway_mode *mode = config->current_mode; | 300 | struct sway_mode *mode = config->current_mode; |
298 | // Lowercase if necessary | 301 | // Lowercase if necessary |
@@ -385,15 +388,13 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
385 | int midway_x = view->x + view->width/2; | 388 | int midway_x = view->x + view->width/2; |
386 | int midway_y = view->y + view->height/2; | 389 | int midway_y = view->y + view->height/2; |
387 | if (dx < 0) { | 390 | if (dx < 0) { |
388 | if (mouse_origin.x > midway_x && !lock_right) { | 391 | if (!lock_right) { |
389 | if (view->width > min_sane_w) { | 392 | if (view->width > min_sane_w) { |
390 | lock_left = true; | ||
391 | changed_floating = true; | 393 | changed_floating = true; |
392 | view->width += dx; | 394 | view->width += dx; |
393 | edge += WLC_RESIZE_EDGE_RIGHT; | 395 | edge += WLC_RESIZE_EDGE_RIGHT; |
394 | } | 396 | } |
395 | } else if (mouse_origin.x < midway_x && !lock_left) { | 397 | } else if (mouse_origin.x < midway_x && !lock_left) { |
396 | lock_right = true; | ||
397 | changed_floating = true; | 398 | changed_floating = true; |
398 | view->x += dx; | 399 | view->x += dx; |
399 | view->width -= dx; | 400 | view->width -= dx; |
@@ -401,16 +402,11 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
401 | } | 402 | } |
402 | } else if (dx > 0){ | 403 | } else if (dx > 0){ |
403 | if (mouse_origin.x > midway_x && !lock_right) { | 404 | if (mouse_origin.x > midway_x && !lock_right) { |
404 | lock_left = true; | ||
405 | changed_floating = true; | 405 | changed_floating = true; |
406 | view->width += dx; | 406 | view->width += dx; |
407 | edge += WLC_RESIZE_EDGE_RIGHT; | 407 | edge += WLC_RESIZE_EDGE_RIGHT; |
408 | } else if (!lock_left) { | ||
408 | if (view->width > min_sane_w) { | 409 | if (view->width > min_sane_w) { |
409 | lock_left = false; | ||
410 | } | ||
411 | } else if (mouse_origin.x < midway_x && !lock_left) { | ||
412 | if (view->width > min_sane_w) { | ||
413 | lock_right = true; | ||
414 | changed_floating = true; | 410 | changed_floating = true; |
415 | view->x += dx; | 411 | view->x += dx; |
416 | view->width -= dx; | 412 | view->width -= dx; |
@@ -420,15 +416,13 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
420 | } | 416 | } |
421 | 417 | ||
422 | if (dy < 0) { | 418 | if (dy < 0) { |
423 | if (mouse_origin.y > midway_y && !lock_bottom) { | 419 | if (!lock_bottom) { |
424 | if (view->height > min_sane_h) { | 420 | if (view->height > min_sane_h) { |
425 | lock_top = true; | ||
426 | changed_floating = true; | 421 | changed_floating = true; |
427 | view->height += dy; | 422 | view->height += dy; |
428 | edge += WLC_RESIZE_EDGE_BOTTOM; | 423 | edge += WLC_RESIZE_EDGE_BOTTOM; |
429 | } | 424 | } |
430 | } else if (mouse_origin.y < midway_y && !lock_top) { | 425 | } else if (mouse_origin.y < midway_y && !lock_top) { |
431 | lock_bottom = true; | ||
432 | changed_floating = true; | 426 | changed_floating = true; |
433 | view->y += dy; | 427 | view->y += dy; |
434 | view->height -= dy; | 428 | view->height -= dy; |
@@ -436,13 +430,11 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
436 | } | 430 | } |
437 | } else if (dy > 0) { | 431 | } else if (dy > 0) { |
438 | if (mouse_origin.y > midway_y && !lock_bottom) { | 432 | if (mouse_origin.y > midway_y && !lock_bottom) { |
439 | lock_top = true; | ||
440 | changed_floating = true; | 433 | changed_floating = true; |
441 | view->height += dy; | 434 | view->height += dy; |
442 | edge += WLC_RESIZE_EDGE_BOTTOM; | 435 | edge += WLC_RESIZE_EDGE_BOTTOM; |
443 | } else if (mouse_origin.y < midway_y && !lock_top) { | 436 | } else if (!lock_top) { |
444 | if (view->height > min_sane_h) { | 437 | if (view->height > min_sane_h) { |
445 | lock_bottom = true; | ||
446 | changed_floating = true; | 438 | changed_floating = true; |
447 | view->y += dy; | 439 | view->y += dy; |
448 | view->height -= dy; | 440 | view->height -= dy; |
@@ -508,6 +500,12 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
508 | if (floating_mod_pressed()) { | 500 | if (floating_mod_pressed()) { |
509 | dragging = m1_held; | 501 | dragging = m1_held; |
510 | resizing = m2_held; | 502 | resizing = m2_held; |
503 | int midway_x = pointer->x + pointer->width/2; | ||
504 | int midway_y = pointer->y + pointer->height/2; | ||
505 | lock_bottom = origin->y < midway_y; | ||
506 | lock_top = !lock_bottom; | ||
507 | lock_right = origin->x < midway_x; | ||
508 | lock_left = !lock_right; | ||
511 | } | 509 | } |
512 | //Dont want pointer sent to window while dragging or resizing | 510 | //Dont want pointer sent to window while dragging or resizing |
513 | return (dragging || resizing); | 511 | return (dragging || resizing); |