mirror of
https://github.com/zoriya/dwm.git
synced 2025-12-05 23:06:19 +00:00
Bar Modules - splits the bar functionality into individual segments that can be re-arranged
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,5 @@
|
|||||||
*.o
|
*.o
|
||||||
dwm
|
dwm
|
||||||
|
.cache
|
||||||
|
.ccls-cache
|
||||||
|
compile_commands.json
|
||||||
|
|||||||
20
config.def.h
20
config.def.h
@@ -31,6 +31,26 @@ static const Rule rules[] = {
|
|||||||
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Bar rules allow you to configure what is shown where on the bar, as well as
|
||||||
|
* introducing your own bar modules.
|
||||||
|
*
|
||||||
|
* monitor:
|
||||||
|
* -1 show on all monitors
|
||||||
|
* 0 show on monitor 0
|
||||||
|
* 'A' show on active monitor (i.e. focused / selected) (or just -1 for active?)
|
||||||
|
* bar - bar index, 0 is default, 1 is extrabar
|
||||||
|
* alignment - how the module is aligned compared to other modules
|
||||||
|
* widthfunc, drawfunc, clickfunc - providing bar module width, draw and click functions
|
||||||
|
* name - does nothing, intended for visual clue and for logging / debugging
|
||||||
|
*/
|
||||||
|
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_NONE, width_wintitle, draw_wintitle, click_wintitle, "wintitle" },
|
||||||
|
};
|
||||||
|
|
||||||
/* layout(s) */
|
/* layout(s) */
|
||||||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||||
static const int nmaster = 1; /* number of clients in master area */
|
static const int nmaster = 1; /* number of clients in master area */
|
||||||
|
|||||||
20
config.h
20
config.h
@@ -37,6 +37,26 @@ static const int nmaster = 1; /* number of clients in master area */
|
|||||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||||
|
|
||||||
|
/* Bar rules allow you to configure what is shown where on the bar, as well as
|
||||||
|
* introducing your own bar modules.
|
||||||
|
*
|
||||||
|
* monitor:
|
||||||
|
* -1 show on all monitors
|
||||||
|
* 0 show on monitor 0
|
||||||
|
* 'A' show on active monitor (i.e. focused / selected) (or just -1 for active?)
|
||||||
|
* bar - bar index, 0 is default, 1 is extrabar
|
||||||
|
* alignment - how the module is aligned compared to other modules
|
||||||
|
* widthfunc, drawfunc, clickfunc - providing bar module width, draw and click functions
|
||||||
|
* name - does nothing, intended for visual clue and for logging / debugging
|
||||||
|
*/
|
||||||
|
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_NONE, width_wintitle, draw_wintitle, click_wintitle, "wintitle" },
|
||||||
|
};
|
||||||
|
|
||||||
static const Layout layouts[] = {
|
static const Layout layouts[] = {
|
||||||
/* symbol arrange function */
|
/* symbol arrange function */
|
||||||
{ "[]=", tile }, /* first entry is default */
|
{ "[]=", tile }, /* first entry is default */
|
||||||
|
|||||||
417
dwm.c
417
dwm.c
@@ -45,6 +45,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
/* macros */
|
/* macros */
|
||||||
|
#define BARRULES 20
|
||||||
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
||||||
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
||||||
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
||||||
@@ -66,6 +67,19 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
|||||||
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
||||||
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
||||||
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
||||||
|
enum {
|
||||||
|
BAR_ALIGN_LEFT,
|
||||||
|
BAR_ALIGN_CENTER,
|
||||||
|
BAR_ALIGN_RIGHT,
|
||||||
|
BAR_ALIGN_LEFT_LEFT,
|
||||||
|
BAR_ALIGN_LEFT_RIGHT,
|
||||||
|
BAR_ALIGN_LEFT_CENTER,
|
||||||
|
BAR_ALIGN_NONE,
|
||||||
|
BAR_ALIGN_RIGHT_LEFT,
|
||||||
|
BAR_ALIGN_RIGHT_RIGHT,
|
||||||
|
BAR_ALIGN_RIGHT_CENTER,
|
||||||
|
BAR_ALIGN_LAST
|
||||||
|
}; /* bar alignment */
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
int i;
|
int i;
|
||||||
@@ -74,6 +88,46 @@ typedef union {
|
|||||||
const void *v;
|
const void *v;
|
||||||
} Arg;
|
} Arg;
|
||||||
|
|
||||||
|
typedef struct Monitor Monitor;
|
||||||
|
typedef struct Bar Bar;
|
||||||
|
struct Bar {
|
||||||
|
Window win;
|
||||||
|
Monitor *mon;
|
||||||
|
Bar *next;
|
||||||
|
int idx;
|
||||||
|
int topbar;
|
||||||
|
int bx, by, bw, bh; /* bar geometry */
|
||||||
|
int w[BARRULES]; // module width
|
||||||
|
int x[BARRULES]; // module position
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int max_width;
|
||||||
|
} BarWidthArg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int x;
|
||||||
|
int w;
|
||||||
|
} BarDrawArg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int rel_x;
|
||||||
|
int rel_y;
|
||||||
|
int rel_w;
|
||||||
|
int rel_h;
|
||||||
|
} BarClickArg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int monitor;
|
||||||
|
int bar;
|
||||||
|
int alignment; // see bar alignment enum
|
||||||
|
int (*widthfunc)(Bar *bar, BarWidthArg *a);
|
||||||
|
int (*drawfunc)(Bar *bar, BarDrawArg *a);
|
||||||
|
int (*clickfunc)(Bar *bar, Arg *arg, BarClickArg *a);
|
||||||
|
char *name; // for debugging
|
||||||
|
int x, w; // position, width for internal use
|
||||||
|
} BarRule;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int click;
|
unsigned int click;
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
@@ -83,7 +137,6 @@ typedef struct {
|
|||||||
} Button;
|
} Button;
|
||||||
|
|
||||||
typedef struct Clientlist Clientlist;
|
typedef struct Clientlist Clientlist;
|
||||||
typedef struct Monitor Monitor;
|
|
||||||
typedef struct Client Client;
|
typedef struct Client Client;
|
||||||
struct Client {
|
struct Client {
|
||||||
char name[256];
|
char name[256];
|
||||||
@@ -117,18 +170,16 @@ struct Monitor {
|
|||||||
float mfact;
|
float mfact;
|
||||||
int nmaster;
|
int nmaster;
|
||||||
int num;
|
int num;
|
||||||
int by; /* bar geometry */
|
|
||||||
int mx, my, mw, mh; /* screen size */
|
int mx, my, mw, mh; /* screen size */
|
||||||
int wx, wy, ww, wh; /* window area */
|
int wx, wy, ww, wh; /* window area */
|
||||||
unsigned int seltags;
|
unsigned int seltags;
|
||||||
unsigned int sellt;
|
unsigned int sellt;
|
||||||
unsigned int tagset[2];
|
unsigned int tagset[2];
|
||||||
int showbar;
|
int showbar;
|
||||||
int topbar;
|
|
||||||
Clientlist *cl;
|
Clientlist *cl;
|
||||||
Client *sel;
|
Client *sel;
|
||||||
Monitor *next;
|
Monitor *next;
|
||||||
Window barwin;
|
Bar *bar;
|
||||||
const Layout *lt[2];
|
const Layout *lt[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -169,6 +220,7 @@ static void detachstack(Client *c);
|
|||||||
static Monitor *dirtomon(int dir);
|
static Monitor *dirtomon(int dir);
|
||||||
static void drawbar(Monitor *m);
|
static void drawbar(Monitor *m);
|
||||||
static void drawbars(void);
|
static void drawbars(void);
|
||||||
|
static void drawbarwin(Bar *bar);
|
||||||
static void enternotify(XEvent *e);
|
static void enternotify(XEvent *e);
|
||||||
static void expose(XEvent *e);
|
static void expose(XEvent *e);
|
||||||
static void focus(Client *c);
|
static void focus(Client *c);
|
||||||
@@ -242,12 +294,13 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
|||||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
static void zoom(const Arg *arg);
|
static void zoom(const Arg *arg);
|
||||||
|
|
||||||
|
#include "patch/include.h"
|
||||||
/* variables */
|
/* variables */
|
||||||
static const char broken[] = "broken";
|
static const char broken[] = "broken";
|
||||||
static char stext[256];
|
static char stext[256];
|
||||||
static int screen;
|
static int screen;
|
||||||
static int sw, sh; /* X display screen geometry width, height */
|
static int sw, sh; /* X display screen geometry width, height */
|
||||||
static int bh, blw = 0; /* bar geometry */
|
static int bh; /* bar geometry */
|
||||||
static int lrpad; /* sum of left and right padding for text */
|
static int lrpad; /* sum of left and right padding for text */
|
||||||
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||||
static unsigned int numlockmask = 0;
|
static unsigned int numlockmask = 0;
|
||||||
@@ -280,6 +333,8 @@ static Clientlist *cl;
|
|||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "patch/include.c"
|
||||||
|
|
||||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||||
|
|
||||||
@@ -459,43 +514,61 @@ attachstack(Client *c)
|
|||||||
void
|
void
|
||||||
buttonpress(XEvent *e)
|
buttonpress(XEvent *e)
|
||||||
{
|
{
|
||||||
unsigned int i, x, click;
|
int click, i, r, mi;
|
||||||
Arg arg = {0};
|
Arg arg = {0};
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
Bar *bar;
|
||||||
XButtonPressedEvent *ev = &e->xbutton;
|
XButtonPressedEvent *ev = &e->xbutton;
|
||||||
|
const BarRule *br;
|
||||||
|
BarClickArg carg = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
click = ClkRootWin;
|
click = ClkRootWin;
|
||||||
/* focus monitor if necessary */
|
/* focus monitor if necessary */
|
||||||
if ((m = wintomon(ev->window)) && m != selmon) {
|
if ((m = wintomon(ev->window)) && m != selmon
|
||||||
|
) {
|
||||||
unfocus(selmon->sel, 1);
|
unfocus(selmon->sel, 1);
|
||||||
selmon = m;
|
selmon = m;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
if (ev->window == selmon->barwin) {
|
|
||||||
i = x = 0;
|
for (mi = 0, m = mons; m && m != selmon; m = m->next, mi++); // get the monitor index
|
||||||
do
|
for (bar = selmon->bar; bar; bar = bar->next) {
|
||||||
x += TEXTW(tags[i]);
|
if (ev->window == bar->win) {
|
||||||
while (ev->x >= x && ++i < LENGTH(tags));
|
for (r = 0; r < LENGTH(barrules); r++) {
|
||||||
if (i < LENGTH(tags)) {
|
br = &barrules[r];
|
||||||
click = ClkTagBar;
|
if (br->bar != bar->idx || (br->monitor == 'A' && m != selmon) || br->clickfunc == NULL)
|
||||||
arg.ui = 1 << i;
|
continue;
|
||||||
} else if (ev->x < x + blw)
|
if (br->monitor != 'A' && br->monitor != -1 && br->monitor != mi)
|
||||||
click = ClkLtSymbol;
|
continue;
|
||||||
else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
if (bar->x[r] <= ev->x && ev->x <= bar->x[r] + bar->w[r]) {
|
||||||
click = ClkStatusText;
|
carg.rel_x = ev->x - bar->x[r];
|
||||||
else
|
carg.rel_y = ev->y;
|
||||||
click = ClkWinTitle;
|
carg.rel_w = bar->w[r];
|
||||||
} else if ((c = wintoclient(ev->window))) {
|
carg.rel_h = bar->bh;
|
||||||
|
click = br->clickfunc(bar, &arg, &carg);
|
||||||
|
if (click < 0)
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (click == ClkRootWin && (c = wintoclient(ev->window))) {
|
||||||
focus(c);
|
focus(c);
|
||||||
restack(selmon);
|
restack(selmon);
|
||||||
XAllowEvents(dpy, ReplayPointer, CurrentTime);
|
XAllowEvents(dpy, ReplayPointer, CurrentTime);
|
||||||
click = ClkClientWin;
|
click = ClkClientWin;
|
||||||
}
|
}
|
||||||
for (i = 0; i < LENGTH(buttons); i++)
|
|
||||||
|
for (i = 0; i < LENGTH(buttons); i++) {
|
||||||
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
|
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
|
||||||
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
|
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) {
|
||||||
buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
|
buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -540,6 +613,7 @@ void
|
|||||||
cleanupmon(Monitor *mon)
|
cleanupmon(Monitor *mon)
|
||||||
{
|
{
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
Bar *bar;
|
||||||
|
|
||||||
if (mon == mons)
|
if (mon == mons)
|
||||||
mons = mons->next;
|
mons = mons->next;
|
||||||
@@ -547,8 +621,12 @@ cleanupmon(Monitor *mon)
|
|||||||
for (m = mons; m && m->next != mon; m = m->next);
|
for (m = mons; m && m->next != mon; m = m->next);
|
||||||
m->next = mon->next;
|
m->next = mon->next;
|
||||||
}
|
}
|
||||||
XUnmapWindow(dpy, mon->barwin);
|
for (bar = mon->bar; bar; bar = mon->bar) {
|
||||||
XDestroyWindow(dpy, mon->barwin);
|
XUnmapWindow(dpy, bar->win);
|
||||||
|
XDestroyWindow(dpy, bar->win);
|
||||||
|
mon->bar = bar->next;
|
||||||
|
free(bar);
|
||||||
|
}
|
||||||
free(mon);
|
free(mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,6 +672,7 @@ void
|
|||||||
configurenotify(XEvent *e)
|
configurenotify(XEvent *e)
|
||||||
{
|
{
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
Bar *bar;
|
||||||
Client *c;
|
Client *c;
|
||||||
XConfigureEvent *ev = &e->xconfigure;
|
XConfigureEvent *ev = &e->xconfigure;
|
||||||
int dirty;
|
int dirty;
|
||||||
@@ -610,7 +689,8 @@ configurenotify(XEvent *e)
|
|||||||
for (c = m->cl->clients; c; c = c->next)
|
for (c = m->cl->clients; c; c = c->next)
|
||||||
if (c->isfullscreen)
|
if (c->isfullscreen)
|
||||||
resizeclient(c, m->mx, m->my, m->mw, m->mh);
|
resizeclient(c, m->mx, m->my, m->mw, m->mh);
|
||||||
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
|
for (bar = m->bar; bar; bar = bar->next)
|
||||||
|
XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
|
||||||
}
|
}
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
@@ -673,8 +753,11 @@ configurerequest(XEvent *e)
|
|||||||
Monitor *
|
Monitor *
|
||||||
createmon(void)
|
createmon(void)
|
||||||
{
|
{
|
||||||
Monitor *m, *tm;
|
Monitor *m, *mon, *tm;
|
||||||
int i;
|
int i, n, mi, max_bars = 2, istopbar = topbar;
|
||||||
|
|
||||||
|
const BarRule *br;
|
||||||
|
Bar *bar;
|
||||||
|
|
||||||
/* bail out if the number of monitors exceeds the number of tags */
|
/* bail out if the number of monitors exceeds the number of tags */
|
||||||
for (i=1, tm=mons; tm; i++, tm=tm->next);
|
for (i=1, tm=mons; tm; i++, tm=tm->next);
|
||||||
@@ -701,10 +784,29 @@ createmon(void)
|
|||||||
m->mfact = mfact;
|
m->mfact = mfact;
|
||||||
m->nmaster = nmaster;
|
m->nmaster = nmaster;
|
||||||
m->showbar = showbar;
|
m->showbar = showbar;
|
||||||
m->topbar = topbar;
|
|
||||||
|
for (mi = 0, mon = mons; mon; mon = mon->next, mi++); // monitor index
|
||||||
m->lt[0] = &layouts[0];
|
m->lt[0] = &layouts[0];
|
||||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||||
|
|
||||||
|
/* Derive the number of bars for this monitor based on bar rules */
|
||||||
|
for (n = -1, i = 0; i < LENGTH(barrules); i++) {
|
||||||
|
br = &barrules[i];
|
||||||
|
if (br->monitor == 'A' || br->monitor == -1 || br->monitor == mi)
|
||||||
|
n = MAX(br->bar, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i <= n && i < max_bars; i++) {
|
||||||
|
bar = ecalloc(1, sizeof(Bar));
|
||||||
|
bar->mon = m;
|
||||||
|
bar->idx = i;
|
||||||
|
bar->next = m->bar;
|
||||||
|
bar->topbar = istopbar;
|
||||||
|
m->bar = bar;
|
||||||
|
istopbar = !istopbar;
|
||||||
|
}
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -759,65 +861,117 @@ dirtomon(int dir)
|
|||||||
void
|
void
|
||||||
drawbar(Monitor *m)
|
drawbar(Monitor *m)
|
||||||
{
|
{
|
||||||
int x, w, tw = 0;
|
Bar *bar;
|
||||||
int boxs = drw->fonts->h / 9;
|
for (bar = m->bar; bar; bar = bar->next)
|
||||||
int boxw = drw->fonts->h / 6 + 2;
|
drawbarwin(bar);
|
||||||
unsigned int i, occ = 0, urg = 0;
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
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 */
|
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
|
||||||
tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
|
||||||
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (c = m->cl->clients; c; c = c->next) {
|
|
||||||
occ |= c->tags;
|
|
||||||
if (c->isurgent)
|
|
||||||
urg |= c->tags;
|
|
||||||
}
|
|
||||||
x = 0;
|
|
||||||
for (i = 0; i < LENGTH(tags); i++) {
|
|
||||||
w = TEXTW(tags[i]);
|
|
||||||
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
|
||||||
if (occ & 1 << i)
|
|
||||||
drw_rect(drw, x + boxs, boxs, boxw, boxw,
|
|
||||||
m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
|
|
||||||
urg & 1 << i);
|
|
||||||
x += w;
|
|
||||||
}
|
|
||||||
w = blw = TEXTW(m->ltsymbol);
|
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
|
||||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
|
||||||
|
|
||||||
if ((w = m->ww - tw - x) > bh) {
|
|
||||||
if (m->sel) {
|
|
||||||
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
|
||||||
if (m->sel->isfloating)
|
|
||||||
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
|
||||||
} else {
|
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
|
||||||
drw_rect(drw, x, 0, w, bh, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawbars(void)
|
drawbars(void)
|
||||||
{
|
{
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
|
||||||
for (m = mons; m; m = m->next)
|
for (m = mons; m; m = m->next)
|
||||||
drawbar(m);
|
drawbar(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drawbarwin(Bar *bar)
|
||||||
|
{
|
||||||
|
if (!bar->win)
|
||||||
|
return;
|
||||||
|
Monitor *mon;
|
||||||
|
int r, w, mi;
|
||||||
|
int rx, lx, rw, lw; // bar size, split between left and right if a center module is added
|
||||||
|
const BarRule *br;
|
||||||
|
BarWidthArg warg = { 0 };
|
||||||
|
BarDrawArg darg = { 0, 0 };
|
||||||
|
|
||||||
|
for (mi = 0, mon = mons; mon && mon != bar->mon; mon = mon->next, mi++); // get the monitor index
|
||||||
|
rw = lw = bar->bw;
|
||||||
|
rx = lx = 0;
|
||||||
|
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_rect(drw, lx, 0, lw, bh, 1, 1);
|
||||||
|
for (r = 0; r < LENGTH(barrules); r++) {
|
||||||
|
br = &barrules[r];
|
||||||
|
if (br->bar != bar->idx || br->drawfunc == NULL || (br->monitor == 'A' && bar->mon != selmon))
|
||||||
|
continue;
|
||||||
|
if (br->monitor != 'A' && br->monitor != -1 && br->monitor != mi)
|
||||||
|
continue;
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
warg.max_width = (br->alignment < BAR_ALIGN_RIGHT_LEFT ? lw : rw);
|
||||||
|
w = br->widthfunc(bar, &warg);
|
||||||
|
w = MIN(warg.max_width, w);
|
||||||
|
|
||||||
|
if (lw <= 0) { // if left is exhausted then switch to right side, and vice versa
|
||||||
|
lw = rw;
|
||||||
|
lx = rx;
|
||||||
|
} else if (rw <= 0) {
|
||||||
|
rw = lw;
|
||||||
|
rx = lx;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(br->alignment) {
|
||||||
|
default:
|
||||||
|
case BAR_ALIGN_NONE:
|
||||||
|
case BAR_ALIGN_LEFT_LEFT:
|
||||||
|
case BAR_ALIGN_LEFT:
|
||||||
|
bar->x[r] = lx;
|
||||||
|
if (lx == rx) {
|
||||||
|
rx += w;
|
||||||
|
rw -= w;
|
||||||
|
}
|
||||||
|
lx += w;
|
||||||
|
lw -= w;
|
||||||
|
break;
|
||||||
|
case BAR_ALIGN_LEFT_RIGHT:
|
||||||
|
case BAR_ALIGN_RIGHT:
|
||||||
|
bar->x[r] = lx + lw - w;
|
||||||
|
if (lx == rx)
|
||||||
|
rw -= w;
|
||||||
|
lw -= w;
|
||||||
|
break;
|
||||||
|
case BAR_ALIGN_LEFT_CENTER:
|
||||||
|
case BAR_ALIGN_CENTER:
|
||||||
|
bar->x[r] = lx + lw / 2 - w / 2;
|
||||||
|
if (lx == rx) {
|
||||||
|
rw = rx + rw - bar->x[r] - w;
|
||||||
|
rx = bar->x[r] + w;
|
||||||
|
}
|
||||||
|
lw = bar->x[r] - lx;
|
||||||
|
break;
|
||||||
|
case BAR_ALIGN_RIGHT_LEFT:
|
||||||
|
bar->x[r] = rx;
|
||||||
|
if (lx == rx) {
|
||||||
|
lx += w;
|
||||||
|
lw -= w;
|
||||||
|
}
|
||||||
|
rx += w;
|
||||||
|
rw -= w;
|
||||||
|
break;
|
||||||
|
case BAR_ALIGN_RIGHT_RIGHT:
|
||||||
|
bar->x[r] = rx + rw - w;
|
||||||
|
if (lx == rx)
|
||||||
|
lw -= w;
|
||||||
|
rw -= w;
|
||||||
|
break;
|
||||||
|
case BAR_ALIGN_RIGHT_CENTER:
|
||||||
|
bar->x[r] = rx + rw / 2 - w / 2;
|
||||||
|
if (lx == rx) {
|
||||||
|
lw = lx + lw - bar->x[r] + w;
|
||||||
|
lx = bar->x[r] + w;
|
||||||
|
}
|
||||||
|
rw = bar->x[r] - rx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bar->w[r] = w;
|
||||||
|
darg.x = bar->x[r];
|
||||||
|
darg.w = bar->w[r];
|
||||||
|
br->drawfunc(bar, &darg);
|
||||||
|
}
|
||||||
|
drw_map(drw, bar->win, 0, 0, bar->bw, bar->bh);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
enternotify(XEvent *e)
|
enternotify(XEvent *e)
|
||||||
{
|
{
|
||||||
@@ -1113,7 +1267,7 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
c->y = c->mon->my + c->mon->mh - HEIGHT(c);
|
c->y = c->mon->my + c->mon->mh - HEIGHT(c);
|
||||||
c->x = MAX(c->x, c->mon->mx);
|
c->x = MAX(c->x, c->mon->mx);
|
||||||
/* only fix client y-offset, if the client center might cover the bar */
|
/* only fix client y-offset, if the client center might cover the bar */
|
||||||
c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx)
|
c->y = MAX(c->y, ((c->mon->bar->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx)
|
||||||
&& (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
|
&& (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
|
||||||
c->bw = borderpx;
|
c->bw = borderpx;
|
||||||
|
|
||||||
@@ -1300,7 +1454,8 @@ propertynotify(XEvent *e)
|
|||||||
break;
|
break;
|
||||||
case XA_WM_HINTS:
|
case XA_WM_HINTS:
|
||||||
updatewmhints(c);
|
updatewmhints(c);
|
||||||
drawbars();
|
if (c->isurgent)
|
||||||
|
drawbars();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
|
if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
|
||||||
@@ -1426,7 +1581,7 @@ restack(Monitor *m)
|
|||||||
XRaiseWindow(dpy, m->sel->win);
|
XRaiseWindow(dpy, m->sel->win);
|
||||||
if (m->lt[m->sellt]->arrange) {
|
if (m->lt[m->sellt]->arrange) {
|
||||||
wc.stack_mode = Below;
|
wc.stack_mode = Below;
|
||||||
wc.sibling = m->barwin;
|
wc.sibling = m->bar->win;
|
||||||
for (c = m->cl->stack; c; c = c->snext)
|
for (c = m->cl->stack; c; c = c->snext)
|
||||||
if (!c->isfloating && ISVISIBLE(c, m)) {
|
if (!c->isfloating && ISVISIBLE(c, m)) {
|
||||||
XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
|
XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
|
||||||
@@ -1787,9 +1942,11 @@ tile(Monitor *m)
|
|||||||
void
|
void
|
||||||
togglebar(const Arg *arg)
|
togglebar(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
Bar *bar;
|
||||||
selmon->showbar = !selmon->showbar;
|
selmon->showbar = !selmon->showbar;
|
||||||
updatebarpos(selmon);
|
updatebarpos(selmon);
|
||||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
for (bar = selmon->bar; bar; bar = bar->next)
|
||||||
|
XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1909,22 +2066,37 @@ unmapnotify(XEvent *e)
|
|||||||
void
|
void
|
||||||
updatebars(void)
|
updatebars(void)
|
||||||
{
|
{
|
||||||
|
Bar *bar;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
XSetWindowAttributes wa = {
|
XSetWindowAttributes wa = {
|
||||||
.override_redirect = True,
|
.override_redirect = True,
|
||||||
|
#if BAR_ALPHA_PATCH
|
||||||
|
.background_pixel = 0,
|
||||||
|
.border_pixel = 0,
|
||||||
|
.colormap = cmap,
|
||||||
|
#else
|
||||||
.background_pixmap = ParentRelative,
|
.background_pixmap = ParentRelative,
|
||||||
|
#endif // BAR_ALPHA_PATCH
|
||||||
.event_mask = ButtonPressMask|ExposureMask
|
.event_mask = ButtonPressMask|ExposureMask
|
||||||
};
|
};
|
||||||
XClassHint ch = {"dwm", "dwm"};
|
XClassHint ch = {"dwm", "dwm"};
|
||||||
for (m = mons; m; m = m->next) {
|
for (m = mons; m; m = m->next) {
|
||||||
if (m->barwin)
|
for (bar = m->bar; bar; bar = bar->next) {
|
||||||
continue;
|
if (!bar->win) {
|
||||||
m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
|
#if BAR_ALPHA_PATCH
|
||||||
CopyFromParent, DefaultVisual(dpy, screen),
|
bar->win = XCreateWindow(dpy, root, bar->bx, bar->by, bar->bw, bar->bh, 0, depth,
|
||||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
InputOutput, visual,
|
||||||
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
|
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa);
|
||||||
XMapRaised(dpy, m->barwin);
|
#else
|
||||||
XSetClassHint(dpy, m->barwin, &ch);
|
bar->win = XCreateWindow(dpy, root, bar->bx, bar->by, bar->bw, bar->bh, 0, DefaultDepth(dpy, screen),
|
||||||
|
CopyFromParent, DefaultVisual(dpy, screen),
|
||||||
|
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
||||||
|
#endif // BAR_ALPHA_PATCH
|
||||||
|
XDefineCursor(dpy, bar->win, cursor[CurNormal]->cursor);
|
||||||
|
XMapRaised(dpy, bar->win);
|
||||||
|
XSetClassHint(dpy, bar->win, &ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1933,12 +2105,30 @@ updatebarpos(Monitor *m)
|
|||||||
{
|
{
|
||||||
m->wy = m->my;
|
m->wy = m->my;
|
||||||
m->wh = m->mh;
|
m->wh = m->mh;
|
||||||
if (m->showbar) {
|
int num_bars;
|
||||||
m->wh -= bh;
|
Bar *bar;
|
||||||
m->by = m->topbar ? m->wy : m->wy + m->wh;
|
int y_pad = 0;
|
||||||
m->wy = m->topbar ? m->wy + bh : m->wy;
|
int x_pad = 0;
|
||||||
} else
|
|
||||||
m->by = -bh;
|
for (bar = m->bar; bar; bar = bar->next) {
|
||||||
|
bar->bx = m->mx + x_pad;
|
||||||
|
bar->bw = m->ww - 2 * x_pad;
|
||||||
|
bar->bh = bh;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m->showbar) {
|
||||||
|
for (bar = m->bar; bar; bar = bar->next)
|
||||||
|
bar->by = -bh - y_pad;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (num_bars = 0, bar = m->bar; bar; bar = bar->next, num_bars++)
|
||||||
|
if (bar->topbar)
|
||||||
|
m->wy = m->my + bh + y_pad;
|
||||||
|
m->wh = m->wh - y_pad * num_bars - bh * num_bars;
|
||||||
|
|
||||||
|
for (bar = m->bar; bar; bar = bar->next)
|
||||||
|
bar->by = (bar->topbar ? m->wy - bh : m->wy + m->wh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2094,9 +2284,11 @@ updatesizehints(Client *c)
|
|||||||
void
|
void
|
||||||
updatestatus(void)
|
updatestatus(void)
|
||||||
{
|
{
|
||||||
|
Monitor *m;
|
||||||
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
||||||
strcpy(stext, "dwm-"VERSION);
|
strcpy(stext, "dwm-"VERSION);
|
||||||
drawbar(selmon);
|
for (m = mons; m; m = m->next)
|
||||||
|
drawbar(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2180,15 +2372,24 @@ warp(const Client *c)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getrootptr(&x, &y) ||
|
if (!getrootptr(&x, &y))
|
||||||
(x > c->x - c->bw &&
|
|
||||||
y > c->y - c->bw &&
|
|
||||||
x < c->x + c->w + c->bw*2 &&
|
|
||||||
y < c->y + c->h + c->bw*2) ||
|
|
||||||
(y > c->mon->by && y < c->mon->by + bh) ||
|
|
||||||
(c->mon->topbar && !y))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (x > c->x - c->bw &&
|
||||||
|
y > c->y - c->bw &&
|
||||||
|
x < c->x + c->w + c->bw*2 &&
|
||||||
|
y < c->y + c->h + c->bw*2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
for (Monitor *m = mons; m; m = m->next)
|
||||||
|
for (Bar *bar = m->bar; bar; bar = bar->next)
|
||||||
|
if (x > bar->bx &&
|
||||||
|
x < bar->bx + bar->bw &&
|
||||||
|
y > bar->by &&
|
||||||
|
y < bar->by + bar->bh)
|
||||||
|
return;
|
||||||
|
|
||||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2211,12 +2412,14 @@ wintomon(Window w)
|
|||||||
int x, y;
|
int x, y;
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
Bar *bar;
|
||||||
|
|
||||||
if (w == root && getrootptr(&x, &y))
|
if (w == root && getrootptr(&x, &y))
|
||||||
return recttomon(x, y, 1, 1);
|
return recttomon(x, y, 1, 1);
|
||||||
for (m = mons; m; m = m->next)
|
for (m = mons; m; m = m->next)
|
||||||
if (w == m->barwin)
|
for (bar = m->bar; bar; bar = bar->next)
|
||||||
return m;
|
if (w == bar->win)
|
||||||
|
return m;
|
||||||
if ((c = wintoclient(w)))
|
if ((c = wintoclient(w)))
|
||||||
return c->mon;
|
return c->mon;
|
||||||
return selmon;
|
return selmon;
|
||||||
|
|||||||
17
patch/bar_ltsymbol.c
Normal file
17
patch/bar_ltsymbol.c
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
int
|
||||||
|
width_ltsymbol(Bar *bar, BarWidthArg *a)
|
||||||
|
{
|
||||||
|
return TEXTW(bar->mon->ltsymbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
draw_ltsymbol(Bar *bar, BarDrawArg *a)
|
||||||
|
{
|
||||||
|
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, bar->mon->ltsymbol, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
click_ltsymbol(Bar *bar, Arg *arg, BarClickArg *a)
|
||||||
|
{
|
||||||
|
return ClkLtSymbol;
|
||||||
|
}
|
||||||
3
patch/bar_ltsymbol.h
Normal file
3
patch/bar_ltsymbol.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
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);
|
||||||
19
patch/bar_status.c
Normal file
19
patch/bar_status.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
int
|
||||||
|
width_status(Bar *bar, BarWidthArg *a)
|
||||||
|
{
|
||||||
|
return TEXTW(stext);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
draw_status(Bar *bar, BarDrawArg *a)
|
||||||
|
{
|
||||||
|
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, stext, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
click_status(Bar *bar, Arg *arg, BarClickArg *a)
|
||||||
|
{
|
||||||
|
return ClkStatusText;
|
||||||
|
}
|
||||||
3
patch/bar_status.h
Normal file
3
patch/bar_status.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
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);
|
||||||
55
patch/bar_tags.c
Normal file
55
patch/bar_tags.c
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
int
|
||||||
|
width_tags(Bar *bar, BarWidthArg *a)
|
||||||
|
{
|
||||||
|
int w, i;
|
||||||
|
|
||||||
|
for (w = 0, i = 0; i < LENGTH(tags); i++) {
|
||||||
|
w += TEXTW(tags[i]);
|
||||||
|
}
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
draw_tags(Bar *bar, BarDrawArg *a)
|
||||||
|
{
|
||||||
|
int invert;
|
||||||
|
int w, x = a->x;
|
||||||
|
int boxs = drw->fonts->h / 9;
|
||||||
|
int boxw = drw->fonts->h / 6 + 2;
|
||||||
|
unsigned int i, occ = 0, urg = 0;
|
||||||
|
Client *c;
|
||||||
|
Monitor *m = bar->mon;
|
||||||
|
|
||||||
|
for (c = m->cl->clients; c; c = c->next) {
|
||||||
|
occ |= c->tags;
|
||||||
|
if (c->isurgent)
|
||||||
|
urg |= c->tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < LENGTH(tags); i++) {
|
||||||
|
invert = urg & 1 << i;
|
||||||
|
w = TEXTW(tags[i]);
|
||||||
|
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
||||||
|
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert);
|
||||||
|
if (occ & 1 << i)
|
||||||
|
drw_rect(drw, x + boxs, boxs, boxw, boxw,
|
||||||
|
m == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert);
|
||||||
|
x += w;
|
||||||
|
}
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
click_tags(Bar *bar, Arg *arg, BarClickArg *a)
|
||||||
|
{
|
||||||
|
int i = 0, x = lrpad / 2;
|
||||||
|
|
||||||
|
do {
|
||||||
|
x += TEXTW(tags[i]);
|
||||||
|
} while (a->rel_x >= x && ++i < LENGTH(tags));
|
||||||
|
if (i < LENGTH(tags)) {
|
||||||
|
arg->ui = 1 << i;
|
||||||
|
}
|
||||||
|
return ClkTagBar;
|
||||||
|
}
|
||||||
3
patch/bar_tags.h
Normal file
3
patch/bar_tags.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
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);
|
||||||
31
patch/bar_wintitle.c
Normal file
31
patch/bar_wintitle.c
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
int
|
||||||
|
width_wintitle(Bar *bar, BarWidthArg *a)
|
||||||
|
{
|
||||||
|
return a->max_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
draw_wintitle(Bar *bar, BarDrawArg *a)
|
||||||
|
{
|
||||||
|
int boxs = drw->fonts->h / 9;
|
||||||
|
int boxw = drw->fonts->h / 6 + 2;
|
||||||
|
int x = a->x, w = a->w;
|
||||||
|
Monitor *m = bar->mon;
|
||||||
|
|
||||||
|
if (m->sel) {
|
||||||
|
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||||
|
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
||||||
|
if (m->sel->isfloating)
|
||||||
|
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
||||||
|
} else {
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||||
|
}
|
||||||
|
return x + w;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
click_wintitle(Bar *bar, Arg *arg, BarClickArg *a)
|
||||||
|
{
|
||||||
|
return ClkWinTitle;
|
||||||
|
}
|
||||||
3
patch/bar_wintitle.h
Normal file
3
patch/bar_wintitle.h
Normal file
@@ -0,0 +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);
|
||||||
5
patch/include.c
Normal file
5
patch/include.c
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
/* Bar functionality */
|
||||||
|
#include "bar_ltsymbol.c"
|
||||||
|
#include "bar_status.c"
|
||||||
|
#include "bar_tags.c"
|
||||||
|
#include "bar_wintitle.c"
|
||||||
5
patch/include.h
Normal file
5
patch/include.h
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
/* Bar functionality */
|
||||||
|
#include "bar_ltsymbol.h"
|
||||||
|
#include "bar_status.h"
|
||||||
|
#include "bar_tags.h"
|
||||||
|
#include "bar_wintitle.h"
|
||||||
Reference in New Issue
Block a user