siduck76 4 лет назад
Родитель
Сommit
3e5d97e928
6 измененных файлов с 38 добавлено и 30 удалено
  1. 1 0
      .gitignore
  2. 4 2
      chadwm/config.h
  3. BIN
      chadwm/dwm
  4. 33 26
      chadwm/dwm.c
  5. BIN
      chadwm/dwm.o
  6. 0 2
      scripts/dwm-xbps

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+chadwm/dwm 

+ 4 - 2
chadwm/config.h

@@ -17,9 +17,11 @@ static const int systraypinningfailfirst = 1;   /* 1: if pinning fails,display s
 static const int showsystray        = 1;     /* 0 means no systray */
 static const int showbar            = 1;        /* 0 means no bar */
 static const int topbar             = 1;        /* 0 means bottom bar */
-static const int horizpadbar        = 8;
+static const int vertpad            = 10;       /* vertical padding of bar */
+static const int sidepad            = 10;       /* horizontal padding of bar */
+static const int horizpadbar        = 5;
 static const int vertpadbar         = 11;
-static const char *fonts[]          = { "JetBrainsMono Nerd Font:style:bold:size=10",
+static const char *fonts[]          = { "JetBrainsMono Nerd Font:style:medium:size=10",
                                 	"Material Design Icons-Regular:size=10",
 };
 static const char dmenufont[]       = "monospace:size=10";


+ 33 - 26
chadwm/dwm.c

@@ -292,6 +292,8 @@ static int screen;
 static int sw, sh;           /* X display screen geometry width, height */
 static int bh, blw = 0;      /* bar geometry */
 static int lrpad;            /* sum of left and right padding for text */
+static int vp;               /* vertical padding for bar */
+static int sp;               /* side padding for bar */
 static int (*xerrorxlib)(Display *, XErrorEvent *);
 static unsigned int numlockmask = 0;
 static void (*handler[LASTEvent]) (XEvent *) = {
@@ -868,8 +870,8 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
 	text = p;
 
         w += horizpadbar;
-	ret = x = m->ww - borderpx - w;
-        x = m->ww - borderpx - w - getsystraywidth();
+       	ret = x = m->ww - sp * 2 - borderpx - w;
+        x = m->ww - sp * 2 - borderpx - w - getsystraywidth();
 
 	drw_setscheme(drw, scheme[LENGTH(colors)]);
 	drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
@@ -1242,14 +1244,14 @@ drawbar(Monitor *m)
 {
   	int x, y = borderpx, w, sw = 0, stw = 0;
 	int th = bh - borderpx * 2;
-	int mw = m->ww - borderpx * 2;
+        int mw = m->ww - sp * 2 - borderpx * 2;
 	int boxs = drw->fonts->h / 9;
 	int boxw = drw->fonts->h / 6 + 2;
 	unsigned int i, occ = 0, urg = 0;
 	Client *c;
 
         XSetForeground(drw->dpy, drw->gc, clrborder.pixel);
-	XFillRectangle(drw->dpy, drw->drawable, drw->gc, 0, 0, m->ww, bh);
+	XFillRectangle(drw->dpy, drw->drawable, drw->gc, 0, 0, m->ww - sp * 2, bh);
 
        	if(showsystray && m == systraytomon(m))
 
@@ -1281,14 +1283,14 @@ drawbar(Monitor *m)
 	drw_setscheme(drw, scheme[SchemeNorm]);
 	x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
 
-        if ((w = m->ww - sw - stw - x) > bh) {
+        if ((w = mw + sp * 2 - sw - stw - x) > th) {
 		if (m->sel) {
 			drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
 			if (m->sel->isfloating)
 				drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
 		} else {
 			drw_setscheme(drw, scheme[SchemeNorm]);
-			drw_rect(drw, x, 0, w, bh, 1, 1);
+                        drw_rect(drw, x, y, w - sp * 2, th, 1, 1);
 		}
 	}
 	drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
@@ -1900,10 +1902,10 @@ resize(Client *c, int x, int y, int w, int h, int interact)
 
 void
 resizebarwin(Monitor *m) {
-	unsigned int w = m->ww;
+        unsigned int w = m->ww - 2 * sp;
 	if (showsystray && m == systraytomon(m))
 		w -= getsystraywidth();
-	XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, w, bh);
+        XMoveResizeWindow(dpy, m->barwin, m->wx + sp, m->by + vp, w, bh);
 }
 
 void
@@ -2263,6 +2265,8 @@ setup(void)
 	lrpad = drw->fonts->h;
         bh = drw->fonts->h + 2 + vertpadbar + borderpx * 2;
 	updategeom();
+        sp = sidepad;
+	vp = (topbar == 1) ? vertpad : - vertpad;
 	/* init atoms */
 	utf8string = XInternAtom(dpy, "UTF8_STRING", False);
 	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
@@ -2302,6 +2306,7 @@ setup(void)
 	/* init bars */
 	updatebars();
 	updatestatus();
+        updatebarpos(selmon);
 	/* supporting window for NetWMCheck */
 	wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0);
 	XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32,
@@ -2556,7 +2561,7 @@ updatebars(void)
 		w = m->ww;
 		if (showsystray && m == systraytomon(m))
 			w -= getsystraywidth();
-		m->barwin = XCreateWindow(dpy, root, m->wx, m->by, w, bh, 0, DefaultDepth(dpy, screen),
+                m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, w - 2 * sp, bh, 0, DefaultDepth(dpy, screen),
 				CopyFromParent, DefaultVisual(dpy, screen),
 				CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
 		XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
@@ -2573,11 +2578,11 @@ updatebarpos(Monitor *m)
 	m->wy = m->my;
 	m->wh = m->mh;
 	if (m->showbar) {
-		m->wh -= bh;
-		m->by = m->topbar ? m->wy : m->wy + m->wh;
-		m->wy = m->topbar ? m->wy + bh : m->wy;
+                m->wh = m->wh - vertpad - bh;
+		m->by = m->topbar ? m->wy : m->wy + m->wh + vertpad;
+		m->wy = m->topbar ? m->wy + bh + vp : m->wy;
 	} else
-		m->by = -bh;
+          	m->by = -bh - vp;
 }
 
 void
@@ -2743,22 +2748,24 @@ updatestatus(void)
 void
 updatesystrayicongeom(Client *i, int w, int h)
 {
+        int rh = bh - vertpadbar;
 	if (i) {
-		i->h = bh;
+		i->h = rh;
 		if (w == h)
-			i->w = bh;
-		else if (h == bh)
+			i->w = rh;
+		else if (h == rh)
 			i->w = w;
 		else
-			i->w = (int) ((float)bh * ((float)w / (float)h));
+                  	i->w = (int) ((float)rh * ((float)w / (float)h));
+		i->y = i->y + vertpadbar / 2;
 		applysizehints(i, &(i->x), &(i->y), &(i->w), &(i->h), False);
 		/* force icons into the systray dimensions if they don't want to */
-		if (i->h > bh) {
+		if (i->h > rh) {
 			if (i->w == i->h)
-				i->w = bh;
+				i->w = rh;
 			else
-				i->w = (int) ((float)bh * ((float)i->w / (float)i->h));
-			i->h = bh;
+				i->w = (int) ((float)rh * ((float)i->w / (float)i->h));
+			i->h = rh;
 		}
 	}
 }
@@ -2798,7 +2805,7 @@ updatesystray(void)
 	XWindowChanges wc;
 	Client *i;
 	Monitor *m = systraytomon(NULL);
-	unsigned int x = m->mx + m->mw;
+	unsigned int x = m->mx + m->mw - sp;
 	unsigned int w = 1;
 
 	if (!showsystray)
@@ -2807,7 +2814,7 @@ updatesystray(void)
 		/* init systray */
 		if (!(systray = (Systray *)calloc(1, sizeof(Systray))))
 			die("fatal: could not malloc() %u bytes\n", sizeof(Systray));
-		systray->win = XCreateSimpleWindow(dpy, root, x, m->by, w, bh, 0, 0, scheme[SchemeSel][ColBg].pixel);
+                systray->win = XCreateSimpleWindow(dpy, root, x, m->by + vp, w, bh, 0, 0, scheme[SchemeSel][ColBg].pixel);
 		wa.event_mask        = ButtonPressMask | ExposureMask;
 		wa.override_redirect = True;
 		wa.background_pixel  = scheme[SchemeNorm][ColBg].pixel;
@@ -2835,15 +2842,15 @@ updatesystray(void)
 		XMapRaised(dpy, i->win);
 		w += systrayspacing;
 		i->x = w;
-		XMoveResizeWindow(dpy, i->win, i->x, 0, i->w, i->h);
+               XMoveResizeWindow(dpy, i->win, i->x, vertpadbar / 2, i->w, i->h);
 		w += i->w;
 		if (i->mon != m)
 			i->mon = m;
 	}
 	w = w ? w + systrayspacing : 1;
 	x -= w;
-	XMoveResizeWindow(dpy, systray->win, x, m->by, w, bh);
-	wc.x = x; wc.y = m->by; wc.width = w; wc.height = bh;
+       	XMoveResizeWindow(dpy, systray->win, x, m->by + vp, w, bh);
+	wc.x = x; wc.y = m->by + vp; wc.width = w; wc.height = bh;
 	wc.stack_mode = Above; wc.sibling = m->barwin;
 	XConfigureWindow(dpy, systray->win, CWX|CWY|CWWidth|CWHeight|CWSibling|CWStackMode, &wc);
 	XMapWindow(dpy, systray->win);


+ 0 - 2
scripts/dwm-xbps

@@ -4,5 +4,3 @@ icon=""
 
 printf "^c#94af7d^ $icon ^d^%s"
 printf "^c#94af7d^"
-
-exit 0