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, | |||
911 | return; | 911 | return; |
912 | } | 912 | } |
913 | 913 | ||
914 | // Handle clicking a container surface | 914 | // Handle clicking a container surface or decorations |
915 | if (cont) { | 915 | if (cont) { |
916 | seat_set_focus_container(seat, cont); | 916 | node = seat_get_focus_inactive(seat, &cont->node); |
917 | seat_set_focus(seat, node); | ||
917 | seat_pointer_notify_button(seat, time_msec, button, state); | 918 | seat_pointer_notify_button(seat, time_msec, button, state); |
918 | return; | 919 | return; |
919 | } | 920 | } |
@@ -930,12 +931,52 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { | |||
930 | transaction_commit_dirty(); | 931 | transaction_commit_dirty(); |
931 | } | 932 | } |
932 | 933 | ||
934 | static void dispatch_cursor_axis(struct sway_cursor *cursor, | ||
935 | struct wlr_event_pointer_axis *event) { | ||
936 | struct sway_seat *seat = cursor->seat; | ||
937 | |||
938 | // Determine what's under the cursor | ||
939 | struct wlr_surface *surface = NULL; | ||
940 | double sx, sy; | ||
941 | struct sway_node *node = node_at_coords(seat, | ||
942 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); | ||
943 | struct sway_container *cont = node && node->type == N_CONTAINER ? | ||
944 | node->sway_container : NULL; | ||
945 | enum wlr_edges edge = cont ? find_edge(cont, cursor) : WLR_EDGE_NONE; | ||
946 | bool on_border = edge != WLR_EDGE_NONE; | ||
947 | bool on_titlebar = cont && !on_border && !surface; | ||
948 | |||
949 | // Scrolling on a tabbed or stacked title bar | ||
950 | if (on_titlebar) { | ||
951 | enum sway_container_layout layout = container_parent_layout(cont); | ||
952 | if (layout == L_TABBED || layout == L_STACKED) { | ||
953 | struct sway_node *active = | ||
954 | seat_get_active_tiling_child(seat, node_get_parent(node)); | ||
955 | list_t *siblings = container_get_siblings(cont); | ||
956 | int desired = list_find(siblings, active->sway_container) + | ||
957 | event->delta_discrete; | ||
958 | if (desired < 0) { | ||
959 | desired = 0; | ||
960 | } else if (desired >= siblings->length) { | ||
961 | desired = siblings->length - 1; | ||
962 | } | ||
963 | struct sway_container *new_focus = siblings->items[desired]; | ||
964 | node = seat_get_focus_inactive(seat, &new_focus->node); | ||
965 | seat_set_focus(seat, node); | ||
966 | return; | ||
967 | } | ||
968 | } | ||
969 | |||
970 | wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec, | ||
971 | event->orientation, event->delta, event->delta_discrete, event->source); | ||
972 | } | ||
973 | |||
933 | static void handle_cursor_axis(struct wl_listener *listener, void *data) { | 974 | static void handle_cursor_axis(struct wl_listener *listener, void *data) { |
934 | struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); | 975 | struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); |
935 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 976 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); |
936 | struct wlr_event_pointer_axis *event = data; | 977 | struct wlr_event_pointer_axis *event = data; |
937 | wlr_seat_pointer_notify_axis(cursor->seat->wlr_seat, event->time_msec, | 978 | dispatch_cursor_axis(cursor, event); |
938 | event->orientation, event->delta, event->delta_discrete, event->source); | 979 | transaction_commit_dirty(); |
939 | } | 980 | } |
940 | 981 | ||
941 | static void handle_touch_down(struct wl_listener *listener, void *data) { | 982 | 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) { | |||
186 | area->width, area->height, area->x, area->y); | 186 | area->width, area->height, area->x, area->y); |
187 | workspace_remove_gaps(workspace); | 187 | workspace_remove_gaps(workspace); |
188 | 188 | ||
189 | bool first_arrange = workspace->width == 0 && workspace->height == 0; | ||
189 | double prev_x = workspace->x; | 190 | double prev_x = workspace->x; |
190 | double prev_y = workspace->y; | 191 | double prev_y = workspace->y; |
191 | workspace->width = area->width; | 192 | workspace->width = area->width; |
@@ -196,7 +197,7 @@ void arrange_workspace(struct sway_workspace *workspace) { | |||
196 | // Adjust any floating containers | 197 | // Adjust any floating containers |
197 | double diff_x = workspace->x - prev_x; | 198 | double diff_x = workspace->x - prev_x; |
198 | double diff_y = workspace->y - prev_y; | 199 | double diff_y = workspace->y - prev_y; |
199 | if (diff_x != 0 || diff_y != 0) { | 200 | if (!first_arrange && (diff_x != 0 || diff_y != 0)) { |
200 | for (int i = 0; i < workspace->floating->length; ++i) { | 201 | for (int i = 0; i < workspace->floating->length; ++i) { |
201 | struct sway_container *floater = workspace->floating->items[i]; | 202 | struct sway_container *floater = workspace->floating->items[i]; |
202 | container_floating_translate(floater, diff_x, diff_y); | 203 | 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, | |||
215 | child_index = children->length - 1; | 215 | child_index = children->length - 1; |
216 | } | 216 | } |
217 | struct sway_container *child = children->items[child_index]; | 217 | struct sway_container *child = children->items[child_index]; |
218 | struct sway_node *node = seat_get_focus_inactive(seat, &child->node); | 218 | return child; |
219 | return node->sway_container; | ||
220 | } | 219 | } |
221 | 220 | ||
222 | // Surfaces | 221 | // Surfaces |
@@ -243,8 +242,7 @@ static struct sway_container *container_at_stacked(struct sway_node *parent, | |||
243 | int child_index = (ly - box.y) / title_height; | 242 | int child_index = (ly - box.y) / title_height; |
244 | if (child_index < children->length) { | 243 | if (child_index < children->length) { |
245 | struct sway_container *child = children->items[child_index]; | 244 | struct sway_container *child = children->items[child_index]; |
246 | struct sway_node *node = seat_get_focus_inactive(seat, &child->node); | 245 | return child; |
247 | return node->sway_container; | ||
248 | } | 246 | } |
249 | 247 | ||
250 | // Surfaces | 248 | // 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, | |||
54 | return NULL; | 54 | return NULL; |
55 | } | 55 | } |
56 | node_init(&ws->node, N_WORKSPACE, ws); | 56 | node_init(&ws->node, N_WORKSPACE, ws); |
57 | ws->x = output->lx; | ||
58 | ws->y = output->ly; | ||
59 | ws->width = output->width; | ||
60 | ws->height = output->height; | ||
61 | ws->name = name ? strdup(name) : NULL; | 57 | ws->name = name ? strdup(name) : NULL; |
62 | ws->prev_split_layout = L_NONE; | 58 | ws->prev_split_layout = L_NONE; |
63 | ws->layout = output_get_default_layout(output); | 59 | ws->layout = output_get_default_layout(output); |