Compare commits
22 Commits
myBuild
...
centeredma
Author | SHA1 | Date | |
---|---|---|---|
|
00574da349 | ||
|
2b480b5562 | ||
|
c4f02778e7 | ||
|
5f5c7bedc0 | ||
|
7b996bd528 | ||
|
2b8e170bc5 | ||
|
44ae2e4c7f | ||
|
f21eb96261 | ||
|
1622204a34 | ||
|
2ec5aff8b6 | ||
|
049c4e1f66 | ||
|
1c509d1e52 | ||
|
cc937128ea | ||
|
d329aaa2b4 | ||
|
57f78bf9dd | ||
|
b3752ff756 | ||
|
585be283d3 | ||
|
aa76446478 | ||
|
3136d7789b | ||
|
164d7179ed | ||
|
af66a53e65 | ||
|
a00158cf00 |
52
.gitignore
vendored
Normal file
52
.gitignore
vendored
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Object files
|
||||||
|
*.o
|
||||||
|
*.ko
|
||||||
|
*.obj
|
||||||
|
*.elf
|
||||||
|
|
||||||
|
# Linker output
|
||||||
|
*.ilk
|
||||||
|
*.map
|
||||||
|
*.exp
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
*.lib
|
||||||
|
*.a
|
||||||
|
*.la
|
||||||
|
*.lo
|
||||||
|
|
||||||
|
# Shared objects (inc. Windows DLLs)
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
*.i*86
|
||||||
|
*.x86_64
|
||||||
|
*.hex
|
||||||
|
|
||||||
|
# Debug files
|
||||||
|
*.dSYM/
|
||||||
|
*.su
|
||||||
|
*.idb
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
# Kernel Module Compile Results
|
||||||
|
*.mod*
|
||||||
|
*.cmd
|
||||||
|
.tmp_versions/
|
||||||
|
modules.order
|
||||||
|
Module.symvers
|
||||||
|
Mkfile.old
|
||||||
|
dkms.conf
|
2
Makefile
2
Makefile
|
@ -26,7 +26,7 @@ dwm: ${OBJ}
|
||||||
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
|
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz config.h
|
||||||
|
|
||||||
dist: clean
|
dist: clean
|
||||||
mkdir -p dwm-${VERSION}
|
mkdir -p dwm-${VERSION}
|
||||||
|
|
51
config.def.h
51
config.def.h
|
@ -1,12 +1,15 @@
|
||||||
|
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <X11/XF86keysym.h>
|
||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
static const unsigned int snap = 32; /* snap pixel */
|
static const unsigned int gappx = 0; /* gaps between windows */
|
||||||
|
static const unsigned int snap = 16; /* 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 char *fonts[] = { "fira:size=10" };
|
||||||
static const char dmenufont[] = "monospace:size=10";
|
static const char dmenufont[] = "fira:size=10";
|
||||||
static const char col_gray1[] = "#222222";
|
static const char col_gray1[] = "#222222";
|
||||||
static const char col_gray2[] = "#444444";
|
static const char col_gray2[] = "#444444";
|
||||||
static const char col_gray3[] = "#bbbbbb";
|
static const char col_gray3[] = "#bbbbbb";
|
||||||
|
@ -16,6 +19,7 @@ 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 },
|
||||||
|
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* tagging */
|
/* tagging */
|
||||||
|
@ -41,10 +45,14 @@ static const Layout layouts[] = {
|
||||||
{ "[]=", tile }, /* first entry is default */
|
{ "[]=", tile }, /* first entry is default */
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
{ "[M]", monocle },
|
{ "[M]", monocle },
|
||||||
|
{ "TTT", bstack },
|
||||||
|
{ "===", bstackhoriz },
|
||||||
|
{ "|M|", centeredmaster },
|
||||||
|
{ ">M>", centeredfloatingmaster },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 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} }, \
|
||||||
|
@ -59,15 +67,26 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
|
||||||
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 *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 const char *volmute[] = { "amixer", "-q", "set", "Master", "toggle", NULL };
|
||||||
|
static const char *volup[] = { "amixer", "-q", "set", "Master", "5%+", "unmute", NULL};
|
||||||
|
static const char *voldown[] = { "amixer", "-q", "set", "Master", "5%-", "unmute", NULL };
|
||||||
|
|
||||||
|
static const char *brupcmd[] = { "xbacklight", "-inc", "5%", NULL };
|
||||||
|
static const char *brdowncmd[] = { "xbacklight", "-dec", "5%", NULL };
|
||||||
|
|
||||||
|
static const char *playplaypause[] = { "playerctl", "play-pause" };
|
||||||
|
static const char *playnext[] = { "playerctl", "next" };
|
||||||
|
static const char *playprev[] = { "playerctl", "previous" };
|
||||||
|
|
||||||
static Key keys[] = {
|
static Key keys[] = {
|
||||||
/* modifier key function argument */
|
/* modifier key function argument */
|
||||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
{ MODKEY, XK_u, spawn, {.v = dmenucmd } },
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
{ MODKEY, XK_greater,incnmaster, {.i = +1 } },
|
||||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
{ MODKEY, XK_less, incnmaster, {.i = -1 } },
|
||||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
{ MODKEY, XK_Return, zoom, {0} },
|
{ MODKEY, XK_Return, zoom, {0} },
|
||||||
|
@ -76,6 +95,10 @@ static Key keys[] = {
|
||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
|
{ MODKEY, XK_y, setlayout, {.v = &layouts[3]} },
|
||||||
|
{ MODKEY|ShiftMask, XK_y, setlayout, {.v = &layouts[4]} },
|
||||||
|
{ MODKEY, XK_i, setlayout, {.v = &layouts[5]} },
|
||||||
|
{ MODKEY|ShiftMask, XK_i, setlayout, {.v = &layouts[6]} },
|
||||||
{ MODKEY, XK_space, setlayout, {0} },
|
{ MODKEY, XK_space, setlayout, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||||
|
@ -84,6 +107,9 @@ static Key keys[] = {
|
||||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||||
|
{ MODKEY, XK_minus, setgaps, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_equal, setgaps, {.i = +1 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
|
||||||
TAGKEYS( XK_1, 0)
|
TAGKEYS( XK_1, 0)
|
||||||
TAGKEYS( XK_2, 1)
|
TAGKEYS( XK_2, 1)
|
||||||
TAGKEYS( XK_3, 2)
|
TAGKEYS( XK_3, 2)
|
||||||
|
@ -94,6 +120,14 @@ static Key keys[] = {
|
||||||
TAGKEYS( XK_8, 7)
|
TAGKEYS( XK_8, 7)
|
||||||
TAGKEYS( XK_9, 8)
|
TAGKEYS( XK_9, 8)
|
||||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||||
|
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = volup} },
|
||||||
|
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = voldown} },
|
||||||
|
{ 0, XF86XK_AudioMute, spawn, {.v = volmute} },
|
||||||
|
{ 0, XF86XK_MonBrightnessUp, spawn, {.v = brupcmd} },
|
||||||
|
{ 0, XF86XK_MonBrightnessDown, spawn, {.v = brdowncmd} },
|
||||||
|
{ 0, XF86XK_AudioPlay, spawn, {.v = playplaypause} },
|
||||||
|
{ 0, XF86XK_AudioNext, spawn, {.v = playnext} },
|
||||||
|
{ 0, XF86XK_AudioPrev, spawn, {.v = playprev} },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* button definitions */
|
/* button definitions */
|
||||||
|
@ -102,6 +136,7 @@ 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]} },
|
||||||
|
{ ClkWinTitle, 0, Button1, togglewin, {0} },
|
||||||
{ 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} },
|
||||||
|
|
409
dwm.c
409
dwm.c
|
@ -50,6 +50,7 @@
|
||||||
#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)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
||||||
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||||
|
#define HIDDEN(C) ((getstate(C->win) == IconicState))
|
||||||
#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)
|
||||||
|
@ -59,7 +60,7 @@
|
||||||
|
|
||||||
/* enums */
|
/* enums */
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
enum { SchemeNorm, SchemeSel, SchemeHid }; /* color schemes */
|
||||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||||
|
@ -111,14 +112,18 @@ typedef struct {
|
||||||
void (*arrange)(Monitor *);
|
void (*arrange)(Monitor *);
|
||||||
} Layout;
|
} Layout;
|
||||||
|
|
||||||
|
typedef struct Pertag Pertag;
|
||||||
struct Monitor {
|
struct Monitor {
|
||||||
char ltsymbol[16];
|
char ltsymbol[16];
|
||||||
float mfact;
|
float mfact;
|
||||||
int nmaster;
|
int nmaster;
|
||||||
int num;
|
int num;
|
||||||
int by; /* bar geometry */
|
int by; /* bar geometry */
|
||||||
|
int btw; /* width of tasks portion of bar */
|
||||||
|
int bt; /* number of tasks */
|
||||||
int mx, my, mw, mh; /* screen size */
|
int mx, my, mw, mh; /* screen size */
|
||||||
int wx, wy, ww, wh; /* window area */
|
int wx, wy, ww, wh; /* window area */
|
||||||
|
int gappx; /* gaps between windows */
|
||||||
unsigned int seltags;
|
unsigned int seltags;
|
||||||
unsigned int sellt;
|
unsigned int sellt;
|
||||||
unsigned int tagset[2];
|
unsigned int tagset[2];
|
||||||
|
@ -130,6 +135,7 @@ struct Monitor {
|
||||||
Monitor *next;
|
Monitor *next;
|
||||||
Window barwin;
|
Window barwin;
|
||||||
const Layout *lt[2];
|
const Layout *lt[2];
|
||||||
|
Pertag *pertag;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -174,6 +180,7 @@ static long getstate(Window w);
|
||||||
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||||
static void grabbuttons(Client *c, int focused);
|
static void grabbuttons(Client *c, int focused);
|
||||||
static void grabkeys(void);
|
static void grabkeys(void);
|
||||||
|
static void hide(Client *c);
|
||||||
static void incnmaster(const Arg *arg);
|
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);
|
||||||
|
@ -193,16 +200,19 @@ static void resizeclient(Client *c, int x, int y, int w, int h);
|
||||||
static void resizemouse(const Arg *arg);
|
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 runAutostart(void);
|
||||||
static void scan(void);
|
static void scan(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);
|
||||||
static void setfocus(Client *c);
|
static void setfocus(Client *c);
|
||||||
static void setfullscreen(Client *c, int fullscreen);
|
static void setfullscreen(Client *c, int fullscreen);
|
||||||
|
static void setgaps(const Arg *arg);
|
||||||
static void setlayout(const Arg *arg);
|
static void setlayout(const Arg *arg);
|
||||||
static void setmfact(const Arg *arg);
|
static void setmfact(const Arg *arg);
|
||||||
static void setup(void);
|
static void setup(void);
|
||||||
static void seturgent(Client *c, int urg);
|
static void seturgent(Client *c, int urg);
|
||||||
|
static void show(Client *c);
|
||||||
static void showhide(Client *c);
|
static void showhide(Client *c);
|
||||||
static void sigchld(int unused);
|
static void sigchld(int unused);
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
|
@ -213,6 +223,7 @@ static void togglebar(const Arg *arg);
|
||||||
static void togglefloating(const Arg *arg);
|
static void togglefloating(const Arg *arg);
|
||||||
static void toggletag(const Arg *arg);
|
static void toggletag(const Arg *arg);
|
||||||
static void toggleview(const Arg *arg);
|
static void toggleview(const Arg *arg);
|
||||||
|
static void togglewin(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 unmapnotify(XEvent *e);
|
static void unmapnotify(XEvent *e);
|
||||||
|
@ -233,6 +244,10 @@ 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);
|
||||||
static void zoom(const Arg *arg);
|
static void zoom(const Arg *arg);
|
||||||
|
static void bstack(Monitor *m);
|
||||||
|
static void bstackhoriz(Monitor *m);
|
||||||
|
static void centeredmaster(Monitor *m);
|
||||||
|
static void centeredfloatingmaster(Monitor *m);
|
||||||
|
|
||||||
/* variables */
|
/* variables */
|
||||||
static const char broken[] = "broken";
|
static const char broken[] = "broken";
|
||||||
|
@ -271,6 +286,15 @@ static Window root, wmcheckwin;
|
||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
struct Pertag {
|
||||||
|
unsigned int curtag, prevtag; /* current and previous tag */
|
||||||
|
int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
|
||||||
|
float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
|
||||||
|
unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
|
||||||
|
const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
|
||||||
|
int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
|
||||||
|
};
|
||||||
|
|
||||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||||
|
|
||||||
|
@ -439,10 +463,25 @@ 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;
|
||||||
else if (ev->x > selmon->ww - TEXTW(stext))
|
/* 2px right padding */
|
||||||
|
else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2)
|
||||||
click = ClkStatusText;
|
click = ClkStatusText;
|
||||||
|
else {
|
||||||
|
x += blw;
|
||||||
|
c = m->clients;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (!ISVISIBLE(c))
|
||||||
|
continue;
|
||||||
else
|
else
|
||||||
|
x += (1.0 / (double)m->bt) * m->btw;
|
||||||
|
} while (ev->x > x && (c = c->next));
|
||||||
|
|
||||||
|
if (c) {
|
||||||
click = ClkWinTitle;
|
click = ClkWinTitle;
|
||||||
|
arg.v = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if ((c = wintoclient(ev->window))) {
|
} else if ((c = wintoclient(ev->window))) {
|
||||||
focus(c);
|
focus(c);
|
||||||
restack(selmon);
|
restack(selmon);
|
||||||
|
@ -452,7 +491,7 @@ 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))
|
||||||
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
|
void
|
||||||
|
@ -631,6 +670,7 @@ Monitor *
|
||||||
createmon(void)
|
createmon(void)
|
||||||
{
|
{
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
m = ecalloc(1, sizeof(Monitor));
|
m = ecalloc(1, sizeof(Monitor));
|
||||||
m->tagset[0] = m->tagset[1] = 1;
|
m->tagset[0] = m->tagset[1] = 1;
|
||||||
|
@ -638,9 +678,24 @@ createmon(void)
|
||||||
m->nmaster = nmaster;
|
m->nmaster = nmaster;
|
||||||
m->showbar = showbar;
|
m->showbar = showbar;
|
||||||
m->topbar = topbar;
|
m->topbar = topbar;
|
||||||
|
m->gappx = gappx;
|
||||||
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);
|
||||||
|
m->pertag = ecalloc(1, sizeof(Pertag));
|
||||||
|
m->pertag->curtag = m->pertag->prevtag = 1;
|
||||||
|
|
||||||
|
for (i = 0; i <= LENGTH(tags); i++) {
|
||||||
|
m->pertag->nmasters[i] = m->nmaster;
|
||||||
|
m->pertag->mfacts[i] = m->mfact;
|
||||||
|
|
||||||
|
m->pertag->ltidxs[i][0] = m->lt[0];
|
||||||
|
m->pertag->ltidxs[i][1] = m->lt[1];
|
||||||
|
m->pertag->sellts[i] = m->sellt;
|
||||||
|
|
||||||
|
m->pertag->showbars[i] = m->showbar;
|
||||||
|
}
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,9 +750,8 @@ dirtomon(int dir)
|
||||||
void
|
void
|
||||||
drawbar(Monitor *m)
|
drawbar(Monitor *m)
|
||||||
{
|
{
|
||||||
int x, w, sw = 0;
|
int x, w, sw = 0, n = 0, scm;
|
||||||
int boxs = drw->fonts->h / 9;
|
int boxw = drw->fonts->h / 6;
|
||||||
int boxw = drw->fonts->h / 6 + 2;
|
|
||||||
unsigned int i, occ = 0, urg = 0;
|
unsigned int i, occ = 0, urg = 0;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
|
@ -709,6 +763,8 @@ drawbar(Monitor *m)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
if (ISVISIBLE(c))
|
||||||
|
n++;
|
||||||
occ |= c->tags;
|
occ |= c->tags;
|
||||||
if (c->isurgent)
|
if (c->isurgent)
|
||||||
urg |= c->tags;
|
urg |= c->tags;
|
||||||
|
@ -719,9 +775,10 @@ drawbar(Monitor *m)
|
||||||
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
||||||
if (occ & 1 << i)
|
if (occ & 1 << i)
|
||||||
drw_rect(drw, x + boxs, boxs, boxw, boxw,
|
drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw,
|
||||||
m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
|
m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
|
||||||
urg & 1 << i);
|
urg & 1 << i);
|
||||||
|
|
||||||
x += w;
|
x += w;
|
||||||
}
|
}
|
||||||
w = blw = TEXTW(m->ltsymbol);
|
w = blw = TEXTW(m->ltsymbol);
|
||||||
|
@ -729,16 +786,28 @@ drawbar(Monitor *m)
|
||||||
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);
|
||||||
|
|
||||||
if ((w = m->ww - sw - x) > bh) {
|
if ((w = m->ww - sw - x) > bh) {
|
||||||
if (m->sel) {
|
if (n > 0) {
|
||||||
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
for (c = m->clients; c; c = c->next) {
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
if (!ISVISIBLE(c))
|
||||||
if (m->sel->isfloating)
|
continue;
|
||||||
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
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 {
|
} else {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m->bt = n;
|
||||||
|
m->btw = w;
|
||||||
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,8 +852,8 @@ expose(XEvent *e)
|
||||||
void
|
void
|
||||||
focus(Client *c)
|
focus(Client *c)
|
||||||
{
|
{
|
||||||
if (!c || !ISVISIBLE(c))
|
if (!c || !ISVISIBLE(c) || HIDDEN(c))
|
||||||
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
|
for (c = selmon->stack; c && (!ISVISIBLE(c) || HIDDEN(c)); c = c->snext);
|
||||||
if (selmon->sel && selmon->sel != c)
|
if (selmon->sel && selmon->sel != c)
|
||||||
unfocus(selmon->sel, 0);
|
unfocus(selmon->sel, 0);
|
||||||
if (c) {
|
if (c) {
|
||||||
|
@ -963,10 +1032,35 @@ grabkeys(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
void
|
||||||
incnmaster(const Arg *arg)
|
incnmaster(const Arg *arg)
|
||||||
{
|
{
|
||||||
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1067,11 +1161,13 @@ 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 (!HIDDEN(c))
|
||||||
setclientstate(c, NormalState);
|
setclientstate(c, NormalState);
|
||||||
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 (!HIDDEN(c))
|
||||||
XMapWindow(dpy, c->win);
|
XMapWindow(dpy, c->win);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
|
@ -1195,7 +1291,7 @@ movemouse(const Arg *arg)
|
||||||
Client *
|
Client *
|
||||||
nexttiled(Client *c)
|
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;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1380,6 +1476,13 @@ run(void)
|
||||||
handler[ev.type](&ev); /* call handler */
|
handler[ev.type](&ev); /* call handler */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
runAutostart(void) {
|
||||||
|
if (!system("cd ~/.config/dwm; ./autostart_blocking.sh") ||
|
||||||
|
!system("cd ~/.config/dwm; ./autostart.sh &"))
|
||||||
|
fputs("Could not run start scripts", stdout);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
scan(void)
|
scan(void)
|
||||||
{
|
{
|
||||||
|
@ -1497,13 +1600,23 @@ setfullscreen(Client *c, int fullscreen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setgaps(const Arg *arg)
|
||||||
|
{
|
||||||
|
if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
|
||||||
|
selmon->gappx = 0;
|
||||||
|
else
|
||||||
|
selmon->gappx += arg->i;
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setlayout(const Arg *arg)
|
setlayout(const Arg *arg)
|
||||||
{
|
{
|
||||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||||
selmon->sellt ^= 1;
|
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
||||||
if (arg && arg->v)
|
if (arg && arg->v)
|
||||||
selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
||||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
||||||
if (selmon->sel)
|
if (selmon->sel)
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
|
@ -1522,7 +1635,7 @@ setmfact(const Arg *arg)
|
||||||
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
||||||
if (f < 0.1 || f > 0.9)
|
if (f < 0.1 || f > 0.9)
|
||||||
return;
|
return;
|
||||||
selmon->mfact = f;
|
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1610,6 +1723,17 @@ seturgent(Client *c, int urg)
|
||||||
XFree(wmh);
|
XFree(wmh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
show(Client *c)
|
||||||
|
{
|
||||||
|
if (!c || !HIDDEN(c))
|
||||||
|
return;
|
||||||
|
|
||||||
|
XMapWindow(dpy, c->win);
|
||||||
|
setclientstate(c, NormalState);
|
||||||
|
arrange(c->mon);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
showhide(Client *c)
|
showhide(Client *c)
|
||||||
{
|
{
|
||||||
|
@ -1683,23 +1807,23 @@ tile(Monitor *m)
|
||||||
if (n > m->nmaster)
|
if (n > m->nmaster)
|
||||||
mw = m->nmaster ? m->ww * m->mfact : 0;
|
mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
else
|
else
|
||||||
mw = m->ww;
|
mw = m->ww - m->gappx;
|
||||||
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
if (i < m->nmaster) {
|
if (i < m->nmaster) {
|
||||||
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
|
||||||
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
|
||||||
my += HEIGHT(c);
|
my += HEIGHT(c) + m->gappx;
|
||||||
} else {
|
} else {
|
||||||
h = (m->wh - ty) / (n - i);
|
h = (m->wh - ty) / (n - i) - m->gappx;
|
||||||
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
|
||||||
ty += HEIGHT(c);
|
ty += HEIGHT(c) + m->gappx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
togglebar(const Arg *arg)
|
togglebar(const Arg *arg)
|
||||||
{
|
{
|
||||||
selmon->showbar = !selmon->showbar;
|
selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !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, bh);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
|
@ -1738,14 +1862,52 @@ void
|
||||||
toggleview(const Arg *arg)
|
toggleview(const Arg *arg)
|
||||||
{
|
{
|
||||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
||||||
|
int i;
|
||||||
|
|
||||||
if (newtagset) {
|
if (newtagset) {
|
||||||
selmon->tagset[selmon->seltags] = newtagset;
|
selmon->tagset[selmon->seltags] = newtagset;
|
||||||
|
|
||||||
|
if (newtagset == ~0) {
|
||||||
|
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||||
|
selmon->pertag->curtag = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* test if the user did not select the same tag */
|
||||||
|
if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
||||||
|
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||||
|
for (i = 0; !(newtagset & 1 << i); i++) ;
|
||||||
|
selmon->pertag->curtag = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* apply settings for this view */
|
||||||
|
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||||
|
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||||
|
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||||
|
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||||
|
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||||
|
|
||||||
|
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||||
|
togglebar(NULL);
|
||||||
|
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
unfocus(Client *c, int setfocus)
|
unfocus(Client *c, int setfocus)
|
||||||
{
|
{
|
||||||
|
@ -2035,11 +2197,37 @@ updatewmhints(Client *c)
|
||||||
void
|
void
|
||||||
view(const Arg *arg)
|
view(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
unsigned int tmptag;
|
||||||
|
|
||||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||||
return;
|
return;
|
||||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||||
if (arg->ui & TAGMASK)
|
if (arg->ui & TAGMASK) {
|
||||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||||
|
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||||
|
|
||||||
|
if (arg->ui == ~0)
|
||||||
|
selmon->pertag->curtag = 0;
|
||||||
|
else {
|
||||||
|
for (i = 0; !(arg->ui & 1 << i); i++) ;
|
||||||
|
selmon->pertag->curtag = i + 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tmptag = selmon->pertag->prevtag;
|
||||||
|
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||||
|
selmon->pertag->curtag = tmptag;
|
||||||
|
}
|
||||||
|
|
||||||
|
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||||
|
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||||
|
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||||
|
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||||
|
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||||
|
|
||||||
|
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||||
|
togglebar(NULL);
|
||||||
|
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
@ -2142,8 +2330,171 @@ main(int argc, char *argv[])
|
||||||
die("pledge");
|
die("pledge");
|
||||||
#endif /* __OpenBSD__ */
|
#endif /* __OpenBSD__ */
|
||||||
scan();
|
scan();
|
||||||
|
runAutostart();
|
||||||
run();
|
run();
|
||||||
cleanup();
|
cleanup();
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bstack(Monitor *m) {
|
||||||
|
int w, h, mh, mx, tx, ty, tw;
|
||||||
|
unsigned int i, n;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
if (n > m->nmaster) {
|
||||||
|
mh = m->nmaster ? m->mfact * m->wh : 0;
|
||||||
|
tw = m->ww / (n - m->nmaster);
|
||||||
|
ty = m->wy + mh;
|
||||||
|
} else {
|
||||||
|
mh = m->wh;
|
||||||
|
tw = m->ww;
|
||||||
|
ty = m->wy;
|
||||||
|
}
|
||||||
|
for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
if (i < m->nmaster) {
|
||||||
|
w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
|
||||||
|
resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
|
||||||
|
mx += WIDTH(c);
|
||||||
|
} else {
|
||||||
|
h = m->wh - mh;
|
||||||
|
resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0);
|
||||||
|
if (tw != m->ww)
|
||||||
|
tx += WIDTH(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bstackhoriz(Monitor *m) {
|
||||||
|
int w, mh, mx, tx, ty, th;
|
||||||
|
unsigned int i, n;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
if (n > m->nmaster) {
|
||||||
|
mh = m->nmaster ? m->mfact * m->wh : 0;
|
||||||
|
th = (m->wh - mh) / (n - m->nmaster);
|
||||||
|
ty = m->wy + mh;
|
||||||
|
} else {
|
||||||
|
th = mh = m->wh;
|
||||||
|
ty = m->wy;
|
||||||
|
}
|
||||||
|
for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
if (i < m->nmaster) {
|
||||||
|
w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
|
||||||
|
resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
|
||||||
|
mx += WIDTH(c);
|
||||||
|
} else {
|
||||||
|
resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0);
|
||||||
|
if (th != m->wh)
|
||||||
|
ty += HEIGHT(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void centeredmaster(Monitor *m) {
|
||||||
|
unsigned int i, n, h, mw, mx, my, oty, ety, tw;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
/* count number of clients in the selected monitor */
|
||||||
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* initialize areas */
|
||||||
|
mw = m->ww;
|
||||||
|
mx = 0;
|
||||||
|
my = 0;
|
||||||
|
tw = mw;
|
||||||
|
|
||||||
|
if (n > m->nmaster) {
|
||||||
|
/* go mfact box in the center if more than nmaster clients */
|
||||||
|
mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
|
tw = m->ww - mw;
|
||||||
|
|
||||||
|
if (n - m->nmaster > 1) {
|
||||||
|
/* only one client */
|
||||||
|
mx = (m->ww - mw) / 2;
|
||||||
|
tw = (m->ww - mw) / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
oty = 0;
|
||||||
|
ety = 0;
|
||||||
|
for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
|
if (i < m->nmaster) {
|
||||||
|
/* nmaster clients are stacked vertically, in the center
|
||||||
|
* of the screen */
|
||||||
|
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||||
|
resize(c, m->wx + mx, m->wy + my, mw - (2*c->bw),
|
||||||
|
+ h - (2*c->bw), 0);
|
||||||
|
my += HEIGHT(c);
|
||||||
|
} else {
|
||||||
|
/* stack clients are stacked vertically */
|
||||||
|
if ((i - m->nmaster) % 2 ) {
|
||||||
|
h = (m->wh - ety) / ( (1 + n - i) / 2);
|
||||||
|
resize(c, m->wx, m->wy + ety, tw - (2*c->bw),
|
||||||
|
h - (2*c->bw), 0);
|
||||||
|
ety += HEIGHT(c);
|
||||||
|
} else {
|
||||||
|
h = (m->wh - oty) / ((1 + n - i) / 2);
|
||||||
|
resize(c, m->wx + mx + mw, m->wy + oty,
|
||||||
|
+ tw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
|
oty += HEIGHT(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
centeredfloatingmaster(Monitor *m)
|
||||||
|
{
|
||||||
|
unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
/* count number of clients in the selected monitor */
|
||||||
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* initialize nmaster area */
|
||||||
|
if (n > m->nmaster) {
|
||||||
|
/* go mfact box in the center if more than nmaster clients */
|
||||||
|
if (m->ww > m->wh) {
|
||||||
|
mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
|
mh = m->nmaster ? m->wh * 0.9 : 0;
|
||||||
|
} else {
|
||||||
|
mh = m->nmaster ? m->wh * m->mfact : 0;
|
||||||
|
mw = m->nmaster ? m->ww * 0.9 : 0;
|
||||||
|
}
|
||||||
|
mx = mxo = (m->ww - mw) / 2;
|
||||||
|
my = myo = (m->wh - mh) / 2;
|
||||||
|
} else {
|
||||||
|
/* go fullscreen if all clients are in the master area */
|
||||||
|
mh = m->wh;
|
||||||
|
mw = m->ww;
|
||||||
|
mx = mxo = 0;
|
||||||
|
my = myo = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
|
if (i < m->nmaster) {
|
||||||
|
/* nmaster clients are stacked horizontally, in the center
|
||||||
|
* of the screen */
|
||||||
|
w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i);
|
||||||
|
resize(c, m->wx + mx, m->wy + my, w - (2*c->bw),
|
||||||
|
mh - (2*c->bw), 0);
|
||||||
|
mx += WIDTH(c);
|
||||||
|
} else {
|
||||||
|
/* stack clients are stacked horizontally */
|
||||||
|
w = (m->ww - tx) / (n - i);
|
||||||
|
resize(c, m->wx + tx, m->wy, w - (2*c->bw),
|
||||||
|
m->wh - (2*c->bw), 0);
|
||||||
|
tx += WIDTH(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
272
patches/001-awesomebar.diff
Normal file
272
patches/001-awesomebar.diff
Normal file
|
@ -0,0 +1,272 @@
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1c0b587..1e62218 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -16,6 +16,7 @@ static const char *colors[][3] = {
|
||||||
|
/* fg bg border */
|
||||||
|
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
|
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||||
|
+ [SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* tagging */
|
||||||
|
@@ -102,6 +103,7 @@ static Button buttons[] = {
|
||||||
|
/* click event mask button function argument */
|
||||||
|
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||||
|
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||||
|
+ { ClkWinTitle, 0, Button1, togglewin, {0} },
|
||||||
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
|
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||||
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 4465af1..be9582d 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -50,6 +50,7 @@
|
||||||
|
#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 ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||||
|
+#define HIDDEN(C) ((getstate(C->win) == IconicState))
|
||||||
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||||
|
@@ -59,7 +60,7 @@
|
||||||
|
|
||||||
|
/* enums */
|
||||||
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
|
-enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||||
|
+enum { SchemeNorm, SchemeSel, SchemeHid }; /* color schemes */
|
||||||
|
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||||
|
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||||
|
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||||
|
@@ -117,6 +118,8 @@ struct Monitor {
|
||||||
|
int nmaster;
|
||||||
|
int num;
|
||||||
|
int by; /* bar geometry */
|
||||||
|
+ int btw; /* width of tasks portion of bar */
|
||||||
|
+ int bt; /* number of tasks */
|
||||||
|
int mx, my, mw, mh; /* screen size */
|
||||||
|
int wx, wy, ww, wh; /* window area */
|
||||||
|
unsigned int seltags;
|
||||||
|
@@ -174,6 +177,7 @@ static long getstate(Window w);
|
||||||
|
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||||
|
static void grabbuttons(Client *c, int focused);
|
||||||
|
static void grabkeys(void);
|
||||||
|
+static void hide(Client *c);
|
||||||
|
static void incnmaster(const Arg *arg);
|
||||||
|
static void keypress(XEvent *e);
|
||||||
|
static void killclient(const Arg *arg);
|
||||||
|
@@ -203,6 +207,7 @@ static void setlayout(const Arg *arg);
|
||||||
|
static void setmfact(const Arg *arg);
|
||||||
|
static void setup(void);
|
||||||
|
static void seturgent(Client *c, int urg);
|
||||||
|
+static void show(Client *c);
|
||||||
|
static void showhide(Client *c);
|
||||||
|
static void sigchld(int unused);
|
||||||
|
static void spawn(const Arg *arg);
|
||||||
|
@@ -213,6 +218,7 @@ static void togglebar(const Arg *arg);
|
||||||
|
static void togglefloating(const Arg *arg);
|
||||||
|
static void toggletag(const Arg *arg);
|
||||||
|
static void toggleview(const Arg *arg);
|
||||||
|
+static void togglewin(const Arg *arg);
|
||||||
|
static void unfocus(Client *c, int setfocus);
|
||||||
|
static void unmanage(Client *c, int destroyed);
|
||||||
|
static void unmapnotify(XEvent *e);
|
||||||
|
@@ -439,10 +445,25 @@ buttonpress(XEvent *e)
|
||||||
|
arg.ui = 1 << i;
|
||||||
|
} else if (ev->x < x + blw)
|
||||||
|
click = ClkLtSymbol;
|
||||||
|
- else if (ev->x > selmon->ww - TEXTW(stext))
|
||||||
|
+ /* 2px right padding */
|
||||||
|
+ else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2)
|
||||||
|
click = ClkStatusText;
|
||||||
|
- else
|
||||||
|
- click = ClkWinTitle;
|
||||||
|
+ 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 if ((c = wintoclient(ev->window))) {
|
||||||
|
focus(c);
|
||||||
|
restack(selmon);
|
||||||
|
@@ -452,7 +473,7 @@ 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
|
||||||
|
@@ -695,7 +716,7 @@ dirtomon(int dir)
|
||||||
|
void
|
||||||
|
drawbar(Monitor *m)
|
||||||
|
{
|
||||||
|
- int x, w, sw = 0;
|
||||||
|
+ int x, w, sw = 0, n = 0, scm;
|
||||||
|
int boxs = drw->fonts->h / 9;
|
||||||
|
int boxw = drw->fonts->h / 6 + 2;
|
||||||
|
unsigned int i, occ = 0, urg = 0;
|
||||||
|
@@ -709,6 +730,8 @@ drawbar(Monitor *m)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
+ if (ISVISIBLE(c))
|
||||||
|
+ n++;
|
||||||
|
occ |= c->tags;
|
||||||
|
if (c->isurgent)
|
||||||
|
urg |= c->tags;
|
||||||
|
@@ -729,16 +752,28 @@ drawbar(Monitor *m)
|
||||||
|
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||||
|
|
||||||
|
if ((w = m->ww - sw - x) > bh) {
|
||||||
|
- if (m->sel) {
|
||||||
|
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||||
|
- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
||||||
|
- if (m->sel->isfloating)
|
||||||
|
- drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
||||||
|
+ 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ m->bt = n;
|
||||||
|
+ m->btw = w;
|
||||||
|
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -783,8 +818,8 @@ expose(XEvent *e)
|
||||||
|
void
|
||||||
|
focus(Client *c)
|
||||||
|
{
|
||||||
|
- if (!c || !ISVISIBLE(c))
|
||||||
|
- for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
|
||||||
|
+ if (!c || !ISVISIBLE(c) || HIDDEN(c))
|
||||||
|
+ for (c = selmon->stack; c && (!ISVISIBLE(c) || HIDDEN(c)); c = c->snext);
|
||||||
|
if (selmon->sel && selmon->sel != c)
|
||||||
|
unfocus(selmon->sel, 0);
|
||||||
|
if (c) {
|
||||||
|
@@ -963,6 +998,31 @@ grabkeys(void)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+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
|
||||||
|
incnmaster(const Arg *arg)
|
||||||
|
{
|
||||||
|
@@ -1067,12 +1127,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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1195,7 +1257,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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1610,6 +1672,17 @@ seturgent(Client *c, int urg)
|
||||||
|
XFree(wmh);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+show(Client *c)
|
||||||
|
+{
|
||||||
|
+ if (!c || !HIDDEN(c))
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ XMapWindow(dpy, c->win);
|
||||||
|
+ setclientstate(c, NormalState);
|
||||||
|
+ arrange(c->mon);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
showhide(Client *c)
|
||||||
|
{
|
||||||
|
@@ -1746,6 +1819,20 @@ toggleview(const Arg *arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+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);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
unfocus(Client *c, int setfocus)
|
||||||
|
{
|
95
patches/002-fullgaps.diff
Normal file
95
patches/002-fullgaps.diff
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1c0b587..38d2f6c 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -2,6 +2,7 @@
|
||||||
|
|
||||||
|
/* appearance */
|
||||||
|
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
|
+static const unsigned int gappx = 5; /* gaps between 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 */
|
||||||
|
@@ -84,6 +85,9 @@ static Key keys[] = {
|
||||||
|
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||||
|
+ { MODKEY, XK_minus, setgaps, {.i = -1 } },
|
||||||
|
+ { MODKEY, XK_equal, setgaps, {.i = +1 } },
|
||||||
|
+ { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
|
||||||
|
TAGKEYS( XK_1, 0)
|
||||||
|
TAGKEYS( XK_2, 1)
|
||||||
|
TAGKEYS( XK_3, 2)
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 4465af1..4363627 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -119,6 +119,7 @@ struct Monitor {
|
||||||
|
int by; /* bar geometry */
|
||||||
|
int mx, my, mw, mh; /* screen size */
|
||||||
|
int wx, wy, ww, wh; /* window area */
|
||||||
|
+ int gappx; /* gaps between windows */
|
||||||
|
unsigned int seltags;
|
||||||
|
unsigned int sellt;
|
||||||
|
unsigned int tagset[2];
|
||||||
|
@@ -199,6 +200,7 @@ 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(const Arg *arg);
|
||||||
|
static void setlayout(const Arg *arg);
|
||||||
|
static void setmfact(const Arg *arg);
|
||||||
|
static void setup(void);
|
||||||
|
@@ -638,6 +640,7 @@ createmon(void)
|
||||||
|
m->nmaster = nmaster;
|
||||||
|
m->showbar = showbar;
|
||||||
|
m->topbar = topbar;
|
||||||
|
+ m->gappx = gappx;
|
||||||
|
m->lt[0] = &layouts[0];
|
||||||
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
|
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||||
|
@@ -1497,6 +1500,16 @@ setfullscreen(Client *c, int fullscreen)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+setgaps(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
|
||||||
|
+ selmon->gappx = 0;
|
||||||
|
+ else
|
||||||
|
+ selmon->gappx += arg->i;
|
||||||
|
+ arrange(selmon);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
setlayout(const Arg *arg)
|
||||||
|
{
|
||||||
|
@@ -1683,16 +1696,16 @@ tile(Monitor *m)
|
||||||
|
if (n > m->nmaster)
|
||||||
|
mw = m->nmaster ? m->ww * 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 - m->gappx;
|
||||||
|
+ for (i = 0, my = ty = m->gappx, 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);
|
||||||
|
- my += HEIGHT(c);
|
||||||
|
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
|
||||||
|
+ resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
|
||||||
|
+ my += HEIGHT(c) + m->gappx;
|
||||||
|
} 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);
|
||||||
|
- ty += HEIGHT(c);
|
||||||
|
+ h = (m->wh - ty) / (n - i) - m->gappx;
|
||||||
|
+ resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
|
||||||
|
+ ty += HEIGHT(c) + m->gappx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
17
patches/003-indicatorbar.diff
Normal file
17
patches/003-indicatorbar.diff
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
diff -up dwm-a/dwm.c dwm-b/dwm.c
|
||||||
|
--- dwm-a/dwm.c 2019-02-02 06:55:28.000000000 -0600
|
||||||
|
+++ dwm-b/dwm.c 2019-02-23 21:43:13.359179100 -0600
|
||||||
|
@@ -719,9 +719,10 @@ drawbar(Monitor *m)
|
||||||
|
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
||||||
|
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
||||||
|
if (occ & 1 << i)
|
||||||
|
- drw_rect(drw, x + boxs, boxs, boxw, boxw,
|
||||||
|
- m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
|
||||||
|
- urg & 1 << i);
|
||||||
|
+ drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw,
|
||||||
|
+ m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
|
||||||
|
+ urg & 1 << i);
|
||||||
|
+
|
||||||
|
x += w;
|
||||||
|
}
|
||||||
|
w = blw = TEXTW(m->ltsymbol);
|
40
patches/004-autostart.diff
Normal file
40
patches/004-autostart.diff
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
commit 5918623c5bd7fda155bf9dc3d33890c4ae1722d0
|
||||||
|
Author: Simon Bremer <simon.bremer@tum.de>
|
||||||
|
Date: Thu Dec 22 17:31:07 2016 +0100
|
||||||
|
|
||||||
|
Applied and fixed autostart patch for previous version;
|
||||||
|
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index d27cb67..066ed71 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -194,6 +194,7 @@ static void resizeclient(Client *c, int x, int y, int w, int h);
|
||||||
|
static void resizemouse(const Arg *arg);
|
||||||
|
static void restack(Monitor *m);
|
||||||
|
static void run(void);
|
||||||
|
+static void runAutostart(void);
|
||||||
|
static void scan(void);
|
||||||
|
static int sendevent(Client *c, Atom proto);
|
||||||
|
static void sendmon(Client *c, Monitor *m);
|
||||||
|
@@ -1386,6 +1388,13 @@ run(void)
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
+runAutostart(void) {
|
||||||
|
+ if (!system("cd ~/.config/dwm; ./autostart_blocking.sh") ||
|
||||||
|
+ !system("cd ~/.config/dwm; ./autostart.sh &"))
|
||||||
|
+ fputs("Could not run start scripts", stdout);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
scan(void)
|
||||||
|
{
|
||||||
|
unsigned int i, num;
|
||||||
|
@@ -2145,6 +2152,7 @@ main(int argc, char *argv[])
|
||||||
|
checkotherwm();
|
||||||
|
setup();
|
||||||
|
scan();
|
||||||
|
+ runAutostart();
|
||||||
|
run();
|
||||||
|
cleanup();
|
||||||
|
XCloseDisplay(dpy);
|
177
patches/005-pertag.diff
Normal file
177
patches/005-pertag.diff
Normal file
|
@ -0,0 +1,177 @@
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 4465af1..6474055 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -111,6 +111,7 @@ typedef struct {
|
||||||
|
void (*arrange)(Monitor *);
|
||||||
|
} Layout;
|
||||||
|
|
||||||
|
+typedef struct Pertag Pertag;
|
||||||
|
struct Monitor {
|
||||||
|
char ltsymbol[16];
|
||||||
|
float mfact;
|
||||||
|
@@ -130,6 +131,7 @@ struct Monitor {
|
||||||
|
Monitor *next;
|
||||||
|
Window barwin;
|
||||||
|
const Layout *lt[2];
|
||||||
|
+ Pertag *pertag;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
@@ -271,6 +273,15 @@ static Window root, wmcheckwin;
|
||||||
|
/* configuration, allows nested code to access above variables */
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
+struct Pertag {
|
||||||
|
+ unsigned int curtag, prevtag; /* current and previous tag */
|
||||||
|
+ int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
|
||||||
|
+ float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
|
||||||
|
+ unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
|
||||||
|
+ const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
|
||||||
|
+ int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||||
|
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||||
|
|
||||||
|
@@ -631,6 +642,7 @@ Monitor *
|
||||||
|
createmon(void)
|
||||||
|
{
|
||||||
|
Monitor *m;
|
||||||
|
+ unsigned int i;
|
||||||
|
|
||||||
|
m = ecalloc(1, sizeof(Monitor));
|
||||||
|
m->tagset[0] = m->tagset[1] = 1;
|
||||||
|
@@ -641,6 +653,20 @@ createmon(void)
|
||||||
|
m->lt[0] = &layouts[0];
|
||||||
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
|
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||||
|
+ m->pertag = ecalloc(1, sizeof(Pertag));
|
||||||
|
+ m->pertag->curtag = m->pertag->prevtag = 1;
|
||||||
|
+
|
||||||
|
+ for (i = 0; i <= LENGTH(tags); i++) {
|
||||||
|
+ m->pertag->nmasters[i] = m->nmaster;
|
||||||
|
+ m->pertag->mfacts[i] = m->mfact;
|
||||||
|
+
|
||||||
|
+ m->pertag->ltidxs[i][0] = m->lt[0];
|
||||||
|
+ m->pertag->ltidxs[i][1] = m->lt[1];
|
||||||
|
+ m->pertag->sellts[i] = m->sellt;
|
||||||
|
+
|
||||||
|
+ m->pertag->showbars[i] = m->showbar;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -966,7 +992,7 @@ grabkeys(void)
|
||||||
|
void
|
||||||
|
incnmaster(const Arg *arg)
|
||||||
|
{
|
||||||
|
- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
||||||
|
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1501,9 +1527,9 @@ void
|
||||||
|
setlayout(const Arg *arg)
|
||||||
|
{
|
||||||
|
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||||
|
- selmon->sellt ^= 1;
|
||||||
|
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
||||||
|
if (arg && arg->v)
|
||||||
|
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
||||||
|
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
||||||
|
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
||||||
|
if (selmon->sel)
|
||||||
|
arrange(selmon);
|
||||||
|
@@ -1522,7 +1548,7 @@ setmfact(const Arg *arg)
|
||||||
|
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
||||||
|
if (f < 0.1 || f > 0.9)
|
||||||
|
return;
|
||||||
|
- selmon->mfact = f;
|
||||||
|
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1699,7 +1725,7 @@ tile(Monitor *m)
|
||||||
|
void
|
||||||
|
togglebar(const Arg *arg)
|
||||||
|
{
|
||||||
|
- selmon->showbar = !selmon->showbar;
|
||||||
|
+ selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
|
||||||
|
updatebarpos(selmon);
|
||||||
|
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
||||||
|
arrange(selmon);
|
||||||
|
@@ -1738,9 +1764,33 @@ void
|
||||||
|
toggleview(const Arg *arg)
|
||||||
|
{
|
||||||
|
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
||||||
|
+ int i;
|
||||||
|
|
||||||
|
if (newtagset) {
|
||||||
|
selmon->tagset[selmon->seltags] = newtagset;
|
||||||
|
+
|
||||||
|
+ if (newtagset == ~0) {
|
||||||
|
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||||
|
+ selmon->pertag->curtag = 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* test if the user did not select the same tag */
|
||||||
|
+ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
||||||
|
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||||
|
+ for (i = 0; !(newtagset & 1 << i); i++) ;
|
||||||
|
+ selmon->pertag->curtag = i + 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* apply settings for this view */
|
||||||
|
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||||
|
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||||
|
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||||
|
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||||
|
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||||
|
+
|
||||||
|
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||||
|
+ togglebar(NULL);
|
||||||
|
+
|
||||||
|
focus(NULL);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
@@ -2035,11 +2085,37 @@ updatewmhints(Client *c)
|
||||||
|
void
|
||||||
|
view(const Arg *arg)
|
||||||
|
{
|
||||||
|
+ int i;
|
||||||
|
+ unsigned int tmptag;
|
||||||
|
+
|
||||||
|
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||||
|
return;
|
||||||
|
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||||
|
- if (arg->ui & TAGMASK)
|
||||||
|
+ if (arg->ui & TAGMASK) {
|
||||||
|
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||||
|
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||||
|
+
|
||||||
|
+ if (arg->ui == ~0)
|
||||||
|
+ selmon->pertag->curtag = 0;
|
||||||
|
+ else {
|
||||||
|
+ for (i = 0; !(arg->ui & 1 << i); i++) ;
|
||||||
|
+ selmon->pertag->curtag = i + 1;
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ tmptag = selmon->pertag->prevtag;
|
||||||
|
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||||
|
+ selmon->pertag->curtag = tmptag;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||||
|
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||||
|
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||||
|
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||||
|
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||||
|
+
|
||||||
|
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||||
|
+ togglebar(NULL);
|
||||||
|
+
|
||||||
|
focus(NULL);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
101
patches/006-bottomstack.diff
Normal file
101
patches/006-bottomstack.diff
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 7054c06..554f1db 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -39,6 +39,8 @@ static const Layout layouts[] = {
|
||||||
|
{ "[]=", tile }, /* first entry is default */
|
||||||
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
|
{ "[M]", monocle },
|
||||||
|
+ { "TTT", bstack },
|
||||||
|
+ { "===", bstackhoriz },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* key definitions */
|
||||||
|
@@ -74,6 +76,8 @@ static Key keys[] = {
|
||||||
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
|
+ { MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
|
||||||
|
+ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
|
||||||
|
{ MODKEY, XK_space, setlayout, {0} },
|
||||||
|
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||||
|
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 0362114..c313b5e 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -233,6 +233,8 @@ static int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
|
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||||
|
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
|
static void zoom(const Arg *arg);
|
||||||
|
+static void bstack(Monitor *m);
|
||||||
|
+static void bstackhoriz(Monitor *m);
|
||||||
|
|
||||||
|
/* variables */
|
||||||
|
static const char broken[] = "broken";
|
||||||
|
@@ -2139,3 +2141,65 @@ main(int argc, char *argv[])
|
||||||
|
XCloseDisplay(dpy);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+bstack(Monitor *m) {
|
||||||
|
+ int w, h, mh, mx, tx, ty, tw;
|
||||||
|
+ unsigned int i, n;
|
||||||
|
+ Client *c;
|
||||||
|
+
|
||||||
|
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
+ if (n == 0)
|
||||||
|
+ return;
|
||||||
|
+ if (n > m->nmaster) {
|
||||||
|
+ mh = m->nmaster ? m->mfact * m->wh : 0;
|
||||||
|
+ tw = m->ww / (n - m->nmaster);
|
||||||
|
+ ty = m->wy + mh;
|
||||||
|
+ } else {
|
||||||
|
+ mh = m->wh;
|
||||||
|
+ tw = m->ww;
|
||||||
|
+ ty = m->wy;
|
||||||
|
+ }
|
||||||
|
+ for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
+ if (i < m->nmaster) {
|
||||||
|
+ w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
|
||||||
|
+ resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
|
||||||
|
+ mx += WIDTH(c);
|
||||||
|
+ } else {
|
||||||
|
+ h = m->wh - mh;
|
||||||
|
+ resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0);
|
||||||
|
+ if (tw != m->ww)
|
||||||
|
+ tx += WIDTH(c);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+bstackhoriz(Monitor *m) {
|
||||||
|
+ int w, mh, mx, tx, ty, th;
|
||||||
|
+ unsigned int i, n;
|
||||||
|
+ Client *c;
|
||||||
|
+
|
||||||
|
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
+ if (n == 0)
|
||||||
|
+ return;
|
||||||
|
+ if (n > m->nmaster) {
|
||||||
|
+ mh = m->nmaster ? m->mfact * m->wh : 0;
|
||||||
|
+ th = (m->wh - mh) / (n - m->nmaster);
|
||||||
|
+ ty = m->wy + mh;
|
||||||
|
+ } else {
|
||||||
|
+ th = mh = m->wh;
|
||||||
|
+ ty = m->wy;
|
||||||
|
+ }
|
||||||
|
+ for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
+ if (i < m->nmaster) {
|
||||||
|
+ w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
|
||||||
|
+ resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
|
||||||
|
+ mx += WIDTH(c);
|
||||||
|
+ } else {
|
||||||
|
+ resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0);
|
||||||
|
+ if (th != m->wh)
|
||||||
|
+ ty += HEIGHT(c);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
115
patches/007-centeredmaster.diff
Normal file
115
patches/007-centeredmaster.diff
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
--- dwm.c 2020-05-25 20:18:32.786733660 +0300
|
||||||
|
+++ dwm.c.orig 2020-05-25 20:11:57.780060152 +0300
|
||||||
|
@@ -246,8 +246,6 @@
|
||||||
|
static void zoom(const Arg *arg);
|
||||||
|
static void bstack(Monitor *m);
|
||||||
|
static void bstackhoriz(Monitor *m);
|
||||||
|
-static void centeredmaster(Monitor *m);
|
||||||
|
-static void centeredfloatingmaster(Monitor *m);
|
||||||
|
|
||||||
|
/* variables */
|
||||||
|
static const char broken[] = "broken";
|
||||||
|
@@ -2398,103 +2396,3 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
-void centeredmaster(Monitor *m) {
|
||||||
|
- unsigned int i, n, h, mw, mx, my, oty, ety, tw;
|
||||||
|
- Client *c;
|
||||||
|
-
|
||||||
|
- /* count number of clients in the selected monitor */
|
||||||
|
- for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
- if (n == 0)
|
||||||
|
- return;
|
||||||
|
-
|
||||||
|
- /* initialize areas */
|
||||||
|
- mw = m->ww;
|
||||||
|
- mx = 0;
|
||||||
|
- my = 0;
|
||||||
|
- tw = mw;
|
||||||
|
-
|
||||||
|
- if (n > m->nmaster) {
|
||||||
|
- /* go mfact box in the center if more than nmaster clients */
|
||||||
|
- mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
|
- tw = m->ww - mw;
|
||||||
|
-
|
||||||
|
- if (n - m->nmaster > 1) {
|
||||||
|
- /* only one client */
|
||||||
|
- mx = (m->ww - mw) / 2;
|
||||||
|
- tw = (m->ww - mw) / 2;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- oty = 0;
|
||||||
|
- ety = 0;
|
||||||
|
- for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
|
- if (i < m->nmaster) {
|
||||||
|
- /* nmaster clients are stacked vertically, in the center
|
||||||
|
- * of the screen */
|
||||||
|
- h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||||
|
- resize(c, m->wx + mx, m->wy + my, mw - (2*c->bw),
|
||||||
|
- + h - (2*c->bw), 0);
|
||||||
|
- my += HEIGHT(c);
|
||||||
|
- } else {
|
||||||
|
- /* stack clients are stacked vertically */
|
||||||
|
- if ((i - m->nmaster) % 2 ) {
|
||||||
|
- h = (m->wh - ety) / ( (1 + n - i) / 2);
|
||||||
|
- resize(c, m->wx, m->wy + ety, tw - (2*c->bw),
|
||||||
|
- h - (2*c->bw), 0);
|
||||||
|
- ety += HEIGHT(c);
|
||||||
|
- } else {
|
||||||
|
- h = (m->wh - oty) / ((1 + n - i) / 2);
|
||||||
|
- resize(c, m->wx + mx + mw, m->wy + oty,
|
||||||
|
- + tw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
|
- oty += HEIGHT(c);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
- void
|
||||||
|
-centeredfloatingmaster(Monitor *m)
|
||||||
|
-{
|
||||||
|
- unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx;
|
||||||
|
- Client *c;
|
||||||
|
-
|
||||||
|
- /* count number of clients in the selected monitor */
|
||||||
|
- for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
- if (n == 0)
|
||||||
|
- return;
|
||||||
|
-
|
||||||
|
- /* initialize nmaster area */
|
||||||
|
- if (n > m->nmaster) {
|
||||||
|
- /* go mfact box in the center if more than nmaster clients */
|
||||||
|
- if (m->ww > m->wh) {
|
||||||
|
- mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
|
- mh = m->nmaster ? m->wh * 0.9 : 0;
|
||||||
|
- } else {
|
||||||
|
- mh = m->nmaster ? m->wh * m->mfact : 0;
|
||||||
|
- mw = m->nmaster ? m->ww * 0.9 : 0;
|
||||||
|
- }
|
||||||
|
- mx = mxo = (m->ww - mw) / 2;
|
||||||
|
- my = myo = (m->wh - mh) / 2;
|
||||||
|
- } else {
|
||||||
|
- /* go fullscreen if all clients are in the master area */
|
||||||
|
- mh = m->wh;
|
||||||
|
- mw = m->ww;
|
||||||
|
- mx = mxo = 0;
|
||||||
|
- my = myo = 0;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- for(i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
|
- if (i < m->nmaster) {
|
||||||
|
- /* nmaster clients are stacked horizontally, in the center
|
||||||
|
- * of the screen */
|
||||||
|
- w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i);
|
||||||
|
- resize(c, m->wx + mx, m->wy + my, w - (2*c->bw),
|
||||||
|
- mh - (2*c->bw), 0);
|
||||||
|
- mx += WIDTH(c);
|
||||||
|
- } else {
|
||||||
|
- /* stack clients are stacked horizontally */
|
||||||
|
- w = (m->ww - tx) / (n - i);
|
||||||
|
- resize(c, m->wx + tx, m->wy, w - (2*c->bw),
|
||||||
|
- m->wh - (2*c->bw), 0);
|
||||||
|
- tx += WIDTH(c);
|
||||||
|
- }
|
||||||
|
-}
|
Loading…
Reference in New Issue
Block a user