dwm.c
changeset 1120 8bd946fbb015
parent 1119 4a078ab3e792
child 1121 898952a1689d
equal deleted inserted replaced
1119:4a078ab3e792 1120:8bd946fbb015
    53  * #define BX 0
    53  * #define BX 0
    54  * #define BY 0
    54  * #define BY 0
    55  * #define BW sw
    55  * #define BW sw
    56  * bh is calculated automatically and should be used for the 
    56  * bh is calculated automatically and should be used for the 
    57  */
    57  */
    58 #ifdef XINERAMA
    58 //#ifdef XINERAMA
    59 #include <X11/extensions/Xinerama.h>
    59 #include <X11/extensions/Xinerama.h>
    60 #endif
    60 //#endif
    61 
    61 
    62 /* macros */
    62 /* macros */
    63 #define BUTTONMASK		(ButtonPressMask|ButtonReleaseMask)
    63 #define BUTTONMASK		(ButtonPressMask|ButtonReleaseMask)
    64 #define CLEANMASK(mask)		(mask & ~(numlockmask|LockMask))
    64 #define CLEANMASK(mask)		(mask & ~(numlockmask|LockMask))
    65 #define LENGTH(x)		(sizeof x / sizeof x[0])
    65 #define LENGTH(x)		(sizeof x / sizeof x[0])
  1472 void
  1472 void
  1473 setup(void) {
  1473 setup(void) {
  1474 	int screens = 1;
  1474 	int screens = 1;
  1475 	unsigned int i;
  1475 	unsigned int i;
  1476 	XSetWindowAttributes wa;
  1476 	XSetWindowAttributes wa;
  1477 #ifdef XINERAMA
  1477 //#ifdef XINERAMA
  1478 	XineramaScreenInfo *info;
  1478 	XineramaScreenInfo *info;
  1479 #endif
  1479 //#endif
  1480 
  1480 
  1481 	/* init screen */
  1481 	/* init screen */
  1482 	screen = DefaultScreen(dpy);
  1482 	screen = DefaultScreen(dpy);
  1483 	root = RootWindow(dpy, screen);
  1483 	root = RootWindow(dpy, screen);
  1484 	sx = 0;
  1484 	sx = 0;
  1485 	sy = 0;
  1485 	sy = 0;
  1486 	sw = DisplayWidth(dpy, screen);
  1486 	sw = DisplayWidth(dpy, screen);
  1487 	sh = DisplayHeight(dpy, screen);
  1487 	sh = DisplayHeight(dpy, screen);
       
  1488 	if(XineramaIsActive(dpy)) {
       
  1489 		if((info = XineramaQueryScreens(dpy, &screens))) {
       
  1490 			sx = info[0].x_org;
       
  1491 			sy = info[0].y_org;
       
  1492 			sw = info[0].width;
       
  1493 			sh = info[0].height;
       
  1494 		}
       
  1495 	}
  1488 
  1496 
  1489 	/* init atoms */
  1497 	/* init atoms */
  1490 	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
  1498 	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
  1491 	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
  1499 	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
  1492 	wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False);
  1500 	wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False);
  1498 	wa.cursor = cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
  1506 	wa.cursor = cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
  1499 	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
  1507 	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
  1500 	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
  1508 	cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
  1501 
  1509 
  1502 	ncols = 2;
  1510 	ncols = 2;
  1503 #ifdef XINERAMA
  1511 #if 0
  1504 	if(XineramaIsActive(dpy)) {
  1512 	if(XineramaIsActive(dpy)) {
  1505 		if((info = XineramaQueryScreens(dpy, &screens))) {
  1513 		if((info = XineramaQueryScreens(dpy, &screens))) {
  1506 			if(screens == 1) {
  1514 			if(screens >= 1) {
  1507 				sx = info[0].x_org;
  1515 				sx = info[0].x_org;
  1508 				sy = info[0].y_org;
  1516 				sy = info[0].y_org;
  1509 				sw = info[0].width;
  1517 				sw = info[0].width;
  1510 				sh = info[0].height;
  1518 				sh = info[0].height;
  1511 			}
  1519 			}
  1521 			}
  1529 			}
  1522 			XFree(info);
  1530 			XFree(info);
  1523 		}
  1531 		}
  1524 	}
  1532 	}
  1525 	else
  1533 	else
  1526 #endif
       
  1527 	{
  1534 	{
  1528 		cols = emallocz(ncols * sizeof(Column));
  1535 		cols = emallocz(ncols * sizeof(Column));
  1529 		cols[0].x = sx;
  1536 		cols[0].x = sx;
  1530 		cols[0].y = sy;
  1537 		cols[0].y = sy;
  1531 
  1538 	}
  1532 
  1539 #endif
  1533 	}
       
  1534 	/* init appearance */
  1540 	/* init appearance */
  1535 	dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR);
  1541 	dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR);
  1536 	dc.norm[ColBG] = getcolor(NORMBGCOLOR);
  1542 	dc.norm[ColBG] = getcolor(NORMBGCOLOR);
  1537 	dc.norm[ColFG] = getcolor(NORMFGCOLOR);
  1543 	dc.norm[ColFG] = getcolor(NORMFGCOLOR);
  1538 	dc.sel[ColBorder] = getcolor(SELBORDERCOLOR);
  1544 	dc.sel[ColBorder] = getcolor(SELBORDERCOLOR);
  1862 
  1868 
  1863 void
  1869 void
  1864 updatewmhints(Client *c) {
  1870 updatewmhints(Client *c) {
  1865 	XWMHints *wmh;
  1871 	XWMHints *wmh;
  1866 
  1872 
       
  1873 	if(c == sel)
       
  1874 		return;
  1867 	if((wmh = XGetWMHints(dpy, c->win))) {
  1875 	if((wmh = XGetWMHints(dpy, c->win))) {
  1868 		c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
  1876 		c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
  1869 		XFree(wmh);
  1877 		XFree(wmh);
  1870 	}
  1878 	}
  1871 }
  1879 }