add support for Urgency hint

This commit is contained in:
Julien Danjou 2007-12-23 15:16:10 +01:00
parent 2906ead93c
commit d5d9439777
7 changed files with 53 additions and 8 deletions

View File

@ -507,6 +507,18 @@ client_unmanage(Client *c, long state)
p_delete(&c);
}
void
client_updatewmhints(Client *c)
{
XWMHints *wmh;
if((wmh = XGetWMHints(globalconf.display, c->win)))
{
c->isurgent = (wmh->flags & XUrgencyHint);
XFree(wmh);
}
}
void
client_updatesizehints(Client *c)
{

View File

@ -34,6 +34,7 @@ void client_manage(Window, XWindowAttributes *, int);
void client_resize(Client *, int, int, int, int, Bool, Bool);
void client_unban(Client *);
void client_unmanage(Client *, long);
void client_updatewmhints(Client *);
void client_updatesizehints(Client *);
void client_updatetitle(Client *);
void client_saveprops(Client *, int);

View File

@ -327,6 +327,8 @@ config_parse(const char *confpatharg)
CFG_STR((char *) "focus_border", (char *) "#6666ff", CFGF_NONE),
CFG_STR((char *) "focus_bg", (char *) "#6666ff", CFGF_NONE),
CFG_STR((char *) "focus_fg", (char *) "#ffffff", CFGF_NONE),
CFG_STR((char *) "urgent_bg", (char *) "#ff0000", CFGF_NONE),
CFG_STR((char *) "urgent_fg", (char *) "#ffffff", CFGF_NONE),
CFG_STR((char *) "tab_border", (char *) "#ff0000", CFGF_NONE),
CFG_END()
};
@ -551,17 +553,21 @@ config_parse(const char *confpatharg)
eprint("awesome: cannot init font\n");
/* Colors */
virtscreen->colors_normal[ColBorder] = initxcolor(screen,
cfg_getstr(cfg_colors, "normal_border"));
cfg_getstr(cfg_colors, "normal_border"));
virtscreen->colors_normal[ColBG] = initxcolor(screen,
cfg_getstr(cfg_colors, "normal_bg"));
cfg_getstr(cfg_colors, "normal_bg"));
virtscreen->colors_normal[ColFG] = initxcolor(screen,
cfg_getstr(cfg_colors, "normal_fg"));
cfg_getstr(cfg_colors, "normal_fg"));
virtscreen->colors_selected[ColBorder] = initxcolor(screen,
cfg_getstr(cfg_colors, "focus_border"));
cfg_getstr(cfg_colors, "focus_border"));
virtscreen->colors_selected[ColBG] = initxcolor(screen,
cfg_getstr(cfg_colors, "focus_bg"));
cfg_getstr(cfg_colors, "focus_bg"));
virtscreen->colors_selected[ColFG] = initxcolor(screen,
cfg_getstr(cfg_colors, "focus_fg"));
cfg_getstr(cfg_colors, "focus_fg"));
virtscreen->colors_urgent[ColBG] = initxcolor(screen,
cfg_getstr(cfg_colors, "urgent_bg"));
virtscreen->colors_urgent[ColFG] = initxcolor(screen,
cfg_getstr(cfg_colors, "urgent_fg"));
/* Statusbar */
virtscreen->statusbar = p_new(Statusbar, 1);

View File

@ -31,8 +31,9 @@
enum
{ BarTop, BarBot, BarLeft, BarRight, BarOff };
/** Common colors */
enum
{ ColBorder, ColFG, ColBG, ColLast }; /* color */
{ ColBorder, ColFG, ColBG, ColLast };
enum
{ CurNormal, CurResize, CurMove, CurLast }; /* cursor */
@ -114,6 +115,8 @@ struct Client
int minax, maxax, minay, maxay;
long flags;
int border, oldborder;
/** Has urgency hint */
Bool isurgent;
/** Store previous floating state before maximizing */
Bool wasfloating;
/** True if the window is floating */
@ -205,6 +208,8 @@ typedef struct
XColor colors_normal[ColLast];
/** Selected colors */
XColor colors_selected[ColLast];
/** Urgency colors */
XColor colors_urgent[ColLast];
/** Tag list */
Tag *tags;
TagClientLink *tclink;

View File

@ -357,6 +357,10 @@ handle_event_propertynotify(XEvent * e)
case XA_WM_NORMAL_HINTS:
client_updatesizehints(c);
break;
case XA_WM_HINTS:
client_updatewmhints(c);
statusbar_draw(c->screen);
break;
}
if(ev->atom == XA_WM_NAME || ev->atom == XInternAtom(c->display, "_NET_WM_NAME", False))
{

3
tag.c
View File

@ -84,6 +84,9 @@ is_client_tagged(Client *c, Tag *t, int screen)
{
TagClientLink *tc;
if(!c || c->screen != screen)
return False;
for(tc = globalconf.screens[screen].tclink; tc; tc = tc->next)
if(tc->client == c && tc->tag == t)
return True;

View File

@ -39,11 +39,23 @@ isoccupied(int screen, Tag *t)
Client *c;
for(c = globalconf.clients; c; c = c->next)
if(c->screen == screen && is_client_tagged(c, t, screen))
if(is_client_tagged(c, t, screen))
return True;
return False;
}
static Bool
isurgent(int screen, Tag *t)
{
Client *c;
for(c = globalconf.clients; c; c = c->next)
if(is_client_tagged(c, t, screen) && c->isurgent)
return True;
return False;
}
static int
taglist_draw(Widget *widget,
DrawCtx *ctx,
@ -73,6 +85,8 @@ taglist_draw(Widget *widget,
w = textwidth(ctx, vscreen.font, tag->name);
if(tag->selected)
colors = vscreen.colors_selected;
else if(isurgent(widget->statusbar->screen, tag))
colors = vscreen.colors_urgent;
else
colors = vscreen.colors_normal;
draw_text(ctx, location + width, 0, w,