diff options
author | Luminarys <kizunanohikari@gmail.com> | 2015-08-21 00:49:47 -0500 |
---|---|---|
committer | Luminarys <kizunanohikari@gmail.com> | 2015-08-21 00:49:47 -0500 |
commit | 96ab21b2766096bdb42d79a0169d42b9ff00e2fb (patch) | |
tree | 79857046974ce779f1d410018a422380d6d2627b | |
parent | Added in bspwm like mouse resizing (diff) | |
download | sway-96ab21b2766096bdb42d79a0169d42b9ff00e2fb.tar.gz sway-96ab21b2766096bdb42d79a0169d42b9ff00e2fb.tar.zst sway-96ab21b2766096bdb42d79a0169d42b9ff00e2fb.zip |
Fixes to resizing and added in resize lock once boundaries are exceeded
-rw-r--r-- | include/input_state.h | 1 | ||||
-rw-r--r-- | sway/handlers.c | 45 | ||||
-rw-r--r-- | sway/log.c | 1 |
3 files changed, 35 insertions, 12 deletions
diff --git a/include/input_state.h b/include/input_state.h index 711ad633..7119c68b 100644 --- a/include/input_state.h +++ b/include/input_state.h | |||
@@ -36,6 +36,7 @@ extern struct pointer_state { | |||
36 | } floating; | 36 | } floating; |
37 | struct pointer_tiling { | 37 | struct pointer_tiling { |
38 | bool resize; | 38 | bool resize; |
39 | swayc_t *init_view; | ||
39 | } tiling; | 40 | } tiling; |
40 | struct pointer_lock { | 41 | struct pointer_lock { |
41 | bool left; | 42 | bool left; |
diff --git a/sway/handlers.c b/sway/handlers.c index a71328e3..571dd2a6 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -348,6 +348,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
348 | static wlc_handle prev_handle = 0; | 348 | static wlc_handle prev_handle = 0; |
349 | mouse_origin = *origin; | 349 | mouse_origin = *origin; |
350 | bool changed_floating = false; | 350 | bool changed_floating = false; |
351 | bool changed_tiling = false; | ||
352 | int min_sane_w = 100; | ||
353 | int min_sane_h = 60; | ||
351 | if (!active_workspace) { | 354 | if (!active_workspace) { |
352 | return false; | 355 | return false; |
353 | } | 356 | } |
@@ -366,8 +369,6 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
366 | if (view->is_floating) { | 369 | if (view->is_floating) { |
367 | int dx = mouse_origin.x - prev_pos.x; | 370 | int dx = mouse_origin.x - prev_pos.x; |
368 | int dy = mouse_origin.y - prev_pos.y; | 371 | int dy = mouse_origin.y - prev_pos.y; |
369 | int min_sane_w = 100; | ||
370 | int min_sane_h = 60; | ||
371 | 372 | ||
372 | // Move and resize the view based on the dx/dy and mouse position | 373 | // Move and resize the view based on the dx/dy and mouse position |
373 | int midway_x = view->x + view->width/2; | 374 | int midway_x = view->x + view->width/2; |
@@ -429,7 +430,11 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
429 | } | 430 | } |
430 | } | 431 | } |
431 | } else if (pointer_state.tiling.resize && view) { | 432 | } else if (pointer_state.tiling.resize && view) { |
432 | if (!view->is_floating) { | 433 | if (view != pointer_state.tiling.init_view) { |
434 | // Quit out of the resize | ||
435 | pointer_state.tiling.init_view = NULL; | ||
436 | } | ||
437 | if (!view->is_floating && view == pointer_state.tiling.init_view) { | ||
433 | // Handle layout resizes -- Find the biggest parent container then apply resizes to that | 438 | // Handle layout resizes -- Find the biggest parent container then apply resizes to that |
434 | // and its bordering siblings | 439 | // and its bordering siblings |
435 | swayc_t *parent = view; | 440 | swayc_t *parent = view; |
@@ -450,8 +455,11 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
450 | swayc_t *sibling = get_swayc_in_direction(parent, MOVE_DOWN); | 455 | swayc_t *sibling = get_swayc_in_direction(parent, MOVE_DOWN); |
451 | if (sibling) { | 456 | if (sibling) { |
452 | sway_log(L_DEBUG, "Found sibling at: %p", sibling); | 457 | sway_log(L_DEBUG, "Found sibling at: %p", sibling); |
453 | recursive_resize(parent, dy, WLC_RESIZE_EDGE_BOTTOM); | 458 | if ((parent->height > min_sane_h || dy > 0) && (sibling->height > min_sane_h || dy < 0)) { |
454 | recursive_resize(sibling, -1 * dy, WLC_RESIZE_EDGE_TOP); | 459 | recursive_resize(parent, dy, WLC_RESIZE_EDGE_BOTTOM); |
460 | recursive_resize(sibling, -1 * dy, WLC_RESIZE_EDGE_TOP); | ||
461 | changed_tiling = true; | ||
462 | } | ||
455 | } | 463 | } |
456 | } | 464 | } |
457 | } else { | 465 | } else { |
@@ -467,8 +475,11 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
467 | swayc_t *sibling = get_swayc_in_direction(parent, MOVE_UP); | 475 | swayc_t *sibling = get_swayc_in_direction(parent, MOVE_UP); |
468 | if (sibling) { | 476 | if (sibling) { |
469 | sway_log(L_DEBUG, "Found sibling at: %p", sibling); | 477 | sway_log(L_DEBUG, "Found sibling at: %p", sibling); |
470 | recursive_resize(parent, -1 * dy, WLC_RESIZE_EDGE_TOP); | 478 | if ((parent->height > min_sane_h || dy < 0) && (sibling->height > min_sane_h || dy > 0)) { |
471 | recursive_resize(sibling, dy, WLC_RESIZE_EDGE_BOTTOM); | 479 | recursive_resize(parent, -1 * dy, WLC_RESIZE_EDGE_TOP); |
480 | recursive_resize(sibling, dy, WLC_RESIZE_EDGE_BOTTOM); | ||
481 | changed_tiling = true; | ||
482 | } | ||
472 | } | 483 | } |
473 | } | 484 | } |
474 | } | 485 | } |
@@ -483,14 +494,16 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
483 | break; | 494 | break; |
484 | } | 495 | } |
485 | } | 496 | } |
486 | sway_log(L_DEBUG, "Left is locked, found biggest valid parent at: %p", parent); | ||
487 | if (parent->parent->children->length > 1 && parent->parent->layout == L_HORIZ) { | 497 | if (parent->parent->children->length > 1 && parent->parent->layout == L_HORIZ) { |
488 | sway_log(L_DEBUG, "Left is locked, found biggest valid parent at: %p", parent); | 498 | sway_log(L_DEBUG, "Left is locked, found biggest valid parent at: %p", parent); |
489 | swayc_t *sibling = get_swayc_in_direction(parent, MOVE_RIGHT); | 499 | swayc_t *sibling = get_swayc_in_direction(parent, MOVE_RIGHT); |
490 | if (sibling) { | 500 | if (sibling) { |
491 | sway_log(L_DEBUG, "Found sibling at: %p", sibling); | 501 | sway_log(L_DEBUG, "Found sibling at: %p", sibling); |
492 | recursive_resize(parent, dx, WLC_RESIZE_EDGE_RIGHT); | 502 | if ((parent->width > min_sane_w || dx > 0) && (sibling->width > min_sane_w || dx < 0)) { |
493 | recursive_resize(sibling, -1 * dx, WLC_RESIZE_EDGE_LEFT); | 503 | recursive_resize(parent, dx, WLC_RESIZE_EDGE_RIGHT); |
504 | recursive_resize(sibling, -1 * dx, WLC_RESIZE_EDGE_LEFT); | ||
505 | changed_tiling = true; | ||
506 | } | ||
494 | } | 507 | } |
495 | } | 508 | } |
496 | } else { | 509 | } else { |
@@ -506,8 +519,11 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
506 | swayc_t *sibling = get_swayc_in_direction(parent, MOVE_LEFT); | 519 | swayc_t *sibling = get_swayc_in_direction(parent, MOVE_LEFT); |
507 | if (sibling) { | 520 | if (sibling) { |
508 | sway_log(L_DEBUG, "Found sibling at: %p", sibling); | 521 | sway_log(L_DEBUG, "Found sibling at: %p", sibling); |
509 | recursive_resize(parent, -1 * dx, WLC_RESIZE_EDGE_LEFT); | 522 | if ((parent->width > min_sane_w || dx < 0) && (sibling->width > min_sane_w || dx > 0)) { |
510 | recursive_resize(sibling, dx, WLC_RESIZE_EDGE_RIGHT); | 523 | recursive_resize(parent, -1 * dx, WLC_RESIZE_EDGE_LEFT); |
524 | recursive_resize(sibling, dx, WLC_RESIZE_EDGE_RIGHT); | ||
525 | changed_tiling = true; | ||
526 | } | ||
511 | } | 527 | } |
512 | } | 528 | } |
513 | } | 529 | } |
@@ -538,6 +554,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
538 | wlc_view_set_geometry(view->handle, edge, &geometry); | 554 | wlc_view_set_geometry(view->handle, edge, &geometry); |
539 | return true; | 555 | return true; |
540 | } | 556 | } |
557 | if (changed_tiling) { | ||
558 | return true; | ||
559 | } | ||
541 | return false; | 560 | return false; |
542 | } | 561 | } |
543 | 562 | ||
@@ -587,6 +606,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
587 | return (pointer_state.floating.drag || pointer_state.floating.resize); | 606 | return (pointer_state.floating.drag || pointer_state.floating.resize); |
588 | } else { | 607 | } else { |
589 | pointer_state.tiling.resize = pointer_state.r_held; | 608 | pointer_state.tiling.resize = pointer_state.r_held; |
609 | pointer_state.tiling.init_view = pointer; | ||
590 | } | 610 | } |
591 | return (pointer && pointer != focused); | 611 | return (pointer && pointer != focused); |
592 | } else { | 612 | } else { |
@@ -599,6 +619,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
599 | pointer_state.r_held = false; | 619 | pointer_state.r_held = false; |
600 | pointer_state.floating.resize = false; | 620 | pointer_state.floating.resize = false; |
601 | pointer_state.tiling.resize = false; | 621 | pointer_state.tiling.resize = false; |
622 | pointer_state.tiling.init_view = NULL; | ||
602 | pointer_state.lock = (struct pointer_lock){false ,false ,false ,false}; | 623 | pointer_state.lock = (struct pointer_lock){false ,false ,false ,false}; |
603 | } | 624 | } |
604 | } | 625 | } |
@@ -149,6 +149,7 @@ static void container_log(const swayc_t *c) { | |||
149 | fprintf(stderr, "children:%d\n",c->children?c->children->length:0); | 149 | fprintf(stderr, "children:%d\n",c->children?c->children->length:0); |
150 | } | 150 | } |
151 | void layout_log(const swayc_t *c, int depth) { | 151 | void layout_log(const swayc_t *c, int depth) { |
152 | if (L_DEBUG > v) return; | ||
152 | int i, d; | 153 | int i, d; |
153 | int e = c->children ? c->children->length : 0; | 154 | int e = c->children ? c->children->length : 0; |
154 | container_log(c); | 155 | container_log(c); |