fix titlebar buttons: render icons directly with pixman instead of XPM parser, remove XPM parsing dependency
This commit is contained in:
parent
f7a3c735a7
commit
c7a3e80c73
|
|
@ -738,35 +738,48 @@ wl_frame_paint_button(WCoreWindow *button, WTexture *texture,
|
|||
wwarning("btn: no fwin");
|
||||
return;
|
||||
}
|
||||
wwarning("btn: paint button=%p is_right=%d", (void*)button, button == fwin->right_button ? 1 : 0);
|
||||
|
||||
struct wl_frame_buf *btn_fb = frame_buf_find(button->window);
|
||||
if (!btn_fb || !btn_fb->image) {
|
||||
wwarning("btn: no fb or no image (fb=%p)", (void*)btn_fb);
|
||||
return;
|
||||
}
|
||||
|
||||
int bw = btn_fb->width;
|
||||
int bh = btn_fb->height;
|
||||
if (bw < 3 || bh < 3)
|
||||
return;
|
||||
|
||||
/* Build button icon RImages once (avoids XPM parser dependency) */
|
||||
if (!wl_state.btn_close_img) {
|
||||
wl_state.btn_close_img = RCreateImage(10, 10, True);
|
||||
if (wl_state.btn_close_img) {
|
||||
unsigned char *d = wl_state.btn_close_img->data;
|
||||
memset(d, 0, 10 * 10 * 4);
|
||||
for (int _i = 0; _i < 10; _i++) {
|
||||
int _j = _i, _k = 9 - _i;
|
||||
d[(_j * 10 + _i) * 4 + 3] = 0xFF; /* alpha=255 on X diagonals */
|
||||
d[(_k * 10 + _i) * 4 + 3] = 0xFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!wl_state.btn_iconify_img) {
|
||||
wl_state.btn_iconify_img = RCreateImage(10, 10, True);
|
||||
if (wl_state.btn_iconify_img) {
|
||||
unsigned char *d = wl_state.btn_iconify_img->data;
|
||||
memset(d, 0, 10 * 10 * 4);
|
||||
for (int _i = 0; _i < 10; _i++) {
|
||||
d[(8 * 10 + _i) * 4 + 3] = 0xFF; /* alpha=255 on two rows */
|
||||
d[(9 * 10 + _i) * 4 + 3] = 0xFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RImage *icon = NULL;
|
||||
if (button == fwin->right_button) {
|
||||
if (!wl_state.btn_close_img)
|
||||
wl_state.btn_close_img = RGetImageFromXPMData(
|
||||
button->screen_ptr->rcontext, PRED_CLOSE_XPM);
|
||||
if (button == fwin->right_button)
|
||||
icon = wl_state.btn_close_img;
|
||||
wwarning("btn: close img=%p", (void*)icon);
|
||||
} else if (button == fwin->left_button) {
|
||||
if (!wl_state.btn_iconify_img)
|
||||
wl_state.btn_iconify_img = RGetImageFromXPMData(
|
||||
button->screen_ptr->rcontext, PRED_ICONIFY_XPM);
|
||||
else if (button == fwin->left_button)
|
||||
icon = wl_state.btn_iconify_img;
|
||||
wwarning("btn: iconify img=%p", (void*)icon);
|
||||
}
|
||||
if (!icon) {
|
||||
wwarning("btn: no icon!");
|
||||
if (!icon)
|
||||
return;
|
||||
}
|
||||
|
||||
struct wl_frame_buf *tb_fb = fwin->titlebar ? frame_buf_find(fwin->titlebar->window) : NULL;
|
||||
uint32_t bg_pixel = 0xFF333333;
|
||||
|
|
|
|||
Loading…
Reference in New Issue