aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-04 11:45:49 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-09-05 18:01:43 +1000
commite5c9204b491cc252baad97acde6a232fded7ee5a (patch)
tree747383b3dca671d4f89afffaa63e91e2eb516810 /sway/input/cursor.c
parentFix crash when running layout toggle split (diff)
downloadsway-e5c9204b491cc252baad97acde6a232fded7ee5a.tar.gz
sway-e5c9204b491cc252baad97acde6a232fded7ee5a.tar.zst
sway-e5c9204b491cc252baad97acde6a232fded7ee5a.zip
Focus empty workspace when clicking it
Also removes container_at_coords as this function is no longer necessary.
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 5b09d646..3ba20ef0 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -126,16 +126,6 @@ static struct sway_node *node_at_coords(
126 return &ws->node; 126 return &ws->node;
127} 127}
128 128
129static struct sway_container *container_at_coords(struct sway_seat *seat,
130 double lx, double ly,
131 struct wlr_surface **surface, double *sx, double *sy) {
132 struct sway_node *node = node_at_coords(seat, lx, ly, surface, sx, sy);
133 if (node && node->type == N_CONTAINER) {
134 return node->sway_container;
135 }
136 return NULL;
137}
138
139/** 129/**
140 * Determine if the edge of the given container is on the edge of the 130 * Determine if the edge of the given container is on the edge of the
141 * workspace/output. 131 * workspace/output.
@@ -630,8 +620,10 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
630 // Determine what's under the cursor 620 // Determine what's under the cursor
631 struct wlr_surface *surface = NULL; 621 struct wlr_surface *surface = NULL;
632 double sx, sy; 622 double sx, sy;
633 struct sway_container *cont = container_at_coords(seat, 623 struct sway_node *node = node_at_coords(seat,
634 cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); 624 cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
625 struct sway_container *cont = node && node->type == N_CONTAINER ?
626 node->sway_container : NULL;
635 bool is_floating = cont && container_is_floating(cont); 627 bool is_floating = cont && container_is_floating(cont);
636 bool is_floating_or_child = cont && container_is_floating_or_child(cont); 628 bool is_floating_or_child = cont && container_is_floating_or_child(cont);
637 bool is_fullscreen_or_child = cont && container_is_fullscreen_or_child(cont); 629 bool is_fullscreen_or_child = cont && container_is_fullscreen_or_child(cont);
@@ -663,6 +655,12 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
663 return; 655 return;
664 } 656 }
665 657
658 // Handle clicking an empty workspace
659 if (node && node->type == N_WORKSPACE) {
660 seat_set_focus(seat, node);
661 return;
662 }
663
666 // Handle clicking a layer surface 664 // Handle clicking a layer surface
667 if (surface && wlr_surface_is_layer_surface(surface)) { 665 if (surface && wlr_surface_is_layer_surface(surface)) {
668 struct wlr_layer_surface *layer = 666 struct wlr_layer_surface *layer =
@@ -801,7 +799,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
801 wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device, 799 wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device,
802 event->x, event->y, &lx, &ly); 800 event->x, event->y, &lx, &ly);
803 double sx, sy; 801 double sx, sy;
804 container_at_coords(seat, lx, ly, &surface, &sx, &sy); 802 node_at_coords(seat, lx, ly, &surface, &sx, &sy);
805 803
806 seat->touch_id = event->touch_id; 804 seat->touch_id = event->touch_id;
807 seat->touch_x = lx; 805 seat->touch_x = lx;
@@ -843,7 +841,7 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
843 wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device, 841 wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device,
844 event->x, event->y, &lx, &ly); 842 event->x, event->y, &lx, &ly);
845 double sx, sy; 843 double sx, sy;
846 container_at_coords(cursor->seat, lx, ly, &surface, &sx, &sy); 844 node_at_coords(cursor->seat, lx, ly, &surface, &sx, &sy);
847 845
848 if (seat->touch_id == event->touch_id) { 846 if (seat->touch_id == event->touch_id) {
849 seat->touch_x = lx; 847 seat->touch_x = lx;