mirror of
https://github.com/swaywm/sway.git
synced 2024-11-19 14:39:15 +00:00
Merge pull request #1886 from RyanDwyer/border-alpha
Support alpha in border colours
This commit is contained in:
commit
fe9cc21ea7
|
@ -8,7 +8,7 @@ static bool parse_color(char *hexstring, float dest[static 4]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(hexstring) != 7) {
|
if (strlen(hexstring) != 7 && strlen(hexstring) != 9) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,10 +20,15 @@ static bool parse_color(char *hexstring, float dest[static 4]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dest[0] = ((decimal >> 16) & 0xff) / 255.0;
|
if (strlen(hexstring) == 6) {
|
||||||
dest[1] = ((decimal >> 8) & 0xff) / 255.0;
|
// Add alpha
|
||||||
dest[2] = (decimal & 0xff) / 255.0;
|
decimal = (decimal << 8) | 0xff;
|
||||||
dest[3] = 1.0;
|
}
|
||||||
|
|
||||||
|
dest[0] = ((decimal >> 24) & 0xff) / 255.0;
|
||||||
|
dest[1] = ((decimal >> 16) & 0xff) / 255.0;
|
||||||
|
dest[2] = ((decimal >> 8) & 0xff) / 255.0;
|
||||||
|
dest[3] = (decimal & 0xff) / 255.0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,10 +232,10 @@ static void render_container_simple_border_normal(struct sway_output *output,
|
||||||
wlr_backend_get_renderer(output->wlr_output->backend);
|
wlr_backend_get_renderer(output->wlr_output->backend);
|
||||||
struct wlr_box box;
|
struct wlr_box box;
|
||||||
float color[4];
|
float color[4];
|
||||||
color[3] = con->alpha;
|
|
||||||
|
|
||||||
// Child border - left edge
|
// Child border - left edge
|
||||||
memcpy(&color, colors->child_border, sizeof(float) * 3);
|
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||||
|
color[3] *= con->alpha;
|
||||||
box.x = con->x;
|
box.x = con->x;
|
||||||
box.y = con->y + 1;
|
box.y = con->y + 1;
|
||||||
box.width = con->sway_view->border_thickness;
|
box.width = con->sway_view->border_thickness;
|
||||||
|
@ -246,10 +246,11 @@ static void render_container_simple_border_normal(struct sway_output *output,
|
||||||
|
|
||||||
// Child border - right edge
|
// Child border - right edge
|
||||||
if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) {
|
if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) {
|
||||||
memcpy(&color, colors->indicator, sizeof(float) * 3);
|
memcpy(&color, colors->indicator, sizeof(float) * 4);
|
||||||
} else {
|
} else {
|
||||||
memcpy(&color, colors->child_border, sizeof(float) * 3);
|
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||||
}
|
}
|
||||||
|
color[3] *= con->alpha;
|
||||||
box.x = con->x + con->width - con->sway_view->border_thickness;
|
box.x = con->x + con->width - con->sway_view->border_thickness;
|
||||||
box.y = con->y + 1;
|
box.y = con->y + 1;
|
||||||
box.width = con->sway_view->border_thickness;
|
box.width = con->sway_view->border_thickness;
|
||||||
|
@ -260,10 +261,11 @@ static void render_container_simple_border_normal(struct sway_output *output,
|
||||||
|
|
||||||
// Child border - bottom edge
|
// Child border - bottom edge
|
||||||
if (con->parent->children->length == 1 && con->parent->layout == L_VERT) {
|
if (con->parent->children->length == 1 && con->parent->layout == L_VERT) {
|
||||||
memcpy(&color, colors->indicator, sizeof(float) * 3);
|
memcpy(&color, colors->indicator, sizeof(float) * 4);
|
||||||
} else {
|
} else {
|
||||||
memcpy(&color, colors->child_border, sizeof(float) * 3);
|
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||||
}
|
}
|
||||||
|
color[3] *= con->alpha;
|
||||||
box.x = con->x;
|
box.x = con->x;
|
||||||
box.y = con->y + con->height - con->sway_view->border_thickness;
|
box.y = con->y + con->height - con->sway_view->border_thickness;
|
||||||
box.width = con->width;
|
box.width = con->width;
|
||||||
|
@ -273,7 +275,8 @@ static void render_container_simple_border_normal(struct sway_output *output,
|
||||||
output->wlr_output->transform_matrix);
|
output->wlr_output->transform_matrix);
|
||||||
|
|
||||||
// Single pixel bar above title
|
// Single pixel bar above title
|
||||||
memcpy(&color, colors->border, sizeof(float) * 3);
|
memcpy(&color, colors->border, sizeof(float) * 4);
|
||||||
|
color[3] *= con->alpha;
|
||||||
box.x = con->x;
|
box.x = con->x;
|
||||||
box.y = con->y;
|
box.y = con->y;
|
||||||
box.width = con->width;
|
box.width = con->width;
|
||||||
|
@ -292,7 +295,8 @@ static void render_container_simple_border_normal(struct sway_output *output,
|
||||||
output->wlr_output->transform_matrix);
|
output->wlr_output->transform_matrix);
|
||||||
|
|
||||||
// Title background
|
// Title background
|
||||||
memcpy(&color, colors->background, sizeof(float) * 3);
|
memcpy(&color, colors->background, sizeof(float) * 4);
|
||||||
|
color[3] *= con->alpha;
|
||||||
box.x = con->x + con->sway_view->border_thickness;
|
box.x = con->x + con->sway_view->border_thickness;
|
||||||
box.y = con->y + 1;
|
box.y = con->y + 1;
|
||||||
box.width = con->width - con->sway_view->border_thickness * 2;
|
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,
|
||||||
wlr_backend_get_renderer(output->wlr_output->backend);
|
wlr_backend_get_renderer(output->wlr_output->backend);
|
||||||
struct wlr_box box;
|
struct wlr_box box;
|
||||||
float color[4];
|
float color[4];
|
||||||
color[3] = con->alpha;
|
|
||||||
|
|
||||||
// Child border - left edge
|
// Child border - left edge
|
||||||
memcpy(&color, colors->child_border, sizeof(float) * 3);
|
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||||
|
color[3] *= con->alpha;
|
||||||
box.x = con->x;
|
box.x = con->x;
|
||||||
box.y = con->y;
|
box.y = con->y;
|
||||||
box.width = con->sway_view->border_thickness;
|
box.width = con->sway_view->border_thickness;
|
||||||
|
@ -328,10 +332,11 @@ static void render_container_simple_border_pixel(struct sway_output *output,
|
||||||
|
|
||||||
// Child border - right edge
|
// Child border - right edge
|
||||||
if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) {
|
if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) {
|
||||||
memcpy(&color, colors->indicator, sizeof(float) * 3);
|
memcpy(&color, colors->indicator, sizeof(float) * 4);
|
||||||
} else {
|
} else {
|
||||||
memcpy(&color, colors->child_border, sizeof(float) * 3);
|
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||||
}
|
}
|
||||||
|
color[3] *= con->alpha;
|
||||||
box.x = con->x + con->width - con->sway_view->border_thickness;
|
box.x = con->x + con->width - con->sway_view->border_thickness;
|
||||||
box.y = con->y;
|
box.y = con->y;
|
||||||
box.width = con->sway_view->border_thickness;
|
box.width = con->sway_view->border_thickness;
|
||||||
|
@ -351,10 +356,11 @@ static void render_container_simple_border_pixel(struct sway_output *output,
|
||||||
|
|
||||||
// Child border - bottom edge
|
// Child border - bottom edge
|
||||||
if (con->parent->children->length == 1 && con->parent->layout == L_VERT) {
|
if (con->parent->children->length == 1 && con->parent->layout == L_VERT) {
|
||||||
memcpy(&color, colors->indicator, sizeof(float) * 3);
|
memcpy(&color, colors->indicator, sizeof(float) * 4);
|
||||||
} else {
|
} else {
|
||||||
memcpy(&color, colors->child_border, sizeof(float) * 3);
|
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||||
}
|
}
|
||||||
|
color[3] *= con->alpha;
|
||||||
box.x = con->x;
|
box.x = con->x;
|
||||||
box.y = con->y + con->height - con->sway_view->border_thickness;
|
box.y = con->y + con->height - con->sway_view->border_thickness;
|
||||||
box.width = con->width;
|
box.width = con->width;
|
||||||
|
|
Loading…
Reference in a new issue