added under bar
This commit is contained in:
		| @ -9,6 +9,7 @@ static const unsigned int gappx     = 10; | ||||
| static const unsigned int snap      = 32;       /* snap pixel */ | ||||
| static const int showbar            = 1;        /* 0 means no bar */ | ||||
| static const int topbar             = 1;        /* 0 means bottom bar */ | ||||
| static const char statussep         = ';'; | ||||
| static const int horizpadbar        = 5; | ||||
| static const int vertpadbar         = 8; | ||||
| static const int vertpadstat        = 0; | ||||
| @ -34,10 +35,12 @@ static const char *tags[] = { "", "", "3", "", "5", "6", "7", "8", " | ||||
|  | ||||
| /* launcher commands (They must be NULL terminated) */ | ||||
| static const char* bhev[] = { "firefox", "bhev.ru", NULL }; | ||||
| static const char* youtube[] = { "firefox", "youtube.com", NULL }; | ||||
|  | ||||
| static const Launcher launchers[] = { | ||||
|     /* command      name to display */ | ||||
| 	{ bhev,         "" }, | ||||
| 	{ youtube,      "" }, | ||||
| }; | ||||
|  | ||||
| static const Rule rules[] = { | ||||
|  | ||||
							
								
								
									
										3
									
								
								config.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								config.h
									
									
									
									
									
								
							| @ -9,6 +9,7 @@ static const unsigned int gappx     = 10; | ||||
| static const unsigned int snap      = 32;       /* snap pixel */ | ||||
| static const int showbar            = 1;        /* 0 means no bar */ | ||||
| static const int topbar             = 1;        /* 0 means bottom bar */ | ||||
| static const char statussep         = ';'; | ||||
| static const int horizpadbar        = 5; | ||||
| static const int vertpadbar         = 8; | ||||
| static const int vertpadstat        = 0; | ||||
| @ -34,10 +35,12 @@ static const char *tags[] = { "", "", "3", "", "5", "6", "7", "8", " | ||||
|  | ||||
| /* launcher commands (They must be NULL terminated) */ | ||||
| static const char* bhev[] = { "firefox", "bhev.ru", NULL }; | ||||
| static const char* youtube[] = { "firefox", "youtube.com", NULL }; | ||||
|  | ||||
| static const Launcher launchers[] = { | ||||
|     /* command      name to display */ | ||||
| 	{ bhev,         "" }, | ||||
| 	{ youtube,      "" }, | ||||
| }; | ||||
|  | ||||
| static const Rule rules[] = { | ||||
|  | ||||
							
								
								
									
										78
									
								
								dwm.c
									
									
									
									
									
								
							
							
						
						
									
										78
									
								
								dwm.c
									
									
									
									
									
								
							| @ -117,6 +117,7 @@ struct Monitor { | ||||
| 	int nmaster; | ||||
| 	int num; | ||||
| 	int by;               /* bar geometry */ | ||||
| 	int eby;               /* bar geometry */ | ||||
| 	int mx, my, mw, mh;   /* screen size */ | ||||
| 	int wx, wy, ww, wh;   /* window area  */ | ||||
|     int gappx; | ||||
| @ -130,6 +131,7 @@ struct Monitor { | ||||
| 	Client *stack; | ||||
| 	Monitor *next; | ||||
| 	Window barwin; | ||||
| 	Window extrabarwin; | ||||
| 	const Layout *lt[2]; | ||||
| }; | ||||
|  | ||||
| @ -169,6 +171,7 @@ static void detachstack(Client *c); | ||||
| static Monitor *dirtomon(int dir); | ||||
| static void drawbar(Monitor *m); | ||||
| static void drawbars(void); | ||||
| static int drawstatusbar(Monitor *m, int bh, int extra, char* text); | ||||
| static void enternotify(XEvent *e); | ||||
| static void expose(XEvent *e); | ||||
| static void focus(Client *c); | ||||
| @ -247,6 +250,7 @@ static void zoom(const Arg *arg); | ||||
| /* variables */ | ||||
| static const char broken[] = "broken"; | ||||
| static char stext[1024]; | ||||
| static char estext[1024]; | ||||
| static int screen; | ||||
| static int sw, sh;           /* X display screen geometry width, height */ | ||||
| static int bh, blw = 0;      /* bar geometry */ | ||||
| @ -537,7 +541,9 @@ cleanupmon(Monitor *mon) | ||||
| 		m->next = mon->next; | ||||
| 	} | ||||
| 	XUnmapWindow(dpy, mon->barwin); | ||||
| 	XUnmapWindow(dpy, mon->extrabarwin); | ||||
| 	XDestroyWindow(dpy, mon->barwin); | ||||
| 	XDestroyWindow(dpy, mon->extrabarwin); | ||||
| 	free(mon); | ||||
| } | ||||
|  | ||||
| @ -600,6 +606,7 @@ configurenotify(XEvent *e) | ||||
| 					if (c->isfullscreen) | ||||
| 						resizeclient(c, m->mx, m->my, m->mw, m->mh); | ||||
| 				XMoveResizeWindow(dpy, m->barwin,      m->wx + hpb, m->by + vpb,  m->ww - 2 * hpb, bh); | ||||
| 				XMoveResizeWindow(dpy, m->extrabarwin, m->wx + hpb, m->eby - vpb, m->ww - 2 * hpb, bh); | ||||
| 			} | ||||
| 			focus(NULL); | ||||
| 			arrange(NULL); | ||||
| @ -726,7 +733,7 @@ dirtomon(int dir) | ||||
| } | ||||
|  | ||||
| int | ||||
| drawstatusbar(Monitor *m, int bh, char* stext) { | ||||
| drawstatusbar(Monitor *m, int bh, int extra, char* stext) { | ||||
|     int ret, i, w, x, len; | ||||
|     short isCode = 0; | ||||
|     char *text; | ||||
| @ -763,9 +770,18 @@ drawstatusbar(Monitor *m, int bh, char* stext) { | ||||
|         isCode = 0; | ||||
|     text = p; | ||||
|  | ||||
|     if (extra) { | ||||
|         w = m->ww; | ||||
| //        w = m->ww - w - 2 * hpb; | ||||
|         ret = x = 1; | ||||
|     } else { | ||||
| //        w += 2; /* 1px padding on both sides */ | ||||
|     ret = m->ww - w; | ||||
|     x = m->ww - w - 2 * hpb; | ||||
| //        ret = x = m->ww - w; | ||||
|         ret = x = m->ww - w - 2 * hpb; | ||||
|     } | ||||
|  | ||||
| //    ret = m->ww - w; | ||||
| //    x = m->ww - w - 2 * hpb; | ||||
|  | ||||
|     drw_setscheme(drw, scheme[LENGTH(colors)]); | ||||
|     drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; | ||||
| @ -846,7 +862,7 @@ drawbar(Monitor *m) | ||||
|  | ||||
| 	/* draw status first so it can be overdrawn by tags later */ | ||||
| 	if (m == selmon) { /* status is only drawn on selected monitor */ | ||||
|         	tw = m->ww - drawstatusbar(m, bh, stext); | ||||
|         	tw = m->ww - drawstatusbar(m, bh, 0, stext); | ||||
| 	} | ||||
|  | ||||
| 	for (c = m->clients; c; c = c->next) { | ||||
| @ -885,7 +901,13 @@ drawbar(Monitor *m) | ||||
| 		drw_setscheme(drw, scheme[SchemeNorm]); | ||||
| 		drw_rect(drw, x, 0, w - 2 * hpb, bh, 1, 1); | ||||
| 	} | ||||
|  | ||||
| 	drw_map(drw, m->barwin, 0, 0, m->ww, bh); | ||||
|  | ||||
|     if (m == selmon) { /* extra status is only drawn on selected monitor */ | ||||
| 		sw = drawstatusbar(m, bh, 1, estext); | ||||
| 		drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void | ||||
| @ -1862,6 +1884,7 @@ togglebar(const Arg *arg) | ||||
| 	selmon->showbar = !selmon->showbar; | ||||
| 	updatebarpos(selmon); | ||||
| 	XMoveResizeWindow(dpy, selmon->barwin,      selmon->wx + hpb, selmon->by + vpb,  selmon->ww - 2 * hpb, bh); | ||||
| 	XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + hpb, selmon->eby - vpb, selmon->ww - 2 * hpb, bh); | ||||
| 	arrange(selmon); | ||||
| } | ||||
|  | ||||
| @ -2002,8 +2025,7 @@ updatebars(void) | ||||
| 	}; | ||||
| 	XClassHint ch = {"dwm", "dwm"}; | ||||
| 	for (m = mons; m; m = m->next) { | ||||
| 		if (m->barwin) | ||||
| 			continue; | ||||
| 		if (!m->barwin) { | ||||
|     		m->barwin = XCreateWindow(dpy, root, m->wx + hpb, m->by + vpb, m->ww - 2 * hpb, bh, 0, DefaultDepth(dpy, screen), | ||||
| 	    			CopyFromParent, DefaultVisual(dpy, screen), | ||||
| 		    		CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); | ||||
| @ -2011,19 +2033,35 @@ updatebars(void) | ||||
| 		    XMapRaised(dpy, m->barwin); | ||||
| 		    XSetClassHint(dpy, m->barwin, &ch); | ||||
|         } | ||||
| 		if (!m->extrabarwin) { | ||||
|     		m->extrabarwin = XCreateWindow(dpy, root, m->wx + hpb, m->eby - vpb, m->ww - 2 * hpb, bh, 0, DefaultDepth(dpy, screen), | ||||
| 	    			CopyFromParent, DefaultVisual(dpy, screen), | ||||
| 		    		CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); | ||||
| 		    XDefineCursor(dpy, m->extrabarwin, cursor[CurNormal]->cursor); | ||||
| 		    XMapRaised(dpy, m->extrabarwin); | ||||
| 		    XSetClassHint(dpy, m->extrabarwin, &ch); | ||||
|         } | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void | ||||
| updatebarpos(Monitor *m) | ||||
| { | ||||
| 	m->wy = m->my; | ||||
| 	m->wh = m->mh; | ||||
| 	m->wy = m->my; // no | ||||
| 	m->wh = m->mh; // no | ||||
|     m->wh -= bh * m->showbar * 2; // no | ||||
|    	m->wy = m->showbar ? m->wy + bh + vpb : m->wy; // no | ||||
|  | ||||
| 	if (m->showbar) { | ||||
| 		m->wh = m->wh - gappx - bh; | ||||
| 		m->by = m->topbar ? m->wy : m->wy + m->wh + gappx; | ||||
| 		m->wy = m->topbar ? m->wy + bh + vpb : m->wy; | ||||
| 	} else | ||||
| //		m->wh = m->wh - gappx - bh; | ||||
| 		m->by  = m->topbar ? m->wy - gappx - bh : m->wy + m->wh + gappx; | ||||
|     	m->eby = m->topbar ? m->wy + m->wh + gappx - vpb * 2 : m->wy - gappx - bh - vpb * 2; | ||||
|         m->wh -= vpb * 2; | ||||
| //		m->wy = m->topbar ? m->wy : m->wy; | ||||
| 	} else { | ||||
| 		m->by  = -bh - vpb; | ||||
| 		m->eby = -bh + vpb; | ||||
|     } | ||||
| } | ||||
|  | ||||
| void | ||||
| @ -2181,8 +2219,20 @@ updatesizehints(Client *c) | ||||
| void | ||||
| updatestatus(void) | ||||
| { | ||||
| 	if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) | ||||
|     char text[2048]; | ||||
| 	if (!gettextprop(root, XA_WM_NAME, text, sizeof(text))) { | ||||
| 		strcpy(stext, "dwm-"VERSION); | ||||
|         estext[0] = '\0'; | ||||
| 	} else { | ||||
| 		char *e = strchr(text, statussep); | ||||
| 		if (e) { | ||||
| 			*e = '\0'; e++; | ||||
| 			strncpy(estext, e, sizeof(estext) - 1); | ||||
| 		} else { | ||||
| 			estext[0] = '\0'; | ||||
| 		} | ||||
| 		strncpy(stext, text, sizeof(stext) - 1); | ||||
| 	} | ||||
| 	drawbar(selmon); | ||||
| } | ||||
|  | ||||
| @ -2282,7 +2332,7 @@ wintomon(Window w) | ||||
| 	if (w == root && getrootptr(&x, &y)) | ||||
| 		return recttomon(x, y, 1, 1); | ||||
| 	for (m = mons; m; m = m->next) | ||||
| 		if (w == m->barwin) | ||||
| 		if (w == m->barwin || w == m->extrabarwin) | ||||
| 			return m; | ||||
| 	if ((c = wintoclient(w))) | ||||
| 		return c->mon; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Linux User
					Linux User