some experimental state DO NOT USE THIS, I plan to have a nicer interface to change geometries

new_dwm
Anselm R Garbe 17 years ago
parent e237b2a76f
commit 33b1960220

@ -1,154 +0,0 @@
/* See LICENSE file for copyright and license details. */
/* appearance */
#define BORDERPX 1
#define FONT "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*"
#define NORMBORDERCOLOR "#cccccc"
#define NORMBGCOLOR "#cccccc"
#define NORMFGCOLOR "#000000"
#define SELBORDERCOLOR "#0066ff"
#define SELBGCOLOR "#0066ff"
#define SELFGCOLOR "#ffffff"
/* tagging */
const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
Rule rules[] = {
/* class instance title tags ref isfloating */
{ NULL, NULL, "Firefox", tags[8], False },
{ NULL, NULL, "Gimp", NULL, True },
{ NULL, NULL, "MPlayer", NULL, True },
{ NULL, NULL, "Acroread", NULL, True },
};
/* geometry function */
void (*setgeoms)(void) = setdefgeoms;
void
setanselmgeoms(void) {
/* screen dimensions */
sx = 0;
sy = 0;
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
/* bar position */
bx = sx;
by = sy;
bw = 1280;
bh = dc.font.height + 2;
/* window area */
wx = sx;
wy = sy + bh;
ww = sw;
wh = sh - bh;
/* master area */
mx = wx;
my = wy;
mw = 1280;
mh = 800 - bh;
/* tile area */
tx = 1280;
ty = 0;
tw = sw - 1280;
th = sh;
/* monocle area */
mox = mx;
moy = my;
mow = mw;
moh = mh;
}
void
anselmgeoms(const char *arg) {
setgeoms = setanselmgeoms;
setgeoms();
updatebarpos();
setlayout("[]|");
}
void
defgeoms(const char *arg) {
setgeoms = setdefgeoms;
setgeoms();
updatebarpos();
setlayout("[]=");
}
/* layout(s) */
#define RESIZEHINTS True /* False - respect size hints in tiled resizals */
#define SNAP 32 /* snap pixel */
Layout layouts[] = {
/* symbol function isfloating */
{ "[]|", tileh, False }, /* first entry is default */
{ "[]=", tilev, False },
{ "><>", floating, True },
{ "[M]", monocle, True },
};
/* key definitions */
#define MODKEY Mod1Mask
Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn,
"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"' -x 0 -y 0 -w 1280" },
{ MODKEY|ShiftMask, XK_Return, spawn, "exec uxterm" },
{ MODKEY, XK_a, anselmgeoms, NULL },
{ MODKEY, XK_d, defgeoms, NULL },
{ MODKEY, XK_j, focusnext, NULL },
{ MODKEY, XK_k, focusprev, NULL },
{ MODKEY, XK_r, reapply, NULL },
{ MODKEY, XK_Return, zoom, NULL },
{ MODKEY, XK_Tab, viewprevtag, NULL },
{ MODKEY, XK_m, setlayout, "[M]" },
{ MODKEY, XK_f, setlayout, "><>" },
{ MODKEY, XK_v, setlayout, "[]=" },
{ MODKEY, XK_h, setlayout, "[]|" },
{ MODKEY|ShiftMask, XK_space, togglefloating, NULL },
{ MODKEY|ShiftMask, XK_c, killclient, NULL },
{ MODKEY, XK_0, view, NULL },
{ MODKEY, XK_1, view, tags[0] },
{ MODKEY, XK_2, view, tags[1] },
{ MODKEY, XK_3, view, tags[2] },
{ MODKEY, XK_4, view, tags[3] },
{ MODKEY, XK_5, view, tags[4] },
{ MODKEY, XK_6, view, tags[5] },
{ MODKEY, XK_7, view, tags[6] },
{ MODKEY, XK_8, view, tags[7] },
{ MODKEY, XK_9, view, tags[8] },
{ MODKEY|ControlMask, XK_1, toggleview, tags[0] },
{ MODKEY|ControlMask, XK_2, toggleview, tags[1] },
{ MODKEY|ControlMask, XK_3, toggleview, tags[2] },
{ MODKEY|ControlMask, XK_4, toggleview, tags[3] },
{ MODKEY|ControlMask, XK_5, toggleview, tags[4] },
{ MODKEY|ControlMask, XK_6, toggleview, tags[5] },
{ MODKEY|ControlMask, XK_7, toggleview, tags[6] },
{ MODKEY|ControlMask, XK_8, toggleview, tags[7] },
{ MODKEY|ControlMask, XK_9, toggleview, tags[8] },
{ MODKEY|ShiftMask, XK_0, tag, NULL },
{ MODKEY|ShiftMask, XK_1, tag, tags[0] },
{ MODKEY|ShiftMask, XK_2, tag, tags[1] },
{ MODKEY|ShiftMask, XK_3, tag, tags[2] },
{ MODKEY|ShiftMask, XK_4, tag, tags[3] },
{ MODKEY|ShiftMask, XK_5, tag, tags[4] },
{ MODKEY|ShiftMask, XK_6, tag, tags[5] },
{ MODKEY|ShiftMask, XK_7, tag, tags[6] },
{ MODKEY|ShiftMask, XK_8, tag, tags[7] },
{ MODKEY|ShiftMask, XK_9, tag, tags[8] },
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, tags[0] },
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, tags[1] },
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, tags[2] },
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, tags[3] },
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, tags[4] },
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, tags[5] },
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, tags[6] },
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, tags[7] },
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, tags[8] },
{ MODKEY|ShiftMask, XK_q, quit, NULL },
};

@ -9,6 +9,7 @@
#define SELBORDERCOLOR "#0066ff" #define SELBORDERCOLOR "#0066ff"
#define SELBGCOLOR "#0066ff" #define SELBGCOLOR "#0066ff"
#define SELFGCOLOR "#ffffff" #define SELFGCOLOR "#ffffff"
#define GEOMETRY "0 0 W B 0 B W H-B 0 B W*0.55 H-B W*0.45 B H-B 0 B W H-B"
/* tagging */ /* tagging */
const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
@ -21,9 +22,6 @@ Rule rules[] = {
{ NULL, NULL, "Acroread", NULL, True }, { NULL, NULL, "Acroread", NULL, True },
}; };
/* geometry function */
void (*setgeoms)(void) = setdefgeoms;
/* layout(s) */ /* layout(s) */
#define RESIZEHINTS True /* False - respect size hints in tiled resizals */ #define RESIZEHINTS True /* False - respect size hints in tiled resizals */
#define SNAP 32 /* snap pixel */ #define SNAP 32 /* snap pixel */
@ -40,6 +38,8 @@ Layout layouts[] = {
#define MODKEY Mod1Mask #define MODKEY Mod1Mask
Key keys[] = { Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
{ MODKEY, XK_a, setgeom, "0 0 W B 0 B W H-B 0 B 1280 800-B 1280 0 W-1280 H 0 B 1280 800-B" },
{ MODKEY, XK_d, setgeom, GEOMETRY },
{ MODKEY, XK_p, spawn, { MODKEY, XK_p, spawn,
"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" }, "exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" },
{ MODKEY|ShiftMask, XK_Return, spawn, "exec uxterm" }, { MODKEY|ShiftMask, XK_Return, spawn, "exec uxterm" },

132
dwm.c

@ -136,6 +136,7 @@ void focusnext(const char *arg);
void focusprev(const char *arg); void focusprev(const char *arg);
Client *getclient(Window w); Client *getclient(Window w);
unsigned long getcolor(const char *colstr); unsigned long getcolor(const char *colstr);
double getdouble(const char *s);
long getstate(Window w); long getstate(Window w);
Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
void grabbuttons(Client *c, Bool focused); void grabbuttons(Client *c, Bool focused);
@ -163,7 +164,7 @@ void restack(void);
void run(void); void run(void);
void scan(void); void scan(void);
void setclientstate(Client *c, long state); void setclientstate(Client *c, long state);
void setdefgeoms(void); void setgeom(const char *arg);
void setlayout(const char *arg); void setlayout(const char *arg);
void setup(void); void setup(void);
void spawn(const char *arg); void spawn(const char *arg);
@ -410,7 +411,7 @@ configurenotify(XEvent *e) {
XConfigureEvent *ev = &e->xconfigure; XConfigureEvent *ev = &e->xconfigure;
if(ev->window == root && (ev->width != sw || ev->height != sh)) { if(ev->window == root && (ev->width != sw || ev->height != sh)) {
setgeoms(); setgeom(NULL);
updatebarpos(); updatebarpos();
arrange(); arrange();
} }
@ -1390,44 +1391,95 @@ setclientstate(Client *c, long state) {
PropModeReplace, (unsigned char *)data, 2); PropModeReplace, (unsigned char *)data, 2);
} }
void /**
setdefgeoms(void) { * Idea:
*
/* screen dimensions */ * having a geom syntax as follows, which is interpreted as integer.
sx = 0; *
sy = 0; * [-,+][<0..n>|<W,H,B>]
sw = DisplayWidth(dpy, screen); *
sh = DisplayHeight(dpy, screen); *
* B = bar height, W = DisplayWidth(), H = DisplayHeight()
/* bar position */ *
bx = sx; * -/+/* /: is relative to current
by = sy; *
bw = sw; * Then we would come down with <bx>,<by>,<bw>,<bh>,...
bh = dc.font.height + 2; *
* "0 0 W B 0 0 W W N E B,W,B,
*
*
*/
/* window area */ double
wx = sx; getdouble(const char *s) {
wy = sy + bh; char *endp;
ww = sw; double result = 0;
wh = sh - bh;
/* master area */ fprintf(stderr, "getdouble '%s'\n", s);
mx = wx; switch(*s) {
my = wy; default:
mw = ((float)sw) * 0.55; result = strtod(s, &endp);
mh = wh; if(s == endp || *endp != 0)
result = strtol(s, &endp, 0);
break;
case 'B': result = dc.font.height + 2; break;
case 'W': result = sw; break;
case 'H': result = sh; break;
}
fprintf(stderr, "getdouble returns '%f'\n", result);
return result;
}
/* tile area */ void
tx = mx + mw; setgeom(const char *arg) {
ty = wy; static const char *lastArg = NULL;
tw = ww - mw; char op, *s, *e, *p;
th = wh; double val;
int i, *map[] = { &bx, &by, &bw, &bh,
&wx, &wy, &ww, &wh,
&mx, &my, &mw, &mh,
&tx, &ty, &tw, &th,
&mox, &moy, &mow, &moh };
/* monocle area */ if(!arg)
mox = wx; arg = lastArg;
moy = wy; else
mow = ww; lastArg = arg;
moh = wh; if(!lastArg)
return;
strncpy(buf, arg, sizeof buf);
for(i = 0, e = s = buf; e && *e; e++)
if(*e == ' ') {
*e = 0;
fprintf(stderr, "next geom arg='%s'\n", s);
op = 0;
/* check if there is an operator */
for(p = s; *p && *p != '-' && *p != '+' && *p != '*' && *p != ':'; p++);
if(*p) {
op = *p;
*p = 0;
}
val = getdouble(s);
fprintf(stderr, "val1: %d\n", val);
if(p > s) { /* intermediate operand, e.g. H-B */
*(map[i]) = val;
s = ++p;
val = getdouble(s);
fprintf(stderr, "val2: %d\n", val);
}
switch(op) {
default: *(map[i]) = val; break;
case '-': *(map[i]) -= val; break;
case '+': *(map[i]) += val; break;
case '*': *(map[i]) *= val; break;
case ':': if(val != 0) *(map[i]) /= val; break;
}
fprintf(stderr, "map[i]='%d'\n", val);
s = ++e;
i++;
}
updatebarpos();
arrange();
} }
void void
@ -1464,8 +1516,12 @@ setup(void) {
root = RootWindow(dpy, screen); root = RootWindow(dpy, screen);
initfont(FONT); initfont(FONT);
/* apply default geometries */ /* apply default dimensions */
setgeoms(); sx = 0;
sy = 0;
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
setgeom(GEOMETRY);
/* init atoms */ /* init atoms */
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);

Loading…
Cancel
Save