added under bar
This commit is contained in:
parent
1bef7a3ff4
commit
4595162952
|
@ -9,6 +9,7 @@ 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 topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
|
static const char statussep = ';';
|
||||||
static const int horizpadbar = 5;
|
static const int horizpadbar = 5;
|
||||||
static const int vertpadbar = 8;
|
static const int vertpadbar = 8;
|
||||||
static const int vertpadstat = 0;
|
static const int vertpadstat = 0;
|
||||||
|
@ -34,10 +35,12 @@ static const char *tags[] = { "", "", "3", "", "5", "6", "7", "8", "
|
||||||
|
|
||||||
/* launcher commands (They must be NULL terminated) */
|
/* launcher commands (They must be NULL terminated) */
|
||||||
static const char* bhev[] = { "firefox", "bhev.ru", NULL };
|
static const char* bhev[] = { "firefox", "bhev.ru", NULL };
|
||||||
|
static const char* youtube[] = { "firefox", "youtube.com", NULL };
|
||||||
|
|
||||||
static const Launcher launchers[] = {
|
static const Launcher launchers[] = {
|
||||||
/* command name to display */
|
/* command name to display */
|
||||||
{ bhev, "" },
|
{ bhev, "" },
|
||||||
|
{ youtube, "" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const Rule rules[] = {
|
static const Rule rules[] = {
|
||||||
|
|
3
config.h
3
config.h
|
@ -9,6 +9,7 @@ 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 topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
|
static const char statussep = ';';
|
||||||
static const int horizpadbar = 5;
|
static const int horizpadbar = 5;
|
||||||
static const int vertpadbar = 8;
|
static const int vertpadbar = 8;
|
||||||
static const int vertpadstat = 0;
|
static const int vertpadstat = 0;
|
||||||
|
@ -34,10 +35,12 @@ static const char *tags[] = { "", "", "3", "", "5", "6", "7", "8", "
|
||||||
|
|
||||||
/* launcher commands (They must be NULL terminated) */
|
/* launcher commands (They must be NULL terminated) */
|
||||||
static const char* bhev[] = { "firefox", "bhev.ru", NULL };
|
static const char* bhev[] = { "firefox", "bhev.ru", NULL };
|
||||||
|
static const char* youtube[] = { "firefox", "youtube.com", NULL };
|
||||||
|
|
||||||
static const Launcher launchers[] = {
|
static const Launcher launchers[] = {
|
||||||
/* command name to display */
|
/* command name to display */
|
||||||
{ bhev, "" },
|
{ bhev, "" },
|
||||||
|
{ youtube, "" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const Rule rules[] = {
|
static const Rule rules[] = {
|
||||||
|
|
80
dwm.c
80
dwm.c
|
@ -117,6 +117,7 @@ struct Monitor {
|
||||||
int nmaster;
|
int nmaster;
|
||||||
int num;
|
int num;
|
||||||
int by; /* bar geometry */
|
int by; /* bar geometry */
|
||||||
|
int eby; /* 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 */
|
||||||
int gappx;
|
int gappx;
|
||||||
|
@ -130,6 +131,7 @@ struct Monitor {
|
||||||
Client *stack;
|
Client *stack;
|
||||||
Monitor *next;
|
Monitor *next;
|
||||||
Window barwin;
|
Window barwin;
|
||||||
|
Window extrabarwin;
|
||||||
const Layout *lt[2];
|
const Layout *lt[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -169,6 +171,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 int drawstatusbar(Monitor *m, int bh, int extra, char* text);
|
||||||
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);
|
||||||
|
@ -247,6 +250,7 @@ static void zoom(const Arg *arg);
|
||||||
/* variables */
|
/* variables */
|
||||||
static const char broken[] = "broken";
|
static const char broken[] = "broken";
|
||||||
static char stext[1024];
|
static char stext[1024];
|
||||||
|
static char estext[1024];
|
||||||
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, blw = 0; /* bar geometry */
|
||||||
|
@ -537,7 +541,9 @@ cleanupmon(Monitor *mon)
|
||||||
m->next = mon->next;
|
m->next = mon->next;
|
||||||
}
|
}
|
||||||
XUnmapWindow(dpy, mon->barwin);
|
XUnmapWindow(dpy, mon->barwin);
|
||||||
|
XUnmapWindow(dpy, mon->extrabarwin);
|
||||||
XDestroyWindow(dpy, mon->barwin);
|
XDestroyWindow(dpy, mon->barwin);
|
||||||
|
XDestroyWindow(dpy, mon->extrabarwin);
|
||||||
free(mon);
|
free(mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,6 +606,7 @@ configurenotify(XEvent *e)
|
||||||
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 + hpb, m->by + vpb, m->ww - 2 * hpb, bh);
|
XMoveResizeWindow(dpy, m->barwin, m->wx + hpb, m->by + vpb, m->ww - 2 * hpb, bh);
|
||||||
|
XMoveResizeWindow(dpy, m->extrabarwin, m->wx + hpb, m->eby - vpb, m->ww - 2 * hpb, bh);
|
||||||
}
|
}
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
|
@ -726,7 +733,7 @@ dirtomon(int dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
drawstatusbar(Monitor *m, int bh, char* stext) {
|
drawstatusbar(Monitor *m, int bh, int extra, char* stext) {
|
||||||
int ret, i, w, x, len;
|
int ret, i, w, x, len;
|
||||||
short isCode = 0;
|
short isCode = 0;
|
||||||
char *text;
|
char *text;
|
||||||
|
@ -763,9 +770,18 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
|
||||||
isCode = 0;
|
isCode = 0;
|
||||||
text = p;
|
text = p;
|
||||||
|
|
||||||
|
if (extra) {
|
||||||
|
w = m->ww;
|
||||||
|
// w = m->ww - w - 2 * hpb;
|
||||||
|
ret = x = 1;
|
||||||
|
} else {
|
||||||
// w += 2; /* 1px padding on both sides */
|
// w += 2; /* 1px padding on both sides */
|
||||||
ret = m->ww - w;
|
// ret = x = m->ww - w;
|
||||||
x = m->ww - w - 2 * hpb;
|
ret = x = m->ww - w - 2 * hpb;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ret = m->ww - w;
|
||||||
|
// x = m->ww - w - 2 * hpb;
|
||||||
|
|
||||||
drw_setscheme(drw, scheme[LENGTH(colors)]);
|
drw_setscheme(drw, scheme[LENGTH(colors)]);
|
||||||
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||||
|
@ -846,7 +862,7 @@ drawbar(Monitor *m)
|
||||||
|
|
||||||
/* draw status first so it can be overdrawn by tags later */
|
/* draw status first so it can be overdrawn by tags later */
|
||||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||||
tw = m->ww - drawstatusbar(m, bh, stext);
|
tw = m->ww - drawstatusbar(m, bh, 0, stext);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
@ -885,7 +901,13 @@ drawbar(Monitor *m)
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
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);
|
drw_map(drw, m->barwin, 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
|
||||||
|
@ -1705,7 +1727,7 @@ setup(void)
|
||||||
lrpad = drw->fonts->h + horizpadbar;
|
lrpad = drw->fonts->h + horizpadbar;
|
||||||
bh = drw->fonts->h + vertpadbar;
|
bh = drw->fonts->h + vertpadbar;
|
||||||
hpb = gappx;
|
hpb = gappx;
|
||||||
vpb = (topbar == 1) ? gappx : - gappx;
|
vpb = (topbar == 1) ? gappx : -gappx;
|
||||||
updategeom();
|
updategeom();
|
||||||
/* init atoms */
|
/* init atoms */
|
||||||
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
|
@ -1862,6 +1884,7 @@ togglebar(const Arg *arg)
|
||||||
selmon->showbar = !selmon->showbar;
|
selmon->showbar = !selmon->showbar;
|
||||||
updatebarpos(selmon);
|
updatebarpos(selmon);
|
||||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + hpb, selmon->by + vpb, selmon->ww - 2 * hpb, bh);
|
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + hpb, selmon->by + vpb, selmon->ww - 2 * hpb, bh);
|
||||||
|
XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + hpb, selmon->eby - vpb, selmon->ww - 2 * hpb, bh);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2002,8 +2025,7 @@ updatebars(void)
|
||||||
};
|
};
|
||||||
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)
|
if (!m->barwin) {
|
||||||
continue;
|
|
||||||
m->barwin = XCreateWindow(dpy, root, m->wx + hpb, m->by + vpb, m->ww - 2 * hpb, bh, 0, DefaultDepth(dpy, screen),
|
m->barwin = XCreateWindow(dpy, root, m->wx + hpb, m->by + vpb, m->ww - 2 * hpb, bh, 0, DefaultDepth(dpy, screen),
|
||||||
CopyFromParent, DefaultVisual(dpy, screen),
|
CopyFromParent, DefaultVisual(dpy, screen),
|
||||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
||||||
|
@ -2011,19 +2033,35 @@ updatebars(void)
|
||||||
XMapRaised(dpy, m->barwin);
|
XMapRaised(dpy, m->barwin);
|
||||||
XSetClassHint(dpy, m->barwin, &ch);
|
XSetClassHint(dpy, m->barwin, &ch);
|
||||||
}
|
}
|
||||||
|
if (!m->extrabarwin) {
|
||||||
|
m->extrabarwin = XCreateWindow(dpy, root, m->wx + hpb, m->eby - vpb, m->ww - 2 * hpb, bh, 0, DefaultDepth(dpy, screen),
|
||||||
|
CopyFromParent, DefaultVisual(dpy, screen),
|
||||||
|
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
||||||
|
XDefineCursor(dpy, m->extrabarwin, cursor[CurNormal]->cursor);
|
||||||
|
XMapRaised(dpy, m->extrabarwin);
|
||||||
|
XSetClassHint(dpy, m->extrabarwin, &ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updatebarpos(Monitor *m)
|
updatebarpos(Monitor *m)
|
||||||
{
|
{
|
||||||
m->wy = m->my;
|
m->wy = m->my; // no
|
||||||
m->wh = m->mh;
|
m->wh = m->mh; // no
|
||||||
|
m->wh -= bh * m->showbar * 2; // no
|
||||||
|
m->wy = m->showbar ? m->wy + bh + vpb : m->wy; // no
|
||||||
|
|
||||||
if (m->showbar) {
|
if (m->showbar) {
|
||||||
m->wh = m->wh - gappx - bh;
|
// m->wh = m->wh - gappx - bh;
|
||||||
m->by = m->topbar ? m->wy : m->wy + m->wh + gappx;
|
m->by = m->topbar ? m->wy - gappx - bh : m->wy + m->wh + gappx;
|
||||||
m->wy = m->topbar ? m->wy + bh + vpb : m->wy;
|
m->eby = m->topbar ? m->wy + m->wh + gappx - vpb * 2 : m->wy - gappx - bh - vpb * 2;
|
||||||
} else
|
m->wh -= vpb * 2;
|
||||||
|
// m->wy = m->topbar ? m->wy : m->wy;
|
||||||
|
} else {
|
||||||
m->by = -bh - vpb;
|
m->by = -bh - vpb;
|
||||||
|
m->eby = -bh + vpb;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2181,8 +2219,20 @@ updatesizehints(Client *c)
|
||||||
void
|
void
|
||||||
updatestatus(void)
|
updatestatus(void)
|
||||||
{
|
{
|
||||||
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
char text[2048];
|
||||||
|
if (!gettextprop(root, XA_WM_NAME, text, sizeof(text))) {
|
||||||
strcpy(stext, "dwm-"VERSION);
|
strcpy(stext, "dwm-"VERSION);
|
||||||
|
estext[0] = '\0';
|
||||||
|
} else {
|
||||||
|
char *e = strchr(text, statussep);
|
||||||
|
if (e) {
|
||||||
|
*e = '\0'; e++;
|
||||||
|
strncpy(estext, e, sizeof(estext) - 1);
|
||||||
|
} else {
|
||||||
|
estext[0] = '\0';
|
||||||
|
}
|
||||||
|
strncpy(stext, text, sizeof(stext) - 1);
|
||||||
|
}
|
||||||
drawbar(selmon);
|
drawbar(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2282,7 +2332,7 @@ wintomon(Window w)
|
||||||
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)
|
if (w == m->barwin || w == m->extrabarwin)
|
||||||
return m;
|
return m;
|
||||||
if ((c = wintoclient(w)))
|
if ((c = wintoclient(w)))
|
||||||
return c->mon;
|
return c->mon;
|
||||||
|
|
Loading…
Reference in New Issue