aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/output.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-02 08:40:38 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-02 08:40:38 +1000
commitdaab8e35038e74f9b21b62cc2d7f74635fb5a34b (patch)
tree7ae5f7973d3aeef506252c1b9f72e1b110ffbcfe /sway/desktop/output.c
parentMerge pull request #1885 from thejan2009/master (diff)
downloadsway-daab8e35038e74f9b21b62cc2d7f74635fb5a34b.tar.gz
sway-daab8e35038e74f9b21b62cc2d7f74635fb5a34b.tar.zst
sway-daab8e35038e74f9b21b62cc2d7f74635fb5a34b.zip
Support alpha in border colours
The alpha component is merged with the container's opacity. Completes #1882.
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r--sway/desktop/output.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index e0a211d1..4fff8cd3 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -232,10 +232,10 @@ static void render_container_simple_border_normal(struct sway_output *output,
232 wlr_backend_get_renderer(output->wlr_output->backend); 232 wlr_backend_get_renderer(output->wlr_output->backend);
233 struct wlr_box box; 233 struct wlr_box box;
234 float color[4]; 234 float color[4];
235 color[3] = con->alpha;
236 235
237 // Child border - left edge 236 // Child border - left edge
238 memcpy(&color, colors->child_border, sizeof(float) * 3); 237 memcpy(&color, colors->child_border, sizeof(float) * 4);
238 color[3] *= con->alpha;
239 box.x = con->x; 239 box.x = con->x;
240 box.y = con->y + 1; 240 box.y = con->y + 1;
241 box.width = con->sway_view->border_thickness; 241 box.width = con->sway_view->border_thickness;
@@ -246,10 +246,11 @@ static void render_container_simple_border_normal(struct sway_output *output,
246 246
247 // Child border - right edge 247 // Child border - right edge
248 if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) { 248 if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) {
249 memcpy(&color, colors->indicator, sizeof(float) * 3); 249 memcpy(&color, colors->indicator, sizeof(float) * 4);
250 } else { 250 } else {
251 memcpy(&color, colors->child_border, sizeof(float) * 3); 251 memcpy(&color, colors->child_border, sizeof(float) * 4);
252 } 252 }
253 color[3] *= con->alpha;
253 box.x = con->x + con->width - con->sway_view->border_thickness; 254 box.x = con->x + con->width - con->sway_view->border_thickness;
254 box.y = con->y + 1; 255 box.y = con->y + 1;
255 box.width = con->sway_view->border_thickness; 256 box.width = con->sway_view->border_thickness;
@@ -260,10 +261,11 @@ static void render_container_simple_border_normal(struct sway_output *output,
260 261
261 // Child border - bottom edge 262 // Child border - bottom edge
262 if (con->parent->children->length == 1 && con->parent->layout == L_VERT) { 263 if (con->parent->children->length == 1 && con->parent->layout == L_VERT) {
263 memcpy(&color, colors->indicator, sizeof(float) * 3); 264 memcpy(&color, colors->indicator, sizeof(float) * 4);
264 } else { 265 } else {
265 memcpy(&color, colors->child_border, sizeof(float) * 3); 266 memcpy(&color, colors->child_border, sizeof(float) * 4);
266 } 267 }
268 color[3] *= con->alpha;
267 box.x = con->x; 269 box.x = con->x;
268 box.y = con->y + con->height - con->sway_view->border_thickness; 270 box.y = con->y + con->height - con->sway_view->border_thickness;
269 box.width = con->width; 271 box.width = con->width;
@@ -273,7 +275,8 @@ static void render_container_simple_border_normal(struct sway_output *output,
273 output->wlr_output->transform_matrix); 275 output->wlr_output->transform_matrix);
274 276
275 // Single pixel bar above title 277 // Single pixel bar above title
276 memcpy(&color, colors->border, sizeof(float) * 3); 278 memcpy(&color, colors->border, sizeof(float) * 4);
279 color[3] *= con->alpha;
277 box.x = con->x; 280 box.x = con->x;
278 box.y = con->y; 281 box.y = con->y;
279 box.width = con->width; 282 box.width = con->width;
@@ -292,7 +295,8 @@ static void render_container_simple_border_normal(struct sway_output *output,
292 output->wlr_output->transform_matrix); 295 output->wlr_output->transform_matrix);
293 296
294 // Title background 297 // Title background
295 memcpy(&color, colors->background, sizeof(float) * 3); 298 memcpy(&color, colors->background, sizeof(float) * 4);
299 color[3] *= con->alpha;
296 box.x = con->x + con->sway_view->border_thickness; 300 box.x = con->x + con->sway_view->border_thickness;
297 box.y = con->y + 1; 301 box.y = con->y + 1;
298 box.width = con->width - con->sway_view->border_thickness * 2; 302 box.width = con->width - con->sway_view->border_thickness * 2;
@@ -314,10 +318,10 @@ static void render_container_simple_border_pixel(struct sway_output *output,
314 wlr_backend_get_renderer(output->wlr_output->backend); 318 wlr_backend_get_renderer(output->wlr_output->backend);
315 struct wlr_box box; 319 struct wlr_box box;
316 float color[4]; 320 float color[4];
317 color[3] = con->alpha;
318 321
319 // Child border - left edge 322 // Child border - left edge
320 memcpy(&color, colors->child_border, sizeof(float) * 3); 323 memcpy(&color, colors->child_border, sizeof(float) * 4);
324 color[3] *= con->alpha;
321 box.x = con->x; 325 box.x = con->x;
322 box.y = con->y; 326 box.y = con->y;
323 box.width = con->sway_view->border_thickness; 327 box.width = con->sway_view->border_thickness;
@@ -328,10 +332,11 @@ static void render_container_simple_border_pixel(struct sway_output *output,
328 332
329 // Child border - right edge 333 // Child border - right edge
330 if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) { 334 if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) {
331 memcpy(&color, colors->indicator, sizeof(float) * 3); 335 memcpy(&color, colors->indicator, sizeof(float) * 4);
332 } else { 336 } else {
333 memcpy(&color, colors->child_border, sizeof(float) * 3); 337 memcpy(&color, colors->child_border, sizeof(float) * 4);
334 } 338 }
339 color[3] *= con->alpha;
335 box.x = con->x + con->width - con->sway_view->border_thickness; 340 box.x = con->x + con->width - con->sway_view->border_thickness;
336 box.y = con->y; 341 box.y = con->y;
337 box.width = con->sway_view->border_thickness; 342 box.width = con->sway_view->border_thickness;
@@ -351,10 +356,11 @@ static void render_container_simple_border_pixel(struct sway_output *output,
351 356
352 // Child border - bottom edge 357 // Child border - bottom edge
353 if (con->parent->children->length == 1 && con->parent->layout == L_VERT) { 358 if (con->parent->children->length == 1 && con->parent->layout == L_VERT) {
354 memcpy(&color, colors->indicator, sizeof(float) * 3); 359 memcpy(&color, colors->indicator, sizeof(float) * 4);
355 } else { 360 } else {
356 memcpy(&color, colors->child_border, sizeof(float) * 3); 361 memcpy(&color, colors->child_border, sizeof(float) * 4);
357 } 362 }
363 color[3] *= con->alpha;
358 box.x = con->x; 364 box.x = con->x;
359 box.y = con->y + con->height - con->sway_view->border_thickness; 365 box.y = con->y + con->height - con->sway_view->border_thickness;
360 box.width = con->width; 366 box.width = con->width;