diff options
author | Sam Chudnick <sam@chudnick.com> | 2023-02-19 10:43:09 -0500 |
---|---|---|
committer | Sam Chudnick <sam@chudnick.com> | 2023-02-19 10:43:09 -0500 |
commit | 8499c582ae6b28a846ea7e46d49af0b942585d7b (patch) | |
tree | 1567b7d5122d353c59b929d9f683800122a0db07 | |
parent | dec15f88a4e2dfec7a3b1b49c63e7c32bb74a075 (diff) |
Add barpadding patch
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | config.h | 8 | ||||
-rw-r--r-- | config.mk | 2 | ||||
-rw-r--r-- | dwm.c | 30 |
4 files changed, 28 insertions, 14 deletions
@@ -4,3 +4,5 @@ patches/* | |||
4 | *.orig | 4 | *.orig |
5 | *.rej | 5 | *.rej |
6 | *.diff | 6 | *.diff |
7 | *.swo | ||
8 | *.swp | ||
@@ -5,15 +5,17 @@ | |||
5 | /* appearance */ | 5 | /* appearance */ |
6 | static const unsigned int borderpx = 0; /* border pixel of windows */ | 6 | static const unsigned int borderpx = 0; /* border pixel of windows */ |
7 | static const unsigned int snap = 32; /* snap pixel */ | 7 | static const unsigned int snap = 32; /* snap pixel */ |
8 | static const unsigned int gappih = 20; /* horiz inner gap between windows */ | 8 | static const unsigned int gappih = 10; /* horiz inner gap between windows */ |
9 | static const unsigned int gappiv = 10; /* vert inner gap between windows */ | 9 | static const unsigned int gappiv = 10; /* vert inner gap between windows */ |
10 | static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ | 10 | static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ |
11 | static const unsigned int gappov = 30; /* vert outer gap between windows and screen edge */ | 11 | static const unsigned int gappov = 10; /* vert outer gap between windows and screen edge */ |
12 | static const int swallowfloating = 0; /* 1 means swallow floating windows by default */ | 12 | static const int swallowfloating = 0; /* 1 means swallow floating windows by default */ |
13 | static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ | 13 | static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ |
14 | static const int showbar = 1; /* 0 means no bar */ | 14 | static const int showbar = 1; /* 0 means no bar */ |
15 | static const int topbar = 1; /* 0 means bottom bar */ | 15 | static const int topbar = 1; /* 0 means bottom bar */ |
16 | static const char *fonts[] = { "monospace:size=10"}; | 16 | static const char *fonts[] = { "monospace:size=10"}; |
17 | static const int vertpad = 5; /* vertical padding of bar */ | ||
18 | static const int sidepad = 10; /* horizontal padding of bar */ | ||
17 | static const char dmenufont[] = "monospace:size=10"; | 19 | static const char dmenufont[] = "monospace:size=10"; |
18 | static const char col_gray1[] = "#282828"; | 20 | static const char col_gray1[] = "#282828"; |
19 | static const char col_gray2[] = "#3c3836"; | 21 | static const char col_gray2[] = "#3c3836"; |
@@ -47,7 +49,7 @@ static const Rule rules[] = { | |||
47 | }; | 49 | }; |
48 | 50 | ||
49 | /* layout(s) */ | 51 | /* layout(s) */ |
50 | static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ | 52 | static const float mfact = 0.50; /* factor of master area size [0.05..0.95] */ |
51 | static const int nmaster = 1; /* number of clients in master area */ | 53 | static const int nmaster = 1; /* number of clients in master area */ |
52 | static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ | 54 | static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ |
53 | 55 | ||
@@ -27,7 +27,7 @@ LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-r | |||
27 | # flags | 27 | # flags |
28 | CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} | 28 | CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} |
29 | #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} | 29 | #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} |
30 | CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} | 30 | CFLAGS = -w -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} |
31 | LDFLAGS = ${LIBS} | 31 | LDFLAGS = ${LIBS} |
32 | 32 | ||
33 | # Solaris | 33 | # Solaris |
@@ -263,6 +263,8 @@ static int screen; | |||
263 | static int sw, sh; /* X display screen geometry width, height */ | 263 | static int sw, sh; /* X display screen geometry width, height */ |
264 | static int bh, blw = 0; /* bar geometry */ | 264 | static int bh, blw = 0; /* bar geometry */ |
265 | static int lrpad; /* sum of left and right padding for text */ | 265 | static int lrpad; /* sum of left and right padding for text */ |
266 | static int vp; /* vertical padding for bar */ | ||
267 | static int sp; /* side padding for bar */ | ||
266 | static int (*xerrorxlib)(Display *, XErrorEvent *); | 268 | static int (*xerrorxlib)(Display *, XErrorEvent *); |
267 | static unsigned int numlockmask = 0; | 269 | static unsigned int numlockmask = 0; |
268 | static void (*handler[LASTEvent]) (XEvent *) = { | 270 | static void (*handler[LASTEvent]) (XEvent *) = { |
@@ -663,7 +665,7 @@ configurenotify(XEvent *e) | |||
663 | for (c = m->clients; c; c = c->next) | 665 | for (c = m->clients; c; c = c->next) |
664 | if (c->isfullscreen) | 666 | if (c->isfullscreen) |
665 | resizeclient(c, m->mx, m->my, m->mw, m->mh); | 667 | resizeclient(c, m->mx, m->my, m->mw, m->mh); |
666 | XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); | 668 | XMoveResizeWindow(dpy, m->barwin, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh); |
667 | } | 669 | } |
668 | focus(NULL); | 670 | focus(NULL); |
669 | arrange(NULL); | 671 | arrange(NULL); |
@@ -800,7 +802,7 @@ dirtomon(int dir) | |||
800 | void | 802 | void |
801 | drawbar(Monitor *m) | 803 | drawbar(Monitor *m) |
802 | { | 804 | { |
803 | int x, w, sw = 0; | 805 | int x, w, sw, tw = 0; |
804 | int boxs = drw->fonts->h / 9; | 806 | int boxs = drw->fonts->h / 9; |
805 | int boxw = drw->fonts->h / 6 + 2; | 807 | int boxw = drw->fonts->h / 6 + 2; |
806 | unsigned int i, occ = 0, urg = 0; | 808 | unsigned int i, occ = 0, urg = 0; |
@@ -826,6 +828,11 @@ drawbar(Monitor *m) | |||
826 | drw_text(drw, m->ww - statusw + x, 0, sw, bh, 0, text, 0); | 828 | drw_text(drw, m->ww - statusw + x, 0, sw, bh, 0, text, 0); |
827 | sw = statusw; | 829 | sw = statusw; |
828 | } | 830 | } |
831 | if (m == selmon) { /* status is only drawn on selected monitor */ | ||
832 | drw_setscheme(drw, scheme[SchemeNorm]); | ||
833 | tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ | ||
834 | drw_text(drw, m->ww - tw - 2 * sp, 0, tw, bh, 0, stext, 0); | ||
835 | } | ||
829 | 836 | ||
830 | for (c = m->clients; c; c = c->next) { | 837 | for (c = m->clients; c; c = c->next) { |
831 | occ |= c->tags; | 838 | occ |= c->tags; |
@@ -855,12 +862,12 @@ drawbar(Monitor *m) | |||
855 | if ((w = m->ww - sw - x) > bh) { | 862 | if ((w = m->ww - sw - x) > bh) { |
856 | if (m->sel) { | 863 | if (m->sel) { |
857 | drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); | 864 | drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); |
858 | drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); | 865 | drw_text(drw, x, 0, w - 2 * sp, bh, lrpad / 2, m->sel->name, 0); |
859 | if (m->sel->isfloating) | 866 | if (m->sel->isfloating) |
860 | drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); | 867 | drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); |
861 | } else { | 868 | } else { |
862 | drw_setscheme(drw, scheme[SchemeNorm]); | 869 | drw_setscheme(drw, scheme[SchemeNorm]); |
863 | drw_rect(drw, x, 0, w, bh, 1, 1); | 870 | drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1); |
864 | } | 871 | } |
865 | } | 872 | } |
866 | drw_map(drw, m->barwin, 0, 0, m->ww, bh); | 873 | drw_map(drw, m->barwin, 0, 0, m->ww, bh); |
@@ -1719,7 +1726,10 @@ setup(void) | |||
1719 | die("no fonts could be loaded."); | 1726 | die("no fonts could be loaded."); |
1720 | lrpad = drw->fonts->h; | 1727 | lrpad = drw->fonts->h; |
1721 | bh = drw->fonts->h + 2; | 1728 | bh = drw->fonts->h + 2; |
1729 | sp = sidepad; | ||
1730 | vp = (topbar == 1) ? vertpad : - vertpad; | ||
1722 | updategeom(); | 1731 | updategeom(); |
1732 | |||
1723 | /* init atoms */ | 1733 | /* init atoms */ |
1724 | utf8string = XInternAtom(dpy, "UTF8_STRING", False); | 1734 | utf8string = XInternAtom(dpy, "UTF8_STRING", False); |
1725 | wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); | 1735 | wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); |
@@ -1873,7 +1883,7 @@ togglebar(const Arg *arg) | |||
1873 | { | 1883 | { |
1874 | selmon->showbar = !selmon->showbar; | 1884 | selmon->showbar = !selmon->showbar; |
1875 | updatebarpos(selmon); | 1885 | updatebarpos(selmon); |
1876 | XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); | 1886 | XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh); |
1877 | arrange(selmon); | 1887 | arrange(selmon); |
1878 | } | 1888 | } |
1879 | 1889 | ||
@@ -2001,7 +2011,7 @@ updatebars(void) | |||
2001 | for (m = mons; m; m = m->next) { | 2011 | for (m = mons; m; m = m->next) { |
2002 | if (m->barwin) | 2012 | if (m->barwin) |
2003 | continue; | 2013 | continue; |
2004 | m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen), | 2014 | m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh, 0, DefaultDepth(dpy, screen), |
2005 | CopyFromParent, DefaultVisual(dpy, screen), | 2015 | CopyFromParent, DefaultVisual(dpy, screen), |
2006 | CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); | 2016 | CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); |
2007 | XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); | 2017 | XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); |
@@ -2016,11 +2026,11 @@ updatebarpos(Monitor *m) | |||
2016 | m->wy = m->my; | 2026 | m->wy = m->my; |
2017 | m->wh = m->mh; | 2027 | m->wh = m->mh; |
2018 | if (m->showbar) { | 2028 | if (m->showbar) { |
2019 | m->wh -= bh; | 2029 | m->wh = m->wh - vertpad - bh; |
2020 | m->by = m->topbar ? m->wy : m->wy + m->wh; | 2030 | m->by = m->topbar ? m->wy : m->wy + m->wh + vertpad; |
2021 | m->wy = m->topbar ? m->wy + bh : m->wy; | 2031 | m->wy = m->topbar ? m->wy + bh + vp : m->wy; |
2022 | } else | 2032 | } else |
2023 | m->by = -bh; | 2033 | m->by = -bh - vp; |
2024 | } | 2034 | } |
2025 | 2035 | ||
2026 | void | 2036 | void |