Focus empty workspace when clicking it

Also removes container_at_coords as this function is no longer
necessary.
This commit is contained in:
Ryan Dwyer 2018-09-04 11:45:49 +10:00
parent 27d2d37d6e
commit e5c9204b49

View file

@ -126,16 +126,6 @@ static struct sway_node *node_at_coords(
return &ws->node; return &ws->node;
} }
static struct sway_container *container_at_coords(struct sway_seat *seat,
double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) {
struct sway_node *node = node_at_coords(seat, lx, ly, surface, sx, sy);
if (node && node->type == N_CONTAINER) {
return node->sway_container;
}
return NULL;
}
/** /**
* Determine if the edge of the given container is on the edge of the * Determine if the edge of the given container is on the edge of the
* workspace/output. * workspace/output.
@ -630,8 +620,10 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
// Determine what's under the cursor // Determine what's under the cursor
struct wlr_surface *surface = NULL; struct wlr_surface *surface = NULL;
double sx, sy; double sx, sy;
struct sway_container *cont = container_at_coords(seat, struct sway_node *node = node_at_coords(seat,
cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
struct sway_container *cont = node && node->type == N_CONTAINER ?
node->sway_container : NULL;
bool is_floating = cont && container_is_floating(cont); bool is_floating = cont && container_is_floating(cont);
bool is_floating_or_child = cont && container_is_floating_or_child(cont); bool is_floating_or_child = cont && container_is_floating_or_child(cont);
bool is_fullscreen_or_child = cont && container_is_fullscreen_or_child(cont); bool is_fullscreen_or_child = cont && container_is_fullscreen_or_child(cont);
@ -663,6 +655,12 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
return; return;
} }
// Handle clicking an empty workspace
if (node && node->type == N_WORKSPACE) {
seat_set_focus(seat, node);
return;
}
// Handle clicking a layer surface // Handle clicking a layer surface
if (surface && wlr_surface_is_layer_surface(surface)) { if (surface && wlr_surface_is_layer_surface(surface)) {
struct wlr_layer_surface *layer = struct wlr_layer_surface *layer =
@ -801,7 +799,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device, wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device,
event->x, event->y, &lx, &ly); event->x, event->y, &lx, &ly);
double sx, sy; double sx, sy;
container_at_coords(seat, lx, ly, &surface, &sx, &sy); node_at_coords(seat, lx, ly, &surface, &sx, &sy);
seat->touch_id = event->touch_id; seat->touch_id = event->touch_id;
seat->touch_x = lx; seat->touch_x = lx;
@ -843,7 +841,7 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device, wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device,
event->x, event->y, &lx, &ly); event->x, event->y, &lx, &ly);
double sx, sy; double sx, sy;
container_at_coords(cursor->seat, lx, ly, &surface, &sx, &sy); node_at_coords(cursor->seat, lx, ly, &surface, &sx, &sy);
if (seat->touch_id == event->touch_id) { if (seat->touch_id == event->touch_id) {
seat->touch_x = lx; seat->touch_x = lx;