mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-16 07:47:22 +01:00
ewmh: store netwm icon as draw_image_t
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
6ca4e58f3d
commit
2fad185fcf
6 changed files with 27 additions and 59 deletions
2
event.c
2
event.c
|
@ -668,7 +668,7 @@ event_handle_propertynotify(void *data __attribute__ ((unused)),
|
|||
else if(ev->atom == _NET_WM_ICON)
|
||||
{
|
||||
xcb_get_property_cookie_t icon_q = ewmh_window_icon_get_unchecked(c->win);
|
||||
netwm_icon_delete(&c->icon);
|
||||
draw_image_delete(&c->icon);
|
||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||
c->icon = ewmh_window_icon_get_reply(icon_q);
|
||||
}
|
||||
|
|
12
ewmh.c
12
ewmh.c
|
@ -507,13 +507,13 @@ ewmh_window_icon_get_unchecked(xcb_window_t w)
|
|||
|
||||
/** Get NET_WM_ICON.
|
||||
* \param cookie The cookie.
|
||||
* \return A netwm_icon_t structure which must be deleted after usage.
|
||||
* \return A draw_image_t structure which must be deleted after usage.
|
||||
*/
|
||||
netwm_icon_t *
|
||||
draw_image_t *
|
||||
ewmh_window_icon_get_reply(xcb_get_property_cookie_t cookie)
|
||||
{
|
||||
double alpha;
|
||||
netwm_icon_t *icon;
|
||||
draw_image_t *icon;
|
||||
int size, i;
|
||||
uint32_t *data;
|
||||
unsigned char *imgdata;
|
||||
|
@ -527,7 +527,7 @@ ewmh_window_icon_get_reply(xcb_get_property_cookie_t cookie)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
icon = p_new(netwm_icon_t, 1);
|
||||
icon = p_new(draw_image_t, 1);
|
||||
|
||||
icon->width = data[0];
|
||||
icon->height = data[1];
|
||||
|
@ -540,8 +540,8 @@ ewmh_window_icon_get_reply(xcb_get_property_cookie_t cookie)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
icon->image = p_new(unsigned char, size * 4);
|
||||
for(imgdata = icon->image, i = 2; i < size + 2; i++, imgdata += 4)
|
||||
icon->data = p_new(unsigned char, size * 4);
|
||||
for(imgdata = icon->data, i = 2; i < size + 2; i++, imgdata += 4)
|
||||
{
|
||||
imgdata[3] = (data[i] >> 24) & 0xff; /* A */
|
||||
alpha = imgdata[3] / 255.0;
|
||||
|
|
12
ewmh.h
12
ewmh.h
|
@ -24,16 +24,6 @@
|
|||
|
||||
#include "structs.h"
|
||||
|
||||
static inline void
|
||||
netwm_icon_delete(netwm_icon_t **i)
|
||||
{
|
||||
if(*i)
|
||||
{
|
||||
p_delete(&(*i)->image);
|
||||
p_delete(i);
|
||||
}
|
||||
}
|
||||
|
||||
void ewmh_init(int);
|
||||
void ewmh_update_net_client_list(int);
|
||||
void ewmh_update_net_numbers_of_desktop(int);
|
||||
|
@ -46,7 +36,7 @@ void ewmh_check_client_hints(client_t *);
|
|||
void ewmh_update_workarea(int);
|
||||
void ewmh_client_strut_update(client_t *);
|
||||
xcb_get_property_cookie_t ewmh_window_icon_get_unchecked(xcb_window_t);
|
||||
netwm_icon_t *ewmh_window_icon_get_reply(xcb_get_property_cookie_t);
|
||||
draw_image_t *ewmh_window_icon_get_reply(xcb_get_property_cookie_t);
|
||||
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
10
structs.h
10
structs.h
|
@ -253,14 +253,6 @@ struct statusbar_t
|
|||
statusbar_t *prev, *next;
|
||||
};
|
||||
|
||||
/** Netwm icon */
|
||||
typedef struct
|
||||
{
|
||||
int height;
|
||||
int width;
|
||||
unsigned char *image;
|
||||
} netwm_icon_t;
|
||||
|
||||
/* Strut */
|
||||
typedef struct
|
||||
{
|
||||
|
@ -337,7 +329,7 @@ struct client_t
|
|||
/** Button bindings */
|
||||
button_array_t buttons;
|
||||
/** Icon */
|
||||
netwm_icon_t *icon;
|
||||
draw_image_t *icon;
|
||||
/** Size hints */
|
||||
xcb_size_hints_t size_hints;
|
||||
/** Next and previous clients */
|
||||
|
|
|
@ -56,7 +56,10 @@ appicon_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
|
|||
|
||||
if(c)
|
||||
{
|
||||
if((image = draw_image_new(c->icon_path)))
|
||||
if(!(image = draw_image_new(c->icon_path)))
|
||||
image = c->icon;
|
||||
|
||||
if(image)
|
||||
{
|
||||
w->area.width = ((double) ctx->height / (double) image->height) * image->width;
|
||||
w->area.x = widget_calculate_offset(ctx->width,
|
||||
|
@ -65,21 +68,8 @@ appicon_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
|
|||
w->widget->align);
|
||||
draw_image(ctx, w->area.x,
|
||||
w->area.y, ctx->height, image);
|
||||
draw_image_delete(&image);
|
||||
}
|
||||
else if(c->icon)
|
||||
{
|
||||
w->area.width = ((double) ctx->height / (double) c->icon->height)
|
||||
* c->icon->width;
|
||||
w->area.x = widget_calculate_offset(ctx->width,
|
||||
w->area.width,
|
||||
offset,
|
||||
w->widget->align);
|
||||
draw_image_from_argb_data(ctx,
|
||||
w->area.x,
|
||||
w->area.y,
|
||||
c->icon->width, c->icon->height,
|
||||
ctx->height, c->icon->image);
|
||||
if(image != c->icon)
|
||||
draw_image_delete(&image);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -142,24 +142,20 @@ tasklist_draw_item(draw_context_t *ctx,
|
|||
else
|
||||
parser_data = NULL;
|
||||
|
||||
if((image = draw_image_new(odata->client_labels.tab[i].client->icon_path)))
|
||||
{
|
||||
icon_width = ((double) ctx->height / (double) image->height) * image->width;
|
||||
draw_image(ctx, w->area.x + pos,
|
||||
w->area.y, ctx->height, image);
|
||||
draw_image_delete(&image);
|
||||
}
|
||||
/* use image from icon_path, otherwise netwm icon */
|
||||
if(!(image = draw_image_new(odata->client_labels.tab[i].client->icon_path)))
|
||||
image = odata->client_labels.tab[i].client->icon;
|
||||
|
||||
if(!icon_width && odata->client_labels.tab[i].client->icon)
|
||||
if(image)
|
||||
{
|
||||
netwm_icon_t *icon = odata->client_labels.tab[i].client->icon;
|
||||
icon_width = ((double) ctx->height / (double) icon->height)
|
||||
* icon->width;
|
||||
draw_image_from_argb_data(ctx,
|
||||
w->area.x + pos,
|
||||
w->area.y,
|
||||
icon->width, icon->height,
|
||||
ctx->height, icon->image);
|
||||
|
||||
icon_width = ((double) ctx->height / (double) image->height) * image->width;
|
||||
draw_image(ctx, w->area.x + odata->box_width * i,
|
||||
w->area.y, ctx->height, image);
|
||||
|
||||
/* a bit hackish */
|
||||
if(image != odata->client_labels.tab[i].client->icon)
|
||||
draw_image_delete(&image);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue