diff options
Diffstat (limited to 'sway/input/seatop_resize_floating.c')
-rw-r--r-- | sway/input/seatop_resize_floating.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/sway/input/seatop_resize_floating.c b/sway/input/seatop_resize_floating.c index 5da22e47..df683026 100644 --- a/sway/input/seatop_resize_floating.c +++ b/sway/input/seatop_resize_floating.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <limits.h> | 2 | #include <limits.h> |
3 | #include <wlr/types/wlr_cursor.h> | 3 | #include <wlr/types/wlr_cursor.h> |
4 | #include <wlr/types/wlr_xcursor_manager.h> | 4 | #include <wlr/types/wlr_xcursor_manager.h> |
5 | #include "sway/desktop/transaction.h" | ||
5 | #include "sway/input/cursor.h" | 6 | #include "sway/input/cursor.h" |
6 | #include "sway/input/seat.h" | 7 | #include "sway/input/seat.h" |
7 | #include "sway/tree/arrange.h" | 8 | #include "sway/tree/arrange.h" |
@@ -27,6 +28,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
27 | if (seat->cursor->pressed_button_count == 0) { | 28 | if (seat->cursor->pressed_button_count == 0) { |
28 | container_set_resizing(con, false); | 29 | container_set_resizing(con, false); |
29 | arrange_container(con); // Send configure w/o resizing hint | 30 | arrange_container(con); // Send configure w/o resizing hint |
31 | transaction_commit_dirty(); | ||
30 | seatop_begin_default(seat); | 32 | seatop_begin_default(seat); |
31 | } | 33 | } |
32 | } | 34 | } |
@@ -78,17 +80,25 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) { | |||
78 | double height = e->ref_height + grow_height; | 80 | double height = e->ref_height + grow_height; |
79 | int min_width, max_width, min_height, max_height; | 81 | int min_width, max_width, min_height, max_height; |
80 | floating_calculate_constraints(&min_width, &max_width, | 82 | floating_calculate_constraints(&min_width, &max_width, |
81 | &min_height, &max_height); | 83 | &min_height, &max_height); |
82 | width = fmax(min_width + border_width, fmin(width, max_width)); | 84 | width = fmin(width, max_width - border_width); |
83 | height = fmax(min_height + border_height, fmin(height, max_height)); | 85 | width = fmax(width, min_width + border_width); |
86 | width = fmax(width, 1); | ||
87 | height = fmin(height, max_height - border_height); | ||
88 | height = fmax(height, min_height + border_height); | ||
89 | height = fmax(height, 1); | ||
84 | 90 | ||
85 | // Apply the view's min/max size | 91 | // Apply the view's min/max size |
86 | if (con->view) { | 92 | if (con->view) { |
87 | double view_min_width, view_max_width, view_min_height, view_max_height; | 93 | double view_min_width, view_max_width, view_min_height, view_max_height; |
88 | view_get_constraints(con->view, &view_min_width, &view_max_width, | 94 | view_get_constraints(con->view, &view_min_width, &view_max_width, |
89 | &view_min_height, &view_max_height); | 95 | &view_min_height, &view_max_height); |
90 | width = fmax(view_min_width + border_width, fmin(width, view_max_width)); | 96 | width = fmin(width, view_max_width - border_width); |
91 | height = fmax(view_min_height + border_height, fmin(height, view_max_height)); | 97 | width = fmax(width, view_min_width + border_width); |
98 | width = fmax(width, 1); | ||
99 | height = fmin(height, view_max_height - border_height); | ||
100 | height = fmax(height, view_min_height + border_height); | ||
101 | height = fmax(height, 1); | ||
92 | 102 | ||
93 | } | 103 | } |
94 | 104 | ||
@@ -116,23 +126,24 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) { | |||
116 | 126 | ||
117 | // Determine the amounts we need to bump everything relative to the current | 127 | // Determine the amounts we need to bump everything relative to the current |
118 | // size. | 128 | // size. |
119 | int relative_grow_width = width - con->width; | 129 | int relative_grow_width = width - con->pending.width; |
120 | int relative_grow_height = height - con->height; | 130 | int relative_grow_height = height - con->pending.height; |
121 | int relative_grow_x = (e->ref_con_lx + grow_x) - con->x; | 131 | int relative_grow_x = (e->ref_con_lx + grow_x) - con->pending.x; |
122 | int relative_grow_y = (e->ref_con_ly + grow_y) - con->y; | 132 | int relative_grow_y = (e->ref_con_ly + grow_y) - con->pending.y; |
123 | 133 | ||
124 | // Actually resize stuff | 134 | // Actually resize stuff |
125 | con->x += relative_grow_x; | 135 | con->pending.x += relative_grow_x; |
126 | con->y += relative_grow_y; | 136 | con->pending.y += relative_grow_y; |
127 | con->width += relative_grow_width; | 137 | con->pending.width += relative_grow_width; |
128 | con->height += relative_grow_height; | 138 | con->pending.height += relative_grow_height; |
129 | 139 | ||
130 | con->content_x += relative_grow_x; | 140 | con->pending.content_x += relative_grow_x; |
131 | con->content_y += relative_grow_y; | 141 | con->pending.content_y += relative_grow_y; |
132 | con->content_width += relative_grow_width; | 142 | con->pending.content_width += relative_grow_width; |
133 | con->content_height += relative_grow_height; | 143 | con->pending.content_height += relative_grow_height; |
134 | 144 | ||
135 | arrange_container(con); | 145 | arrange_container(con); |
146 | transaction_commit_dirty(); | ||
136 | } | 147 | } |
137 | 148 | ||
138 | static void handle_unref(struct sway_seat *seat, struct sway_container *con) { | 149 | static void handle_unref(struct sway_seat *seat, struct sway_container *con) { |
@@ -166,16 +177,17 @@ void seatop_begin_resize_floating(struct sway_seat *seat, | |||
166 | e->edge = edge == WLR_EDGE_NONE ? WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT : edge; | 177 | e->edge = edge == WLR_EDGE_NONE ? WLR_EDGE_BOTTOM | WLR_EDGE_RIGHT : edge; |
167 | e->ref_lx = seat->cursor->cursor->x; | 178 | e->ref_lx = seat->cursor->cursor->x; |
168 | e->ref_ly = seat->cursor->cursor->y; | 179 | e->ref_ly = seat->cursor->cursor->y; |
169 | e->ref_con_lx = con->x; | 180 | e->ref_con_lx = con->pending.x; |
170 | e->ref_con_ly = con->y; | 181 | e->ref_con_ly = con->pending.y; |
171 | e->ref_width = con->width; | 182 | e->ref_width = con->pending.width; |
172 | e->ref_height = con->height; | 183 | e->ref_height = con->pending.height; |
173 | 184 | ||
174 | seat->seatop_impl = &seatop_impl; | 185 | seat->seatop_impl = &seatop_impl; |
175 | seat->seatop_data = e; | 186 | seat->seatop_data = e; |
176 | 187 | ||
177 | container_set_resizing(con, true); | 188 | container_set_resizing(con, true); |
178 | container_raise_floating(con); | 189 | container_raise_floating(con); |
190 | transaction_commit_dirty(); | ||
179 | 191 | ||
180 | const char *image = edge == WLR_EDGE_NONE ? | 192 | const char *image = edge == WLR_EDGE_NONE ? |
181 | "se-resize" : wlr_xcursor_get_resize_name(edge); | 193 | "se-resize" : wlr_xcursor_get_resize_name(edge); |