aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2025-03-14 12:53:29 +0100
committerdec05eba <dec05eba@protonmail.com>2025-03-14 12:53:29 +0100
commit637d092f808c695e920d5955f6f56460ea847cd6 (patch)
treed89ee3f67102bbb0c194c0d218e58669a6ea00f8
parentb2c7f26283b1740debeff2d06939c05a4a804304 (diff)
Handle window background transparency correctly (premultiplied alpha)HEADmaster
-rw-r--r--src/window/window.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/window/window.c b/src/window/window.c
index 6dbf3df..bce68fc 100644
--- a/src/window/window.c
+++ b/src/window/window.c
@@ -800,7 +800,7 @@ static void mgl_window_on_resize(mgl_window *self, int width, int height) {
static unsigned long mgl_color_to_x11_pixel(mgl_color color) {
if(color.a == 0)
return 0;
- return ((uint32_t)color.a << 24) | ((uint32_t)color.r << 16) | ((uint32_t)color.g << 8) | (uint32_t)color.b;
+ return ((uint32_t)color.a << 24) | (((uint32_t)color.r * color.a / 0xFF) << 16) | (((uint32_t)color.g * color.a / 0xFF) << 8) | ((uint32_t)color.b * color.a / 0xFF);
}
static void mgl_set_window_type(mgl_window *self, mgl_window_type window_type) {
@@ -911,7 +911,7 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window
XSetWindowAttributes window_attr;
window_attr.override_redirect = params ? params->override_redirect : false;
window_attr.colormap = x11_context->color_map;
- window_attr.background_pixel = mgl_color_to_x11_pixel(params ? params->background_color : (mgl_color){ .r = 0, .g = 0, .b = 0, .a = 0 });
+ window_attr.background_pixel = mgl_color_to_x11_pixel(params ? params->background_color : (mgl_color){ .r = 0, .g = 0, .b = 0, .a = 255 });
window_attr.border_pixel = 0;
window_attr.bit_gravity = NorthWestGravity;
window_attr.event_mask =