Browse files

More robust view urgency tracking. Closes issue #241.

  • Loading branch information...
1 parent 4a97ce6 commit 9abf489c7c3d57f8ea0eab20167ecfad93a68914 Kris Maglione committed Sep 14, 2011
Showing with 65 additions and 49 deletions.
  1. +4 −11 cmd/wmii/client.c
  2. +1 −0 cmd/wmii/dat.h
  3. +1 −0 cmd/wmii/fns.h
  4. +2 −0 cmd/wmii/message.c
  5. +57 −38 cmd/wmii/view.c
View
15 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) {
View
1 cmd/wmii/dat.h
@@ -295,6 +295,7 @@ struct View {
int selcol;
int selscreen;
bool dead;
+ bool urgent;
Rectangle *r;
Rectangle *pad;
};
View
1 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 */
View
2 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)
View
95 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);
}

0 comments on commit 9abf489

Please sign in to comment.