wayland: workspace name badge with transparent background and fade
The workspace name display was rendering with an opaque black background and never fading out. Fix by: - Using transparent (alpha=0) background instead of black - Returning RGBA images from badge_render and badge_get_background - Preserving alpha channel in badge_update instead of hardcoding 0xFF This allows the fade animation (RCombineImagesWithOpaqueness) to work correctly, blending text with decreasing opacity over a transparent background until the badge disappears.
This commit is contained in:
parent
172e226947
commit
7ea6a7ac88
|
|
@ -8291,27 +8291,12 @@ wl_workspace_badge_render(WScreen *scr, WNativeWindow badge_win,
|
|||
W_RegisterBacking(fb->id, fb->image);
|
||||
}
|
||||
|
||||
/* Fill black */
|
||||
pixman_image_t *black_fill = pixman_image_create_bits(PIXMAN_a8r8g8b8, width, height, NULL, 0);
|
||||
if (black_fill) {
|
||||
uint32_t *data = pixman_image_get_data(black_fill);
|
||||
for (int i = 0; i < width * height; i++)
|
||||
data[i] = 0xFF000000;
|
||||
pixman_image_composite32(PIXMAN_OP_SRC, black_fill, NULL, fb->image,
|
||||
0, 0, 0, 0, 0, 0, width, height);
|
||||
pixman_image_unref(black_fill);
|
||||
}
|
||||
|
||||
/* Draw text (shadow passes + final) */
|
||||
for (int x = 0; x <= 4; x++)
|
||||
for (int y = 0; y <= 4; y++)
|
||||
WMDrawString(scr->wmscreen, (WMDrawable)badge_win, scr->white,
|
||||
scr->workspace_name_font, x, y, name, name_len);
|
||||
|
||||
/* Clear and redraw final text centered */
|
||||
/* Fill transparent */
|
||||
uint32_t *px = pixman_image_get_data(fb->image);
|
||||
for (int i = 0; i < width * height; i++)
|
||||
px[i] = 0xFF000000;
|
||||
px[i] = 0x00000000;
|
||||
|
||||
/* Draw white text */
|
||||
WMDrawString(scr->wmscreen, (WMDrawable)badge_win, scr->white,
|
||||
scr->workspace_name_font, 2, 2, name, name_len);
|
||||
|
||||
|
|
@ -8319,15 +8304,16 @@ wl_workspace_badge_render(WScreen *scr, WNativeWindow badge_win,
|
|||
if (fb->scene_buf)
|
||||
wlr_scene_buffer_set_buffer_with_damage(fb->scene_buf, &fb->base, NULL);
|
||||
|
||||
/* Return RImage copy for fade animation */
|
||||
RImage *result = RCreateImage(width, height, False);
|
||||
/* Return RGBA RImage copy for fade animation */
|
||||
RImage *result = RCreateImage(width, height, True);
|
||||
if (result) {
|
||||
uint32_t *src = pixman_image_get_data(fb->image);
|
||||
for (int i = 0; i < width * height; i++) {
|
||||
uint32_t p = src[i];
|
||||
result->data[i * 3 + 0] = (p >> 16) & 0xFF; /* R */
|
||||
result->data[i * 3 + 1] = (p >> 8) & 0xFF; /* G */
|
||||
result->data[i * 3 + 2] = p & 0xFF; /* B */
|
||||
result->data[i * 4 + 0] = (p >> 16) & 0xFF; /* R */
|
||||
result->data[i * 4 + 1] = (p >> 8) & 0xFF; /* G */
|
||||
result->data[i * 4 + 2] = p & 0xFF; /* B */
|
||||
result->data[i * 4 + 3] = (p >> 24) & 0xFF; /* A */
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
@ -8337,9 +8323,10 @@ static RImage *
|
|||
wl_workspace_badge_get_background(WScreen *scr, int x, int y, int width, int height)
|
||||
{
|
||||
(void)scr; (void)x; (void)y;
|
||||
RImage *img = RCreateImage(width, height, False);
|
||||
/* Return a fully transparent background so the badge floats over the desktop */
|
||||
RImage *img = RCreateImage(width, height, True);
|
||||
if (img)
|
||||
memset(img->data, 8, width * height * 3);
|
||||
memset(img->data, 0, width * height * 4);
|
||||
return img;
|
||||
}
|
||||
|
||||
|
|
@ -8365,7 +8352,8 @@ wl_workspace_badge_update(WScreen *scr, WNativeWindow badge_win, RImage *img)
|
|||
uint8_t r = img->data[si];
|
||||
uint8_t g = img->data[si + 1];
|
||||
uint8_t b = img->data[si + 2];
|
||||
dst[y * fb->width + x] = 0xFF000000 | (r << 16) | (g << 8) | b;
|
||||
uint8_t a = (bpp == 4) ? img->data[si + 3] : 0xFF;
|
||||
dst[y * fb->width + x] = ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue