commit f78cc72f3d8100946425c956b5b1a04f2ed1e7d0
parent 95b53743deccf486e5d03fbb1b7ad98257290564
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Wed, 8 Mar 2006 23:53:52 +0100
fixed transient handling, fixed zombie frames
Diffstat:
7 files changed, 41 insertions(+), 47 deletions(-)
diff --git a/cmd/wm/area.c b/cmd/wm/area.c
@@ -40,7 +40,7 @@ destroy_area(Area *a)
free(a->frame);
cext_array_detach((void **)t->area, a, &t->areasz);
t->narea--;
- if(t->sel > 0)
+ if(t->sel > 1)
t->sel--;
free(a);
}
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -185,7 +185,7 @@ kill_client(Client * c)
}
void
-handle_client_property(Client *c, XPropertyEvent *e)
+update_client_property(Client *c, XPropertyEvent *e)
{
XTextProperty name;
long msize;
@@ -217,17 +217,6 @@ handle_client_property(Client *c, XPropertyEvent *e)
}
}
-void
-destroy_client(Client * c)
-{
- XFreeGC(dpy, c->gc);
- XDestroyWindow(dpy, c->framewin);
- cext_array_detach((void **)client, c, &clientsz);
- nclient--;
- update_ctags();
- free(c);
-}
-
/* speed reasoned function for client property change */
void
draw_client(Client *c)
@@ -328,21 +317,29 @@ gravitate(Client *c, Bool invert)
}
void
-attach_client(Client *c)
+manage_client(Client *c)
{
TClass *tc = client2class(c);
Tag *t;
+ if(c->trans) {
+ c->tags[0] = '~';
+ c->tags[1] = 0;
+ }
+ else
+ c->tags[0] = 0;
+
t = ntag ? tag[sel] : alloc_tag(def.tag);
- cext_strlcpy(c->tags, tc && strlen(tc->tags) ? tc->tags : t->name, sizeof(c->tags));
- update_ctags();
+ cext_strlcat(c->tags, tc && strlen(tc->tags) ? tc->tags : t->name, sizeof(c->tags));
+ update_tags();
}
void
-detach_client(Client *c, Bool unmap)
+destroy_client(Client *c, Bool unmap)
{
int i;
Client *cl;
+
for(i = 0; i < ntag; i++)
detach_fromtag(tag[i], c, unmap);
if(!unmap)
@@ -351,8 +348,15 @@ detach_client(Client *c, Bool unmap)
c->rect.x = c->frame[c->sel]->rect.x;
c->rect.y = c->frame[c->sel]->rect.y;
reparent_client(c, root, c->rect.x, c->rect.y);
- XUnmapWindow(dpy, c->framewin);
}
+
+ XFreeGC(dpy, c->gc);
+ XDestroyWindow(dpy, c->framewin);
+ cext_array_detach((void **)client, c, &clientsz);
+ nclient--;
+ update_tags();
+ free(c);
+
if((cl = sel_client_of_tag(tag[sel])))
focus_client(cl);
}
diff --git a/cmd/wm/event.c b/cmd/wm/event.c
@@ -183,9 +183,7 @@ handle_destroynotify(XEvent *e)
Client *c = win2client(ev->window);
if(!c)
return;
- if(c->frame)
- detach_client(c, False);
- destroy_client(c);
+ destroy_client(c, False);
}
static void
@@ -224,7 +222,6 @@ handle_maprequest(XEvent *e)
{
XMapRequestEvent *ev = &e->xmaprequest;
static XWindowAttributes wa;
- static Client *c;
if(!XGetWindowAttributes(dpy, ev->window, &wa))
return;
@@ -235,11 +232,8 @@ handle_maprequest(XEvent *e)
}
/* there're client which send map requests twice */
- c = win2client(ev->window);
- if(!c)
- c = alloc_client(ev->window, &wa);
- if(!c->frame)
- attach_client(c);
+ if(!win2client(ev->window))
+ manage_client(alloc_client(ev->window, &wa));
}
static void
@@ -265,7 +259,7 @@ handle_propertynotify(XEvent *e)
return; /* ignore */
if((c = win2client(ev->window)))
- handle_client_property(c, ev);
+ update_client_property(c, ev);
}
static void
@@ -274,5 +268,5 @@ handle_unmapnotify(XEvent *e)
XUnmapEvent *ev = &e->xunmap;
Client *c;
if((c = win2client(ev->window)))
- detach_client(c, True);
+ destroy_client(c, True);
}
diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c
@@ -327,7 +327,7 @@ name2type(char *name, unsigned char dir_type)
return FsFmode;
if(!strncmp(name, "tag", 4))
return FsFtag;
- if(has_ctag(name) && (dir_type == FsDtags))
+ if(has_tag(name) && (dir_type == FsDtags))
return FsFtag;
if((dir_type == FsDclass) && name2class(name))
return FsFclasstag;
@@ -1346,7 +1346,7 @@ xwrite(IXPConn *c, Fcall *fcall)
memcpy(client[i1]->tags, fcall->data, fcall->count);
client[i1]->tags[fcall->count] = 0;
}
- update_ctags();
+ update_tags();
break;
case FsFgeom:
if(fcall->count > sizeof(buf))
diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c
@@ -139,7 +139,7 @@ get_tag(char *name)
unsigned int i, n = 0;
Tag *t;
- if(!has_ctag(name))
+ if(!has_tag(name))
return nil;
for(i = 0; i < ntag; i++) {
t = tag[i];
@@ -185,7 +185,7 @@ select_tag(char *arg)
}
Bool
-has_ctag(char *tag)
+has_tag(char *tag)
{
unsigned int i;
for(i = 0; i < nctag; i++)
@@ -205,14 +205,14 @@ clientoftag(Tag *t, Client *c)
}
void
-update_ctags()
+update_tags()
{
unsigned int i, j, k;
char buf[256];
char *tags[128];
char *t;
- fprintf(stderr, "%s", "update_ctags\n");
+ fprintf(stderr, "%s", "update_tags\n");
for(i = 0; i < nctag; i++) {
free(ctag[i]);
ctag[i] = nil;
@@ -226,7 +226,7 @@ update_ctags()
t = tags[k];
if(*t == '~')
t++;
- if(!has_ctag(t)) {
+ if(!has_tag(t)) {
ctag = (char **)cext_array_attach((void **)ctag, strdup(t),
sizeof(char *), &ctagsz);
nctag++;
diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c
@@ -48,7 +48,6 @@ scan_wins()
Window *wins;
XWindowAttributes wa;
Window d1, d2;
- Client *c;
if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
for(i = 0; i < num; i++) {
@@ -57,10 +56,8 @@ scan_wins()
if(wa.override_redirect
|| XGetTransientForHint(dpy, wins[i], &d1))
continue;
- if(wa.map_state == IsViewable) {
- c = alloc_client(wins[i], &wa);
- attach_client(c);
- }
+ if(wa.map_state == IsViewable)
+ manage_client(alloc_client(wins[i], &wa));
}
}
if(wins)
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -249,17 +249,16 @@ TClass *client2class(Client *c);
/* client.c */
Client *alloc_client(Window w, XWindowAttributes *wa);
-void destroy_client(Client *c);
void configure_client(Client *c);
-void handle_client_property(Client *c, XPropertyEvent *e);
+void update_client_property(Client *c, XPropertyEvent *e);
void kill_client(Client *c);
void draw_client(Client *client);
void gravitate(Client *c, Bool invert);
void unmap_client(Client *c);
void map_client(Client *c);
void reparent_client(Client *c, Window w, int x, int y);
-void attach_client(Client *c);
-void detach_client(Client *c, Bool unmap);
+void manage_client(Client *c);
+void destroy_client(Client *c, Bool unmap);
Client *sel_client();
void focus_client(Client *c);
void resize_client(Client *c, XRectangle *r, XPoint *pt, Bool ignore_xcall);
@@ -313,8 +312,8 @@ XRectangle *rectangles(unsigned int *num);
int tid2index(unsigned short id);
void select_tag(char *arg);
int tag2index(Tag *t);
-Bool has_ctag(char *tag);
-void update_ctags();
+Bool has_tag(char *tag);
+void update_tags();
Bool clientoftag(Tag *t, Client *c);
void detach_fromtag(Tag *t, Client *c, Bool unmap);
void attach_totag(Tag *t, Client *c);