Compare commits
9 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d76176d770 | |||
| d19bb915e1 | |||
| 361054b838 | |||
| 1306d2d540 | |||
| dd8e930f3f | |||
| 6e9eaf61ac | |||
| 5eb2db4061 | |||
| 162f3c32f2 | |||
| 5a38a89afd |
11 changed files with 3374 additions and 35 deletions
2
Makefile
2
Makefile
|
|
@ -20,7 +20,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} config.h dwm-${VERSION}.tar.gz
|
||||||
|
|
||||||
dist: clean
|
dist: clean
|
||||||
mkdir -p dwm-${VERSION}
|
mkdir -p dwm-${VERSION}
|
||||||
|
|
|
||||||
73
config.def.h
73
config.def.h
|
|
@ -1,34 +1,55 @@
|
||||||
/* 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 = 3; /* border pixel of windows */
|
||||||
static const unsigned int snap = 32; /* snap pixel */
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
|
static const int swallowfloating = 1; /* 1 means swallow floating windows by default */
|
||||||
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[] = { "monospace:size=16" }; */
|
||||||
static const char dmenufont[] = "monospace:size=10";
|
static const char *fonts[] = {"Mononoki Nerd Font:size=16:antialias=true:autohint=true",
|
||||||
static const char col_gray1[] = "#222222";
|
"Hack:size=14:antialias=true:autohint=true",
|
||||||
static const char col_gray2[] = "#444444";
|
"JoyPixels:size=16:antialias=true:autohint=true"};
|
||||||
static const char col_gray3[] = "#bbbbbb";
|
|
||||||
static const char col_gray4[] = "#eeeeee";
|
#include "/home/moo/.config/themes/using/colors-wal-dwm.h"
|
||||||
static const char col_cyan[] = "#005577";
|
|
||||||
static const char *colors[][3] = {
|
typedef struct {
|
||||||
/* fg bg border */
|
const char *name;
|
||||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
const void *cmd;
|
||||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
} Sp;
|
||||||
|
const char *spcmd1[] = {"st", "-n", "spterm", "-g", "120x34", NULL };
|
||||||
|
const char *spcmd2[] = {"st", "-n", "spfm", "-g", "120x34", "-e", "tmux", NULL };
|
||||||
|
const char *spcmd3[] = {"passed", NULL };
|
||||||
|
static Sp scratchpads[] = {
|
||||||
|
/* name cmd */
|
||||||
|
{"spterm", spcmd1},
|
||||||
|
{"spfm", spcmd2},
|
||||||
|
{"keepassxc", spcmd3},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* tagging */
|
/* tagging */
|
||||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
/*static const char *tags[] = { "", "", "", "", "", "", "7", "8", "9" };
|
||||||
|
*/
|
||||||
|
static const char *tags[] = { "•", "•", "•", "•", "•", "•", "•", "•", "•" };
|
||||||
|
|
||||||
static const Rule rules[] = {
|
static const Rule rules[] = {
|
||||||
/* xprop(1):
|
/* xprop(1):
|
||||||
* WM_CLASS(STRING) = instance, class
|
* WM_CLASS(STRING) = instance, class
|
||||||
* WM_NAME(STRING) = title
|
* WM_NAME(STRING) = title
|
||||||
*/
|
*/
|
||||||
/* class instance title tags mask isfloating monitor */
|
/* class instance title tags mask isfloating isterminal noswallow monitor */
|
||||||
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
{ NULL, NULL, "st", 0, 0, 1, 0, -1 },
|
||||||
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
{ "Gimp", NULL, NULL, 1 << 6, 1, 0, 0, -1 },
|
||||||
|
{ "Element", NULL, NULL, 1 << 8, 0, 0, 0, -1 },
|
||||||
|
{ NULL, NULL, "LibreWolf", 1 << 0, 0, 0, 0, -1 },
|
||||||
|
{ NULL, NULL, "Waterfox", 1 << 0, 0, 0, 0, -1 },
|
||||||
|
{ NULL, NULL, "Discord", 1 << 8, 0, 0, 0, -1 },
|
||||||
|
{ "mpv", NULL, NULL, 1 << 5, 1, 0, 0, -1 },
|
||||||
|
{ "xterm-256color", "spterm", NULL, SPTAG(0), 1, 1, 0, -1 },
|
||||||
|
{ "xterm-256color", "spfm", NULL, SPTAG(1), 1, 1, 0, -1 },
|
||||||
|
{ "KeePassXC", NULL, NULL, SPTAG(2), 0, 0, 0, -1 },
|
||||||
|
{ NULL, NULL, "pulsemixer", 0, 1, 1, 0, -1 },
|
||||||
|
{ NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* layout(s) */
|
/* layout(s) */
|
||||||
|
|
@ -45,7 +66,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} }, \
|
||||||
|
|
@ -57,21 +78,26 @@ static const Layout layouts[] = {
|
||||||
|
|
||||||
/* commands */
|
/* commands */
|
||||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
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", "-p", "Run: ", NULL };
|
||||||
static const char *termcmd[] = { "st", NULL };
|
static const char *termcmd[] = { "st", NULL };
|
||||||
|
static const char *volume[] = { "st", "-e", "pulsemixer", NULL };
|
||||||
|
|
||||||
|
#include "movestack.c"
|
||||||
static const Key keys[] = {
|
static const Key keys[] = {
|
||||||
/* modifier key function argument */
|
/* modifier key function argument */
|
||||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = dmenucmd } },
|
||||||
|
{ MODKEY|Mod1Mask, XK_v, spawn, {.v = volume } },
|
||||||
{ 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_i, incnmaster, {.i = +1 } },
|
||||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_k, movestack, {.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_p, zoom, {0} },
|
||||||
{ MODKEY, XK_Tab, view, {0} },
|
{ MODKEY, XK_Tab, view, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
|
|
@ -85,6 +111,9 @@ static const 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_y, togglescratch, {.ui = 0 } },
|
||||||
|
{ MODKEY, XK_u, togglescratch, {.ui = 1 } },
|
||||||
|
{ MODKEY, XK_x, togglescratch, {.ui = 2 } },
|
||||||
TAGKEYS( XK_1, 0)
|
TAGKEYS( XK_1, 0)
|
||||||
TAGKEYS( XK_2, 1)
|
TAGKEYS( XK_2, 1)
|
||||||
TAGKEYS( XK_3, 2)
|
TAGKEYS( XK_3, 2)
|
||||||
|
|
@ -107,7 +136,7 @@ static const Button buttons[] = {
|
||||||
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
{ ClkClientWin, MODKEY, Button1, resizemouse, {0} },
|
||||||
{ ClkTagBar, 0, Button1, view, {0} },
|
{ ClkTagBar, 0, Button1, view, {0} },
|
||||||
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
||||||
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,11 @@ FREETYPEINC = /usr/include/freetype2
|
||||||
# OpenBSD (uncomment)
|
# OpenBSD (uncomment)
|
||||||
#FREETYPEINC = ${X11INC}/freetype2
|
#FREETYPEINC = ${X11INC}/freetype2
|
||||||
#MANPREFIX = ${PREFIX}/man
|
#MANPREFIX = ${PREFIX}/man
|
||||||
|
#KVMLIB = -lkvm
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
INCS = -I${X11INC} -I${FREETYPEINC}
|
||||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res ${KVMLIB}
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||||
|
|
|
||||||
296
dwm.c
296
dwm.c
|
|
@ -40,6 +40,12 @@
|
||||||
#include <X11/extensions/Xinerama.h>
|
#include <X11/extensions/Xinerama.h>
|
||||||
#endif /* XINERAMA */
|
#endif /* XINERAMA */
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
|
#include <X11/Xlib-xcb.h>
|
||||||
|
#include <xcb/res.h>
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <kvm.h>
|
||||||
|
#endif /* __OpenBSD */
|
||||||
|
|
||||||
#include "drw.h"
|
#include "drw.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
@ -53,7 +59,10 @@
|
||||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
#define NUMTAGS (LENGTH(tags) + LENGTH(scratchpads))
|
||||||
|
#define TAGMASK ((1 << NUMTAGS) - 1)
|
||||||
|
#define SPTAG(i) ((1 << LENGTH(tags)) << (i))
|
||||||
|
#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags))
|
||||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
|
||||||
/* enums */
|
/* enums */
|
||||||
|
|
@ -91,9 +100,11 @@ struct Client {
|
||||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
|
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
|
||||||
int bw, oldbw;
|
int bw, oldbw;
|
||||||
unsigned int tags;
|
unsigned int tags;
|
||||||
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
|
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow;
|
||||||
|
pid_t pid;
|
||||||
Client *next;
|
Client *next;
|
||||||
Client *snext;
|
Client *snext;
|
||||||
|
Client *swallowing;
|
||||||
Monitor *mon;
|
Monitor *mon;
|
||||||
Window win;
|
Window win;
|
||||||
};
|
};
|
||||||
|
|
@ -137,6 +148,8 @@ typedef struct {
|
||||||
const char *title;
|
const char *title;
|
||||||
unsigned int tags;
|
unsigned int tags;
|
||||||
int isfloating;
|
int isfloating;
|
||||||
|
int isterminal;
|
||||||
|
int noswallow;
|
||||||
int monitor;
|
int monitor;
|
||||||
} Rule;
|
} Rule;
|
||||||
|
|
||||||
|
|
@ -146,6 +159,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
|
||||||
static void arrange(Monitor *m);
|
static void arrange(Monitor *m);
|
||||||
static void arrangemon(Monitor *m);
|
static void arrangemon(Monitor *m);
|
||||||
static void attach(Client *c);
|
static void attach(Client *c);
|
||||||
|
static void attachbottom(Client *c);
|
||||||
static void attachstack(Client *c);
|
static void attachstack(Client *c);
|
||||||
static void buttonpress(XEvent *e);
|
static void buttonpress(XEvent *e);
|
||||||
static void checkotherwm(void);
|
static void checkotherwm(void);
|
||||||
|
|
@ -210,6 +224,7 @@ static void tagmon(const Arg *arg);
|
||||||
static void tile(Monitor *m);
|
static void tile(Monitor *m);
|
||||||
static void togglebar(const Arg *arg);
|
static void togglebar(const Arg *arg);
|
||||||
static void togglefloating(const Arg *arg);
|
static void togglefloating(const Arg *arg);
|
||||||
|
static void togglescratch(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 unfocus(Client *c, int setfocus);
|
static void unfocus(Client *c, int setfocus);
|
||||||
|
|
@ -233,6 +248,12 @@ 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 pid_t getparentprocess(pid_t p);
|
||||||
|
static int isdescprocess(pid_t p, pid_t c);
|
||||||
|
static Client *swallowingclient(Window w);
|
||||||
|
static Client *termforwin(const Client *c);
|
||||||
|
static pid_t winpid(Window w);
|
||||||
|
|
||||||
/* variables */
|
/* variables */
|
||||||
static const char broken[] = "broken";
|
static const char broken[] = "broken";
|
||||||
static char stext[256];
|
static char stext[256];
|
||||||
|
|
@ -267,6 +288,8 @@ static Drw *drw;
|
||||||
static Monitor *mons, *selmon;
|
static Monitor *mons, *selmon;
|
||||||
static Window root, wmcheckwin;
|
static Window root, wmcheckwin;
|
||||||
|
|
||||||
|
static xcb_connection_t *xcon;
|
||||||
|
|
||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
@ -296,8 +319,15 @@ applyrules(Client *c)
|
||||||
&& (!r->class || strstr(class, r->class))
|
&& (!r->class || strstr(class, r->class))
|
||||||
&& (!r->instance || strstr(instance, r->instance)))
|
&& (!r->instance || strstr(instance, r->instance)))
|
||||||
{
|
{
|
||||||
|
c->isterminal = r->isterminal;
|
||||||
|
c->noswallow = r->noswallow;
|
||||||
c->isfloating = r->isfloating;
|
c->isfloating = r->isfloating;
|
||||||
c->tags |= r->tags;
|
c->tags |= r->tags;
|
||||||
|
if ((r->tags & SPTAGMASK) && r->isfloating) {
|
||||||
|
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
|
||||||
|
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
for (m = mons; m && m->num != r->monitor; m = m->next);
|
for (m = mons; m && m->num != r->monitor; m = m->next);
|
||||||
if (m)
|
if (m)
|
||||||
c->mon = m;
|
c->mon = m;
|
||||||
|
|
@ -307,7 +337,7 @@ applyrules(Client *c)
|
||||||
XFree(ch.res_class);
|
XFree(ch.res_class);
|
||||||
if (ch.res_name)
|
if (ch.res_name)
|
||||||
XFree(ch.res_name);
|
XFree(ch.res_name);
|
||||||
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
|
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -407,6 +437,15 @@ attach(Client *c)
|
||||||
c->mon->clients = c;
|
c->mon->clients = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
attachbottom(Client *c)
|
||||||
|
{
|
||||||
|
Client **tc;
|
||||||
|
c->next = NULL;
|
||||||
|
for (tc = &c->mon->clients; *tc; tc = &(*tc)->next);
|
||||||
|
*tc = c;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
attachstack(Client *c)
|
attachstack(Client *c)
|
||||||
{
|
{
|
||||||
|
|
@ -414,6 +453,53 @@ attachstack(Client *c)
|
||||||
c->mon->stack = c;
|
c->mon->stack = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
swallow(Client *p, Client *c)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (c->noswallow || c->isterminal)
|
||||||
|
return;
|
||||||
|
if (c->noswallow && !swallowfloating && c->isfloating)
|
||||||
|
return;
|
||||||
|
|
||||||
|
detach(c);
|
||||||
|
detachstack(c);
|
||||||
|
|
||||||
|
setclientstate(c, WithdrawnState);
|
||||||
|
XUnmapWindow(dpy, p->win);
|
||||||
|
|
||||||
|
p->swallowing = c;
|
||||||
|
c->mon = p->mon;
|
||||||
|
|
||||||
|
Window w = p->win;
|
||||||
|
p->win = c->win;
|
||||||
|
c->win = w;
|
||||||
|
updatetitle(p);
|
||||||
|
XMoveResizeWindow(dpy, p->win, p->x, p->y, p->w, p->h);
|
||||||
|
arrange(p->mon);
|
||||||
|
configure(p);
|
||||||
|
updateclientlist();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
unswallow(Client *c)
|
||||||
|
{
|
||||||
|
c->win = c->swallowing->win;
|
||||||
|
|
||||||
|
free(c->swallowing);
|
||||||
|
c->swallowing = NULL;
|
||||||
|
|
||||||
|
/* unfullscreen the client */
|
||||||
|
setfullscreen(c, 0);
|
||||||
|
updatetitle(c);
|
||||||
|
arrange(c->mon);
|
||||||
|
XMapWindow(dpy, c->win);
|
||||||
|
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||||
|
setclientstate(c, NormalState);
|
||||||
|
focus(NULL);
|
||||||
|
arrange(c->mon);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
buttonpress(XEvent *e)
|
buttonpress(XEvent *e)
|
||||||
{
|
{
|
||||||
|
|
@ -654,6 +740,9 @@ destroynotify(XEvent *e)
|
||||||
|
|
||||||
if ((c = wintoclient(ev->window)))
|
if ((c = wintoclient(ev->window)))
|
||||||
unmanage(c, 1);
|
unmanage(c, 1);
|
||||||
|
|
||||||
|
else if ((c = swallowingclient(ev->window)))
|
||||||
|
unmanage(c->swallowing, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1030,12 +1119,13 @@ killclient(const Arg *arg)
|
||||||
void
|
void
|
||||||
manage(Window w, XWindowAttributes *wa)
|
manage(Window w, XWindowAttributes *wa)
|
||||||
{
|
{
|
||||||
Client *c, *t = NULL;
|
Client *c, *t = NULL, *term = NULL;
|
||||||
Window trans = None;
|
Window trans = None;
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
|
||||||
c = ecalloc(1, sizeof(Client));
|
c = ecalloc(1, sizeof(Client));
|
||||||
c->win = w;
|
c->win = w;
|
||||||
|
c->pid = winpid(w);
|
||||||
/* geometry */
|
/* geometry */
|
||||||
c->x = c->oldx = wa->x;
|
c->x = c->oldx = wa->x;
|
||||||
c->y = c->oldy = wa->y;
|
c->y = c->oldy = wa->y;
|
||||||
|
|
@ -1050,6 +1140,7 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
} else {
|
} else {
|
||||||
c->mon = selmon;
|
c->mon = selmon;
|
||||||
applyrules(c);
|
applyrules(c);
|
||||||
|
term = termforwin(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
|
if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
|
||||||
|
|
@ -1067,13 +1158,15 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
updatewindowtype(c);
|
updatewindowtype(c);
|
||||||
updatesizehints(c);
|
updatesizehints(c);
|
||||||
updatewmhints(c);
|
updatewmhints(c);
|
||||||
|
c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
|
||||||
|
c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
|
||||||
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||||
grabbuttons(c, 0);
|
grabbuttons(c, 0);
|
||||||
if (!c->isfloating)
|
if (!c->isfloating)
|
||||||
c->isfloating = c->oldstate = trans != None || c->isfixed;
|
c->isfloating = c->oldstate = trans != None || c->isfixed;
|
||||||
if (c->isfloating)
|
if (c->isfloating)
|
||||||
XRaiseWindow(dpy, c->win);
|
XRaiseWindow(dpy, c->win);
|
||||||
attach(c);
|
attachbottom(c);
|
||||||
attachstack(c);
|
attachstack(c);
|
||||||
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);
|
||||||
|
|
@ -1084,6 +1177,8 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
c->mon->sel = c;
|
c->mon->sel = c;
|
||||||
arrange(c->mon);
|
arrange(c->mon);
|
||||||
XMapWindow(dpy, c->win);
|
XMapWindow(dpy, c->win);
|
||||||
|
if (term)
|
||||||
|
swallow(term, c);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1426,7 +1521,7 @@ sendmon(Client *c, Monitor *m)
|
||||||
detachstack(c);
|
detachstack(c);
|
||||||
c->mon = m;
|
c->mon = m;
|
||||||
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||||
attach(c);
|
attachbottom(c);
|
||||||
attachstack(c);
|
attachstack(c);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
|
|
@ -1631,6 +1726,10 @@ showhide(Client *c)
|
||||||
if (!c)
|
if (!c)
|
||||||
return;
|
return;
|
||||||
if (ISVISIBLE(c)) {
|
if (ISVISIBLE(c)) {
|
||||||
|
if ((c->tags & SPTAGMASK) && c->isfloating) {
|
||||||
|
c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
|
||||||
|
c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
|
||||||
|
}
|
||||||
/* show clients top down */
|
/* show clients top down */
|
||||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||||
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
|
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
|
||||||
|
|
@ -1734,6 +1833,32 @@ togglefloating(const Arg *arg)
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
togglescratch(const Arg *arg)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
unsigned int found = 0;
|
||||||
|
unsigned int scratchtag = SPTAG(arg->ui);
|
||||||
|
Arg sparg = {.v = scratchpads[arg->ui].cmd};
|
||||||
|
|
||||||
|
for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
|
||||||
|
if (found) {
|
||||||
|
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
|
||||||
|
if (newtagset) {
|
||||||
|
selmon->tagset[selmon->seltags] = newtagset;
|
||||||
|
focus(NULL);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
if (ISVISIBLE(c)) {
|
||||||
|
focus(c);
|
||||||
|
restack(selmon);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
selmon->tagset[selmon->seltags] |= scratchtag;
|
||||||
|
spawn(&sparg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
toggletag(const Arg *arg)
|
toggletag(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
|
@ -1780,6 +1905,20 @@ unmanage(Client *c, int destroyed)
|
||||||
Monitor *m = c->mon;
|
Monitor *m = c->mon;
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
|
||||||
|
if (c->swallowing) {
|
||||||
|
unswallow(c);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client *s = swallowingclient(c->win);
|
||||||
|
if (s) {
|
||||||
|
free(s->swallowing);
|
||||||
|
s->swallowing = NULL;
|
||||||
|
arrange(m);
|
||||||
|
focus(NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
detach(c);
|
detach(c);
|
||||||
detachstack(c);
|
detachstack(c);
|
||||||
if (!destroyed) {
|
if (!destroyed) {
|
||||||
|
|
@ -1795,9 +1934,12 @@ unmanage(Client *c, int destroyed)
|
||||||
XUngrabServer(dpy);
|
XUngrabServer(dpy);
|
||||||
}
|
}
|
||||||
free(c);
|
free(c);
|
||||||
focus(NULL);
|
|
||||||
updateclientlist();
|
if (!s) {
|
||||||
arrange(m);
|
arrange(m);
|
||||||
|
focus(NULL);
|
||||||
|
updateclientlist();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1914,7 +2056,7 @@ updategeom(void)
|
||||||
m->clients = c->next;
|
m->clients = c->next;
|
||||||
detachstack(c);
|
detachstack(c);
|
||||||
c->mon = mons;
|
c->mon = mons;
|
||||||
attach(c);
|
attachbottom(c);
|
||||||
attachstack(c);
|
attachstack(c);
|
||||||
}
|
}
|
||||||
if (m == selmon)
|
if (m == selmon)
|
||||||
|
|
@ -2061,6 +2203,136 @@ view(const Arg *arg)
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
winpid(Window w)
|
||||||
|
{
|
||||||
|
|
||||||
|
pid_t result = 0;
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
xcb_res_client_id_spec_t spec = {0};
|
||||||
|
spec.client = w;
|
||||||
|
spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID;
|
||||||
|
|
||||||
|
xcb_generic_error_t *e = NULL;
|
||||||
|
xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec);
|
||||||
|
xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e);
|
||||||
|
|
||||||
|
if (!r)
|
||||||
|
return (pid_t)0;
|
||||||
|
|
||||||
|
xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r);
|
||||||
|
for (; i.rem; xcb_res_client_id_value_next(&i)) {
|
||||||
|
spec = i.data->spec;
|
||||||
|
if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) {
|
||||||
|
uint32_t *t = xcb_res_client_id_value_value(i.data);
|
||||||
|
result = *t;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(r);
|
||||||
|
|
||||||
|
if (result == (pid_t)-1)
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
#endif /* __linux__ */
|
||||||
|
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
Atom type;
|
||||||
|
int format;
|
||||||
|
unsigned long len, bytes;
|
||||||
|
unsigned char *prop;
|
||||||
|
pid_t ret;
|
||||||
|
|
||||||
|
if (XGetWindowProperty(dpy, w, XInternAtom(dpy, "_NET_WM_PID", 0), 0, 1, False, AnyPropertyType, &type, &format, &len, &bytes, &prop) != Success || !prop)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ret = *(pid_t*)prop;
|
||||||
|
XFree(prop);
|
||||||
|
result = ret;
|
||||||
|
|
||||||
|
#endif /* __OpenBSD__ */
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
getparentprocess(pid_t p)
|
||||||
|
{
|
||||||
|
unsigned int v = 0;
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
FILE *f;
|
||||||
|
char buf[256];
|
||||||
|
snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p);
|
||||||
|
|
||||||
|
if (!(f = fopen(buf, "r")))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fscanf(f, "%*u %*s %*c %u", &v);
|
||||||
|
fclose(f);
|
||||||
|
#endif /* __linux__*/
|
||||||
|
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
int n;
|
||||||
|
kvm_t *kd;
|
||||||
|
struct kinfo_proc *kp;
|
||||||
|
|
||||||
|
kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL);
|
||||||
|
if (!kd)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
kp = kvm_getprocs(kd, KERN_PROC_PID, p, sizeof(*kp), &n);
|
||||||
|
v = kp->p_ppid;
|
||||||
|
#endif /* __OpenBSD__ */
|
||||||
|
|
||||||
|
return (pid_t)v;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
isdescprocess(pid_t p, pid_t c)
|
||||||
|
{
|
||||||
|
while (p != c && c != 0)
|
||||||
|
c = getparentprocess(c);
|
||||||
|
|
||||||
|
return (int)c;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client *
|
||||||
|
termforwin(const Client *w)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
Monitor *m;
|
||||||
|
|
||||||
|
if (!w->pid || w->isterminal)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (m = mons; m; m = m->next) {
|
||||||
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid))
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client *
|
||||||
|
swallowingclient(Window w)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
Monitor *m;
|
||||||
|
|
||||||
|
for (m = mons; m; m = m->next) {
|
||||||
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
if (c->swallowing && c->swallowing->win == w)
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
wintoclient(Window w)
|
wintoclient(Window w)
|
||||||
{
|
{
|
||||||
|
|
@ -2150,10 +2422,12 @@ main(int argc, char *argv[])
|
||||||
fputs("warning: no locale support\n", stderr);
|
fputs("warning: no locale support\n", stderr);
|
||||||
if (!(dpy = XOpenDisplay(NULL)))
|
if (!(dpy = XOpenDisplay(NULL)))
|
||||||
die("dwm: cannot open display");
|
die("dwm: cannot open display");
|
||||||
|
if (!(xcon = XGetXCBConnection(dpy)))
|
||||||
|
die("dwm: cannot get xcb connection\n");
|
||||||
checkotherwm();
|
checkotherwm();
|
||||||
setup();
|
setup();
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
if (pledge("stdio rpath proc exec", NULL) == -1)
|
if (pledge("stdio rpath proc exec ps", NULL) == -1)
|
||||||
die("pledge");
|
die("pledge");
|
||||||
#endif /* __OpenBSD__ */
|
#endif /* __OpenBSD__ */
|
||||||
scan();
|
scan();
|
||||||
|
|
|
||||||
2215
dwm.c.orig
Normal file
2215
dwm.c.orig
Normal file
File diff suppressed because it is too large
Load diff
48
movestack.c
Normal file
48
movestack.c
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
void
|
||||||
|
movestack(const Arg *arg) {
|
||||||
|
Client *c = NULL, *p = NULL, *pc = NULL, *i;
|
||||||
|
|
||||||
|
if(arg->i > 0) {
|
||||||
|
/* find the client after selmon->sel */
|
||||||
|
for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||||||
|
if(!c)
|
||||||
|
for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* find the client before selmon->sel */
|
||||||
|
for(i = selmon->clients; i != selmon->sel; i = i->next)
|
||||||
|
if(ISVISIBLE(i) && !i->isfloating)
|
||||||
|
c = i;
|
||||||
|
if(!c)
|
||||||
|
for(; i; i = i->next)
|
||||||
|
if(ISVISIBLE(i) && !i->isfloating)
|
||||||
|
c = i;
|
||||||
|
}
|
||||||
|
/* find the client before selmon->sel and c */
|
||||||
|
for(i = selmon->clients; i && (!p || !pc); i = i->next) {
|
||||||
|
if(i->next == selmon->sel)
|
||||||
|
p = i;
|
||||||
|
if(i->next == c)
|
||||||
|
pc = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* swap c and selmon->sel selmon->clients in the selmon->clients list */
|
||||||
|
if(c && c != selmon->sel) {
|
||||||
|
Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
|
||||||
|
selmon->sel->next = c->next==selmon->sel?c:c->next;
|
||||||
|
c->next = temp;
|
||||||
|
|
||||||
|
if(p && p != c)
|
||||||
|
p->next = c;
|
||||||
|
if(pc && pc != selmon->sel)
|
||||||
|
pc->next = selmon->sel;
|
||||||
|
|
||||||
|
if(selmon->sel == selmon->clients)
|
||||||
|
selmon->clients = c;
|
||||||
|
else if(c == selmon->clients)
|
||||||
|
selmon->clients = selmon->sel;
|
||||||
|
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
patches/dwm-alwayscenter-20200625-f04cac6.diff
Normal file
12
patches/dwm-alwayscenter-20200625-f04cac6.diff
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
diff -up dwm/dwm.c dwmmod/dwm.c
|
||||||
|
--- dwm/dwm.c 2020-06-25 00:21:30.383692180 -0300
|
||||||
|
+++ dwmmod/dwm.c 2020-06-25 00:20:35.643692330 -0300
|
||||||
|
@@ -1057,6 +1057,8 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
|
updatewindowtype(c);
|
||||||
|
updatesizehints(c);
|
||||||
|
updatewmhints(c);
|
||||||
|
+ c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
|
||||||
|
+ c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
|
||||||
|
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||||
|
grabbuttons(c, 0);
|
||||||
|
if (!c->isfloating)
|
||||||
54
patches/dwm-attachbottom-6.3.diff
Normal file
54
patches/dwm-attachbottom-6.3.diff
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
diff -up dwm-6.3/dwm.c dwm-6.3-attachbottom/dwm.c
|
||||||
|
--- dwm-6.3/dwm.c 2022-01-07 12:42:18.000000000 +0100
|
||||||
|
+++ dwm-6.3-attachbottom/dwm.c 2022-08-17 22:14:41.813809073 +0200
|
||||||
|
@@ -147,6 +147,7 @@ static int applysizehints(Client *c, int
|
||||||
|
static void arrange(Monitor *m);
|
||||||
|
static void arrangemon(Monitor *m);
|
||||||
|
static void attach(Client *c);
|
||||||
|
+static void attachbottom(Client *c);
|
||||||
|
static void attachstack(Client *c);
|
||||||
|
static void buttonpress(XEvent *e);
|
||||||
|
static void checkotherwm(void);
|
||||||
|
@@ -408,6 +409,15 @@ attach(Client *c)
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
+attachbottom(Client *c)
|
||||||
|
+{
|
||||||
|
+ Client **tc;
|
||||||
|
+ c->next = NULL;
|
||||||
|
+ for (tc = &c->mon->clients; *tc; tc = &(*tc)->next);
|
||||||
|
+ *tc = c;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
attachstack(Client *c)
|
||||||
|
{
|
||||||
|
c->snext = c->mon->stack;
|
||||||
|
@@ -1066,7 +1076,7 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
|
c->isfloating = c->oldstate = trans != None || c->isfixed;
|
||||||
|
if (c->isfloating)
|
||||||
|
XRaiseWindow(dpy, c->win);
|
||||||
|
- attach(c);
|
||||||
|
+ attachbottom(c);
|
||||||
|
attachstack(c);
|
||||||
|
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
||||||
|
(unsigned char *) &(c->win), 1);
|
||||||
|
@@ -1421,7 +1431,7 @@ sendmon(Client *c, Monitor *m)
|
||||||
|
detachstack(c);
|
||||||
|
c->mon = m;
|
||||||
|
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||||
|
- attach(c);
|
||||||
|
+ attachbottom(c);
|
||||||
|
attachstack(c);
|
||||||
|
focus(NULL);
|
||||||
|
arrange(NULL);
|
||||||
|
@@ -1903,7 +1913,7 @@ updategeom(void)
|
||||||
|
m->clients = c->next;
|
||||||
|
detachstack(c);
|
||||||
|
c->mon = mons;
|
||||||
|
- attach(c);
|
||||||
|
+ attachbottom(c);
|
||||||
|
attachstack(c);
|
||||||
|
}
|
||||||
|
if (m == selmon)
|
||||||
95
patches/dwm-movestack-20211115-a786211.diff
Normal file
95
patches/dwm-movestack-20211115-a786211.diff
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
From 9a4037dc0ef56f91c009317e78e9e3790dafbb58 Mon Sep 17 00:00:00 2001
|
||||||
|
From: BrunoCooper17 <BrunoCooper17@outlook.com>
|
||||||
|
Date: Mon, 15 Nov 2021 14:04:53 -0600
|
||||||
|
Subject: [PATCH] MoveStack patch
|
||||||
|
|
||||||
|
This plugin allows you to move clients around in the stack and swap them
|
||||||
|
with the master. It emulates the behavior off mod+shift+j and mod+shift+k
|
||||||
|
in Xmonad. movestack(+1) will swap the client with the current focus with
|
||||||
|
the next client. movestack(-1) will swap the client with the current focus
|
||||||
|
with the previous client.
|
||||||
|
---
|
||||||
|
config.def.h | 3 +++
|
||||||
|
movestack.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
2 files changed, 51 insertions(+)
|
||||||
|
create mode 100644 movestack.c
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index a2ac963..33efa5b 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -60,6 +60,7 @@ 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 *termcmd[] = { "st", NULL };
|
||||||
|
|
||||||
|
+#include "movestack.c"
|
||||||
|
static Key keys[] = {
|
||||||
|
/* modifier key function argument */
|
||||||
|
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||||
|
@@ -71,6 +72,8 @@ static Key keys[] = {
|
||||||
|
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
|
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
|
+ { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
|
||||||
|
+ { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_Return, zoom, {0} },
|
||||||
|
{ MODKEY, XK_Tab, view, {0} },
|
||||||
|
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||||
|
diff --git a/movestack.c b/movestack.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..520f4ae
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/movestack.c
|
||||||
|
@@ -0,0 +1,48 @@
|
||||||
|
+void
|
||||||
|
+movestack(const Arg *arg) {
|
||||||
|
+ Client *c = NULL, *p = NULL, *pc = NULL, *i;
|
||||||
|
+
|
||||||
|
+ if(arg->i > 0) {
|
||||||
|
+ /* find the client after selmon->sel */
|
||||||
|
+ for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||||||
|
+ if(!c)
|
||||||
|
+ for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+ else {
|
||||||
|
+ /* find the client before selmon->sel */
|
||||||
|
+ for(i = selmon->clients; i != selmon->sel; i = i->next)
|
||||||
|
+ if(ISVISIBLE(i) && !i->isfloating)
|
||||||
|
+ c = i;
|
||||||
|
+ if(!c)
|
||||||
|
+ for(; i; i = i->next)
|
||||||
|
+ if(ISVISIBLE(i) && !i->isfloating)
|
||||||
|
+ c = i;
|
||||||
|
+ }
|
||||||
|
+ /* find the client before selmon->sel and c */
|
||||||
|
+ for(i = selmon->clients; i && (!p || !pc); i = i->next) {
|
||||||
|
+ if(i->next == selmon->sel)
|
||||||
|
+ p = i;
|
||||||
|
+ if(i->next == c)
|
||||||
|
+ pc = i;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* swap c and selmon->sel selmon->clients in the selmon->clients list */
|
||||||
|
+ if(c && c != selmon->sel) {
|
||||||
|
+ Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
|
||||||
|
+ selmon->sel->next = c->next==selmon->sel?c:c->next;
|
||||||
|
+ c->next = temp;
|
||||||
|
+
|
||||||
|
+ if(p && p != c)
|
||||||
|
+ p->next = c;
|
||||||
|
+ if(pc && pc != selmon->sel)
|
||||||
|
+ pc->next = selmon->sel;
|
||||||
|
+
|
||||||
|
+ if(selmon->sel == selmon->clients)
|
||||||
|
+ selmon->clients = c;
|
||||||
|
+ else if(c == selmon->clients)
|
||||||
|
+ selmon->clients = selmon->sel;
|
||||||
|
+
|
||||||
|
+ arrange(selmon);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
\ No newline at end of file
|
||||||
|
--
|
||||||
|
2.33.1
|
||||||
|
|
||||||
199
patches/dwm-scratchpads-20200414-728d397b.diff
Normal file
199
patches/dwm-scratchpads-20200414-728d397b.diff
Normal file
|
|
@ -0,0 +1,199 @@
|
||||||
|
From 728d397b21982af88737277fd9d6939a7b558786 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Christian Tenllado <ctenllado@gmail.com>
|
||||||
|
Date: Tue, 14 Apr 2020 23:31:15 +0200
|
||||||
|
Subject: [PATCH] Multiple scratchpads
|
||||||
|
|
||||||
|
This patch enables multiple scratchpads, each with one asigned window.
|
||||||
|
This enables the same scratchpad workflow that you have in i3.
|
||||||
|
|
||||||
|
Scratchpads are implemented as special tags, whose mask does not
|
||||||
|
apply to new spawned windows. To assign a window to a scratchpad you
|
||||||
|
have to set up a rule, as you do with regular tags.
|
||||||
|
|
||||||
|
Windows tagged with scratchpad tags can be set floating or not in the
|
||||||
|
rules array. Most users would probably want them floating (i3 style),
|
||||||
|
but having them tiled does also perfectly work and might fit better the
|
||||||
|
DWM approach. In case they are set floating, the patch moves them to the
|
||||||
|
center of the screen whenever they are shown. The patch can easily be
|
||||||
|
modified to make this last feature configurable in the rules array (see
|
||||||
|
the center patch).
|
||||||
|
|
||||||
|
The togglescratch function, borrowed from the previous scratchpad patch
|
||||||
|
and slightly modified, can be used to spawn a registered scratchpad
|
||||||
|
process or toggle its view. This function looks for a window tagged with
|
||||||
|
the selected scratchpad tag. If it is found its view is toggled. If it is
|
||||||
|
not found the corresponding registered command is spawned. The
|
||||||
|
config.def.h shows three examples of its use to spawn a terminal in the
|
||||||
|
first scratchpad tag, a second terminal running ranger on the second
|
||||||
|
scratchpad tag and the keepassxc application to manage passwords on a
|
||||||
|
third scratchpad tag.
|
||||||
|
|
||||||
|
If you prefer to spawn your scratchpad applications from the startup
|
||||||
|
script, you might opt for binding keys to toggleview instead, as
|
||||||
|
scratchpads are just special tags (you may even extend the TAGKEYS macro
|
||||||
|
to generalize the key bindings).
|
||||||
|
---
|
||||||
|
config.def.h | 28 ++++++++++++++++++++++++----
|
||||||
|
dwm.c | 43 +++++++++++++++++++++++++++++++++++++++++--
|
||||||
|
2 files changed, 65 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1c0b587..06265e1 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -18,17 +18,33 @@ static const char *colors[][3] = {
|
||||||
|
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||||
|
};
|
||||||
|
|
||||||
|
+typedef struct {
|
||||||
|
+ const char *name;
|
||||||
|
+ const void *cmd;
|
||||||
|
+} Sp;
|
||||||
|
+const char *spcmd1[] = {"st", "-n", "spterm", "-g", "120x34", NULL };
|
||||||
|
+const char *spcmd2[] = {"st", "-n", "spfm", "-g", "144x41", "-e", "ranger", NULL };
|
||||||
|
+const char *spcmd3[] = {"keepassxc", NULL };
|
||||||
|
+static Sp scratchpads[] = {
|
||||||
|
+ /* name cmd */
|
||||||
|
+ {"spterm", spcmd1},
|
||||||
|
+ {"spranger", spcmd2},
|
||||||
|
+ {"keepassxc", spcmd3},
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
/* 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 },
|
||||||
|
- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||||
|
+ { "Gimp", NULL, NULL, 0, 1, -1 },
|
||||||
|
+ { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||||
|
+ { NULL, "spterm", NULL, SPTAG(0), 1, -1 },
|
||||||
|
+ { NULL, "spfm", NULL, SPTAG(1), 1, -1 },
|
||||||
|
+ { NULL, "keepassxc", NULL, SPTAG(2), 0, -1 },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* layout(s) */
|
||||||
|
@@ -59,6 +75,7 @@ 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 *termcmd[] = { "st", NULL };
|
||||||
|
|
||||||
|
+
|
||||||
|
static Key keys[] = {
|
||||||
|
/* modifier key function argument */
|
||||||
|
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||||
|
@@ -84,6 +101,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_y, togglescratch, {.ui = 0 } },
|
||||||
|
+ { MODKEY, XK_u, togglescratch, {.ui = 1 } },
|
||||||
|
+ { MODKEY, XK_x, togglescratch, {.ui = 2 } },
|
||||||
|
TAGKEYS( XK_1, 0)
|
||||||
|
TAGKEYS( XK_2, 1)
|
||||||
|
TAGKEYS( XK_3, 2)
|
||||||
|
@@ -106,7 +126,7 @@ static Button buttons[] = {
|
||||||
|
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||||
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
|
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||||
|
- { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||||
|
+ { ClkClientWin, MODKEY, Button1, resizemouse, {0} },
|
||||||
|
{ ClkTagBar, 0, Button1, view, {0} },
|
||||||
|
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
||||||
|
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 4465af1..646aa1a 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -54,7 +54,10 @@
|
||||||
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||||
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||||
|
-#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||||
|
+#define NUMTAGS (LENGTH(tags) + LENGTH(scratchpads))
|
||||||
|
+#define TAGMASK ((1 << NUMTAGS) - 1)
|
||||||
|
+#define SPTAG(i) ((1 << LENGTH(tags)) << (i))
|
||||||
|
+#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags))
|
||||||
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
|
||||||
|
/* enums */
|
||||||
|
@@ -211,6 +214,7 @@ static void tagmon(const Arg *arg);
|
||||||
|
static void tile(Monitor *);
|
||||||
|
static void togglebar(const Arg *arg);
|
||||||
|
static void togglefloating(const Arg *arg);
|
||||||
|
+static void togglescratch(const Arg *arg);
|
||||||
|
static void toggletag(const Arg *arg);
|
||||||
|
static void toggleview(const Arg *arg);
|
||||||
|
static void unfocus(Client *c, int setfocus);
|
||||||
|
@@ -299,6 +303,11 @@ applyrules(Client *c)
|
||||||
|
{
|
||||||
|
c->isfloating = r->isfloating;
|
||||||
|
c->tags |= r->tags;
|
||||||
|
+ if ((r->tags & SPTAGMASK) && r->isfloating) {
|
||||||
|
+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
|
||||||
|
+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
for (m = mons; m && m->num != r->monitor; m = m->next);
|
||||||
|
if (m)
|
||||||
|
c->mon = m;
|
||||||
|
@@ -308,7 +317,7 @@ applyrules(Client *c)
|
||||||
|
XFree(ch.res_class);
|
||||||
|
if (ch.res_name)
|
||||||
|
XFree(ch.res_name);
|
||||||
|
- c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
|
||||||
|
+ c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
@@ -1616,6 +1625,10 @@ showhide(Client *c)
|
||||||
|
if (!c)
|
||||||
|
return;
|
||||||
|
if (ISVISIBLE(c)) {
|
||||||
|
+ if ((c->tags & SPTAGMASK) && c->isfloating) {
|
||||||
|
+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2);
|
||||||
|
+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2);
|
||||||
|
+ }
|
||||||
|
/* show clients top down */
|
||||||
|
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||||
|
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
|
||||||
|
@@ -1719,6 +1732,32 @@ togglefloating(const Arg *arg)
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+togglescratch(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ Client *c;
|
||||||
|
+ unsigned int found = 0;
|
||||||
|
+ unsigned int scratchtag = SPTAG(arg->ui);
|
||||||
|
+ Arg sparg = {.v = scratchpads[arg->ui].cmd};
|
||||||
|
+
|
||||||
|
+ for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
|
||||||
|
+ if (found) {
|
||||||
|
+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
|
||||||
|
+ if (newtagset) {
|
||||||
|
+ selmon->tagset[selmon->seltags] = newtagset;
|
||||||
|
+ focus(NULL);
|
||||||
|
+ arrange(selmon);
|
||||||
|
+ }
|
||||||
|
+ if (ISVISIBLE(c)) {
|
||||||
|
+ focus(c);
|
||||||
|
+ restack(selmon);
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ selmon->tagset[selmon->seltags] |= scratchtag;
|
||||||
|
+ spawn(&sparg);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
toggletag(const Arg *arg)
|
||||||
|
{
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
||||||
412
patches/dwm-swallow-6.3.diff
Normal file
412
patches/dwm-swallow-6.3.diff
Normal file
|
|
@ -0,0 +1,412 @@
|
||||||
|
From 0cf9a007511f7dfd7dd94171b172562ebac9b6d5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tom Schwindl <schwindl@posteo.de>
|
||||||
|
Date: Sat, 10 Sep 2022 12:51:09 +0200
|
||||||
|
Subject: [PATCH] 6.3 swallow patch
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 9 +-
|
||||||
|
config.mk | 3 +-
|
||||||
|
dwm.c | 235 +++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||||
|
3 files changed, 237 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 061ad662f82a..0b2b8ffd30d5 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -3,6 +3,7 @@
|
||||||
|
/* appearance */
|
||||||
|
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
|
+static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
|
||||||
|
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" };
|
||||||
|
@@ -26,9 +27,11 @@ static const Rule rules[] = {
|
||||||
|
* WM_CLASS(STRING) = instance, class
|
||||||
|
* WM_NAME(STRING) = title
|
||||||
|
*/
|
||||||
|
- /* class instance title tags mask isfloating monitor */
|
||||||
|
- { "Gimp", NULL, NULL, 0, 1, -1 },
|
||||||
|
- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||||
|
+ /* class instance title tags mask isfloating isterminal noswallow monitor */
|
||||||
|
+ { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||||
|
+ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 },
|
||||||
|
+ { "St", NULL, NULL, 0, 0, 1, 0, -1 },
|
||||||
|
+ { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* layout(s) */
|
||||||
|
diff --git a/config.mk b/config.mk
|
||||||
|
index 81c493ef4aff..52d1ebf30bec 100644
|
||||||
|
--- a/config.mk
|
||||||
|
+++ b/config.mk
|
||||||
|
@@ -20,10 +20,11 @@ FREETYPEINC = /usr/include/freetype2
|
||||||
|
# OpenBSD (uncomment)
|
||||||
|
#FREETYPEINC = ${X11INC}/freetype2
|
||||||
|
#MANPREFIX = ${PREFIX}/man
|
||||||
|
+#KVMLIB = -lkvm
|
||||||
|
|
||||||
|
# includes and libs
|
||||||
|
INCS = -I${X11INC} -I${FREETYPEINC}
|
||||||
|
-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
||||||
|
+LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res ${KVMLIB}
|
||||||
|
|
||||||
|
# flags
|
||||||
|
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index e5efb6a22806..e68294b6b679 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -40,6 +40,12 @@
|
||||||
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
#endif /* XINERAMA */
|
||||||
|
#include <X11/Xft/Xft.h>
|
||||||
|
+#include <X11/Xlib-xcb.h>
|
||||||
|
+#include <xcb/res.h>
|
||||||
|
+#ifdef __OpenBSD__
|
||||||
|
+#include <sys/sysctl.h>
|
||||||
|
+#include <kvm.h>
|
||||||
|
+#endif /* __OpenBSD */
|
||||||
|
|
||||||
|
#include "drw.h"
|
||||||
|
#include "util.h"
|
||||||
|
@@ -92,9 +98,11 @@ struct Client {
|
||||||
|
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
|
||||||
|
int bw, oldbw;
|
||||||
|
unsigned int tags;
|
||||||
|
- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
|
||||||
|
+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow;
|
||||||
|
+ pid_t pid;
|
||||||
|
Client *next;
|
||||||
|
Client *snext;
|
||||||
|
+ Client *swallowing;
|
||||||
|
Monitor *mon;
|
||||||
|
Window win;
|
||||||
|
};
|
||||||
|
@@ -138,6 +146,8 @@ typedef struct {
|
||||||
|
const char *title;
|
||||||
|
unsigned int tags;
|
||||||
|
int isfloating;
|
||||||
|
+ int isterminal;
|
||||||
|
+ int noswallow;
|
||||||
|
int monitor;
|
||||||
|
} Rule;
|
||||||
|
|
||||||
|
@@ -235,6 +245,12 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||||
|
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
|
static void zoom(const Arg *arg);
|
||||||
|
|
||||||
|
+static pid_t getparentprocess(pid_t p);
|
||||||
|
+static int isdescprocess(pid_t p, pid_t c);
|
||||||
|
+static Client *swallowingclient(Window w);
|
||||||
|
+static Client *termforwin(const Client *c);
|
||||||
|
+static pid_t winpid(Window w);
|
||||||
|
+
|
||||||
|
/* variables */
|
||||||
|
static const char broken[] = "broken";
|
||||||
|
static char stext[256];
|
||||||
|
@@ -269,6 +285,8 @@ static Drw *drw;
|
||||||
|
static Monitor *mons, *selmon;
|
||||||
|
static Window root, wmcheckwin;
|
||||||
|
|
||||||
|
+static xcb_connection_t *xcon;
|
||||||
|
+
|
||||||
|
/* configuration, allows nested code to access above variables */
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
@@ -298,6 +316,8 @@ applyrules(Client *c)
|
||||||
|
&& (!r->class || strstr(class, r->class))
|
||||||
|
&& (!r->instance || strstr(instance, r->instance)))
|
||||||
|
{
|
||||||
|
+ c->isterminal = r->isterminal;
|
||||||
|
+ c->noswallow = r->noswallow;
|
||||||
|
c->isfloating = r->isfloating;
|
||||||
|
c->tags |= r->tags;
|
||||||
|
for (m = mons; m && m->num != r->monitor; m = m->next);
|
||||||
|
@@ -416,6 +436,53 @@ attachstack(Client *c)
|
||||||
|
c->mon->stack = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+swallow(Client *p, Client *c)
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ if (c->noswallow || c->isterminal)
|
||||||
|
+ return;
|
||||||
|
+ if (c->noswallow && !swallowfloating && c->isfloating)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ detach(c);
|
||||||
|
+ detachstack(c);
|
||||||
|
+
|
||||||
|
+ setclientstate(c, WithdrawnState);
|
||||||
|
+ XUnmapWindow(dpy, p->win);
|
||||||
|
+
|
||||||
|
+ p->swallowing = c;
|
||||||
|
+ c->mon = p->mon;
|
||||||
|
+
|
||||||
|
+ Window w = p->win;
|
||||||
|
+ p->win = c->win;
|
||||||
|
+ c->win = w;
|
||||||
|
+ updatetitle(p);
|
||||||
|
+ XMoveResizeWindow(dpy, p->win, p->x, p->y, p->w, p->h);
|
||||||
|
+ arrange(p->mon);
|
||||||
|
+ configure(p);
|
||||||
|
+ updateclientlist();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+unswallow(Client *c)
|
||||||
|
+{
|
||||||
|
+ c->win = c->swallowing->win;
|
||||||
|
+
|
||||||
|
+ free(c->swallowing);
|
||||||
|
+ c->swallowing = NULL;
|
||||||
|
+
|
||||||
|
+ /* unfullscreen the client */
|
||||||
|
+ setfullscreen(c, 0);
|
||||||
|
+ updatetitle(c);
|
||||||
|
+ arrange(c->mon);
|
||||||
|
+ XMapWindow(dpy, c->win);
|
||||||
|
+ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||||
|
+ setclientstate(c, NormalState);
|
||||||
|
+ focus(NULL);
|
||||||
|
+ arrange(c->mon);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
buttonpress(XEvent *e)
|
||||||
|
{
|
||||||
|
@@ -656,6 +723,9 @@ destroynotify(XEvent *e)
|
||||||
|
|
||||||
|
if ((c = wintoclient(ev->window)))
|
||||||
|
unmanage(c, 1);
|
||||||
|
+
|
||||||
|
+ else if ((c = swallowingclient(ev->window)))
|
||||||
|
+ unmanage(c->swallowing, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -1022,12 +1092,13 @@ killclient(const Arg *arg)
|
||||||
|
void
|
||||||
|
manage(Window w, XWindowAttributes *wa)
|
||||||
|
{
|
||||||
|
- Client *c, *t = NULL;
|
||||||
|
+ Client *c, *t = NULL, *term = NULL;
|
||||||
|
Window trans = None;
|
||||||
|
XWindowChanges wc;
|
||||||
|
|
||||||
|
c = ecalloc(1, sizeof(Client));
|
||||||
|
c->win = w;
|
||||||
|
+ c->pid = winpid(w);
|
||||||
|
/* geometry */
|
||||||
|
c->x = c->oldx = wa->x;
|
||||||
|
c->y = c->oldy = wa->y;
|
||||||
|
@@ -1042,6 +1113,7 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
|
} else {
|
||||||
|
c->mon = selmon;
|
||||||
|
applyrules(c);
|
||||||
|
+ term = termforwin(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
|
||||||
|
@@ -1076,6 +1148,8 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
|
c->mon->sel = c;
|
||||||
|
arrange(c->mon);
|
||||||
|
XMapWindow(dpy, c->win);
|
||||||
|
+ if (term)
|
||||||
|
+ swallow(term, c);
|
||||||
|
focus(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1763,6 +1837,20 @@ unmanage(Client *c, int destroyed)
|
||||||
|
Monitor *m = c->mon;
|
||||||
|
XWindowChanges wc;
|
||||||
|
|
||||||
|
+ if (c->swallowing) {
|
||||||
|
+ unswallow(c);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ Client *s = swallowingclient(c->win);
|
||||||
|
+ if (s) {
|
||||||
|
+ free(s->swallowing);
|
||||||
|
+ s->swallowing = NULL;
|
||||||
|
+ arrange(m);
|
||||||
|
+ focus(NULL);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
detach(c);
|
||||||
|
detachstack(c);
|
||||||
|
if (!destroyed) {
|
||||||
|
@@ -1778,9 +1866,12 @@ unmanage(Client *c, int destroyed)
|
||||||
|
XUngrabServer(dpy);
|
||||||
|
}
|
||||||
|
free(c);
|
||||||
|
- focus(NULL);
|
||||||
|
- updateclientlist();
|
||||||
|
- arrange(m);
|
||||||
|
+
|
||||||
|
+ if (!s) {
|
||||||
|
+ arrange(m);
|
||||||
|
+ focus(NULL);
|
||||||
|
+ updateclientlist();
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -2044,6 +2135,136 @@ view(const Arg *arg)
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
+pid_t
|
||||||
|
+winpid(Window w)
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ pid_t result = 0;
|
||||||
|
+
|
||||||
|
+#ifdef __linux__
|
||||||
|
+ xcb_res_client_id_spec_t spec = {0};
|
||||||
|
+ spec.client = w;
|
||||||
|
+ spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID;
|
||||||
|
+
|
||||||
|
+ xcb_generic_error_t *e = NULL;
|
||||||
|
+ xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec);
|
||||||
|
+ xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e);
|
||||||
|
+
|
||||||
|
+ if (!r)
|
||||||
|
+ return (pid_t)0;
|
||||||
|
+
|
||||||
|
+ xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r);
|
||||||
|
+ for (; i.rem; xcb_res_client_id_value_next(&i)) {
|
||||||
|
+ spec = i.data->spec;
|
||||||
|
+ if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) {
|
||||||
|
+ uint32_t *t = xcb_res_client_id_value_value(i.data);
|
||||||
|
+ result = *t;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ free(r);
|
||||||
|
+
|
||||||
|
+ if (result == (pid_t)-1)
|
||||||
|
+ result = 0;
|
||||||
|
+
|
||||||
|
+#endif /* __linux__ */
|
||||||
|
+
|
||||||
|
+#ifdef __OpenBSD__
|
||||||
|
+ Atom type;
|
||||||
|
+ int format;
|
||||||
|
+ unsigned long len, bytes;
|
||||||
|
+ unsigned char *prop;
|
||||||
|
+ pid_t ret;
|
||||||
|
+
|
||||||
|
+ if (XGetWindowProperty(dpy, w, XInternAtom(dpy, "_NET_WM_PID", 0), 0, 1, False, AnyPropertyType, &type, &format, &len, &bytes, &prop) != Success || !prop)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ ret = *(pid_t*)prop;
|
||||||
|
+ XFree(prop);
|
||||||
|
+ result = ret;
|
||||||
|
+
|
||||||
|
+#endif /* __OpenBSD__ */
|
||||||
|
+ return result;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+pid_t
|
||||||
|
+getparentprocess(pid_t p)
|
||||||
|
+{
|
||||||
|
+ unsigned int v = 0;
|
||||||
|
+
|
||||||
|
+#ifdef __linux__
|
||||||
|
+ FILE *f;
|
||||||
|
+ char buf[256];
|
||||||
|
+ snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p);
|
||||||
|
+
|
||||||
|
+ if (!(f = fopen(buf, "r")))
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ fscanf(f, "%*u %*s %*c %u", &v);
|
||||||
|
+ fclose(f);
|
||||||
|
+#endif /* __linux__*/
|
||||||
|
+
|
||||||
|
+#ifdef __OpenBSD__
|
||||||
|
+ int n;
|
||||||
|
+ kvm_t *kd;
|
||||||
|
+ struct kinfo_proc *kp;
|
||||||
|
+
|
||||||
|
+ kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL);
|
||||||
|
+ if (!kd)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ kp = kvm_getprocs(kd, KERN_PROC_PID, p, sizeof(*kp), &n);
|
||||||
|
+ v = kp->p_ppid;
|
||||||
|
+#endif /* __OpenBSD__ */
|
||||||
|
+
|
||||||
|
+ return (pid_t)v;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int
|
||||||
|
+isdescprocess(pid_t p, pid_t c)
|
||||||
|
+{
|
||||||
|
+ while (p != c && c != 0)
|
||||||
|
+ c = getparentprocess(c);
|
||||||
|
+
|
||||||
|
+ return (int)c;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+Client *
|
||||||
|
+termforwin(const Client *w)
|
||||||
|
+{
|
||||||
|
+ Client *c;
|
||||||
|
+ Monitor *m;
|
||||||
|
+
|
||||||
|
+ if (!w->pid || w->isterminal)
|
||||||
|
+ return NULL;
|
||||||
|
+
|
||||||
|
+ for (m = mons; m; m = m->next) {
|
||||||
|
+ for (c = m->clients; c; c = c->next) {
|
||||||
|
+ if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid))
|
||||||
|
+ return c;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return NULL;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+Client *
|
||||||
|
+swallowingclient(Window w)
|
||||||
|
+{
|
||||||
|
+ Client *c;
|
||||||
|
+ Monitor *m;
|
||||||
|
+
|
||||||
|
+ for (m = mons; m; m = m->next) {
|
||||||
|
+ for (c = m->clients; c; c = c->next) {
|
||||||
|
+ if (c->swallowing && c->swallowing->win == w)
|
||||||
|
+ return c;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return NULL;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
Client *
|
||||||
|
wintoclient(Window w)
|
||||||
|
{
|
||||||
|
@@ -2133,10 +2354,12 @@ main(int argc, char *argv[])
|
||||||
|
fputs("warning: no locale support\n", stderr);
|
||||||
|
if (!(dpy = XOpenDisplay(NULL)))
|
||||||
|
die("dwm: cannot open display");
|
||||||
|
+ if (!(xcon = XGetXCBConnection(dpy)))
|
||||||
|
+ die("dwm: cannot get xcb connection\n");
|
||||||
|
checkotherwm();
|
||||||
|
setup();
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
- if (pledge("stdio rpath proc exec", NULL) == -1)
|
||||||
|
+ if (pledge("stdio rpath proc exec ps", NULL) == -1)
|
||||||
|
die("pledge");
|
||||||
|
#endif /* __OpenBSD__ */
|
||||||
|
scan();
|
||||||
|
--
|
||||||
|
2.37.2
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue