commit 5f37f678214b337639e8cf579bacb3ccac26862e
parent 4c995b291123f5e27a281002bb4f926861f04d42
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Wed, 29 Mar 2006 09:45:54 +0200
implemented implicit view destroying if last client gets detached, corrected taglabel appearance/disappearance, fixed some small bugs
Diffstat:
3 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c
@@ -76,7 +76,14 @@ update_tags()
organize_client(view[sel], client[i]);
}
- if(!nview && ntag)
+ if(!hasclient(view[sel])) {
+ destroy_view(view[sel]);
+ if(nview)
+ focus_view(view[sel]);
+ else
+ update_bar_tags();
+ }
+ else if(!nview && ntag)
select_view(tag[0]);
else
update_bar_tags();
diff --git a/cmd/wm/view.c b/cmd/wm/view.c
@@ -19,12 +19,11 @@ alloc_view(char *name)
alloc_area(v);
alloc_area(v);
view = (View **)cext_array_attach((void **)view, v, sizeof(View *), &viewsz);
- nview++;
- focus_view(v);
+ sel = nview++;
return v;
}
-static void
+void
destroy_view(View *v)
{
while(v->narea)
@@ -63,14 +62,23 @@ update_frame_selectors(View *v)
void
focus_view(View *v)
{
+ Client *c;
unsigned int i;
+ char vname[256];
- if(!nview)
- return;
+ /* cleanup other empty views */
+ for(i = 0; i < nview; i++)
+ if(!hasclient(view[i])) {
+ destroy_view(view[i]);
+ i--;
+ }
XGrabServer(dpy);
sel = view2index(v);
+ tags2str(vname, sizeof(vname), v->tag, v->ntag);
+ cext_strlcpy(def.tag, vname, sizeof(def.tag));
+
update_frame_selectors(v);
/* gives all(!) clients proper geometry (for use of different tags) */
@@ -87,6 +95,8 @@ focus_view(View *v)
XMoveWindow(dpy, client[i]->framewin,
2 * rect.width + f->rect.x, f->rect.y);
}
+ if((c = sel_client_of_view(v)))
+ focus_client(c);
update_bar_tags();
XSync(dpy, False);
XUngrabServer(dpy);
@@ -189,32 +199,15 @@ hasclient(View *v)
void
select_view(char *arg)
{
- int i;
- Client *c;
View *v = get_view(arg);
-
if(!v)
return;
- cext_strlcpy(def.tag, arg, sizeof(def.tag));
if(!istag(arg)) {
- char buf[256];
tag = (char **)cext_array_attach((void **)tag, strdup(arg),
sizeof(char *), &tagsz);
ntag++;
- snprintf(buf, sizeof(buf), "NewTag %s\n", arg);
- write_event(buf);
}
focus_view(v);
-
- /* cleanup on select */
- for(i = 0; i < nview; i++)
- if(!hasclient(view[i])) {
- destroy_view(view[i]);
- i--;
- }
-
- if((c = sel_client_of_view(v)))
- focus_client(c);
}
Bool
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -300,6 +300,7 @@ Client *sel_client_of_view(View *v);
void restack_view(View *v);
Bool hasclient(View *v);
View *name2view(char *name);
+void destroy_view(View *v);
/* wm.c */
void scan_wins();