aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-06 19:26:56 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-06 19:26:56 +1000
commit908095ef9a479cafaf7d815824f243b4576ff1bb (patch)
tree812b58eae73d0816610e93c6595facb42b141536 /sway/input/cursor.c
parentMerge pull request #2578 from RyanDwyer/fix-binding-reload (diff)
downloadsway-908095ef9a479cafaf7d815824f243b4576ff1bb.tar.gz
sway-908095ef9a479cafaf7d815824f243b4576ff1bb.tar.zst
sway-908095ef9a479cafaf7d815824f243b4576ff1bb.zip
Introduce seat_set_focus_container and seat_set_focus_workspace
These are the same as seat_set_focus, but accept a specific type rather than using nodes. Doing this adds more typesafety and lets us avoid using &con->node which looks a little ugly. This fixes a crash that pretty much nobody would ever come across. If you have a bindsym for "focus" with no arguments and run it from an empty workspace, sway would crash because it assumes `container` is not NULL.
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 19dc3165..be3fc9c7 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -675,7 +675,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
675 // Handle tiling resize via border 675 // Handle tiling resize via border
676 if (resize_edge && button == BTN_LEFT && state == WLR_BUTTON_PRESSED && 676 if (resize_edge && button == BTN_LEFT && state == WLR_BUTTON_PRESSED &&
677 !is_floating) { 677 !is_floating) {
678 seat_set_focus(seat, &cont->node); 678 seat_set_focus_container(seat, cont);
679 seat_begin_resize_tiling(seat, cont, button, edge); 679 seat_begin_resize_tiling(seat, cont, button, edge);
680 return; 680 return;
681 } 681 }
@@ -704,7 +704,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
704 image = "sw-resize"; 704 image = "sw-resize";
705 } 705 }
706 cursor_set_image(seat->cursor, image, NULL); 706 cursor_set_image(seat->cursor, image, NULL);
707 seat_set_focus(seat, &cont->node); 707 seat_set_focus_container(seat, cont);
708 seat_begin_resize_tiling(seat, cont, button, edge); 708 seat_begin_resize_tiling(seat, cont, button, edge);
709 return; 709 return;
710 } 710 }
@@ -753,7 +753,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
753 753
754 // Handle mousedown on a container surface 754 // Handle mousedown on a container surface
755 if (surface && cont && state == WLR_BUTTON_PRESSED) { 755 if (surface && cont && state == WLR_BUTTON_PRESSED) {
756 seat_set_focus(seat, &cont->node); 756 seat_set_focus_container(seat, cont);
757 seat_pointer_notify_button(seat, time_msec, button, state); 757 seat_pointer_notify_button(seat, time_msec, button, state);
758 seat_begin_down(seat, cont, button, sx, sy); 758 seat_begin_down(seat, cont, button, sx, sy);
759 return; 759 return;
@@ -761,7 +761,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
761 761
762 // Handle clicking a container surface 762 // Handle clicking a container surface
763 if (cont) { 763 if (cont) {
764 seat_set_focus(seat, &cont->node); 764 seat_set_focus_container(seat, cont);
765 seat_pointer_notify_button(seat, time_msec, button, state); 765 seat_pointer_notify_button(seat, time_msec, button, state);
766 return; 766 return;
767 } 767 }