mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding awesomebar patch
This commit is contained in:
parent
4a17b880ad
commit
d6517bf4f8
@ -1,6 +1,6 @@
|
|||||||
This side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more.
|
This side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more.
|
||||||
|
|
||||||
For example to include the alpha patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/dwm-flexipatch/blob/master/patches.h):
|
For example to include the `alpha` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/dwm-flexipatch/blob/master/patches.h):
|
||||||
```c
|
```c
|
||||||
#define ALPHA_PATCH 1
|
#define ALPHA_PATCH 1
|
||||||
```
|
```
|
||||||
|
@ -42,6 +42,9 @@ static const char *colors[][3] = {
|
|||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||||
|
#endif // AWESOMEBAR_PATCH
|
||||||
};
|
};
|
||||||
|
|
||||||
/* tagging */
|
/* tagging */
|
||||||
@ -276,6 +279,9 @@ static Button buttons[] = {
|
|||||||
/* click event mask button function argument */
|
/* click event mask button function argument */
|
||||||
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||||
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
{ ClkWinTitle, 0, Button1, togglewin, {0} },
|
||||||
|
#endif // AWESOMEBAR_PATCH
|
||||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
|
99
dwm.c
99
dwm.c
@ -56,6 +56,9 @@
|
|||||||
#else
|
#else
|
||||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||||
#endif // ATTACHASIDE_PATCH
|
#endif // ATTACHASIDE_PATCH
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
#define HIDDEN(C) ((getstate(C->win) == IconicState))
|
||||||
|
#endif // AWESOMEBAR_PATCH
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||||
@ -65,7 +68,11 @@
|
|||||||
|
|
||||||
/* enums */
|
/* enums */
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
enum { SchemeNorm, SchemeSel, SchemeHid }; /* color schemes */
|
||||||
|
#else
|
||||||
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||||
|
#endif // #if AWESOMEBAR_PATCH
|
||||||
#if SYSTRAY_PATCH
|
#if SYSTRAY_PATCH
|
||||||
enum { NetSupported, NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayVisual,
|
enum { NetSupported, NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayVisual,
|
||||||
NetWMName, NetWMState, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDock,
|
NetWMName, NetWMState, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDock,
|
||||||
@ -148,6 +155,10 @@ struct Monitor {
|
|||||||
int nmaster;
|
int nmaster;
|
||||||
int num;
|
int num;
|
||||||
int by; /* bar geometry */
|
int by; /* bar geometry */
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
int btw; /* width of tasks portion of bar */
|
||||||
|
int bt; /* number of tasks */
|
||||||
|
#endif // AWESOMEBAR_PATCH
|
||||||
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 */
|
||||||
#if VANITYGAPS_PATCH
|
#if VANITYGAPS_PATCH
|
||||||
@ -533,14 +544,38 @@ buttonpress(XEvent *e)
|
|||||||
arg.ui = 1 << i;
|
arg.ui = 1 << i;
|
||||||
} else if (ev->x < x + blw)
|
} else if (ev->x < x + blw)
|
||||||
click = ClkLtSymbol;
|
click = ClkLtSymbol;
|
||||||
#if SYSTRAY_PATCH
|
#if AWESOMEBAR_PATCH && SYSTRAY_PATCH
|
||||||
|
else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2 - getsystraywidth())
|
||||||
|
#elif AWESOMEBAR_PATCH
|
||||||
|
else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2)
|
||||||
|
#elif SYSTRAY_PATCH
|
||||||
else if (ev->x > selmon->ww - TEXTW(stext) - getsystraywidth())
|
else if (ev->x > selmon->ww - TEXTW(stext) - getsystraywidth())
|
||||||
#else
|
#else
|
||||||
else if (ev->x > selmon->ww - TEXTW(stext))
|
else if (ev->x > selmon->ww - TEXTW(stext))
|
||||||
#endif // SYSTRAY_PATCH
|
#endif // SYSTRAY_PATCH
|
||||||
click = ClkStatusText;
|
click = ClkStatusText;
|
||||||
|
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
else {
|
||||||
|
x += blw;
|
||||||
|
c = m->clients;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (!ISVISIBLE(c))
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
x += (1.0 / (double)m->bt) * m->btw;
|
||||||
|
} while (ev->x > x && (c = c->next));
|
||||||
|
|
||||||
|
if (c) {
|
||||||
|
click = ClkWinTitle;
|
||||||
|
arg.v = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
else
|
else
|
||||||
click = ClkWinTitle;
|
click = ClkWinTitle;
|
||||||
|
#endif // AWESOMEBAR_PATCH
|
||||||
} else if ((c = wintoclient(ev->window))) {
|
} else if ((c = wintoclient(ev->window))) {
|
||||||
focus(c);
|
focus(c);
|
||||||
restack(selmon);
|
restack(selmon);
|
||||||
@ -550,7 +585,11 @@ buttonpress(XEvent *e)
|
|||||||
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))
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
buttons[i].func((click == ClkTagBar || click == ClkWinTitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
|
||||||
|
#else
|
||||||
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);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -920,10 +959,12 @@ drawbar(Monitor *m)
|
|||||||
#if ALTERNATIVE_TAGS_PATCH
|
#if ALTERNATIVE_TAGS_PATCH
|
||||||
int wdelta;
|
int wdelta;
|
||||||
#endif // ALTERNATIVE_TAGS_PATCH
|
#endif // ALTERNATIVE_TAGS_PATCH
|
||||||
#if FANCYBAR_PATCH
|
#if AWESOMEBAR_PATCH
|
||||||
|
int n = 0, scm;
|
||||||
|
#elif FANCYBAR_PATCH
|
||||||
int tw, mw, ew = 0;
|
int tw, mw, ew = 0;
|
||||||
unsigned int n = 0;
|
int n = 0;
|
||||||
#endif // FANCYBAR_PATCH
|
#endif // FANCYBAR_PATCH, AWESOMEBAR_PATCH
|
||||||
#if SYSTRAY_PATCH
|
#if SYSTRAY_PATCH
|
||||||
int stw = 0;
|
int stw = 0;
|
||||||
#endif // SYSTRAY_PATCH
|
#endif // SYSTRAY_PATCH
|
||||||
@ -958,7 +999,7 @@ drawbar(Monitor *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
#if FANCYBAR_PATCH
|
#if AWESOMEBAR_PATCH || FANCYBAR_PATCH
|
||||||
if (ISVISIBLE(c))
|
if (ISVISIBLE(c))
|
||||||
n++;
|
n++;
|
||||||
#endif // FANCYBAR_PATCH
|
#endif // FANCYBAR_PATCH
|
||||||
@ -994,7 +1035,26 @@ drawbar(Monitor *m)
|
|||||||
if ((w = m->ww - sw - x) > bh)
|
if ((w = m->ww - sw - x) > bh)
|
||||||
#endif // SYSTRAY_PATCH
|
#endif // SYSTRAY_PATCH
|
||||||
{
|
{
|
||||||
#if FANCYBAR_PATCH
|
#if AWESOMEBAR_PATCH
|
||||||
|
if (n > 0) {
|
||||||
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
if (!ISVISIBLE(c))
|
||||||
|
continue;
|
||||||
|
if (m->sel == c)
|
||||||
|
scm = SchemeSel;
|
||||||
|
else if (HIDDEN(c))
|
||||||
|
scm = SchemeHid;
|
||||||
|
else
|
||||||
|
scm = SchemeNorm;
|
||||||
|
drw_setscheme(drw, scheme[scm]);
|
||||||
|
drw_text(drw, x, 0, (1.0 / (double)n) * w, bh, lrpad / 2, c->name, 0);
|
||||||
|
x += (1.0 / (double)n) * w;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||||
|
}
|
||||||
|
#elif FANCYBAR_PATCH
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
tw = TEXTW(m->sel->name) + lrpad;
|
tw = TEXTW(m->sel->name) + lrpad;
|
||||||
mw = (tw >= w || n == 1) ? 0 : (w - tw) / (n - 1);
|
mw = (tw >= w || n == 1) ? 0 : (w - tw) / (n - 1);
|
||||||
@ -1038,8 +1098,13 @@ drawbar(Monitor *m)
|
|||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
drw_rect(drw, x, 0, w, bh, 1, 1);
|
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||||
}
|
}
|
||||||
#endif // FANCYBAR_PATCH
|
#endif // FANCYBAR_PATCH, AWESOMEBAR_PATCH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
m->bt = n;
|
||||||
|
m->btw = w;
|
||||||
|
#endif // AWESOMEBAR_PATCH
|
||||||
#if SYSTRAY_PATCH
|
#if SYSTRAY_PATCH
|
||||||
drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
|
drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
|
||||||
#else
|
#else
|
||||||
@ -1093,8 +1158,13 @@ expose(XEvent *e)
|
|||||||
void
|
void
|
||||||
focus(Client *c)
|
focus(Client *c)
|
||||||
{
|
{
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
if (!c || !ISVISIBLE(c) || HIDDEN(c))
|
||||||
|
for (c = selmon->stack; c && (!ISVISIBLE(c) || HIDDEN(c)); c = c->snext);
|
||||||
|
#else
|
||||||
if (!c || !ISVISIBLE(c))
|
if (!c || !ISVISIBLE(c))
|
||||||
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
|
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
|
||||||
|
#endif // AWESOMEBAR_PATCH
|
||||||
if (selmon->sel && selmon->sel != c)
|
if (selmon->sel && selmon->sel != c)
|
||||||
unfocus(selmon->sel, 0);
|
unfocus(selmon->sel, 0);
|
||||||
if (c) {
|
if (c) {
|
||||||
@ -1440,12 +1510,23 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
||||||
(unsigned char *) &(c->win), 1);
|
(unsigned char *) &(c->win), 1);
|
||||||
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
|
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
|
||||||
|
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
if (!HIDDEN(c))
|
||||||
setclientstate(c, NormalState);
|
setclientstate(c, NormalState);
|
||||||
|
#else
|
||||||
|
setclientstate(c, NormalState);
|
||||||
|
#endif // AWESOMEBAR_PATCH
|
||||||
if (c->mon == selmon)
|
if (c->mon == selmon)
|
||||||
unfocus(selmon->sel, 0);
|
unfocus(selmon->sel, 0);
|
||||||
c->mon->sel = c;
|
c->mon->sel = c;
|
||||||
arrange(c->mon);
|
arrange(c->mon);
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
if (!HIDDEN(c))
|
||||||
XMapWindow(dpy, c->win);
|
XMapWindow(dpy, c->win);
|
||||||
|
#else
|
||||||
|
XMapWindow(dpy, c->win);
|
||||||
|
#endif // AWESOMEBAR_PATCH
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1569,7 +1650,11 @@ movemouse(const Arg *arg)
|
|||||||
Client *
|
Client *
|
||||||
nexttiled(Client *c)
|
nexttiled(Client *c)
|
||||||
{
|
{
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
for (; c && (c->isfloating || !ISVISIBLE(c) || HIDDEN(c)); c = c->next);
|
||||||
|
#else
|
||||||
for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
|
for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
|
||||||
|
#endif // AWESOMEBAR_PATCH
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
49
patch/awesomebar.c
Normal file
49
patch/awesomebar.c
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
void
|
||||||
|
hide(Client *c) {
|
||||||
|
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);
|
||||||
|
|
||||||
|
focus(c->snext);
|
||||||
|
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 == selmon->sel)
|
||||||
|
hide(c);
|
||||||
|
else {
|
||||||
|
if (HIDDEN(c))
|
||||||
|
show(c);
|
||||||
|
focus(c);
|
||||||
|
restack(selmon);
|
||||||
|
}
|
||||||
|
}
|
3
patch/awesomebar.h
Normal file
3
patch/awesomebar.h
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
static void hide(Client *c);
|
||||||
|
static void show(Client *c);
|
||||||
|
static void togglewin(const Arg *arg);
|
@ -16,6 +16,10 @@
|
|||||||
#include "autostart.c"
|
#include "autostart.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
#include "awesomebar.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CFACTS_PATCH
|
#if CFACTS_PATCH
|
||||||
#include "cfacts.c"
|
#include "cfacts.c"
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
#include "autostart.h"
|
#include "autostart.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
#include "awesomebar.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CFACTS_PATCH
|
#if CFACTS_PATCH
|
||||||
#include "cfacts.h"
|
#include "cfacts.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -55,6 +55,12 @@
|
|||||||
*/
|
*/
|
||||||
#define AUTOSTART_PATCH 0
|
#define AUTOSTART_PATCH 0
|
||||||
|
|
||||||
|
/* Enhanced taskbar that shows the titles of all visible windows in the status bar
|
||||||
|
* and allows focus / hiding / unhiding of windows by clicking on the status bar.
|
||||||
|
* https://dwm.suckless.org/patches/awesomebar/
|
||||||
|
*/
|
||||||
|
#define AWESOMEBAR_PATCH 1
|
||||||
|
|
||||||
/* This patch adds an iscentered rule to automatically center clients on the current monitor.
|
/* This patch adds an iscentered rule to automatically center clients on the current monitor.
|
||||||
* https://dwm.suckless.org/patches/center/
|
* https://dwm.suckless.org/patches/center/
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user