aboutsummaryrefslogtreecommitdiff
path: root/sway/layout.c
diff options
context:
space:
mode:
authorMikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-29 14:47:30 +0200
committerMikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-30 00:47:58 +0200
commit5a13cb0ed136906a4370235214601b0129548c49 (patch)
tree51dce6cdcb9bb1ffe27dcdc9a01ca9bda3a7c87a /sway/layout.c
parent3b05f92f76c3bd9400320844e485eb06e94772cd (diff)
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).
Diffstat (limited to 'sway/layout.c')
-rw-r--r--sway/layout.c76
1 files changed, 75 insertions, 1 deletions
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);
}