[hackers] [wmii] Allow max mode with or without stack mode (this will change). Fix a crash with minimum-sized clients in columns. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Sat, 30 Aug 2008 21:49:25 +0000 (UTC)

changeset: 2339:34287266d90d
user: Kris Maglione <jg_AT_suckless.org>
date: Sun Jun 01 11:28:37 2008 -0400
files: cmd/wmii.rc.rc cmd/wmii/client.c cmd/wmii/column.c cmd/wmii/dat.h cmd/wmii/event.c cmd/wmii/frame.c cmd/wmii/layout.c cmd/wmii/message.c cmd/wmii/mouse.c cmd/wmii/view.c rc/rc.wmii.rc rc/wmiirc.sh
description:
Allow max mode with or without stack mode (this will change). Fix a crash with minimum-sized clients in columns.

diff -r 1c4e86948dcf -r 34287266d90d cmd/wmii.rc.rc
--- a/cmd/wmii.rc.rc Sat May 31 18:42:13 2008 -0400
+++ b/cmd/wmii.rc.rc Sun Jun 01 11:28:37 2008 -0400
@@ -70,9 +70,10 @@
 }
 
 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 -r 1c4e86948dcf -r 34287266d90d cmd/wmii/client.c
--- a/cmd/wmii/client.c Sat May 31 18:42:13 2008 -0400
+++ b/cmd/wmii/client.c Sun Jun 01 11:28:37 2008 -0400
@@ -519,7 +519,7 @@
         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 -r 1c4e86948dcf -r 34287266d90d cmd/wmii/column.c
--- a/cmd/wmii/column.c Sat May 31 18:42:13 2008 -0400
+++ b/cmd/wmii/column.c Sun Jun 01 11:28:37 2008 -0400
@@ -13,18 +13,56 @@
         [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 @@
                 a->max = true;
         }
         return true;
+#endif
 }
 
 char*
@@ -261,7 +300,7 @@
         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 @@
 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_fit(a, &ncol, &nuncol);
 
         colh = labelh(def.font);
- if(a->max)
+ if(a->max && !resizing)
                 colh = 0;
 
         dy = 0;
diff -r 1c4e86948dcf -r 34287266d90d cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Sat May 31 18:42:13 2008 -0400
+++ b/cmd/wmii/dat.h Sun Jun 01 11:28:37 2008 -0400
@@ -364,6 +364,7 @@
 
 /* Misc */
 EXTERN bool starting;
+EXTERN bool resizing;
 EXTERN bool ignoreenter;
 EXTERN char* user;
 EXTERN char* execstr;
diff -r 1c4e86948dcf -r 34287266d90d cmd/wmii/event.c
--- a/cmd/wmii/event.c Sat May 31 18:42:13 2008 -0400
+++ b/cmd/wmii/event.c Sun Jun 01 11:28:37 2008 -0400
@@ -4,6 +4,8 @@
 #include "dat.h"
 #include <X11/keysym.h>
 #include "fns.h"
+
+typedef void (*EvHandler)(XEvent*);
 
 void
 dispatch_event(XEvent *e) {
@@ -94,21 +96,17 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
         }
 }
 
-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 @@
                 dispatch_event(&ev);
         }
 }
+
diff -r 1c4e86948dcf -r 34287266d90d cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Sat May 31 18:42:13 2008 -0400
+++ b/cmd/wmii/frame.c Sun Jun 01 11:28:37 2008 -0400
@@ -255,6 +255,7 @@
 frame_gethints(Frame *f) {
         WinHints h;
         Client *c;
+ Rectangle r;
         Point d;
         int minh;
 
@@ -263,14 +264,9 @@
         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 @@
 
         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 @@
         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 @@
         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 -r 1c4e86948dcf -r 34287266d90d cmd/wmii/layout.c
--- a/cmd/wmii/layout.c Sat May 31 18:42:13 2008 -0400
+++ b/cmd/wmii/layout.c Sun Jun 01 11:28:37 2008 -0400
@@ -258,6 +258,7 @@
 
         incmode = def.incmode;
         def.incmode = IShow;
+ resizing = true;
         view_update(f->view);
         warppointer(grabboxcenter(f));
 
@@ -267,6 +268,7 @@
                 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 -r 1c4e86948dcf -r 34287266d90d cmd/wmii/message.c
--- a/cmd/wmii/message.c Sat May 31 18:42:13 2008 -0400
+++ b/cmd/wmii/message.c Sun Jun 01 11:28:37 2008 -0400
@@ -553,7 +553,7 @@
                 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 @@
                 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 -r 1c4e86948dcf -r 34287266d90d cmd/wmii/mouse.c
--- a/cmd/wmii/mouse.c Sat May 31 18:42:13 2008 -0400
+++ b/cmd/wmii/mouse.c Sun Jun 01 11:28:37 2008 -0400
@@ -536,6 +536,7 @@
 
         incmode = def.incmode;
         def.incmode = IIgnore;
+ resizing = true;
         column_arrange(a, false);
 
         r.min.x = p.x;
@@ -568,6 +569,7 @@
         ungrabpointer();
         destroyconstraintwin(cwin);
         def.incmode = incmode;
+ resizing = false;
         column_arrange(a, false);
 }
 
diff -r 1c4e86948dcf -r 34287266d90d cmd/wmii/view.c
--- a/cmd/wmii/view.c Sat May 31 18:42:13 2008 -0400
+++ b/cmd/wmii/view.c Sun Jun 01 11:28:37 2008 -0400
@@ -275,12 +275,8 @@
         
         USED(s);
 
- XGrabServer(display);
-
         _view_select(v);
         view_update(v);
-
- XUngrabServer(display);
 }
 
 void
diff -r 1c4e86948dcf -r 34287266d90d rc/rc.wmii.rc
--- a/rc/rc.wmii.rc Sat May 31 18:42:13 2008 -0400
+++ b/rc/rc.wmii.rc Sun Jun 01 11:28:37 2008 -0400
@@ -205,11 +205,11 @@
 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 -r 1c4e86948dcf -r 34287266d90d rc/wmiirc.sh
--- a/rc/wmiirc.sh Sat May 31 18:42:13 2008 -0400
+++ b/rc/wmiirc.sh Sun Jun 01 11:28:37 2008 -0400
@@ -151,11 +151,11 @@
         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
Received on Sat Aug 30 2008 - 21:49:25 UTC

This archive was generated by hypermail 2.2.0 : Sat Aug 30 2008 - 22:00:06 UTC