next on TODO
e3c2d327
1 file(s) · +54 −10
| 40 | 40 | #include <X11/Xlib.h> |
|
| 41 | 41 | #include <X11/Xproto.h> |
|
| 42 | 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 | 58 | #ifdef XINERAMA |
|
| 44 | 59 | #include <X11/extensions/Xinerama.h> |
|
| 45 | 60 | #endif |
|
| 78 | 93 | ||
| 79 | 94 | typedef struct { |
|
| 80 | 95 | int x, y, w, h; |
|
| 96 | + | } Column; |
|
| 97 | + | ||
| 98 | + | typedef struct { |
|
| 99 | + | int x, y, w, h; |
|
| 81 | 100 | unsigned long norm[ColLast]; |
|
| 82 | 101 | unsigned long sel[ColLast]; |
|
| 83 | 102 | Drawable drawable; |
|
| 195 | 214 | /* variables */ |
|
| 196 | 215 | char stext[256], buf[256]; |
|
| 197 | 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 | 218 | int (*xerrorxlib)(Display *, XErrorEvent *); |
|
| 200 | 219 | unsigned int bh, bpos; |
|
| 201 | 220 | unsigned int blw = 0; |
|
| 224 | 243 | Client *clients = NULL; |
|
| 225 | 244 | Client *sel = NULL; |
|
| 226 | 245 | Client *stack = NULL; |
|
| 246 | + | Column *cols = NULL; |
|
| 227 | 247 | Cursor cursor[CurLast]; |
|
| 228 | 248 | Display *dpy; |
|
| 229 | 249 | DC dc = {0}; |
|
| 230 | 250 | Layout *lt; |
|
| 231 | 251 | Window root, barwin; |
|
| 232 | - | #ifdef XINERAMA |
|
| 233 | - | XineramaScreenInfo *info = NULL; |
|
| 234 | - | #endif |
|
| 235 | 252 | ||
| 236 | 253 | /* configuration, allows nested code to access above variables */ |
|
| 237 | 254 | #include "config.h" |
|
| 393 | 410 | XFreeCursor(dpy, cursor[CurResize]); |
|
| 394 | 411 | XFreeCursor(dpy, cursor[CurMove]); |
|
| 395 | 412 | XDestroyWindow(dpy, barwin); |
|
| 396 | - | #if XINERAMA |
|
| 397 | - | if(info) |
|
| 398 | - | XFree(info); |
|
| 399 | - | #endif |
|
| 400 | 413 | XSync(dpy, False); |
|
| 401 | 414 | XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); |
|
| 402 | 415 | } |
|
| 1458 | 1471 | ||
| 1459 | 1472 | void |
|
| 1460 | 1473 | setup(void) { |
|
| 1474 | + | int screens = 1; |
|
| 1461 | 1475 | unsigned int i; |
|
| 1462 | 1476 | XSetWindowAttributes wa; |
|
| 1477 | + | #ifdef XINERAMA |
|
| 1478 | + | XineramaScreenInfo *info; |
|
| 1479 | + | #endif |
|
| 1463 | 1480 | ||
| 1464 | 1481 | /* init screen */ |
|
| 1465 | 1482 | screen = DefaultScreen(dpy); |
|
| 1482 | 1499 | cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); |
|
| 1483 | 1500 | cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); |
|
| 1484 | 1501 | ||
| 1502 | + | ncols = 2; |
|
| 1485 | 1503 | #ifdef XINERAMA |
|
| 1486 | - | if(XineramaIsActive(dpy)) |
|
| 1487 | - | info = XineramaQueryScreens(dpy, &xscreens); |
|
| 1504 | + | if(XineramaIsActive(dpy)) { |
|
| 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 | 1526 | #endif |
|
| 1527 | + | { |
|
| 1528 | + | cols = emallocz(ncols * sizeof(Column)); |
|
| 1529 | + | cols[0].x = sx; |
|
| 1530 | + | cols[0].y = sy; |
|
| 1489 | 1531 | ||
| 1532 | + | ||
| 1533 | + | } |
|
| 1490 | 1534 | /* init appearance */ |
|
| 1491 | 1535 | dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); |
|
| 1492 | 1536 | dc.norm[ColBG] = getcolor(NORMBGCOLOR); |
|