diff options
Diffstat (limited to 'sway/layout.c')
-rw-r--r-- | sway/layout.c | 81 |
1 files changed, 65 insertions, 16 deletions
diff --git a/sway/layout.c b/sway/layout.c index 4d738433..bc12b9b1 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -242,21 +242,14 @@ void arrange_windows(swayc_t *container, double width, double height) { | |||
242 | for (i = 0; i < container->children->length; ++i) { | 242 | for (i = 0; i < container->children->length; ++i) { |
243 | swayc_t *child = container->children->items[i]; | 243 | swayc_t *child = container->children->items[i]; |
244 | sway_log(L_DEBUG, "Arranging output at %d", x); | 244 | sway_log(L_DEBUG, "Arranging output at %d", x); |
245 | child->x = x; | ||
246 | child->y = y; | ||
247 | arrange_windows(child, -1, -1); | 245 | arrange_windows(child, -1, -1); |
248 | // Removed for now because wlc works with relative positions | 246 | x += child->width; |
249 | // Addition can be reconsidered once wlc positions are changed | ||
250 | // x += child->width; | ||
251 | } | 247 | } |
252 | return; | 248 | return; |
253 | case C_OUTPUT: | 249 | case C_OUTPUT: |
254 | container->width = width; | 250 | container->width = width; |
255 | container->height = height; | 251 | container->height = height; |
256 | // These lines make x/y negative and result in stuff glitching out | 252 | x = 0, y = 0; |
257 | // Their addition can be reconsidered once wlc positions are changed | ||
258 | // x -= container->x; | ||
259 | // y -= container->y; | ||
260 | for (i = 0; i < container->children->length; ++i) { | 253 | for (i = 0; i < container->children->length; ++i) { |
261 | swayc_t *child = container->children->items[i]; | 254 | swayc_t *child = container->children->items[i]; |
262 | child->x = x + container->gaps; | 255 | child->x = x + container->gaps; |
@@ -375,19 +368,75 @@ swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir) | |||
375 | // Test if we can even make a difference here | 368 | // Test if we can even make a difference here |
376 | bool can_move = false; | 369 | bool can_move = false; |
377 | int diff = 0; | 370 | int diff = 0; |
378 | if (dir == MOVE_LEFT || dir == MOVE_RIGHT) { | 371 | int i; |
379 | if (parent->layout == L_HORIZ || parent->type == C_ROOT) { | 372 | if (parent->type == C_ROOT) { |
373 | // Find the next output | ||
374 | int target = -1, max_x = 0, max_y = 0, self = -1; | ||
375 | sway_log(L_DEBUG, "Moving between outputs"); | ||
376 | |||
377 | for (i = 0; i < parent->children->length; ++i) { | ||
378 | swayc_t *next = parent->children->items[i]; | ||
379 | if (next == container) { | ||
380 | self = i; | ||
381 | sway_log(L_DEBUG, "self is %p %d", next, self); | ||
382 | continue; | ||
383 | } | ||
384 | if (next->type == C_OUTPUT) { | ||
385 | sway_log(L_DEBUG, "Testing with %p %d (dir %d)", next, i, dir); | ||
386 | // Check if it's more extreme | ||
387 | if (dir == MOVE_RIGHT) { | ||
388 | if (container->x + container->width <= next->x) { | ||
389 | if (target == -1 || next->x < max_x) { | ||
390 | target = i; | ||
391 | max_x = next->x; | ||
392 | } | ||
393 | } | ||
394 | } else if (dir == MOVE_LEFT) { | ||
395 | if (container->x >= next->x + next->width) { | ||
396 | if (target == -1 || max_x < next->x) { | ||
397 | target = i; | ||
398 | max_x = next->x; | ||
399 | } | ||
400 | } | ||
401 | } else if (dir == MOVE_DOWN) { | ||
402 | if (container->y + container->height <= next->y) { | ||
403 | if (target == -1 || next->y < max_y) { | ||
404 | target = i; | ||
405 | max_y = next->y; | ||
406 | } | ||
407 | } | ||
408 | } else if (dir == MOVE_UP) { | ||
409 | if (container->y >= next->y + next->height) { | ||
410 | if (target == -1 || max_y < next->y) { | ||
411 | target = i; | ||
412 | max_y = next->y; | ||
413 | } | ||
414 | } | ||
415 | } | ||
416 | } | ||
417 | } | ||
418 | |||
419 | if (target == -1) { | ||
420 | can_move = false; | ||
421 | } else { | ||
380 | can_move = true; | 422 | can_move = true; |
381 | diff = dir == MOVE_LEFT ? -1 : 1; | 423 | diff = target - self; |
382 | } | 424 | } |
383 | } else { | 425 | } else { |
384 | if (parent->layout == L_VERT) { | 426 | if (dir == MOVE_LEFT || dir == MOVE_RIGHT) { |
385 | can_move = true; | 427 | if (parent->layout == L_HORIZ) { |
386 | diff = dir == MOVE_UP ? -1 : 1; | 428 | can_move = true; |
429 | diff = dir == MOVE_LEFT ? -1 : 1; | ||
430 | } | ||
431 | } else { | ||
432 | if (parent->layout == L_VERT) { | ||
433 | can_move = true; | ||
434 | diff = dir == MOVE_UP ? -1 : 1; | ||
435 | } | ||
387 | } | 436 | } |
388 | } | 437 | } |
438 | |||
389 | if (can_move) { | 439 | if (can_move) { |
390 | int i; | ||
391 | for (i = 0; i < parent->children->length; ++i) { | 440 | for (i = 0; i < parent->children->length; ++i) { |
392 | swayc_t *child = parent->children->items[i]; | 441 | swayc_t *child = parent->children->items[i]; |
393 | if (child == container) { | 442 | if (child == container) { |