From b903f7f655479b9ed095cf5b5950d963d525dd8c Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 13 Mar 2016 21:10:46 -0400 Subject: Implement some more on borders Note that this segfaults ALL THE TIME in wlc code. Paging @Cloudef for help, I'm at a loss. --- sway/layout.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sway/layout.c') diff --git a/sway/layout.c b/sway/layout.c index d9c4598f..be898c58 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -12,6 +12,7 @@ #include "focus.h" #include "output.h" #include "ipc-server.h" +#include "render.h" swayc_t root_container; list_t *scratchpad; -- cgit v1.2.3 From 5a13cb0ed136906a4370235214601b0129548c49 Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Tue, 29 Mar 2016 14:47:30 +0200 Subject: Implement borders The borders are implemented as a surface/buffer attached to each view which is sent to and rendered by wlc in the view_pre_render callback. All the drawing logic is handled in sway/border.c and all the logic for calculating the geometry of the border/view is handled in `update_geometry` in sway/layout.c (same place as gaps are calculated). --- sway/layout.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) (limited to 'sway/layout.c') diff --git a/sway/layout.c b/sway/layout.c index be898c58..a282f36e 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -12,7 +12,7 @@ #include "focus.h" #include "output.h" #include "ipc-server.h" -#include "render.h" +#include "border.h" swayc_t root_container; list_t *scratchpad; @@ -427,6 +427,80 @@ void update_geometry(swayc_t *container) { geometry.size.h = ws->y + ws->height - geometry.origin.y; } } + + 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 + container->border_geometry = geometry; + + int border_top = container->border_thickness; + int border_bottom = container->border_thickness; + int border_left = container->border_thickness; + int border_right = container->border_thickness; + + // handle hide_edge_borders + if (config->hide_edge_borders != E_NONE && gap <= 0) { + swayc_t *output = swayc_parent_by_type(container, C_OUTPUT); + const struct wlc_size *size = wlc_output_get_resolution(output->handle); + + if (config->hide_edge_borders == E_HORIZONTAL || config->hide_edge_borders == E_BOTH) { + if (geometry.origin.x == 0) { + border_left = 0; + } + + if (geometry.origin.x + geometry.size.w == size->w) { + border_right = 0; + } + } + + if (config->hide_edge_borders == E_VERTICAL || config->hide_edge_borders == E_BOTH) { + if (geometry.origin.y == 0) { + border_top = 0; + } + + if (geometry.origin.y + geometry.size.h == size->h) { + border_bottom = 0; + } + } + } + + switch (container->border_type) { + case B_NONE: + break; + case B_PIXEL: + geometry.origin.x += border_left; + geometry.origin.y += border_top; + geometry.size.w -= (border_left + border_right); + geometry.size.h -= (border_top + border_bottom); + break; + case B_NORMAL: + { + struct wlc_geometry title_bar = { + .origin = { + .x = container->border_geometry.origin.x, + .y = container->border_geometry.origin.y + }, + .size = { + .w = container->border_geometry.size.w, + .h = config->font_height + 4 // borders + padding + } + }; + geometry.origin.x += border_left; + geometry.origin.y += title_bar.size.h; + geometry.size.w -= (border_left + border_right); + geometry.size.h -= (border_bottom + title_bar.size.h); + container->title_bar_geometry = title_bar; + break; + } + } + + container->actual_geometry = geometry; + + update_view_border(container); + } + wlc_view_set_geometry(container->handle, 0, &geometry); } -- cgit v1.2.3 From 0af55539a8afe38fa1a1beb6af15b0891030985a Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Wed, 30 Mar 2016 10:09:08 +0200 Subject: Fix borders with floating windows --- sway/layout.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'sway/layout.c') 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; -- cgit v1.2.3