diff options
-rw-r--r-- | sway/input/cursor.c | 49 | ||||
-rw-r--r-- | sway/tree/arrange.c | 3 | ||||
-rw-r--r-- | sway/tree/container.c | 6 | ||||
-rw-r--r-- | sway/tree/workspace.c | 4 |
4 files changed, 49 insertions, 13 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 85951c09..5111e8e5 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -911,9 +911,10 @@ void dispatch_cursor_button(struct sway_cursor *cursor, return; } - // Handle clicking a container surface + // Handle clicking a container surface or decorations if (cont) { - seat_set_focus_container(seat, cont); + node = seat_get_focus_inactive(seat, &cont->node); + seat_set_focus(seat, node); seat_pointer_notify_button(seat, time_msec, button, state); return; } @@ -930,12 +931,52 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { transaction_commit_dirty(); } +static void dispatch_cursor_axis(struct sway_cursor *cursor, + struct wlr_event_pointer_axis *event) { + struct sway_seat *seat = cursor->seat; + + // Determine what's under the cursor + struct wlr_surface *surface = NULL; + double sx, sy; + struct sway_node *node = node_at_coords(seat, + cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); + struct sway_container *cont = node && node->type == N_CONTAINER ? + node->sway_container : NULL; + enum wlr_edges edge = cont ? find_edge(cont, cursor) : WLR_EDGE_NONE; + bool on_border = edge != WLR_EDGE_NONE; + bool on_titlebar = cont && !on_border && !surface; + + // Scrolling on a tabbed or stacked title bar + if (on_titlebar) { + enum sway_container_layout layout = container_parent_layout(cont); + if (layout == L_TABBED || layout == L_STACKED) { + struct sway_node *active = + seat_get_active_tiling_child(seat, node_get_parent(node)); + list_t *siblings = container_get_siblings(cont); + int desired = list_find(siblings, active->sway_container) + + event->delta_discrete; + if (desired < 0) { + desired = 0; + } else if (desired >= siblings->length) { + desired = siblings->length - 1; + } + struct sway_container *new_focus = siblings->items[desired]; + node = seat_get_focus_inactive(seat, &new_focus->node); + seat_set_focus(seat, node); + return; + } + } + + wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec, + event->orientation, event->delta, event->delta_discrete, event->source); +} + static void handle_cursor_axis(struct wl_listener *listener, void *data) { struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); struct wlr_event_pointer_axis *event = data; - wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec, - event->orientation, event->delta, event->delta_discrete, event->source); + dispatch_cursor_axis(cursor, event); + transaction_commit_dirty(); } static void handle_touch_down(struct wl_listener *listener, void *data) { diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c index d50be25d..373460a2 100644 --- a/sway/tree/arrange.c +++ b/sway/tree/arrange.c @@ -186,6 +186,7 @@ void arrange_workspace(struct sway_workspace *workspace) { area->width, area->height, area->x, area->y); workspace_remove_gaps(workspace); + bool first_arrange = workspace->width == 0 && workspace->height == 0; double prev_x = workspace->x; double prev_y = workspace->y; workspace->width = area->width; @@ -196,7 +197,7 @@ void arrange_workspace(struct sway_workspace *workspace) { // Adjust any floating containers double diff_x = workspace->x - prev_x; double diff_y = workspace->y - prev_y; - if (diff_x != 0 || diff_y != 0) { + if (!first_arrange && (diff_x != 0 || diff_y != 0)) { for (int i = 0; i < workspace->floating->length; ++i) { struct sway_container *floater = workspace->floating->items[i]; container_floating_translate(floater, diff_x, diff_y); diff --git a/sway/tree/container.c b/sway/tree/container.c index 8dc22410..53b127b7 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -215,8 +215,7 @@ static struct sway_container *container_at_tabbed(struct sway_node *parent, child_index = children->length - 1; } struct sway_container *child = children->items[child_index]; - struct sway_node *node = seat_get_focus_inactive(seat, &child->node); - return node->sway_container; + return child; } // Surfaces @@ -243,8 +242,7 @@ static struct sway_container *container_at_stacked(struct sway_node *parent, int child_index = (ly - box.y) / title_height; if (child_index < children->length) { struct sway_container *child = children->items[child_index]; - struct sway_node *node = seat_get_focus_inactive(seat, &child->node); - return node->sway_container; + return child; } // Surfaces diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index b0c440c1..16031e87 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -54,10 +54,6 @@ struct sway_workspace *workspace_create(struct sway_output *output, return NULL; } node_init(&ws->node, N_WORKSPACE, ws); - ws->x = output->lx; - ws->y = output->ly; - ws->width = output->width; - ws->height = output->height; ws->name = name ? strdup(name) : NULL; ws->prev_split_layout = L_NONE; ws->layout = output_get_default_layout(output); |