From 0af55539a8afe38fa1a1beb6af15b0891030985a Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Wed, 30 Mar 2016 10:09:08 +0200 Subject: [PATCH] Fix borders with floating windows --- sway/handlers.c | 14 +++++++------- sway/layout.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/sway/handlers.c b/sway/handlers.c index fc473640..54326dd0 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -349,13 +349,13 @@ static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geo view->desired_width = geometry->size.w; view->desired_height = geometry->size.h; - /* if (view->is_floating) { */ - /* view->width = view->desired_width; */ - /* view->height = view->desired_height; */ - /* view->x = geometry->origin.x; */ - /* view->y = geometry->origin.y; */ - /* /1* arrange_windows(view->parent, -1, -1); *1/ */ - /* } */ + if (view->is_floating) { + view->width = view->desired_width; + view->height = view->desired_height; + view->x = geometry->origin.x; + view->y = geometry->origin.y; + arrange_windows(view->parent, -1, -1); + } } } diff --git a/sway/layout.c b/sway/layout.c index a282f36e..3f271caf 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -374,6 +374,46 @@ void move_workspace_to(swayc_t* workspace, swayc_t* destination) { update_visibility(src_op); } +static void update_border_geometry_floating(swayc_t *c, struct wlc_geometry *geometry) { + struct wlc_geometry g = *geometry; + c->actual_geometry = g; + + switch (c->border_type) { + case B_NONE: + break; + case B_PIXEL: + g.origin.x -= c->border_thickness; + g.origin.y -= c->border_thickness; + g.size.w += (c->border_thickness * 2); + g.size.h += (c->border_thickness * 2); + break; + case B_NORMAL: + g.origin.x -= c->border_thickness; + uint32_t title_bar_height = config->font_height + 4; // borders + padding + g.origin.y -= title_bar_height; + g.size.w += (c->border_thickness * 2); + g.size.h += (c->border_thickness + title_bar_height); + + struct wlc_geometry title_bar = { + .origin = { + .x = g.origin.x, + .y = g.origin.y + }, + .size = { + .w = g.size.w, + .h = title_bar_height + } + }; + c->title_bar_geometry = title_bar; + break; + } + + c->border_geometry = g; + *geometry = c->actual_geometry; + + update_view_border(c); +} + void update_geometry(swayc_t *container) { if (container->type != C_VIEW) { return; @@ -431,8 +471,9 @@ void update_geometry(swayc_t *container) { if (swayc_is_fullscreen(container)) { container->border_geometry = (const struct wlc_geometry){0}; container->title_bar_geometry = (const struct wlc_geometry){0}; - } else { - // make room for border + } else if (container->is_floating) { // allocate border for floating window + update_border_geometry_floating(container, &geometry); + } else if (!container->is_floating) { // allocate border for titled window container->border_geometry = geometry; int border_top = container->border_thickness;