commit f7f15fa7a7462e96cace6c4e4ae50f6d041a4bc8
parent b340936d27de03abe3420683f986c915a61e2532
Author: Kris Maglione <kris@suckless.org>
Date: Wed, 14 Sep 2011 18:21:18 -0400
More robust view urgency tracking. Closes issue #241.
Diffstat:
5 files changed, 65 insertions(+), 49 deletions(-)
diff --git a/cmd/wmii/client.c b/cmd/wmii/client.c
@@ -714,18 +714,11 @@ client_seturgent(Client *c, int urgent, int from) {
event("%sUrgent %#C %s\n", cnot, c, cfrom);
c->urgent = urgent;
ewmh_updatestate(c);
- if(c->sel) {
+ if(c->sel)
frame_draw(c->sel);
- for(f=c->frame; f; f=f->cnext) {
- SET(ff);
- if(!urgent)
- foreach_frame(f->view, s, a, ff)
- if(ff->client->urgent) break;
- if(urgent || ff == nil)
- event("%sUrgentTag %s %s\n",
- cnot, cfrom, f->view->name);
- }
- }
+
+ for(f=c->frame; f; f=f->cnext)
+ view_update_urgency(f->view, cfrom);
}
if(from == UrgManager) {
diff --git a/cmd/wmii/dat.h b/cmd/wmii/dat.h
@@ -295,6 +295,7 @@ struct View {
int selcol;
int selscreen;
bool dead;
+ bool urgent;
Rectangle *r;
Rectangle *pad;
};
diff --git a/cmd/wmii/fns.h b/cmd/wmii/fns.h
@@ -279,6 +279,7 @@ void view_select(const char*);
void view_update(View*);
void view_update_all(void);
void view_update_rect(View*);
+void view_update_urgency(View*, char*);
Rectangle* view_rects(View*, uint *num, Frame *ignore);
/* utf.c */
diff --git a/cmd/wmii/message.c b/cmd/wmii/message.c
@@ -794,6 +794,8 @@ readctl_view(View *v) {
bufclear();
bufprint("%s\n", v->name);
+ bufprint("urgent %s\n", TOGGLE(v->urgent));
+
/* select <area>[ <frame>] */
bufprint("select %a", v->sel);
if(v->sel->sel)
diff --git a/cmd/wmii/view.c b/cmd/wmii/view.c
@@ -287,47 +287,67 @@ view_update(View *v) {
Area *a;
int s;
- if(v != selview)
- return;
- if(starting)
- return;
-
- frames_update_sel(v);
+ if(v == selview && !starting) {
+ frames_update_sel(v);
- foreach_frame(v, s, a, f)
- if(f->client->fullscreen >= 0) {
- f->collapsed = false;
- if(!f->area->floating) {
- f->oldarea = area_idx(f->area);
- f->oldscreen = f->area->screen;
- area_moveto(v->floating, f);
- area_setsel(v->floating, f);
- }else if(f->oldarea == -1)
- f->oldarea = 0;
+ foreach_frame(v, s, a, f)
+ if(f->client->fullscreen >= 0) {
+ f->collapsed = false;
+ if(!f->area->floating) {
+ f->oldarea = area_idx(f->area);
+ f->oldscreen = f->area->screen;
+ area_moveto(v->floating, f);
+ area_setsel(v->floating, f);
+ }else if(f->oldarea == -1)
+ f->oldarea = 0;
+ }
+
+ view_arrange(v);
+
+ for(c=client; c; c=c->next) {
+ f = c->sel;
+ if((f && f->view == v)
+ && (f->area == v->sel || !(f->area && f->area->max && f->area->floating))) {
+ if(f->area)
+ client_resize(c, f->r);
+ }else {
+ client_unmapframe(c);
+ client_unmap(c, IconicState);
+ }
+ ewmh_updatestate(c);
+ ewmh_updateclient(c);
}
- view_arrange(v);
+ view_restack(v);
+ if(!v->sel->floating && view_fullscreen_p(v, v->sel->screen))
+ area_focus(v->floating);
+ else
+ area_focus(v->sel);
+ frame_draw_all();
+ }
+ view_update_urgency(v, nil);
+}
- for(c=client; c; c=c->next) {
- f = c->sel;
- if((f && f->view == v)
- && (f->area == v->sel || !(f->area && f->area->max && f->area->floating))) {
- if(f->area)
- client_resize(c, f->r);
- }else {
- client_unmapframe(c);
- client_unmap(c, IconicState);
+void
+view_update_urgency(View *v, char *from) {
+ Area *a;
+ Frame *f;
+ int s, urgent;
+
+ urgent = 0;
+ foreach_frame(v, s, a, f)
+ if (f->client->urgent) {
+ urgent++;
+ break;
}
- ewmh_updatestate(c);
- ewmh_updateclient(c);
- }
- view_restack(v);
- if(!v->sel->floating && view_fullscreen_p(v, v->sel->screen))
- area_focus(v->floating);
- else
- area_focus(v->sel);
- frame_draw_all();
+ if (urgent != v->urgent)
+ event("%sUrgentTag %s %s\n",
+ urgent ? "" : "Not",
+ from ? from : "Unknown",
+ v->name);
+
+ v->urgent = urgent;
}
void
@@ -432,9 +452,8 @@ view_detach(Frame *f) {
c->sel = f->cnext;
event("ViewDetach %s %#C\n", v->name, c);
- if(v == selview)
- view_update(v);
- else if(empty_p(v))
+ view_update(v);
+ if(view != selview && empty_p(v))
view_destroy(v);
}