aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-10 17:22:50 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-12 10:45:54 +1000
commit2dceae6224f38a706182394dc77ebd11afb22531 (patch)
treeda47146ddfa9cefdda8fa71edd30f3fd321a66a0 /sway/input/cursor.c
parentRefactor dispatch_cursor_button (diff)
downloadsway-2dceae6224f38a706182394dc77ebd11afb22531.tar.gz
sway-2dceae6224f38a706182394dc77ebd11afb22531.tar.zst
sway-2dceae6224f38a706182394dc77ebd11afb22531.zip
Allow resizing tiled views via mod key
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c60
1 files changed, 42 insertions, 18 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index d4dc617a..5f295828 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -356,27 +356,35 @@ static void handle_resize_floating_motion(struct sway_seat *seat,
356 356
357static void handle_resize_tiling_motion(struct sway_seat *seat, 357static void handle_resize_tiling_motion(struct sway_seat *seat,
358 struct sway_cursor *cursor) { 358 struct sway_cursor *cursor) {
359 int amount = 0; 359 int amount_x = 0;
360 int amount_y = 0;
360 int moved_x = cursor->cursor->x - seat->op_ref_lx; 361 int moved_x = cursor->cursor->x - seat->op_ref_lx;
361 int moved_y = cursor->cursor->y - seat->op_ref_ly; 362 int moved_y = cursor->cursor->y - seat->op_ref_ly;
363 enum wlr_edges edge_x = WLR_EDGE_NONE;
364 enum wlr_edges edge_y = WLR_EDGE_NONE;
362 struct sway_container *con = seat->op_container; 365 struct sway_container *con = seat->op_container;
363 switch (seat->op_resize_edge) { 366
364 case WLR_EDGE_TOP: 367 if (seat->op_resize_edge & WLR_EDGE_TOP) {
365 amount = (seat->op_ref_height - moved_y) - con->height; 368 amount_y = (seat->op_ref_height - moved_y) - con->height;
366 break; 369 edge_y = WLR_EDGE_TOP;
367 case WLR_EDGE_BOTTOM: 370 } else if (seat->op_resize_edge & WLR_EDGE_BOTTOM) {
368 amount = (seat->op_ref_height + moved_y) - con->height; 371 amount_y = (seat->op_ref_height + moved_y) - con->height;
369 break; 372 edge_y = WLR_EDGE_BOTTOM;
370 case WLR_EDGE_LEFT: 373 }
371 amount = (seat->op_ref_width - moved_x) - con->width; 374 if (seat->op_resize_edge & WLR_EDGE_LEFT) {
372 break; 375 amount_x = (seat->op_ref_width - moved_x) - con->width;
373 case WLR_EDGE_RIGHT: 376 edge_x = WLR_EDGE_LEFT;
374 amount = (seat->op_ref_width + moved_x) - con->width; 377 } else if (seat->op_resize_edge & WLR_EDGE_RIGHT) {
375 break; 378 amount_x = (seat->op_ref_width + moved_x) - con->width;
376 case WLR_EDGE_NONE: 379 edge_x = WLR_EDGE_RIGHT;
377 break; 380 }
381
382 if (amount_x != 0) {
383 container_resize_tiled(seat->op_container, edge_x, amount_x);
384 }
385 if (amount_y != 0) {
386 container_resize_tiled(seat->op_container, edge_y, amount_y);
378 } 387 }
379 container_resize_tiled(seat->op_container, seat->op_resize_edge, amount);
380} 388}
381 389
382void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, 390void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
@@ -655,10 +663,25 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
655 return; 663 return;
656 } 664 }
657 665
658 // Handle beginning floating move 666 // Handle tiling resize via mod
659 bool mod_pressed = keyboard && 667 bool mod_pressed = keyboard &&
660 (wlr_keyboard_get_modifiers(keyboard) & config->floating_mod); 668 (wlr_keyboard_get_modifiers(keyboard) & config->floating_mod);
669 if (!is_floating) {
670 uint32_t btn_resize = config->floating_mod_inverse ?
671 BTN_LEFT : BTN_RIGHT;
672 if (button == btn_resize) {
673 edge = 0;
674 edge |= cursor->cursor->x > cont->x + cont->width / 2 ?
675 WLR_EDGE_RIGHT : WLR_EDGE_LEFT;
676 edge |= cursor->cursor->y > cont->y + cont->height / 2 ?
677 WLR_EDGE_BOTTOM : WLR_EDGE_TOP;
678 seat_set_focus(seat, cont);
679 seat_begin_resize_tiling(seat, cont, button, edge);
680 return;
681 }
682 }
661 683
684 // Handle beginning floating move
662 if (is_floating_or_child && !is_fullscreen_or_child) { 685 if (is_floating_or_child && !is_fullscreen_or_child) {
663 uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT; 686 uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT;
664 if (button == btn_move && state == WLR_BUTTON_PRESSED && 687 if (button == btn_move && state == WLR_BUTTON_PRESSED &&
@@ -688,6 +711,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
688 uint32_t btn_resize = config->floating_mod_inverse ? 711 uint32_t btn_resize = config->floating_mod_inverse ?
689 BTN_LEFT : BTN_RIGHT; 712 BTN_LEFT : BTN_RIGHT;
690 if (button == btn_resize) { 713 if (button == btn_resize) {
714 edge = 0;
691 edge |= cursor->cursor->x > floater->x + floater->width / 2 ? 715 edge |= cursor->cursor->x > floater->x + floater->width / 2 ?
692 WLR_EDGE_RIGHT : WLR_EDGE_LEFT; 716 WLR_EDGE_RIGHT : WLR_EDGE_LEFT;
693 edge |= cursor->cursor->y > floater->y + floater->height / 2 ? 717 edge |= cursor->cursor->y > floater->y + floater->height / 2 ?