Compare commits
5 Commits
8930e62c70
...
8bdf86d786
| Author | SHA1 | Date |
|---|---|---|
|
|
8bdf86d786 | |
|
|
6e35858434 | |
|
|
17942b75cc | |
|
|
4a31bdbc63 | |
|
|
c929eb93f8 |
83
config.def.h
83
config.def.h
|
|
@ -1,25 +1,34 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
/* appearance */
|
||||
static unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static unsigned int snap = 32; /* snap pixel */
|
||||
static int showbar = 1; /* 0 means no bar */
|
||||
static int topbar = 1; /* 0 means bottom bar */
|
||||
static const char *fonts[] = { "monospace:size=10" };
|
||||
static const char dmenufont[] = "monospace:size=10";
|
||||
/*
|
||||
* Appearance
|
||||
*/
|
||||
static unsigned int snap = 32; /* snap pixel */
|
||||
static char *fonts[] = { "monospace:size=14" };
|
||||
static unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static char normbgcolor[] = "#222222";
|
||||
static char normbordercolor[] = "#444444";
|
||||
static char normfgcolor[] = "#bbbbbb";
|
||||
static char selfgcolor[] = "#eeeeee";
|
||||
static char selbordercolor[] = "#005577";
|
||||
static char selbgcolor[] = "#005577";
|
||||
|
||||
/* color schemes */
|
||||
static char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
|
||||
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
/*
|
||||
* Bar configuration
|
||||
*/
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
|
||||
/*
|
||||
* Tagging
|
||||
*/
|
||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
||||
static const Rule rules[] = {
|
||||
|
|
@ -32,10 +41,12 @@ static const Rule rules[] = {
|
|||
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
static float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||
static int nmaster = 1; /* number of clients in master area */
|
||||
static int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||
/*
|
||||
* Layout(s)
|
||||
*/
|
||||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||
static const int nmaster = 1; /* number of clients in master area */
|
||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||
|
||||
static const Layout layouts[] = {
|
||||
|
|
@ -45,7 +56,9 @@ static const Layout layouts[] = {
|
|||
{ "[M]", monocle },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
/*
|
||||
* Key definitions
|
||||
*/
|
||||
#define MODKEY Mod1Mask
|
||||
#define TAGKEYS(KEY,TAG) \
|
||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
|
|
@ -55,12 +68,6 @@ static const Layout layouts[] = {
|
|||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
||||
/* commands */
|
||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
||||
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL };
|
||||
static const char *termcmd[] = { "st", NULL };
|
||||
|
||||
/*
|
||||
* Xresources preferences to load at startup
|
||||
*/
|
||||
|
|
@ -72,39 +79,52 @@ ResourcePref resources[] = {
|
|||
{ "selbordercolor", STRING, &selbordercolor },
|
||||
{ "selfgcolor", STRING, &selfgcolor },
|
||||
{ "borderpx", INTEGER, &borderpx },
|
||||
{ "snap", INTEGER, &snap },
|
||||
{ "showbar", INTEGER, &showbar },
|
||||
{ "topbar", INTEGER, &topbar },
|
||||
{ "nmaster", INTEGER, &nmaster },
|
||||
{ "resizehints", INTEGER, &resizehints },
|
||||
{ "mfact", FLOAT, &mfact },
|
||||
};
|
||||
|
||||
/*
|
||||
* Commands
|
||||
*/
|
||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
||||
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, NULL };
|
||||
static const char *termcmd[] = { "st", NULL };
|
||||
|
||||
|
||||
static Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
|
||||
/* spawn programs */
|
||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||
|
||||
/* window manager controls */
|
||||
{ MODKEY, XK_b, togglebar, {0} },
|
||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY, XK_Return, zoom, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
|
||||
/* window management */
|
||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
{ MODKEY, XK_Return, zoom, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||
|
||||
/* monitor navigation */
|
||||
{ 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 } },
|
||||
|
||||
/* tags */
|
||||
TAGKEYS( XK_1, 0)
|
||||
TAGKEYS( XK_2, 1)
|
||||
TAGKEYS( XK_3, 2)
|
||||
|
|
@ -114,7 +134,6 @@ static Key keys[] = {
|
|||
TAGKEYS( XK_7, 6)
|
||||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
|
|
|
|||
4
drw.c
4
drw.c
|
|
@ -154,7 +154,7 @@ xfont_free(Fnt *font)
|
|||
}
|
||||
|
||||
Fnt*
|
||||
drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
|
||||
drw_fontset_create(Drw* drw, char *fonts[], size_t fontcount)
|
||||
{
|
||||
Fnt *cur, *ret = NULL;
|
||||
size_t i;
|
||||
|
|
@ -190,6 +190,8 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
|||
DefaultColormap(drw->dpy, drw->screen),
|
||||
clrname, dest))
|
||||
die("error, cannot allocate color '%s'", clrname);
|
||||
|
||||
dest->pixel |= 0xff << 24;
|
||||
}
|
||||
|
||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||
|
|
|
|||
3
drw.h
3
drw.h
|
|
@ -32,7 +32,8 @@ void drw_resize(Drw *drw, unsigned int w, unsigned int h);
|
|||
void drw_free(Drw *drw);
|
||||
|
||||
/* Fnt abstraction */
|
||||
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
|
||||
Fnt *drw_fontset_create(Drw* drw, char *fonts[], size_t fontcount);
|
||||
|
||||
void drw_fontset_free(Fnt* set);
|
||||
unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
|
||||
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);
|
||||
|
|
|
|||
243
dwm.c
243
dwm.c
|
|
@ -51,7 +51,7 @@
|
|||
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
||||
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
||||
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||
#define ISVISIBLE(C, M) ((C->tags & M->tagset[M->seltags]))
|
||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||
|
|
@ -64,7 +64,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
|||
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
NetWMWindowTypeDialog, NetClientList, NetClientInfo, NetLast }; /* EWMH atoms */
|
||||
NetWMWindowTypeDialog, NetClientList, NetClientListStacking, NetClientInfo, NetLast }; /* EWMH atoms */
|
||||
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
||||
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
||||
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
||||
|
|
@ -84,6 +84,7 @@ typedef struct {
|
|||
const Arg arg;
|
||||
} Button;
|
||||
|
||||
typedef struct Clientlist Clientlist;
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct Client Client;
|
||||
struct Client {
|
||||
|
|
@ -127,9 +128,8 @@ struct Monitor {
|
|||
unsigned int tagset[2];
|
||||
int showbar;
|
||||
int topbar;
|
||||
Client *clients;
|
||||
Clientlist *cl;
|
||||
Client *sel;
|
||||
Client *stack;
|
||||
Monitor *next;
|
||||
Window barwin;
|
||||
const Layout *lt[2];
|
||||
|
|
@ -158,12 +158,18 @@ typedef struct {
|
|||
void *dst;
|
||||
} ResourcePref;
|
||||
|
||||
struct Clientlist {
|
||||
Client *clients;
|
||||
Client *stack;
|
||||
};
|
||||
|
||||
/* function declarations */
|
||||
static void applyrules(Client *c);
|
||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||
static void arrange(Monitor *m);
|
||||
static void arrangemon(Monitor *m);
|
||||
static void attach(Client *c);
|
||||
static void attachclients(Monitor *m);
|
||||
static void attachstack(Client *c);
|
||||
static void buttonpress(XEvent *e);
|
||||
static void checkotherwm(void);
|
||||
|
|
@ -201,7 +207,7 @@ static void maprequest(XEvent *e);
|
|||
static void monocle(Monitor *m);
|
||||
static void motionnotify(XEvent *e);
|
||||
static void movemouse(const Arg *arg);
|
||||
static Client *nexttiled(Client *c);
|
||||
static Client *nexttiled(Client *c, Monitor *m);
|
||||
static void pop(Client *c);
|
||||
static void propertynotify(XEvent *e);
|
||||
static void quit(const Arg *arg);
|
||||
|
|
@ -295,6 +301,7 @@ static Display *dpy;
|
|||
static Drw *drw;
|
||||
static Monitor *mons, *selmon;
|
||||
static Window root, wmcheckwin;
|
||||
static Clientlist *cl;
|
||||
|
||||
/* configuration, allows nested code to access above variables */
|
||||
#include "config.h"
|
||||
|
|
@ -336,7 +343,7 @@ applyrules(Client *c)
|
|||
{
|
||||
c->isfloating = r->isfloating;
|
||||
c->tags |= r->tags;
|
||||
for (m = mons; m && m->num != r->monitor; m = m->next);
|
||||
for (m = mons; m && (m->tagset[m->seltags] & c->tags) == 0; m = m->next);
|
||||
if (m)
|
||||
c->mon = m;
|
||||
}
|
||||
|
|
@ -420,9 +427,9 @@ void
|
|||
arrange(Monitor *m)
|
||||
{
|
||||
if (m)
|
||||
showhide(m->stack);
|
||||
showhide(m->cl->stack);
|
||||
else for (m = mons; m; m = m->next)
|
||||
showhide(m->stack);
|
||||
showhide(m->cl->stack);
|
||||
if (m) {
|
||||
arrangemon(m);
|
||||
restack(m);
|
||||
|
|
@ -441,15 +448,49 @@ arrangemon(Monitor *m)
|
|||
void
|
||||
attach(Client *c)
|
||||
{
|
||||
c->next = c->mon->clients;
|
||||
c->mon->clients = c;
|
||||
c->next = c->mon->cl->clients;
|
||||
c->mon->cl->clients = c;
|
||||
}
|
||||
|
||||
void
|
||||
attachclients(Monitor *m) {
|
||||
/* attach clients to the specified monitor */
|
||||
Monitor *tm;
|
||||
Client *c;
|
||||
unsigned int utags = 0;
|
||||
Bool rmons = False;
|
||||
if(!m)
|
||||
return;
|
||||
|
||||
/* collect information about the tags in use */
|
||||
for (tm = mons; tm; tm = tm->next)
|
||||
if(tm != m)
|
||||
utags |= tm->tagset[tm->seltags];
|
||||
|
||||
for (c = m->cl->clients; c; c = c->next)
|
||||
if(ISVISIBLE(c, m)) {
|
||||
/* if client is also visible on other tags that are displayed on
|
||||
* other monitors, remove these tags */
|
||||
if(c->tags & utags) {
|
||||
c->tags = c->tags & m->tagset[m->seltags];
|
||||
rmons = True;
|
||||
}
|
||||
unfocus(c, True);
|
||||
c->mon = m;
|
||||
}
|
||||
|
||||
if (rmons)
|
||||
for (tm = mons; tm; tm = tm->next)
|
||||
if(tm != m)
|
||||
arrange(tm);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
attachstack(Client *c)
|
||||
{
|
||||
c->snext = c->mon->stack;
|
||||
c->mon->stack = c;
|
||||
c->snext = c->mon->cl->stack;
|
||||
c->mon->cl->stack = c;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -470,9 +511,15 @@ buttonpress(XEvent *e)
|
|||
}
|
||||
if (ev->window == selmon->barwin) {
|
||||
i = x = 0;
|
||||
do
|
||||
unsigned int occ = 0;
|
||||
for(c = m->cl->clients; c; c=c->next)
|
||||
occ |= c->tags == TAGMASK ? 0 : c->tags;
|
||||
do {
|
||||
/* Do not reserve space for vacant tags */
|
||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||
continue;
|
||||
x += TEXTW(tags[i]);
|
||||
while (ev->x >= x && ++i < LENGTH(tags));
|
||||
} while (ev->x >= x && ++i < LENGTH(tags));
|
||||
if (i < LENGTH(tags)) {
|
||||
click = ClkTagBar;
|
||||
arg.ui = 1 << i;
|
||||
|
|
@ -516,8 +563,8 @@ cleanup(void)
|
|||
view(&a);
|
||||
selmon->lt[selmon->sellt] = &foo;
|
||||
for (m = mons; m; m = m->next)
|
||||
while (m->stack)
|
||||
unmanage(m->stack, 0);
|
||||
while (m->cl->stack)
|
||||
unmanage(m->cl->stack, 0);
|
||||
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||
while (mons)
|
||||
cleanupmon(mons);
|
||||
|
|
@ -604,7 +651,7 @@ configurenotify(XEvent *e)
|
|||
drw_resize(drw, sw, bh);
|
||||
updatebars();
|
||||
for (m = mons; m; m = m->next) {
|
||||
for (c = m->clients; c; c = c->next)
|
||||
for (c = m->cl->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);
|
||||
|
|
@ -650,7 +697,7 @@ configurerequest(XEvent *e)
|
|||
c->y = m->my + (m->mh / 2 - HEIGHT(c) / 2); /* center in y direction */
|
||||
if ((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
|
||||
configure(c);
|
||||
if (ISVISIBLE(c))
|
||||
if (ISVISIBLE(c, m))
|
||||
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||
} else
|
||||
configure(c);
|
||||
|
|
@ -670,11 +717,32 @@ configurerequest(XEvent *e)
|
|||
Monitor *
|
||||
createmon(void)
|
||||
{
|
||||
Monitor *m;
|
||||
Monitor *m, *tm;
|
||||
unsigned int i;
|
||||
|
||||
/* bail out if the number of monitors exceeds the number of tags */
|
||||
for (i=1, tm=mons; tm; i++, tm=tm->next);
|
||||
if (i > LENGTH(tags)) {
|
||||
fprintf(stderr, "dwm: failed to add monitor, number of tags exceeded\n");
|
||||
return NULL;
|
||||
}
|
||||
/* find the first tag that isn't in use */
|
||||
for (i=0; i < LENGTH(tags); i++) {
|
||||
for (tm=mons; tm && !(tm->tagset[tm->seltags] & (1<<i)); tm=tm->next);
|
||||
if (!tm)
|
||||
break;
|
||||
}
|
||||
/* reassign all tags to monitors since there's currently no free tag for the
|
||||
* new monitor */
|
||||
if (i >= LENGTH(tags))
|
||||
for (i=0, tm=mons; tm; tm=tm->next, i++) {
|
||||
tm->seltags ^= 1;
|
||||
tm->tagset[tm->seltags] = (1<<i) & TAGMASK;
|
||||
}
|
||||
|
||||
m = ecalloc(1, sizeof(Monitor));
|
||||
m->tagset[0] = m->tagset[1] = 1;
|
||||
m->cl = cl;
|
||||
m->tagset[0] = m->tagset[1] = (1<<i) & TAGMASK;
|
||||
m->mfact = mfact;
|
||||
m->nmaster = nmaster;
|
||||
m->showbar = showbar;
|
||||
|
|
@ -714,7 +782,7 @@ detach(Client *c)
|
|||
{
|
||||
Client **tc;
|
||||
|
||||
for (tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next);
|
||||
for (tc = &c->mon->cl->clients; *tc && *tc != c; tc = &(*tc)->next);
|
||||
*tc = c->next;
|
||||
}
|
||||
|
||||
|
|
@ -723,11 +791,11 @@ detachstack(Client *c)
|
|||
{
|
||||
Client **tc, *t;
|
||||
|
||||
for (tc = &c->mon->stack; *tc && *tc != c; tc = &(*tc)->snext);
|
||||
for (tc = &c->mon->cl->stack; *tc && *tc != c; tc = &(*tc)->snext);
|
||||
*tc = c->snext;
|
||||
|
||||
if (c == c->mon->sel) {
|
||||
for (t = c->mon->stack; t && !ISVISIBLE(t); t = t->snext);
|
||||
for (t = c->mon->cl->stack; t && !ISVISIBLE(t, c->mon); t = t->snext);
|
||||
c->mon->sel = t;
|
||||
}
|
||||
}
|
||||
|
|
@ -751,8 +819,6 @@ void
|
|||
drawbar(Monitor *m)
|
||||
{
|
||||
int x, w, tw = 0;
|
||||
int boxs = drw->fonts->h / 9;
|
||||
int boxw = drw->fonts->h / 6 + 2;
|
||||
unsigned int i, occ = 0, urg = 0;
|
||||
Client *c;
|
||||
|
||||
|
|
@ -766,20 +832,19 @@ drawbar(Monitor *m)
|
|||
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||
}
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
occ |= c->tags;
|
||||
for (c = m->cl->clients; c; c = c->next) {
|
||||
occ |= c->tags == TAGMASK ? 0 : c->tags;
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
}
|
||||
x = 0;
|
||||
for (i = 0; i < LENGTH(tags); i++) {
|
||||
/* Do not draw vacant tags */
|
||||
if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||
continue;
|
||||
w = TEXTW(tags[i]);
|
||||
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);
|
||||
x += w;
|
||||
}
|
||||
w = TEXTW(m->ltsymbol);
|
||||
|
|
@ -841,8 +906,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, selmon))
|
||||
for (c = selmon->cl->stack; c && !ISVISIBLE(c, selmon); c = c->snext);
|
||||
if (selmon->sel && selmon->sel != c)
|
||||
unfocus(selmon->sel, 0);
|
||||
if (c) {
|
||||
|
|
@ -895,16 +960,16 @@ focusstack(const Arg *arg)
|
|||
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
||||
return;
|
||||
if (arg->i > 0) {
|
||||
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
|
||||
for (c = selmon->sel->next; c && !ISVISIBLE(c, selmon); c = c->next);
|
||||
if (!c)
|
||||
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
|
||||
for (c = selmon->cl->clients; c && !ISVISIBLE(c, selmon); c = c->next);
|
||||
} else {
|
||||
for (i = selmon->clients; i != selmon->sel; i = i->next)
|
||||
if (ISVISIBLE(i))
|
||||
for (i = selmon->cl->clients; i != selmon->sel; i = i->next)
|
||||
if (ISVISIBLE(i, selmon))
|
||||
c = i;
|
||||
if (!c)
|
||||
for (; i; i = i->next)
|
||||
if (ISVISIBLE(i))
|
||||
if (ISVISIBLE(i, selmon))
|
||||
c = i;
|
||||
}
|
||||
if (c) {
|
||||
|
|
@ -1150,6 +1215,8 @@ manage(Window w, XWindowAttributes *wa)
|
|||
attachstack(c);
|
||||
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
|
||||
(unsigned char *) &(c->win), 1);
|
||||
XChangeProperty(dpy, root, netatom[NetClientListStacking], XA_WINDOW, 32, PropModePrepend,
|
||||
(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 (c->mon == selmon)
|
||||
|
|
@ -1188,12 +1255,12 @@ monocle(Monitor *m)
|
|||
unsigned int n = 0;
|
||||
Client *c;
|
||||
|
||||
for (c = m->clients; c; c = c->next)
|
||||
if (ISVISIBLE(c))
|
||||
for (c = m->cl->clients; c; c = c->next)
|
||||
if (ISVISIBLE(c, m))
|
||||
n++;
|
||||
if (n > 0) /* override layout symbol */
|
||||
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
|
||||
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
|
||||
for (c = nexttiled(m->cl->clients, m); c; c = nexttiled(c->next, m))
|
||||
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
||||
}
|
||||
|
||||
|
|
@ -1275,9 +1342,9 @@ movemouse(const Arg *arg)
|
|||
}
|
||||
|
||||
Client *
|
||||
nexttiled(Client *c)
|
||||
nexttiled(Client *c, Monitor *m)
|
||||
{
|
||||
for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
|
||||
for (; c && (c->isfloating || !ISVISIBLE(c, m)); c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
@ -1441,8 +1508,8 @@ restack(Monitor *m)
|
|||
if (m->lt[m->sellt]->arrange) {
|
||||
wc.stack_mode = Below;
|
||||
wc.sibling = m->barwin;
|
||||
for (c = m->stack; c; c = c->snext)
|
||||
if (!c->isfloating && ISVISIBLE(c)) {
|
||||
for (c = m->cl->stack; c; c = c->snext)
|
||||
if (!c->isfloating && ISVISIBLE(c, m)) {
|
||||
XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
|
||||
wc.sibling = c->win;
|
||||
}
|
||||
|
|
@ -1572,11 +1639,9 @@ sendmon(Client *c, Monitor *m)
|
|||
if (c->mon == m)
|
||||
return;
|
||||
unfocus(c, 1);
|
||||
detach(c);
|
||||
detachstack(c);
|
||||
c->mon = m;
|
||||
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||
attach(c);
|
||||
attachstack(c);
|
||||
setclienttagprop(c);
|
||||
focus(NULL);
|
||||
|
|
@ -1707,6 +1772,8 @@ setup(void)
|
|||
screen = DefaultScreen(dpy);
|
||||
sw = DisplayWidth(dpy, screen);
|
||||
sh = DisplayHeight(dpy, screen);
|
||||
if(!(cl = (Clientlist *)calloc(1, sizeof(Clientlist))))
|
||||
die("fatal: could not malloc() %u bytes\n", sizeof(Clientlist));
|
||||
root = RootWindow(dpy, screen);
|
||||
drw = drw_create(dpy, screen, root, sw, sh);
|
||||
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
||||
|
|
@ -1730,6 +1797,7 @@ setup(void)
|
|||
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
||||
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
|
||||
netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False);
|
||||
netatom[NetClientListStacking] = XInternAtom(dpy, "_NET_CLIENT_LIST_STACKING", False);
|
||||
/* init cursors */
|
||||
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
|
||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||
|
|
@ -1754,6 +1822,7 @@ setup(void)
|
|||
PropModeReplace, (unsigned char *) netatom, NetLast);
|
||||
XDeleteProperty(dpy, root, netatom[NetClientList]);
|
||||
XDeleteProperty(dpy, root, netatom[NetClientInfo]);
|
||||
XDeleteProperty(dpy, root, netatom[NetClientListStacking]);
|
||||
/* select events */
|
||||
wa.cursor = cursor[CurNormal]->cursor;
|
||||
wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
|
||||
|
|
@ -1783,7 +1852,7 @@ showhide(Client *c)
|
|||
{
|
||||
if (!c)
|
||||
return;
|
||||
if (ISVISIBLE(c)) {
|
||||
if (ISVISIBLE(c, c->mon)) {
|
||||
/* show clients top down */
|
||||
window_map(dpy, c, 1);
|
||||
showhide(c->snext);
|
||||
|
|
@ -1827,8 +1896,26 @@ setclienttagprop(Client *c)
|
|||
void
|
||||
tag(const Arg *arg)
|
||||
{
|
||||
Monitor *m;
|
||||
unsigned int newtags;
|
||||
Client *c;
|
||||
|
||||
if (selmon->sel && arg->ui & TAGMASK) {
|
||||
newtags = arg->ui & TAGMASK;
|
||||
for (m = mons; m; m = m->next)
|
||||
/* if tag is visible on another monitor, move client to the new monitor */
|
||||
if (m != selmon && m->tagset[m->seltags] & newtags) {
|
||||
/* prevent moving client to all tags (MODKEY-Shift-0) when multiple monitors are connected */
|
||||
if(newtags & selmon->tagset[selmon->seltags])
|
||||
return;
|
||||
selmon->sel->tags = newtags;
|
||||
selmon->sel->mon = m;
|
||||
arrange(m);
|
||||
break;
|
||||
}
|
||||
/* workaround in case just one monitor is connected */
|
||||
|
||||
|
||||
c = selmon->sel;
|
||||
selmon->sel->tags = arg->ui & TAGMASK;
|
||||
setclienttagprop(c);
|
||||
|
|
@ -1851,7 +1938,7 @@ tile(Monitor *m)
|
|||
unsigned int i, n, h, mw, my, ty;
|
||||
Client *c;
|
||||
|
||||
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||
for (n = 0, c = nexttiled(m->cl->clients, m); c; c = nexttiled(c->next, m), n++);
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
|
|
@ -1859,7 +1946,7 @@ tile(Monitor *m)
|
|||
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++)
|
||||
for (i = my = ty = 0, c = nexttiled(m->cl->clients, m); c; c = nexttiled(c->next, m), 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);
|
||||
|
|
@ -1899,12 +1986,17 @@ togglefloating(const Arg *arg)
|
|||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
Monitor *m;
|
||||
unsigned int newtags;
|
||||
|
||||
if (!selmon->sel)
|
||||
return;
|
||||
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
|
||||
if (newtags) {
|
||||
/* prevent adding tags that are in use on other monitors */
|
||||
for (m = mons; m; m = m->next)
|
||||
if (m != selmon && newtags & m->tagset[m->seltags])
|
||||
return;
|
||||
selmon->sel->tags = newtags;
|
||||
setclienttagprop(selmon->sel);
|
||||
focus(NULL);
|
||||
|
|
@ -2044,10 +2136,17 @@ updateclientlist()
|
|||
|
||||
XDeleteProperty(dpy, root, netatom[NetClientList]);
|
||||
for (m = mons; m; m = m->next)
|
||||
for (c = m->clients; c; c = c->next)
|
||||
for (c = m->cl->clients; c; c = c->next)
|
||||
XChangeProperty(dpy, root, netatom[NetClientList],
|
||||
XA_WINDOW, 32, PropModeAppend,
|
||||
(unsigned char *) &(c->win), 1);
|
||||
|
||||
XDeleteProperty(dpy, root, netatom[NetClientListStacking]);
|
||||
for (m = mons; m; m = m->next)
|
||||
for (c = m->cl->stack; c; c = c->snext)
|
||||
XChangeProperty(dpy, root, netatom[NetClientListStacking],
|
||||
XA_WINDOW, 32, PropModeAppend,
|
||||
(unsigned char *) &(c->win), 1);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -2075,8 +2174,10 @@ updategeom(void)
|
|||
/* new monitors if nn > n */
|
||||
for (i = n; i < nn; i++) {
|
||||
for (m = mons; m && m->next; m = m->next);
|
||||
if (m)
|
||||
if (m) {
|
||||
m->next = createmon();
|
||||
attachclients(m->next);
|
||||
}
|
||||
else
|
||||
mons = createmon();
|
||||
}
|
||||
|
|
@ -2096,16 +2197,13 @@ updategeom(void)
|
|||
/* removed monitors if n > nn */
|
||||
for (i = nn; i < n; i++) {
|
||||
for (m = mons; m && m->next; m = m->next);
|
||||
while ((c = m->clients)) {
|
||||
dirty = 1;
|
||||
m->clients = c->next;
|
||||
detachstack(c);
|
||||
c->mon = mons;
|
||||
attach(c);
|
||||
attachstack(c);
|
||||
}
|
||||
if (m == selmon)
|
||||
selmon = mons;
|
||||
for (c = m->cl->clients; c; c = c->next) {
|
||||
dirty = True;
|
||||
if (c->mon == m)
|
||||
c->mon = selmon;
|
||||
}
|
||||
cleanupmon(m);
|
||||
}
|
||||
free(unique);
|
||||
|
|
@ -2284,11 +2382,29 @@ window_unmap(Display *dpy, Window win, Window root, int iconify)
|
|||
void
|
||||
view(const Arg *arg)
|
||||
{
|
||||
Monitor *m;
|
||||
unsigned int newtagset = selmon->tagset[selmon->seltags ^ 1];
|
||||
int i;
|
||||
unsigned int tmptag;
|
||||
|
||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||
return;
|
||||
/* swap tags when trying to display a tag from another monitor */
|
||||
if (arg->ui & TAGMASK)
|
||||
newtagset = arg->ui & TAGMASK;
|
||||
for (m = mons; m; m = m->next)
|
||||
if (m != selmon && newtagset & m->tagset[m->seltags]) {
|
||||
/* prevent displaying all tags (MODKEY-0) when multiple monitors
|
||||
* are connected */
|
||||
if (newtagset & selmon->tagset[selmon->seltags])
|
||||
return;
|
||||
m->sel = selmon->sel;
|
||||
m->seltags ^= 1;
|
||||
m->tagset[m->seltags] = selmon->tagset[selmon->seltags];
|
||||
attachclients(m);
|
||||
arrange(m);
|
||||
break;
|
||||
}
|
||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||
if (arg->ui & TAGMASK) {
|
||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
|
|
@ -2315,8 +2431,9 @@ view(const Arg *arg)
|
|||
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||
togglebar(NULL);
|
||||
|
||||
focus(NULL);
|
||||
attachclients(selmon);
|
||||
arrange(selmon);
|
||||
focus(NULL);
|
||||
}
|
||||
|
||||
Client *
|
||||
|
|
@ -2326,7 +2443,7 @@ wintoclient(Window w)
|
|||
Monitor *m;
|
||||
|
||||
for (m = mons; m; m = m->next)
|
||||
for (c = m->clients; c; c = c->next)
|
||||
for (c = m->cl->clients; c; c = c->next)
|
||||
if (c->win == w)
|
||||
return c;
|
||||
return NULL;
|
||||
|
|
@ -2392,7 +2509,7 @@ zoom(const Arg *arg)
|
|||
|
||||
if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating)
|
||||
return;
|
||||
if (c == nexttiled(selmon->clients) && !(c = nexttiled(c->next)))
|
||||
if (c == nexttiled(selmon->cl->clients, selmon) && !(c = nexttiled(c->next, selmon)))
|
||||
return;
|
||||
pop(c);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue