aboutsummaryrefslogtreecommitdiff
path: root/sway/layout.c
diff options
context:
space:
mode:
authortaiyu <taiyu.len@gmail.com>2015-09-22 09:41:01 -0700
committertaiyu <taiyu.len@gmail.com>2015-09-22 09:41:01 -0700
commit6c33f8122a3c4bb8fc22129d1d2ad03f535885f7 (patch)
tree443f1c25df9193c0533710df78be0d7e7d0816ed /sway/layout.c
parentd7f8bbd35323e9d83b10ab9fbd8715ec4f1aaa8c (diff)
#184
Diffstat (limited to 'sway/layout.c')
-rw-r--r--sway/layout.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/sway/layout.c b/sway/layout.c
index bef1b88d..086dc542 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -280,7 +280,6 @@ void move_container(swayc_t *container, enum movement_direction dir) {
// Dirty hack to fix a certain case
arrange_windows(parent, -1, -1);
arrange_windows(parent->parent, -1, -1);
- update_visibility(parent->parent);
set_focused_container_for(parent->parent, container);
}
@@ -319,31 +318,34 @@ void update_geometry(swayc_t *container) {
if (container->type != C_VIEW) {
return;
}
- int gap = swayc_gap(container);
+ swayc_t *ws = swayc_parent_by_type(container, C_WORKSPACE);
+ swayc_t *op = ws->parent;
+ int gap = container->is_floating ? 0 : swayc_gap(container);
+
struct wlc_geometry geometry = {
.origin = {
- .x = container->x + (container->is_floating ? 0 : gap / 2),
- .y = container->y + (container->is_floating ? 0 : gap / 2)
+ .x = container->x + gap/2 < op->width ? container->x + gap/2 : op->width-1,
+ .y = container->y + gap/2 < op->height ? container->y + gap/2 : op->height-1
},
.size = {
- .w = container->width > (container->is_floating ? 0 : gap) ?
- container->width - (container->is_floating ? 0 : gap) : 0,
- .h = container->height > (container->is_floating ? 0 : gap) ?
- container->height - (container->is_floating ? 0 : gap) : 0,
+ .w = container->width > gap ? container->width - gap : 1,
+ .h = container->height > gap ? container->height - gap : 1,
}
};
if (swayc_is_fullscreen(container)) {
- swayc_t *parent = swayc_parent_by_type(container, C_OUTPUT);
geometry.origin.x = 0;
geometry.origin.y = 0;
- geometry.size.w = parent->width;
- geometry.size.h = parent->height;
+ geometry.size.w = op->width;
+ geometry.size.h = op->height;
+ if (op->focused == ws) {
+ wlc_view_bring_to_front(container->handle);
+ }
}
wlc_view_set_geometry(container->handle, 0, &geometry);
return;
}
-void arrange_windows(swayc_t *container, double width, double height) {
+static void arrange_windows_r(swayc_t *container, double width, double height) {
int i;
if (width == -1 || height == -1) {
sway_log(L_DEBUG, "Arranging layout for %p", container);
@@ -357,7 +359,7 @@ void arrange_windows(swayc_t *container, double width, double height) {
for (i = 0; i < container->children->length; ++i) {
swayc_t *child = container->children->items[i];
sway_log(L_DEBUG, "Arranging output at %d", x);
- arrange_windows(child, -1, -1);
+ arrange_windows_r(child, -1, -1);
x += child->width;
}
return;
@@ -373,7 +375,7 @@ void arrange_windows(swayc_t *container, double width, double height) {
child->width = width - gap * 2;
child->height = height - gap * 2;
sway_log(L_DEBUG, "Arranging workspace #%d at %f, %f", i, child->x, child->y);
- arrange_windows(child, -1, -1);
+ arrange_windows_r(child, -1, -1);
}
return;
case C_VIEW:
@@ -417,7 +419,7 @@ void arrange_windows(swayc_t *container, double width, double height) {
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->y = y + container->y;
- arrange_windows(child, child->width * scale, height);
+ arrange_windows_r(child, child->width * scale, height);
x += child->width;
}
}
@@ -444,7 +446,7 @@ void arrange_windows(swayc_t *container, double width, double height) {
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->y = y + container->y;
- arrange_windows(child, width, child->height * scale);
+ arrange_windows_r(child, width, child->height * scale);
y += child->height;
}
}
@@ -466,6 +468,11 @@ void arrange_windows(swayc_t *container, double width, double height) {
}
}
}
+}
+
+void arrange_windows(swayc_t *container, double width, double height) {
+ update_visibility(container);
+ arrange_windows_r(container, width, height);
layout_log(&root_container, 0);
}