Refinement

This commit is contained in:
bakkeby
2020-07-18 13:03:30 +02:00
parent ad09397ad9
commit 664484d572
36 changed files with 512 additions and 524 deletions

View File

@@ -34,7 +34,7 @@ xinitvisual()
XFree(infos);
if (! visual) {
if (!visual) {
visual = DefaultVisual(dpy, screen);
depth = DefaultDepth(dpy, screen);
cmap = DefaultColormap(dpy, screen);

View File

@@ -1,26 +1,36 @@
int
width_awesomebar(Monitor *m, BarWidthArg *a)
width_awesomebar(Bar *bar, BarWidthArg *a)
{
return a->max_width;
}
int
draw_awesomebar(Monitor *m, BarDrawArg *a)
draw_awesomebar(Bar *bar, BarDrawArg *a)
{
int n = 0, scm, remainder = 0, tabw;
unsigned int i, x = a->x;
unsigned int i;
#if BAR_TITLE_LEFT_PAD && BAR_TITLE_RIGHT_PAD
int x = a->x + lrpad / 2, w = a->w - lrpad;
#elif BAR_TITLE_LEFT_PAD
int x = a->x + lrpad / 2, w = a->w - lrpad / 2;
#elif BAR_TITLE_RIGHT_PAD
int x = a->x, w = a->w - lrpad / 2;
#else
int x = a->x, w = a->w;
#endif // BAR_TITLE_LEFT_PAD | BAR_TITLE_RIGHT_PAD
Client *c;
for (c = m->clients; c; c = c->next)
for (c = bar->mon->clients; c; c = c->next)
if (ISVISIBLE(c))
n++;
if (n > 0) {
remainder = a->w % n;
tabw = a->w / n;
for (i = 0, c = m->clients; c; c = c->next, i++) {
remainder = w % n;
tabw = w / n;
for (i = 0, c = bar->mon->clients; c; c = c->next, i++) {
if (!ISVISIBLE(c))
continue;
if (m->sel == c)
if (bar->mon->sel == c)
#if BAR_VTCOLORS_PATCH
scm = SchemeTitleSel;
#elif BAR_TITLECOLOR_PATCH
@@ -38,10 +48,11 @@ draw_awesomebar(Monitor *m, BarDrawArg *a)
#endif // BAR_VTCOLORS_PATCH
drw_setscheme(drw, scheme[scm]);
tabw += (i < remainder ? 1 : 0);
#if BAR_PANGO_PATCH
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0, False);
drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0, False);
#else
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0);
drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0);
#endif // BAR_PANGO_PATCH
x += tabw;
}
@@ -50,16 +61,16 @@ draw_awesomebar(Monitor *m, BarDrawArg *a)
}
int
click_awesomebar(Monitor *m, Arg *arg, BarClickArg *a)
click_awesomebar(Bar *bar, Arg *arg, BarClickArg *a)
{
int x = 0, n = 0;
Client *c;
for (c = m->clients; c; c = c->next)
for (c = bar->mon->clients; c; c = c->next)
if (ISVISIBLE(c))
n++;
c = m->clients;
c = bar->mon->clients;
do {
if (!c || !ISVISIBLE(c))

View File

@@ -1,6 +1,6 @@
static int width_awesomebar(Monitor *m, BarWidthArg *a);
static int draw_awesomebar(Monitor *m, BarDrawArg *a);
static int click_awesomebar(Monitor *m, Arg *arg, BarClickArg *a);
static int width_awesomebar(Bar *bar, BarWidthArg *a);
static int draw_awesomebar(Bar *bar, BarDrawArg *a);
static int click_awesomebar(Bar *bar, Arg *arg, BarClickArg *a);
static void hide(Client *c);
static void show(Client *c);

View File

@@ -1,29 +1,33 @@
int
width_fancybar(Monitor *m, BarWidthArg *a)
width_fancybar(Bar *bar, BarWidthArg *a)
{
return a->max_width;
}
int
draw_fancybar(Monitor *m, BarDrawArg *a)
draw_fancybar(Bar *bar, BarDrawArg *a)
{
int ftw, mw, ew = 0, n = 0, x = a->x, w = a->w;
int ftw, mw, ew = 0, n = 0;
unsigned int i;
Client *c;
#if !BAR_HIDEVACANTTAGS_PATCH
#if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
Monitor *m = bar->mon;
#if BAR_PANGO_PATCH
int boxs = drw->font->h / 9;
#else
int boxs = drw->fonts->h / 9;
#endif // BAR_PANGO_PATCH
#endif // BAR_ACTIVETAGINDICATORBAR_PATCH | BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
#if BAR_PANGO_PATCH
int boxw = drw->font->h / 6 + 2;
#else
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
#endif // BAR_PANGO_PATCH
#endif // BAR_HIDEVACANTTAGS_PATCH
#if BAR_TITLE_LEFT_PAD && BAR_TITLE_RIGHT_PAD
int x = a->x + lrpad / 2, w = a->w - lrpad;
#elif BAR_TITLE_LEFT_PAD
int x = a->x + lrpad / 2, w = a->w - lrpad / 2;
#elif BAR_TITLE_RIGHT_PAD
int x = a->x, w = a->w - lrpad / 2;
#else
int x = a->x, w = a->w;
#endif // BAR_TITLE_LEFT_PAD | BAR_TITLE_RIGHT_PAD
for (c = m->clients; c; c = c->next) {
if (ISVISIBLE(c))
@@ -31,10 +35,11 @@ draw_fancybar(Monitor *m, BarDrawArg *a)
}
if (n > 0) {
ftw = TEXTW(m->sel->name) + lrpad;
ftw = TEXTW(m->sel->name);
mw = (ftw >= w || n == 1) ? 0 : (w - ftw) / (n - 1);
i = 0;
for (c = m->clients; c; c = c->next) {
if (!ISVISIBLE(c) || c == m->sel)
continue;
@@ -44,6 +49,7 @@ draw_fancybar(Monitor *m, BarDrawArg *a)
else
i++;
}
if (i > 0)
mw += ew / i;
@@ -65,31 +71,17 @@ draw_fancybar(Monitor *m, BarDrawArg *a)
#else
drw_text(drw, x, 0, ftw, bh, lrpad / 2, c->name, 0);
#endif // BAR_PANGO_PATCH
#if !BAR_HIDEVACANTTAGS_PATCH
if (c->isfloating)
#if BAR_ACTIVETAGINDICATORBAR_PATCH
drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, c->isfixed, 0);
#elif BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2,
#else
drw_rect(drw, x + boxs, boxs, boxw, boxw, c->isfixed, 0);
#endif // BAR_ACTIVETAGINDICATORBAR_PATCH
#endif // BAR_HIDEVACANTTAGS_PATCH
x += ftw;
w -= ftw;
}
}
#if BAR_VTCOLORS_PATCH
drw_setscheme(drw, scheme[SchemeTitleNorm]);
#else
drw_setscheme(drw, scheme[SchemeNorm]);
#endif // BAR_VTCOLORS_PATCH
drw_rect(drw, x, 0, w, bh, 1, 1);
return x + w;
}
int
click_fancybar(Monitor *m, Arg *arg, BarClickArg *a)
click_fancybar(Bar *bar, Arg *arg, BarClickArg *a)
{
return ClkWinTitle;
}

View File

@@ -1,3 +1,3 @@
static int width_fancybar(Monitor *m, BarWidthArg *a);
static int draw_fancybar(Monitor *m, BarDrawArg *a);
static int click_fancybar(Monitor *m, Arg *arg, BarClickArg *a);
static int width_fancybar(Bar *bar, BarWidthArg *a);
static int draw_fancybar(Bar *bar, BarDrawArg *a);
static int click_fancybar(Bar *bar, Arg *arg, BarClickArg *a);

View File

@@ -1,21 +1,21 @@
int
width_ltsymbol(Monitor *m, BarWidthArg *a)
width_ltsymbol(Bar *bar, BarWidthArg *a)
{
return TEXTW(m->ltsymbol);
return TEXTW(bar->mon->ltsymbol);
}
int
draw_ltsymbol(Monitor *m, BarDrawArg *a)
draw_ltsymbol(Bar *bar, BarDrawArg *a)
{
#if BAR_PANGO_PATCH
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, m->ltsymbol, 0, False);
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, bar->mon->ltsymbol, 0, False);
#else
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, m->ltsymbol, 0);
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, bar->mon->ltsymbol, 0);
#endif // BAR_PANGO_PATCH
}
int
click_ltsymbol(Monitor *m, Arg *arg, BarClickArg *a)
click_ltsymbol(Bar *bar, Arg *arg, BarClickArg *a)
{
return ClkLtSymbol;
}

View File

@@ -1,3 +1,3 @@
static int width_ltsymbol(Monitor *m, BarWidthArg *a);
static int draw_ltsymbol(Monitor *m, BarDrawArg *a);
static int click_ltsymbol(Monitor *m, Arg *arg, BarClickArg *a);
static int width_ltsymbol(Bar *bar, BarWidthArg *a);
static int draw_ltsymbol(Bar *bar, BarDrawArg *a);
static int click_ltsymbol(Bar *bar, Arg *arg, BarClickArg *a);

View File

@@ -1,25 +1,25 @@
int
width_status(Monitor *m, BarWidthArg *a)
width_status(Bar *bar, BarWidthArg *a)
{
#if BAR_PANGO_PATCH
return TEXTWM(stext) - lrpad + 2; /* 2px right padding */
return TEXTWM(stext);
#else
return TEXTW(stext) - lrpad + 2; /* 2px right padding */
return TEXTW(stext);
#endif // BAR_PANGO_PATCH
}
int
draw_status(Monitor *m, BarDrawArg *a)
draw_status(Bar *bar, BarDrawArg *a)
{
#if BAR_PANGO_PATCH
return drw_text(drw, a->x, 0, a->w, bh, 0, stext, 0, True);
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, stext, 0, True);
#else
return drw_text(drw, a->x, 0, a->w, bh, 0, stext, 0);
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, stext, 0);
#endif // BAR_PANGO_PATCH
}
int
click_status(Monitor *m, Arg *arg, BarClickArg *a)
click_status(Bar *bar, Arg *arg, BarClickArg *a)
{
return ClkStatusText;
}

View File

@@ -1,3 +1,3 @@
static int width_status(Monitor *m, BarWidthArg *a);
static int draw_status(Monitor *m, BarDrawArg *a);
static int click_status(Monitor *m, Arg *arg, BarClickArg *a);
static int width_status(Bar *bar, BarWidthArg *a);
static int draw_status(Bar *bar, BarDrawArg *a);
static int click_status(Bar *bar, Arg *arg, BarClickArg *a);

View File

@@ -1,25 +1,25 @@
int
width_status2d(Monitor *m, BarWidthArg *a)
width_status2d(Bar *bar, BarWidthArg *a)
{
return status2dtextlength(rawstext);
return status2dtextlength(rawstext) + lrpad;
}
int
draw_status2d(Monitor *m, BarDrawArg *a)
draw_status2d(Bar *bar, BarDrawArg *a)
{
return drawstatusbar(m, a->x, a->w, rawstext);
return drawstatusbar(a->x, rawstext);
}
#if !BAR_DWMBLOCKS_PATCH
#if !BAR_STATUSCMD_PATCH
int
click_status2d(Monitor *m, Arg *arg, BarClickArg *a)
click_status2d(Bar *bar, Arg *arg, BarClickArg *a)
{
return ClkStatusText;
}
#endif // BAR_DWMBLOCKS_PATCH
#endif // BAR_STATUSCMD_PATCH
int
drawstatusbar(Monitor *m, int x, int ow, char* stext)
drawstatusbar(int x, char* stext)
{
int i, w, len;
short isCode = 0;
@@ -36,6 +36,8 @@ drawstatusbar(Monitor *m, int x, int ow, char* stext)
memcpy(text, stext, len);
#endif // BAR_STATUSCMD_PATCH
x += lrpad / 2;
/* process status text */
i = -1;
while (text[++i]) {

View File

@@ -1,7 +1,7 @@
static int width_status2d(Monitor *m, BarWidthArg *a);
static int draw_status2d(Monitor *m, BarDrawArg *a);
#if !BAR_DWMBLOCKS_PATCH
static int click_status2d(Monitor *m, Arg *arg, BarClickArg *a);
#endif // BAR_DWMBLOCKS_PATCH
static int drawstatusbar(Monitor *m, int x, int w, char* text);
static int width_status2d(Bar *bar, BarWidthArg *a);
static int draw_status2d(Bar *bar, BarDrawArg *a);
#if !BAR_STATUSCMD_PATCH
static int click_status2d(Bar *bar, Arg *arg, BarClickArg *a);
#endif // BAR_STATUSCMD_PATCH
static int drawstatusbar(int x, char* text);
static int status2dtextlength(char* stext);

View File

@@ -1,11 +1,11 @@
int
width_status2d_eb(Monitor *m, BarWidthArg *a)
width_status2d_eb(Bar *bar, BarWidthArg *a)
{
return status2dtextlength(rawestext);
}
int
draw_status2d_eb(Monitor *m, BarDrawArg *a)
draw_status2d_eb(Bar *bar, BarDrawArg *a)
{
return drawstatusbar(m, a->x, a->w, rawestext);
return drawstatusbar(a->x, rawestext);
}

View File

@@ -1,2 +1,2 @@
static int width_status2d_eb(Monitor *m, BarWidthArg *a);
static int draw_status2d_eb(Monitor *m, BarDrawArg *a);
static int width_status2d_eb(Bar *bar, BarWidthArg *a);
static int draw_status2d_eb(Bar *bar, BarDrawArg *a);

19
patch/bar_status_eb.c Normal file
View File

@@ -0,0 +1,19 @@
int
width_status_eb(Bar *bar, BarWidthArg *a)
{
#if BAR_PANGO_PATCH
return TEXTWM(estext) - lrpad;
#else
return TEXTW(estext) - lrpad;
#endif // BAR_PANGO_PATCH
}
int
draw_status_eb(Bar *bar, BarDrawArg *a)
{
#if BAR_PANGO_PATCH
return drw_text(drw, a->x, 0, a->w, bh, 0, estext, 0, True);
#else
return drw_text(drw, a->x, 0, a->w, bh, 0, estext, 0);
#endif // BAR_PANGO_PATCH
}

2
patch/bar_status_eb.h Normal file
View File

@@ -0,0 +1,2 @@
static int width_status_eb(Bar *bar, BarWidthArg *a);
static int draw_status_eb(Bar *bar, BarDrawArg *a);

View File

@@ -1,11 +1,11 @@
int
width_stbutton(Monitor *m, BarWidthArg *a)
width_stbutton(Bar *bar, BarWidthArg *a)
{
return TEXTW(buttonbar);
}
int
draw_stbutton(Monitor *m, BarDrawArg *a)
draw_stbutton(Bar *bar, BarDrawArg *a)
{
#if BAR_PANGO_PATCH
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, buttonbar, 0, False);
@@ -15,7 +15,7 @@ draw_stbutton(Monitor *m, BarDrawArg *a)
}
int
click_stbutton(Monitor *m, Arg *arg, BarClickArg *a)
click_stbutton(Bar *bar, Arg *arg, BarClickArg *a)
{
return ClkButton;
}

View File

@@ -1,3 +1,3 @@
static int width_stbutton(Monitor *m, BarWidthArg *a);
static int draw_stbutton(Monitor *m, BarDrawArg *a);
static int click_stbutton(Monitor *m, Arg *arg, BarClickArg *a);
static int width_stbutton(Bar *bar, BarWidthArg *a);
static int draw_stbutton(Bar *bar, BarDrawArg *a);
static int click_stbutton(Bar *bar, Arg *arg, BarClickArg *a);

View File

@@ -5,21 +5,21 @@ static int lastbutton;
#endif // BAR_DWMBLOCKS_PATCH
int
click_statuscmd(Monitor *m, Arg *arg, BarClickArg *a)
click_statuscmd(Bar *bar, Arg *arg, BarClickArg *a)
{
return click_statuscmd_text(m, arg, a->rel_x, rawstext);
return click_statuscmd_text(arg, a->rel_x, rawstext);
}
#if BAR_EXTRABAR_PATCH
int
click_statuscmd_eb(Monitor *m, Arg *arg, BarClickArg *a)
click_statuscmd_eb(Bar *bar, Arg *arg, BarClickArg *a)
{
return click_statuscmd_text(m, arg, a->rel_x, rawestext);
return click_statuscmd_text(arg, a->rel_x, rawestext);
}
#endif // BAR_EXTRABAR_PATCH
int
click_statuscmd_text(Monitor *m, Arg *arg, int rel_x, char *text)
click_statuscmd_text(Arg *arg, int rel_x, char *text)
{
int i = -1;
int x = 0;

View File

@@ -1,6 +1,6 @@
static int click_statuscmd(Monitor *m, Arg *arg, BarClickArg *a);
static int click_statuscmd(Bar *bar, Arg *arg, BarClickArg *a);
#if BAR_EXTRABAR_PATCH
static int click_statuscmd_eb(Monitor *m, Arg *arg, BarClickArg *a);
static int click_statuscmd_eb(Bar *bar, Arg *arg, BarClickArg *a);
#endif // BAR_EXTRABAR_PATCH
static int click_statuscmd_text(Monitor *m, Arg *arg, int rel_x, char *text);
static int click_statuscmd_text(Arg *arg, int rel_x, char *text);
static void copyvalidchars(char *text, char *rawtext);

View File

@@ -1,11 +1,8 @@
static Systray *systray = NULL;
static unsigned long systrayorientation = _NET_SYSTEM_TRAY_ORIENTATION_HORZ;
static int systraybaridx = -1;
static int systraybarrule = -1;
static int systrayxpos = 0;
int
width_systray(Monitor *m, BarWidthArg *a)
width_systray(Bar *bar, BarWidthArg *a)
{
unsigned int w = 0;
Client *i;
@@ -13,87 +10,40 @@ width_systray(Monitor *m, BarWidthArg *a)
return 1;
if (showsystray)
for (i = systray->icons; i; w += i->w + systrayspacing, i = i->next);
return w ? w + systrayspacing : 0;
return w ? w + lrpad - systrayspacing : 0;
}
int
draw_systray(Monitor *m, BarDrawArg *a)
{
systrayxpos = a->x;
updatesystray();
return systrayxpos + a->w;
}
int
click_systray(Monitor *m, Arg *arg, BarClickArg *a)
{
return -1;
}
void
removesystrayicon(Client *i)
{
Client **ii;
if (!showsystray || !i)
return;
for (ii = &systray->icons; *ii && *ii != i; ii = &(*ii)->next);
if (ii)
*ii = i->next;
free(i);
}
void
resizerequest(XEvent *e)
{
XResizeRequestEvent *ev = &e->xresizerequest;
Client *i;
if ((i = wintosystrayicon(ev->window))) {
updatesystrayicongeom(i, ev->width, ev->height);
updatesystray();
}
}
void
updatesystray(void)
draw_systray(Bar *bar, BarDrawArg *a)
{
if (!showsystray)
return;
return a->x;
XSetWindowAttributes wa;
Client *i;
Monitor *m;
unsigned int w = 1, r, mi;
const BarRule *br;
unsigned int w;
if (!systray) {
/* init systray */
if (!(systray = (Systray *)calloc(1, sizeof(Systray))))
die("fatal: could not malloc() %u bytes\n", sizeof(Systray));
/* Work out which bar the systray is to be displayed on */
for (r = 0; r < LENGTH(barrules); r++) {
br = &barrules[r];
if (br->drawfunc == &draw_systray) {
systraybaridx = br->bar;
systraybarrule = r;
if (br->monitor == -1 || br->monitor == 'A')
m = selmon;
else
for (m = mons, mi = 0; m && mi < br->monitor && m->next; m = m->next, mi++);
systray->win = m->bars[systraybaridx]->win;
systray->mon = m;
break;
}
}
if (systraybaridx == -1) {
fprintf(stderr, "dwm: unable to obtain system tray, no draw_systray in bar rules.\n");
free(systray);
systray = NULL;
return;
}
wa.override_redirect = True;
wa.event_mask = ButtonPressMask|ExposureMask;
wa.border_pixel = 0;
#if BAR_ALPHA_PATCH
wa.background_pixel = 0;
wa.colormap = cmap;
systray->win = XCreateWindow(dpy, root, bar->bx + a->x + lrpad / 2, bar->by, MAX(a->w + 40, 1), bar->bh, 0, depth,
InputOutput, visual,
CWOverrideRedirect|CWBorderPixel|CWBackPixel|CWColormap|CWEventMask, &wa); // CWBackPixmap
#else
wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
systray->win = XCreateSimpleWindow(dpy, root, bar->bx + a->x + lrpad / 2, bar->by, MIN(a->w, 1), bar->bh, 0, 0, scheme[SchemeNorm][ColBg].pixel);
XChangeWindowAttributes(dpy, systray->win, CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &wa);
#endif // BAR_ALPHA_PATCH
XSelectInput(dpy, systray->win, SubstructureNotifyMask);
XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation], XA_CARDINAL, 32,
PropModeReplace, (unsigned char *)&systrayorientation, 1);
#if BAR_ALPHA_PATCH
@@ -111,21 +61,63 @@ updatesystray(void)
fprintf(stderr, "dwm: unable to obtain system tray.\n");
free(systray);
systray = NULL;
return;
return a->x;
}
}
systray->bar = bar;
drw_setscheme(drw, scheme[SchemeNorm]);
for (w = 0, i = systray->icons; i; i = i->next) {
/* make sure the background color stays the same */
#if BAR_ALPHA_PATCH
wa.background_pixel = 0;
#else
wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
#endif // BAR_ALPHA_PATCH
XChangeWindowAttributes(dpy, i->win, CWBackPixel, &wa);
XMapRaised(dpy, i->win);
w += systrayspacing;
i->x = systrayxpos + w;
i->x = w;
XMoveResizeWindow(dpy, i->win, i->x, 0, i->w, i->h);
w += i->w;
if (i->mon != systray->mon)
i->mon = systray->mon;
if (i->next)
w += systrayspacing;
if (i->mon != bar->mon)
i->mon = bar->mon;
}
XMoveResizeWindow(dpy, systray->win, bar->bx + a->x + lrpad / 2, (w ? bar->by : -bar->by), MAX(w, 1), bar->bh);
return a->x + a->w;
}
int
click_systray(Bar *bar, Arg *arg, BarClickArg *a)
{
return -1;
}
void
removesystrayicon(Client *i)
{
Client **ii;
if (!showsystray || !i)
return;
for (ii = &systray->icons; *ii && *ii != i; ii = &(*ii)->next);
if (ii)
*ii = i->next;
free(i);
drawbarwin(systray->bar);
}
void
resizerequest(XEvent *e)
{
XResizeRequestEvent *ev = &e->xresizerequest;
Client *i;
if ((i = wintosystrayicon(ev->window))) {
updatesystrayicongeom(i, ev->width, ev->height);
drawbarwin(systray->bar);
}
}
@@ -185,8 +177,9 @@ updatesystrayiconstate(Client *i, XPropertyEvent *ev)
Client *
wintosystrayicon(Window w)
{
if (!systray)
return NULL;
Client *i = NULL;
if (!showsystray || !w)
return i;
for (i = systray->icons; i && i->win != w; i = i->next);

View File

@@ -22,19 +22,18 @@ typedef struct Systray Systray;
struct Systray {
Window win;
Client *icons;
Monitor *mon;
Bar *bar;
};
/* bar integration */
static int width_systray(Monitor *m, BarWidthArg *a);
static int draw_systray(Monitor *m, BarDrawArg *a);
static int click_systray(Monitor *m, Arg *arg, BarClickArg *a);
static int width_systray(Bar *bar, BarWidthArg *a);
static int draw_systray(Bar *bar, BarDrawArg *a);
static int click_systray(Bar *bar, Arg *arg, BarClickArg *a);
/* function declarations */
static Atom getatomprop(Client *c, Atom prop);
static void removesystrayicon(Client *i);
static void resizerequest(XEvent *e);
static void updatesystray(void);
static void updatesystrayicongeom(Client *i, int w, int h);
static void updatesystrayiconstate(Client *i, XPropertyEvent *ev);
static Client *wintosystrayicon(Window w);

View File

@@ -1,43 +1,58 @@
int
width_taggrid(Monitor *m, BarWidthArg *a)
width_taggrid(Bar *bar, BarWidthArg *a)
{
return (bh / 2) * (LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0));
return (bh / 2) * (LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0)) + lrpad;
}
int
draw_taggrid(Monitor *m, BarDrawArg *a)
draw_taggrid(Bar *bar, BarDrawArg *a)
{
unsigned int x, y, h, max_x, columns, occ = 0;
unsigned int x, y, h, max_x = 0, columns, occ = 0;
int invert, i,j, k;
Client *c;
for (c = m->clients; c; c = c->next)
for (c = bar->mon->clients; c; c = c->next)
occ |= c->tags;
max_x = x = a->x + lrpad / 2;
h = bh / tagrows;
x = max_x = a->x;
y = 0;
columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0);
/* Firstly we will fill the borders of squares */
#if BAR_VTCOLORS_PATCH
XSetForeground(drw->dpy, drw->gc, scheme[SchemeTagsNorm][ColBg].pixel);
#else
XSetForeground(drw->dpy, drw->gc, scheme[SchemeNorm][ColBg].pixel);
#endif // BAR_VTCOLORS_PATCH
XFillRectangle(dpy, drw->drawable, drw->gc, x, y, h*columns + 1, bh);
/* We will draw LENGTH(tags) squares in tagraws raws. */
for (j = 0, i = 0; j < tagrows; j++) {
x = a->x;
x = a->x + lrpad / 2;
for (k = 0; k < columns; k++, i++) {
if (i < LENGTH(tags)) {
invert = m->tagset[m->seltags] & 1 << i ? 0 : 1;
invert = bar->mon->tagset[bar->mon->seltags] & 1 << i ? 0 : 1;
/* Select active color for current square */
#if BAR_VTCOLORS_PATCH
XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeTagsSel][ColBg].pixel :
scheme[SchemeTagsNorm][ColFg].pixel);
#else
XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColBg].pixel :
scheme[SchemeNorm][ColFg].pixel);
#endif // BAR_VTCOLORS_PATCH
XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h-1);
/* Mark square if tag has client */
if (occ & 1 << i) {
#if BAR_VTCOLORS_PATCH
XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeTagsSel][ColFg].pixel :
scheme[SchemeTagsNorm][ColBg].pixel);
#else
XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColFg].pixel :
scheme[SchemeNorm][ColBg].pixel);
#endif // BAR_VTCOLORS_PATCH
XFillRectangle(dpy, drw->drawable, drw->gc, x + 1, y + 1,
h / 2, h / 2);
}
@@ -60,12 +75,12 @@ draw_taggrid(Monitor *m, BarDrawArg *a)
}
int
click_taggrid(Monitor *m, Arg *arg, BarClickArg *a)
click_taggrid(Bar *bar, Arg *arg, BarClickArg *a)
{
unsigned int i, columns;
columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0);
i = (a->rel_x - 0) / (bh / tagrows) + columns * (a->rel_y / (bh / tagrows));
i = (a->rel_x - lrpad / 2) / (bh / tagrows) + columns * (a->rel_y / (bh / tagrows));
if (i >= LENGTH(tags)) {
i = LENGTH(tags) - 1;
}

View File

@@ -1,4 +1,4 @@
static int width_taggrid(Monitor *m, BarWidthArg *a);
static int draw_taggrid(Monitor *m, BarDrawArg *a);
static int click_taggrid(Monitor *m, Arg *arg, BarClickArg *a);
static int width_taggrid(Bar *bar, BarWidthArg *a);
static int draw_taggrid(Bar *bar, BarDrawArg *a);
static int click_taggrid(Bar *bar, Arg *arg, BarClickArg *a);
static void switchtag(const Arg *arg);

View File

@@ -1,5 +1,5 @@
int
width_tags(Monitor *m, BarWidthArg *a)
width_tags(Bar *bar, BarWidthArg *a)
{
int w, i;
for (w = 0, i = 0; i < LENGTH(tags); i++) {
@@ -9,14 +9,14 @@ width_tags(Monitor *m, BarWidthArg *a)
w += TEXTW(tags[i]);
#endif // BAR_ALTERNATIVE_TAGS_PATCH
}
return w;
return w + lrpad;
}
int
draw_tags(Monitor *m, BarDrawArg *a)
draw_tags(Bar *bar, BarDrawArg *a)
{
int invert;
int w, x = a->x;
int w, x = a->x + lrpad / 2;
#if BAR_ALTERNATIVE_TAGS_PATCH
int wdelta;
#endif // BAR_ALTERNATIVE_TAGS_PATCH
@@ -36,6 +36,7 @@ draw_tags(Monitor *m, BarDrawArg *a)
#endif // BAR_HIDEVACANTTAGS_PATCH
unsigned int i, occ = 0, urg = 0;
Client *c;
Monitor *m = bar->mon;
for (c = m->clients; c; c = c->next) {
#if BAR_HIDEVACANTTAGS_PATCH
@@ -107,9 +108,9 @@ draw_tags(Monitor *m, BarDrawArg *a)
}
int
click_tags(Monitor *m, Arg *arg, BarClickArg *a)
click_tags(Bar *bar, Arg *arg, BarClickArg *a)
{
int i = 0, x = 0;
int i = 0, x = lrpad / 2;
do
#if BAR_ALTERNATIVE_TAGS_PATCH
x += selmon->alttag ? TEXTW(tagsalt[i]) : TEXTW(tags[i]);

View File

@@ -1,3 +1,3 @@
static int width_tags(Monitor *m, BarWidthArg *a);
static int draw_tags(Monitor *m, BarDrawArg *a);
static int click_tags(Monitor *m, Arg *arg, BarClickArg *a);
static int width_tags(Bar *bar, BarWidthArg *a);
static int draw_tags(Bar *bar, BarDrawArg *a);
static int click_tags(Bar *bar, Arg *arg, BarClickArg *a);

View File

@@ -1,11 +1,11 @@
int
width_wintitle(Monitor *m, BarWidthArg *a)
width_wintitle(Bar *bar, BarWidthArg *a)
{
return a->max_width;
}
int
draw_wintitle(Monitor *m, BarDrawArg *a)
draw_wintitle(Bar *bar, BarDrawArg *a)
{
#if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
#if BAR_PANGO_PATCH
@@ -19,7 +19,17 @@ draw_wintitle(Monitor *m, BarDrawArg *a)
#else
int boxw = drw->fonts->h / 6 + 2;
#endif // BAR_PANGO_PATCH
#if BAR_TITLE_LEFT_PAD && BAR_TITLE_RIGHT_PAD
int x = a->x + lrpad / 2, w = a->w - lrpad;
#elif BAR_TITLE_LEFT_PAD
int x = a->x + lrpad / 2, w = a->w - lrpad / 2;
#elif BAR_TITLE_RIGHT_PAD
int x = a->x, w = a->w - lrpad / 2;
#else
int x = a->x, w = a->w;
#endif // BAR_TITLE_LEFT_PAD | BAR_TITLE_RIGHT_PAD
Monitor *m = bar->mon;
if (m->sel) {
#if BAR_VTCOLORS_PATCH
@@ -70,7 +80,7 @@ draw_wintitle(Monitor *m, BarDrawArg *a)
}
int
click_wintitle(Monitor *m, Arg *arg, BarClickArg *a)
click_wintitle(Bar *bar, Arg *arg, BarClickArg *a)
{
return ClkWinTitle;
}

View File

@@ -1,3 +1,3 @@
static int width_wintitle(Monitor *m, BarWidthArg *a);
static int draw_wintitle(Monitor *m, BarDrawArg *a);
static int click_wintitle(Monitor *m, Arg *arg, BarClickArg *a);
static int width_wintitle(Bar *bar, BarWidthArg *a);
static int draw_wintitle(Bar *bar, BarDrawArg *a);
static int click_wintitle(Bar *bar, Arg *arg, BarClickArg *a);

View File

@@ -19,6 +19,9 @@
#endif
#if BAR_STATUS_PATCH
#include "bar_status.c"
#if BAR_EXTRABAR_PATCH
#include "bar_status_eb.c"
#endif // BAR_EXTRABAR_PATCH
#endif
#if BAR_STATUS2D_PATCH
#include "bar_status2d.c"

View File

@@ -19,6 +19,9 @@
#endif
#if BAR_STATUS_PATCH
#include "bar_status.h"
#if BAR_EXTRABAR_PATCH
#include "bar_status_eb.h"
#endif // BAR_EXTRABAR_PATCH
#endif
#if BAR_STATUS2D_PATCH
#include "bar_status2d.h"

View File

@@ -1,70 +0,0 @@
void
get_vt_colors(void)
{
char *cfs[3] = {
"/sys/module/vt/parameters/default_red",
"/sys/module/vt/parameters/default_grn",
"/sys/module/vt/parameters/default_blu",
};
char vtcs[16][8];
char tk[] = ",";
char cl[64];
char *tp = NULL;
FILE *fp;
size_t r;
int i, c, n;
for (i = 0; i < 16; i++)
strcpy(vtcs[i], "#000000");
for (i = 0, r = 0; i < 3; i++) {
if ((fp = fopen(cfs[i], "r")) == NULL)
continue;
while ((cl[r] = fgetc(fp)) != EOF && cl[r] != '\n')
r++;
cl[r] = '\0';
for (c = 0, tp = cl, n = 0; c < 16; c++, tp++) {
if ((r = strcspn(tp, tk)) == -1)
break;
for (n = 0; r && *tp >= 48 && *tp < 58; r--, tp++)
n = n * 10 - 48 + *tp;
vtcs[c][i * 2 + 1] = n / 16 < 10 ? n / 16 + 48 : n / 16 + 87;
vtcs[c][i * 2 + 2] = n % 16 < 10 ? n % 16 + 48 : n % 16 + 87;
}
fclose(fp);
}
for (i = 0; i < LENGTH(colors); i++) {
#if FLOAT_BORDER_COLOR_PATCH
for (c = 0; c < 4; c++)
#else
for (c = 0; c < 3; c++)
#endif // FLOAT_BORDER_COLOR_PATCH
{
n = color_ptrs[i][c];
if (n > -1 && strlen(colors[i][c]) >= strlen(vtcs[n]))
memcpy(colors[i][c], vtcs[n], 7);
}
}
}
int get_luminance(char *r)
{
char *c = r;
int n[3] = {0};
int i = 0;
while (*c) {
if (*c >= 48 && *c < 58)
n[i / 2] = n[i / 2] * 16 - 48 + *c;
else if (*c >= 65 && *c < 71)
n[i / 2] = n[i / 2] * 16 - 55 + *c;
else if (*c >= 97 && *c < 103)
n[i / 2] = n[i / 2] * 16 - 87 + *c;
else
i--;
i++;
c++;
}
return (0.299 * n[0] + 0.587 * n[1] + 0.114 * n[2]) / 2.55;
}

View File

@@ -1,2 +0,0 @@
static void get_vt_colors(void);
static int get_luminance(char *rgb);