add semi hide bars

This commit is contained in:
Linux User 2022-09-28 15:32:13 +00:00
parent 0a4047f2aa
commit 3f65bea116
5 changed files with 46 additions and 24 deletions

View File

@ -8,6 +8,7 @@ static const unsigned int borderpx = 4;
static const unsigned int gappx = 10; static const unsigned int gappx = 10;
static const unsigned int snap = 32; /* snap pixel */ static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 1; /* 0 means no bar */
static const int showextrabar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */ static const int topbar = 1; /* 0 means bottom bar */
static const char statussep = ';'; static const char statussep = ';';
static const int horizpadbar = 5; static const int horizpadbar = 5;
@ -103,7 +104,8 @@ static Key keys[] = {
{ 0, XF86XK_AudioMute, spawn, {.v = volmute } }, { 0, XF86XK_AudioMute, spawn, {.v = volmute } },
{ SUPERKEY, XK_p, spawn, {.v = dmenucmd } }, { SUPERKEY, XK_p, spawn, {.v = dmenucmd } },
{ SUPERKEY, XK_Return, spawn, {.v = termcmd } }, { SUPERKEY, XK_Return, spawn, {.v = termcmd } },
{ SUPERKEY, XK_b, togglebar, {0} }, { SUPERKEY, XK_b, togglebar, {.i = 1} },
{ SUPERKEY|ShiftMask, XK_b, togglebar, {.i = 2} },
{ ALTKEY, XK_Tab, focusstack, {.i = +1 } }, { ALTKEY, XK_Tab, focusstack, {.i = +1 } },
/* { SUPERKEY, XK_k, focusstack, {.i = -1 } }, */ /* { SUPERKEY, XK_k, focusstack, {.i = -1 } }, */
{ SUPERKEY, XK_i, incnmaster, {.i = +1 } }, { SUPERKEY, XK_i, incnmaster, {.i = +1 } },

View File

@ -7,7 +7,8 @@
static const unsigned int borderpx = 4; static const unsigned int borderpx = 4;
static const unsigned int gappx = 10; static const unsigned int gappx = 10;
static const unsigned int snap = 32; /* snap pixel */ static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 0; /* 0 means no bar */
static const int showextrabar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */ static const int topbar = 1; /* 0 means bottom bar */
static const char statussep = ';'; static const char statussep = ';';
static const int horizpadbar = 5; static const int horizpadbar = 5;
@ -103,7 +104,8 @@ static Key keys[] = {
{ 0, XF86XK_AudioMute, spawn, {.v = volmute } }, { 0, XF86XK_AudioMute, spawn, {.v = volmute } },
{ SUPERKEY, XK_p, spawn, {.v = dmenucmd } }, { SUPERKEY, XK_p, spawn, {.v = dmenucmd } },
{ SUPERKEY, XK_Return, spawn, {.v = termcmd } }, { SUPERKEY, XK_Return, spawn, {.v = termcmd } },
{ SUPERKEY, XK_b, togglebar, {0} }, { SUPERKEY, XK_b, togglebar, {.i = 1} },
{ SUPERKEY|ShiftMask, XK_b, togglebar, {.i = 2} },
{ ALTKEY, XK_Tab, focusstack, {.i = +1 } }, { ALTKEY, XK_Tab, focusstack, {.i = +1 } },
/* { SUPERKEY, XK_k, focusstack, {.i = -1 } }, */ /* { SUPERKEY, XK_k, focusstack, {.i = -1 } }, */
{ SUPERKEY, XK_i, incnmaster, {.i = +1 } }, { SUPERKEY, XK_i, incnmaster, {.i = +1 } },

BIN
dwm

Binary file not shown.

60
dwm.c
View File

@ -125,6 +125,7 @@ struct Monitor {
unsigned int sellt; unsigned int sellt;
unsigned int tagset[2]; unsigned int tagset[2];
int showbar; int showbar;
int showextrabar;
int topbar; int topbar;
Client *clients; Client *clients;
Client *sel; Client *sel;
@ -675,7 +676,8 @@ createmon(void)
m->tagset[0] = m->tagset[1] = 1; m->tagset[0] = m->tagset[1] = 1;
m->mfact = mfact; m->mfact = mfact;
m->nmaster = nmaster; m->nmaster = nmaster;
m->showbar = showbar; m->showbar = showbar;
m->showextrabar = showextrabar;
m->topbar = topbar; m->topbar = topbar;
m->gappx = gappx; m->gappx = gappx;
m->lt[0] = &layouts[0]; m->lt[0] = &layouts[0];
@ -857,13 +859,12 @@ drawbar(Monitor *m)
unsigned int i, occ = 0, urg = 0; unsigned int i, occ = 0, urg = 0;
Client *c; Client *c;
if (!m->showbar) if (m->showbar) {
return; /* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */
/* draw status first so it can be overdrawn by tags later */ tw = m->ww - drawstatusbar(m, bh, 0, stext);
if (m == selmon) { /* status is only drawn on selected monitor */ }
tw = m->ww - drawstatusbar(m, bh, 0, stext); }
}
for (c = m->clients; c; c = c->next) { for (c = m->clients; c; c = c->next) {
occ |= c->tags; occ |= c->tags;
@ -902,12 +903,16 @@ drawbar(Monitor *m)
drw_rect(drw, x, 0, w - 2 * hpb, bh, 1, 1); drw_rect(drw, x, 0, w - 2 * hpb, bh, 1, 1);
} }
drw_map(drw, m->barwin, 0, 0, m->ww, bh); if (m->showbar)
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
if (m->showextrabar) {
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);
}
}
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 void
@ -1670,10 +1675,11 @@ setfullscreen(Client *c, int fullscreen)
void void
setgaps(const Arg *arg) setgaps(const Arg *arg)
{ {
if ((arg->i == 0) || (selmon->gappx + arg->i < 0)) if ((arg->i == 0) || (selmon->gappx + arg->i < 0)) {
selmon->gappx = 0; selmon->gappx = 0;
else } else {
selmon->gappx += arg->i; selmon->gappx += arg->i;
}
arrange(selmon); arrange(selmon);
} }
@ -1881,10 +1887,17 @@ tile(Monitor *m)
void void
togglebar(const Arg *arg) togglebar(const Arg *arg)
{ {
selmon->showbar = !selmon->showbar; if (arg->i == 1 || arg->i == 0) {
updatebarpos(selmon); selmon->showbar = !selmon->showbar;
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + hpb, selmon->by + vpb, selmon->ww - 2 * hpb, bh); updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + hpb, selmon->eby - vpb, selmon->ww - 2 * hpb, bh); XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + hpb, selmon->by + vpb, selmon->ww - 2 * hpb, bh);
}
if (arg->i == 2 || arg->i == 0) {
selmon->showextrabar = !selmon->showextrabar;
updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + hpb, selmon->eby - vpb, selmon->ww - 2 * hpb, bh);
}
arrange(selmon); arrange(selmon);
} }
@ -2049,14 +2062,19 @@ updatebarpos(Monitor *m)
{ {
m->wy = m->my; m->wy = m->my;
m->wh = m->mh; m->wh = m->mh;
m->wh -= bh * m->showbar * 2; m->wh -= bh * m->showbar + bh * m->showextrabar;
m->wy = m->showbar ? m->wy + bh + vpb : m->wy; m->wy = m->showbar ? m->wy + bh + vpb : m->wy;
if (m->showbar) { if (m->showbar && m->showextrabar) {
m->by = m->topbar ? m->wy - gappx - bh : m->wy + m->wh + gappx; 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->eby = m->topbar ? m->wy + m->wh + gappx - vpb * 2 : m->wy - gappx - bh - vpb * 2;
m->wy = topbar ? m->wy : m->wy - vpb * 2; m->wy = topbar ? m->wy : m->wy - vpb * 2;
m->wh = topbar ? m->wh - vpb * 2 : m->wh + vpb * 2; m->wh = topbar ? m->wh - vpb * 2 : m->wh + vpb * 2;
} else if (m->showbar || m->showextrabar) {
m->by = m->topbar ? m->wy - gappx - bh : m->wy + m->wh + gappx;
m->eby = m->topbar ? m->wy + m->wh + gappx - vpb : m->wy - gappx - bh - vpb;
m->wy = topbar ? m->wy : m->wy - vpb;
m->wh = topbar ? m->wh - vpb: m->wh + vpb;
} else { } else {
m->by = -bh - vpb; m->by = -bh - vpb;
m->eby = -bh + vpb; m->eby = -bh + vpb;

BIN
dwm.o

Binary file not shown.