Introduction
Introduction Statistics Contact Development Disclaimer Help
tsome experimental state DO NOT USE THIS, I plan to have a nicer interface to c…
git clone git://src.adamsgaard.dk/dwm
Log
Files
Refs
README
LICENSE
---
commit 33b1960220f468ff2888e8ba3517e9a62ed99974
parent e237b2a76fb3dac1f43b91e5c7b6adb9ef04c9ed
Author: Anselm R Garbe <[email protected]>
Date: Fri, 14 Mar 2008 17:17:08 +0000
some experimental state DO NOT USE THIS, I plan to have a nicer interface to ch…
Diffstat:
D config.anselm.h | 154 -----------------------------…
M config.def.h | 6 +++---
M dwm.c | 134 ++++++++++++++++++++++-------…
3 files changed, 98 insertions(+), 196 deletions(-)
---
diff --git a/config.anselm.h b/config.anselm.h
t@@ -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 i…
- { NULL, NULL, "Firefox", tags[8],…
- { NULL, NULL, "Gimp", NUL…
- { NULL, NULL, "MPlayer", NULL, …
- { NULL, NULL, "Acroread", NULL, …
-};
-
-/* 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 i…
-#define SNAP 32 /* snap pixel */
-
-Layout layouts[] = {
- /* symbol function isfloating */
- { "[]|", tileh, False }, /* first entry …
- { "[]=", tilev, False },
- { "><>", floating, True },
- { "[M]", monocle, True },
-};
-
-/* key definitions */
-#define MODKEY Mod1Mask
-Key keys[] = {
- /* modifier key function …
- { MODKEY, XK_p, spawn,
- "exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGC…
- { MODKEY|ShiftMask, XK_Return, spawn, "exec uxte…
- { MODKEY, XK_a, anselmgeoms, …
- { MODKEY, XK_d, defgeoms, …
- { MODKEY, XK_j, focusnext, …
- { MODKEY, XK_k, focusprev, …
- { MODKEY, XK_r, reapply, …
- { MODKEY, XK_Return, zoom, …
- { MODKEY, XK_Tab, viewprevtag, …
- { MODKEY, XK_m, setlayout, …
- { MODKEY, XK_f, setlayout, …
- { MODKEY, XK_v, setlayout, …
- { MODKEY, XK_h, setlayout, …
- { MODKEY|ShiftMask, XK_space, togglefloating, …
- { MODKEY|ShiftMask, XK_c, killclient, …
- { MODKEY, XK_0, view, …
- { MODKEY, XK_1, view, …
- { MODKEY, XK_2, view, …
- { MODKEY, XK_3, view, …
- { MODKEY, XK_4, view, …
- { MODKEY, XK_5, view, …
- { MODKEY, XK_6, view, …
- { MODKEY, XK_7, view, …
- { MODKEY, XK_8, view, …
- { MODKEY, XK_9, view, …
- { MODKEY|ControlMask, XK_1, toggleview, …
- { MODKEY|ControlMask, XK_2, toggleview, …
- { MODKEY|ControlMask, XK_3, toggleview, …
- { MODKEY|ControlMask, XK_4, toggleview, …
- { MODKEY|ControlMask, XK_5, toggleview, …
- { MODKEY|ControlMask, XK_6, toggleview, …
- { MODKEY|ControlMask, XK_7, toggleview, …
- { MODKEY|ControlMask, XK_8, toggleview, …
- { MODKEY|ControlMask, XK_9, toggleview, …
- { MODKEY|ShiftMask, XK_0, tag, …
- { MODKEY|ShiftMask, XK_1, tag, …
- { MODKEY|ShiftMask, XK_2, tag, …
- { MODKEY|ShiftMask, XK_3, tag, …
- { MODKEY|ShiftMask, XK_4, tag, …
- { MODKEY|ShiftMask, XK_5, tag, …
- { MODKEY|ShiftMask, XK_6, tag, …
- { MODKEY|ShiftMask, XK_7, tag, …
- { MODKEY|ShiftMask, XK_8, tag, …
- { MODKEY|ShiftMask, XK_9, tag, …
- { MODKEY|ControlMask|ShiftMask, XK_1, toggletag,…
- { MODKEY|ControlMask|ShiftMask, XK_2, toggletag,…
- { MODKEY|ControlMask|ShiftMask, XK_3, toggletag,…
- { MODKEY|ControlMask|ShiftMask, XK_4, toggletag,…
- { MODKEY|ControlMask|ShiftMask, XK_5, toggletag,…
- { MODKEY|ControlMask|ShiftMask, XK_6, toggletag,…
- { MODKEY|ControlMask|ShiftMask, XK_7, toggletag,…
- { MODKEY|ControlMask|ShiftMask, XK_8, toggletag,…
- { MODKEY|ControlMask|ShiftMask, XK_9, toggletag,…
- { MODKEY|ShiftMask, XK_q, quit, …
-};
diff --git a/config.def.h b/config.def.h
t@@ -9,6 +9,7 @@
#define SELBORDERCOLOR "#0066ff"
#define SELBGCOLOR "#0066ff"
#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…
/* tagging */
const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
t@@ -21,9 +22,6 @@ Rule rules[] = {
{ NULL, NULL, "Acroread", NULL, …
};
-/* geometry function */
-void (*setgeoms)(void) = setdefgeoms;
-
/* layout(s) */
#define RESIZEHINTS True /* False - respect size hints i…
#define SNAP 32 /* snap pixel */
t@@ -40,6 +38,8 @@ Layout layouts[] = {
#define MODKEY Mod1Mask
Key keys[] = {
/* modifier key function …
+ { MODKEY, XK_a, setgeom, …
+ { MODKEY, XK_d, setgeom, …
{ MODKEY, XK_p, spawn,
"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGC…
{ MODKEY|ShiftMask, XK_Return, spawn, "exec uxte…
diff --git a/dwm.c b/dwm.c
t@@ -136,6 +136,7 @@ void focusnext(const char *arg);
void focusprev(const char *arg);
Client *getclient(Window w);
unsigned long getcolor(const char *colstr);
+double getdouble(const char *s);
long getstate(Window w);
Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
void grabbuttons(Client *c, Bool focused);
t@@ -163,7 +164,7 @@ void restack(void);
void run(void);
void scan(void);
void setclientstate(Client *c, long state);
-void setdefgeoms(void);
+void setgeom(const char *arg);
void setlayout(const char *arg);
void setup(void);
void spawn(const char *arg);
t@@ -410,7 +411,7 @@ configurenotify(XEvent *e) {
XConfigureEvent *ev = &e->xconfigure;
if(ev->window == root && (ev->width != sw || ev->height != sh)) {
- setgeoms();
+ setgeom(NULL);
updatebarpos();
arrange();
}
t@@ -1390,44 +1391,95 @@ setclientstate(Client *c, long state) {
PropModeReplace, (unsigned char *)data, 2);
}
-void
-setdefgeoms(void) {
-
- /* screen dimensions */
- sx = 0;
- sy = 0;
- sw = DisplayWidth(dpy, screen);
- sh = DisplayHeight(dpy, screen);
-
- /* bar position */
- bx = sx;
- by = sy;
- bw = sw;
- bh = dc.font.height + 2;
-
- /* window area */
- wx = sx;
- wy = sy + bh;
- ww = sw;
- wh = sh - bh;
+/**
+ * Idea:
+ *
+ * having a geom syntax as follows, which is interpreted as integer.
+ *
+ * [-,+][<0..n>|<W,H,B>]
+ *
+ *
+ * B = bar height, W = DisplayWidth(), H = DisplayHeight()
+ *
+ * -/+/* /: is relative to current
+ *
+ * Then we would come down with <bx>,<by>,<bw>,<bh>,...
+ *
+ * "0 0 W B 0 0 W W N E B,W,B,
+ *
+ *
+ */
- /* master area */
- mx = wx;
- my = wy;
- mw = ((float)sw) * 0.55;
- mh = wh;
+double
+getdouble(const char *s) {
+ char *endp;
+ double result = 0;
+
+ fprintf(stderr, "getdouble '%s'\n", s);
+ switch(*s) {
+ default:
+ result = strtod(s, &endp);
+ 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 */
- tx = mx + mw;
- ty = wy;
- tw = ww - mw;
- th = wh;
+void
+setgeom(const char *arg) {
+ static const char *lastArg = NULL;
+ char op, *s, *e, *p;
+ 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 */
- mox = wx;
- moy = wy;
- mow = ww;
- moh = wh;
+ if(!arg)
+ arg = lastArg;
+ else
+ lastArg = arg;
+ 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 != '*' &…
+ 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
t@@ -1464,8 +1516,12 @@ setup(void) {
root = RootWindow(dpy, screen);
initfont(FONT);
- /* apply default geometries */
- setgeoms();
+ /* apply default dimensions */
+ sx = 0;
+ sy = 0;
+ sw = DisplayWidth(dpy, screen);
+ sh = DisplayHeight(dpy, screen);
+ setgeom(GEOMETRY);
/* init atoms */
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.