38 #include <X11/keysym.h> |
38 #include <X11/keysym.h> |
39 #include <X11/Xatom.h> |
39 #include <X11/Xatom.h> |
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 |
46 |
61 |
47 /* macros */ |
62 /* macros */ |
193 void selectview(const char *arg); |
212 void selectview(const char *arg); |
194 |
213 |
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; |
202 unsigned int numlockmask = 0; |
221 unsigned int numlockmask = 0; |
203 void (*handler[LASTEvent]) (XEvent *) = { |
222 void (*handler[LASTEvent]) (XEvent *) = { |
222 Bool *prevtags; |
241 Bool *prevtags; |
223 Bool *seltags; |
242 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" |
238 #define TAGSZ (LENGTH(tags) * sizeof(Bool)) |
255 #define TAGSZ (LENGTH(tags) * sizeof(Bool)) |
239 static Bool tmp[LENGTH(tags)]; |
256 static Bool tmp[LENGTH(tags)]; |
391 XFreeGC(dpy, dc.gc); |
408 XFreeGC(dpy, dc.gc); |
392 XFreeCursor(dpy, cursor[CurNormal]); |
409 XFreeCursor(dpy, cursor[CurNormal]); |
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 } |
403 |
416 |
404 void |
417 void |
1480 /* init cursors */ |
1497 /* init cursors */ |
1481 wa.cursor = cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); |
1498 wa.cursor = cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); |
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 |
1489 |
1527 { |
|
1528 cols = emallocz(ncols * sizeof(Column)); |
|
1529 cols[0].x = sx; |
|
1530 cols[0].y = sy; |
|
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); |
1493 dc.norm[ColFG] = getcolor(NORMFGCOLOR); |
1537 dc.norm[ColFG] = getcolor(NORMFGCOLOR); |
1494 dc.sel[ColBorder] = getcolor(SELBORDERCOLOR); |
1538 dc.sel[ColBorder] = getcolor(SELBORDERCOLOR); |