wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit de0d5ba77e81dbebd877941493124c1257d57a0d
parent 7344423cc4608c7232fce9e97da777cbfdcec0c7
Author: Kris Maglione <kris@suckless.org>
Date:   Sat, 29 May 2010 18:03:14 -0400

Collapse/uncollapse floating clients on grab box click.

Diffstat:
cmd/wmii/area.c | 4++--
cmd/wmii/bar.c | 4++--
cmd/wmii/client.c | 12++++++------
cmd/wmii/column.c | 6+++---
cmd/wmii/div.c | 8++++----
cmd/wmii/ewmh.c | 2+-
cmd/wmii/float.c | 10++++------
cmd/wmii/frame.c | 20++++++++++++--------
cmd/wmii/fs.c | 12++++++------
cmd/wmii/layout.c | 29+++++++++++++++++++----------
cmd/wmii/message.c | 4++--
cmd/wmii/mouse.c | 4++--
cmd/wmii/rule.c | 2+-
cmd/wmii/view.c | 7+++----
14 files changed, 67 insertions(+), 57 deletions(-)

diff --git a/cmd/wmii/area.c b/cmd/wmii/area.c @@ -94,7 +94,7 @@ area_create(View *v, Area *pos, int scrn, uint width) { if(width == 0) { if(numcols >= 0) { width = view_newcolwidth(v, scrn, index); - if (width == 0) + if(width == 0) width = Dx(v->r[scrn]) / (numcols + 1); } else @@ -213,7 +213,7 @@ area_moveto(Area *to, Frame *f) { return; from = f->area; - if (from == to) + if(from == to) return; area_detach(f); diff --git a/cmd/wmii/bar.c b/cmd/wmii/bar.c @@ -98,7 +98,7 @@ bar_create(Bar **bp, const char *name) { strlcat(b->buf, b->col.colstr, sizeof(b->buf)); strlcat(b->buf, " ", sizeof(b->buf)); strlcat(b->buf, b->text, sizeof(b->buf)); - + SET(i); for(sp=screens; (s = *sp); sp++) { i = bp - s->bar; @@ -265,7 +265,7 @@ static bool bup_event(Window *w, void *aux, XButtonPressedEvent *e) { WMScreen *s; Bar *b; - + s = aux; b = findbar(s, Pt(e->x, e->y)); if(b) diff --git a/cmd/wmii/client.c b/cmd/wmii/client.c @@ -175,7 +175,7 @@ client_create(XWindow w, XWindowAttributes *wa) { } - /* + /* * It's actually possible for a window to be destroyed * before we get a chance to reparent it. Check for that * now, because otherwise we'll wind up mapping a @@ -277,7 +277,7 @@ client_destroy(Client *c) { r = client_grav(c, ZR); - hide = false; + hide = false; if(!c->sel || c->sel->view != selview) hide = true; @@ -887,7 +887,7 @@ destroy_event(Window *w, void *aux, XDestroyWindowEvent *e) { static bool enter_event(Window *w, void *aux, XCrossingEvent *e) { Client *c; - + c = aux; if(e->detail != NotifyInferior) { if(e->detail != NotifyVirtual) @@ -942,7 +942,7 @@ focusout_event(Window *w, void *aux, XFocusChangeEvent *e) { static bool unmap_event(Window *w, void *aux, XUnmapEvent *e) { Client *c; - + c = aux; if(e->send_event || c->w.unmapped < 0) client_destroy(c); @@ -954,7 +954,7 @@ map_event(Window *w, void *aux, XMapEvent *e) { Client *c; USED(e); - + c = aux; if(c == selclient()) client_focus(c); @@ -1033,7 +1033,7 @@ bsstrcmp(const void *a, const void *b) { static int strpcmp(const void *ap, const void *bp) { char **a, **b; - + a = (char**)ap; b = (char**)bp; return strcmp(*a, *b); diff --git a/cmd/wmii/column.c b/cmd/wmii/column.c @@ -67,7 +67,7 @@ column_setmode(Area *a, const char *mode) { } if(old) str++; - + } free(orig); return true; @@ -233,7 +233,7 @@ find(Area **ap, Frame **fp, int dir, bool wrap, bool stack) { *fp = stack_find(a, f, dir, stack); if(*fp) return true; - if (!a->floating) + if(!a->floating) *ap = area_find(a->view, r, dir, wrap); if(!*ap) return false; @@ -496,7 +496,7 @@ comp_frame(const void *a, const void *b) { ia = foo(*(Frame**)a); ib = foo(*(Frame**)b); - /* + /* * I'd like to favor the selected client, but * it causes windows to jump as focus changes. */ diff --git a/cmd/wmii/div.c b/cmd/wmii/div.c @@ -140,7 +140,7 @@ div_update_all(void) { dp = &divs; ap = nil; foreach_column(v, s, a) { - if (ap && ap->screen != s) + if(ap && ap->screen != s) ap = nil; d = getdiv(&dp); @@ -168,7 +168,7 @@ bdown_event(Window *w, void *aux, XButtonEvent *e) { Divide *d; USED(e); - + d = aux; mouse_resizecol(d); return false; @@ -177,9 +177,9 @@ bdown_event(Window *w, void *aux, XButtonEvent *e) { static bool expose_event(Window *w, void *aux, XExposeEvent *e) { Divide *d; - + USED(e); - + d = aux; drawdiv(d); return false; diff --git a/cmd/wmii/ewmh.c b/cmd/wmii/ewmh.c @@ -507,7 +507,7 @@ ewmh_updatestate(Client *c) { if(c->fullscreen >= 0) changeprop_long(&c->w, Net("WM_FULLSCREEN_MONITORS"), "CARDINAL", (long[]) { c->fullscreen, c->fullscreen, - c->fullscreen, c->fullscreen }, + c->fullscreen, c->fullscreen }, 4); else delproperty(&c->w, Net("WM_FULLSCREEN_MONITORS")); diff --git a/cmd/wmii/float.c b/cmd/wmii/float.c @@ -70,8 +70,6 @@ float_arrange(Area *a) { switch(a->mode) { case Coldefault: - for(f=a->frame; f; f=f->anext) - f->collapsed = false; break; case Colstack: for(f=a->frame; f; f=f->anext) @@ -201,15 +199,15 @@ float_placeframe(Frame *f) { */ s = -1; ff = client_groupframe(c, f->view); - if (f->screen >= 0) + if(f->screen >= 0) s = f->screen; - else if (ff) + else if(ff) s = ownerscreen(ff->r); - else if (selclient()) + else if(selclient()) s = ownerscreen(selclient()->sel->r); else { sel = view_findarea(a->view, a->view->selscreen, a->view->selcol, false); - if (sel) + if(sel) s = sel->screen; } diff --git a/cmd/wmii/frame.c b/cmd/wmii/frame.c @@ -216,7 +216,7 @@ enter_event(Window *w, void *aux, XCrossingEvent *e) { f->client, f->client->name, ignoreenter == e->serial ? " (ignored)" : ""); if(e->detail != NotifyInferior) - if(e->serial != ignoreenter && (f->area->floating || !f->collapsed)) + if(e->serial != ignoreenter && !f->collapsed) focus(f->client, false); } mouse_checkresize(f, Pt(e->x, e->y), false); @@ -241,7 +241,7 @@ expose_event(Window *w, void *aux, XExposeEvent *e) { static bool motion_event(Window *w, void *aux, XMotionEvent *e) { Client *c; - + c = aux; mouse_checkresize(c->sel, Pt(e->x, e->y), false); return false; @@ -269,9 +269,8 @@ frame_gethints(Frame *f) { c = f->client; h = *c->w.hints; - r = frame_rect2client(c, f->r, f->area->floating); - d.x = Dx(f->r) - Dx(r); - d.y = Dy(f->r) - Dy(r); + r = frame_client2rect(c, ZR, f->area->floating); + d = subpt(r.max, r.min); if(!f->area->floating && def.incmode == IIgnore) h.inc = Pt(1, 1); @@ -605,7 +604,9 @@ frame_focus(Frame *f) { /* XXX */ f->colr.max.y = f->colr.min.y + Dy(ff->colr); ff->colr.max.y = ff->colr.min.y + labelh(def.font); - }else if(f->area->mode == Coldefault) { + } + else if(f->area->mode == Coldefault) { + /* XXX */ for(; f->collapsed && f->anext; f=f->anext) ; for(; f->collapsed && f->aprev; f=f->aprev) @@ -620,6 +621,9 @@ frame_focus(Frame *f) { if(old_a != v->oldsel && f != old_f) v->oldsel = nil; + if(f->area->floating) + f->collapsed = false; + if(v != selview || a != v->sel || resizing) return; @@ -649,7 +653,7 @@ constrain(Rectangle r, int inset) { if(inset < 0) inset = Dy(screen->brect); - /* + /* * FIXME: This will cause problems for windows with * D(r) < 2 * inset */ @@ -657,7 +661,7 @@ constrain(Rectangle r, int inset) { SET(best); sbest = nil; for(sp=screens; (s = *sp); sp++) { - if (!screen->showing) + if(!screen->showing) continue; isect = rect_intersection(r, insetrect(s->r, inset)); if(Dx(isect) >= 0 && Dy(isect) >= 0) diff --git a/cmd/wmii/fs.c b/cmd/wmii/fs.c @@ -212,7 +212,7 @@ dostat(Stat *s, IxpFileId *f) { s->muid = user; } -/* +/* * All lookups and directory organization should be performed through * lookup_file, mostly through the dirtab[] tree. */ @@ -399,7 +399,7 @@ fs_stat(Ixp9Req *r) { int size; char *buf; IxpFileId *f; - + f = r->fid->aux; if(!ixp_srv_verifyfile(f, lookup_file)) { @@ -578,7 +578,7 @@ fs_write(Ixp9Req *r) { void fs_open(Ixp9Req *r) { IxpFileId *f; - + f = r->fid->aux; if(!ixp_srv_verifyfile(f, lookup_file)) { @@ -608,7 +608,7 @@ fs_open(Ixp9Req *r) { void fs_create(Ixp9Req *r) { IxpFileId *f; - + f = r->fid->aux; switch(f->tab.type) { @@ -639,7 +639,7 @@ void fs_remove(Ixp9Req *r) { IxpFileId *f; WMScreen *s; - + f = r->fid->aux; if(!ixp_srv_verifyfile(f, lookup_file)) { respond(r, Enofile); @@ -663,7 +663,7 @@ fs_remove(Ixp9Req *r) { void fs_clunk(Ixp9Req *r) { IxpFileId *f; - + f = r->fid->aux; if(!ixp_srv_verifyfile(f, lookup_file)) { respond(r, nil); diff --git a/cmd/wmii/layout.c b/cmd/wmii/layout.c @@ -48,7 +48,7 @@ framerect(Framewin *f) { r = rectaddpt(r, f->pt); scrn = f->screen; - if (scrn == -1) + if(scrn == -1) scrn = max(ownerscreen(f->f->r), 0); /* Keep onscreen */ @@ -72,7 +72,7 @@ framewin(Frame *f, Point pt, int orientation, int n) { Framewin *fw; fw = emallocz(sizeof *fw); - wa.override_redirect = true; + wa.override_redirect = true; wa.event_mask = ExposureMask; fw->w = createwindow(&scr.root, Rect(0, 0, 1, 1), scr.depth, InputOutput, @@ -88,7 +88,7 @@ framewin(Frame *f, Point pt, int orientation, int n) { raisewin(fw->w); - return fw; + return fw; } static void @@ -103,20 +103,20 @@ expose_event(Window *w, void *aux, XExposeEvent *e) { Framewin *f; Image *buf; CTuple *c; - + USED(e); f = aux; c = &def.focuscolor; buf = disp.ibuf; - + r = rectsubpt(w->r, w->r.min); fill(buf, r, c->bg); border(buf, r, 1, c->border); border(buf, f->grabbox, 1, c->border); border(buf, insetrect(f->grabbox, -f->grabbox.min.x), 1, c->border); - copyimage(w, r, buf, ZP); + copyimage(w, r, buf, ZP); return false; } @@ -202,7 +202,7 @@ hplace(Framewin *fw, Point pt) { Area *a; View *v; int minw; - + v = selview; a = find_area(pt); @@ -223,7 +223,7 @@ hplace(Framewin *fw, Point pt) { pt.y = a->r.min.y; frameadjust(fw, pt, OVert, Dy(a->r)); - reshapewin(fw->w, framerect(fw)); + reshapewin(fw->w, framerect(fw)); } static Point @@ -449,6 +449,7 @@ thcol(Frame *f, bool moved) { case ButtonRelease: if(!moved) goto done; + if(button != 1) continue; SET(collapsed); @@ -586,7 +587,8 @@ tfloat(Frame *f, bool moved) { warppointer(grabboxcenter(f)); } map_frame(f->client); - focus(f->client, false); + if(!f->collapsed) + focus(f->client, false); ret = TDone; if(!grabpointer(c->framewin, nil, cursor[CurMove], MouseMask)) @@ -596,7 +598,10 @@ tfloat(Frame *f, bool moved) { origin = f->r; frect = f->r; - pt = querypointer(&scr.root); + if(!readmotion(&pt)) { + focus(f->client, false); + goto done; + } /* pt1 = grabboxcenter(f); */ pt1 = pt; goto case_motion; @@ -622,6 +627,10 @@ shut_up_ken: case ButtonRelease: if(button != 1) continue; + if(!moved) { + f->collapsed = !f->collapsed; + client_resize(f->client, f->floatr); + } goto done; case ButtonPress: if(button != 3) diff --git a/cmd/wmii/message.c b/cmd/wmii/message.c @@ -550,7 +550,7 @@ message_view(View *v, IxpMsg *m) { if(s == nil) return nil; - /* + /* * area ::= ~ * | <column number> * | sel @@ -578,7 +578,7 @@ message_view(View *v, IxpMsg *m) { * | ~ * | <column> <frame number> * | <column> - * amount ::= + * amount ::= * | <number> * | <number>px * diff --git a/cmd/wmii/mouse.c b/cmd/wmii/mouse.c @@ -77,7 +77,7 @@ static Window* gethsep(Rectangle r) { Window *w; WinAttr wa; - + wa.background_pixel = def.normcolor.border.pixel; w = createwindow(&scr.root, r, scr.depth, InputOutput, &wa, CWBackPixel); mapwin(w); @@ -152,7 +152,7 @@ Align snap_rect(const Rectangle *rects, int num, Rectangle *r, Align *mask, int snap) { Align ret; Point d; - + d.x = snap+1; d.y = snap+1; diff --git a/cmd/wmii/rule.c b/cmd/wmii/rule.c @@ -41,7 +41,7 @@ update_rules(Rule **rule, const char *data) { char *r, *v; const char *p; char c; - + SET(r); SET(v); diff --git a/cmd/wmii/view.c b/cmd/wmii/view.c @@ -86,7 +86,6 @@ view_create(const char *name) { for(i=0; i < nscreens; i++) view_init(v, i); - area_focus(v->firstarea); v->next = *vp; @@ -332,7 +331,7 @@ view_update(View *v) { void view_focus(WMScreen *s, View *v) { - + USED(s); _view_select(v); @@ -360,7 +359,7 @@ view_attach(View *v, Frame *f) { Client *c; Frame *ff; Area *a, *oldsel; - + c = f->client; oldsel = v->oldsel; @@ -450,7 +449,7 @@ view_restack(View *v) { Frame *f; Area *a; int s; - + if(v != selview) return;