wmii

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

commit 8a01b0b63e4823a4185a321eb45044841e4902f9
parent dbdddb4036015c687348d49b5aa077961cac5194
Author: Kris Maglione <jg@suckless.org>
Date:   Sun,  1 Jun 2008 11:28:37 -0400

Allow max mode with or without stack mode (this will change). Fix a crash with minimum-sized clients in columns.

Diffstat:
cmd/wmii.rc.rc | 7++++---
cmd/wmii/client.c | 2+-
cmd/wmii/column.c | 67++++++++++++++++++++++++++++++++++++++++++++++++++++---------------
cmd/wmii/dat.h | 1+
cmd/wmii/event.c | 120+++++++++++++++++++++++++++++--------------------------------------------------
cmd/wmii/frame.c | 17+++++++----------
cmd/wmii/layout.c | 2++
cmd/wmii/message.c | 4+++-
cmd/wmii/mouse.c | 2++
cmd/wmii/view.c | 4----
rc/rc.wmii.rc | 6+++---
rc/wmiirc.sh | 6+++---
12 files changed, 122 insertions(+), 116 deletions(-)

diff --git a/cmd/wmii.rc.rc b/cmd/wmii.rc.rc @@ -70,9 +70,10 @@ fn wi_fn-p { } fn wi_proglist { - /bin/ls -lL `{echo $* | sed 'y/:/ /'} >[2]/dev/null \ - | awk '$1 ~ /^[^d].*x/ { print $NF }' \ - | sort | uniq + # XXX: maxdepth is not POSIX compliant. + ifs=: { find -L `{echo $*} -type f -a -maxdepth 1 \ + '(' -perm -0100 -o -perm -0010 -o -perm -0001 ')' >[2]/dev/null \ + | sed 's,.*/,,' | sort | uniq} } fn wi_actions { diff --git a/cmd/wmii/client.c b/cmd/wmii/client.c @@ -519,7 +519,7 @@ client_resize(Client *c, Rectangle r) { c->r = rectaddpt(f->crect, f->r.min); if(f->collapsed) { - if(f->area->max) + if(f->area->max && !resizing) unmap_frame(c); else { reshapewin(c->framewin, f->r); diff --git a/cmd/wmii/column.c b/cmd/wmii/column.c @@ -13,18 +13,56 @@ char *modes[] = { [Colmax] = "max", }; -static int -str2colmode(const char *str) { - int i; - - for(i = 0; i < nelem(modes); i++) - if(!strcasecmp(str, modes[i])) - return i; - return -1; -} - bool column_setmode(Area *a, const char *mode) { + char *s, *t, *orig; + char add, old; + + orig = strdup(mode); + t = orig; + old = '\0'; + for(s=t; *s; s=t) { + add = old; + while((old=*s) && !strchr("+-^", old)) + s++; + *s = '\0'; + if(s > t) { + if(!strcmp(t, "max")) { + if(add == '\0' || add == '+') + a->max = true; + else if(add == '-') + a->max = false; + else + a->max = !a->max; + }else + if(!strcmp(t, "stack")) { + if(add == '\0' || add == '+') + a->mode = Colstack; + else if(add == '-') + a->mode = Coldefault; + else + a->mode = a->mode == Colstack ? Coldefault : Colstack; + }else + if(!strcmp(t, "default")) { + if(add == '\0' || add == '+') { + a->mode = Coldefault; + column_arrange(a, true); + }else if(add == '-') + a->mode = Colstack; + else + a->mode = a->mode == Coldefault ? Colstack : Coldefault; + }else + return false; + } + t = s; + if(old) + t++; + + } + free(orig); + return true; + +#ifdef notdef int i; i = str2colmode(mode); @@ -37,6 +75,7 @@ column_setmode(Area *a, const char *mode) { a->max = true; } return true; +#endif } char* @@ -261,7 +300,7 @@ column_fit(Area *a, uint *ncolp, uint *nuncolp) { minh = labelh(def.font); colh = labelh(def.font); uncolh = minh + colh + 1; - if(a->max) + if(a->max && !resizing) colh = 0; /* Count collapsed and uncollapsed frames. */ @@ -421,15 +460,13 @@ comp_frame(const void *a, const void *b) { static void column_squeeze(Area *a) { static Vector_ptr fvec; - WinHints h; Frame *f; int surplus, osurplus, dy, i; fvec.n = 0; for(f=a->frame; f; f=f->anext) if(!f->collapsed) { - h = frame_gethints(f); - f->r = sizehint(&h, f->r); + f->r = frame_hints(f, f->r, 0); vector_ppush(&fvec, f); } @@ -474,7 +511,7 @@ column_scale(Area *a) { column_fit(a, &ncol, &nuncol); colh = labelh(def.font); - if(a->max) + if(a->max && !resizing) colh = 0; dy = 0; diff --git a/cmd/wmii/dat.h b/cmd/wmii/dat.h @@ -364,6 +364,7 @@ EXTERN XHandler handler[LASTEvent]; /* Misc */ EXTERN bool starting; +EXTERN bool resizing; EXTERN bool ignoreenter; EXTERN char* user; EXTERN char* execstr; diff --git a/cmd/wmii/event.c b/cmd/wmii/event.c @@ -5,6 +5,8 @@ #include <X11/keysym.h> #include "fns.h" +typedef void (*EvHandler)(XEvent*); + void dispatch_event(XEvent *e) { Dprint(DEvent, "%E\n", e); @@ -94,21 +96,17 @@ flushenterevents(void) { } static void -buttonrelease(XEvent *e) { - XButtonPressedEvent *ev; +buttonrelease(XButtonPressedEvent *ev) { Window *w; - ev = &e->xbutton; if((w = findwin(ev->window))) handle(w, bup, ev); } static void -buttonpress(XEvent *e) { - XButtonPressedEvent *ev; +buttonpress(XButtonPressedEvent *ev) { Window *w; - ev = &e->xbutton; if((w = findwin(ev->window))) handle(w, bdown, ev); else @@ -116,12 +114,10 @@ buttonpress(XEvent *e) { } static void -configurerequest(XEvent *e) { - XConfigureRequestEvent *ev; +configurerequest(XConfigureRequestEvent *ev) { XWindowChanges wc; Window *w; - ev = &e->xconfigurerequest; if((w = findwin(ev->window))) handle(w, configreq, ev); else{ @@ -137,20 +133,16 @@ configurerequest(XEvent *e) { } static void -configurenotify(XEvent *e) { - XConfigureEvent *ev; +configurenotify(XConfigureEvent *ev) { Window *w; - ev = &e->xconfigure; if((w = findwin(ev->window))) handle(w, config, ev); } static void -clientmessage(XEvent *e) { - XClientMessageEvent *ev; +clientmessage(XClientMessageEvent *ev) { - ev = &e->xclient; if(ewmh_clientmessage(ev)) return; if(xdnd_clientmessage(ev)) @@ -158,12 +150,10 @@ clientmessage(XEvent *e) { } static void -destroynotify(XEvent *e) { - XDestroyWindowEvent *ev; +destroynotify(XDestroyWindowEvent *ev) { Window *w; Client *c; - ev = &e->xdestroywindow; if((w = findwin(ev->window))) handle(w, destroy, ev); else { @@ -174,11 +164,9 @@ destroynotify(XEvent *e) { } static void -enternotify(XEvent *e) { - XCrossingEvent *ev; +enternotify(XCrossingEvent *ev) { Window *w; - ev = &e->xcrossing; xtime = ev->time; if(ev->mode != NotifyNormal) return; @@ -192,10 +180,8 @@ enternotify(XEvent *e) { } static void -leavenotify(XEvent *e) { - XCrossingEvent *ev; +leavenotify(XCrossingEvent *ev) { - ev = &e->xcrossing; xtime = ev->time; if((ev->window == scr.root.w) && !ev->same_screen) { sel_screen = true; @@ -211,12 +197,10 @@ print_focus(const char *fn, Client *c, const char *to) { } static void -focusin(XEvent *e) { - XFocusChangeEvent *ev; +focusin(XFocusChangeEvent *ev) { Window *w; Client *c; - ev = &e->xfocus; /* Yes, we're focusing in on nothing, here. */ if(ev->detail == NotifyDetailNone) { print_focus("focusin", &c_magic, "<magic[none]>"); @@ -254,12 +238,10 @@ focusin(XEvent *e) { } static void -focusout(XEvent *e) { +focusout(XFocusChangeEvent *ev) { XEvent me; - XFocusChangeEvent *ev; Window *w; - ev = &e->xfocus; if(!((ev->detail == NotifyNonlinear) ||(ev->detail == NotifyNonlinearVirtual) ||(ev->detail == NotifyVirtual) @@ -277,22 +259,17 @@ focusout(XEvent *e) { } static void -expose(XEvent *e) { - XExposeEvent *ev; +expose(XExposeEvent *ev) { Window *w; - ev = &e->xexpose; - if(ev->count == 0) { + if(ev->count == 0) if((w = findwin(ev->window))) handle(w, expose, ev); - } } static void -keypress(XEvent *e) { - XKeyEvent *ev; +keypress(XKeyEvent *ev) { - ev = &e->xkey; xtime = ev->time; ev->state &= valid_mask; if(ev->window == scr.root.w) @@ -300,27 +277,25 @@ keypress(XEvent *e) { } static void -mappingnotify(XEvent *e) { - XMappingEvent *ev; +mappingnotify(XMappingEvent *ev) { - ev = &e->xmapping; XRefreshKeyboardMapping(ev); if(ev->request == MappingKeyboard) update_keys(); } static void -maprequest(XEvent *e) { - XMapRequestEvent *ev; +maprequest(XMapRequestEvent *ev) { XWindowAttributes wa; - ev = &e->xmaprequest; if(!XGetWindowAttributes(display, ev->window, &wa)) return; if(wa.override_redirect) { /* Do I really want these? */ + /* Probably not. XSelectInput(display, ev->window, - (StructureNotifyMask | PropertyChangeMask)); + PropertyChangeMask | StructureNotifyMask); + */ return; } if(!win2client(ev->window)) @@ -328,45 +303,37 @@ maprequest(XEvent *e) { } static void -motionnotify(XEvent *e) { - XMotionEvent *ev; +motionnotify(XMotionEvent *ev) { Window *w; ignoreenter = false; - ev = &e->xmotion; xtime = ev->time; if((w = findwin(ev->window))) handle(w, motion, ev); } static void -propertynotify(XEvent *e) { - XPropertyEvent *ev; +propertynotify(XPropertyEvent *ev) { Window *w; - ev = &e->xproperty; xtime = ev->time; if((w = findwin(ev->window))) handle(w, property, ev); } static void -mapnotify(XEvent *e) { - XMapEvent *ev; +mapnotify(XMapEvent *ev) { Window *w; - ev = &e->xmap; if((w = findwin(ev->window))) handle(w, map, ev); } static void -unmapnotify(XEvent *e) { - XUnmapEvent *ev; +unmapnotify(XUnmapEvent *ev) { Window *w; - ev = &e->xunmap; if((w = findwin(ev->window)) && (ev->event == w->parent->w)) { w->mapped = false; if(ev->send_event || w->unmapped-- == 0) @@ -374,25 +341,25 @@ unmapnotify(XEvent *e) { } } -void (*handler[LASTEvent]) (XEvent *) = { - [ButtonPress] = buttonpress, - [ButtonRelease] = buttonrelease, - [ConfigureRequest] = configurerequest, - [ConfigureNotify] = configurenotify, - [ClientMessage] = clientmessage, - [DestroyNotify] = destroynotify, - [EnterNotify] = enternotify, - [Expose] = expose, - [FocusIn] = focusin, - [FocusOut] = focusout, - [KeyPress] = keypress, - [LeaveNotify] = leavenotify, - [MapNotify] = mapnotify, - [MapRequest] = maprequest, - [MappingNotify] = mappingnotify, - [MotionNotify] = motionnotify, - [PropertyNotify] = propertynotify, - [UnmapNotify] = unmapnotify, +EvHandler handler[LASTEvent] = { + [ButtonPress] = (EvHandler)buttonpress, + [ButtonRelease] = (EvHandler)buttonrelease, + [ConfigureRequest] = (EvHandler)configurerequest, + [ConfigureNotify] = (EvHandler)configurenotify, + [ClientMessage] = (EvHandler)clientmessage, + [DestroyNotify] = (EvHandler)destroynotify, + [EnterNotify] = (EvHandler)enternotify, + [Expose] = (EvHandler)expose, + [FocusIn] = (EvHandler)focusin, + [FocusOut] = (EvHandler)focusout, + [KeyPress] = (EvHandler)keypress, + [LeaveNotify] = (EvHandler)leavenotify, + [MapNotify] = (EvHandler)mapnotify, + [MapRequest] = (EvHandler)maprequest, + [MappingNotify] = (EvHandler)mappingnotify, + [MotionNotify] = (EvHandler)motionnotify, + [PropertyNotify] = (EvHandler)propertynotify, + [UnmapNotify] = (EvHandler)unmapnotify, }; void @@ -406,3 +373,4 @@ check_x_event(IxpConn *c) { dispatch_event(&ev); } } + diff --git a/cmd/wmii/frame.c b/cmd/wmii/frame.c @@ -255,6 +255,7 @@ WinHints frame_gethints(Frame *f) { WinHints h; Client *c; + Rectangle r; Point d; int minh; @@ -263,14 +264,9 @@ frame_gethints(Frame *f) { c = f->client; h = *c->w.hints; - d.y = labelh(def.font); - if(f->area->floating) { - d.x = 2*def.border; - d.y += def.border; - }else { - d.x = 2; - d.y += 2; - } + r = frame_rect2client(c, f->r, f->area->floating); + d.x = Dx(f->r) - Dx(r); + d.y = Dy(f->r) - Dy(r); if(!f->area->floating && def.incmode == IIgnore) h.inc = Pt(1, 1); @@ -282,6 +278,7 @@ frame_gethints(Frame *f) { h.min.x += d.x; h.min.y += d.y; + /* Guard against overflow. */ if(h.max.x + d.x > h.max.x) h.max.x += d.x; if(h.max.y + d.y > h.max.y) @@ -354,7 +351,7 @@ frame_resize(Frame *f, Rectangle r) { int collapsed, dx; if(btassert("8 full", Dx(r) <= 0 || Dy(r) < 0 - || Dy(r) == 0 && !f->area->max && !f->collapsed)) { + || Dy(r) == 0 && (!f->area->max || resizing) && !f->collapsed)) { fprint(2, "Frame rect: %R\n", r); r.max.x = min(r.min.x+1, r.max.x); r.max.y = min(r.min.y+1, r.max.y); @@ -495,7 +492,7 @@ frame_draw(Frame *f) { r.min.y = 0; r.max.y = labelh(def.font); /* Draw count on frames in 'max' columns. */ - if(f->area->max) { + if(f->area->max && !resizing) { /* XXX */ n = stack_count(f, &m); s = smprint("%d/%d", m, n); diff --git a/cmd/wmii/layout.c b/cmd/wmii/layout.c @@ -258,6 +258,7 @@ mouse_movegrabbox(Client *c, bool grabmod) { incmode = def.incmode; def.incmode = IShow; + resizing = true; view_update(f->view); warppointer(grabboxcenter(f)); @@ -267,6 +268,7 @@ mouse_movegrabbox(Client *c, bool grabmod) { trampoline(THCol, f); def.incmode = incmode; + resizing = false; view_update(f->view); if(grabmod) warppointer(addpt(f->r.min, Pt(x * Dx(f->r), diff --git a/cmd/wmii/message.c b/cmd/wmii/message.c @@ -553,7 +553,7 @@ message_view(View *v, IxpMsg *m) { if(s == nil || !column_setmode(a, s)) return Ebadvalue; - column_arrange(a, true); + column_arrange(a, false); view_restack(v); view_update(v); @@ -889,6 +889,8 @@ msg_selectframe(Frame *f, IxpMsg *m, int sym) { fp->colr.max.y = fp->colr.min.y + dy; column_arrange(a, false); } + if(!f->area->floating) + frame_draw_all(); frame_focus(fp); frame_restack(fp, nil); diff --git a/cmd/wmii/mouse.c b/cmd/wmii/mouse.c @@ -536,6 +536,7 @@ mouse_tempvertresize(Area *a, Point p) { incmode = def.incmode; def.incmode = IIgnore; + resizing = true; column_arrange(a, false); r.min.x = p.x; @@ -568,6 +569,7 @@ done: ungrabpointer(); destroyconstraintwin(cwin); def.incmode = incmode; + resizing = false; column_arrange(a, false); } diff --git a/cmd/wmii/view.c b/cmd/wmii/view.c @@ -275,12 +275,8 @@ view_focus(WMScreen *s, View *v) { USED(s); - XGrabServer(display); - _view_select(v); view_update(v); - - XUngrabServer(display); } void diff --git a/rc/rc.wmii.rc b/rc/rc.wmii.rc @@ -205,11 +205,11 @@ key $MODKEY-space || fn $key { key $MODKEY-Shift-space || fn $key { wmiir xwrite /tag/sel/ctl send sel toggle} key $MODKEY-d || fn $key { - wmiir xwrite /tag/sel/ctl colmode sel default} + wmiir xwrite /tag/sel/ctl colmode sel default-max} key $MODKEY-s || fn $key { - wmiir xwrite /tag/sel/ctl colmode sel stack} + wmiir xwrite /tag/sel/ctl colmode sel stack-max} key $MODKEY-m || fn $key { - wmiir xwrite /tag/sel/ctl colmode sel max} + wmiir xwrite /tag/sel/ctl colmode sel stack+max} key $MODKEY-Shift-c || fn $key { wmiir xwrite /client/sel/ctl kill} diff --git a/rc/wmiirc.sh b/rc/wmiirc.sh @@ -151,11 +151,11 @@ events() { Key $MODKEY-space wmiir xwrite /tag/sel/ctl select toggle Key $MODKEY-d - wmiir xwrite /tag/sel/ctl colmode sel default + wmiir xwrite /tag/sel/ctl colmode sel default-max Key $MODKEY-s - wmiir xwrite /tag/sel/ctl colmode sel stack + wmiir xwrite /tag/sel/ctl colmode sel stack-max Key $MODKEY-m - wmiir xwrite /tag/sel/ctl colmode sel max + wmiir xwrite /tag/sel/ctl colmode sel stack+max Key $MODKEY-a Action $(wi_actions | wi_menu) & Key $MODKEY-p