diff --git a/src/backend/wayland/wl_framebuf.c b/src/backend/wayland/wl_framebuf.c index 4223ffb..39c523d 100644 --- a/src/backend/wayland/wl_framebuf.c +++ b/src/backend/wayland/wl_framebuf.c @@ -911,9 +911,12 @@ wl_frame_paint_button(WCoreWindow *button, WTexture *texture, if (!icon) return; + struct wl_frame_buf *parent_fb = frame_buf_find(fwin->core->window); struct wl_frame_buf *tb_fb = fwin->titlebar ? frame_buf_find(fwin->titlebar->window) : NULL; uint32_t bg_pixel = 0xFF333333; - if (tb_fb && tb_fb->image) { + /* Sample button background from the titlebar buffer, or from the + * parent frame buffer if the titlebar was rendered there (fallback). */ + if (tb_fb && tb_fb->image && tb_fb->width >= btn_fb->rel_x + bw) { uint32_t *tb_data = pixman_image_get_data(tb_fb->image); int tb_stride = pixman_image_get_stride(tb_fb->image) / 4; int sample_y = btn_fb->rel_y + bh / 2; @@ -921,6 +924,14 @@ wl_frame_paint_button(WCoreWindow *button, WTexture *texture, if (sample_y >= 0 && sample_y < tb_fb->height && sample_x >= 0 && sample_x < tb_fb->width) bg_pixel = tb_data[sample_y * tb_stride + sample_x]; + } else if (parent_fb && parent_fb->image) { + uint32_t *p_data = pixman_image_get_data(parent_fb->image); + int p_stride = pixman_image_get_stride(parent_fb->image) / 4; + int sample_y = btn_fb->rel_y + bh / 2; + int sample_x = btn_fb->rel_x + bw / 2; + if (sample_y >= 0 && sample_y < parent_fb->height && + sample_x >= 0 && sample_x < parent_fb->width) + bg_pixel = p_data[sample_y * p_stride + sample_x]; } uint32_t fg_pixel = 0xFF000000 | ((color >> 16 & 0xFF) << 16) |