summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-21 19:36:57 -0500
committerLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-21 19:37:19 -0500
commit63a32360642cc66753e66ac0d3245af8b3ce9375 (patch)
tree7b485c144c9f862f979b906aee85d35265859ec0
parentRemove wlc logging stuff (diff)
downloadsway-63a32360642cc66753e66ac0d3245af8b3ce9375.tar.gz
sway-63a32360642cc66753e66ac0d3245af8b3ce9375.tar.zst
sway-63a32360642cc66753e66ac0d3245af8b3ce9375.zip
Fixed resizing
-rw-r--r--sway/commands.c3
-rw-r--r--sway/handlers.c36
2 files changed, 34 insertions, 5 deletions
diff --git a/sway/commands.c b/sway/commands.c
index efaa7472..ef76c169 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -448,6 +448,8 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) {
448 return false; 448 return false;
449 } 449 }
450 char *end; 450 char *end;
451 int min_sane_w = 100;
452 int min_sane_h = 60;
451 int amount = (int)strtol(argv[2], &end, 10); 453 int amount = (int)strtol(argv[2], &end, 10);
452 if (errno == ERANGE || amount == 0) { 454 if (errno == ERANGE || amount == 0) {
453 errno = 0; 455 errno = 0;
@@ -496,6 +498,7 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) {
496 sway_log(L_DEBUG, "Found the proper parent: %p. It has %d l conts, and %d r conts", parent->parent, lnumber, rnumber); 498 sway_log(L_DEBUG, "Found the proper parent: %p. It has %d l conts, and %d r conts", parent->parent, lnumber, rnumber);
497 //TODO: Ensure rounding is done in such a way that there are NO pixel leaks 499 //TODO: Ensure rounding is done in such a way that there are NO pixel leaks
498 for (i = 0; i < parent->parent->children->length; i++) { 500 for (i = 0; i < parent->parent->children->length; i++) {
501 bool valid = true;
499 sibling = parent->parent->children->items[i]; 502 sibling = parent->parent->children->items[i];
500 if (sibling->x != focused->x) { 503 if (sibling->x != focused->x) {
501 if (sibling->x < parent->x) { 504 if (sibling->x < parent->x) {
diff --git a/sway/handlers.c b/sway/handlers.c
index 57251307..7370d3b9 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -422,9 +422,25 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
422 bool valid = true; 422 bool valid = true;
423 double dx = mouse_origin.x - prev_pos.x; 423 double dx = mouse_origin.x - prev_pos.x;
424 double dy = mouse_origin.y - prev_pos.y; 424 double dy = mouse_origin.y - prev_pos.y;
425
426 if (view != pointer_state.tiling.init_view) { 425 if (view != pointer_state.tiling.init_view) {
426 changed_tiling = true;
427 valid = false; 427 valid = false;
428 if (view->type != C_WORKSPACE) {
429 if (view->x < pointer_state.tiling.init_view->x) {
430 pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + 20;
431 pointer_state.lock.temp_left = true;
432 } else if (view->x > pointer_state.tiling.init_view->x) {
433 pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + pointer_state.tiling.init_view->width - 20;
434 pointer_state.lock.temp_right = true;
435 }
436 if (view->y < pointer_state.tiling.init_view->y) {
437 pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20;
438 pointer_state.lock.temp_up = true;
439 } else if (view->y > pointer_state.tiling.init_view->y) {
440 pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20;
441 pointer_state.lock.temp_down = true;
442 }
443 }
428 } 444 }
429 445
430 if ((dx < 0 || mouse_origin.x < pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_left) { 446 if ((dx < 0 || mouse_origin.x < pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_left) {
@@ -432,6 +448,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
432 valid = false; 448 valid = false;
433 } else if (dx > 0 && pointer_state.lock.temp_left) { 449 } else if (dx > 0 && pointer_state.lock.temp_left) {
434 pointer_state.lock.temp_left = false; 450 pointer_state.lock.temp_left = false;
451 pointer_state.tiling.lock_pos.x = 0;
435 } 452 }
436 453
437 if ((dx > 0 || mouse_origin.x > pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_right) { 454 if ((dx > 0 || mouse_origin.x > pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_right) {
@@ -439,6 +456,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
439 valid = false; 456 valid = false;
440 } else if (dx < 0 && pointer_state.lock.temp_right) { 457 } else if (dx < 0 && pointer_state.lock.temp_right) {
441 pointer_state.lock.temp_right = false; 458 pointer_state.lock.temp_right = false;
459 pointer_state.tiling.lock_pos.x = 0;
442 } 460 }
443 461
444 if ((dy < 0 || mouse_origin.y < pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_up) { 462 if ((dy < 0 || mouse_origin.y < pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_up) {
@@ -446,6 +464,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
446 valid = false; 464 valid = false;
447 } else if (dy > 0 && pointer_state.lock.temp_up) { 465 } else if (dy > 0 && pointer_state.lock.temp_up) {
448 pointer_state.lock.temp_up = false; 466 pointer_state.lock.temp_up = false;
467 pointer_state.tiling.lock_pos.y = 0;
449 } 468 }
450 469
451 if ((dy > 0 || mouse_origin.y > pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_down) { 470 if ((dy > 0 || mouse_origin.y > pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_down) {
@@ -453,6 +472,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
453 valid = false; 472 valid = false;
454 } else if (dy < 0 && pointer_state.lock.temp_down) { 473 } else if (dy < 0 && pointer_state.lock.temp_down) {
455 pointer_state.lock.temp_down = false; 474 pointer_state.lock.temp_down = false;
475 pointer_state.tiling.lock_pos.y = 0;
456 } 476 }
457 477
458 if (!view->is_floating && valid) { 478 if (!view->is_floating && valid) {
@@ -477,10 +497,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
477 recursive_resize(sibling, -1 * dy, WLC_RESIZE_EDGE_TOP); 497 recursive_resize(sibling, -1 * dy, WLC_RESIZE_EDGE_TOP);
478 changed_tiling = true; 498 changed_tiling = true;
479 } else { 499 } else {
480 pointer_state.tiling.lock_pos.y = mouse_origin.y;
481 if (parent->height < min_sane_h) { 500 if (parent->height < min_sane_h) {
501 //pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20;
502 pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20;
482 pointer_state.lock.temp_up = true; 503 pointer_state.lock.temp_up = true;
483 } else if (sibling->height < min_sane_h) { 504 } else if (sibling->height < min_sane_h) {
505 pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20;
484 pointer_state.lock.temp_down = true; 506 pointer_state.lock.temp_down = true;
485 } 507 }
486 } 508 }
@@ -502,10 +524,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
502 recursive_resize(sibling, dy, WLC_RESIZE_EDGE_BOTTOM); 524 recursive_resize(sibling, dy, WLC_RESIZE_EDGE_BOTTOM);
503 changed_tiling = true; 525 changed_tiling = true;
504 } else { 526 } else {
505 pointer_state.tiling.lock_pos.y = mouse_origin.y;
506 if (parent->height < min_sane_h) { 527 if (parent->height < min_sane_h) {
528 //pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20;
529 pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20;
507 pointer_state.lock.temp_down = true; 530 pointer_state.lock.temp_down = true;
508 } else if (sibling->height < min_sane_h) { 531 } else if (sibling->height < min_sane_h) {
532 pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20;
509 pointer_state.lock.temp_up = true; 533 pointer_state.lock.temp_up = true;
510 } 534 }
511 } 535 }
@@ -531,11 +555,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
531 recursive_resize(sibling, -1 * dx, WLC_RESIZE_EDGE_LEFT); 555 recursive_resize(sibling, -1 * dx, WLC_RESIZE_EDGE_LEFT);
532 changed_tiling = true; 556 changed_tiling = true;
533 } else { 557 } else {
534 pointer_state.tiling.lock_pos.x = mouse_origin.x;
535 if (parent->width < min_sane_w) { 558 if (parent->width < min_sane_w) {
536 pointer_state.lock.temp_left = true; 559 pointer_state.lock.temp_left = true;
560 pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + pointer_state.tiling.init_view->width - 20;
537 } else if (sibling->width < min_sane_w) { 561 } else if (sibling->width < min_sane_w) {
538 pointer_state.lock.temp_right = true; 562 pointer_state.lock.temp_right = true;
563 pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + pointer_state.tiling.init_view->width - 20;
539 } 564 }
540 } 565 }
541 } 566 }
@@ -556,11 +581,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
556 recursive_resize(sibling, dx, WLC_RESIZE_EDGE_RIGHT); 581 recursive_resize(sibling, dx, WLC_RESIZE_EDGE_RIGHT);
557 changed_tiling = true; 582 changed_tiling = true;
558 } else { 583 } else {
559 pointer_state.tiling.lock_pos.x = mouse_origin.x;
560 if (parent->width < min_sane_w) { 584 if (parent->width < min_sane_w) {
561 pointer_state.lock.temp_right = true; 585 pointer_state.lock.temp_right = true;
586 pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + 20;
562 } else if (sibling->width < min_sane_w) { 587 } else if (sibling->width < min_sane_w) {
563 pointer_state.lock.temp_left = true; 588 pointer_state.lock.temp_left = true;
589 pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + 20;
564 } 590 }
565 } 591 }
566 } 592 }