logo

inaban

Distrustful Wayland Compositor (inspired by XMonad and dwm) git clone https://hacktivis.me/git/inaban.git
commit: 3a2e8aaaf5b13fd7b8eeed253cdb98ae7c3aae41
parent 55343689ddd9f796d57920f5744cb59102e5bdfd
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri,  1 Jan 2021 23:18:58 +0100

Add borders on all surfaces

Looks weird for GTK menus, I guess they're doing client-side drop-shadow (WHY?)
Not my bug.

Diffstat:

Mconfig.h5+++++
Minaban.c24++++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/config.h b/config.h @@ -4,6 +4,11 @@ static const char *menucmd[] = {"bemenu-run", NULL}; static const char *termcmd[] = {"cage", "-d", "st", NULL}; +static const float background_color[4] = {0.11f, 0.11f, 0.11f, 1.0f}; // approx. gruvbox hard-dark +static const float border_color[4] = {0.25f, 0.25f, 0.50f, 1.0f}; + +#define BORDER_SIZE 1 + // See `enum wlr_keyboard_modifier` in `<wlr/types/wlr_keyboard.h>` #define ModMask WLR_MODIFIER_ALT #define ShiftMask WLR_MODIFIER_SHIFT diff --git a/inaban.c b/inaban.c @@ -385,6 +385,8 @@ server_cursor_frame(struct wl_listener *listener, void *data) static void render_surface(struct wlr_surface *surface, int sx, int sy, void *data) { + struct wlr_box border_box; + struct render_data *rdata = data; struct inaban_view *view = rdata->view; struct wlr_output *output = rdata->output; @@ -429,6 +431,25 @@ render_surface(struct wlr_surface *surface, int sx, int sy, void *data) enum wl_output_transform transform = wlr_output_transform_invert(surface->current.transform); wlr_matrix_project_box(matrix, &box, transform, 0, output->transform_matrix); + /* top border */ + border_box.x = box.x - BORDER_SIZE; + border_box.y = box.y - BORDER_SIZE; + border_box.width = box.width + BORDER_SIZE * 2; + border_box.height = BORDER_SIZE; + wlr_render_rect(rdata->renderer, &border_box, border_color, output->transform_matrix); + /* bottom border */ + border_box.y = box.y + box.height; + wlr_render_rect(rdata->renderer, &border_box, border_color, output->transform_matrix); + /* left border */ + border_box.x = box.x - BORDER_SIZE; + border_box.y = box.y - BORDER_SIZE; + border_box.width = BORDER_SIZE; + border_box.height = box.height + BORDER_SIZE * 2; + wlr_render_rect(rdata->renderer, &border_box, border_color, output->transform_matrix); + /* right border */ + border_box.x = box.x + box.width; + wlr_render_rect(rdata->renderer, &border_box, border_color, output->transform_matrix); + /* This takes our matrix, the texture, and an alpha, and performs the actual * rendering on the GPU. */ wlr_render_texture_with_matrix(rdata->renderer, texture, matrix, 1); @@ -458,8 +479,7 @@ output_frame(struct wl_listener *listener, void *data) /* Begin the renderer (calls glViewport and some other GL sanity checks) */ wlr_renderer_begin(renderer, width, height); - float color[4] = {0.11f, 0.11f, 0.11f, 1.0f}; // approx. gruvbox hard-dark - wlr_renderer_clear(renderer, color); + wlr_renderer_clear(renderer, background_color); /* Each subsequent window we render is rendered on top of the last. Because * our view list is ordered front-to-back, we iterate over it backwards. */