diff options
author | Luminarys <kizunanohikari@gmail.com> | 2015-08-19 12:06:00 -0500 |
---|---|---|
committer | Luminarys <kizunanohikari@gmail.com> | 2015-08-19 12:06:00 -0500 |
commit | daea22bc8920fea1d6fba923169173a2bbdc75f9 (patch) | |
tree | 28cd4da4237cc587dc94be81465fd0ec1f23f952 | |
parent | Added in resize locking (diff) | |
download | sway-daea22bc8920fea1d6fba923169173a2bbdc75f9.tar.gz sway-daea22bc8920fea1d6fba923169173a2bbdc75f9.tar.zst sway-daea22bc8920fea1d6fba923169173a2bbdc75f9.zip |
Resize lock fixes
-rw-r--r-- | sway/handlers.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index faade5eb..5e8e05b8 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -388,15 +388,13 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
388 | int midway_x = view->x + view->width/2; | 388 | int midway_x = view->x + view->width/2; |
389 | int midway_y = view->y + view->height/2; | 389 | int midway_y = view->y + view->height/2; |
390 | if (dx < 0) { | 390 | if (dx < 0) { |
391 | if (mouse_origin.x > midway_x && !lock_right) { | 391 | if (!lock_right) { |
392 | if (view->width > min_sane_w) { | 392 | if (view->width > min_sane_w) { |
393 | lock_left = true; | ||
394 | changed_floating = true; | 393 | changed_floating = true; |
395 | view->width += dx; | 394 | view->width += dx; |
396 | edge += WLC_RESIZE_EDGE_RIGHT; | 395 | edge += WLC_RESIZE_EDGE_RIGHT; |
397 | } | 396 | } |
398 | } else if (mouse_origin.x < midway_x && !lock_left) { | 397 | } else if (mouse_origin.x < midway_x && !lock_left) { |
399 | lock_right = true; | ||
400 | changed_floating = true; | 398 | changed_floating = true; |
401 | view->x += dx; | 399 | view->x += dx; |
402 | view->width -= dx; | 400 | view->width -= dx; |
@@ -404,16 +402,11 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
404 | } | 402 | } |
405 | } else if (dx > 0){ | 403 | } else if (dx > 0){ |
406 | if (mouse_origin.x > midway_x && !lock_right) { | 404 | if (mouse_origin.x > midway_x && !lock_right) { |
407 | lock_left = true; | ||
408 | changed_floating = true; | 405 | changed_floating = true; |
409 | view->width += dx; | 406 | view->width += dx; |
410 | edge += WLC_RESIZE_EDGE_RIGHT; | 407 | edge += WLC_RESIZE_EDGE_RIGHT; |
408 | } else if (!lock_left) { | ||
411 | if (view->width > min_sane_w) { | 409 | if (view->width > min_sane_w) { |
412 | lock_left = false; | ||
413 | } | ||
414 | } else if (mouse_origin.x < midway_x && !lock_left) { | ||
415 | if (view->width > min_sane_w) { | ||
416 | lock_right = true; | ||
417 | changed_floating = true; | 410 | changed_floating = true; |
418 | view->x += dx; | 411 | view->x += dx; |
419 | view->width -= dx; | 412 | view->width -= dx; |
@@ -423,15 +416,13 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
423 | } | 416 | } |
424 | 417 | ||
425 | if (dy < 0) { | 418 | if (dy < 0) { |
426 | if (mouse_origin.y > midway_y && !lock_bottom) { | 419 | if (!lock_bottom) { |
427 | if (view->height > min_sane_h) { | 420 | if (view->height > min_sane_h) { |
428 | lock_top = true; | ||
429 | changed_floating = true; | 421 | changed_floating = true; |
430 | view->height += dy; | 422 | view->height += dy; |
431 | edge += WLC_RESIZE_EDGE_BOTTOM; | 423 | edge += WLC_RESIZE_EDGE_BOTTOM; |
432 | } | 424 | } |
433 | } else if (mouse_origin.y < midway_y && !lock_top) { | 425 | } else if (mouse_origin.y < midway_y && !lock_top) { |
434 | lock_bottom = true; | ||
435 | changed_floating = true; | 426 | changed_floating = true; |
436 | view->y += dy; | 427 | view->y += dy; |
437 | view->height -= dy; | 428 | view->height -= dy; |
@@ -439,13 +430,11 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
439 | } | 430 | } |
440 | } else if (dy > 0) { | 431 | } else if (dy > 0) { |
441 | if (mouse_origin.y > midway_y && !lock_bottom) { | 432 | if (mouse_origin.y > midway_y && !lock_bottom) { |
442 | lock_top = true; | ||
443 | changed_floating = true; | 433 | changed_floating = true; |
444 | view->height += dy; | 434 | view->height += dy; |
445 | edge += WLC_RESIZE_EDGE_BOTTOM; | 435 | edge += WLC_RESIZE_EDGE_BOTTOM; |
446 | } else if (mouse_origin.y < midway_y && !lock_top) { | 436 | } else if (!lock_top) { |
447 | if (view->height > min_sane_h) { | 437 | if (view->height > min_sane_h) { |
448 | lock_bottom = true; | ||
449 | changed_floating = true; | 438 | changed_floating = true; |
450 | view->y += dy; | 439 | view->y += dy; |
451 | view->height -= dy; | 440 | view->height -= dy; |
@@ -511,6 +500,12 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
511 | if (floating_mod_pressed()) { | 500 | if (floating_mod_pressed()) { |
512 | dragging = m1_held; | 501 | dragging = m1_held; |
513 | 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; | ||
514 | } | 509 | } |
515 | //Dont want pointer sent to window while dragging or resizing | 510 | //Dont want pointer sent to window while dragging or resizing |
516 | return (dragging || resizing); | 511 | return (dragging || resizing); |