Add awesomebar
This commit is contained in:
parent
c031927603
commit
eab24097e5
74
bar/bar_awesomebar.c
Normal file
74
bar/bar_awesomebar.c
Normal file
|
@ -0,0 +1,74 @@
|
|||
int
|
||||
width_awesomebar(Bar *bar, BarWidthArg *a)
|
||||
{
|
||||
return a->max_width;
|
||||
}
|
||||
|
||||
int
|
||||
draw_awesomebar(Bar *bar, BarDrawArg *a)
|
||||
{
|
||||
int n = 0, scm, remainder = 0, tabw, pad;
|
||||
unsigned int i;
|
||||
int x = a->x + lrpad / 2, w = a->w - lrpad;
|
||||
|
||||
Client *c;
|
||||
for (c = bar->mon->clients; c; c = c->next)
|
||||
if (ISVISIBLE(c))
|
||||
n++;
|
||||
|
||||
if (n > 0) {
|
||||
remainder = w % n;
|
||||
tabw = w / n;
|
||||
char *fgc;
|
||||
char *bgc;
|
||||
int fga = 255;
|
||||
int bga = 255;
|
||||
|
||||
for (i = 0, c = bar->mon->clients; c; c = c->next, i++) {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
if (bar->mon->sel == c) {
|
||||
fgc = col_gray4;
|
||||
bgc = col_cyan;
|
||||
} else if (HIDDEN(c)) {
|
||||
fgc = col_cyan;
|
||||
bgc = col_gray1;
|
||||
} else {
|
||||
fgc = col_gray3;
|
||||
bgc = col_gray1;
|
||||
}
|
||||
|
||||
pad = lrpad / 2;
|
||||
|
||||
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, pad, c->name, 0, False, fgc, bgc, fga, bga);
|
||||
x += tabw + (i < remainder ? 1 : 0);
|
||||
}
|
||||
}
|
||||
return a->x + a->w;
|
||||
}
|
||||
|
||||
int
|
||||
click_awesomebar(Bar *bar, Arg *arg, BarClickArg *a)
|
||||
{
|
||||
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;
|
||||
}
|
3
bar/bar_awesomebar.h
Normal file
3
bar/bar_awesomebar.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
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);
|
|
@ -8,10 +8,9 @@ width_status(Bar *bar, BarWidthArg *a)
|
|||
int
|
||||
draw_status(Bar *bar, BarDrawArg *a)
|
||||
{
|
||||
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, stext, 0);
|
||||
return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, stext, 0, False, col_gray3, col_gray1, 255, 255);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
click_status(Bar *bar, Arg *arg, BarClickArg *a)
|
||||
{
|
||||
|
|
90
bar/bar_wintitleactions.c
Normal file
90
bar/bar_wintitleactions.c
Normal file
|
@ -0,0 +1,90 @@
|
|||
void
|
||||
hide(Client *c) {
|
||||
|
||||
Client *n;
|
||||
if (!c || HIDDEN(c))
|
||||
return;
|
||||
|
||||
Window w = c->win;
|
||||
static XWindowAttributes ra, ca;
|
||||
|
||||
// more or less taken directly from blackbox's hide() function
|
||||
XGrabServer(dpy);
|
||||
XGetWindowAttributes(dpy, root, &ra);
|
||||
XGetWindowAttributes(dpy, w, &ca);
|
||||
// prevent UnmapNotify events
|
||||
XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
|
||||
XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask);
|
||||
XUnmapWindow(dpy, w);
|
||||
setclientstate(c, IconicState);
|
||||
XSelectInput(dpy, root, ra.your_event_mask);
|
||||
XSelectInput(dpy, w, ca.your_event_mask);
|
||||
XUngrabServer(dpy);
|
||||
|
||||
if (c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) {
|
||||
for (n = c->snext; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext);
|
||||
if (!n)
|
||||
for (n = c->mon->stack; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext);
|
||||
} else {
|
||||
n = nexttiled(c);
|
||||
if (!n)
|
||||
n = prevtiled(c);
|
||||
}
|
||||
focus(n);
|
||||
arrange(c->mon);
|
||||
}
|
||||
|
||||
void
|
||||
show(Client *c)
|
||||
{
|
||||
if (!c || !HIDDEN(c))
|
||||
return;
|
||||
|
||||
XMapWindow(dpy, c->win);
|
||||
setclientstate(c, NormalState);
|
||||
arrange(c->mon);
|
||||
}
|
||||
|
||||
void
|
||||
togglewin(const Arg *arg)
|
||||
{
|
||||
Client *c = (Client*)arg->v;
|
||||
if (!c)
|
||||
return;
|
||||
if (c == selmon->sel)
|
||||
hide(c);
|
||||
else {
|
||||
if (HIDDEN(c))
|
||||
show(c);
|
||||
focus(c);
|
||||
restack(c->mon);
|
||||
}
|
||||
}
|
||||
|
||||
Client *
|
||||
prevtiled(Client *c)
|
||||
{
|
||||
Client *p, *i;
|
||||
for (p = NULL, i = c->mon->clients; c && i != c; i = i->next)
|
||||
if (ISVISIBLE(i) && !HIDDEN(i))
|
||||
p = i;
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
showhideclient(const Arg *arg)
|
||||
{
|
||||
Client *c = (Client*)arg->v;
|
||||
if (!c)
|
||||
c = selmon->sel;
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
if (HIDDEN(c)) {
|
||||
show(c);
|
||||
focus(c);
|
||||
restack(c->mon);
|
||||
} else {
|
||||
hide(c);
|
||||
}
|
||||
}
|
7
bar/bar_wintitleactions.h
Normal file
7
bar/bar_wintitleactions.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#define HIDDEN(C) ((getstate(C->win) == IconicState))
|
||||
|
||||
static void hide(Client *c);
|
||||
static void show(Client *c);
|
||||
static void togglewin(const Arg *arg);
|
||||
static Client * prevtiled(Client *c);
|
||||
static void showhideclient(const Arg *arg);
|
|
@ -1,8 +1,10 @@
|
|||
/* Bar functionality */
|
||||
#include "bar_ltsymbol.c"
|
||||
//#include "bar_status.c"
|
||||
#include "bar_status.c"
|
||||
#include "bar_tags.c"
|
||||
#include "bar_wintitle.c"
|
||||
#include "bar_status2d.c"
|
||||
#include "bar_dwmblocks.c"
|
||||
#include "bar_statuscmd.c"
|
||||
#include "bar_statuscmd.c"
|
||||
#include "bar_wintitleactions.c"
|
||||
#include "bar_awesomebar.c"
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
/* Bar functionality */
|
||||
#include "bar_ltsymbol.h"
|
||||
//#include "bar_status.h"
|
||||
#include "bar_status.h"
|
||||
#include "bar_tags.h"
|
||||
#include "bar_wintitle.h"
|
||||
#include "bar_status2d.h"
|
||||
#include "bar_dwmblocks.h"
|
||||
#include "bar_statuscmd.h"
|
||||
#include "bar_statuscmd.h"
|
||||
#include "bar_awesomebar.h"
|
||||
#include "bar_wintitleactions.h"
|
||||
|
|
|
@ -44,7 +44,7 @@ static const BarRule barrules[] = {
|
|||
{ -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_status2d, draw_status2d, click_statuscmd, "status2d" },
|
||||
{ -1, 0, BAR_ALIGN_NONE, width_wintitle, draw_wintitle, click_wintitle, "wintitle" },
|
||||
{ -1, 0, BAR_ALIGN_NONE, width_awesomebar, draw_awesomebar, click_awesomebar, "awesomebar" },
|
||||
{ 0, 1, BAR_ALIGN_CENTER, width_status2d_es, draw_status2d_es, click_statuscmd_es, "status2d_es" },
|
||||
|
||||
};
|
||||
|
@ -91,6 +91,7 @@ static const Key keys[] = {
|
|||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY, XK_Return, zoom, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ MODKEY|ControlMask, XK_z, showhideclient, {0} },
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
|
@ -121,7 +122,8 @@ static const Button buttons[] = {
|
|||
/* click event mask button function argument */
|
||||
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||
{ ClkWinTitle, 0, Button1, togglewin, {0} },
|
||||
{ ClkWinTitle, 0, Button3, showhideclient, {0} },
|
||||
{ ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1 } },
|
||||
{ ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2 } },
|
||||
{ ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3 } },
|
||||
|
|
23
dwm.c
23
dwm.c
|
@ -536,7 +536,8 @@ buttonpress(XEvent *e)
|
|||
for (i = 0; i < LENGTH(buttons); i++)
|
||||
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
|
||||
&& 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 || click == ClkWinTitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1033,16 +1034,16 @@ focusstack(const Arg *arg)
|
|||
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
||||
return;
|
||||
if (arg->i > 0) {
|
||||
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
|
||||
for (c = selmon->sel->next; c && (!ISVISIBLE(c) || (arg->i == 1 && HIDDEN(c))); c = c->next);
|
||||
if (!c)
|
||||
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
|
||||
for (c = selmon->clients; c && (!ISVISIBLE(c) || (arg->i == 1 && HIDDEN(c))); c = c->next);
|
||||
} else {
|
||||
for (i = selmon->clients; i != selmon->sel; i = i->next)
|
||||
if (ISVISIBLE(i))
|
||||
if (ISVISIBLE(i) && !(arg->i == -1 && HIDDEN(i)))
|
||||
c = i;
|
||||
if (!c)
|
||||
for (; i; i = i->next)
|
||||
if (ISVISIBLE(i))
|
||||
if (ISVISIBLE(i) && !(arg->i == -1 && HIDDEN(i)))
|
||||
c = i;
|
||||
}
|
||||
if (c) {
|
||||
|
@ -1287,12 +1288,14 @@ manage(Window w, XWindowAttributes *wa)
|
|||
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
||||
(unsigned char *) &(c->win), 1);
|
||||
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
|
||||
setclientstate(c, NormalState);
|
||||
if (!HIDDEN(c))
|
||||
setclientstate(c, NormalState);
|
||||
if (c->mon == selmon)
|
||||
unfocus(selmon->sel, 0);
|
||||
c->mon->sel = c;
|
||||
arrange(c->mon);
|
||||
XMapWindow(dpy, c->win);
|
||||
if (!HIDDEN(c))
|
||||
XMapWindow(dpy, c->win);
|
||||
focus(NULL);
|
||||
}
|
||||
|
||||
|
@ -1413,7 +1416,7 @@ movemouse(const Arg *arg)
|
|||
Client *
|
||||
nexttiled(Client *c)
|
||||
{
|
||||
for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
|
||||
for (; c && (c->isfloating || !ISVISIBLE(c) || HIDDEN(c)); c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -2436,7 +2439,9 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
|
|||
void
|
||||
zoom(const Arg *arg)
|
||||
{
|
||||
Client *c = selmon->sel;
|
||||
Client *c = (Client*)arg->v;
|
||||
if (!c)
|
||||
c = selmon->sel;
|
||||
|
||||
if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating)
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue