Compare commits
5 Commits
44adafe006
...
1f0c5309e7
Author | SHA1 | Date |
---|---|---|
fuzzy | 1f0c5309e7 | |
Hiltjo Posthuma | 970f376973 | |
Stein | c2b748e793 | |
NRK | 84d7322113 | |
Stein | 5799dd1fca |
27
config.def.h
27
config.def.h
|
@ -1,17 +1,21 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
static const unsigned int borderpx = 2; /* border pixel of windows */
|
||||||
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 *fonts[] = { "monospace:size=10" };
|
static const int usealtbar = 1; /* 1 means use non-dwm status bar */
|
||||||
static const char dmenufont[] = "monospace:size=10";
|
static const char *altbarclass = "Polybar"; /* Alternate bar class name */
|
||||||
|
static const char *alttrayname = "tray"; /* Polybar tray instance name */
|
||||||
|
static const char *altbarcmd = "$HOME/.config/polybar/launch.sh"; /* Alternate bar launch command */
|
||||||
|
static const char *fonts[] = { "JetBrains Mono:size=13" };
|
||||||
|
static const char dmenufont[] = "JetBrains Mono:size=13";
|
||||||
static const char col_gray1[] = "#222222";
|
static const char col_gray1[] = "#222222";
|
||||||
static const char col_gray2[] = "#444444";
|
static const char col_gray2[] = "#8181a6";
|
||||||
static const char col_gray3[] = "#bbbbbb";
|
static const char col_gray3[] = "#bbbbbb";
|
||||||
static const char col_gray4[] = "#eeeeee";
|
static const char col_gray4[] = "#eeeeee";
|
||||||
static const char col_cyan[] = "#005577";
|
static const char col_cyan[] = "#8f6f8f";
|
||||||
static const char *colors[][3] = {
|
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 },
|
||||||
|
@ -28,7 +32,9 @@ static const Rule rules[] = {
|
||||||
*/
|
*/
|
||||||
/* class instance title tags mask isfloating monitor */
|
/* class instance title tags mask isfloating monitor */
|
||||||
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
||||||
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
{ "wired", NULL, NULL, 0, 1, -1 },
|
||||||
|
{ "KeePassXC", NULL, NULL, 0, 1, -1 },
|
||||||
|
{ "xzoom", NULL, NULL, 0, 1, -1}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* layout(s) */
|
/* layout(s) */
|
||||||
|
@ -45,7 +51,7 @@ static const Layout layouts[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod4Mask
|
||||||
#define TAGKEYS(KEY,TAG) \
|
#define TAGKEYS(KEY,TAG) \
|
||||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||||
|
@ -56,11 +62,10 @@ static const Layout layouts[] = {
|
||||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
|
||||||
/* commands */
|
/* commands */
|
||||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
static const char *dmenucmd[] = { "dmenu_run", NULL };
|
||||||
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
|
||||||
static const char *termcmd[] = { "st", NULL };
|
static const char *termcmd[] = { "st", NULL };
|
||||||
|
|
||||||
static Key keys[] = {
|
static const Key keys[] = {
|
||||||
/* modifier key function argument */
|
/* modifier key function argument */
|
||||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||||
|
@ -99,7 +104,7 @@ static Key keys[] = {
|
||||||
|
|
||||||
/* button definitions */
|
/* button definitions */
|
||||||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||||
static Button buttons[] = {
|
static const 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]} },
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
|
/* appearance */
|
||||||
|
static const unsigned int borderpx = 2; /* 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 usealtbar = 1; /* 1 means use non-dwm status bar */
|
||||||
|
static const char *altbarclass = "Polybar"; /* Alternate bar class name */
|
||||||
|
static const char *alttrayname = "tray"; /* Polybar tray instance name */
|
||||||
|
static const char *altbarcmd = "$HOME/.config/polybar/launch.sh"; /* Alternate bar launch command */
|
||||||
|
static const char *fonts[] = { "JetBrains Mono:size=13" };
|
||||||
|
static const char dmenufont[] = "JetBrains Mono:size=13";
|
||||||
|
static const char col_gray1[] = "#222222";
|
||||||
|
static const char col_gray2[] = "#8181a6";
|
||||||
|
static const char col_gray3[] = "#bbbbbb";
|
||||||
|
static const char col_gray4[] = "#eeeeee";
|
||||||
|
static const char col_cyan[] = "#8f6f8f";
|
||||||
|
static const char *colors[][3] = {
|
||||||
|
/* fg bg border */
|
||||||
|
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
|
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* tagging */
|
||||||
|
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||||
|
|
||||||
|
static const Rule rules[] = {
|
||||||
|
/* xprop(1):
|
||||||
|
* WM_CLASS(STRING) = instance, class
|
||||||
|
* WM_NAME(STRING) = title
|
||||||
|
*/
|
||||||
|
/* class instance title tags mask isfloating monitor */
|
||||||
|
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
||||||
|
{ "wired", NULL, NULL, 0, 1, -1 },
|
||||||
|
{ "KeePassXC", NULL, NULL, 0, 1, -1 },
|
||||||
|
{ "xzoom", NULL, NULL, 0, 1, -1}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* layout(s) */
|
||||||
|
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 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 Layout layouts[] = {
|
||||||
|
/* symbol arrange function */
|
||||||
|
{ "[]=", tile }, /* first entry is default */
|
||||||
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
|
{ "[M]", monocle },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* key definitions */
|
||||||
|
#define MODKEY Mod4Mask
|
||||||
|
#define TAGKEYS(KEY,TAG) \
|
||||||
|
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||||
|
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||||
|
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||||||
|
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
||||||
|
|
||||||
|
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||||
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
|
||||||
|
/* commands */
|
||||||
|
static const char *dmenucmd[] = { "dmenu_run", NULL };
|
||||||
|
static const char *termcmd[] = { "st", NULL };
|
||||||
|
|
||||||
|
static const Key keys[] = {
|
||||||
|
/* modifier key function argument */
|
||||||
|
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||||
|
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||||
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
|
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||||
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||||
|
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
|
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
|
{ MODKEY, XK_Return, zoom, {0} },
|
||||||
|
{ MODKEY, XK_Tab, view, {0} },
|
||||||
|
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||||
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
|
{ MODKEY, XK_space, setlayout, {0} },
|
||||||
|
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||||
|
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||||
|
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||||
|
TAGKEYS( XK_1, 0)
|
||||||
|
TAGKEYS( XK_2, 1)
|
||||||
|
TAGKEYS( XK_3, 2)
|
||||||
|
TAGKEYS( XK_4, 3)
|
||||||
|
TAGKEYS( XK_5, 4)
|
||||||
|
TAGKEYS( XK_6, 5)
|
||||||
|
TAGKEYS( XK_7, 6)
|
||||||
|
TAGKEYS( XK_8, 7)
|
||||||
|
TAGKEYS( XK_9, 8)
|
||||||
|
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* button definitions */
|
||||||
|
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||||
|
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} },
|
||||||
|
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||||
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
|
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||||
|
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||||
|
{ ClkTagBar, 0, Button1, view, {0} },
|
||||||
|
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
||||||
|
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||||
|
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
||||||
|
};
|
||||||
|
|
14
drw.c
14
drw.c
|
@ -133,19 +133,6 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
||||||
die("no font specified.");
|
die("no font specified.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do not allow using color fonts. This is a workaround for a BadLength
|
|
||||||
* error from Xft with color glyphs. Modelled on the Xterm workaround. See
|
|
||||||
* https://bugzilla.redhat.com/show_bug.cgi?id=1498269
|
|
||||||
* https://lists.suckless.org/dev/1701/30932.html
|
|
||||||
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
|
|
||||||
* and lots more all over the internet.
|
|
||||||
*/
|
|
||||||
FcBool iscol;
|
|
||||||
if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
|
|
||||||
XftFontClose(drw->dpy, xfont);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
font = ecalloc(1, sizeof(Fnt));
|
font = ecalloc(1, sizeof(Fnt));
|
||||||
font->xfont = xfont;
|
font->xfont = xfont;
|
||||||
font->pattern = pattern;
|
font->pattern = pattern;
|
||||||
|
@ -368,7 +355,6 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
||||||
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||||
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
||||||
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
|
|
||||||
|
|
||||||
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
||||||
FcDefaultSubstitute(fcpattern);
|
FcDefaultSubstitute(fcpattern);
|
||||||
|
|
221
dwm.c
221
dwm.c
|
@ -47,8 +47,8 @@
|
||||||
/* macros */
|
/* macros */
|
||||||
#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)->mx+(m)->mw) - MAX((x),(m)->mx)) \
|
||||||
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
* MAX(0, MIN((y)+(h),(m)->my+(m)->mh) - MAX((y),(m)->my)))
|
||||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
|
@ -116,7 +116,8 @@ struct Monitor {
|
||||||
float mfact;
|
float mfact;
|
||||||
int nmaster;
|
int nmaster;
|
||||||
int num;
|
int num;
|
||||||
int by; /* bar geometry */
|
int by, bh; /* bar geometry */
|
||||||
|
int tx, tw; /* bar tray 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;
|
||||||
|
@ -129,6 +130,7 @@ struct Monitor {
|
||||||
Client *stack;
|
Client *stack;
|
||||||
Monitor *next;
|
Monitor *next;
|
||||||
Window barwin;
|
Window barwin;
|
||||||
|
Window traywin;
|
||||||
const Layout *lt[2];
|
const Layout *lt[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -179,6 +181,8 @@ static void incnmaster(const Arg *arg);
|
||||||
static void keypress(XEvent *e);
|
static void keypress(XEvent *e);
|
||||||
static void killclient(const Arg *arg);
|
static void killclient(const Arg *arg);
|
||||||
static void manage(Window w, XWindowAttributes *wa);
|
static void manage(Window w, XWindowAttributes *wa);
|
||||||
|
static void managealtbar(Window win, XWindowAttributes *wa);
|
||||||
|
static void managetray(Window win, XWindowAttributes *wa);
|
||||||
static void mappingnotify(XEvent *e);
|
static void mappingnotify(XEvent *e);
|
||||||
static void maprequest(XEvent *e);
|
static void maprequest(XEvent *e);
|
||||||
static void monocle(Monitor *m);
|
static void monocle(Monitor *m);
|
||||||
|
@ -195,6 +199,7 @@ static void resizemouse(const Arg *arg);
|
||||||
static void restack(Monitor *m);
|
static void restack(Monitor *m);
|
||||||
static void run(void);
|
static void run(void);
|
||||||
static void scan(void);
|
static void scan(void);
|
||||||
|
static void scantray(void);
|
||||||
static int sendevent(Client *c, Atom proto);
|
static int sendevent(Client *c, Atom proto);
|
||||||
static void sendmon(Client *c, Monitor *m);
|
static void sendmon(Client *c, Monitor *m);
|
||||||
static void setclientstate(Client *c, long state);
|
static void setclientstate(Client *c, long state);
|
||||||
|
@ -206,7 +211,9 @@ static void setup(void);
|
||||||
static void seturgent(Client *c, int urg);
|
static void seturgent(Client *c, int urg);
|
||||||
static void showhide(Client *c);
|
static void showhide(Client *c);
|
||||||
static void sigchld(int unused);
|
static void sigchld(int unused);
|
||||||
|
static int solitary(Client *c);
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
|
static void spawnbar();
|
||||||
static void tag(const Arg *arg);
|
static void tag(const Arg *arg);
|
||||||
static void tagmon(const Arg *arg);
|
static void tagmon(const Arg *arg);
|
||||||
static void tile(Monitor *m);
|
static void tile(Monitor *m);
|
||||||
|
@ -216,6 +223,8 @@ static void toggletag(const Arg *arg);
|
||||||
static void toggleview(const Arg *arg);
|
static void toggleview(const Arg *arg);
|
||||||
static void unfocus(Client *c, int setfocus);
|
static void unfocus(Client *c, int setfocus);
|
||||||
static void unmanage(Client *c, int destroyed);
|
static void unmanage(Client *c, int destroyed);
|
||||||
|
static void unmanagealtbar(Window w);
|
||||||
|
static void unmanagetray(Window w);
|
||||||
static void unmapnotify(XEvent *e);
|
static void unmapnotify(XEvent *e);
|
||||||
static void updatebarpos(Monitor *m);
|
static void updatebarpos(Monitor *m);
|
||||||
static void updatebars(void);
|
static void updatebars(void);
|
||||||
|
@ -230,6 +239,7 @@ static void updatewmhints(Client *c);
|
||||||
static void view(const Arg *arg);
|
static void view(const Arg *arg);
|
||||||
static Client *wintoclient(Window w);
|
static Client *wintoclient(Window w);
|
||||||
static Monitor *wintomon(Window w);
|
static Monitor *wintomon(Window w);
|
||||||
|
static int wmclasscontains(Window win, const char *class, const char *name);
|
||||||
static int xerror(Display *dpy, XErrorEvent *ee);
|
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
|
@ -240,7 +250,7 @@ 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 height */
|
||||||
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;
|
||||||
|
@ -440,7 +450,7 @@ buttonpress(XEvent *e)
|
||||||
if (i < LENGTH(tags)) {
|
if (i < LENGTH(tags)) {
|
||||||
click = ClkTagBar;
|
click = ClkTagBar;
|
||||||
arg.ui = 1 << i;
|
arg.ui = 1 << i;
|
||||||
} else if (ev->x < x + blw)
|
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
||||||
click = ClkLtSymbol;
|
click = ClkLtSymbol;
|
||||||
else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
||||||
click = ClkStatusText;
|
click = ClkStatusText;
|
||||||
|
@ -508,8 +518,10 @@ 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);
|
if (!usealtbar) {
|
||||||
XDestroyWindow(dpy, mon->barwin);
|
XUnmapWindow(dpy, mon->barwin);
|
||||||
|
XDestroyWindow(dpy, mon->barwin);
|
||||||
|
}
|
||||||
free(mon);
|
free(mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +583,7 @@ configurenotify(XEvent *e)
|
||||||
for (c = m->clients; c; c = c->next)
|
for (c = m->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);
|
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, m->bh);
|
||||||
}
|
}
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
|
@ -642,6 +654,7 @@ createmon(void)
|
||||||
m->nmaster = nmaster;
|
m->nmaster = nmaster;
|
||||||
m->showbar = showbar;
|
m->showbar = showbar;
|
||||||
m->topbar = topbar;
|
m->topbar = topbar;
|
||||||
|
m->bh = bh;
|
||||||
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);
|
||||||
|
@ -652,10 +665,15 @@ void
|
||||||
destroynotify(XEvent *e)
|
destroynotify(XEvent *e)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
|
Monitor *m;
|
||||||
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
||||||
|
|
||||||
if ((c = wintoclient(ev->window)))
|
if ((c = wintoclient(ev->window)))
|
||||||
unmanage(c, 1);
|
unmanage(c, 1);
|
||||||
|
else if ((m = wintomon(ev->window)) && m->barwin == ev->window)
|
||||||
|
unmanagealtbar(ev->window);
|
||||||
|
else if (m->traywin == ev->window)
|
||||||
|
unmanagetray(ev->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -699,6 +717,9 @@ dirtomon(int dir)
|
||||||
void
|
void
|
||||||
drawbar(Monitor *m)
|
drawbar(Monitor *m)
|
||||||
{
|
{
|
||||||
|
if (usealtbar)
|
||||||
|
return;
|
||||||
|
|
||||||
int x, w, tw = 0;
|
int x, w, tw = 0;
|
||||||
int boxs = drw->fonts->h / 9;
|
int boxs = drw->fonts->h / 9;
|
||||||
int boxw = drw->fonts->h / 6 + 2;
|
int boxw = drw->fonts->h / 6 + 2;
|
||||||
|
@ -731,7 +752,7 @@ drawbar(Monitor *m)
|
||||||
urg & 1 << i);
|
urg & 1 << i);
|
||||||
x += w;
|
x += w;
|
||||||
}
|
}
|
||||||
w = blw = TEXTW(m->ltsymbol);
|
w = TEXTW(m->ltsymbol);
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||||
|
|
||||||
|
@ -802,7 +823,11 @@ focus(Client *c)
|
||||||
detachstack(c);
|
detachstack(c);
|
||||||
attachstack(c);
|
attachstack(c);
|
||||||
grabbuttons(c, 1);
|
grabbuttons(c, 1);
|
||||||
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
/* Avoid flickering when another client appears and the border
|
||||||
|
* is restored */
|
||||||
|
if (!solitary(c)) {
|
||||||
|
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
||||||
|
}
|
||||||
setfocus(c);
|
setfocus(c);
|
||||||
} else {
|
} else {
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||||
|
@ -1079,6 +1104,45 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
managealtbar(Window win, XWindowAttributes *wa)
|
||||||
|
{
|
||||||
|
Monitor *m;
|
||||||
|
if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m->barwin = win;
|
||||||
|
m->by = wa->y;
|
||||||
|
bh = m->bh = wa->height;
|
||||||
|
updatebarpos(m);
|
||||||
|
arrange(m);
|
||||||
|
XSelectInput(dpy, win, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||||
|
XMoveResizeWindow(dpy, win, wa->x, wa->y, wa->width, wa->height);
|
||||||
|
XMapWindow(dpy, win);
|
||||||
|
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
||||||
|
(unsigned char *) &win, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
managetray(Window win, XWindowAttributes *wa)
|
||||||
|
{
|
||||||
|
Monitor *m;
|
||||||
|
if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m->traywin = win;
|
||||||
|
m->tx = wa->x;
|
||||||
|
m->tw = wa->width;
|
||||||
|
updatebarpos(m);
|
||||||
|
arrange(m);
|
||||||
|
XSelectInput(dpy, win, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||||
|
XMoveResizeWindow(dpy, win, wa->x, wa->y, wa->width, wa->height);
|
||||||
|
XMapWindow(dpy, win);
|
||||||
|
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
||||||
|
(unsigned char *) &win, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mappingnotify(XEvent *e)
|
mappingnotify(XEvent *e)
|
||||||
{
|
{
|
||||||
|
@ -1097,7 +1161,9 @@ maprequest(XEvent *e)
|
||||||
|
|
||||||
if (!XGetWindowAttributes(dpy, ev->window, &wa) || wa.override_redirect)
|
if (!XGetWindowAttributes(dpy, ev->window, &wa) || wa.override_redirect)
|
||||||
return;
|
return;
|
||||||
if (!wintoclient(ev->window))
|
if (wmclasscontains(ev->window, altbarclass, ""))
|
||||||
|
managealtbar(ev->window, &wa);
|
||||||
|
else if (!wintoclient(ev->window))
|
||||||
manage(ev->window, &wa);
|
manage(ev->window, &wa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1283,6 +1349,11 @@ resizeclient(Client *c, int x, int y, int w, int h)
|
||||||
c->oldw = c->w; c->w = wc.width = w;
|
c->oldw = c->w; c->w = wc.width = w;
|
||||||
c->oldh = c->h; c->h = wc.height = h;
|
c->oldh = c->h; c->h = wc.height = h;
|
||||||
wc.border_width = c->bw;
|
wc.border_width = c->bw;
|
||||||
|
if (solitary(c)) {
|
||||||
|
c->w = wc.width += c->bw * 2;
|
||||||
|
c->h = wc.height += c->bw * 2;
|
||||||
|
wc.border_width = 0;
|
||||||
|
}
|
||||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
||||||
configure(c);
|
configure(c);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
@ -1393,7 +1464,9 @@ scan(void)
|
||||||
if (!XGetWindowAttributes(dpy, wins[i], &wa)
|
if (!XGetWindowAttributes(dpy, wins[i], &wa)
|
||||||
|| wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
|
|| wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
|
||||||
continue;
|
continue;
|
||||||
if (wa.map_state == IsViewable || getstate(wins[i]) == IconicState)
|
if (wmclasscontains(wins[i], altbarclass, ""))
|
||||||
|
managealtbar(wins[i], &wa);
|
||||||
|
else if (wa.map_state == IsViewable || getstate(wins[i]) == IconicState)
|
||||||
manage(wins[i], &wa);
|
manage(wins[i], &wa);
|
||||||
}
|
}
|
||||||
for (i = 0; i < num; i++) { /* now the transients */
|
for (i = 0; i < num; i++) { /* now the transients */
|
||||||
|
@ -1408,6 +1481,29 @@ scan(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
scantray(void)
|
||||||
|
{
|
||||||
|
unsigned int num;
|
||||||
|
Window d1, d2, *wins = NULL;
|
||||||
|
XWindowAttributes wa;
|
||||||
|
|
||||||
|
if (XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
|
||||||
|
for (unsigned int i = 0; i < num; i++) {
|
||||||
|
if (wmclasscontains(wins[i], altbarclass, alttrayname)) {
|
||||||
|
if (!XGetWindowAttributes(dpy, wins[i], &wa))
|
||||||
|
break;
|
||||||
|
managetray(wins[i], &wa);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wins)
|
||||||
|
XFree(wins);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sendmon(Client *c, Monitor *m)
|
sendmon(Client *c, Monitor *m)
|
||||||
{
|
{
|
||||||
|
@ -1546,7 +1642,7 @@ setup(void)
|
||||||
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
||||||
die("no fonts could be loaded.");
|
die("no fonts could be loaded.");
|
||||||
lrpad = drw->fonts->h;
|
lrpad = drw->fonts->h;
|
||||||
bh = drw->fonts->h + 2;
|
bh = usealtbar ? 0 : drw->fonts->h + 2;
|
||||||
updategeom();
|
updategeom();
|
||||||
/* init atoms */
|
/* init atoms */
|
||||||
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
|
@ -1595,6 +1691,7 @@ setup(void)
|
||||||
XSelectInput(dpy, root, wa.event_mask);
|
XSelectInput(dpy, root, wa.event_mask);
|
||||||
grabkeys();
|
grabkeys();
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
|
spawnbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1636,11 +1733,18 @@ sigchld(int unused)
|
||||||
while (0 < waitpid(-1, NULL, WNOHANG));
|
while (0 < waitpid(-1, NULL, WNOHANG));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
solitary(Client *c)
|
||||||
|
{
|
||||||
|
return ((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
|
||||||
|
|| &monocle == c->mon->lt[c->mon->sellt]->arrange)
|
||||||
|
&& !c->isfullscreen && !c->isfloating
|
||||||
|
&& NULL != c->mon->lt[c->mon->sellt]->arrange;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
if (arg->v == dmenucmd)
|
|
||||||
dmenumon[0] = '0' + selmon->num;
|
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
if (dpy)
|
if (dpy)
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
|
@ -1650,6 +1754,13 @@ spawn(const Arg *arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
spawnbar()
|
||||||
|
{
|
||||||
|
if (*altbarcmd)
|
||||||
|
system(altbarcmd);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tag(const Arg *arg)
|
tag(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
@ -1699,9 +1810,18 @@ tile(Monitor *m)
|
||||||
void
|
void
|
||||||
togglebar(const Arg *arg)
|
togglebar(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Polybar tray does not raise maprequest event. It must be manually scanned
|
||||||
|
* for. Scanning it too early while the tray is being populated would give
|
||||||
|
* wrong dimensions.
|
||||||
|
*/
|
||||||
|
if (!selmon->traywin)
|
||||||
|
scantray();
|
||||||
|
|
||||||
selmon->showbar = !selmon->showbar;
|
selmon->showbar = !selmon->showbar;
|
||||||
updatebarpos(selmon);
|
updatebarpos(selmon);
|
||||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, selmon->bh);
|
||||||
|
XMoveResizeWindow(dpy, selmon->traywin, selmon->tx, selmon->by, selmon->tw, selmon->bh);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1785,10 +1905,41 @@ unmanage(Client *c, int destroyed)
|
||||||
arrange(m);
|
arrange(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
unmanagealtbar(Window w)
|
||||||
|
{
|
||||||
|
Monitor *m = wintomon(w);
|
||||||
|
|
||||||
|
if (!m)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m->barwin = 0;
|
||||||
|
m->by = 0;
|
||||||
|
m->bh = 0;
|
||||||
|
updatebarpos(m);
|
||||||
|
arrange(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
unmanagetray(Window w)
|
||||||
|
{
|
||||||
|
Monitor *m = wintomon(w);
|
||||||
|
|
||||||
|
if (!m)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m->traywin = 0;
|
||||||
|
m->tx = 0;
|
||||||
|
m->tw = 0;
|
||||||
|
updatebarpos(m);
|
||||||
|
arrange(m);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
unmapnotify(XEvent *e)
|
unmapnotify(XEvent *e)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
|
Monitor *m;
|
||||||
XUnmapEvent *ev = &e->xunmap;
|
XUnmapEvent *ev = &e->xunmap;
|
||||||
|
|
||||||
if ((c = wintoclient(ev->window))) {
|
if ((c = wintoclient(ev->window))) {
|
||||||
|
@ -1796,12 +1947,18 @@ unmapnotify(XEvent *e)
|
||||||
setclientstate(c, WithdrawnState);
|
setclientstate(c, WithdrawnState);
|
||||||
else
|
else
|
||||||
unmanage(c, 0);
|
unmanage(c, 0);
|
||||||
}
|
} else if ((m = wintomon(ev->window)) && m->barwin == ev->window)
|
||||||
|
unmanagealtbar(ev->window);
|
||||||
|
else if (m->traywin == ev->window)
|
||||||
|
unmanagetray(ev->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updatebars(void)
|
updatebars(void)
|
||||||
{
|
{
|
||||||
|
if (usealtbar)
|
||||||
|
return;
|
||||||
|
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
XSetWindowAttributes wa = {
|
XSetWindowAttributes wa = {
|
||||||
.override_redirect = True,
|
.override_redirect = True,
|
||||||
|
@ -1827,11 +1984,11 @@ updatebarpos(Monitor *m)
|
||||||
m->wy = m->my;
|
m->wy = m->my;
|
||||||
m->wh = m->mh;
|
m->wh = m->mh;
|
||||||
if (m->showbar) {
|
if (m->showbar) {
|
||||||
m->wh -= bh;
|
m->wh -= m->bh;
|
||||||
m->by = m->topbar ? m->wy : m->wy + m->wh;
|
m->by = m->topbar ? m->wy : m->wy + m->wh;
|
||||||
m->wy = m->topbar ? m->wy + bh : m->wy;
|
m->wy = m->topbar ? m->wy + m->bh : m->wy;
|
||||||
} else
|
} else
|
||||||
m->by = -bh;
|
m->by = -m->bh;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2069,13 +2226,35 @@ 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->traywin)
|
||||||
return m;
|
return m;
|
||||||
if ((c = wintoclient(w)))
|
if ((c = wintoclient(w)))
|
||||||
return c->mon;
|
return c->mon;
|
||||||
return selmon;
|
return selmon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
wmclasscontains(Window win, const char *class, const char *name)
|
||||||
|
{
|
||||||
|
XClassHint ch = { NULL, NULL };
|
||||||
|
int res = 1;
|
||||||
|
|
||||||
|
if (XGetClassHint(dpy, win, &ch)) {
|
||||||
|
if (ch.res_name && strstr(ch.res_name, name) == NULL)
|
||||||
|
res = 0;
|
||||||
|
if (ch.res_class && strstr(ch.res_class, class) == NULL)
|
||||||
|
res = 0;
|
||||||
|
} else
|
||||||
|
res = 0;
|
||||||
|
|
||||||
|
if (ch.res_class)
|
||||||
|
XFree(ch.res_class);
|
||||||
|
if (ch.res_name)
|
||||||
|
XFree(ch.res_name);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/* There's no way to check accesses to destroyed windows, thus those cases are
|
/* There's no way to check accesses to destroyed windows, thus those cases are
|
||||||
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
||||||
* default error handler, which may call exit. */
|
* default error handler, which may call exit. */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,445 @@
|
||||||
|
From 9b5719969ce85c3ecc0238d49c0255c5c2cc79f0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: mihirlad55 <mihirlad55@gmail.com>
|
||||||
|
Date: Mon, 10 Aug 2020 01:39:28 +0000
|
||||||
|
Subject: [PATCH] Add support for managing external status bars
|
||||||
|
|
||||||
|
This patch allows dwm to manage other status bars such as
|
||||||
|
polybar/lemonbar without them needing to set override-redirect. For
|
||||||
|
all intents and purposes, DWM treats this bar as if it were its own
|
||||||
|
and as a result helps the status bar and DWM live in harmony.
|
||||||
|
|
||||||
|
This has a few advantages
|
||||||
|
* The bar does not block fullscreen windows
|
||||||
|
* DWM makes room for the status bar, so windows do not overlap the bar
|
||||||
|
* The bar can be hidden/killed and DWM will not keep an unsightly gap
|
||||||
|
where the bar was
|
||||||
|
* DWM receives EnterNotify events when your cursor enters the bar
|
||||||
|
|
||||||
|
To use another status bar, set usealtbar to 1 in your config.h and set
|
||||||
|
altbarclass to the class name (can be found using xprop) to the class
|
||||||
|
name of your status bar. Also make sure that if your status bar will
|
||||||
|
be displayed on top, topbar is set to 1 in your config, and if it will
|
||||||
|
be displayed on bottom, topbar is set to 0. This patch does not
|
||||||
|
support bars that are not docked at the top or at the bottom of your
|
||||||
|
monitor.
|
||||||
|
|
||||||
|
This verison of the patch fixes handling of polybar's tray.
|
||||||
|
|
||||||
|
The patch is developed at https://github.com/mihirlad55/dwm-anybar
|
||||||
|
---
|
||||||
|
config.def.h | 4 ++
|
||||||
|
dwm.c | 192 +++++++++++++++++++++++++++++++++++++++++++++++----
|
||||||
|
2 files changed, 181 insertions(+), 15 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1c0b587..f45211b 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -5,6 +5,10 @@ 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 usealtbar = 1; /* 1 means use non-dwm status bar */
|
||||||
|
+static const char *altbarclass = "Polybar"; /* Alternate bar class name */
|
||||||
|
+static const char *alttrayname = "tray"; /* Polybar tray instance name */
|
||||||
|
+static const char *altbarcmd = "$HOME/bar.sh"; /* Alternate bar launch command */
|
||||||
|
static const char *fonts[] = { "monospace:size=10" };
|
||||||
|
static const char dmenufont[] = "monospace:size=10";
|
||||||
|
static const char col_gray1[] = "#222222";
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 9fd0286..c1d8ce0 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -47,8 +47,8 @@
|
||||||
|
/* macros */
|
||||||
|
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
||||||
|
#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)) \
|
||||||
|
- * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||||
|
+#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->mx+(m)->mw) - MAX((x),(m)->mx)) \
|
||||||
|
+ * MAX(0, MIN((y)+(h),(m)->my+(m)->mh) - MAX((y),(m)->my)))
|
||||||
|
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||||
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
|
@@ -116,7 +116,8 @@ struct Monitor {
|
||||||
|
float mfact;
|
||||||
|
int nmaster;
|
||||||
|
int num;
|
||||||
|
- int by; /* bar geometry */
|
||||||
|
+ int by, bh; /* bar geometry */
|
||||||
|
+ int tx, tw; /* bar tray geometry */
|
||||||
|
int mx, my, mw, mh; /* screen size */
|
||||||
|
int wx, wy, ww, wh; /* window area */
|
||||||
|
unsigned int seltags;
|
||||||
|
@@ -129,6 +130,7 @@ struct Monitor {
|
||||||
|
Client *stack;
|
||||||
|
Monitor *next;
|
||||||
|
Window barwin;
|
||||||
|
+ Window traywin;
|
||||||
|
const Layout *lt[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -179,6 +181,8 @@ static void incnmaster(const Arg *arg);
|
||||||
|
static void keypress(XEvent *e);
|
||||||
|
static void killclient(const Arg *arg);
|
||||||
|
static void manage(Window w, XWindowAttributes *wa);
|
||||||
|
+static void managealtbar(Window win, XWindowAttributes *wa);
|
||||||
|
+static void managetray(Window win, XWindowAttributes *wa);
|
||||||
|
static void mappingnotify(XEvent *e);
|
||||||
|
static void maprequest(XEvent *e);
|
||||||
|
static void monocle(Monitor *m);
|
||||||
|
@@ -195,6 +199,7 @@ static void resizemouse(const Arg *arg);
|
||||||
|
static void restack(Monitor *m);
|
||||||
|
static void run(void);
|
||||||
|
static void scan(void);
|
||||||
|
+static void scantray(void);
|
||||||
|
static int sendevent(Client *c, Atom proto);
|
||||||
|
static void sendmon(Client *c, Monitor *m);
|
||||||
|
static void setclientstate(Client *c, long state);
|
||||||
|
@@ -207,6 +212,7 @@ static void seturgent(Client *c, int urg);
|
||||||
|
static void showhide(Client *c);
|
||||||
|
static void sigchld(int unused);
|
||||||
|
static void spawn(const Arg *arg);
|
||||||
|
+static void spawnbar();
|
||||||
|
static void tag(const Arg *arg);
|
||||||
|
static void tagmon(const Arg *arg);
|
||||||
|
static void tile(Monitor *);
|
||||||
|
@@ -216,6 +222,8 @@ static void toggletag(const Arg *arg);
|
||||||
|
static void toggleview(const Arg *arg);
|
||||||
|
static void unfocus(Client *c, int setfocus);
|
||||||
|
static void unmanage(Client *c, int destroyed);
|
||||||
|
+static void unmanagealtbar(Window w);
|
||||||
|
+static void unmanagetray(Window w);
|
||||||
|
static void unmapnotify(XEvent *e);
|
||||||
|
static void updatebarpos(Monitor *m);
|
||||||
|
static void updatebars(void);
|
||||||
|
@@ -230,6 +238,7 @@ static void updatewmhints(Client *c);
|
||||||
|
static void view(const Arg *arg);
|
||||||
|
static Client *wintoclient(Window w);
|
||||||
|
static Monitor *wintomon(Window w);
|
||||||
|
+static int wmclasscontains(Window win, const char *class, const char *name);
|
||||||
|
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
|
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||||
|
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
|
@@ -505,8 +514,10 @@ cleanupmon(Monitor *mon)
|
||||||
|
for (m = mons; m && m->next != mon; m = m->next);
|
||||||
|
m->next = mon->next;
|
||||||
|
}
|
||||||
|
- XUnmapWindow(dpy, mon->barwin);
|
||||||
|
- XDestroyWindow(dpy, mon->barwin);
|
||||||
|
+ if (!usealtbar) {
|
||||||
|
+ XUnmapWindow(dpy, mon->barwin);
|
||||||
|
+ XDestroyWindow(dpy, mon->barwin);
|
||||||
|
+ }
|
||||||
|
free(mon);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -568,7 +579,7 @@ configurenotify(XEvent *e)
|
||||||
|
for (c = m->clients; c; c = c->next)
|
||||||
|
if (c->isfullscreen)
|
||||||
|
resizeclient(c, m->mx, m->my, m->mw, m->mh);
|
||||||
|
- XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
|
||||||
|
+ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, m->bh);
|
||||||
|
}
|
||||||
|
focus(NULL);
|
||||||
|
arrange(NULL);
|
||||||
|
@@ -639,6 +650,7 @@ createmon(void)
|
||||||
|
m->nmaster = nmaster;
|
||||||
|
m->showbar = showbar;
|
||||||
|
m->topbar = topbar;
|
||||||
|
+ m->bh = bh;
|
||||||
|
m->lt[0] = &layouts[0];
|
||||||
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
|
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||||
|
@@ -649,10 +661,15 @@ void
|
||||||
|
destroynotify(XEvent *e)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
+ Monitor *m;
|
||||||
|
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
||||||
|
|
||||||
|
if ((c = wintoclient(ev->window)))
|
||||||
|
unmanage(c, 1);
|
||||||
|
+ else if ((m = wintomon(ev->window)) && m->barwin == ev->window)
|
||||||
|
+ unmanagealtbar(ev->window);
|
||||||
|
+ else if (m->traywin == ev->window)
|
||||||
|
+ unmanagetray(ev->window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -696,6 +713,9 @@ dirtomon(int dir)
|
||||||
|
void
|
||||||
|
drawbar(Monitor *m)
|
||||||
|
{
|
||||||
|
+ if (usealtbar)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
int x, w, tw = 0;
|
||||||
|
int boxs = drw->fonts->h / 9;
|
||||||
|
int boxw = drw->fonts->h / 6 + 2;
|
||||||
|
@@ -1077,6 +1097,45 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
|
focus(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+managealtbar(Window win, XWindowAttributes *wa)
|
||||||
|
+{
|
||||||
|
+ Monitor *m;
|
||||||
|
+ if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height)))
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ m->barwin = win;
|
||||||
|
+ m->by = wa->y;
|
||||||
|
+ bh = m->bh = wa->height;
|
||||||
|
+ updatebarpos(m);
|
||||||
|
+ arrange(m);
|
||||||
|
+ XSelectInput(dpy, win, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||||
|
+ XMoveResizeWindow(dpy, win, wa->x, wa->y, wa->width, wa->height);
|
||||||
|
+ XMapWindow(dpy, win);
|
||||||
|
+ XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
||||||
|
+ (unsigned char *) &win, 1);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+managetray(Window win, XWindowAttributes *wa)
|
||||||
|
+{
|
||||||
|
+ Monitor *m;
|
||||||
|
+ if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height)))
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ m->traywin = win;
|
||||||
|
+ m->tx = wa->x;
|
||||||
|
+ m->tw = wa->width;
|
||||||
|
+ updatebarpos(m);
|
||||||
|
+ arrange(m);
|
||||||
|
+ XSelectInput(dpy, win, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||||
|
+ XMoveResizeWindow(dpy, win, wa->x, wa->y, wa->width, wa->height);
|
||||||
|
+ XMapWindow(dpy, win);
|
||||||
|
+ XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
||||||
|
+ (unsigned char *) &win, 1);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
void
|
||||||
|
mappingnotify(XEvent *e)
|
||||||
|
{
|
||||||
|
@@ -1097,7 +1156,9 @@ maprequest(XEvent *e)
|
||||||
|
return;
|
||||||
|
if (wa.override_redirect)
|
||||||
|
return;
|
||||||
|
- if (!wintoclient(ev->window))
|
||||||
|
+ if (wmclasscontains(ev->window, altbarclass, ""))
|
||||||
|
+ managealtbar(ev->window, &wa);
|
||||||
|
+ else if (!wintoclient(ev->window))
|
||||||
|
manage(ev->window, &wa);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1393,7 +1454,9 @@ scan(void)
|
||||||
|
if (!XGetWindowAttributes(dpy, wins[i], &wa)
|
||||||
|
|| wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
|
||||||
|
continue;
|
||||||
|
- if (wa.map_state == IsViewable || getstate(wins[i]) == IconicState)
|
||||||
|
+ if (wmclasscontains(wins[i], altbarclass, ""))
|
||||||
|
+ managealtbar(wins[i], &wa);
|
||||||
|
+ else if (wa.map_state == IsViewable || getstate(wins[i]) == IconicState)
|
||||||
|
manage(wins[i], &wa);
|
||||||
|
}
|
||||||
|
for (i = 0; i < num; i++) { /* now the transients */
|
||||||
|
@@ -1408,6 +1471,29 @@ scan(void)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+scantray(void)
|
||||||
|
+{
|
||||||
|
+ unsigned int num;
|
||||||
|
+ Window d1, d2, *wins = NULL;
|
||||||
|
+ XWindowAttributes wa;
|
||||||
|
+
|
||||||
|
+ if (XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
|
||||||
|
+ for (unsigned int i = 0; i < num; i++) {
|
||||||
|
+ if (wmclasscontains(wins[i], altbarclass, alttrayname)) {
|
||||||
|
+ if (!XGetWindowAttributes(dpy, wins[i], &wa))
|
||||||
|
+ break;
|
||||||
|
+ managetray(wins[i], &wa);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (wins)
|
||||||
|
+ XFree(wins);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+
|
||||||
|
void
|
||||||
|
sendmon(Client *c, Monitor *m)
|
||||||
|
{
|
||||||
|
@@ -1546,7 +1632,7 @@ setup(void)
|
||||||
|
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
||||||
|
die("no fonts could be loaded.");
|
||||||
|
lrpad = drw->fonts->h;
|
||||||
|
- bh = drw->fonts->h + 2;
|
||||||
|
+ bh = usealtbar ? 0 : drw->fonts->h + 2;
|
||||||
|
updategeom();
|
||||||
|
/* init atoms */
|
||||||
|
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
|
@@ -1595,6 +1681,7 @@ setup(void)
|
||||||
|
XSelectInput(dpy, root, wa.event_mask);
|
||||||
|
grabkeys();
|
||||||
|
focus(NULL);
|
||||||
|
+ spawnbar();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1653,6 +1740,13 @@ spawn(const Arg *arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+spawnbar()
|
||||||
|
+{
|
||||||
|
+ if (*altbarcmd)
|
||||||
|
+ system(altbarcmd);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
tag(const Arg *arg)
|
||||||
|
{
|
||||||
|
@@ -1702,9 +1796,18 @@ tile(Monitor *m)
|
||||||
|
void
|
||||||
|
togglebar(const Arg *arg)
|
||||||
|
{
|
||||||
|
+ /**
|
||||||
|
+ * Polybar tray does not raise maprequest event. It must be manually scanned
|
||||||
|
+ * for. Scanning it too early while the tray is being populated would give
|
||||||
|
+ * wrong dimensions.
|
||||||
|
+ */
|
||||||
|
+ if (!selmon->traywin)
|
||||||
|
+ scantray();
|
||||||
|
+
|
||||||
|
selmon->showbar = !selmon->showbar;
|
||||||
|
updatebarpos(selmon);
|
||||||
|
- XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
||||||
|
+ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, selmon->bh);
|
||||||
|
+ XMoveResizeWindow(dpy, selmon->traywin, selmon->tx, selmon->by, selmon->tw, selmon->bh);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1787,10 +1890,41 @@ unmanage(Client *c, int destroyed)
|
||||||
|
arrange(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+unmanagealtbar(Window w)
|
||||||
|
+{
|
||||||
|
+ Monitor *m = wintomon(w);
|
||||||
|
+
|
||||||
|
+ if (!m)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ m->barwin = 0;
|
||||||
|
+ m->by = 0;
|
||||||
|
+ m->bh = 0;
|
||||||
|
+ updatebarpos(m);
|
||||||
|
+ arrange(m);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+unmanagetray(Window w)
|
||||||
|
+{
|
||||||
|
+ Monitor *m = wintomon(w);
|
||||||
|
+
|
||||||
|
+ if (!m)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ m->traywin = 0;
|
||||||
|
+ m->tx = 0;
|
||||||
|
+ m->tw = 0;
|
||||||
|
+ updatebarpos(m);
|
||||||
|
+ arrange(m);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
unmapnotify(XEvent *e)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
+ Monitor *m;
|
||||||
|
XUnmapEvent *ev = &e->xunmap;
|
||||||
|
|
||||||
|
if ((c = wintoclient(ev->window))) {
|
||||||
|
@@ -1798,12 +1932,18 @@ unmapnotify(XEvent *e)
|
||||||
|
setclientstate(c, WithdrawnState);
|
||||||
|
else
|
||||||
|
unmanage(c, 0);
|
||||||
|
- }
|
||||||
|
+ } else if ((m = wintomon(ev->window)) && m->barwin == ev->window)
|
||||||
|
+ unmanagealtbar(ev->window);
|
||||||
|
+ else if (m->traywin == ev->window)
|
||||||
|
+ unmanagetray(ev->window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
updatebars(void)
|
||||||
|
{
|
||||||
|
+ if (usealtbar)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
Monitor *m;
|
||||||
|
XSetWindowAttributes wa = {
|
||||||
|
.override_redirect = True,
|
||||||
|
@@ -1829,11 +1969,11 @@ updatebarpos(Monitor *m)
|
||||||
|
m->wy = m->my;
|
||||||
|
m->wh = m->mh;
|
||||||
|
if (m->showbar) {
|
||||||
|
- m->wh -= bh;
|
||||||
|
+ m->wh -= m->bh;
|
||||||
|
m->by = m->topbar ? m->wy : m->wy + m->wh;
|
||||||
|
- m->wy = m->topbar ? m->wy + bh : m->wy;
|
||||||
|
+ m->wy = m->topbar ? m->wy + m->bh : m->wy;
|
||||||
|
} else
|
||||||
|
- m->by = -bh;
|
||||||
|
+ m->by = -m->bh;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -2070,13 +2210,35 @@ wintomon(Window w)
|
||||||
|
if (w == root && getrootptr(&x, &y))
|
||||||
|
return recttomon(x, y, 1, 1);
|
||||||
|
for (m = mons; m; m = m->next)
|
||||||
|
- if (w == m->barwin)
|
||||||
|
+ if (w == m->barwin || w == m->traywin)
|
||||||
|
return m;
|
||||||
|
if ((c = wintoclient(w)))
|
||||||
|
return c->mon;
|
||||||
|
return selmon;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int
|
||||||
|
+wmclasscontains(Window win, const char *class, const char *name)
|
||||||
|
+{
|
||||||
|
+ XClassHint ch = { NULL, NULL };
|
||||||
|
+ int res = 1;
|
||||||
|
+
|
||||||
|
+ if (XGetClassHint(dpy, win, &ch)) {
|
||||||
|
+ if (ch.res_name && strstr(ch.res_name, name) == NULL)
|
||||||
|
+ res = 0;
|
||||||
|
+ if (ch.res_class && strstr(ch.res_class, class) == NULL)
|
||||||
|
+ res = 0;
|
||||||
|
+ } else
|
||||||
|
+ res = 0;
|
||||||
|
+
|
||||||
|
+ if (ch.res_class)
|
||||||
|
+ XFree(ch.res_class);
|
||||||
|
+ if (ch.res_name)
|
||||||
|
+ XFree(ch.res_name);
|
||||||
|
+
|
||||||
|
+ return res;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/* There's no way to check accesses to destroyed windows, thus those cases are
|
||||||
|
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
||||||
|
* default error handler, which may call exit. */
|
||||||
|
--
|
||||||
|
2.28.0
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
diff --git dwm.c dwm.c
|
||||||
|
index 0fc328a..4a767bd 100644
|
||||||
|
--- dwm.c
|
||||||
|
+++ dwm.c
|
||||||
|
@@ -206,6 +206,7 @@ static void setup(void);
|
||||||
|
static void seturgent(Client *c, int urg);
|
||||||
|
static void showhide(Client *c);
|
||||||
|
static void sigchld(int unused);
|
||||||
|
+static int solitary(Client *c);
|
||||||
|
static void spawn(const Arg *arg);
|
||||||
|
static void tag(const Arg *arg);
|
||||||
|
static void tagmon(const Arg *arg);
|
||||||
|
@@ -802,7 +803,11 @@ focus(Client *c)
|
||||||
|
detachstack(c);
|
||||||
|
attachstack(c);
|
||||||
|
grabbuttons(c, 1);
|
||||||
|
- XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
||||||
|
+ /* Avoid flickering when another client appears and the border
|
||||||
|
+ * is restored */
|
||||||
|
+ if (!solitary(c)) {
|
||||||
|
+ XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
||||||
|
+ }
|
||||||
|
setfocus(c);
|
||||||
|
} else {
|
||||||
|
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||||
|
@@ -1288,6 +1293,11 @@ resizeclient(Client *c, int x, int y, int w, int h)
|
||||||
|
c->oldw = c->w; c->w = wc.width = w;
|
||||||
|
c->oldh = c->h; c->h = wc.height = h;
|
||||||
|
wc.border_width = c->bw;
|
||||||
|
+ if (solitary(c)) {
|
||||||
|
+ c->w = wc.width += c->bw * 2;
|
||||||
|
+ c->h = wc.height += c->bw * 2;
|
||||||
|
+ wc.border_width = 0;
|
||||||
|
+ }
|
||||||
|
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
||||||
|
configure(c);
|
||||||
|
XSync(dpy, False);
|
||||||
|
@@ -1642,6 +1652,15 @@ sigchld(int unused)
|
||||||
|
while (0 < waitpid(-1, NULL, WNOHANG));
|
||||||
|
}
|
||||||
|
|
||||||
|
+int
|
||||||
|
+solitary(Client *c)
|
||||||
|
+{
|
||||||
|
+ return ((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
|
||||||
|
+ || &monocle == c->mon->lt[c->mon->sellt]->arrange)
|
||||||
|
+ && !c->isfullscreen && !c->isfloating
|
||||||
|
+ && NULL != c->mon->lt[c->mon->sellt]->arrange;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
spawn(const Arg *arg)
|
||||||
|
{
|
|
@ -0,0 +1,262 @@
|
||||||
|
From c35fd03ec002e1f4476a75203ff9b5cbcc630177 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michel Boaventura <michel.boaventura@protonmail.com>
|
||||||
|
Date: Wed, 10 Jun 2020 10:46:51 -0300
|
||||||
|
Subject: [PATCH] Update Vanity Gaps to master
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 21 +++++++
|
||||||
|
dwm.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++----
|
||||||
|
2 files changed, 163 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1c0b587..0927c2d 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -3,6 +3,11 @@
|
||||||
|
/* appearance */
|
||||||
|
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
|
+static const unsigned int gappih = 10; /* horiz inner gap between windows */
|
||||||
|
+static const unsigned int gappiv = 10; /* vert inner gap between windows */
|
||||||
|
+static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
|
||||||
|
+static const unsigned int gappov = 10; /* vert outer gap between windows and screen edge */
|
||||||
|
+static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
||||||
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
|
static const char *fonts[] = { "monospace:size=10" };
|
||||||
|
@@ -70,6 +75,22 @@ static Key keys[] = {
|
||||||
|
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
|
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
|
+ { MODKEY|Mod4Mask, XK_h, incrgaps, {.i = +1 } },
|
||||||
|
+ { MODKEY|Mod4Mask, XK_l, incrgaps, {.i = -1 } },
|
||||||
|
+ { MODKEY|Mod4Mask|ShiftMask, XK_h, incrogaps, {.i = +1 } },
|
||||||
|
+ { MODKEY|Mod4Mask|ShiftMask, XK_l, incrogaps, {.i = -1 } },
|
||||||
|
+ { MODKEY|Mod4Mask|ControlMask, XK_h, incrigaps, {.i = +1 } },
|
||||||
|
+ { MODKEY|Mod4Mask|ControlMask, XK_l, incrigaps, {.i = -1 } },
|
||||||
|
+ { MODKEY|Mod4Mask, XK_0, togglegaps, {0} },
|
||||||
|
+ { MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} },
|
||||||
|
+ { MODKEY, XK_y, incrihgaps, {.i = +1 } },
|
||||||
|
+ { MODKEY, XK_o, incrihgaps, {.i = -1 } },
|
||||||
|
+ { MODKEY|ControlMask, XK_y, incrivgaps, {.i = +1 } },
|
||||||
|
+ { MODKEY|ControlMask, XK_o, incrivgaps, {.i = -1 } },
|
||||||
|
+ { MODKEY|Mod4Mask, XK_y, incrohgaps, {.i = +1 } },
|
||||||
|
+ { MODKEY|Mod4Mask, XK_o, incrohgaps, {.i = -1 } },
|
||||||
|
+ { MODKEY|ShiftMask, XK_y, incrovgaps, {.i = +1 } },
|
||||||
|
+ { MODKEY|ShiftMask, XK_o, incrovgaps, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_Return, zoom, {0} },
|
||||||
|
{ MODKEY, XK_Tab, view, {0} },
|
||||||
|
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 9fd0286..50dbbaf 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -119,6 +119,10 @@ struct Monitor {
|
||||||
|
int by; /* bar geometry */
|
||||||
|
int mx, my, mw, mh; /* screen size */
|
||||||
|
int wx, wy, ww, wh; /* window area */
|
||||||
|
+ int gappih; /* horizontal gap between windows */
|
||||||
|
+ int gappiv; /* vertical gap between windows */
|
||||||
|
+ int gappoh; /* horizontal outer gaps */
|
||||||
|
+ int gappov; /* vertical outer gaps */
|
||||||
|
unsigned int seltags;
|
||||||
|
unsigned int sellt;
|
||||||
|
unsigned int tagset[2];
|
||||||
|
@@ -200,6 +204,16 @@ static void sendmon(Client *c, Monitor *m);
|
||||||
|
static void setclientstate(Client *c, long state);
|
||||||
|
static void setfocus(Client *c);
|
||||||
|
static void setfullscreen(Client *c, int fullscreen);
|
||||||
|
+static void setgaps(int oh, int ov, int ih, int iv);
|
||||||
|
+static void incrgaps(const Arg *arg);
|
||||||
|
+static void incrigaps(const Arg *arg);
|
||||||
|
+static void incrogaps(const Arg *arg);
|
||||||
|
+static void incrohgaps(const Arg *arg);
|
||||||
|
+static void incrovgaps(const Arg *arg);
|
||||||
|
+static void incrihgaps(const Arg *arg);
|
||||||
|
+static void incrivgaps(const Arg *arg);
|
||||||
|
+static void togglegaps(const Arg *arg);
|
||||||
|
+static void defaultgaps(const Arg *arg);
|
||||||
|
static void setlayout(const Arg *arg);
|
||||||
|
static void setmfact(const Arg *arg);
|
||||||
|
static void setup(void);
|
||||||
|
@@ -241,6 +255,7 @@ static char stext[256];
|
||||||
|
static int screen;
|
||||||
|
static int sw, sh; /* X display screen geometry width, height */
|
||||||
|
static int bh, blw = 0; /* bar geometry */
|
||||||
|
+static int enablegaps = 1; /* enables gaps, used by togglegaps */
|
||||||
|
static int lrpad; /* sum of left and right padding for text */
|
||||||
|
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||||
|
static unsigned int numlockmask = 0;
|
||||||
|
@@ -639,6 +654,10 @@ createmon(void)
|
||||||
|
m->nmaster = nmaster;
|
||||||
|
m->showbar = showbar;
|
||||||
|
m->topbar = topbar;
|
||||||
|
+ m->gappih = gappih;
|
||||||
|
+ m->gappiv = gappiv;
|
||||||
|
+ m->gappoh = gappoh;
|
||||||
|
+ m->gappov = gappov;
|
||||||
|
m->lt[0] = &layouts[0];
|
||||||
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
|
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||||
|
@@ -1498,6 +1517,111 @@ setfullscreen(Client *c, int fullscreen)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+setgaps(int oh, int ov, int ih, int iv)
|
||||||
|
+{
|
||||||
|
+ if (oh < 0) oh = 0;
|
||||||
|
+ if (ov < 0) ov = 0;
|
||||||
|
+ if (ih < 0) ih = 0;
|
||||||
|
+ if (iv < 0) iv = 0;
|
||||||
|
+
|
||||||
|
+ selmon->gappoh = oh;
|
||||||
|
+ selmon->gappov = ov;
|
||||||
|
+ selmon->gappih = ih;
|
||||||
|
+ selmon->gappiv = iv;
|
||||||
|
+ arrange(selmon);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+togglegaps(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ enablegaps = !enablegaps;
|
||||||
|
+ arrange(selmon);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+defaultgaps(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ setgaps(gappoh, gappov, gappih, gappiv);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+incrgaps(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ setgaps(
|
||||||
|
+ selmon->gappoh + arg->i,
|
||||||
|
+ selmon->gappov + arg->i,
|
||||||
|
+ selmon->gappih + arg->i,
|
||||||
|
+ selmon->gappiv + arg->i
|
||||||
|
+ );
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+incrigaps(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ setgaps(
|
||||||
|
+ selmon->gappoh,
|
||||||
|
+ selmon->gappov,
|
||||||
|
+ selmon->gappih + arg->i,
|
||||||
|
+ selmon->gappiv + arg->i
|
||||||
|
+ );
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+incrogaps(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ setgaps(
|
||||||
|
+ selmon->gappoh + arg->i,
|
||||||
|
+ selmon->gappov + arg->i,
|
||||||
|
+ selmon->gappih,
|
||||||
|
+ selmon->gappiv
|
||||||
|
+ );
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+incrohgaps(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ setgaps(
|
||||||
|
+ selmon->gappoh + arg->i,
|
||||||
|
+ selmon->gappov,
|
||||||
|
+ selmon->gappih,
|
||||||
|
+ selmon->gappiv
|
||||||
|
+ );
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+incrovgaps(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ setgaps(
|
||||||
|
+ selmon->gappoh,
|
||||||
|
+ selmon->gappov + arg->i,
|
||||||
|
+ selmon->gappih,
|
||||||
|
+ selmon->gappiv
|
||||||
|
+ );
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+incrihgaps(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ setgaps(
|
||||||
|
+ selmon->gappoh,
|
||||||
|
+ selmon->gappov,
|
||||||
|
+ selmon->gappih + arg->i,
|
||||||
|
+ selmon->gappiv
|
||||||
|
+ );
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+incrivgaps(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ setgaps(
|
||||||
|
+ selmon->gappoh,
|
||||||
|
+ selmon->gappov,
|
||||||
|
+ selmon->gappih,
|
||||||
|
+ selmon->gappiv + arg->i
|
||||||
|
+ );
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
setlayout(const Arg *arg)
|
||||||
|
{
|
||||||
|
@@ -1674,28 +1798,34 @@ tagmon(const Arg *arg)
|
||||||
|
void
|
||||||
|
tile(Monitor *m)
|
||||||
|
{
|
||||||
|
- unsigned int i, n, h, mw, my, ty;
|
||||||
|
+ unsigned int i, n, h, r, oe = enablegaps, ie = enablegaps, mw, my, ty;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
+ if (smartgaps == n) {
|
||||||
|
+ oe = 0; // outer gaps disabled
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (n > m->nmaster)
|
||||||
|
- mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
|
+ mw = m->nmaster ? (m->ww + m->gappiv*ie) * m->mfact : 0;
|
||||||
|
else
|
||||||
|
- mw = m->ww;
|
||||||
|
- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
|
+ mw = m->ww - 2*m->gappov*oe + m->gappiv*ie;
|
||||||
|
+ for (i = 0, my = ty = m->gappoh*oe, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
|
if (i < m->nmaster) {
|
||||||
|
- h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||||
|
- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
|
- if (my + HEIGHT(c) < m->wh)
|
||||||
|
- my += HEIGHT(c);
|
||||||
|
+ r = MIN(n, m->nmaster) - i;
|
||||||
|
+ h = (m->wh - my - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
|
||||||
|
+ resize(c, m->wx + m->gappov*oe, m->wy + my, mw - (2*c->bw) - m->gappiv*ie, h - (2*c->bw), 0);
|
||||||
|
+ if (my + HEIGHT(c) + m->gappih*ie < m->wh)
|
||||||
|
+ my += HEIGHT(c) + m->gappih*ie;
|
||||||
|
} else {
|
||||||
|
- h = (m->wh - ty) / (n - i);
|
||||||
|
- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
|
- if (ty + HEIGHT(c) < m->wh)
|
||||||
|
- ty += HEIGHT(c);
|
||||||
|
+ r = n - i;
|
||||||
|
+ h = (m->wh - ty - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
|
||||||
|
+ resize(c, m->wx + mw + m->gappov*oe, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappov*oe, h - (2*c->bw), 0);
|
||||||
|
+ if (ty + HEIGHT(c) + m->gappih*ie < m->wh)
|
||||||
|
+ ty += HEIGHT(c) + m->gappih*ie;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
Loading…
Reference in New Issue