aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-21 12:23:53 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-21 12:23:53 -0400
commit1c38b7a8d228585018651741ce748c4b0d6c8d0e (patch)
treeebbb4c441b45e5ea6aadef51c0a995f99b169be4 /sway
parentMerge pull request #110 from minus7/sign-comparsion-fix (diff)
parentAdded in proper resize locking (diff)
downloadsway-1c38b7a8d228585018651741ce748c4b0d6c8d0e.tar.gz
sway-1c38b7a8d228585018651741ce748c4b0d6c8d0e.tar.zst
sway-1c38b7a8d228585018651741ce748c4b0d6c8d0e.zip
Merge pull request #111 from Luminarys/master
Added in proper resize locking
Diffstat (limited to 'sway')
-rw-r--r--sway/handlers.c76
-rw-r--r--sway/input_state.c2
2 files changed, 62 insertions, 16 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 78f8927d..7188092a 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -421,16 +421,42 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
421 } 421 }
422 } 422 }
423 } else if (pointer_state.tiling.resize && view) { 423 } else if (pointer_state.tiling.resize && view) {
424 if (view != pointer_state.tiling.init_view) { 424 bool valid = true;
425 // Quit out of the resize 425 double dx = mouse_origin.x - prev_pos.x;
426 //pointer_state.tiling.init_view = NULL; 426 double dy = mouse_origin.y - prev_pos.y;
427
428 if ((dx < 0 || mouse_origin.x < pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_left) {
429 changed_tiling = true;
430 valid = false;
431 } else if (dx > 0 && pointer_state.lock.temp_left) {
432 pointer_state.lock.temp_left = false;
427 } 433 }
428 if (!view->is_floating && view == pointer_state.tiling.init_view) { 434
435 if ((dx > 0 || mouse_origin.x > pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_right) {
436 changed_tiling = true;
437 valid = false;
438 } else if (dx < 0 && pointer_state.lock.temp_right) {
439 pointer_state.lock.temp_right = false;
440 }
441
442 if ((dy < 0 || mouse_origin.y < pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_up) {
443 changed_tiling = true;
444 valid = false;
445 } else if (dy > 0 && pointer_state.lock.temp_up) {
446 pointer_state.lock.temp_up = false;
447 }
448
449 if ((dy > 0 || mouse_origin.y > pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_down) {
450 changed_tiling = true;
451 valid = false;
452 } else if (dy < 0 && pointer_state.lock.temp_down) {
453 pointer_state.lock.temp_down = false;
454 }
455
456 if (!view->is_floating && valid) {
429 // Handle layout resizes -- Find the biggest parent container then apply resizes to that 457 // Handle layout resizes -- Find the biggest parent container then apply resizes to that
430 // and its bordering siblings 458 // and its bordering siblings
431 swayc_t *parent = view; 459 swayc_t *parent = view;
432 double dx = mouse_origin.x - prev_pos.x;
433 double dy = mouse_origin.y - prev_pos.y;
434 if (!pointer_state.lock.bottom) { 460 if (!pointer_state.lock.bottom) {
435 while (parent->type != C_WORKSPACE) { 461 while (parent->type != C_WORKSPACE) {
436 // TODO: Absolute value is a bad hack here to compensate for rounding. Find a better 462 // TODO: Absolute value is a bad hack here to compensate for rounding. Find a better
@@ -442,14 +468,19 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
442 } 468 }
443 } 469 }
444 if (parent->parent->children->length > 1 && parent->parent->layout == L_VERT) { 470 if (parent->parent->children->length > 1 && parent->parent->layout == L_VERT) {
445 sway_log(L_DEBUG, "Top is locked, found biggest valid parent at: %p", parent);
446 swayc_t *sibling = get_swayc_in_direction(parent, MOVE_DOWN); 471 swayc_t *sibling = get_swayc_in_direction(parent, MOVE_DOWN);
447 if (sibling) { 472 if (sibling) {
448 sway_log(L_DEBUG, "Found sibling at: %p", sibling);
449 if ((parent->height > min_sane_h || dy > 0) && (sibling->height > min_sane_h || dy < 0)) { 473 if ((parent->height > min_sane_h || dy > 0) && (sibling->height > min_sane_h || dy < 0)) {
450 recursive_resize(parent, dy, WLC_RESIZE_EDGE_BOTTOM); 474 recursive_resize(parent, dy, WLC_RESIZE_EDGE_BOTTOM);
451 recursive_resize(sibling, -1 * dy, WLC_RESIZE_EDGE_TOP); 475 recursive_resize(sibling, -1 * dy, WLC_RESIZE_EDGE_TOP);
452 changed_tiling = true; 476 changed_tiling = true;
477 } else {
478 pointer_state.tiling.lock_pos.y = mouse_origin.y;
479 if (parent->height < min_sane_h) {
480 pointer_state.lock.temp_up = true;
481 } else if (sibling->height < min_sane_h) {
482 pointer_state.lock.temp_down = true;
483 }
453 } 484 }
454 } 485 }
455 } 486 }
@@ -462,14 +493,19 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
462 } 493 }
463 } 494 }
464 if (parent->parent->children->length > 1 && parent->parent->layout == L_VERT) { 495 if (parent->parent->children->length > 1 && parent->parent->layout == L_VERT) {
465 sway_log(L_DEBUG, "Bot is locked, found biggest valid parent at: %p", parent);
466 swayc_t *sibling = get_swayc_in_direction(parent, MOVE_UP); 496 swayc_t *sibling = get_swayc_in_direction(parent, MOVE_UP);
467 if (sibling) { 497 if (sibling) {
468 sway_log(L_DEBUG, "Found sibling at: %p", sibling);
469 if ((parent->height > min_sane_h || dy < 0) && (sibling->height > min_sane_h || dy > 0)) { 498 if ((parent->height > min_sane_h || dy < 0) && (sibling->height > min_sane_h || dy > 0)) {
470 recursive_resize(parent, -1 * dy, WLC_RESIZE_EDGE_TOP); 499 recursive_resize(parent, -1 * dy, WLC_RESIZE_EDGE_TOP);
471 recursive_resize(sibling, dy, WLC_RESIZE_EDGE_BOTTOM); 500 recursive_resize(sibling, dy, WLC_RESIZE_EDGE_BOTTOM);
472 changed_tiling = true; 501 changed_tiling = true;
502 } else {
503 pointer_state.tiling.lock_pos.y = mouse_origin.y;
504 if (parent->height < min_sane_h) {
505 pointer_state.lock.temp_down = true;
506 } else if (sibling->height < min_sane_h) {
507 pointer_state.lock.temp_up = true;
508 }
473 } 509 }
474 } 510 }
475 } 511 }
@@ -486,14 +522,19 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
486 } 522 }
487 } 523 }
488 if (parent->parent->children->length > 1 && parent->parent->layout == L_HORIZ) { 524 if (parent->parent->children->length > 1 && parent->parent->layout == L_HORIZ) {
489 sway_log(L_DEBUG, "Left is locked, found biggest valid parent at: %p", parent);
490 swayc_t *sibling = get_swayc_in_direction(parent, MOVE_RIGHT); 525 swayc_t *sibling = get_swayc_in_direction(parent, MOVE_RIGHT);
491 if (sibling) { 526 if (sibling) {
492 sway_log(L_DEBUG, "Found sibling at: %p", sibling);
493 if ((parent->width > min_sane_w || dx > 0) && (sibling->width > min_sane_w || dx < 0)) { 527 if ((parent->width > min_sane_w || dx > 0) && (sibling->width > min_sane_w || dx < 0)) {
494 recursive_resize(parent, dx, WLC_RESIZE_EDGE_RIGHT); 528 recursive_resize(parent, dx, WLC_RESIZE_EDGE_RIGHT);
495 recursive_resize(sibling, -1 * dx, WLC_RESIZE_EDGE_LEFT); 529 recursive_resize(sibling, -1 * dx, WLC_RESIZE_EDGE_LEFT);
496 changed_tiling = true; 530 changed_tiling = true;
531 } else {
532 pointer_state.tiling.lock_pos.x = mouse_origin.x;
533 if (parent->width < min_sane_w) {
534 pointer_state.lock.temp_left = true;
535 } else if (sibling->width < min_sane_w) {
536 pointer_state.lock.temp_right = true;
537 }
497 } 538 }
498 } 539 }
499 } 540 }
@@ -506,14 +547,19 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
506 } 547 }
507 } 548 }
508 if (parent->parent->children->length > 1 && parent->parent->layout == L_HORIZ) { 549 if (parent->parent->children->length > 1 && parent->parent->layout == L_HORIZ) {
509 sway_log(L_DEBUG, "Right is locked, found biggest valid parent at: %p", parent);
510 swayc_t *sibling = get_swayc_in_direction(parent, MOVE_LEFT); 550 swayc_t *sibling = get_swayc_in_direction(parent, MOVE_LEFT);
511 if (sibling) { 551 if (sibling) {
512 sway_log(L_DEBUG, "Found sibling at: %p", sibling);
513 if ((parent->width > min_sane_w || dx < 0) && (sibling->width > min_sane_w || dx > 0)) { 552 if ((parent->width > min_sane_w || dx < 0) && (sibling->width > min_sane_w || dx > 0)) {
514 recursive_resize(parent, -1 * dx, WLC_RESIZE_EDGE_LEFT); 553 recursive_resize(parent, -1 * dx, WLC_RESIZE_EDGE_LEFT);
515 recursive_resize(sibling, dx, WLC_RESIZE_EDGE_RIGHT); 554 recursive_resize(sibling, dx, WLC_RESIZE_EDGE_RIGHT);
516 changed_tiling = true; 555 changed_tiling = true;
556 } else {
557 pointer_state.tiling.lock_pos.x = mouse_origin.x;
558 if (parent->width < min_sane_w) {
559 pointer_state.lock.temp_right = true;
560 } else if (sibling->width < min_sane_w) {
561 pointer_state.lock.temp_left = true;
562 }
517 } 563 }
518 } 564 }
519 } 565 }
@@ -611,7 +657,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
611 pointer_state.floating.resize = false; 657 pointer_state.floating.resize = false;
612 pointer_state.tiling.resize = false; 658 pointer_state.tiling.resize = false;
613 pointer_state.tiling.init_view = NULL; 659 pointer_state.tiling.init_view = NULL;
614 pointer_state.lock = (struct pointer_lock){false ,false ,false ,false}; 660 pointer_state.lock = (struct pointer_lock){false ,false ,false ,false, false, false, false, false};
615 } 661 }
616 } 662 }
617 return false; 663 return false;
diff --git a/sway/input_state.c b/sway/input_state.c
index 5119930a..61c1e4ba 100644
--- a/sway/input_state.c
+++ b/sway/input_state.c
@@ -48,7 +48,7 @@ void release_key(keycode key) {
48 } 48 }
49} 49}
50 50
51struct pointer_state pointer_state = {0, 0, {0, 0}, {0, 0, 0}, {0, 0, 0, 0}}; 51struct pointer_state pointer_state = {0, 0, {0, 0}, {0, 0, {0, 0}}, {0, 0, 0, 0, 0, 0, 0, 0}};
52 52
53static struct wlc_geometry saved_floating; 53static struct wlc_geometry saved_floating;
54 54