diff options
| author | Anselm R Garbe <garbeam@gmail.com> | 2008-03-14 17:17:08 +0000 |
|---|---|---|
| committer | Anselm R Garbe <garbeam@gmail.com> | 2008-03-14 17:17:08 +0000 |
| commit | 33b1960220f468ff2888e8ba3517e9a62ed99974 (patch) | |
| tree | 29c0ce55031bb61dec5e6937fd099638964ed478 /dwm.c | |
| parent | some changes towards 4.9 (diff) | |
| download | dwm-33b1960220f468ff2888e8ba3517e9a62ed99974.tar.gz dwm-33b1960220f468ff2888e8ba3517e9a62ed99974.zip | |
some experimental state DO NOT USE THIS, I plan to have a nicer interface to change geometries
Diffstat (limited to '')
| -rw-r--r-- | dwm.c | 134 |
1 files changed, 95 insertions, 39 deletions
| @@ -136,6 +136,7 @@ void focusnext(const char *arg); | |||
| 136 | void focusprev(const char *arg); | 136 | void focusprev(const char *arg); |
| 137 | Client *getclient(Window w); | 137 | Client *getclient(Window w); |
| 138 | unsigned long getcolor(const char *colstr); | 138 | unsigned long getcolor(const char *colstr); |
| 139 | double getdouble(const char *s); | ||
| 139 | long getstate(Window w); | 140 | long getstate(Window w); |
| 140 | Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); | 141 | Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); |
| 141 | void grabbuttons(Client *c, Bool focused); | 142 | void grabbuttons(Client *c, Bool focused); |
| @@ -163,7 +164,7 @@ void restack(void); | |||
| 163 | void run(void); | 164 | void run(void); |
| 164 | void scan(void); | 165 | void scan(void); |
| 165 | void setclientstate(Client *c, long state); | 166 | void setclientstate(Client *c, long state); |
| 166 | void setdefgeoms(void); | 167 | void setgeom(const char *arg); |
| 167 | void setlayout(const char *arg); | 168 | void setlayout(const char *arg); |
| 168 | void setup(void); | 169 | void setup(void); |
| 169 | void spawn(const char *arg); | 170 | void spawn(const char *arg); |
| @@ -410,7 +411,7 @@ configurenotify(XEvent *e) { | |||
| 410 | XConfigureEvent *ev = &e->xconfigure; | 411 | XConfigureEvent *ev = &e->xconfigure; |
| 411 | 412 | ||
| 412 | if(ev->window == root && (ev->width != sw || ev->height != sh)) { | 413 | if(ev->window == root && (ev->width != sw || ev->height != sh)) { |
| 413 | setgeoms(); | 414 | setgeom(NULL); |
| 414 | updatebarpos(); | 415 | updatebarpos(); |
| 415 | arrange(); | 416 | arrange(); |
| 416 | } | 417 | } |
| @@ -1390,44 +1391,95 @@ setclientstate(Client *c, long state) { | |||
| 1390 | PropModeReplace, (unsigned char *)data, 2); | 1391 | PropModeReplace, (unsigned char *)data, 2); |
| 1391 | } | 1392 | } |
| 1392 | 1393 | ||
| 1393 | void | 1394 | /** |
| 1394 | setdefgeoms(void) { | 1395 | * Idea: |
| 1395 | 1396 | * | |
| 1396 | /* screen dimensions */ | 1397 | * having a geom syntax as follows, which is interpreted as integer. |
| 1397 | sx = 0; | 1398 | * |
| 1398 | sy = 0; | 1399 | * [-,+][<0..n>|<W,H,B>] |
| 1399 | sw = DisplayWidth(dpy, screen); | 1400 | * |
| 1400 | sh = DisplayHeight(dpy, screen); | 1401 | * |
| 1401 | 1402 | * B = bar height, W = DisplayWidth(), H = DisplayHeight() | |
| 1402 | /* bar position */ | 1403 | * |
| 1403 | bx = sx; | 1404 | * -/+/* /: is relative to current |
| 1404 | by = sy; | 1405 | * |
| 1405 | bw = sw; | 1406 | * Then we would come down with <bx>,<by>,<bw>,<bh>,... |
| 1406 | bh = dc.font.height + 2; | 1407 | * |
| 1407 | 1408 | * "0 0 W B 0 0 W W N E B,W,B, | |
| 1408 | /* window area */ | 1409 | * |
| 1409 | wx = sx; | 1410 | * |
| 1410 | wy = sy + bh; | 1411 | */ |
| 1411 | ww = sw; | ||
| 1412 | wh = sh - bh; | ||
| 1413 | 1412 | ||
| 1414 | /* master area */ | 1413 | double |
| 1415 | mx = wx; | 1414 | getdouble(const char *s) { |
| 1416 | my = wy; | 1415 | char *endp; |
| 1417 | mw = ((float)sw) * 0.55; | 1416 | double result = 0; |
| 1418 | mh = wh; | 1417 | |
| 1418 | fprintf(stderr, "getdouble '%s'\n", s); | ||
| 1419 | switch(*s) { | ||
| 1420 | default: | ||
| 1421 | result = strtod(s, &endp); | ||
| 1422 | if(s == endp || *endp != 0) | ||
| 1423 | result = strtol(s, &endp, 0); | ||
| 1424 | break; | ||
| 1425 | case 'B': result = dc.font.height + 2; break; | ||
| 1426 | case 'W': result = sw; break; | ||
| 1427 | case 'H': result = sh; break; | ||
| 1428 | } | ||
| 1429 | fprintf(stderr, "getdouble returns '%f'\n", result); | ||
| 1430 | return result; | ||
| 1431 | } | ||
| 1419 | 1432 | ||
| 1420 | /* tile area */ | 1433 | void |
| 1421 | tx = mx + mw; | 1434 | setgeom(const char *arg) { |
| 1422 | ty = wy; | 1435 | static const char *lastArg = NULL; |
| 1423 | tw = ww - mw; | 1436 | char op, *s, *e, *p; |
| 1424 | th = wh; | 1437 | double val; |
| 1438 | int i, *map[] = { &bx, &by, &bw, &bh, | ||
| 1439 | &wx, &wy, &ww, &wh, | ||
| 1440 | &mx, &my, &mw, &mh, | ||
| 1441 | &tx, &ty, &tw, &th, | ||
| 1442 | &mox, &moy, &mow, &moh }; | ||
| 1425 | 1443 | ||
| 1426 | /* monocle area */ | 1444 | if(!arg) |
| 1427 | mox = wx; | 1445 | arg = lastArg; |
| 1428 | moy = wy; | 1446 | else |
| 1429 | mow = ww; | 1447 | lastArg = arg; |
| 1430 | moh = wh; | 1448 | if(!lastArg) |
| 1449 | return; | ||
| 1450 | strncpy(buf, arg, sizeof buf); | ||
| 1451 | for(i = 0, e = s = buf; e && *e; e++) | ||
| 1452 | if(*e == ' ') { | ||
| 1453 | *e = 0; | ||
| 1454 | fprintf(stderr, "next geom arg='%s'\n", s); | ||
| 1455 | op = 0; | ||
| 1456 | /* check if there is an operator */ | ||
| 1457 | for(p = s; *p && *p != '-' && *p != '+' && *p != '*' && *p != ':'; p++); | ||
| 1458 | if(*p) { | ||
| 1459 | op = *p; | ||
| 1460 | *p = 0; | ||
| 1461 | } | ||
| 1462 | val = getdouble(s); | ||
| 1463 | fprintf(stderr, "val1: %d\n", val); | ||
| 1464 | if(p > s) { /* intermediate operand, e.g. H-B */ | ||
| 1465 | *(map[i]) = val; | ||
| 1466 | s = ++p; | ||
| 1467 | val = getdouble(s); | ||
| 1468 | fprintf(stderr, "val2: %d\n", val); | ||
| 1469 | } | ||
| 1470 | switch(op) { | ||
| 1471 | default: *(map[i]) = val; break; | ||
| 1472 | case '-': *(map[i]) -= val; break; | ||
| 1473 | case '+': *(map[i]) += val; break; | ||
| 1474 | case '*': *(map[i]) *= val; break; | ||
| 1475 | case ':': if(val != 0) *(map[i]) /= val; break; | ||
| 1476 | } | ||
| 1477 | fprintf(stderr, "map[i]='%d'\n", val); | ||
| 1478 | s = ++e; | ||
| 1479 | i++; | ||
| 1480 | } | ||
| 1481 | updatebarpos(); | ||
| 1482 | arrange(); | ||
| 1431 | } | 1483 | } |
| 1432 | 1484 | ||
| 1433 | void | 1485 | void |
| @@ -1464,8 +1516,12 @@ setup(void) { | |||
| 1464 | root = RootWindow(dpy, screen); | 1516 | root = RootWindow(dpy, screen); |
| 1465 | initfont(FONT); | 1517 | initfont(FONT); |
| 1466 | 1518 | ||
| 1467 | /* apply default geometries */ | 1519 | /* apply default dimensions */ |
| 1468 | setgeoms(); | 1520 | sx = 0; |
| 1521 | sy = 0; | ||
| 1522 | sw = DisplayWidth(dpy, screen); | ||
| 1523 | sh = DisplayHeight(dpy, screen); | ||
| 1524 | setgeom(GEOMETRY); | ||
| 1469 | 1525 | ||
| 1470 | /* init atoms */ | 1526 | /* init atoms */ |
| 1471 | wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); | 1527 | wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); |
