commit 512e0d43bb1c925441e7f1f68e605c8dea6d5019
parent d82f5b113a20955c5557924b645df45426e75cea
Author: Kris Maglione <jg@suckless.org>
Date: Mon, 2 Jun 2008 11:58:27 -0400
Allow setting of increment display from /ctl. Fix CONFVERSION.
Diffstat:
7 files changed, 55 insertions(+), 52 deletions(-)
diff --git a/cmd/wmii/column.c b/cmd/wmii/column.c
@@ -61,31 +61,13 @@ column_setmode(Area *a, const char *mode) {
}
free(orig);
return true;
-
-#ifdef notdef
- int i;
-
- i = str2colmode(mode);
- if(i == -1)
- return false;
- a->mode = i;
- a->max = false;
- if(i == Colmax) {
- a->mode = Colstack;
- a->max = true;
- }
- return true;
-#endif
}
char*
column_getmode(Area *a) {
- if(a->mode == Coldefault)
- return "default";
- if(a->max)
- return "max";
- return "stack";
+ return sxprint("%s%cmax", a->mode == Colstack ? "stack" : "default",
+ a->max ? '+' : '-');
}
Area*
@@ -408,7 +390,7 @@ column_settle(Area *a) {
f->colr = rectsetorigin(f->colr, Pt(a->r.min.x, yoffcr));
f->r.min.x = a->r.min.x;
f->r.max.x = a->r.max.x;
- if(def.incmode == ISqueeze)
+ if(def.incmode == ISqueeze && !resizing)
if(!f->collapsed) {
f->r.max.y += surplus;
if(n-- > 0)
@@ -535,7 +517,7 @@ column_scale(Area *a) {
frame_resize(f, f->colr);
}
- if(def.incmode == ISqueeze)
+ if(def.incmode == ISqueeze && !resizing)
column_squeeze(a);
column_settle(a);
}
diff --git a/cmd/wmii/dat.h b/cmd/wmii/dat.h
@@ -32,9 +32,9 @@ enum {
};
enum IncMode {
- ISqueeze,
- IShow,
IIgnore,
+ IShow,
+ ISqueeze,
};
enum {
@@ -81,7 +81,7 @@ enum {
CurNormal,
CurNECorner, CurNWCorner, CurSECorner, CurSWCorner,
CurDHArrow, CurDVArrow, CurMove, CurInput, CurSizing,
- CurIcon,
+ CurTCross, CurIcon,
CurNone,
CurLast,
};
diff --git a/cmd/wmii/layout.c b/cmd/wmii/layout.c
@@ -246,7 +246,6 @@ mouse_movegrabbox(Client *c, bool grabmod) {
Frame *f;
Point p;
float x, y;
- int incmode;
f = c->sel;
@@ -256,8 +255,6 @@ mouse_movegrabbox(Client *c, bool grabmod) {
y = (float)p.y / Dy(f->r);
}
- incmode = def.incmode;
- def.incmode = IShow;
resizing = true;
view_update(f->view);
warppointer(grabboxcenter(f));
@@ -267,7 +264,6 @@ mouse_movegrabbox(Client *c, bool grabmod) {
else
trampoline(THCol, f);
- def.incmode = incmode;
resizing = false;
view_update(f->view);
if(grabmod)
diff --git a/cmd/wmii/main.c b/cmd/wmii/main.c
@@ -120,6 +120,7 @@ init_cursors(void) {
create_cursor(CurInput, XC_xterm);
create_cursor(CurSizing, XC_sizing);
create_cursor(CurIcon, XC_icon);
+ create_cursor(CurTCross, XC_tcross);
XAllocNamedColor(display, scr.colormap,
"black", &black, &dummy);
@@ -209,9 +210,15 @@ cleanup_handler(int signal) {
srv.running = false;
switch(signal) {
+ case SIGTERM:
+ sa.sa_handler = cleanup_handler;
+ sigaction(SIGALRM, &sa, nil);
+ alarm(1);
default:
exitsignal = signal;
break;
+ case SIGALRM:
+ raise(SIGTERM);
case SIGINT:
break;
}
@@ -230,7 +237,7 @@ init_traps(void) {
close(ConnectionNumber(display));
setsid();
- display = XOpenDisplay(0);
+ display = XOpenDisplay(nil);
if(!display)
fatal("Can't open display");
@@ -365,9 +372,10 @@ extern int fmtevent(Fmt*);
ixp_listen(&srv, sock, &p9srv, serve_9pcon, nil);
ixp_listen(&srv, ConnectionNumber(display), nil, check_x_event, closedisplay);
- def.font = loadfont(FONT);
def.border = 1;
def.colmode = Coldefault;
+ def.font = loadfont(FONT);
+ def.incmode = ISqueeze;
def.mod = Mod1Mask;
strcpy(def.grabmod, "Mod1");
diff --git a/cmd/wmii/message.c b/cmd/wmii/message.c
@@ -31,6 +31,7 @@ enum {
LFONT,
LGRABMOD,
LGROW,
+ LINCMODE,
LKILL,
LLEFT,
LNORMCOLORS,
@@ -63,6 +64,7 @@ char *symtab[] = {
"font",
"grabmod",
"grow",
+ "incmode",
"kill",
"left",
"normcolors",
@@ -91,8 +93,13 @@ char* debugtab[] = {
};
static char* barpostab[] = {
- [BBottom] = "bottom",
- [BTop] = "top",
+ "bottom",
+ "top",
+};
+static char* incmodetab[] = {
+ "ignore",
+ "show",
+ "squeeze",
};
/* Edit ,y/^[a-zA-Z].*\n.* {\n/d
@@ -134,9 +141,14 @@ getdebug(char *s) {
return _bsearch(s, debugtab, nelem(debugtab));
}
-static int
-getbarpos(char *s) {
- return _bsearch(s, barpostab, nelem(barpostab));
+static bool
+setdef(int *ptr, char *s, char *tab[], int ntab) {
+ int i;
+
+ i = _bsearch(s, tab, ntab);
+ if(i >= 0)
+ *ptr = i;
+ return i >= 0;
}
static int
@@ -417,7 +429,6 @@ message_root(void *p, IxpMsg *m) {
Font *fn;
char *s, *ret;
ulong n;
- int i;
USED(p);
ret = nil;
@@ -430,10 +441,8 @@ message_root(void *p, IxpMsg *m) {
s = msg_getword(m);
if(!strcmp(s, "on"))
s = msg_getword(m);
- i = getbarpos(s);
- if(i < 0)
+ if(!setdef(&screen->barpos, s, barpostab, nelem(barpostab)))
return Ebadvalue;
- screen->barpos = i;
view_update(screen->sel);
break;
case LBORDER:
@@ -473,12 +482,17 @@ message_root(void *p, IxpMsg *m) {
utflcpy(def.grabmod, s, sizeof def.grabmod);
def.mod = n;
break;
+ case LINCMODE:
+ if(!setdef(&def.incmode, msg_getword(m), incmodetab, nelem(incmodetab)))
+ return Ebadvalue;
+ view_update(screen->sel);
+ break;
case LNORMCOLORS:
ret = msg_parsecolors(m, &def.normcolor);
view_update(screen->sel);
break;
case LSELCOLORS:
- fprint(2, "%s: warning: selcolors have been removed\n", argv0);
+ warning("selcolors have been removed");
return Ebadcmd;
case LVIEW:
view_select(m->pos);
@@ -1033,13 +1047,8 @@ printdebug(int mask) {
char*
readctl_root(void) {
bufclear();
- bufprint("view %s\n", screen->sel->name);
- bufprint("focuscolors %s\n", def.focuscolor.colstr);
- bufprint("normcolors %s\n", def.normcolor.colstr);
- bufprint("font %s\n", def.font->name);
- bufprint("grabmod %s\n", def.grabmod);
- bufprint("border %d\n", def.border);
bufprint("bar on %s\n", barpostab[screen->barpos]);
+ bufprint("border %d\n", def.border);
if(debugflag) {
bufprint("debug ");
printdebug(debugflag);
@@ -1050,6 +1059,12 @@ readctl_root(void) {
printdebug(debugfile);
bufprint("\n");
}
+ bufprint("focuscolors %s\n", def.focuscolor.colstr);
+ bufprint("font %s\n", def.font->name);
+ bufprint("grabmod %s\n", def.grabmod);
+ bufprint("incmode %s\n", incmodetab[screen->barpos]);
+ bufprint("normcolors %s\n", def.normcolor.colstr);
+ bufprint("view %s\n", screen->sel->name);
return buffer;
}
diff --git a/cmd/wmii/mouse.c b/cmd/wmii/mouse.c
@@ -128,9 +128,10 @@ snap_vline(Rectangle *rects, int nrect, int dxy, Rectangle *r, int x) {
#undef frob
-/* Returns a gravity for increment handling. It's normally the opposite of the mask
- * (the directions that we're resizing in), unless a snap occurs, in which case, it's the
- * direction of the snap.
+/* Returns a gravity for increment handling. It's normally the
+ * opposite of the mask (the directions that we're resizing in),
+ * unless a snap occurs, in which case, it's the direction of the
+ * snap.
*/
Align
snap_rect(Rectangle *rects, int num, Rectangle *r, Align *mask, int snap) {
@@ -588,7 +589,7 @@ mouse_checkresize(Frame *f, Point p, bool exec) {
r = rectsubpt(f->r, f->r.min);
q = quadrant(r, p);
if(rect_haspoint_p(p, f->grabbox)) {
- cur = cursor[CurMove];
+ cur = cursor[CurTCross];
if(exec) mouse_movegrabbox(f->client, false);
}
else if(f->area->floating) {
diff --git a/mk/wmii.mk b/mk/wmii.mk
@@ -3,4 +3,5 @@ VERS = hg$$(hg log -r $$(hg id | awk -F'[+ ]' '{print $$1}') --template '{rev}')
VERSION = $(VERS)
VERSION := $(shell echo $(VERS) 2>/dev/null)
VERSION != echo $(VERS) 2>/dev/null
-CONFVERSION = 3.5
+CONFVERSION = hg
+