From 6c33f8122a3c4bb8fc22129d1d2ad03f535885f7 Mon Sep 17 00:00:00 2001 From: taiyu Date: Tue, 22 Sep 2015 09:41:01 -0700 Subject: [PATCH] #184 --- sway/handlers.c | 4 ++-- sway/layout.c | 39 +++++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/sway/handlers.c b/sway/handlers.c index 096df53c..cef4a980 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -253,8 +253,8 @@ static void handle_view_focus(wlc_handle view, bool focus) { } static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geometry *geometry) { - sway_log(L_DEBUG, "geometry request %d x %d : %d x %d", - geometry->origin.x, geometry->origin.y, geometry->size.w, geometry->size.h); + sway_log(L_DEBUG, "geometry request for %ld %dx%d : %dx%d", + handle, geometry->origin.x, geometry->origin.y, geometry->size.w, geometry->size.h); // If the view is floating, then apply the geometry. // Otherwise save the desired width/height for the view. // This will not do anything for the time being as WLC improperly sends geometry requests 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); }