Add powerlines for tags, might add for status too, but i don't think
it's necessary
This commit is contained in:
parent
359dc8c73c
commit
1e37ced222
|
@ -323,6 +323,10 @@
|
|||
!!
|
||||
- speedwm.hideemptytags: 1
|
||||
!!
|
||||
!! Hide tag powerlines. If set to 0, the powerlines (arrows) will be printed over the tags. Otherwise they will be hidden just like dwm. (1/0)
|
||||
!!
|
||||
- speedwm.hidetagpowerline: 1
|
||||
!!
|
||||
!! Hide sticky window indicator. If set to 0, the sticky window indicator will be drawn. Otherwise it will be hidden (1/0)
|
||||
!!
|
||||
- speedwm.hidesticky: 0
|
||||
|
|
41
drw.c
41
drw.c
|
@ -19,6 +19,7 @@ static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0}
|
|||
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
||||
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
||||
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
||||
Clr transcheme[3];
|
||||
unsigned int ew;
|
||||
|
||||
static long
|
||||
|
@ -108,6 +109,46 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash)
|
||||
{
|
||||
if (!drw || !drw->scheme)
|
||||
return;
|
||||
|
||||
/* direction=1 draws right arrow */
|
||||
x = direction ? x : x + w;
|
||||
w = direction ? w : -w;
|
||||
/* slash=1 draws slash instead of arrow */
|
||||
unsigned int hh = slash ? (direction ? 0 : h) : h/2;
|
||||
|
||||
XPoint points[] = {
|
||||
{x , y },
|
||||
{x + w, y + hh },
|
||||
{x , y + h },
|
||||
};
|
||||
|
||||
XPoint bg[] = {
|
||||
{x , y },
|
||||
{x + w, y },
|
||||
{x + w, y + h},
|
||||
{x , y + h},
|
||||
};
|
||||
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBg].pixel);
|
||||
XFillPolygon(drw->dpy, drw->drawable, drw->gc, bg, 4, Convex, CoordModeOrigin);
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColFg].pixel);
|
||||
XFillPolygon(drw->dpy, drw->drawable, drw->gc, points, 3, Nonconvex, CoordModeOrigin);
|
||||
}
|
||||
|
||||
void
|
||||
drw_settrans(Drw *drw, Clr *psc, Clr *nsc)
|
||||
{
|
||||
if (drw) {
|
||||
transcheme[0] = psc[ColBg]; transcheme[1] = nsc[ColBg]; transcheme[2] = psc[ColBorder];
|
||||
drw->scheme = transcheme;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
drw_free(Drw *drw)
|
||||
{
|
||||
|
|
2
drw.h
2
drw.h
|
@ -56,6 +56,7 @@ void drw_cur_free(Drw *drw, Cur *cursor);
|
|||
/* Drawing context manipulation */
|
||||
void drw_setfontset(Drw *drw, Fnt *set);
|
||||
void drw_setscheme(Drw *drw, Clr *scm);
|
||||
void drw_settrans(Drw *drw, Clr *psc, Clr *nsc);
|
||||
|
||||
#if USEWINICON
|
||||
Picture drw_picture_create_resized(Drw *drw, char *src, unsigned int src_w, unsigned int src_h, unsigned int dst_w, unsigned int dst_h);
|
||||
|
@ -65,6 +66,7 @@ Picture drw_picture_create_resized(Drw *drw, char *src, unsigned int src_w, unsi
|
|||
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
|
||||
void drw_polygon(Drw *drw, int x, int y, int ow, int oh, int sw, int sh, const XPoint *points, int npoints, int shape, int filled);
|
||||
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
|
||||
void drw_arrow(Drw* drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash);
|
||||
#if USEWINICON
|
||||
void drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic);
|
||||
#endif
|
||||
|
|
|
@ -207,6 +207,7 @@ static int hidestatus = 0; /* Hide status bar (1) or sho
|
|||
static int hideicon = 0; /* Hide icon (1) or show (0) */
|
||||
static int hidetags = 0; /* Hide status bar (1) or show (0) */
|
||||
static int hideemptytags = 1; /* Hide empty tags (1) or show (0) */
|
||||
static int hidetagpowerline = 1; /* Hide tag powerline (1) or show (0) */
|
||||
static int hidefloating = 0; /* Hide floating indicator (1) or show (0) */
|
||||
static int hidesticky = 0; /* Hide sticky indicator (1) or show (0) */
|
||||
|
||||
|
|
145
speedwm.c
145
speedwm.c
|
@ -373,6 +373,7 @@ static void dragmfact(const Arg *arg);
|
|||
#endif
|
||||
static void drawbar(Monitor *m);
|
||||
static void drawbars(void);
|
||||
static int drawarrows(Monitor *m);
|
||||
#if USEROUNDCORNERS
|
||||
static void drawroundedcorners(Client *c);
|
||||
#endif
|
||||
|
@ -636,7 +637,8 @@ static char lastbutton[] = "-";
|
|||
static int screen;
|
||||
static int tw, sh; /* X display screen geometry width, height */
|
||||
static int bh; /* bar geometry */
|
||||
// NOTE: Implemented https://git.suckless.org/dwm/commit/5799dd1fca6576b662d299e210cd5933b29d502d.html
|
||||
static int plw; /* powerline geometry */
|
||||
/* implemented https://git.suckless.org/dwm/commit/5799dd1fca6576b662d299e210cd5933b29d502d.html */
|
||||
static int unmanaged = 0; /* whether the window manager should manage the new window or not */
|
||||
static int lrpad; /* sum of left and right padding for text */
|
||||
static int vp; /* vertical padding for bar */
|
||||
|
@ -1132,24 +1134,32 @@ buttonpress(XEvent *e)
|
|||
focus(NULL);
|
||||
}
|
||||
if (ev->window == selmon->barwin) {
|
||||
i = x = occ = 0;
|
||||
|
||||
/* powerline */
|
||||
if (!hidetagpowerline) {
|
||||
i = 0; x = plw; occ = 0;
|
||||
} else {
|
||||
i = x = occ = 0;
|
||||
}
|
||||
|
||||
/* powerline */
|
||||
if (!hidetagpowerline)
|
||||
x = plw;
|
||||
|
||||
/* Bitmask of occupied tags */
|
||||
for (c = m->clients; c; c = c->next)
|
||||
occ |= c->tags;
|
||||
|
||||
if (layoutposition) {
|
||||
if (layoutposition && !hidelayout) {
|
||||
x += TEXTW(m->ltsymbol);
|
||||
} if (ev->x < x && layoutposition && !selmon->isreset) {
|
||||
click = ClkLtSymbol; // left layout
|
||||
} if (ev->x < x && layoutposition && !selmon->isreset && !hidelayout) {
|
||||
click = ClkLtSymbol; /* left layout */
|
||||
} else {
|
||||
do {
|
||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i) && hideemptytags)
|
||||
continue;
|
||||
if (!hidetags && hideemptytags)
|
||||
x += TEXTW(occ & 1 << i ? usedtags[i] : tags[i]);
|
||||
else if (!hidetags && !hideemptytags)
|
||||
x += TEXTW(occ & 1 << i ? usedtags[i] : tags[i]);
|
||||
|
||||
x += TEXTW(occ & 1 << i ? usedtags[i] : tags[i]) + plw;
|
||||
} while (ev->x >= x && ++i < LENGTH(tags));
|
||||
if (i < LENGTH(tags) && !hidetags) {
|
||||
click = ClkTagBar;
|
||||
|
@ -1191,7 +1201,6 @@ buttonpress(XEvent *e)
|
|||
ch = text[i];
|
||||
text[i] = '\0';
|
||||
x += statuslength(text);
|
||||
//x += TEXTW(text) - lrpad - 2;
|
||||
text[i] = ch;
|
||||
text += i+1;
|
||||
i = -1;
|
||||
|
@ -1202,7 +1211,7 @@ buttonpress(XEvent *e)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (!layoutposition) {
|
||||
if (!layoutposition && !hidelayout) {
|
||||
x += TEXTW(m->ltsymbol); // Left layout does not need this
|
||||
}
|
||||
|
||||
|
@ -1989,6 +1998,8 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
|
|||
}
|
||||
}
|
||||
|
||||
drw_setscheme(drw, scheme[SchemeStatus]);
|
||||
|
||||
if (!isCode) {
|
||||
w = TEXTW(text) - lrpad;
|
||||
drw_text(drw, x, 0, w, bh, 0, text, 0);
|
||||
|
@ -1996,6 +2007,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
|
|||
}
|
||||
|
||||
drw_setscheme(drw, scheme[SchemeStatus]);
|
||||
|
||||
free(p);
|
||||
|
||||
return ret;
|
||||
|
@ -2153,15 +2165,23 @@ void
|
|||
drawbar(Monitor *m)
|
||||
{
|
||||
int x = 0, w = 0, tw = 0, scm;
|
||||
#if USESYSTRAY
|
||||
int stw = 0;
|
||||
#endif
|
||||
int stw = 0; /* systray width */
|
||||
unsigned int i, occ = 0, urg = 0, n = 0;
|
||||
|
||||
/* powerline */
|
||||
int wt;
|
||||
Clr *prevscheme, *nxtscheme; /* powerline schemes */
|
||||
|
||||
if (!hidetagpowerline)
|
||||
plw = drw->fonts->h / 2 + 1;
|
||||
|
||||
/* indicators */
|
||||
int boxs = drw->fonts->h / 9;
|
||||
int boxw = drw->fonts->h / 6 + 2;
|
||||
unsigned int i, occ = 0, urg = 0, n = 0;
|
||||
#if LAYOUT_MONOCLE
|
||||
|
||||
/* monocle layout */
|
||||
unsigned int s = 0, a = 0;
|
||||
#endif
|
||||
|
||||
const char *tagtext;
|
||||
Client *c;
|
||||
|
||||
|
@ -2204,6 +2224,7 @@ resizebarwin(m);
|
|||
|
||||
}
|
||||
|
||||
/* urgent tags */
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (ISVISIBLE(c))
|
||||
n++;
|
||||
|
@ -2212,45 +2233,68 @@ resizebarwin(m);
|
|||
urg |= c->tags;
|
||||
}
|
||||
|
||||
/* Draw the layout bar on the left if layoutposition = 1 */
|
||||
/* If colorlayoutnorm = 0, draw using SchemeLayout */
|
||||
/* draw the layout bar on the left if layoutposition = 1 and we're not hiding the layout */
|
||||
if (layoutposition && !hidelayout) {
|
||||
w = TEXTW(m->ltsymbol);
|
||||
drw_setscheme(drw, scheme[SchemeLayout]);
|
||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||
}
|
||||
|
||||
/* draw tags */
|
||||
if (!hidetags) {
|
||||
for (i = 0; i < LENGTH(tags); i++) {
|
||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i) && hideemptytags)
|
||||
continue;
|
||||
if (!hidetags) {
|
||||
tagtext = occ & 1 << i ? usedtags[i] : tags[i];
|
||||
w = TEXTW(tagtext);
|
||||
for (i = 0; i < LENGTH(tags); i++) {
|
||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i) && hideemptytags)
|
||||
continue;
|
||||
if (!hidetags) {
|
||||
tagtext = occ & 1 << i ? usedtags[i] : tags[i];
|
||||
w = TEXTW(tagtext);
|
||||
|
||||
/* draw powerlined tags */
|
||||
if (!hidetagpowerline) {
|
||||
prevscheme = scheme[SchemeTags]; /* previous scheme = scheme */
|
||||
drw_settrans(drw, prevscheme, (nxtscheme = scheme[m->tagset[m->seltags] & 1 << i ? SchemeTitleSel : SchemeBar])); /* set transition colorscheme */
|
||||
drw_arrow(drw, x, 0, plw, bh, 1, 0); /* draw arrow */
|
||||
drw_setscheme(drw, nxtscheme); /* set scheme to next scheme */
|
||||
x += plw;
|
||||
} else {
|
||||
drw_setscheme(drw, (m->tagset[m->seltags] & 1 << i ? tagscheme[i] : scheme[SchemeTags])); /* set scheme */
|
||||
}
|
||||
|
||||
/* draw tag text */
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, tagtext, urg & 1 << i);
|
||||
|
||||
/* underline */
|
||||
if (underlineall || m->tagset[m->seltags] & 1 << i)
|
||||
if (underline)
|
||||
drw_rect(drw, x + underlinepad, bh - underlinestroke - underlinevoffset, w - (underlinepad * 2), underlinestroke, 1, 0);
|
||||
|
||||
x += w;
|
||||
|
||||
}
|
||||
|
||||
drw_setscheme(drw, (m->tagset[m->seltags] & 1 << i ? tagscheme[i] : scheme[SchemeTags]));
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, tagtext, urg & 1 << i);
|
||||
|
||||
if (underlineall || m->tagset[m->seltags] & 1 << i)
|
||||
if (underline)
|
||||
drw_rect(drw, x + underlinepad, bh - underlinestroke - underlinevoffset, w - (underlinepad * 2), underlinestroke, 1, 0);
|
||||
|
||||
x += w;
|
||||
/* draw end of powerline tags */
|
||||
if (!hidetagpowerline) {
|
||||
prevscheme = nxtscheme; /* previous scheme = next colorscheme */
|
||||
nxtscheme = scheme[SchemeBar]; /* next colorscheme = bar color */
|
||||
drw_settrans(drw, prevscheme, nxtscheme); /* set transition colorscheme */
|
||||
drw_arrow(drw, x, 0, plw, bh, 1, 0); /* draw arrow */
|
||||
x += plw; /* powerline width */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if LAYOUT_MONOCLE
|
||||
/* override layout icon with number of layouts */
|
||||
if (monoclecount) {
|
||||
if (m->lt[m->sellt]->arrange == monocle) {
|
||||
for (c = nexttiled(m->clients), a = 0, s = 0; c; c = nexttiled(c->next), a++)
|
||||
if (c == m->stack)
|
||||
s = a + 1;
|
||||
if (!s && a)
|
||||
s = 1;
|
||||
snprintf(m->ltsymbol, sizeof m->ltsymbol, monocleformat, s, a);
|
||||
if (m->lt[m->sellt]->arrange == monocle) {
|
||||
for (c = nexttiled(m->clients), a = 0, s = 0; c; c = nexttiled(c->next), a++)
|
||||
if (c == m->stack)
|
||||
s = a + 1;
|
||||
if (!s && a)
|
||||
s = 1;
|
||||
snprintf(m->ltsymbol, sizeof m->ltsymbol, monocleformat, s, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Draw the layout bar on the right if layoutposition is not 0 */
|
||||
|
@ -2300,12 +2344,12 @@ resizebarwin(m);
|
|||
}
|
||||
}
|
||||
|
||||
// Draw sticky window indicator
|
||||
/* draw sticky window indicator */
|
||||
if (c->issticky && !hidesticky) {
|
||||
drw_polygon(drw, x + boxs, c->isfloating ? boxs * 2 + boxw : boxs, stickyiconbb.x, stickyiconbb.y, boxw, boxw * stickyiconbb.y / stickyiconbb.x, stickyicon, LENGTH(stickyicon), Nonconvex, c->tags & c->mon->tagset[c->mon->seltags]);
|
||||
}
|
||||
|
||||
// Draw floating window indicator
|
||||
/* draw floating window indicator */
|
||||
if (c->isfloating && !hidefloating) {
|
||||
drw_rect(drw, x + boxs, boxs, boxw, boxw, c->isfixed, 0);
|
||||
}
|
||||
|
@ -2320,11 +2364,12 @@ resizebarwin(m);
|
|||
|
||||
m->bt = n;
|
||||
m->btw = w;
|
||||
#if USESYSTRAY
|
||||
|
||||
#if USESYSTRAY
|
||||
drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
|
||||
#else
|
||||
#else
|
||||
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2399,9 +2444,15 @@ focus(Client *c)
|
|||
detachstack(c);
|
||||
attachstack(c);
|
||||
grabbuttons(c, 1);
|
||||
|
||||
/* draw window border for the focused window */
|
||||
XSetWindowBorder(dpy, c->win, scheme[SchemeBorderSel][ColBorder].pixel);
|
||||
|
||||
/* set focus */
|
||||
setfocus(c);
|
||||
|
||||
#if USEFADE
|
||||
/* set opacity to activeopacity */
|
||||
opacity(c, activeopacity);
|
||||
#endif
|
||||
} else {
|
||||
|
|
|
@ -134,6 +134,7 @@ ResourcePref resources[] = {
|
|||
{ "hideicon", INTEGER, &hideicon },
|
||||
{ "hidetags", INTEGER, &hidetags },
|
||||
{ "hideemptytags", INTEGER, &hideemptytags },
|
||||
{ "hidetagpowerline", INTEGER, &hidetagpowerline },
|
||||
{ "hidestatus", INTEGER, &hidestatus },
|
||||
{ "hidesticky", INTEGER, &hidesticky },
|
||||
{ "hidefloating", INTEGER, &hidefloating },
|
||||
|
|
Loading…
Reference in a new issue