diff options
| -rw-r--r-- | dwm.c | 64 |
1 files changed, 54 insertions, 10 deletions
| @@ -40,6 +40,21 @@ | |||
| 40 | #include <X11/Xlib.h> | 40 | #include <X11/Xlib.h> |
| 41 | #include <X11/Xproto.h> | 41 | #include <X11/Xproto.h> |
| 42 | #include <X11/Xutil.h> | 42 | #include <X11/Xutil.h> |
| 43 | /* | ||
| 44 | * TODO: Idea: | ||
| 45 | * I intend to not provide real Xinerama support, but instead having a Column | ||
| 46 | * tilecols[] array which is used by tile(), and a Column maxcols[] arrays which is used by | ||
| 47 | * maximise(). Those arrays should be initialized in config.h. For simplicity | ||
| 48 | * reasons mwfact should be replaced with a more advanced method which | ||
| 49 | * implements the same, but using the boundary between tilecols[0] and | ||
| 50 | * tilecols[1] instead. Besides this, get rid of BARPOS and use instead the | ||
| 51 | * following mechanism: | ||
| 52 | * | ||
| 53 | * #define BX 0 | ||
| 54 | * #define BY 0 | ||
| 55 | * #define BW sw | ||
| 56 | * bh is calculated automatically and should be used for the | ||
| 57 | */ | ||
| 43 | #ifdef XINERAMA | 58 | #ifdef XINERAMA |
| 44 | #include <X11/extensions/Xinerama.h> | 59 | #include <X11/extensions/Xinerama.h> |
| 45 | #endif | 60 | #endif |
| @@ -78,6 +93,10 @@ struct Client { | |||
| 78 | 93 | ||
| 79 | typedef struct { | 94 | typedef struct { |
| 80 | int x, y, w, h; | 95 | int x, y, w, h; |
| 96 | } Column; | ||
| 97 | |||
| 98 | typedef struct { | ||
| 99 | int x, y, w, h; | ||
| 81 | unsigned long norm[ColLast]; | 100 | unsigned long norm[ColLast]; |
| 82 | unsigned long sel[ColLast]; | 101 | unsigned long sel[ColLast]; |
| 83 | Drawable drawable; | 102 | Drawable drawable; |
| @@ -195,7 +214,7 @@ void selectview(const char *arg); | |||
| 195 | /* variables */ | 214 | /* variables */ |
| 196 | char stext[256], buf[256]; | 215 | char stext[256], buf[256]; |
| 197 | double mwfact; | 216 | double mwfact; |
| 198 | int screen, sx, sy, sw, sh, wax, way, waw, wah, xscreens; | 217 | int screen, sx, sy, sw, sh, wax, way, waw, wah, ncols; |
| 199 | int (*xerrorxlib)(Display *, XErrorEvent *); | 218 | int (*xerrorxlib)(Display *, XErrorEvent *); |
| 200 | unsigned int bh, bpos; | 219 | unsigned int bh, bpos; |
| 201 | unsigned int blw = 0; | 220 | unsigned int blw = 0; |
| @@ -224,14 +243,12 @@ Bool *seltags; | |||
| 224 | Client *clients = NULL; | 243 | Client *clients = NULL; |
| 225 | Client *sel = NULL; | 244 | Client *sel = NULL; |
| 226 | Client *stack = NULL; | 245 | Client *stack = NULL; |
| 246 | Column *cols = NULL; | ||
| 227 | Cursor cursor[CurLast]; | 247 | Cursor cursor[CurLast]; |
| 228 | Display *dpy; | 248 | Display *dpy; |
| 229 | DC dc = {0}; | 249 | DC dc = {0}; |
| 230 | Layout *lt; | 250 | Layout *lt; |
| 231 | Window root, barwin; | 251 | Window root, barwin; |
| 232 | #ifdef XINERAMA | ||
| 233 | XineramaScreenInfo *info = NULL; | ||
| 234 | #endif | ||
| 235 | 252 | ||
| 236 | /* configuration, allows nested code to access above variables */ | 253 | /* configuration, allows nested code to access above variables */ |
| 237 | #include "config.h" | 254 | #include "config.h" |
| @@ -393,10 +410,6 @@ cleanup(void) { | |||
| 393 | XFreeCursor(dpy, cursor[CurResize]); | 410 | XFreeCursor(dpy, cursor[CurResize]); |
| 394 | XFreeCursor(dpy, cursor[CurMove]); | 411 | XFreeCursor(dpy, cursor[CurMove]); |
| 395 | XDestroyWindow(dpy, barwin); | 412 | XDestroyWindow(dpy, barwin); |
| 396 | #if XINERAMA | ||
| 397 | if(info) | ||
| 398 | XFree(info); | ||
| 399 | #endif | ||
| 400 | XSync(dpy, False); | 413 | XSync(dpy, False); |
| 401 | XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); | 414 | XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); |
| 402 | } | 415 | } |
| @@ -1458,8 +1471,12 @@ setmwfact(const char *arg) { | |||
| 1458 | 1471 | ||
| 1459 | void | 1472 | void |
| 1460 | setup(void) { | 1473 | setup(void) { |
| 1474 | int screens = 1; | ||
| 1461 | unsigned int i; | 1475 | unsigned int i; |
| 1462 | XSetWindowAttributes wa; | 1476 | XSetWindowAttributes wa; |
| 1477 | #ifdef XINERAMA | ||
| 1478 | XineramaScreenInfo *info; | ||
| 1479 | #endif | ||
| 1463 | 1480 | ||
| 1464 | /* init screen */ | 1481 | /* init screen */ |
| 1465 | screen = DefaultScreen(dpy); | 1482 | screen = DefaultScreen(dpy); |
| @@ -1482,11 +1499,38 @@ setup(void) { | |||
| 1482 | cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); | 1499 | cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); |
| 1483 | cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); | 1500 | cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); |
| 1484 | 1501 | ||
| 1502 | ncols = 2; | ||
| 1485 | #ifdef XINERAMA | 1503 | #ifdef XINERAMA |
| 1486 | if(XineramaIsActive(dpy)) | 1504 | if(XineramaIsActive(dpy)) { |
| 1487 | info = XineramaQueryScreens(dpy, &xscreens); | 1505 | if((info = XineramaQueryScreens(dpy, &screens))) { |
| 1506 | if(screens == 1) { | ||
| 1507 | sx = info[0].x_org; | ||
| 1508 | sy = info[0].y_org; | ||
| 1509 | sw = info[0].width; | ||
| 1510 | sh = info[0].height; | ||
| 1511 | } | ||
| 1512 | else { | ||
| 1513 | ncols = screens; | ||
| 1514 | cols = emallocz(ncols * sizeof(Column)); | ||
| 1515 | for(i = 0; i < ncols; i++) { | ||
| 1516 | cols[i].x = info[i].x_org; | ||
| 1517 | cols[i].y = info[i].y_org; | ||
| 1518 | cols[i].w = info[i].width; | ||
| 1519 | cols[i].h = info[i].height; | ||
| 1520 | } | ||
| 1521 | } | ||
| 1522 | XFree(info); | ||
| 1523 | } | ||
| 1524 | } | ||
| 1525 | else | ||
| 1488 | #endif | 1526 | #endif |
| 1527 | { | ||
| 1528 | cols = emallocz(ncols * sizeof(Column)); | ||
| 1529 | cols[0].x = sx; | ||
| 1530 | cols[0].y = sy; | ||
| 1489 | 1531 | ||
| 1532 | |||
| 1533 | } | ||
| 1490 | /* init appearance */ | 1534 | /* init appearance */ |
| 1491 | dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); | 1535 | dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); |
| 1492 | dc.norm[ColBG] = getcolor(NORMBGCOLOR); | 1536 | dc.norm[ColBG] = getcolor(NORMBGCOLOR); |
