dwm.c
changeset 1404 2fd482e3405b
parent 1403 9bfeee8174c2
child 1405 f28d889cef66
equal deleted inserted replaced
1403:9bfeee8174c2 1404:2fd482e3405b
   122 
   122 
   123 struct Monitor {
   123 struct Monitor {
   124 	int screen_number;
   124 	int screen_number;
   125 	float mfact;
   125 	float mfact;
   126 	int by, btx;          /* bar geometry */
   126 	int by, btx;          /* bar geometry */
       
   127 	int my, mh;           /* vertical screen size*/
   127 	int wx, wy, ww, wh;   /* window area  */
   128 	int wx, wy, ww, wh;   /* window area  */
   128 	unsigned int seltags;
   129 	unsigned int seltags;
   129 	unsigned int sellt;
   130 	unsigned int sellt;
   130 	unsigned int tagset[2];
   131 	unsigned int tagset[2];
   131 	Bool showbar;
   132 	Bool showbar;
   207 static void toggletag(const Arg *arg);
   208 static void toggletag(const Arg *arg);
   208 static void toggleview(const Arg *arg);
   209 static void toggleview(const Arg *arg);
   209 static void unmanage(Client *c);
   210 static void unmanage(Client *c);
   210 static void unmapnotify(XEvent *e);
   211 static void unmapnotify(XEvent *e);
   211 static void updategeom(void);
   212 static void updategeom(void);
       
   213 static void updatebarpos(Monitor *m);
   212 static void updatebars(void);
   214 static void updatebars(void);
   213 static void updatenumlockmask(void);
   215 static void updatenumlockmask(void);
   214 static void updatesizehints(Client *c);
   216 static void updatesizehints(Client *c);
   215 static void updatestatus(void);
   217 static void updatestatus(void);
   216 static void updatetitle(Client *c);
   218 static void updatetitle(Client *c);
   387 	Arg arg = {0};
   389 	Arg arg = {0};
   388 	Client *c;
   390 	Client *c;
   389 	XButtonPressedEvent *ev = &e->xbutton;
   391 	XButtonPressedEvent *ev = &e->xbutton;
   390 
   392 
   391 	click = ClkRootWin;
   393 	click = ClkRootWin;
   392 	if(ev->window == selmon->barwin) {
   394 	if(ev->window == selmon->barwin && ev->x >= selmon->btx) {
   393 		i = 0;
   395 		i = 0;
   394 		x = selmon->btx;
   396 		x = selmon->btx;
   395 		do
   397 		do
   396 			x += TEXTW(tags[i]);
   398 			x += TEXTW(tags[i]);
   397 		while(ev->x >= x && ++i < LENGTH(tags));
   399 		while(ev->x >= x && ++i < LENGTH(tags));
   595 	exit(EXIT_FAILURE);
   597 	exit(EXIT_FAILURE);
   596 }
   598 }
   597 
   599 
   598 void
   600 void
   599 drawbar(Monitor *m) {
   601 drawbar(Monitor *m) {
       
   602 	char buf[2];
   600 	int x;
   603 	int x;
   601 	unsigned int i, occ = 0, urg = 0;
   604 	unsigned int i, occ = 0, urg = 0;
   602 	unsigned long *col;
   605 	unsigned long *col;
   603 	Client *c;
   606 	Client *c;
   604 
   607 
   611 	}
   614 	}
   612 
   615 
   613 	dc.x = 0;
   616 	dc.x = 0;
   614 #ifdef XINERAMA
   617 #ifdef XINERAMA
   615 	{
   618 	{
   616 		/*
   619 		buf[0] = m->screen_number + '0';
   617 		dc.w = TEXTW(m->symbol);
   620 		buf[1] = '\0';
   618 		drawtext(NULL, selmon == m ? dc.sel : dc.norm, False);
   621 		dc.w = TEXTW(buf);
       
   622 		drawtext(buf, selmon == m ? dc.sel : dc.norm, True);
   619 		dc.x += dc.w;
   623 		dc.x += dc.w;
   620 		*/
       
   621 	}
   624 	}
   622 #endif /* XINERAMA */
   625 #endif /* XINERAMA */
   623 	m->btx = dc.x;
   626 	m->btx = dc.x;
   624 	for(i = 0; i < LENGTH(tags); i++) {
   627 	for(i = 0; i < LENGTH(tags); i++) {
   625 		dc.w = TEXTW(tags[i]);
   628 		dc.w = TEXTW(tags[i]);
  1523 }
  1526 }
  1524 
  1527 
  1525 void
  1528 void
  1526 togglebar(const Arg *arg) {
  1529 togglebar(const Arg *arg) {
  1527 	selmon->showbar = !selmon->showbar;
  1530 	selmon->showbar = !selmon->showbar;
  1528 	updategeom();
  1531 	updatebarpos(selmon);
  1529 	XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
  1532 	XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
  1530 	arrange();
  1533 	arrange();
  1531 }
  1534 }
  1532 
  1535 
  1533 void
  1536 void
  1613 		XMapRaised(dpy, m->barwin);
  1616 		XMapRaised(dpy, m->barwin);
  1614 	}
  1617 	}
  1615 }
  1618 }
  1616 
  1619 
  1617 void
  1620 void
       
  1621 updatebarpos(Monitor *m) {
       
  1622 	m->wy = m->my;
       
  1623 	m->wh = m->mh;
       
  1624 	if(m->showbar) {
       
  1625 		m->wh -= bh;
       
  1626 		m->by = m->topbar ? m->wy : m->wy + m->wh;
       
  1627 		m->wy = m->topbar ? m->wy + bh : m->wy;
       
  1628 	}
       
  1629 	else
       
  1630 		m->by = -bh;
       
  1631 }
       
  1632 
       
  1633 void
  1618 updategeom(void) {
  1634 updategeom(void) {
  1619 	int i, n;
  1635 	int i, n;
  1620 	Client *c;
  1636 	Client *c;
  1621 	Monitor *newmons = NULL, *m;
  1637 	Monitor *newmons = NULL, *m;
  1622 
  1638 
  1637 #ifdef XINERAMA
  1653 #ifdef XINERAMA
  1638 	if(XineramaIsActive(dpy)) {
  1654 	if(XineramaIsActive(dpy)) {
  1639 		for(i = 0, m = newmons; m; m = m->next, i++) {
  1655 		for(i = 0, m = newmons; m; m = m->next, i++) {
  1640 			m->screen_number = info[i].screen_number;
  1656 			m->screen_number = info[i].screen_number;
  1641 			m->wx = info[i].x_org;
  1657 			m->wx = info[i].x_org;
  1642 			m->wy = info[i].y_org;
  1658 			m->my = m->wy = info[i].y_org;
  1643 			m->ww = info[i].width;
  1659 			m->ww = info[i].width;
  1644 			m->wh = info[i].height;
  1660 			m->mh = m->wh = info[i].height;
  1645 		}
  1661 		}
  1646 		XFree(info);
  1662 		XFree(info);
  1647 	}
  1663 	}
  1648 	else
  1664 	else
  1649 #endif
  1665 #endif
  1650 	/* default monitor setup */
  1666 	/* default monitor setup */
  1651 	{
  1667 	{
  1652 		m->screen_number = 0;
  1668 		m->screen_number = 0;
  1653 		m->wx = sx;
  1669 		m->wx = sx;
  1654 		m->wy = sy;
  1670 		m->my = m->wy = sy;
  1655 		m->ww = sw;
  1671 		m->ww = sw;
  1656 		m->wh = sh;
  1672 		m->mh = m->wh = sh;
  1657 	}
  1673 	}
  1658 
  1674 
  1659 	/* bar geometry setup */
  1675 	/* bar geometry setup */
  1660 	for(m = newmons; m; m = m->next) {
  1676 	for(m = newmons; m; m = m->next) {
  1661 		/* TODO: consider removing the following values from config.h */
  1677 		/* TODO: consider removing the following values from config.h */
  1663 		m->sellt = 0;
  1679 		m->sellt = 0;
  1664 		m->tagset[0] = m->tagset[1] = 1;
  1680 		m->tagset[0] = m->tagset[1] = 1;
  1665 		m->mfact = mfact;
  1681 		m->mfact = mfact;
  1666 		m->showbar = showbar;
  1682 		m->showbar = showbar;
  1667 		m->topbar = topbar;
  1683 		m->topbar = topbar;
  1668 		if(m->showbar) {
  1684 		updatebarpos(m);
  1669 			m->wh -= bh;
       
  1670 			m->by = m->topbar ? m->wy : m->wy + m->wh;
       
  1671 			m->wy = m->topbar ? m->wy + bh : m->wy;
       
  1672 		}
       
  1673 		else
       
  1674 			m->by = -bh;
       
  1675 		/* reassign all clients with same screen number */
  1685 		/* reassign all clients with same screen number */
  1676 		for(c = clients; c; c = c->next)
  1686 		for(c = clients; c; c = c->next)
  1677 			if(c->m->screen_number == m->screen_number)
  1687 			if(c->m->screen_number == m->screen_number)
  1678 				c->m = m;
  1688 				c->m = m;
  1679 	}
  1689 	}