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