tAdd simple client borders - spkp - Stacking wayland compositor
 (HTM) git clone git://git.z3bra.org/spkp.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit 9937532ed873f3f1b1da2e28fc7b2fa1ab2a50cb
 (DIR) parent 5a70d3af8c86f86ce61bf586772662ac6eb670b2
 (HTM) Author: Willy Goiffon <dev@z3bra.org>
       Date:   Tue, 10 Nov 2020 13:28:19 +0100
       
       Add simple client borders
       
       Diffstat:
         M compositor.c                        |      13 +++++++++++--
         M config.def.h                        |       3 +++
       
       2 files changed, 14 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/compositor.c b/compositor.c
       t@@ -84,6 +84,7 @@ struct output {
        struct window {
                struct state *server;
                struct wlr_xdg_surface *toplevel;
       +
                double x, y;
        
                int mapped;
       t@@ -720,7 +721,7 @@ render(struct wlr_surface *surface, int x, int y, void *data)
                struct window *window;
                struct wlr_output *output;
                struct wlr_texture *texture;
       -        struct wlr_box box;
       +        struct wlr_box box, border;
                enum wl_output_transform transform;
        
                rdata = data;
       t@@ -731,12 +732,20 @@ render(struct wlr_surface *surface, int x, int y, void *data)
                if (!texture)
                        return;
        
       +        transform = wlr_output_transform_invert(surface->current.transform);
       +
                box.x = window->x + x;
                box.y = window->y + y;
                box.width = surface->current.width;
                box.height = surface->current.height;
        
       -        transform = wlr_output_transform_invert(surface->current.transform);
       +        if (surface == window->toplevel->surface) {
       +                border.x = box.x - bordersize;
       +                border.y = box.y - bordersize;
       +                border.width = box.width + bordersize * 2;
       +                border.height = box.height + bordersize * 2;
       +                wlr_render_rect(rdata->renderer, &border, bordercolor, output->transform_matrix);
       +        }
        
                wlr_matrix_project_box(matrix, &box, transform, 0, output->transform_matrix);
        
 (DIR) diff --git a/config.def.h b/config.def.h
       t@@ -1,4 +1,7 @@
        float background[4] = { 1.0, 0.6, 0.6, 0.3 };
       +float bordercolor[4] = { 0.7, 0.7, 0.7, 1.0 };
       +
       +int bordersize = 2;
        
        struct key keys[] = {
                { WLR_MODIFIER_LOGO, XKB_KEY_Escape, kb_terminate, {0} },