gimp but for windows: a wayland compositor
git clone https://github.com/m-col/wimp
Files | Refs | Readme

Commit accf2e5e294ac47b5dfc3fc515fb2d3e25706397
Parent: e0f847b4502a2b5c1a7dd393abefb971ec1f1442
Author: mcol <mcol@posteo.net>
Date: 2021-02-13 22:07:41 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2021-02-13 22:07:41 +0000

Draw borders as hollow box

Fixes #30

src/output.c Modified

@@ -43,36 +43,38 @@
     int height = surface->current.height * output->scale * rdata->zoom;
 
     if (rdata->bordered == surface) {
-	int border_width = wimp.current_desk->border_width;
-	if (border_width > 0) {
-	    int remainder = ceil(border_width * 2 * rdata->zoom);
-	    struct wlr_box borders = {
-		.x = x - border_width * rdata->zoom,
-		.y = y - border_width * rdata->zoom,
-		.width = width + remainder,
-		.height = height + remainder,
-	    };
-	    wlr_render_rect(
-		rdata->renderer,
-		&borders,
-		rdata->is_focussed ? wimp.current_desk->border_focus : wimp.current_desk->border_normal,
-		output->transform_matrix
-	    );
-	    struct wlr_box corners = {
-		.x = borders.x,
-		.y = borders.y,
-		.width = CORNER,
-		.height = CORNER,
-	    };
-	    float *corner = rdata->is_focussed ?
+	if (wimp.current_desk->border_width > 0) {
+	    double border_width = ceil(wimp.current_desk->border_width * rdata->zoom);
+	    float *colour = rdata->is_focussed ?
 		wimp.current_desk->corner_focus : wimp.current_desk->corner_normal;
-	    wlr_render_rect(rdata->renderer, &corners, corner, output->transform_matrix);
-	    corners.x = borders.x + borders.width - CORNER;
-	    wlr_render_rect(rdata->renderer, &corners, corner, output->transform_matrix);
-	    corners.y = borders.y + borders.height - CORNER;
-	    wlr_render_rect(rdata->renderer, &corners, corner, output->transform_matrix);
-	    corners.x = borders.x;
-	    wlr_render_rect(rdata->renderer, &corners, corner, output->transform_matrix);
+	    struct wlr_box border = {
+		.x = x - border_width,
+		.y = y - border_width,
+		.width = width + border_width * 2,
+		.height = border_width,
+	    };
+	    wlr_render_rect(rdata->renderer, &border, colour, output->transform_matrix);
+	    border.y = y + height;
+	    wlr_render_rect(rdata->renderer, &border, colour, output->transform_matrix);
+	    border.y = y - border_width;
+	    border.width = border_width;
+	    border.height = height + border_width * 2;
+	    wlr_render_rect(rdata->renderer, &border, colour, output->transform_matrix);
+	    border.x = x + width;
+	    wlr_render_rect(rdata->renderer, &border, colour, output->transform_matrix);
+	    colour = rdata->is_focussed ? wimp.current_desk->border_focus : wimp.current_desk->border_normal;
+	    border.y += CORNER;
+	    border.height -= CORNER * 2;
+	    wlr_render_rect(rdata->renderer, &border, colour, output->transform_matrix);
+	    border.x = x - border_width;
+	    wlr_render_rect(rdata->renderer, &border, colour, output->transform_matrix);
+	    border.y = y - border_width;
+	    border.x += CORNER;
+	    border.height = border_width;
+	    border.width = width + border_width * 2 - CORNER * 2;
+	    wlr_render_rect(rdata->renderer, &border, colour, output->transform_matrix);
+	    border.y = y + height;
+	    wlr_render_rect(rdata->renderer, &border, colour, output->transform_matrix);
 	}
     }