| 107 |
107 |
|
} Rule; |
| 108 |
108 |
|
|
| 109 |
109 |
|
/* function declarations */ |
|
110 |
+ |
void applygeom(const char *arg); |
| 110 |
111 |
|
void applyrules(Client *c); |
| 111 |
112 |
|
void arrange(void); |
| 112 |
113 |
|
void attach(Client *c); |
|
| 236 |
237 |
|
/* function implementations */ |
| 237 |
238 |
|
|
| 238 |
239 |
|
void |
|
240 |
+ |
applygeometry(const char *arg) { |
|
241 |
+ |
static const char *lastArg = NULL; |
|
242 |
+ |
char delim, op, *s, *e, *p; |
|
243 |
+ |
double val; |
|
244 |
+ |
int i, *map[] = { &bx, &by, &bw, &bh, |
|
245 |
+ |
&wx, &wy, &ww, &wh, |
|
246 |
+ |
&mx, &my, &mw, &mh, |
|
247 |
+ |
&tx, &ty, &tw, &th, |
|
248 |
+ |
&mox, &moy, &mow, &moh }; |
|
249 |
+ |
|
|
250 |
+ |
if(!arg) |
|
251 |
+ |
arg = lastArg; |
|
252 |
+ |
else |
|
253 |
+ |
lastArg = arg; |
|
254 |
+ |
if(!lastArg) |
|
255 |
+ |
return; |
|
256 |
+ |
strncpy(buf, arg, sizeof buf); |
|
257 |
+ |
for(i = 0, e = s = buf; i < LENGTH(map) && e; e++) |
|
258 |
+ |
if(*e == ' ' || *e == 0) { |
|
259 |
+ |
delim = *e; |
|
260 |
+ |
*e = 0; |
|
261 |
+ |
op = 0; |
|
262 |
+ |
/* check if there is an operator */ |
|
263 |
+ |
for(p = s; p < e && *p != '-' && *p != '+' && *p != '*'; p++); |
|
264 |
+ |
if(*p) { |
|
265 |
+ |
op = *p; |
|
266 |
+ |
*p = 0; |
|
267 |
+ |
} |
|
268 |
+ |
val = getdouble(s); |
|
269 |
+ |
if(op && p > s) { /* intermediate operand, e.g. H-B */ |
|
270 |
+ |
*(map[i]) = (int)val; |
|
271 |
+ |
s = ++p; |
|
272 |
+ |
val = getdouble(s); |
|
273 |
+ |
} |
|
274 |
+ |
switch(op) { |
|
275 |
+ |
default: *(map[i]) = (int)val; break; |
|
276 |
+ |
case '-': *(map[i]) -= (int)val; break; |
|
277 |
+ |
case '+': *(map[i]) += (int)val; break; |
|
278 |
+ |
case '*': *(map[i]) = (int)(((double)*(map[i])) * val); break; |
|
279 |
+ |
} |
|
280 |
+ |
if(delim == 0) |
|
281 |
+ |
e = NULL; |
|
282 |
+ |
else |
|
283 |
+ |
s = ++e; |
|
284 |
+ |
i++; |
|
285 |
+ |
} |
|
286 |
+ |
} |
|
287 |
+ |
|
|
288 |
+ |
void |
| 239 |
289 |
|
applyrules(Client *c) { |
| 240 |
290 |
|
unsigned int i; |
| 241 |
291 |
|
Bool matched = False; |
|
| 410 |
460 |
|
configurenotify(XEvent *e) { |
| 411 |
461 |
|
XConfigureEvent *ev = &e->xconfigure; |
| 412 |
462 |
|
|
| 413 |
|
- |
if(ev->window == root && (ev->width != sw || ev->height != sh)) { |
|
463 |
+ |
if(ev->window == root && (ev->width != sw || ev->height != sh)) |
| 414 |
464 |
|
setgeom(NULL); |
| 415 |
|
- |
updatebarpos(); |
| 416 |
|
- |
arrange(); |
| 417 |
|
- |
} |
| 418 |
465 |
|
} |
| 419 |
466 |
|
|
| 420 |
467 |
|
void |
|
| 1391 |
1438 |
|
PropModeReplace, (unsigned char *)data, 2); |
| 1392 |
1439 |
|
} |
| 1393 |
1440 |
|
|
| 1394 |
|
- |
/** |
| 1395 |
|
- |
* Idea: |
| 1396 |
|
- |
* |
| 1397 |
|
- |
* having a geom syntax as follows, which is interpreted as integer. |
| 1398 |
|
- |
* |
| 1399 |
|
- |
* [-,+][<0..n>|<W,H,B>] |
| 1400 |
|
- |
* |
| 1401 |
|
- |
* |
| 1402 |
|
- |
* B = bar height, W = DisplayWidth(), H = DisplayHeight() |
| 1403 |
|
- |
* |
| 1404 |
|
- |
* -/+/* /: is relative to current |
| 1405 |
|
- |
* |
| 1406 |
|
- |
* Then we would come down with <bx>,<by>,<bw>,<bh>,... |
| 1407 |
|
- |
* |
| 1408 |
|
- |
* "0 0 W B 0 0 W W N E B,W,B, |
| 1409 |
|
- |
* |
| 1410 |
|
- |
* |
| 1411 |
|
- |
*/ |
| 1412 |
|
- |
|
| 1413 |
1441 |
|
double |
| 1414 |
1442 |
|
getdouble(const char *s) { |
| 1415 |
1443 |
|
char *endp; |
| 1416 |
1444 |
|
double result = 0; |
| 1417 |
1445 |
|
|
| 1418 |
|
- |
fprintf(stderr, "getdouble '%s'\n", s); |
| 1419 |
1446 |
|
switch(*s) { |
| 1420 |
1447 |
|
default: |
| 1421 |
1448 |
|
result = strtod(s, &endp); |
|
| 1426 |
1453 |
|
case 'W': result = sw; break; |
| 1427 |
1454 |
|
case 'H': result = sh; break; |
| 1428 |
1455 |
|
} |
| 1429 |
|
- |
fprintf(stderr, "getdouble returns '%f'\n", result); |
| 1430 |
1456 |
|
return result; |
| 1431 |
1457 |
|
} |
| 1432 |
1458 |
|
|
| 1433 |
1459 |
|
void |
| 1434 |
1460 |
|
setgeom(const char *arg) { |
| 1435 |
|
- |
static const char *lastArg = NULL; |
| 1436 |
|
- |
char op, *s, *e, *p; |
| 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 }; |
| 1443 |
|
- |
|
| 1444 |
|
- |
if(!arg) |
| 1445 |
|
- |
arg = lastArg; |
| 1446 |
|
- |
else |
| 1447 |
|
- |
lastArg = arg; |
| 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 |
|
- |
} |
|
1461 |
+ |
applygeometry(arg); |
| 1481 |
1462 |
|
updatebarpos(); |
| 1482 |
1463 |
|
arrange(); |
| 1483 |
1464 |
|
} |
|
| 1521 |
1502 |
|
sy = 0; |
| 1522 |
1503 |
|
sw = DisplayWidth(dpy, screen); |
| 1523 |
1504 |
|
sh = DisplayHeight(dpy, screen); |
| 1524 |
|
- |
setgeom(GEOMETRY); |
|
1505 |
+ |
applygeometry(GEOMETRY); |
| 1525 |
1506 |
|
|
| 1526 |
1507 |
|
/* init atoms */ |
| 1527 |
1508 |
|
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); |