diff options
author | taiyu <taiyu.len@gmail.com> | 2015-08-22 22:14:59 -0700 |
---|---|---|
committer | taiyu <taiyu.len@gmail.com> | 2015-08-22 22:14:59 -0700 |
commit | f53ce887e854dba1db327ae8e18b12dd385e2743 (patch) | |
tree | 61efa126fd93c1dda6dd7603453441379d8ea648 | |
parent | dont swap view with workspace... (diff) | |
download | sway-f53ce887e854dba1db327ae8e18b12dd385e2743.tar.gz sway-f53ce887e854dba1db327ae8e18b12dd385e2743.tar.zst sway-f53ce887e854dba1db327ae8e18b12dd385e2743.zip |
fixed container resize oddity
-rw-r--r-- | sway/input_state.c | 57 | ||||
-rw-r--r-- | sway/layout.c | 39 |
2 files changed, 36 insertions, 60 deletions
diff --git a/sway/input_state.c b/sway/input_state.c index cb8632de..ece75bf4 100644 --- a/sway/input_state.c +++ b/sway/input_state.c | |||
@@ -60,10 +60,12 @@ static struct mode_state { | |||
60 | struct { | 60 | struct { |
61 | double x, w; | 61 | double x, w; |
62 | swayc_t *ptr; | 62 | swayc_t *ptr; |
63 | swayc_t *sib; | ||
63 | } lr; | 64 | } lr; |
64 | struct { | 65 | struct { |
65 | double y, h; | 66 | double y, h; |
66 | swayc_t *ptr; | 67 | swayc_t *ptr; |
68 | swayc_t *sib; | ||
67 | } tb; | 69 | } tb; |
68 | } initial; | 70 | } initial; |
69 | 71 | ||
@@ -72,7 +74,7 @@ static struct { | |||
72 | bool top; | 74 | bool top; |
73 | } lock; | 75 | } lock; |
74 | 76 | ||
75 | // Floating set/unset | 77 | // initial set/unset |
76 | 78 | ||
77 | static void set_initial_view(swayc_t *view) { | 79 | static void set_initial_view(swayc_t *view) { |
78 | initial.ptr = view; | 80 | initial.ptr = view; |
@@ -82,6 +84,26 @@ static void set_initial_view(swayc_t *view) { | |||
82 | initial.h = view->height; | 84 | initial.h = view->height; |
83 | } | 85 | } |
84 | 86 | ||
87 | static void set_initial_sibling(void) { | ||
88 | bool reset = true; | ||
89 | if ((initial.lr.ptr = get_swayc_in_direction(initial.ptr, lock.left ? MOVE_RIGHT: MOVE_LEFT))) { | ||
90 | initial.lr.sib = get_swayc_in_direction(initial.lr.ptr, lock.left ? MOVE_LEFT : MOVE_RIGHT); | ||
91 | initial.lr.x = initial.lr.ptr->x; | ||
92 | initial.lr.w = initial.lr.ptr->width; | ||
93 | reset = false; | ||
94 | } | ||
95 | if ((initial.tb.ptr = get_swayc_in_direction(initial.ptr, lock.top ? MOVE_DOWN: MOVE_UP))) { | ||
96 | initial.tb.sib = get_swayc_in_direction(initial.tb.ptr, lock.top ? MOVE_UP : MOVE_DOWN); | ||
97 | initial.tb.y = initial.tb.ptr->y; | ||
98 | initial.tb.h = initial.tb.ptr->height; | ||
99 | reset = false; | ||
100 | } | ||
101 | // If nothing changes just undo the mode | ||
102 | if (reset) { | ||
103 | pointer_state.mode = 0; | ||
104 | } | ||
105 | } | ||
106 | |||
85 | static void reset_initial_view(void) { | 107 | static void reset_initial_view(void) { |
86 | initial.ptr->x = initial.x; | 108 | initial.ptr->x = initial.x; |
87 | initial.ptr->y = initial.y; | 109 | initial.ptr->y = initial.y; |
@@ -114,22 +136,8 @@ static void pointer_mode_set_right(void) { | |||
114 | if (initial.ptr->is_floating) { | 136 | if (initial.ptr->is_floating) { |
115 | pointer_state.mode = M_RESIZING | M_FLOATING; | 137 | pointer_state.mode = M_RESIZING | M_FLOATING; |
116 | } else { | 138 | } else { |
117 | bool reset = true; | ||
118 | pointer_state.mode = M_RESIZING | M_TILING; | 139 | pointer_state.mode = M_RESIZING | M_TILING; |
119 | if ((initial.lr.ptr = get_swayc_in_direction(initial.ptr, lock.left ? MOVE_RIGHT: MOVE_LEFT))) { | 140 | set_initial_sibling(); |
120 | initial.lr.x = initial.lr.ptr->x; | ||
121 | initial.lr.w = initial.lr.ptr->width; | ||
122 | reset = false; | ||
123 | } | ||
124 | if ((initial.tb.ptr = get_swayc_in_direction(initial.ptr, lock.top ? MOVE_DOWN: MOVE_UP))) { | ||
125 | initial.tb.y = initial.tb.ptr->y; | ||
126 | initial.tb.h = initial.tb.ptr->height; | ||
127 | reset = false; | ||
128 | } | ||
129 | // If nothing changes just undo the mode | ||
130 | if (reset) { | ||
131 | pointer_state.mode = 0; | ||
132 | } | ||
133 | } | 141 | } |
134 | } | 142 | } |
135 | 143 | ||
@@ -187,7 +195,6 @@ void pointer_mode_update(void) { | |||
187 | } | 195 | } |
188 | int dx = pointer_state.origin.x; | 196 | int dx = pointer_state.origin.x; |
189 | int dy = pointer_state.origin.y; | 197 | int dy = pointer_state.origin.y; |
190 | bool changed = false; | ||
191 | 198 | ||
192 | switch (pointer_state.mode) { | 199 | switch (pointer_state.mode) { |
193 | case M_FLOATING | M_DRAGGING: | 200 | case M_FLOATING | M_DRAGGING: |
@@ -196,11 +203,9 @@ void pointer_mode_update(void) { | |||
196 | dy -= pointer_state.left.y; | 203 | dy -= pointer_state.left.y; |
197 | if (initial.x + dx != initial.ptr->x) { | 204 | if (initial.x + dx != initial.ptr->x) { |
198 | initial.ptr->x = initial.x + dx; | 205 | initial.ptr->x = initial.x + dx; |
199 | changed = true; | ||
200 | } | 206 | } |
201 | if (initial.y + dy != initial.ptr->y) { | 207 | if (initial.y + dy != initial.ptr->y) { |
202 | initial.ptr->y = initial.y + dy; | 208 | initial.ptr->y = initial.y + dy; |
203 | changed = true; | ||
204 | } | 209 | } |
205 | update_geometry(initial.ptr); | 210 | update_geometry(initial.ptr); |
206 | break; | 211 | break; |
@@ -253,37 +258,31 @@ void pointer_mode_update(void) { | |||
253 | if (lock.left) { | 258 | if (lock.left) { |
254 | // Check whether its fine to resize | 259 | // Check whether its fine to resize |
255 | if (initial.w + dx > min_sane_w && initial.lr.w - dx > min_sane_w) { | 260 | if (initial.w + dx > min_sane_w && initial.lr.w - dx > min_sane_w) { |
256 | initial.ptr->width = initial.w + dx; | 261 | initial.lr.sib->width = initial.w + dx; |
257 | initial.lr.ptr->width = initial.lr.w - dx; | 262 | initial.lr.ptr->width = initial.lr.w - dx; |
258 | } | 263 | } |
259 | } else { //lock.right | 264 | } else { //lock.right |
260 | if (initial.w - dx > min_sane_w && initial.lr.w + dx > min_sane_w) { | 265 | if (initial.w - dx > min_sane_w && initial.lr.w + dx > min_sane_w) { |
261 | initial.ptr->width = initial.w - dx; | 266 | initial.lr.sib->width = initial.w - dx; |
262 | initial.lr.ptr->width = initial.lr.w + dx; | 267 | initial.lr.ptr->width = initial.lr.w + dx; |
263 | } | 268 | } |
264 | changed = true; | ||
265 | } | 269 | } |
266 | arrange_windows(initial.lr.ptr->parent, -1, -1); | 270 | arrange_windows(initial.lr.ptr->parent, -1, -1); |
267 | } | 271 | } |
268 | if (initial.tb.ptr) { | 272 | if (initial.tb.ptr) { |
269 | if (lock.top) { | 273 | if (lock.top) { |
270 | if (initial.h + dy > min_sane_h && initial.tb.h - dy > min_sane_h) { | 274 | if (initial.h + dy > min_sane_h && initial.tb.h - dy > min_sane_h) { |
271 | initial.ptr->height = initial.h + dy; | 275 | initial.tb.sib->height = initial.h + dy; |
272 | initial.tb.ptr->height = initial.tb.h - dy; | 276 | initial.tb.ptr->height = initial.tb.h - dy; |
273 | } | 277 | } |
274 | } else { //lock.bottom | 278 | } else { //lock.bottom |
275 | if (initial.h - dy > min_sane_h && initial.tb.h + dy > min_sane_h) { | 279 | if (initial.h - dy > min_sane_h && initial.tb.h + dy > min_sane_h) { |
276 | initial.ptr->height = initial.h - dy; | 280 | initial.tb.sib->height = initial.h - dy; |
277 | initial.tb.ptr->height = initial.tb.h + dy; | 281 | initial.tb.ptr->height = initial.tb.h + dy; |
278 | } | 282 | } |
279 | changed = true; | ||
280 | } | 283 | } |
281 | arrange_windows(initial.tb.ptr->parent, -1, -1); | 284 | arrange_windows(initial.tb.ptr->parent, -1, -1); |
282 | } | 285 | } |
283 | if (changed) { | ||
284 | arrange_windows(initial.ptr->parent, -1, -1); | ||
285 | } | ||
286 | changed = false; | ||
287 | default: | 286 | default: |
288 | return; | 287 | return; |
289 | } | 288 | } |
diff --git a/sway/layout.c b/sway/layout.c index fd2e80fe..4d738433 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -209,12 +209,12 @@ void update_geometry(swayc_t *container) { | |||
209 | } | 209 | } |
210 | struct wlc_geometry geometry = { | 210 | struct wlc_geometry geometry = { |
211 | .origin = { | 211 | .origin = { |
212 | .x = container->x + container->gaps / 2, | 212 | .x = container->x + (container->is_floating ? 0 : container->gaps / 2), |
213 | .y = container->y + container->gaps / 2 | 213 | .y = container->y + (container->is_floating ? 0 : container->gaps / 2) |
214 | }, | 214 | }, |
215 | .size = { | 215 | .size = { |
216 | .w = container->width - container->gaps, | 216 | .w = container->width - (container->is_floating ? 0 : container->gaps), |
217 | .h = container->height - container->gaps | 217 | .h = container->height - (container->is_floating ? 0 : container->gaps) |
218 | } | 218 | } |
219 | }; | 219 | }; |
220 | if (swayc_is_fullscreen(container)) { | 220 | if (swayc_is_fullscreen(container)) { |
@@ -347,35 +347,12 @@ void arrange_windows(swayc_t *container, double width, double height) { | |||
347 | for (i = 0; i < container->floating->length; ++i) { | 347 | for (i = 0; i < container->floating->length; ++i) { |
348 | swayc_t *view = container->floating->items[i]; | 348 | swayc_t *view = container->floating->items[i]; |
349 | if (view->type == C_VIEW) { | 349 | if (view->type == C_VIEW) { |
350 | // Set the geometry | 350 | update_geometry(view); |
351 | struct wlc_geometry geometry = { | ||
352 | .origin = { | ||
353 | .x = view->x, | ||
354 | .y = view->y | ||
355 | }, | ||
356 | .size = { | ||
357 | .w = view->width, | ||
358 | .h = view->height | ||
359 | } | ||
360 | }; | ||
361 | if (swayc_is_fullscreen(view)) { | 351 | if (swayc_is_fullscreen(view)) { |
362 | swayc_t *parent = swayc_parent_by_type(view, C_OUTPUT); | ||
363 | geometry.origin.x = 0; | ||
364 | geometry.origin.y = 0; | ||
365 | geometry.size.w = parent->width; | ||
366 | geometry.size.h = parent->height; | ||
367 | wlc_view_set_geometry(view->handle, 0, &geometry); | ||
368 | wlc_view_bring_to_front(view->handle); | 352 | wlc_view_bring_to_front(view->handle); |
369 | } else { | 353 | } else if (!container->focused |
370 | wlc_view_set_geometry(view->handle, 0, &geometry); | 354 | || !swayc_is_fullscreen(container->focused)) { |
371 | // Bring the views to the front in order of the list, the list | 355 | wlc_view_bring_to_front(view->handle); |
372 | // will be kept up to date so that more recently focused views | ||
373 | // have higher indexes | ||
374 | // This is conditional on there not being a fullscreen view in the workspace | ||
375 | if (!container->focused | ||
376 | || !swayc_is_fullscreen(container->focused)) { | ||
377 | wlc_view_bring_to_front(view->handle); | ||
378 | } | ||
379 | } | 356 | } |
380 | } | 357 | } |
381 | } | 358 | } |