ewmh: store NET_WM icon
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
f9954cd6af
commit
1fbe4f0d5e
1
client.c
1
client.c
|
@ -399,6 +399,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
|
||||||
c->geometry.height = c->f_geometry.height = c->m_geometry.height = wgeom->height;
|
c->geometry.height = c->f_geometry.height = c->m_geometry.height = wgeom->height;
|
||||||
c->layer = c->oldlayer = LAYER_TILE;
|
c->layer = c->oldlayer = LAYER_TILE;
|
||||||
client_setborder(c, wgeom->border_width);
|
client_setborder(c, wgeom->border_width);
|
||||||
|
c->icon = ewmh_window_icon_get(c->win);
|
||||||
|
|
||||||
/* update hints */
|
/* update hints */
|
||||||
u_size_hints = client_updatesizehints(c);
|
u_size_hints = client_updatesizehints(c);
|
||||||
|
|
6
event.c
6
event.c
|
@ -538,6 +538,12 @@ event_handle_propertynotify(void *data __attribute__ ((unused)),
|
||||||
client_updatewmhints(c);
|
client_updatewmhints(c);
|
||||||
else if(ev->atom == WM_NAME || ev->atom == _NET_WM_NAME)
|
else if(ev->atom == WM_NAME || ev->atom == _NET_WM_NAME)
|
||||||
client_updatetitle(c);
|
client_updatetitle(c);
|
||||||
|
else if(ev->atom == _NET_WM_ICON)
|
||||||
|
{
|
||||||
|
netwm_icon_delete(&c->icon);
|
||||||
|
c->icon = ewmh_window_icon_get(c->win);
|
||||||
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
2
ewmh.c
2
ewmh.c
|
@ -516,7 +516,7 @@ ewmh_check_client_hints(client_t *c)
|
||||||
* \return A netwm_icon_t structure which must be deleted after usage.
|
* \return A netwm_icon_t structure which must be deleted after usage.
|
||||||
*/
|
*/
|
||||||
netwm_icon_t *
|
netwm_icon_t *
|
||||||
ewmh_get_window_icon(xcb_window_t w)
|
ewmh_window_icon_get(xcb_window_t w)
|
||||||
{
|
{
|
||||||
double alpha;
|
double alpha;
|
||||||
netwm_icon_t *icon;
|
netwm_icon_t *icon;
|
||||||
|
|
12
ewmh.h
12
ewmh.h
|
@ -24,19 +24,15 @@
|
||||||
|
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int height;
|
|
||||||
int width;
|
|
||||||
unsigned char *image;
|
|
||||||
} netwm_icon_t;
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
netwm_icon_delete(netwm_icon_t **i)
|
netwm_icon_delete(netwm_icon_t **i)
|
||||||
|
{
|
||||||
|
if(*i)
|
||||||
{
|
{
|
||||||
p_delete(&(*i)->image);
|
p_delete(&(*i)->image);
|
||||||
p_delete(i);
|
p_delete(i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ewmh_init(int);
|
void ewmh_init(int);
|
||||||
void ewmh_update_net_client_list(int);
|
void ewmh_update_net_client_list(int);
|
||||||
|
@ -48,7 +44,7 @@ int ewmh_process_client_message(xcb_client_message_event_t *);
|
||||||
void ewmh_update_net_client_list_stacking(int);
|
void ewmh_update_net_client_list_stacking(int);
|
||||||
void ewmh_check_client_hints(client_t *);
|
void ewmh_check_client_hints(client_t *);
|
||||||
void ewmh_update_workarea(int);
|
void ewmh_update_workarea(int);
|
||||||
netwm_icon_t * ewmh_get_window_icon(xcb_window_t);
|
netwm_icon_t * ewmh_window_icon_get(xcb_window_t);
|
||||||
void ewmh_restart(void);
|
void ewmh_restart(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
10
structs.h
10
structs.h
|
@ -236,6 +236,14 @@ struct statusbar_t
|
||||||
statusbar_t *prev, *next;
|
statusbar_t *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Netwm icon */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int height;
|
||||||
|
int width;
|
||||||
|
unsigned char *image;
|
||||||
|
} netwm_icon_t;
|
||||||
|
|
||||||
/** client_t type */
|
/** client_t type */
|
||||||
struct client_t
|
struct client_t
|
||||||
{
|
{
|
||||||
|
@ -295,6 +303,8 @@ struct client_t
|
||||||
button_t *buttons;
|
button_t *buttons;
|
||||||
/** Floating window placement algo */
|
/** Floating window placement algo */
|
||||||
floating_placement_t *floating_placement;
|
floating_placement_t *floating_placement;
|
||||||
|
/** Icon */
|
||||||
|
netwm_icon_t *icon;
|
||||||
/** Next and previous clients */
|
/** Next and previous clients */
|
||||||
client_t *prev, *next;
|
client_t *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,7 +42,6 @@ appicon_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
|
||||||
void *p, awesome_type_t type)
|
void *p, awesome_type_t type)
|
||||||
{
|
{
|
||||||
client_t *c = NULL;
|
client_t *c = NULL;
|
||||||
netwm_icon_t *icon;
|
|
||||||
draw_image_t *image;
|
draw_image_t *image;
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
|
@ -68,10 +67,10 @@ appicon_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
|
||||||
w->area.y, ctx->height, image);
|
w->area.y, ctx->height, image);
|
||||||
draw_image_delete(&image);
|
draw_image_delete(&image);
|
||||||
}
|
}
|
||||||
else if((icon = ewmh_get_window_icon(c->win)))
|
else if(c->icon)
|
||||||
{
|
{
|
||||||
w->area.width = ((double) ctx->height / (double) icon->height)
|
w->area.width = ((double) ctx->height / (double) c->icon->height)
|
||||||
* icon->width;
|
* c->icon->width;
|
||||||
w->area.x = widget_calculate_offset(ctx->width,
|
w->area.x = widget_calculate_offset(ctx->width,
|
||||||
w->area.width,
|
w->area.width,
|
||||||
offset,
|
offset,
|
||||||
|
@ -79,9 +78,8 @@ appicon_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
|
||||||
draw_image_from_argb_data(ctx,
|
draw_image_from_argb_data(ctx,
|
||||||
w->area.x,
|
w->area.x,
|
||||||
w->area.y,
|
w->area.y,
|
||||||
icon->width, icon->height,
|
c->icon->width, c->icon->height,
|
||||||
ctx->height, icon->image);
|
ctx->height, c->icon->image);
|
||||||
netwm_icon_delete(&icon);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -118,7 +118,6 @@ tasklist_draw(draw_context_t *ctx, int screen,
|
||||||
tasklist_data_t *d = w->widget->data;
|
tasklist_data_t *d = w->widget->data;
|
||||||
area_t area;
|
area_t area;
|
||||||
int i = 0, icon_width = 0, box_width_rest = 0;
|
int i = 0, icon_width = 0, box_width_rest = 0;
|
||||||
netwm_icon_t *icon;
|
|
||||||
draw_image_t *image;
|
draw_image_t *image;
|
||||||
draw_parser_data_t pdata, *parser_data;
|
draw_parser_data_t pdata, *parser_data;
|
||||||
tasklist_object_data_t *odata;
|
tasklist_object_data_t *odata;
|
||||||
|
@ -213,8 +212,9 @@ tasklist_draw(draw_context_t *ctx, int screen,
|
||||||
draw_image_delete(&image);
|
draw_image_delete(&image);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!icon_width && (icon = ewmh_get_window_icon(odata->client_labels.tab[i].client->win)))
|
if(!icon_width && odata->client_labels.tab[i].client->icon)
|
||||||
{
|
{
|
||||||
|
netwm_icon_t *icon = odata->client_labels.tab[i].client->icon;
|
||||||
icon_width = ((double) ctx->height / (double) icon->height)
|
icon_width = ((double) ctx->height / (double) icon->height)
|
||||||
* icon->width;
|
* icon->width;
|
||||||
draw_image_from_argb_data(ctx,
|
draw_image_from_argb_data(ctx,
|
||||||
|
@ -222,7 +222,6 @@ tasklist_draw(draw_context_t *ctx, int screen,
|
||||||
w->area.y,
|
w->area.y,
|
||||||
icon->width, icon->height,
|
icon->width, icon->height,
|
||||||
ctx->height, icon->image);
|
ctx->height, icon->image);
|
||||||
netwm_icon_delete(&icon);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue