dwm.c
changeset 1240 3a7c590338b3
parent 1239 e7f93f1f63ba
child 1241 c93c552561b4
equal deleted inserted replaced
1239:e7f93f1f63ba 1240:3a7c590338b3
   191 void zoom(const void *arg);
   191 void zoom(const void *arg);
   192 
   192 
   193 /* variables */
   193 /* variables */
   194 char stext[256];
   194 char stext[256];
   195 int screen, sx, sy, sw, sh;
   195 int screen, sx, sy, sw, sh;
   196 int bx, by, bw, bh, blw, wx, wy, ww, wh;
   196 int by, bh, blw, wx, wy, ww, wh;
   197 uint seltags = 0;
   197 uint seltags = 0;
   198 int (*xerrorxlib)(Display *, XErrorEvent *);
   198 int (*xerrorxlib)(Display *, XErrorEvent *);
   199 uint numlockmask = 0;
   199 uint numlockmask = 0;
   200 void (*handler[LASTEvent]) (XEvent *) = {
   200 void (*handler[LASTEvent]) (XEvent *) = {
   201 	[ButtonPress] = buttonpress,
   201 	[ButtonPress] = buttonpress,
   504 		x = dc.x + dc.w;
   504 		x = dc.x + dc.w;
   505 	}
   505 	}
   506 	else
   506 	else
   507 		x = dc.x;
   507 		x = dc.x;
   508 	dc.w = TEXTW(stext);
   508 	dc.w = TEXTW(stext);
   509 	dc.x = bw - dc.w;
   509 	dc.x = ww - dc.w;
   510 	if(dc.x < x) {
   510 	if(dc.x < x) {
   511 		dc.x = x;
   511 		dc.x = x;
   512 		dc.w = bw - x;
   512 		dc.w = ww - x;
   513 	}
   513 	}
   514 	drawtext(stext, dc.norm, False);
   514 	drawtext(stext, dc.norm, False);
   515 	if((dc.w = dc.x - x) > bh) {
   515 	if((dc.w = dc.x - x) > bh) {
   516 		dc.x = x;
   516 		dc.x = x;
   517 		if(c) {
   517 		if(c) {
   519 			drawsquare(False, c->isfloating, False, dc.sel);
   519 			drawsquare(False, c->isfloating, False, dc.sel);
   520 		}
   520 		}
   521 		else
   521 		else
   522 			drawtext(NULL, dc.norm, False);
   522 			drawtext(NULL, dc.norm, False);
   523 	}
   523 	}
   524 	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
   524 	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, ww, bh, 0, 0);
   525 	XSync(dpy, False);
   525 	XSync(dpy, False);
   526 }
   526 }
   527 
   527 
   528 void
   528 void
   529 drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]) {
   529 drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]) {
  1370 
  1370 
  1371 	wa.override_redirect = 1;
  1371 	wa.override_redirect = 1;
  1372 	wa.background_pixmap = ParentRelative;
  1372 	wa.background_pixmap = ParentRelative;
  1373 	wa.event_mask = ButtonPressMask|ExposureMask;
  1373 	wa.event_mask = ButtonPressMask|ExposureMask;
  1374 
  1374 
  1375 	barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
  1375 	barwin = XCreateWindow(dpy, root, wx, by, ww, bh, 0, DefaultDepth(dpy, screen),
  1376 			CopyFromParent, DefaultVisual(dpy, screen),
  1376 			CopyFromParent, DefaultVisual(dpy, screen),
  1377 			CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
  1377 			CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
  1378 	XDefineCursor(dpy, barwin, cursor[CurNormal]);
  1378 	XDefineCursor(dpy, barwin, cursor[CurNormal]);
  1379 	XMapRaised(dpy, barwin);
  1379 	XMapRaised(dpy, barwin);
  1380 	strcpy(stext, "dwm-"VERSION);
  1380 	strcpy(stext, "dwm-"VERSION);
  1565 
  1565 
  1566 void
  1566 void
  1567 updatebar(void) {
  1567 updatebar(void) {
  1568 	if(dc.drawable != 0)
  1568 	if(dc.drawable != 0)
  1569 		XFreePixmap(dpy, dc.drawable);
  1569 		XFreePixmap(dpy, dc.drawable);
  1570 	dc.drawable = XCreatePixmap(dpy, root, bw, bh, DefaultDepth(dpy, screen));
  1570 	dc.drawable = XCreatePixmap(dpy, root, ww, bh, DefaultDepth(dpy, screen));
  1571 	XMoveResizeWindow(dpy, barwin, bx, by, bw, bh);
  1571 	XMoveResizeWindow(dpy, barwin, wx, by, ww, bh);
  1572 }
  1572 }
  1573 
  1573 
  1574 void
  1574 void
  1575 updategeom(void) {
  1575 updategeom(void) {
  1576 	int i;
  1576 	int i;
  1593 		wy = showbar && topbar ? sy + bh : sy;
  1593 		wy = showbar && topbar ? sy + bh : sy;
  1594 		ww = sw;
  1594 		ww = sw;
  1595 		wh = showbar ? sh - bh : sh;
  1595 		wh = showbar ? sh - bh : sh;
  1596 	}
  1596 	}
  1597 
  1597 
  1598 	/* bar geometry */
  1598 	/* bar position */
  1599 	bx = wx;
       
  1600 	by = showbar ? (topbar ? wy - bh : wy + wh) : -bh;
  1599 	by = showbar ? (topbar ? wy - bh : wy + wh) : -bh;
  1601 	bw = ww;
       
  1602 }
  1600 }
  1603 
  1601 
  1604 void
  1602 void
  1605 updatesizehints(Client *c) {
  1603 updatesizehints(Client *c) {
  1606 	long msize;
  1604 	long msize;