Compare commits
12 Commits
d2c66c146e
...
ea4b6f32ea
| Author | SHA1 | Date |
|---|---|---|
|
|
ea4b6f32ea | |
|
|
360d8aa7b9 | |
|
|
6850fb18a5 | |
|
|
2e1a993b8f | |
|
|
64bfc616c2 | |
|
|
43da1fc4ab | |
|
|
d5c53a94c7 | |
|
|
1a103f3fbf | |
|
|
fe4dc6622a | |
|
|
b39edf6b34 | |
|
|
ad63d3113a | |
|
|
80b5349ba7 |
110
config.def.h
110
config.def.h
|
|
@ -1,24 +1,36 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
static const char *fonts[] = { "monospace:size=10" };
|
||||
static const char dmenufont[] = "monospace:size=10";
|
||||
static const char col_gray1[] = "#222222";
|
||||
static const char col_gray2[] = "#444444";
|
||||
static const char col_gray3[] = "#bbbbbb";
|
||||
static const char col_gray4[] = "#eeeeee";
|
||||
static const char col_cyan[] = "#005577";
|
||||
static const char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
/*
|
||||
* 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 },
|
||||
[SchemeTabActive] = { selfgcolor, normbgcolor, selbordercolor },
|
||||
[SchemeTabInactive] = { normfgcolor, normbgcolor, normbordercolor }
|
||||
};
|
||||
|
||||
/* 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[] = {
|
||||
|
|
@ -31,12 +43,25 @@ static const Rule rules[] = {
|
|||
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
/*
|
||||
* 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 */
|
||||
|
||||
/*
|
||||
* Bartabgroups properties
|
||||
*/
|
||||
#define BARTAB_BORDERS 1 // 0 = off, 1 = on
|
||||
#define BARTAB_BOTTOMBORDER 1 // 0 = off, 1 = on
|
||||
#define BARTAB_TAGSINDICATOR 1 // 0 = off, 1 = on if >1 client/view tag, 2 = always on
|
||||
#define BARTAB_TAGSPX 5 // # pixels for tag grid boxes
|
||||
#define BARTAB_TAGSROWS 3 // # rows in tag grid (9 tags, e.g. 3x3)
|
||||
static void (*bartabmonfns[])(Monitor *) = { monocle /* , customlayoutfn */ };
|
||||
static void (*bartabfloatfns[])(Monitor *) = { NULL /* , customlayoutfn */ };
|
||||
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
{ "[]=", tile }, /* first entry is default */
|
||||
|
|
@ -44,7 +69,9 @@ static const Layout layouts[] = {
|
|||
{ "[M]", monocle },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
/*
|
||||
* Key definitions
|
||||
*/
|
||||
#define MODKEY Mod1Mask
|
||||
#define TAGKEYS(KEY,TAG) \
|
||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
|
|
@ -54,37 +81,63 @@ 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 } }
|
||||
/*
|
||||
* Xresources preferences to load at startup
|
||||
*/
|
||||
ResourcePref resources[] = {
|
||||
{ "normbgcolor", STRING, &normbgcolor },
|
||||
{ "normbordercolor", STRING, &normbordercolor },
|
||||
{ "normfgcolor", STRING, &normfgcolor },
|
||||
{ "selbgcolor", STRING, &selbgcolor },
|
||||
{ "selbordercolor", STRING, &selbordercolor },
|
||||
{ "selfgcolor", STRING, &selfgcolor },
|
||||
{ "borderpx", INTEGER, &borderpx },
|
||||
};
|
||||
|
||||
/* commands */
|
||||
/*
|
||||
* Commands
|
||||
*/
|
||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
||||
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, NULL };
|
||||
static const char *termcmd[] = { "st", NULL };
|
||||
|
||||
static const Key keys[] = {
|
||||
|
||||
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)
|
||||
|
|
@ -94,7 +147,6 @@ static const Key keys[] = {
|
|||
TAGKEYS( XK_7, 6)
|
||||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,195 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#include <X11/XF86keysym.h>
|
||||
|
||||
/*
|
||||
* Appearance
|
||||
*/
|
||||
static unsigned int snap = 32; /* snap pixel */
|
||||
static char *fonts[] = { "Iosevka Term: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 },
|
||||
[SchemeTabActive] = { selfgcolor, normbgcolor, selbordercolor },
|
||||
[SchemeTabInactive] = { normfgcolor, normbgcolor, normbordercolor }
|
||||
};
|
||||
|
||||
/*
|
||||
* 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[] = {
|
||||
/* xprop(1):
|
||||
* WM_CLASS(STRING) = instance, class
|
||||
* WM_NAME(STRING) = title
|
||||
*/
|
||||
/* class instance title tags mask isfloating monitor */
|
||||
{ "Emacs", NULL, NULL, 1 << 0, 0, -1 },
|
||||
{ "Firefox", NULL, NULL, 1 << 1, 0, -1 },
|
||||
{ "st", NULL, NULL, 1 << 2, 0, -1 },
|
||||
{ "Slack", NULL, NULL, 1 << 3, 0, -1 },
|
||||
{ "discord", NULL, NULL, 1 << 3, 0, -1 },
|
||||
{ "Signal", NULL, NULL, 1 << 3, 0, -1 },
|
||||
{ "Spotify", NULL, NULL, 1 << 4, 0, -1 },
|
||||
{ "vlc", NULL, NULL, 1 << 5, 0, -1 },
|
||||
{ "1Password", NULL, NULL, 1 << 6, 0, -1 },
|
||||
{ "Zoom", NULL, NULL, 0, 1, -1 },
|
||||
};
|
||||
|
||||
/*
|
||||
* Layout(s)
|
||||
*/
|
||||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||
static const int nmaster = 1; /* number of clients in master area */
|
||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||
|
||||
/*
|
||||
* Bartabgroups properties
|
||||
*/
|
||||
#define BARTAB_BORDERS 1 // 0 = off, 1 = on
|
||||
#define BARTAB_BOTTOMBORDER 0 // 0 = off, 1 = on
|
||||
#define BARTAB_TAGSINDICATOR 1 // 0 = off, 1 = on if >1 client/view tag, 2 = always on
|
||||
#define BARTAB_TAGSPX 5 // # pixels for tag grid boxes
|
||||
#define BARTAB_TAGSROWS 3 // # rows in tag grid (9 tags, e.g. 3x3)
|
||||
static void (*bartabmonfns[])(Monitor *) = { monocle /* , customlayoutfn */ };
|
||||
static void (*bartabfloatfns[])(Monitor *) = { NULL /* , customlayoutfn */ };
|
||||
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
{ "[]=", tile }, /* first entry is default */
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
};
|
||||
|
||||
/*
|
||||
* Xresources preferences to load at startup
|
||||
*/
|
||||
ResourcePref resources[] = {
|
||||
{ "normbgcolor", STRING, &normbgcolor },
|
||||
{ "normbordercolor", STRING, &normbordercolor },
|
||||
{ "normfgcolor", STRING, &normfgcolor },
|
||||
{ "selbgcolor", STRING, &selbgcolor },
|
||||
{ "selbordercolor", STRING, &selbordercolor },
|
||||
{ "selfgcolor", STRING, &selfgcolor },
|
||||
{ "borderpx", INTEGER, &borderpx },
|
||||
};
|
||||
|
||||
/*
|
||||
* Key definitions
|
||||
*/
|
||||
#define MODKEY Mod4Mask
|
||||
#define TAGKEYS(KEY,TAG) \
|
||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
||||
/* Commands */
|
||||
static 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_t, spawn, {.v = dmenucmd } },
|
||||
{ MODKEY, XK_a, spawn, {.v = termcmd } },
|
||||
{ MODKEY, XK_g, spawn, SHCMD("emacsclient -c") },
|
||||
{ MODKEY|ShiftMask, XK_g, spawn, SHCMD("emacs") },
|
||||
{ MODKEY, XK_s, spawn, SHCMD("pass-dmenu type") },
|
||||
{ MODKEY|ShiftMask, XK_S, spawn, SHCMD("pass-dmenu clip") },
|
||||
|
||||
/* window manager controls */
|
||||
{ MODKEY|ControlMask, XK_q, spawn, SHCMD("dmenu-sys") },
|
||||
{ MODKEY|ControlMask, XK_z, togglebar, {0} },
|
||||
{ MODKEY|ControlMask, XK_l, incnmaster, {.i = -1 } },
|
||||
{ MODKEY|ControlMask, XK_u, incnmaster, {.i = +1 } },
|
||||
{ MODKEY|ControlMask, XK_m, setmfact, {.f = -0.05} },
|
||||
{ MODKEY|ControlMask, XK_i, setmfact, {.f = +0.05} },
|
||||
{ MODKEY, XK_w, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_p, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
|
||||
|
||||
/* window management */
|
||||
{ MODKEY, XK_n, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_e, focusstack, {.i = -1 } },
|
||||
{ MODKEY, XK_m, zoom, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||
{ MODKEY, XK_x, togglefloating, {0} },
|
||||
{ MODKEY, XK_q, killclient, {0} },
|
||||
|
||||
/* monitor navigation */
|
||||
{ MODKEY, XK_comma, focusmon, {.i = +1 } },
|
||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = +1 } },
|
||||
|
||||
/* system managemment */
|
||||
{ 0, XF86XK_AudioMute, spawn, SHCMD("pamixer --toggle-mute") },
|
||||
{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pamixer -d 5") },
|
||||
{ ShiftMask, XF86XK_AudioLowerVolume, spawn, SHCMD("pamixer -d 10") },
|
||||
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pamixer -i 5") },
|
||||
{ ShiftMask, XF86XK_AudioRaiseVolume, spawn, SHCMD("pamixer -i 10") },
|
||||
{ 0, XF86XK_MonBrightnessUp, spawn, SHCMD("sudo light -A 5") },
|
||||
{ 0, XF86XK_MonBrightnessDown, spawn, SHCMD("sudo light -U 5") },
|
||||
{ 0, XF86XK_AudioPlay, spawn, SHCMD("playerctl play-pause") },
|
||||
{ 0, XF86XK_AudioNext, spawn, SHCMD("playerctl next") },
|
||||
{ 0, XF86XK_AudioPrev, spawn, SHCMD("playerctl previous") },
|
||||
{ 0, XF86XK_Display, spawn, SHCMD("autorandr --change") },
|
||||
|
||||
/* tags */
|
||||
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)
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||
static const Button buttons[] = {
|
||||
/* click event mask button function argument */
|
||||
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||
{ ClkTagBar, 0, Button1, view, {0} },
|
||||
{ ClkTagBar, 0, Button3, toggleview, {0} },
|
||||
{ ClkTagBar, MODKEY, Button1, tag, {0} },
|
||||
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
|
||||
};
|
||||
|
||||
6
drw.c
6
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,12 +190,14 @@ 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
|
||||
* returned color scheme when done using it. */
|
||||
Clr *
|
||||
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||
drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount)
|
||||
{
|
||||
size_t i;
|
||||
Clr *ret;
|
||||
|
|
|
|||
5
drw.h
5
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);
|
||||
|
|
@ -40,7 +41,7 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
|
|||
|
||||
/* Colorscheme abstraction */
|
||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||
Clr *drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount);
|
||||
|
||||
/* Cursor abstraction */
|
||||
Cur *drw_cur_create(Drw *drw, int shape);
|
||||
|
|
|
|||
536
dwm.c
536
dwm.c
|
|
@ -37,6 +37,7 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xresource.h>
|
||||
#ifdef XINERAMA
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif /* XINERAMA */
|
||||
|
|
@ -50,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)
|
||||
|
|
@ -60,7 +61,7 @@
|
|||
|
||||
/* enums */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||
enum { SchemeNorm, SchemeSel, SchemeTabActive, SchemeTabInactive }; /* color schemes */
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
NetWMWindowTypeDialog, NetClientList, NetClientInfo, NetLast }; /* EWMH atoms */
|
||||
|
|
@ -83,6 +84,7 @@ typedef struct {
|
|||
const Arg arg;
|
||||
} Button;
|
||||
|
||||
typedef struct Clientlist Clientlist;
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct Client Client;
|
||||
struct Client {
|
||||
|
|
@ -112,6 +114,7 @@ typedef struct {
|
|||
void (*arrange)(Monitor *);
|
||||
} Layout;
|
||||
|
||||
typedef struct Pertag Pertag;
|
||||
struct Monitor {
|
||||
char ltsymbol[16];
|
||||
float mfact;
|
||||
|
|
@ -125,12 +128,12 @@ 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];
|
||||
Pertag *pertag;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -142,12 +145,31 @@ typedef struct {
|
|||
int monitor;
|
||||
} Rule;
|
||||
|
||||
/* Xresources preferences */
|
||||
enum resource_type {
|
||||
STRING = 0,
|
||||
INTEGER = 1,
|
||||
FLOAT = 2
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
enum resource_type type;
|
||||
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);
|
||||
|
|
@ -185,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);
|
||||
|
|
@ -230,12 +252,17 @@ static void updatetitle(Client *c);
|
|||
static void updatewindowtype(Client *c);
|
||||
static void updatewmhints(Client *c);
|
||||
static void view(const Arg *arg);
|
||||
static void window_set_state(Display *dpy, Window win, long state);
|
||||
static void window_map(Display *dpy, Client *c, int deiconify);
|
||||
static void window_unmap(Display *dpy, Window win, Window root, int iconify);
|
||||
static Client *wintoclient(Window w);
|
||||
static Monitor *wintomon(Window w);
|
||||
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
static void load_xresources(void);
|
||||
static void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst);
|
||||
|
||||
/* variables */
|
||||
static const char autostartblocksh[] = "autostart_blocking.sh";
|
||||
|
|
@ -274,10 +301,20 @@ 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"
|
||||
|
||||
struct Pertag {
|
||||
unsigned int curtag, prevtag; /* current and previous tag */
|
||||
int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
|
||||
float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
|
||||
unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
|
||||
const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
|
||||
int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
|
||||
};
|
||||
|
||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||
|
||||
|
|
@ -306,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;
|
||||
}
|
||||
|
|
@ -386,13 +423,105 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact)
|
|||
return *x != c->x || *y != c->y || *w != c->w || *h != c->h;
|
||||
}
|
||||
|
||||
void
|
||||
bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive) {
|
||||
if (!c) return;
|
||||
int i, nclienttags = 0, nviewtags = 0;
|
||||
|
||||
drw_setscheme(drw, scheme[
|
||||
m->sel == c ? SchemeSel : (groupactive ? SchemeTabActive: SchemeTabInactive)
|
||||
]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, c->name, 0);
|
||||
|
||||
// Floating win indicator
|
||||
if (c->isfloating) drw_rect(drw, x + 2, 2, 5, 5, 0, 0);
|
||||
|
||||
// Optional borders between tabs
|
||||
if (BARTAB_BORDERS) {
|
||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBorder].pixel);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, 0, 1, bh);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w, 0, 1, bh);
|
||||
}
|
||||
|
||||
// Optional tags icons
|
||||
for (i = 0; i < LENGTH(tags); i++) {
|
||||
if ((m->tagset[m->seltags] >> i) & 1) { nviewtags++; }
|
||||
if ((c->tags >> i) & 1) { nclienttags++; }
|
||||
}
|
||||
if (BARTAB_TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1) {
|
||||
for (i = 0; i < LENGTH(tags); i++) {
|
||||
drw_rect(drw,
|
||||
( x + w - 2 - ((LENGTH(tags) / BARTAB_TAGSROWS) * BARTAB_TAGSPX)
|
||||
- (i % (LENGTH(tags)/BARTAB_TAGSROWS)) + ((i % (LENGTH(tags) / BARTAB_TAGSROWS)) * BARTAB_TAGSPX)
|
||||
),
|
||||
( 2 + ((i / (LENGTH(tags)/BARTAB_TAGSROWS)) * BARTAB_TAGSPX)
|
||||
- ((i / (LENGTH(tags)/BARTAB_TAGSROWS)))
|
||||
),
|
||||
BARTAB_TAGSPX, BARTAB_TAGSPX, (c->tags >> i) & 1, 0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
battabclick(Monitor *m, Client *c, int passx, int x, int w, int unused) {
|
||||
if (passx >= x && passx <= x + w) {
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bartabcalculate(
|
||||
Monitor *m, int offx, int sw, int passx,
|
||||
void(*tabfn)(Monitor *, Client *, int, int, int, int)
|
||||
) {
|
||||
Client *c;
|
||||
int
|
||||
i, clientsnmaster = 0, clientsnstack = 0, clientsnfloating = 0,
|
||||
masteractive = 0, fulllayout = 0, floatlayout = 0,
|
||||
x, w, tgactive;
|
||||
|
||||
for (i = 0, c = m->cl->clients; c; c = c->next) {
|
||||
if (!ISVISIBLE(c, m)) continue;
|
||||
if (c->isfloating) { clientsnfloating++; continue; }
|
||||
if (m->sel == c) { masteractive = i < m->nmaster; }
|
||||
if (i < m->nmaster) { clientsnmaster++; } else { clientsnstack++; }
|
||||
i++;
|
||||
}
|
||||
for (i = 0; i < LENGTH(bartabfloatfns); i++) if (m ->lt[m->sellt]->arrange == bartabfloatfns[i]) { floatlayout = 1; break; }
|
||||
for (i = 0; i < LENGTH(bartabmonfns); i++) if (m ->lt[m->sellt]->arrange == bartabmonfns[i]) { fulllayout = 1; break; }
|
||||
for (c = m->cl->clients, i = 0; c; c = c->next) {
|
||||
if (!ISVISIBLE(c, m)) continue;
|
||||
if (clientsnmaster + clientsnstack == 0 || floatlayout) {
|
||||
x = offx + (((m->mw - offx - sw) / (clientsnmaster + clientsnstack + clientsnfloating)) * i);
|
||||
w = (m->mw - offx - sw) / (clientsnmaster + clientsnstack + clientsnfloating);
|
||||
tgactive = 1;
|
||||
} else if (!c->isfloating && (fulllayout || ((clientsnmaster == 0) ^ (clientsnstack == 0)))) {
|
||||
x = offx + (((m->mw - offx - sw) / (clientsnmaster + clientsnstack)) * i);
|
||||
w = (m->mw - offx - sw) / (clientsnmaster + clientsnstack);
|
||||
tgactive = 1;
|
||||
} else if (i < m->nmaster && !c->isfloating) {
|
||||
x = offx + ((((m->mw * m->mfact) - offx) /clientsnmaster) * i);
|
||||
w = ((m->mw * m->mfact) - offx) / clientsnmaster;
|
||||
tgactive = masteractive;
|
||||
} else if (!c->isfloating) {
|
||||
x = (m->mw * m->mfact) + ((((m->mw * (1 - m->mfact)) - sw) / clientsnstack) * (i - m->nmaster));
|
||||
w = ((m->mw * (1 - m->mfact)) - sw) / clientsnstack;
|
||||
tgactive = !masteractive;
|
||||
} else continue;
|
||||
tabfn(m, c, passx, x, w, tgactive);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
@ -411,15 +540,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
|
||||
|
|
@ -450,8 +613,8 @@ buttonpress(XEvent *e)
|
|||
click = ClkLtSymbol;
|
||||
else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
||||
click = ClkStatusText;
|
||||
else
|
||||
click = ClkWinTitle;
|
||||
else // Focus clicked tab bar item
|
||||
bartabcalculate(selmon, x, TEXTW(stext) - lrpad + 2, ev->x, battabclick);
|
||||
} else if ((c = wintoclient(ev->window))) {
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
|
|
@ -486,8 +649,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);
|
||||
|
|
@ -574,7 +737,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);
|
||||
|
|
@ -620,7 +783,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);
|
||||
|
|
@ -640,10 +803,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;
|
||||
|
|
@ -651,6 +836,20 @@ createmon(void)
|
|||
m->lt[0] = &layouts[0];
|
||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||
m->pertag = ecalloc(1, sizeof(Pertag));
|
||||
m->pertag->curtag = m->pertag->prevtag = 1;
|
||||
|
||||
for (i = 0; i <= LENGTH(tags); i++) {
|
||||
m->pertag->nmasters[i] = m->nmaster;
|
||||
m->pertag->mfacts[i] = m->mfact;
|
||||
|
||||
m->pertag->ltidxs[i][0] = m->lt[0];
|
||||
m->pertag->ltidxs[i][1] = m->lt[1];
|
||||
m->pertag->sellts[i] = m->sellt;
|
||||
|
||||
m->pertag->showbars[i] = m->showbar;
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
|
|
@ -669,7 +868,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;
|
||||
}
|
||||
|
||||
|
|
@ -678,11 +877,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;
|
||||
}
|
||||
}
|
||||
|
|
@ -721,7 +920,8 @@ drawbar(Monitor *m)
|
|||
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||
}
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
resizebarwin(m);
|
||||
for (c = m->cl->clients; c; c = c->next) {
|
||||
occ |= c->tags;
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
|
|
@ -741,15 +941,13 @@ drawbar(Monitor *m)
|
|||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||
|
||||
// Draw bartabgroups
|
||||
drw_rect(drw, x, 0, m->ww - tw - x, bh, 1, 1);
|
||||
if ((w = m->ww - tw - x) > bh) {
|
||||
if (m->sel) {
|
||||
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
||||
if (m->sel->isfloating)
|
||||
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
||||
} else {
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||
bartabcalculate(m, x, tw, -1, bartabdraw);
|
||||
if (BARTAB_BOTTOMBORDER) {
|
||||
drw_setscheme(drw, scheme[SchemeTabActive]);
|
||||
drw_rect(drw, 0, bh - 1, m->ww, 1, 1, 0);
|
||||
}
|
||||
}
|
||||
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
||||
|
|
@ -796,8 +994,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) {
|
||||
|
|
@ -850,16 +1048,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) {
|
||||
|
|
@ -987,7 +1185,7 @@ grabkeys(void)
|
|||
void
|
||||
incnmaster(const Arg *arg)
|
||||
{
|
||||
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
|
|
@ -1143,12 +1341,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);
|
||||
}
|
||||
|
||||
|
|
@ -1230,9 +1428,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;
|
||||
}
|
||||
|
||||
|
|
@ -1396,8 +1594,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;
|
||||
}
|
||||
|
|
@ -1527,11 +1725,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);
|
||||
|
|
@ -1616,9 +1812,9 @@ void
|
|||
setlayout(const Arg *arg)
|
||||
{
|
||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||
selmon->sellt ^= 1;
|
||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
||||
if (arg && arg->v)
|
||||
selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
||||
if (selmon->sel)
|
||||
arrange(selmon);
|
||||
|
|
@ -1637,7 +1833,7 @@ setmfact(const Arg *arg)
|
|||
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
||||
if (f < 0.05 || f > 0.95)
|
||||
return;
|
||||
selmon->mfact = f;
|
||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
|
|
@ -1662,6 +1858,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)))
|
||||
|
|
@ -1738,16 +1936,14 @@ showhide(Client *c)
|
|||
{
|
||||
if (!c)
|
||||
return;
|
||||
if (ISVISIBLE(c)) {
|
||||
if (ISVISIBLE(c, c->mon)) {
|
||||
/* show clients top down */
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
|
||||
resize(c, c->x, c->y, c->w, c->h, 0);
|
||||
window_map(dpy, c, 1);
|
||||
showhide(c->snext);
|
||||
} else {
|
||||
/* hide clients bottom up */
|
||||
showhide(c->snext);
|
||||
XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
|
||||
window_unmap(dpy, c->win, root, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1784,8 +1980,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);
|
||||
|
|
@ -1808,7 +2022,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;
|
||||
|
||||
|
|
@ -1816,7 +2030,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);
|
||||
|
|
@ -1833,7 +2047,7 @@ tile(Monitor *m)
|
|||
void
|
||||
togglebar(const Arg *arg)
|
||||
{
|
||||
selmon->showbar = !selmon->showbar;
|
||||
selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
|
||||
updatebarpos(selmon);
|
||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
||||
arrange(selmon);
|
||||
|
|
@ -1856,12 +2070,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);
|
||||
|
|
@ -1873,9 +2092,33 @@ void
|
|||
toggleview(const Arg *arg)
|
||||
{
|
||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
||||
int i;
|
||||
|
||||
if (newtagset) {
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
|
||||
if (newtagset == ~0) {
|
||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
selmon->pertag->curtag = 0;
|
||||
}
|
||||
|
||||
/* test if the user did not select the same tag */
|
||||
if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
for (i = 0; !(newtagset & 1 << i); i++) ;
|
||||
selmon->pertag->curtag = i + 1;
|
||||
}
|
||||
|
||||
/* apply settings for this view */
|
||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||
|
||||
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||
togglebar(NULL);
|
||||
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
|
@ -1977,7 +2220,7 @@ 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);
|
||||
|
|
@ -2008,8 +2251,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();
|
||||
}
|
||||
|
|
@ -2029,16 +2274,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);
|
||||
|
|
@ -2169,16 +2411,106 @@ updatewmhints(Client *c)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
window_set_state(Display *dpy, Window win, long state)
|
||||
{
|
||||
long data[] = { state, None };
|
||||
|
||||
XChangeProperty(dpy, win, wmatom[WMState], wmatom[WMState], 32,
|
||||
PropModeReplace, (unsigned char*)data, 2);
|
||||
}
|
||||
|
||||
void
|
||||
window_map(Display *dpy, Client *c, int deiconify)
|
||||
{
|
||||
Window win = c->win;
|
||||
|
||||
if (deiconify)
|
||||
window_set_state(dpy, win, NormalState);
|
||||
|
||||
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||
XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
|
||||
XMapWindow(dpy, win);
|
||||
}
|
||||
|
||||
void
|
||||
window_unmap(Display *dpy, Window win, Window root, int iconify)
|
||||
{
|
||||
static XWindowAttributes ca, ra;
|
||||
|
||||
XGrabServer(dpy);
|
||||
XGetWindowAttributes(dpy, root, &ra);
|
||||
XGetWindowAttributes(dpy, win, &ca);
|
||||
|
||||
/* Prevent UnmapNotify events */
|
||||
XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
|
||||
XSelectInput(dpy, win, ca.your_event_mask & ~StructureNotifyMask);
|
||||
|
||||
XUnmapWindow(dpy, win);
|
||||
|
||||
if (iconify)
|
||||
window_set_state(dpy, win, IconicState);
|
||||
|
||||
XSelectInput(dpy, root, ra.your_event_mask);
|
||||
XSelectInput(dpy, win, ca.your_event_mask);
|
||||
XUngrabServer(dpy);
|
||||
}
|
||||
|
||||
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;
|
||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||
/* 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;
|
||||
focus(NULL);
|
||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
|
||||
if (arg->ui == ~0)
|
||||
selmon->pertag->curtag = 0;
|
||||
else {
|
||||
for (i = 0; !(arg->ui & 1 << i); i++) ;
|
||||
selmon->pertag->curtag = i + 1;
|
||||
}
|
||||
} else {
|
||||
tmptag = selmon->pertag->prevtag;
|
||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
selmon->pertag->curtag = tmptag;
|
||||
}
|
||||
|
||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||
|
||||
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||
togglebar(NULL);
|
||||
|
||||
attachclients(selmon);
|
||||
arrange(selmon);
|
||||
focus(NULL);
|
||||
}
|
||||
|
||||
Client *
|
||||
|
|
@ -2188,7 +2520,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;
|
||||
|
|
@ -2254,11 +2586,65 @@ 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);
|
||||
}
|
||||
|
||||
void
|
||||
resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
|
||||
{
|
||||
char *sdst = NULL;
|
||||
int *idst = NULL;
|
||||
float *fdst = NULL;
|
||||
|
||||
sdst = dst;
|
||||
idst = dst;
|
||||
fdst = dst;
|
||||
|
||||
char fullname[256];
|
||||
char *type;
|
||||
XrmValue ret;
|
||||
|
||||
snprintf(fullname, sizeof(fullname), "%s.%s", "dwm", name);
|
||||
fullname[sizeof(fullname) - 1] = '\0';
|
||||
|
||||
XrmGetResource(db, fullname, "*", &type, &ret);
|
||||
if (!(ret.addr == NULL || strncmp("String", type, 64)))
|
||||
{
|
||||
switch (rtype) {
|
||||
case STRING:
|
||||
strcpy(sdst, ret.addr);
|
||||
break;
|
||||
case INTEGER:
|
||||
*idst = strtoul(ret.addr, NULL, 10);
|
||||
break;
|
||||
case FLOAT:
|
||||
*fdst = strtof(ret.addr, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
load_xresources(void)
|
||||
{
|
||||
Display *display;
|
||||
char *resm;
|
||||
XrmDatabase db;
|
||||
ResourcePref *p;
|
||||
|
||||
display = XOpenDisplay(NULL);
|
||||
resm = XResourceManagerString(display);
|
||||
if (!resm)
|
||||
return;
|
||||
|
||||
db = XrmGetStringDatabase(resm);
|
||||
for (p = resources; p < resources + LENGTH(resources); p++)
|
||||
resource_load(db, p->name, p->type, p->dst);
|
||||
XCloseDisplay(display);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
|
@ -2271,6 +2657,8 @@ main(int argc, char *argv[])
|
|||
if (!(dpy = XOpenDisplay(NULL)))
|
||||
die("dwm: cannot open display");
|
||||
checkotherwm();
|
||||
XrmInitialize();
|
||||
load_xresources();
|
||||
setup();
|
||||
#ifdef __OpenBSD__
|
||||
if (pledge("stdio rpath proc exec", NULL) == -1)
|
||||
|
|
|
|||
Loading…
Reference in New Issue