123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- diff --git a/config.def.h b/config.def.h
- index 7054c06..b96107a 100644
- --- a/config.def.h
- +++ b/config.def.h
- @@ -15,6 +15,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
- static const unsigned int snap = 32; /* snap pixel */
- static const int showbar = 1; /* 0 means no bar */
- static const int topbar = 1; /* 0 means bottom bar */
- +static const int extrabar = 1; /* 0 means no extra bar */
-
- /* tagging */
- static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
- @@ -62,6 +63,7 @@ static Key keys[] = {
- { MODKEY, XK_p, spawn, {.v = dmenucmd } },
- { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
- { MODKEY, XK_b, togglebar, {0} },
- + { MODKEY, XK_b, toggleextrabar, {0} },
- { MODKEY, XK_j, focusstack, {.i = +1 } },
- { MODKEY, XK_k, focusstack, {.i = -1 } },
- { MODKEY, XK_i, incnmaster, {.i = +1 } },
- diff --git a/dwm.c b/dwm.c
- index 0362114..9b7cd74 100644
- --- a/dwm.c
- +++ b/dwm.c
- @@ -141,6 +141,13 @@ typedef struct {
- int monitor;
- } Rule;
-
- +typedef struct {
- + int y;
- + int show;
- + Window win;
- + char text[256];
- +} Bar;
- +
- /* function declarations */
- static void applyrules(Client *c);
- static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
- @@ -210,6 +217,7 @@ static void tag(const Arg *arg);
- static void tagmon(const Arg *arg);
- static void tile(Monitor *);
- static void togglebar(const Arg *arg);
- +static void toggleextrabar(const Arg *arg);
- static void togglefloating(const Arg *arg);
- static void toggletag(const Arg *arg);
- static void toggleview(const Arg *arg);
- @@ -266,6 +274,7 @@ static Display *dpy;
- static Drw *drw;
- static Monitor *mons, *selmon;
- static Window root;
- +static Bar eb;
-
- /* configuration, allows nested code to access above variables */
- #include "config.h"
- @@ -477,6 +486,8 @@ cleanup(void)
- while (m->stack)
- unmanage(m->stack, 0);
- XUngrabKey(dpy, AnyKey, AnyModifier, root);
- + XUnmapWindow(dpy, eb.win);
- + XDestroyWindow(dpy, eb.win);
- while (mons)
- cleanupmon(mons);
- for (i = 0; i < CurLast; i++)
- @@ -578,6 +589,7 @@ configurenotify(XEvent *e)
- updatebars();
- for (m = mons; m; m = m->next)
- XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
- + XMoveResizeWindow(dpy, eb.win, mons->wx, eb.y, mons->ww, bh);
- focus(NULL);
- arrange(NULL);
- }
- @@ -751,6 +763,9 @@ drawbar(Monitor *m)
- }
- }
- drw_map(drw, m->barwin, 0, 0, m->ww, bh);
- + drw_setscheme(drw, &scheme[SchemeNorm]);
- + drw_text(drw, 0, 0, mons->ww, bh, eb.text, 0);
- + drw_map(drw, eb.win, 0, 0, mons->ww, bh);
- }
-
- void
- @@ -1558,6 +1573,7 @@ setup(void)
- root = RootWindow(dpy, screen);
- drw = drw_create(dpy, screen, root, sw, sh);
- drw_load_fonts(drw, fonts, LENGTH(fonts));
- + eb.show = extrabar;
- if (!drw->fontcount)
- die("no fonts could be loaded.\n");
- bh = drw->fonts[0]->h + 2;
- @@ -1699,6 +1715,17 @@ togglebar(const Arg *arg)
- }
-
- void
- +toggleextrabar(const Arg *arg)
- +{
- + if(selmon == mons) {
- + eb.show = !eb.show;
- + updatebarpos(selmon);
- + XMoveResizeWindow(dpy, eb.win, selmon->wx, eb.y, selmon->ww, bh);
- + arrange(selmon);
- + }
- +}
- +
- +void
- togglefloating(const Arg *arg)
- {
- if (!selmon->sel)
- @@ -1810,6 +1837,13 @@ updatebars(void)
- XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
- XMapRaised(dpy, m->barwin);
- }
- + if(!eb.win) {
- + eb.win = XCreateWindow(dpy, root, mons->wx, eb.y, mons->ww, bh, 0, DefaultDepth(dpy, screen),
- + CopyFromParent, DefaultVisual(dpy, screen),
- + CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
- + XDefineCursor(dpy, eb.win, cursor[CurNormal]->cursor);
- + XMapRaised(dpy, eb.win);
- + }
- }
-
- void
- @@ -1823,6 +1857,13 @@ updatebarpos(Monitor *m)
- m->wy = m->topbar ? m->wy + bh : m->wy;
- } else
- m->by = -bh;
- + if(m == mons && eb.show) {
- + m->wh -= bh;
- + eb.y = topbar ? m->wy + m->wh : m->wy;
- + m->wy = m->topbar ? m->wy : m->wy + bh;
- + }
- + else
- + eb.y = -bh;
- }
-
- void
- @@ -1992,8 +2033,21 @@ updatetitle(Client *c)
- void
- updatestatus(void)
- {
- - if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
- + char text[512];
- + if(!gettextprop(root, XA_WM_NAME, text, sizeof(text))) {
- strcpy(stext, "dwm-"VERSION);
- + eb.text[0] = '\0';
- + }
- + else {
- + char *e = strchr(text, ';');
- + if(e) {
- + *e = '\0'; e++;
- + strncpy(eb.text, e, sizeof(eb.text)-1);
- + }
- + else
- + eb.text[0] = '\0';
- + strncpy(stext, text, sizeof(stext)-1);
- + }
- drawbar(selmon);
- }
-
|