mirror of https://github.com/0intro/wmii
proceeded with fixing detach_fromtag, still buggy
This commit is contained in:
parent
34cebed260
commit
8a85f71a24
|
@ -103,9 +103,9 @@ select_area(Area *a, char *arg)
|
|||
}
|
||||
|
||||
void
|
||||
send_toarea(Area *to, Client *c)
|
||||
send_toarea(Area *to, Area *from, Client *c)
|
||||
{
|
||||
detach_fromarea(c);
|
||||
detach_fromarea(from, c);
|
||||
attach_toarea(to, c);
|
||||
focus_client(c);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ attach_toarea(Area *a, Client *c)
|
|||
static unsigned short id = 1;
|
||||
Frame *f;
|
||||
|
||||
if(is_clientof(a->tag, c))
|
||||
if(clientoftag(a->tag, c))
|
||||
return;
|
||||
f = cext_emallocz(sizeof(Frame));
|
||||
f->id = id++;
|
||||
|
@ -142,21 +142,20 @@ attach_toarea(Area *a, Client *c)
|
|||
}
|
||||
|
||||
void
|
||||
detach_fromarea(Client *c)
|
||||
detach_fromarea(Area *a, Client *c)
|
||||
{
|
||||
Frame *f = c->frame;
|
||||
Area *a = f->area;
|
||||
Tag *t = a->tag;
|
||||
|
||||
cext_array_detach((void **)a->frame, f, &a->framesz);
|
||||
free(f);
|
||||
a->nframe--;
|
||||
c->frame = nil;
|
||||
if(a->nframe) {
|
||||
if(a->sel >= a->nframe)
|
||||
a->sel = 0;
|
||||
if(a->sel >= a->nframe)
|
||||
a->sel = 0;
|
||||
if(a->nframe)
|
||||
arrange_area(a);
|
||||
}
|
||||
else {
|
||||
Tag *t = a->tag;
|
||||
if(t->narea > 2)
|
||||
destroy_area(a);
|
||||
arrange_tag(t, True);
|
||||
|
@ -387,7 +386,7 @@ drop_moving(Frame *f, XRectangle *new, XPoint * pt)
|
|||
!blitz_ispointinrect(pt->x, pt->y, &t->area[i]->rect); i++);
|
||||
if((tgt = ((i < t->narea) ? t->area[i] : nil))) {
|
||||
if(tgt != src) {
|
||||
send_toarea(tgt, f->client);
|
||||
send_toarea(tgt, src, f->client);
|
||||
arrange_area(tgt);
|
||||
}
|
||||
else {
|
||||
|
@ -415,3 +414,14 @@ resize_area(Client *c, XRectangle *r, XPoint *pt)
|
|||
else
|
||||
drop_resize(f, r);
|
||||
}
|
||||
|
||||
Bool
|
||||
clientofarea(Area *a, Client *c)
|
||||
{
|
||||
unsigned int i;
|
||||
for(i = 0; i < a->nframe; i++)
|
||||
if(a->frame[i]->client == c)
|
||||
return True;
|
||||
return False;
|
||||
}
|
||||
|
||||
|
|
|
@ -343,21 +343,10 @@ attach_client(Client *c)
|
|||
void
|
||||
detach_fromtag(Tag *t, Client *c, Bool unmap)
|
||||
{
|
||||
/* TODO: later check c->frame's if it is a member of t */
|
||||
Frame *f = c->frame;
|
||||
if(f) {
|
||||
if(!c->destroyed) {
|
||||
if(!unmap)
|
||||
unmap_client(c);
|
||||
c->rect.x = f->rect.x;
|
||||
c->rect.y = f->rect.y;
|
||||
reparent_client(c, root, c->rect.x, c->rect.y);
|
||||
XUnmapWindow(dpy, c->framewin);
|
||||
}
|
||||
detach_fromarea(c);
|
||||
}
|
||||
if(c->destroyed)
|
||||
destroy_client(c);
|
||||
int i;
|
||||
for(i = 0; i < t->narea; i++)
|
||||
if(clientofarea(t->area[i], c))
|
||||
detach_fromarea(t->area[i], c);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -365,8 +354,13 @@ detach_client(Client *c, Bool unmap)
|
|||
{
|
||||
int i;
|
||||
for(i = 0; i < ntag; i++)
|
||||
if(is_clientof(tag[i], c))
|
||||
detach_fromtag(tag[i], c, unmap);
|
||||
detach_fromtag(tag[i], c, unmap);
|
||||
if(!unmap)
|
||||
unmap_client(c);
|
||||
c->rect.x = c->frame->rect.x;
|
||||
c->rect.y = c->frame->rect.y;
|
||||
reparent_client(c, root, c->rect.x, c->rect.y);
|
||||
XUnmapWindow(dpy, c->framewin);
|
||||
}
|
||||
|
||||
Client *
|
||||
|
@ -547,9 +541,7 @@ sendtoarea_client(Client *c, char *arg)
|
|||
return;
|
||||
to = t->area[i];
|
||||
}
|
||||
send_toarea(to, c);
|
||||
arrange_area(a);
|
||||
arrange_area(to);
|
||||
send_toarea(to, a, c);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -183,11 +183,9 @@ handle_destroynotify(XEvent *e)
|
|||
{
|
||||
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
||||
Client *c = win2client(ev->window);
|
||||
if(c) {
|
||||
fprintf(stderr, "destroy: %s\n", c->name);
|
||||
c->destroyed = True;
|
||||
if(c->frame)
|
||||
detach_client(c, False);
|
||||
}
|
||||
destroy_client(c);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -275,10 +273,8 @@ handle_unmapnotify(XEvent *e)
|
|||
{
|
||||
XUnmapEvent *ev = &e->xunmap;
|
||||
Client *c;
|
||||
if((c = win2client(ev->window))) {
|
||||
fprintf(stderr, "unmap %s\n", c->name);
|
||||
if((c = win2client(ev->window)))
|
||||
detach_client(c, True);
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_clientmessage(XEvent *e)
|
||||
|
|
19
cmd/wm/tag.c
19
cmd/wm/tag.c
|
@ -147,7 +147,7 @@ get_tag(char *name)
|
|||
|
||||
t = alloc_tag(name);
|
||||
for(i = 0; i < nclient; i++)
|
||||
if(!is_clientof(t, client[i]) && strstr(client[i]->tags, name))
|
||||
if(!clientoftag(t, client[i]) && strstr(client[i]->tags, name))
|
||||
attach_totag(t, client[i]);
|
||||
return t;
|
||||
}
|
||||
|
@ -175,15 +175,12 @@ has_ctag(char *tag)
|
|||
}
|
||||
|
||||
Bool
|
||||
is_clientof(Tag *t, Client *c)
|
||||
clientoftag(Tag *t, Client *c)
|
||||
{
|
||||
unsigned int i, j;
|
||||
for(i = 0; i < t->narea; i++) {
|
||||
Area *a = t->area[i];
|
||||
for(j = 0; j < a->nframe; j++)
|
||||
if(a->frame[j]->client == c)
|
||||
return True;
|
||||
}
|
||||
unsigned int i;
|
||||
for(i = 0; i < t->narea; i++)
|
||||
if(clientofarea(t->area[i], c))
|
||||
return True;
|
||||
return False;
|
||||
}
|
||||
|
||||
|
@ -226,11 +223,11 @@ update_ctags()
|
|||
for(i = 0; i < nclient; i++)
|
||||
for(j = 0; j < ntag; j++) {
|
||||
if(strstr(client[i]->tags, tag[j]->name)) {
|
||||
if(!is_clientof(tag[j], client[i]))
|
||||
if(!clientoftag(tag[j], client[i]))
|
||||
attach_totag(tag[j], client[i]);
|
||||
}
|
||||
else {
|
||||
if(is_clientof(tag[j], client[i]))
|
||||
if(clientoftag(tag[j], client[i]))
|
||||
detach_fromtag(tag[j], client[i], False);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,14 +210,15 @@ int area2index(Area *a);
|
|||
int aid2index(Tag *t, unsigned short id);
|
||||
void update_area_geometry(Area *a);
|
||||
void select_area(Area *a, char *arg);
|
||||
void send_toarea(Area *to, Client *c);
|
||||
void send_toarea(Area *to, Area *from, Client *c);
|
||||
void attach_toarea(Area *a, Client *c);
|
||||
void detach_fromarea(Client *c);
|
||||
void detach_fromarea(Area *a, Client *c);
|
||||
void arrange_tag(Tag *t, Bool updategeometry);
|
||||
void arrange_area(Area *a);
|
||||
void resize_area(Client *c, XRectangle *r, XPoint *pt);
|
||||
int str2mode(char *arg);
|
||||
char *mode2str(int mode);
|
||||
Bool clientofarea(Area *a, Client *c);
|
||||
|
||||
/* bar.c */
|
||||
Label *new_label();
|
||||
|
@ -295,7 +296,7 @@ void select_tag(char *arg);
|
|||
int tag2index(Tag *t);
|
||||
Bool has_ctag(char *tag);
|
||||
void update_ctags();
|
||||
Bool is_clientof(Tag *t, Client *c);
|
||||
Bool clientoftag(Tag *t, Client *c);
|
||||
|
||||
/* wm.c */
|
||||
void scan_wins();
|
||||
|
|
Loading…
Reference in New Issue