|
|
@ -1,5 +1,6 @@
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <wlc/wlc.h>
|
|
|
|
#include <wlc/wlc.h>
|
|
|
|
#include "extensions.h"
|
|
|
|
#include "extensions.h"
|
|
|
|
#include "layout.h"
|
|
|
|
#include "layout.h"
|
|
|
@ -379,6 +380,11 @@ void update_geometry(swayc_t *container) {
|
|
|
|
swayc_t *ws = swayc_parent_by_type(container, C_WORKSPACE);
|
|
|
|
swayc_t *ws = swayc_parent_by_type(container, C_WORKSPACE);
|
|
|
|
swayc_t *op = ws->parent;
|
|
|
|
swayc_t *op = ws->parent;
|
|
|
|
int gap = container->is_floating ? 0 : swayc_gap(container);
|
|
|
|
int gap = container->is_floating ? 0 : swayc_gap(container);
|
|
|
|
|
|
|
|
if (gap % 2 != 0) {
|
|
|
|
|
|
|
|
// because gaps are implemented as "half sized margins" it's currently
|
|
|
|
|
|
|
|
// not possible to align views properly with odd sized gaps.
|
|
|
|
|
|
|
|
gap -= 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlc_geometry geometry = {
|
|
|
|
struct wlc_geometry geometry = {
|
|
|
|
.origin = {
|
|
|
|
.origin = {
|
|
|
@ -430,11 +436,16 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
|
|
|
|
width = container->width;
|
|
|
|
width = container->width;
|
|
|
|
height = container->height;
|
|
|
|
height = container->height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// pixels are indivisable. if we don't round the pixels, then the view
|
|
|
|
|
|
|
|
// calculations will be off (e.g. 50.5 + 50.5 = 101, but in reality it's
|
|
|
|
|
|
|
|
// 50 + 50 = 100). doing it here cascades properly to all width/height/x/y.
|
|
|
|
|
|
|
|
width = floor(width);
|
|
|
|
|
|
|
|
height = floor(height);
|
|
|
|
|
|
|
|
|
|
|
|
sway_log(L_DEBUG, "Arranging layout for %p %s %fx%f+%f,%f", container,
|
|
|
|
sway_log(L_DEBUG, "Arranging layout for %p %s %fx%f+%f,%f", container,
|
|
|
|
container->name, container->width, container->height, container->x, container->y);
|
|
|
|
container->name, container->width, container->height, container->x, container->y);
|
|
|
|
|
|
|
|
|
|
|
|
int x = 0, y = 0;
|
|
|
|
double x = 0, y = 0;
|
|
|
|
switch (container->type) {
|
|
|
|
switch (container->type) {
|
|
|
|
case C_ROOT:
|
|
|
|
case C_ROOT:
|
|
|
|
for (i = 0; i < container->children->length; ++i) {
|
|
|
|
for (i = 0; i < container->children->length; ++i) {
|
|
|
@ -489,8 +500,8 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int gap = swayc_gap(container);
|
|
|
|
int gap = swayc_gap(container);
|
|
|
|
container->x = x + gap;
|
|
|
|
x = container->x = x + gap;
|
|
|
|
container->y = y + gap;
|
|
|
|
y = container->y = y + gap;
|
|
|
|
width = container->width = width - gap * 2;
|
|
|
|
width = container->width = width - gap * 2;
|
|
|
|
height = container->height = height - gap * 2;
|
|
|
|
height = container->height = height - gap * 2;
|
|
|
|
sway_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", container->name, container->x, container->y);
|
|
|
|
sway_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", container->name, container->x, container->y);
|
|
|
@ -509,10 +520,11 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
container->width = width;
|
|
|
|
container->width = width;
|
|
|
|
container->height = height;
|
|
|
|
container->height = height;
|
|
|
|
|
|
|
|
x = container->x;
|
|
|
|
|
|
|
|
y = container->y;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
x = y = 0;
|
|
|
|
|
|
|
|
double scale = 0;
|
|
|
|
double scale = 0;
|
|
|
|
switch (container->layout) {
|
|
|
|
switch (container->layout) {
|
|
|
|
case L_HORIZ:
|
|
|
|
case L_HORIZ:
|
|
|
@ -536,9 +548,14 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
|
|
|
|
for (i = 0; i < container->children->length; ++i) {
|
|
|
|
for (i = 0; i < container->children->length; ++i) {
|
|
|
|
swayc_t *child = container->children->items[i];
|
|
|
|
swayc_t *child = container->children->items[i];
|
|
|
|
sway_log(L_DEBUG, "Calculating arrangement for %p:%d (will scale %f by %f)", child, child->type, width, scale);
|
|
|
|
sway_log(L_DEBUG, "Calculating arrangement for %p:%d (will scale %f by %f)", child, child->type, width, scale);
|
|
|
|
child->x = x + container->x;
|
|
|
|
child->x = x;
|
|
|
|
child->y = y + container->y;
|
|
|
|
child->y = y;
|
|
|
|
arrange_windows_r(child, child->width * scale, height);
|
|
|
|
if (i == container->children->length - 1) {
|
|
|
|
|
|
|
|
double remaining_width = container->x + width - x;
|
|
|
|
|
|
|
|
arrange_windows_r(child, remaining_width, height);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
arrange_windows_r(child, child->width * scale, height);
|
|
|
|
|
|
|
|
}
|
|
|
|
x += child->width;
|
|
|
|
x += child->width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -563,9 +580,14 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
|
|
|
|
for (i = 0; i < container->children->length; ++i) {
|
|
|
|
for (i = 0; i < container->children->length; ++i) {
|
|
|
|
swayc_t *child = container->children->items[i];
|
|
|
|
swayc_t *child = container->children->items[i];
|
|
|
|
sway_log(L_DEBUG, "Calculating arrangement for %p:%d (will scale %f by %f)", child, child->type, height, scale);
|
|
|
|
sway_log(L_DEBUG, "Calculating arrangement for %p:%d (will scale %f by %f)", child, child->type, height, scale);
|
|
|
|
child->x = x + container->x;
|
|
|
|
child->x = x;
|
|
|
|
child->y = y + container->y;
|
|
|
|
child->y = y;
|
|
|
|
arrange_windows_r(child, width, child->height * scale);
|
|
|
|
if (i == container->children->length - 1) {
|
|
|
|
|
|
|
|
double remaining_height = container->y + height - y;
|
|
|
|
|
|
|
|
arrange_windows_r(child, width, remaining_height);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
arrange_windows_r(child, width, child->height * scale);
|
|
|
|
|
|
|
|
}
|
|
|
|
y += child->height;
|
|
|
|
y += child->height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|