Merge branch 'master' of github.com:Jab2870/dwm
This commit is contained in:
commit
71b5f7ce6a
7 changed files with 471 additions and 83 deletions
131
config.def.h
131
config.def.h
|
@ -1,12 +1,15 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
//The media and volume keys
|
||||
#include "X11/XF86keysym.h"
|
||||
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const int showbar = 0; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
static const char *fonts[] = { "monospace:size=10" };
|
||||
static const char dmenufont[] = "monospace:size=10";
|
||||
static const char *fonts[] = { "Iosevka:size=10" };
|
||||
static const char dmenufont[] = "Iosevka:size=10";
|
||||
static const char col_gray1[] = "#222222";
|
||||
static const char col_gray2[] = "#444444";
|
||||
static const char col_gray3[] = "#bbbbbb";
|
||||
|
@ -26,22 +29,29 @@ 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, 0, 0, 0, -1 },
|
||||
//{ "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 },
|
||||
{ "xterm-256color", NULL, NULL, 0, 0, 1, 1, -1 },
|
||||
{ "Thunderbird", NULL, NULL, 1 << 8 , 0, 0, 0, -1 },
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||
static const int nmaster = 1; /* number of clients in master area */
|
||||
static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */
|
||||
static const int attachbelow = 1; /* 1 means attach after the currently active window */
|
||||
static int attachbelow = 0; /* 1 means attach after the currently active window */
|
||||
|
||||
#include "tcl.c"
|
||||
#include "fibonacci.c"
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
{ "[]=", tile }, /* first entry is default */
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
{ "|||", tcl },
|
||||
{ "[@]", spiral },
|
||||
{ "[\\]", dwindle },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
|
@ -61,52 +71,73 @@ static const char *dmenucmd[] = { "rofi", "-show", "drun", 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[] = { "folder-shell", NULL };
|
||||
|
||||
static const char *fullscreenshot[] = { "scrot", "/tmp/%F_%T_$wx$h.png", "-e", "xclip -selection clipboard -target image/png -i $f", NULL };
|
||||
static const char *activescreenshot[] = { "scrot", "-u", "/tmp/%F_%T_$wx$h.png", "-e", "xclip -selection clipboard -target image/png -i $f", NULL };
|
||||
static const char *selectscreenshot[] = { "scrot", "-s", "/tmp/%F_%T_$wx$h.png", "-e", "xclip -selection clipboard -target image/png -i $f", NULL };
|
||||
static const char *fullscreenshot[] = { "screenshot", NULL };
|
||||
static const char *activescreenshot[] = { "screenshot", "window", NULL };
|
||||
static const char *selectscreenshot[] = { "screenshot", "select", NULL };
|
||||
|
||||
static const char *greenclip[] = { "rofi", "-modi", "clipboard:greenclip print", "-show", "clipboard", "-run-command", "{cmd}", NULL };
|
||||
|
||||
static const char *qutebrowser[] = { "qutebrowser", NULL };
|
||||
static const char *chromium[] = { "chromium-snapshot-bin", NULL };
|
||||
static const char *bigchromium[] = { "chromium-snapshot-bin", "--force-device-scale-factor=2", NULL };
|
||||
|
||||
static const char *date[] = { "datetime", NULL };
|
||||
|
||||
static const char *playpause[] = { "playerctl", "play-pause", NULL };
|
||||
|
||||
static const char *logout[] = { "rofi-shutdown", NULL };
|
||||
|
||||
#include "movestack.c"
|
||||
static Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
|
||||
{ MODKEY, XK_b, togglebar, {0} },
|
||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY|ShiftMask, XK_Return, zoom, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ MODKEY, XK_q, killclient, {0} },
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||
{ MODKEY, XK_Print, spawn, {.v = fullscreenshot } },
|
||||
{ ControlMask, XK_Print, spawn, {.v = activescreenshot } },
|
||||
{ ShiftMask, XK_Print, spawn, {.v = selectscreenshot } },
|
||||
//Applications
|
||||
{ MODKEY|ShiftMask, XK_q, spawn, {.v = { "qutebrowser", NULL } } },
|
||||
{ MODKEY, XK_c, spawn, {.v = { "chromium-snapshot-bin", NULL } } },
|
||||
{ MODKEY|ShiftMask, XK_c, spawn, {.v = { "chromium-snapshot-bin", "--force-device-scale-factor=2", NULL } } },
|
||||
TAGKEYS( XK_1, 0)
|
||||
TAGKEYS( XK_2, 1)
|
||||
TAGKEYS( XK_3, 2)
|
||||
TAGKEYS( XK_4, 3)
|
||||
TAGKEYS( XK_5, 4)
|
||||
TAGKEYS( XK_6, 5)
|
||||
TAGKEYS( XK_7, 6)
|
||||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
{ MODKEY|ShiftMask, XK_r, quit, {0} },
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
|
||||
{ MODKEY, XK_b, togglebar, {0} },
|
||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
|
||||
{ MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
|
||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY|ShiftMask, XK_l, spawn, {.v = logout} },
|
||||
{ MODKEY|ShiftMask, XK_Return, zoom, {0} },
|
||||
{ MODKEY, XK_Tab, toggleAttachBelow, {0} },
|
||||
{ MODKEY, XK_q, killclient, {0} },
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[4]} },
|
||||
{ MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[5]} },
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||
{ 0, XK_Print, spawn, {.v = fullscreenshot } },
|
||||
{ ControlMask, XK_Print, spawn, {.v = activescreenshot } },
|
||||
{ ShiftMask, XK_Print, spawn, {.v = selectscreenshot } },
|
||||
{ 0, XF86XK_AudioPlay, spawn, {.v = playpause } },
|
||||
{ MODKEY|ShiftMask, XK_d, spawn, {.v = date } },
|
||||
{ MODKEY|ShiftMask, XK_Insert, spawn, {.v = greenclip } },
|
||||
//Applications
|
||||
{ MODKEY|ShiftMask, XK_q, spawn, {.v = qutebrowser } },
|
||||
{ MODKEY, XK_c, spawn, {.v = chromium } },
|
||||
{ MODKEY|ShiftMask, XK_c, spawn, {.v = bigchromium } },
|
||||
TAGKEYS( XK_1, 0)
|
||||
TAGKEYS( XK_2, 1)
|
||||
TAGKEYS( XK_3, 2)
|
||||
TAGKEYS( XK_4, 3)
|
||||
TAGKEYS( XK_5, 4)
|
||||
TAGKEYS( XK_6, 5)
|
||||
TAGKEYS( XK_7, 6)
|
||||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
{ MODKEY|ShiftMask, XK_r, quit, {0} },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
|
|
|
@ -22,7 +22,7 @@ FREETYPEINC = /usr/include/freetype2
|
|||
|
||||
# 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
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
|
|
8
dwm.1
8
dwm.1
|
@ -110,7 +110,13 @@ Focus next window.
|
|||
.B Super\-k
|
||||
Focus previous window.
|
||||
.TP
|
||||
.B Super\-i
|
||||
.B Super\-Shift\-j
|
||||
Moves the focused window down in the stack
|
||||
.TP
|
||||
.B Super\-Shift\-k
|
||||
Moves the focused window up in the stack
|
||||
.TP
|
||||
.B Mod1\-i
|
||||
Increase number of windows in master area.
|
||||
.TP
|
||||
.B Super\-d
|
||||
|
|
224
dwm.c
224
dwm.c
|
@ -40,6 +40,8 @@
|
|||
#include <X11/extensions/Xinerama.h>
|
||||
#endif /* XINERAMA */
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <X11/Xlib-xcb.h>
|
||||
#include <xcb/res.h>
|
||||
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
|
@ -92,9 +94,11 @@ struct Client {
|
|||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||
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 +142,8 @@ typedef struct {
|
|||
const char *title;
|
||||
unsigned int tags;
|
||||
int isfloating;
|
||||
int isterminal;
|
||||
int noswallow;
|
||||
int monitor;
|
||||
} Rule;
|
||||
|
||||
|
@ -148,6 +154,7 @@ static void arrange(Monitor *m);
|
|||
static void arrangemon(Monitor *m);
|
||||
static void attach(Client *c);
|
||||
static void attachBelow(Client *c);
|
||||
static void toggleAttachBelow();
|
||||
static void attachstack(Client *c);
|
||||
static void buttonpress(XEvent *e);
|
||||
static void checkotherwm(void);
|
||||
|
@ -235,6 +242,13 @@ 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 +283,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 +314,7 @@ applyrules(Client *c)
|
|||
&& (!r->class || strstr(class, r->class))
|
||||
&& (!r->instance || strstr(instance, r->instance)))
|
||||
{
|
||||
c->isterminal = r->isterminal;
|
||||
c->isfloating = r->isfloating;
|
||||
c->tags |= r->tags;
|
||||
for (m = mons; m && m->num != r->monitor; m = m->next);
|
||||
|
@ -422,6 +439,11 @@ attachBelow(Client *c)
|
|||
|
||||
}
|
||||
|
||||
void toggleAttachBelow()
|
||||
{
|
||||
attachbelow = !attachbelow;
|
||||
}
|
||||
|
||||
void
|
||||
attachstack(Client *c)
|
||||
{
|
||||
|
@ -429,6 +451,47 @@ attachstack(Client *c)
|
|||
c->mon->stack = c;
|
||||
}
|
||||
|
||||
void
|
||||
swallow(Client *p, Client *c)
|
||||
{
|
||||
if (c->noswallow || c->isterminal)
|
||||
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);
|
||||
arrange(p->mon);
|
||||
XMoveResizeWindow(dpy, p->win, p->x, p->y, p->w, p->h);
|
||||
configure(p);
|
||||
updateclientlist();
|
||||
}
|
||||
|
||||
void
|
||||
unswallow(Client *c)
|
||||
{
|
||||
c->win = c->swallowing->win;
|
||||
|
||||
free(c->swallowing);
|
||||
c->swallowing = NULL;
|
||||
|
||||
updatetitle(c);
|
||||
arrange(c->mon);
|
||||
XMapWindow(dpy, c->win);
|
||||
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||
configure(c);
|
||||
setclientstate(c, NormalState);
|
||||
}
|
||||
|
||||
void
|
||||
buttonpress(XEvent *e)
|
||||
{
|
||||
|
@ -537,7 +600,7 @@ clientmessage(XEvent *e)
|
|||
if (cme->data.l[1] == netatom[NetWMFullscreen]
|
||||
|| cme->data.l[2] == netatom[NetWMFullscreen])
|
||||
setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
|
||||
|| (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
|
||||
|| cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */));
|
||||
} else if (cme->message_type == netatom[NetActiveWindow]) {
|
||||
if (c != selmon->sel && !c->isurgent)
|
||||
seturgent(c, 1);
|
||||
|
@ -567,7 +630,6 @@ void
|
|||
configurenotify(XEvent *e)
|
||||
{
|
||||
Monitor *m;
|
||||
Client *c;
|
||||
XConfigureEvent *ev = &e->xconfigure;
|
||||
int dirty;
|
||||
|
||||
|
@ -580,9 +642,6 @@ configurenotify(XEvent *e)
|
|||
drw_resize(drw, sw, bh);
|
||||
updatebars();
|
||||
for (m = mons; m; m = m->next) {
|
||||
for (c = m->clients; c; c = c->next)
|
||||
if (c->isfullscreen)
|
||||
resizeclient(c, m->mx, m->my, m->mw, m->mh);
|
||||
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
|
||||
}
|
||||
focus(NULL);
|
||||
|
@ -668,6 +727,9 @@ destroynotify(XEvent *e)
|
|||
|
||||
if ((c = wintoclient(ev->window)))
|
||||
unmanage(c, 1);
|
||||
|
||||
else if ((c = swallowingclient(ev->window)))
|
||||
unmanage(c->swallowing, 1);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1033,12 +1095,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;
|
||||
|
@ -1053,6 +1116,7 @@ manage(Window w, XWindowAttributes *wa)
|
|||
} else {
|
||||
c->mon = selmon;
|
||||
applyrules(c);
|
||||
term = termforwin(c);
|
||||
}
|
||||
|
||||
if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
|
||||
|
@ -1092,6 +1156,8 @@ manage(Window w, XWindowAttributes *wa)
|
|||
c->mon->sel = c;
|
||||
arrange(c->mon);
|
||||
XMapWindow(dpy, c->win);
|
||||
if (term)
|
||||
swallow(term, c);
|
||||
focus(NULL);
|
||||
}
|
||||
|
||||
|
@ -1162,8 +1228,6 @@ movemouse(const Arg *arg)
|
|||
|
||||
if (!(c = selmon->sel))
|
||||
return;
|
||||
if (c->isfullscreen) /* no support moving fullscreen windows by mouse */
|
||||
return;
|
||||
restack(selmon);
|
||||
ocx = c->x;
|
||||
ocy = c->y;
|
||||
|
@ -1317,8 +1381,6 @@ resizemouse(const Arg *arg)
|
|||
|
||||
if (!(c = selmon->sel))
|
||||
return;
|
||||
if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
|
||||
return;
|
||||
restack(selmon);
|
||||
ocx = c->x;
|
||||
ocy = c->y;
|
||||
|
@ -1498,24 +1560,10 @@ setfullscreen(Client *c, int fullscreen)
|
|||
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
|
||||
c->isfullscreen = 1;
|
||||
c->oldstate = c->isfloating;
|
||||
c->oldbw = c->bw;
|
||||
c->bw = 0;
|
||||
c->isfloating = 1;
|
||||
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
|
||||
XRaiseWindow(dpy, c->win);
|
||||
} else if (!fullscreen && c->isfullscreen){
|
||||
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char*)0, 0);
|
||||
c->isfullscreen = 0;
|
||||
c->isfloating = c->oldstate;
|
||||
c->bw = c->oldbw;
|
||||
c->x = c->oldx;
|
||||
c->y = c->oldy;
|
||||
c->w = c->oldw;
|
||||
c->h = c->oldh;
|
||||
resizeclient(c, c->x, c->y, c->w, c->h);
|
||||
arrange(c->mon);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1640,7 +1688,7 @@ showhide(Client *c)
|
|||
if (ISVISIBLE(c)) {
|
||||
/* show clients top down */
|
||||
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)
|
||||
resize(c, c->x, c->y, c->w, c->h, 0);
|
||||
showhide(c->snext);
|
||||
} else {
|
||||
|
@ -1732,8 +1780,6 @@ togglefloating(const Arg *arg)
|
|||
{
|
||||
if (!selmon->sel)
|
||||
return;
|
||||
if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
|
||||
return;
|
||||
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
|
||||
if (selmon->sel->isfloating)
|
||||
resize(selmon->sel, selmon->sel->x, selmon->sel->y,
|
||||
|
@ -1787,6 +1833,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) {
|
||||
|
@ -1801,9 +1861,12 @@ unmanage(Client *c, int destroyed)
|
|||
XUngrabServer(dpy);
|
||||
}
|
||||
free(c);
|
||||
focus(NULL);
|
||||
updateclientlist();
|
||||
arrange(m);
|
||||
|
||||
if (!s) {
|
||||
arrange(m);
|
||||
focus(NULL);
|
||||
updateclientlist();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2069,6 +2132,103 @@ view(const Arg *arg)
|
|||
arrange(selmon);
|
||||
}
|
||||
|
||||
pid_t
|
||||
winpid(Window w)
|
||||
{
|
||||
pid_t result = 0;
|
||||
|
||||
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;
|
||||
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__ */
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -2160,6 +2320,8 @@ 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__
|
||||
|
|
66
fibonacci.c
Normal file
66
fibonacci.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
void
|
||||
fibonacci(Monitor *mon, int s) {
|
||||
unsigned int i, n, nx, ny, nw, nh;
|
||||
Client *c;
|
||||
|
||||
for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++);
|
||||
if(n == 0)
|
||||
return;
|
||||
|
||||
nx = mon->wx;
|
||||
ny = 0;
|
||||
nw = mon->ww;
|
||||
nh = mon->wh;
|
||||
|
||||
for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) {
|
||||
if((i % 2 && nh / 2 > 2 * c->bw)
|
||||
|| (!(i % 2) && nw / 2 > 2 * c->bw)) {
|
||||
if(i < n - 1) {
|
||||
if(i % 2)
|
||||
nh /= 2;
|
||||
else
|
||||
nw /= 2;
|
||||
if((i % 4) == 2 && !s)
|
||||
nx += nw;
|
||||
else if((i % 4) == 3 && !s)
|
||||
ny += nh;
|
||||
}
|
||||
if((i % 4) == 0) {
|
||||
if(s)
|
||||
ny += nh;
|
||||
else
|
||||
ny -= nh;
|
||||
}
|
||||
else if((i % 4) == 1)
|
||||
nx += nw;
|
||||
else if((i % 4) == 2)
|
||||
ny += nh;
|
||||
else if((i % 4) == 3) {
|
||||
if(s)
|
||||
nx += nw;
|
||||
else
|
||||
nx -= nw;
|
||||
}
|
||||
if(i == 0)
|
||||
{
|
||||
if(n != 1)
|
||||
nw = mon->ww * mon->mfact;
|
||||
ny = mon->wy;
|
||||
}
|
||||
else if(i == 1)
|
||||
nw = mon->ww - nw;
|
||||
i++;
|
||||
}
|
||||
resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dwindle(Monitor *mon) {
|
||||
fibonacci(mon, 1);
|
||||
}
|
||||
|
||||
void
|
||||
spiral(Monitor *mon) {
|
||||
fibonacci(mon, 0);
|
||||
}
|
49
movestack.c
Normal file
49
movestack.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
74
tcl.c
Normal file
74
tcl.c
Normal file
|
@ -0,0 +1,74 @@
|
|||
void
|
||||
tcl(Monitor * m)
|
||||
{
|
||||
int x, y, h, w, mw, sw, bdw;
|
||||
unsigned int i, n;
|
||||
Client * c;
|
||||
|
||||
for (n = 0, c = nexttiled(m->clients); c;
|
||||
c = nexttiled(c->next), n++);
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
c = nexttiled(m->clients);
|
||||
|
||||
mw = m->mfact * m->ww;
|
||||
sw = (m->ww - mw) / 2;
|
||||
bdw = (2 * c->bw);
|
||||
resize(c,
|
||||
n < 3 ? m->wx : m->wx + sw,
|
||||
m->wy,
|
||||
n == 1 ? m->ww - bdw : mw - bdw,
|
||||
m->wh - bdw,
|
||||
False);
|
||||
|
||||
if (--n == 0)
|
||||
return;
|
||||
|
||||
w = (m->ww - mw) / ((n > 1) + 1);
|
||||
c = nexttiled(c->next);
|
||||
|
||||
if (n > 1)
|
||||
{
|
||||
x = m->wx + ((n > 1) ? mw + sw : mw);
|
||||
y = m->wy;
|
||||
h = m->wh / (n / 2);
|
||||
|
||||
if (h < bh)
|
||||
h = m->wh;
|
||||
|
||||
for (i = 0; c && i < n / 2; c = nexttiled(c->next), i++)
|
||||
{
|
||||
resize(c,
|
||||
x,
|
||||
y,
|
||||
w - bdw,
|
||||
(i + 1 == n / 2) ? m->wy + m->wh - y - bdw : h - bdw,
|
||||
False);
|
||||
|
||||
if (h != m->wh)
|
||||
y = c->y + HEIGHT(c);
|
||||
}
|
||||
}
|
||||
|
||||
x = (n + 1 / 2) == 1 ? mw : m->wx;
|
||||
y = m->wy;
|
||||
h = m->wh / ((n + 1) / 2);
|
||||
|
||||
if (h < bh)
|
||||
h = m->wh;
|
||||
|
||||
for (i = 0; c; c = nexttiled(c->next), i++)
|
||||
{
|
||||
resize(c,
|
||||
x,
|
||||
y,
|
||||
(i + 1 == (n + 1) / 2) ? w - bdw : w - bdw,
|
||||
(i + 1 == (n + 1) / 2) ? m->wy + m->wh - y - bdw : h - bdw,
|
||||
False);
|
||||
|
||||
if (h != m->wh)
|
||||
y = c->y + HEIGHT(c);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue