diff options
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/cursor.c | 15 | ||||
-rw-r--r-- | sway/input/seat.c | 22 |
2 files changed, 24 insertions, 13 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 6751931d..16e5427b 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -46,7 +46,7 @@ static struct wlr_surface *layer_surface_at(struct sway_output *output, * location, it is stored in **surface (it may not be a view). */ static struct sway_container *container_at_coords( - struct sway_seat *seat, double x, double y, + struct sway_seat *seat, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { // check for unmanaged views first struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged; @@ -55,8 +55,8 @@ static struct sway_container *container_at_coords( struct wlr_xwayland_surface *xsurface = unmanaged_surface->wlr_xwayland_surface; - double _sx = x - unmanaged_surface->lx; - double _sy = y - unmanaged_surface->ly; + double _sx = lx - unmanaged_surface->lx; + double _sy = ly - unmanaged_surface->ly; if (wlr_surface_point_accepts_input(xsurface->surface, _sx, _sy)) { *surface = xsurface->surface; *sx = _sx; @@ -69,12 +69,12 @@ static struct sway_container *container_at_coords( struct wlr_output_layout *output_layout = root_container.sway_root->output_layout; struct wlr_output *wlr_output = wlr_output_layout_output_at( - output_layout, x, y); + output_layout, lx, ly); if (wlr_output == NULL) { return NULL; } struct sway_output *output = wlr_output->data; - double ox = x, oy = y; + double ox = lx, oy = ly; wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy); // find the focused workspace on the output for this seat @@ -108,7 +108,10 @@ static struct sway_container *container_at_coords( } struct sway_container *c; - if ((c = container_at(ws, ox, oy, surface, sx, sy))) { + if ((c = floating_container_at(lx, ly, surface, sx, sy))) { + return c; + } + if ((c = container_at(ws, lx, ly, surface, sx, sy))) { return c; } diff --git a/sway/input/seat.c b/sway/input/seat.c index 0295212c..d35cbeef 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -113,7 +113,14 @@ static void seat_send_focus(struct sway_container *con, static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, struct sway_container *container, enum sway_container_type type) { - if (container->type == C_VIEW || container->children->length == 0) { + if (container->type == C_VIEW) { + return container; + } + + struct sway_container *floating = container->type == C_WORKSPACE ? + container->sway_workspace->floating : NULL; + if (container->children->length == 0 && + (!floating || floating->children->length == 0)) { return container; } @@ -126,6 +133,9 @@ static struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, if (container_has_child(container, current->container)) { return current->container; } + if (floating && container_has_child(floating, current->container)) { + return current->container; + } } return NULL; @@ -568,7 +578,7 @@ void seat_set_focus_warp(struct sway_seat *seat, // clean up unfocused empty workspace on new output if (new_output_last_ws) { if (!workspace_is_visible(new_output_last_ws) - && new_output_last_ws->children->length == 0) { + && workspace_is_empty(new_output_last_ws)) { if (last_workspace == new_output_last_ws) { last_focus = NULL; last_workspace = NULL; @@ -581,7 +591,7 @@ void seat_set_focus_warp(struct sway_seat *seat, if (last_workspace) { ipc_event_workspace(last_workspace, container, "focus"); if (!workspace_is_visible(last_workspace) - && last_workspace->children->length == 0) { + && workspace_is_empty(last_workspace)) { if (last_workspace == last_focus) { last_focus = NULL; } @@ -591,10 +601,8 @@ void seat_set_focus_warp(struct sway_seat *seat, if (config->mouse_warping && warp) { if (new_output && last_output && new_output != last_output) { - double x = new_output->x + container->x + - container->width / 2.0; - double y = new_output->y + container->y + - container->height / 2.0; + double x = container->x + container->width / 2.0; + double y = container->y + container->height / 2.0; struct wlr_output *wlr_output = new_output->sway_output->wlr_output; if (!wlr_output_layout_contains_point( |