rename old title, add awesomebar title

This commit is contained in:
speedie 2022-12-03 17:54:18 +01:00
parent 2004e5dddf
commit b9259c32db
7 changed files with 96 additions and 22 deletions

7
bar.h
View file

@ -12,9 +12,10 @@
*/
static const BarRule barrules[] = {
/* monitor bar alignment widthfunc drawfunc clickfunc name */
{ -1, 0, BAR_ALIGN_LEFT, width_tags, draw_tags, click_tags, "tags" },
{ -1, 0, BAR_ALIGN_LEFT, width_ltsymbol, draw_ltsymbol, click_ltsymbol, "layout" },
//{ 'A', 0, BAR_ALIGN_RIGHT, width_status, draw_status, click_status, "status" },
{ -1, 0, BAR_ALIGN_LEFT, width_tags, draw_tags, click_tags, "tags" },
{ 'A', 0, BAR_ALIGN_RIGHT, width_systray, draw_systray, click_systray, "systray" },
{ -1, 0, BAR_ALIGN_NONE, width_wintitle, draw_wintitle, click_wintitle, "wintitle" },
{ 'A', 0, BAR_ALIGN_RIGHT, width_status, draw_status, click_status, "status" },
//{ -1, 0, BAR_ALIGN_NONE, width_title_basic, draw_title_basic, click_title_basic, "basic title" },
{ -1, 0, BAR_ALIGN_NONE, width_title, draw_title, click_title, "title" },
};

View file

@ -2,6 +2,7 @@
#include "tags.c"
#include "layoutindicator.c"
#include "statusbar.c"
#include "title-basic.c"
#include "title.c"
#if USESYSTRAY
#include "systray.c"

View file

@ -2,6 +2,7 @@
#include "tags.h"
#include "layoutindicator.h"
#include "statusbar.h"
#include "title-basic.h"
#include "title.h"
#if USESYSTRAY
#include "systray.h"

31
bar/title-basic.c Normal file
View file

@ -0,0 +1,31 @@
int
width_title_basic(Bar *bar, BarWidthArg *a)
{
return a->max_width;
}
int
draw_title_basic(Bar *bar, BarDrawArg *a)
{
int boxs = drw->font->h / 9;
int boxw = drw->font->h / 6 + 2;
int x = a->x, w = a->w;
Monitor *m = bar->mon;
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeTitleSel : SchemeTitleNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0, False);
if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
} else {
drw_setscheme(drw, scheme[SchemeBar]);
drw_rect(drw, x, 0, w, bh, 1, 1);
}
return x + w;
}
int
click_title_basic(Bar *bar, Arg *arg, BarClickArg *a)
{
return ClkWinTitle;
}

3
bar/title-basic.h Normal file
View file

@ -0,0 +1,3 @@
static int width_title_basic(Bar *bar, BarWidthArg *a);
static int draw_title_basic(Bar *bar, BarDrawArg *a);
static int click_title_basic(Bar *bar, Arg *arg, BarClickArg *a);

View file

@ -1,31 +1,68 @@
int
width_wintitle(Bar *bar, BarWidthArg *a)
width_title(Bar *bar, BarWidthArg *a)
{
return a->max_width;
}
int
draw_wintitle(Bar *bar, BarDrawArg *a)
draw_title(Bar *bar, BarDrawArg *a)
{
int boxs = drw->font->h / 9;
int boxw = drw->font->h / 6 + 2;
int n = 0, scm, remainder = 0, tabw, padding;
unsigned int i;
int x = a->x, w = a->w;
Monitor *m = bar->mon;
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeTitleSel : SchemeTitleNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0, False);
if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
} else {
drw_setscheme(drw, scheme[SchemeBar]);
drw_rect(drw, x, 0, w, bh, 1, 1);
Client *c;
for (c = bar->mon->clients; c; c = c->next)
if (ISVISIBLE(c))
n++;
if (n > 0) {
remainder = w % n;
tabw = w / n;
for (i = 0, c = bar->mon->clients; c; c = c->next, i++) {
if (!ISVISIBLE(c))
continue;
if (bar->mon->sel == c)
scm = SchemeTitleSel;
else if (HIDDEN(c))
scm = SchemeTitleHidden;
else
scm = SchemeTitleNorm;
padding = lrpad / 2;
if (TEXTW(c->name) < tabw && titleposition)
padding = (tabw - TEXTW(c->name) + lrpad) / 2;
drw_setscheme(drw, scheme[scm]);
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, padding, c->name, 0, False);
x += tabw + (i < remainder ? 1 : 0);
}
}
return x + w;
return a->x + a->w;
}
int
click_wintitle(Bar *bar, Arg *arg, BarClickArg *a)
click_title(Bar *bar, Arg *arg, BarClickArg *a)
{
return ClkWinTitle;
int x = 0, n = 0;
Client *c;
for (c = bar->mon->clients; c; c = c->next)
if (ISVISIBLE(c))
n++;
c = bar->mon->clients;
do {
if (!c || !ISVISIBLE(c))
continue;
else
x += (1.0 / (double)n) * a->rel_w;
} while (c && a->rel_x > x && (c = c->next));
if (c) {
arg->v = c;
return ClkWinTitle;
}
return -1;
}

View file

@ -1,3 +1,3 @@
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);
static int width_title(Bar *bar, BarWidthArg *a);
static int draw_title(Bar *bar, BarDrawArg *a);
static int click_title(Bar *bar, Arg *arg, BarClickArg *a);