Compare commits

..

No commits in common. "5d304c99af714dda72bf58ad1e6761df6cfb34bf" and "c2ab5aa0571dd0d9357ced506c36a3da577b494b" have entirely different histories.

7 changed files with 294 additions and 533 deletions

10
PATCHES
View File

@ -1,10 +1,4 @@
actualfullscreen
quitprompt
fullgaps fullgaps
status2d
extrabar
gaplessgrid gaplessgrid
status2d + extrabar
barpadding + notitle
resizecorners
statuspadding
- fonts

View File

@ -1,18 +1,12 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include <X11/XF86keysym.h>
/* appearance */ /* appearance */
static const unsigned int borderpx = 4; /* border pixel of windows */ static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int gappx = 15; /* gaps between windows */
static const unsigned int snap = 32; /* snap pixel */ static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */ static const int topbar = 1; /* 0 means bottom bar */
static const char statussep = ';'; static const char *fonts[] = { "monospace:size=10" };
static const int horizpadbar = 8; /* horizontal padding for statusbar */ static const char dmenufont[] = "monospace:size=10";
static const int vertpadbar = 12; /* vertical padding for statusbar */
static const char *fonts[] = { "Ubuntu Mono:size=12" };
static const char dmenufont[] = "Ubuntu Mono:size=12";
static const char col_gray1[] = "#222222"; static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444"; static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb"; static const char col_gray3[] = "#bbbbbb";
@ -25,7 +19,7 @@ static const char *colors[][3] = {
}; };
/* tagging */ /* tagging */
static const char *tags[] = { "", "", "", "", "", "", "", "", "", "0", "-", "=" }; static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const Rule rules[] = { static const Rule rules[] = {
/* xprop(1): /* xprop(1):
@ -33,32 +27,8 @@ static const Rule rules[] = {
* WM_NAME(STRING) = title * WM_NAME(STRING) = title
*/ */
/* class instance title tags mask isfloating monitor */ /* class instance title tags mask isfloating monitor */
// ----- 1 ----- { "Gimp", NULL, NULL, 0, 1, -1 },
{ "st-256color", NULL, NULL, 0, 0, -1 }, { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
// ----- 2 -----
{ "Nemo", NULL, NULL, 1 << 1, 0, -1 },
{ "Code", NULL, NULL, 1 << 1, 0, -1 },
// ----- 3 -----
{ "thunderbird", NULL, NULL, 1 << 2, 0, -1 },
{ "KeePassXC", NULL, NULL, 1 << 2, 0, -1 },
// ----- 4 -----
{ "vesktop", NULL, NULL, 1 << 3, 0, -1 },
{ "discord", NULL, NULL, 1 << 3, 0, -1 },
{ "KotatogramDesktop", NULL, NULL, 1 << 3, 0, -1 },
// ----- 5 -----
{ "Steam", NULL, NULL, 1 << 4, 0, -1 },
{ "steam", NULL, NULL, 1 << 4, 0, -1 },
{ "steamwebhelper", NULL, NULL, 1 << 4, 0, -1 },
// ----- 7 -----
{ "QjackCtl", NULL, NULL, 1 << 6, 1, -1 },
{ "PatchMatrix", NULL, NULL, 1 << 6, 0, -1 },
{ "Blueman-manager", NULL, NULL, 1 << 6, 0, -1 },
{ "corectrl", NULL, NULL, 1 << 6, 0, -1 },
// ----- 9 -----
{ "firefox", NULL, NULL, 1 << 8, 0, -1 },
{ "librewolf-default", NULL, NULL, 1 << 8, 0, -1 },
// ----- OTHER -----
{ "xwinwrap", NULL, NULL, 1 << 9, 0, -1 },
}; };
/* layout(s) */ /* layout(s) */
@ -67,86 +37,64 @@ 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 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 int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
#include "layouts.c"
static const Layout layouts[] = { static const Layout layouts[] = {
/* symbol arrange function */ /* symbol arrange function */
{ "###", gaplessgrid }, { "[]=", tile }, /* first entry is default */
{ "[]=", tile }, { "><>", NULL }, /* no layout function means floating behavior */
{ "><>", NULL }, { "[M]", monocle },
{ "[M]", monocle },
}; };
/* key definitions */ /* key definitions */
#define SUPERKEY Mod4Mask #define MODKEY Mod1Mask
#define ALTKEY Mod1Mask
#define TAGKEYS(KEY,TAG) \ #define TAGKEYS(KEY,TAG) \
{ SUPERKEY, KEY, view, {.ui = 1 << TAG} }, \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ SUPERKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
{ SUPERKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
{ SUPERKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
/* helper for spawning shell commands in the pre dwm-5.0 fashion */ /* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* commands */ /* commands */
static const char *screenshot[] = { "scrsht", NULL };
static const char *screenshotarea[] = { "scrsht", "-s", NULL };
static const char *volup[] = { "pactl", "set-sink-volume", "0", "+5%", NULL };
static const char *voldown[] = { "pactl", "set-sink-volume", "0", "-5%", NULL };
static const char *volmute[] = { "pactl", "set-sink-mute", "0", "toggle", NULL };
static const char *backlightup[] = { "light", "-A", "10", NULL };
static const char *backlightdown[] = { "light", "-U", "10", NULL };
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "st", NULL }; static const char *termcmd[] = { "st", NULL };
static const Key keys[] = { static const Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
{ 0, XK_Print, spawn, {.v = screenshot } }, { MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ ShiftMask, XK_Print, spawn, {.v = screenshotarea } }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = volup } }, { MODKEY, XK_b, togglebar, {0} },
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = voldown } }, { MODKEY, XK_j, focusstack, {.i = +1 } },
{ 0, XF86XK_MonBrightnessUp, spawn, {.v = backlightup } }, { MODKEY, XK_k, focusstack, {.i = -1 } },
{ 0, XF86XK_MonBrightnessDown, spawn, {.v = backlightdown } }, { MODKEY, XK_i, incnmaster, {.i = +1 } },
{ 0, XF86XK_AudioMute, spawn, {.v = volmute } }, { MODKEY, XK_d, incnmaster, {.i = -1 } },
{ SUPERKEY, XK_d, spawn, {.v = dmenucmd } }, { MODKEY, XK_h, setmfact, {.f = -0.05} },
{ SUPERKEY, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_l, setmfact, {.f = +0.05} },
{ SUPERKEY, XK_b, togglebar, {.i = 1} }, { MODKEY, XK_Return, zoom, {0} },
{ SUPERKEY|ShiftMask, XK_b, togglebar, {.i = 2} }, { MODKEY, XK_Tab, view, {0} },
{ ALTKEY, XK_Tab, focusstack, {.i = +1 } }, { MODKEY|ShiftMask, XK_c, killclient, {0} },
{ SUPERKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ SUPERKEY, XK_p, incnmaster, {.i = -1 } }, { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ SUPERKEY, XK_o, setmfact, {.f = -0.05} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ SUPERKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY, XK_space, setlayout, {0} },
{ SUPERKEY|ShiftMask, XK_Return, zoom, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ SUPERKEY, XK_q, killclient, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } },
{ SUPERKEY, XK_g, setlayout, {.v = &layouts[0]} }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ SUPERKEY, XK_t, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_comma, focusmon, {.i = -1 } },
{ SUPERKEY, XK_f, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_period, focusmon, {.i = +1 } },
{ SUPERKEY, XK_m, setlayout, {.v = &layouts[3]} }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ SUPERKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
// { SUPERKEY, XK_comma, focusmon, {.i = -1 } }, TAGKEYS( XK_1, 0)
// { SUPERKEY, XK_period, focusmon, {.i = +1 } }, TAGKEYS( XK_2, 1)
// { SUPERKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, TAGKEYS( XK_3, 2)
// { SUPERKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, TAGKEYS( XK_4, 3)
{ SUPERKEY|ShiftMask, XK_f, togglefullscr, {0} }, TAGKEYS( XK_5, 4)
TAGKEYS( XK_1, 0) TAGKEYS( XK_6, 5)
TAGKEYS( XK_2, 1) TAGKEYS( XK_7, 6)
TAGKEYS( XK_3, 2) TAGKEYS( XK_8, 7)
TAGKEYS( XK_4, 3) TAGKEYS( XK_9, 8)
TAGKEYS( XK_5, 4) { MODKEY|ShiftMask, XK_q, quit, {0} },
TAGKEYS( XK_6, 5)
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
TAGKEYS( XK_0, 9)
TAGKEYS( XK_minus, 10)
TAGKEYS( XK_equal, 11)
{ SUPERKEY|ShiftMask, XK_q, quitprompt, {0} },
}; };
/* button definitions */ /* button definitions */
@ -155,13 +103,14 @@ static const Button buttons[] = {
/* click event mask button function argument */ /* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, SUPERKEY, Button1, movemouse, {0} }, { ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, SUPERKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, SUPERKEY, Button3, resizemouse, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
{ ClkTagBar, 0, Button1, view, {0} }, { ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button3, toggleview, {0} }, { ClkTagBar, 0, Button3, toggleview, {0} },
{ ClkTagBar, SUPERKEY, Button1, tag, {0} }, { ClkTagBar, MODKEY, Button1, tag, {0} },
{ ClkTagBar, SUPERKEY, Button3, toggletag, {0} }, { ClkTagBar, MODKEY, Button3, toggletag, {0} },
}; };

161
config.h
View File

@ -1,18 +1,12 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include <X11/XF86keysym.h>
/* appearance */ /* appearance */
static const unsigned int borderpx = 4; /* border pixel of windows */ static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int gappx = 15; /* gaps between windows */
static const unsigned int snap = 32; /* snap pixel */ static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */ static const int topbar = 1; /* 0 means bottom bar */
static const char statussep = ';'; static const char *fonts[] = { "monospace:size=10" };
static const int horizpadbar = 8; /* horizontal padding for statusbar */ static const char dmenufont[] = "monospace:size=10";
static const int vertpadbar = 12; /* vertical padding for statusbar */
static const char *fonts[] = { "Ubuntu Mono:size=12" };
static const char dmenufont[] = "Ubuntu Mono:size=12";
static const char col_gray1[] = "#222222"; static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444"; static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb"; static const char col_gray3[] = "#bbbbbb";
@ -25,7 +19,7 @@ static const char *colors[][3] = {
}; };
/* tagging */ /* tagging */
static const char *tags[] = { "", "", "", "", "", "", "", "", "", "0", "-", "=" }; static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const Rule rules[] = { static const Rule rules[] = {
/* xprop(1): /* xprop(1):
@ -33,32 +27,8 @@ static const Rule rules[] = {
* WM_NAME(STRING) = title * WM_NAME(STRING) = title
*/ */
/* class instance title tags mask isfloating monitor */ /* class instance title tags mask isfloating monitor */
// ----- 1 ----- { "Gimp", NULL, NULL, 0, 1, -1 },
{ "st-256color", NULL, NULL, 0, 0, -1 }, { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
// ----- 2 -----
{ "Nemo", NULL, NULL, 1 << 1, 0, -1 },
{ "Code", NULL, NULL, 1 << 1, 0, -1 },
// ----- 3 -----
{ "thunderbird", NULL, NULL, 1 << 2, 0, -1 },
{ "KeePassXC", NULL, NULL, 1 << 2, 0, -1 },
// ----- 4 -----
{ "vesktop", NULL, NULL, 1 << 3, 0, -1 },
{ "discord", NULL, NULL, 1 << 3, 0, -1 },
{ "KotatogramDesktop", NULL, NULL, 1 << 3, 0, -1 },
// ----- 5 -----
{ "Steam", NULL, NULL, 1 << 4, 0, -1 },
{ "steam", NULL, NULL, 1 << 4, 0, -1 },
{ "steamwebhelper", NULL, NULL, 1 << 4, 0, -1 },
// ----- 7 -----
{ "QjackCtl", NULL, NULL, 1 << 6, 1, -1 },
{ "PatchMatrix", NULL, NULL, 1 << 6, 0, -1 },
{ "Blueman-manager", NULL, NULL, 1 << 6, 0, -1 },
{ "corectrl", NULL, NULL, 1 << 6, 0, -1 },
// ----- 9 -----
{ "firefox", NULL, NULL, 1 << 8, 0, -1 },
{ "librewolf-default", NULL, NULL, 1 << 8, 0, -1 },
// ----- OTHER -----
{ "xwinwrap", NULL, NULL, 1 << 9, 0, -1 },
}; };
/* layout(s) */ /* layout(s) */
@ -67,86 +37,64 @@ 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 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 int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
#include "layouts.c"
static const Layout layouts[] = { static const Layout layouts[] = {
/* symbol arrange function */ /* symbol arrange function */
{ "###", gaplessgrid }, { "[]=", tile }, /* first entry is default */
{ "[]=", tile }, { "><>", NULL }, /* no layout function means floating behavior */
{ "><>", NULL }, { "[M]", monocle },
{ "[M]", monocle },
}; };
/* key definitions */ /* key definitions */
#define SUPERKEY Mod4Mask #define MODKEY Mod1Mask
#define ALTKEY Mod1Mask
#define TAGKEYS(KEY,TAG) \ #define TAGKEYS(KEY,TAG) \
{ SUPERKEY, KEY, view, {.ui = 1 << TAG} }, \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ SUPERKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
{ SUPERKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
{ SUPERKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
/* helper for spawning shell commands in the pre dwm-5.0 fashion */ /* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* commands */ /* commands */
static const char *screenshot[] = { "scrsht", NULL };
static const char *screenshotarea[] = { "scrsht", "-s", NULL };
static const char *volup[] = { "pactl", "set-sink-volume", "0", "+5%", NULL };
static const char *voldown[] = { "pactl", "set-sink-volume", "0", "-5%", NULL };
static const char *volmute[] = { "pactl", "set-sink-mute", "0", "toggle", NULL };
static const char *backlightup[] = { "light", "-A", "10", NULL };
static const char *backlightdown[] = { "light", "-U", "10", NULL };
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "st", NULL }; static const char *termcmd[] = { "st", NULL };
static const Key keys[] = { static const Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
{ 0, XK_Print, spawn, {.v = screenshot } }, { MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ ShiftMask, XK_Print, spawn, {.v = screenshotarea } }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = volup } }, { MODKEY, XK_b, togglebar, {0} },
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = voldown } }, { MODKEY, XK_j, focusstack, {.i = +1 } },
{ 0, XF86XK_MonBrightnessUp, spawn, {.v = backlightup } }, { MODKEY, XK_k, focusstack, {.i = -1 } },
{ 0, XF86XK_MonBrightnessDown, spawn, {.v = backlightdown } }, { MODKEY, XK_i, incnmaster, {.i = +1 } },
{ 0, XF86XK_AudioMute, spawn, {.v = volmute } }, { MODKEY, XK_d, incnmaster, {.i = -1 } },
{ SUPERKEY, XK_d, spawn, {.v = dmenucmd } }, { MODKEY, XK_h, setmfact, {.f = -0.05} },
{ SUPERKEY, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_l, setmfact, {.f = +0.05} },
{ SUPERKEY, XK_b, togglebar, {.i = 1} }, { MODKEY, XK_Return, zoom, {0} },
{ SUPERKEY|ShiftMask, XK_b, togglebar, {.i = 2} }, { MODKEY, XK_Tab, view, {0} },
{ ALTKEY, XK_Tab, focusstack, {.i = +1 } }, { MODKEY|ShiftMask, XK_c, killclient, {0} },
{ SUPERKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ SUPERKEY, XK_p, incnmaster, {.i = -1 } }, { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ SUPERKEY, XK_o, setmfact, {.f = -0.05} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ SUPERKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY, XK_space, setlayout, {0} },
{ SUPERKEY|ShiftMask, XK_Return, zoom, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ SUPERKEY, XK_q, killclient, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } },
{ SUPERKEY, XK_g, setlayout, {.v = &layouts[0]} }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ SUPERKEY, XK_t, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_comma, focusmon, {.i = -1 } },
{ SUPERKEY, XK_f, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_period, focusmon, {.i = +1 } },
{ SUPERKEY, XK_m, setlayout, {.v = &layouts[3]} }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ SUPERKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
// { SUPERKEY, XK_comma, focusmon, {.i = -1 } }, TAGKEYS( XK_1, 0)
// { SUPERKEY, XK_period, focusmon, {.i = +1 } }, TAGKEYS( XK_2, 1)
// { SUPERKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, TAGKEYS( XK_3, 2)
// { SUPERKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, TAGKEYS( XK_4, 3)
{ SUPERKEY|ShiftMask, XK_f, togglefullscr, {0} }, TAGKEYS( XK_5, 4)
TAGKEYS( XK_1, 0) TAGKEYS( XK_6, 5)
TAGKEYS( XK_2, 1) TAGKEYS( XK_7, 6)
TAGKEYS( XK_3, 2) TAGKEYS( XK_8, 7)
TAGKEYS( XK_4, 3) TAGKEYS( XK_9, 8)
TAGKEYS( XK_5, 4) { MODKEY|ShiftMask, XK_q, quit, {0} },
TAGKEYS( XK_6, 5)
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
TAGKEYS( XK_0, 9)
TAGKEYS( XK_minus, 10)
TAGKEYS( XK_equal, 11)
{ SUPERKEY|ShiftMask, XK_q, quitprompt, {0} },
}; };
/* button definitions */ /* button definitions */
@ -155,13 +103,14 @@ static const Button buttons[] = {
/* click event mask button function argument */ /* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, SUPERKEY, Button1, movemouse, {0} }, { ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, SUPERKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, SUPERKEY, Button3, resizemouse, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
{ ClkTagBar, 0, Button1, view, {0} }, { ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button3, toggleview, {0} }, { ClkTagBar, 0, Button3, toggleview, {0} },
{ ClkTagBar, SUPERKEY, Button1, tag, {0} }, { ClkTagBar, MODKEY, Button1, tag, {0} },
{ ClkTagBar, SUPERKEY, Button3, toggletag, {0} }, { ClkTagBar, MODKEY, Button3, toggletag, {0} },
}; };

BIN
dwm

Binary file not shown.

388
dwm.c
View File

@ -45,27 +45,27 @@
#include "util.h" #include "util.h"
/* macros */ /* macros */
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) #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)) \ #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
#define LENGTH(X) (sizeof X / sizeof X[0]) #define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask) #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw) #define WIDTH(X) ((X)->w + 2 * (X)->bw)
#define HEIGHT(X) ((X)->h + 2 * (X)->bw) #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
#define TAGMASK ((1 << LENGTH(tags)) - 1) #define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
/* enums */ /* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel }; /* color schemes */ enum { SchemeNorm, SchemeSel }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck, enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
typedef union { typedef union {
int i; int i;
@ -116,10 +116,9 @@ struct Monitor {
float mfact; float mfact;
int nmaster; int nmaster;
int num; int num;
int by; /* bar geometry */ int by; /* bar geometry */
int eby; /* extra bar geometry */ int mx, my, mw, mh; /* screen size */
int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */
int wx, wy, ww, wh; /* window area */
unsigned int seltags; unsigned int seltags;
unsigned int sellt; unsigned int sellt;
unsigned int tagset[2]; unsigned int tagset[2];
@ -130,7 +129,6 @@ struct Monitor {
Client *stack; Client *stack;
Monitor *next; Monitor *next;
Window barwin; Window barwin;
Window extrabarwin;
const Layout *lt[2]; const Layout *lt[2];
}; };
@ -165,7 +163,6 @@ static void detachstack(Client *c);
static Monitor *dirtomon(int dir); static Monitor *dirtomon(int dir);
static void drawbar(Monitor *m); static void drawbar(Monitor *m);
static void drawbars(void); static void drawbars(void);
static int drawstatusbar(Monitor *m, int bh, int extra, char* text);
static void enternotify(XEvent *e); static void enternotify(XEvent *e);
static void expose(XEvent *e); static void expose(XEvent *e);
static void focus(Client *c); static void focus(Client *c);
@ -184,13 +181,13 @@ static void killclient(const Arg *arg);
static void manage(Window w, XWindowAttributes *wa); static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e); static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e); static void maprequest(XEvent *e);
static void monocle(Monitor *m);
static void motionnotify(XEvent *e); static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg); static void movemouse(const Arg *arg);
static Client *nexttiled(Client *c); static Client *nexttiled(Client *c);
static void pop(Client *c); static void pop(Client *c);
static void propertynotify(XEvent *e); static void propertynotify(XEvent *e);
static void quit(const Arg *arg); static void quit(const Arg *arg);
static void quitprompt(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h); static Monitor *recttomon(int x, int y, int w, int h);
static void resize(Client *c, int x, int y, int w, int h, int interact); static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizeclient(Client *c, int x, int y, int w, int h); static void resizeclient(Client *c, int x, int y, int w, int h);
@ -211,9 +208,9 @@ static void showhide(Client *c);
static void spawn(const Arg *arg); static void spawn(const Arg *arg);
static void tag(const Arg *arg); static void tag(const Arg *arg);
static void tagmon(const Arg *arg); static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglebar(const Arg *arg); static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
static void togglefullscr(const Arg *arg);
static void toggletag(const Arg *arg); static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg); static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus); static void unfocus(Client *c, int setfocus);
@ -239,14 +236,13 @@ static void zoom(const Arg *arg);
/* variables */ /* variables */
static const char broken[] = "broken"; static const char broken[] = "broken";
static char stext[1024]; static char stext[256];
static char estext[1024];
static int screen; static int screen;
static int sw, sh; /* X display screen geometry width, height */ static int sw, sh; /* X display screen geometry width, height */
static int bh; /* bar height */ static int bh; /* bar height */
static int lrpad; /* sum of left and right padding for text */ static int lrpad; /* sum of left and right padding for text */
static int (*xerrorxlib)(Display *, XErrorEvent *); static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 1; static unsigned int numlockmask = 0;
static void (*handler[LASTEvent]) (XEvent *) = { static void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress, [ButtonPress] = buttonpress,
[ClientMessage] = clientmessage, [ClientMessage] = clientmessage,
@ -265,7 +261,6 @@ static void (*handler[LASTEvent]) (XEvent *) = {
}; };
static Atom wmatom[WMLast], netatom[NetLast]; static Atom wmatom[WMLast], netatom[NetLast];
static int running = 1; static int running = 1;
static int restart = 1;
static Cur *cursor[CurLast]; static Cur *cursor[CurLast];
static Clr **scheme; static Clr **scheme;
static Display *dpy; static Display *dpy;
@ -293,7 +288,7 @@ applyrules(Client *c)
c->isfloating = 0; c->isfloating = 0;
c->tags = 0; c->tags = 0;
XGetClassHint(dpy, c->win, &ch); XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : broken; class = ch.res_class ? ch.res_class : broken;
instance = ch.res_name ? ch.res_name : broken; instance = ch.res_name ? ch.res_name : broken;
for (i = 0; i < LENGTH(rules); i++) { for (i = 0; i < LENGTH(rules); i++) {
@ -446,8 +441,10 @@ buttonpress(XEvent *e)
arg.ui = 1 << i; arg.ui = 1 << i;
} else if (ev->x < x + TEXTW(selmon->ltsymbol)) } else if (ev->x < x + TEXTW(selmon->ltsymbol))
click = ClkLtSymbol; click = ClkLtSymbol;
else else if (ev->x > selmon->ww - (int)TEXTW(stext))
click = ClkStatusText; click = ClkStatusText;
else
click = ClkWinTitle;
} else if ((c = wintoclient(ev->window))) { } else if ((c = wintoclient(ev->window))) {
focus(c); focus(c);
restack(selmon); restack(selmon);
@ -489,7 +486,7 @@ cleanup(void)
cleanupmon(mons); cleanupmon(mons);
for (i = 0; i < CurLast; i++) for (i = 0; i < CurLast; i++)
drw_cur_free(drw, cursor[i]); drw_cur_free(drw, cursor[i]);
for (i = 0; i < LENGTH(colors) + 1; i++) for (i = 0; i < LENGTH(colors); i++)
free(scheme[i]); free(scheme[i]);
free(scheme); free(scheme);
XDestroyWindow(dpy, wmcheckwin); XDestroyWindow(dpy, wmcheckwin);
@ -511,9 +508,7 @@ cleanupmon(Monitor *mon)
m->next = mon->next; m->next = mon->next;
} }
XUnmapWindow(dpy, mon->barwin); XUnmapWindow(dpy, mon->barwin);
XUnmapWindow(dpy, mon->extrabarwin);
XDestroyWindow(dpy, mon->barwin); XDestroyWindow(dpy, mon->barwin);
XDestroyWindow(dpy, mon->extrabarwin);
free(mon); free(mon);
} }
@ -528,7 +523,7 @@ clientmessage(XEvent *e)
if (cme->message_type == netatom[NetWMState]) { if (cme->message_type == netatom[NetWMState]) {
if (cme->data.l[1] == netatom[NetWMFullscreen] if (cme->data.l[1] == netatom[NetWMFullscreen]
|| cme->data.l[2] == netatom[NetWMFullscreen]) || cme->data.l[2] == netatom[NetWMFullscreen])
setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ 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 */ && !c->isfullscreen)));
} else if (cme->message_type == netatom[NetActiveWindow]) { } else if (cme->message_type == netatom[NetActiveWindow]) {
if (c != selmon->sel && !c->isurgent) if (c != selmon->sel && !c->isurgent)
@ -575,8 +570,7 @@ configurenotify(XEvent *e)
for (c = m->clients; c; c = c->next) for (c = m->clients; c; c = c->next)
if (c->isfullscreen) if (c->isfullscreen)
resizeclient(c, m->mx, m->my, m->mw, m->mh); resizeclient(c, m->mx, m->my, m->mw, m->mh);
XMoveResizeWindow(dpy, m->barwin, m->wx + gappx, m->by + gappx, m->ww - 2 * gappx, bh); XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
XMoveResizeWindow(dpy, m->extrabarwin, m->wx + gappx, m->eby - gappx, m->ww - 2 * gappx, bh);
} }
focus(NULL); focus(NULL);
arrange(NULL); arrange(NULL);
@ -701,119 +695,6 @@ dirtomon(int dir)
return m; return m;
} }
int
drawstatusbar(Monitor *m, int bh, int extra, char* stext) {
int ret, i, w, x, len;
short isCode = 0;
char *text;
char *p;
len = strlen(stext) + 1 ;
if (!(text = (char*) malloc(sizeof(char)*len)))
die("malloc");
p = text;
memcpy(text, stext, len);
/* compute width of the status text */
w = 0;
i = -1;
while (text[++i]) {
if (text[i] == '^') {
if (!isCode) {
isCode = 1;
text[i] = '\0';
w += TEXTW(text) - lrpad;
text[i] = '^';
if (text[++i] == 'f')
w += atoi(text + ++i);
} else {
isCode = 0;
text = text + i + 1;
i = -1;
}
}
}
if (!isCode)
w += TEXTW(text) - lrpad;
else
isCode = 0;
text = p;
if (extra) {
w = m->ww - 2 * gappx;
ret = x = 0;
} else {
ret = m->ww - w;
x = ret - 2 * gappx;
}
drw_setscheme(drw, scheme[LENGTH(colors)]);
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
drw_rect(drw, x, 0, w, bh, 1, 1);
x++;
/* process status text */
i = -1;
while (text[++i]) {
if (text[i] == '^' && !isCode) {
isCode = 1;
text[i] = '\0';
w = TEXTW(text) - lrpad;
drw_text(drw, x, 0, w, bh, 0, text, 0);
x += w;
/* process code */
while (text[++i] != '^') {
if (text[i] == 'c') {
char buf[8];
memcpy(buf, (char*)text+i+1, 7);
buf[7] = '\0';
drw_clr_create(drw, &drw->scheme[ColFg], buf);
i += 7;
} else if (text[i] == 'b') {
char buf[8];
memcpy(buf, (char*)text+i+1, 7);
buf[7] = '\0';
drw_clr_create(drw, &drw->scheme[ColBg], buf);
i += 7;
} else if (text[i] == 'd') {
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
} else if (text[i] == 'r') {
int rx = atoi(text + ++i);
while (text[++i] != ',');
int ry = atoi(text + ++i);
while (text[++i] != ',');
int rw = atoi(text + ++i);
while (text[++i] != ',');
int rh = atoi(text + ++i);
drw_rect(drw, rx + x, ry, rw, rh, 1, 0);
} else if (text[i] == 'f') {
x += atoi(text + ++i);
}
}
text = text + i + 1;
i=-1;
isCode = 0;
}
}
if (!isCode) {
w = TEXTW(text) - lrpad;
drw_text(drw, x, 0, w, bh, 0, text, 0);
}
drw_setscheme(drw, scheme[SchemeNorm]);
free(p);
return ret;
}
void void
drawbar(Monitor *m) drawbar(Monitor *m)
{ {
@ -828,10 +709,9 @@ drawbar(Monitor *m)
/* draw status first so it can be overdrawn by tags later */ /* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */ if (m == selmon) { /* status is only drawn on selected monitor */
// drw_setscheme(drw, scheme[SchemeNorm]); drw_setscheme(drw, scheme[SchemeNorm]);
// tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
// drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
tw = m->ww - drawstatusbar(m, bh, 0, stext);
} }
for (c = m->clients; c; c = c->next) { for (c = m->clients; c; c = c->next) {
@ -855,15 +735,17 @@ drawbar(Monitor *m)
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
if ((w = m->ww - tw - x) > bh) { if ((w = m->ww - tw - x) > bh) {
drw_setscheme(drw, scheme[SchemeNorm]); if (m->sel) {
drw_rect(drw, x, 0, w - 2 * gappx, bh, 1, 1); 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);
}
} }
drw_map(drw, m->barwin, 0, 0, m->ww, bh); drw_map(drw, m->barwin, 0, 0, m->ww, bh);
if (m == selmon) { /* extra status is only drawn on selected monitor */
tw = drawstatusbar(m, bh, 1, estext);
drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh);
}
} }
void void
@ -1228,6 +1110,21 @@ maprequest(XEvent *e)
manage(ev->window, &wa); manage(ev->window, &wa);
} }
void
monocle(Monitor *m)
{
unsigned int n = 0;
Client *c;
for (c = m->clients; c; c = c->next)
if (ISVISIBLE(c))
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))
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
}
void void
motionnotify(XEvent *e) motionnotify(XEvent *e)
{ {
@ -1348,8 +1245,11 @@ propertynotify(XEvent *e)
drawbars(); drawbars();
break; break;
} }
if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
updatetitle(c); updatetitle(c);
if (c == c->mon->sel)
drawbar(c->mon);
}
if (ev->atom == netatom[NetWMWindowType]) if (ev->atom == netatom[NetWMWindowType])
updatewindowtype(c); updatewindowtype(c);
} }
@ -1361,31 +1261,6 @@ quit(const Arg *arg)
running = 0; running = 0;
} }
void
quitprompt(const Arg *arg)
{
FILE *pp = popen("echo -e \"no\nrestart\nyes\" | dmenu -i -sb red -p \"Quit DWM?\"", "r");
if(pp != NULL) {
char buf[1024];
if (fgets(buf, sizeof(buf), pp) == NULL) {
fprintf(stderr, "Quitprompt: Error reading pipe!\n");
return;
}
if (strcmp(buf, "yes\n") == 0) {
pclose(pp);
restart = 0;
quit(NULL);
} else if (strcmp(buf, "restart\n") == 0) {
pclose(pp);
restart = 1;
quit(NULL);
} else if (strcmp(buf, "no\n") == 0) {
pclose(pp);
return;
}
}
}
Monitor * Monitor *
recttomon(int x, int y, int w, int h) recttomon(int x, int y, int w, int h)
{ {
@ -1426,15 +1301,9 @@ void
resizemouse(const Arg *arg) resizemouse(const Arg *arg)
{ {
int ocx, ocy, nw, nh; int ocx, ocy, nw, nh;
int ocx2, ocy2, nx, ny;
Client *c; Client *c;
Monitor *m; Monitor *m;
XEvent ev; XEvent ev;
int horizcorner, vertcorner;
int di;
unsigned int dui;
Window dummy;
Time lasttime = 0; Time lasttime = 0;
if (!(c = selmon->sel)) if (!(c = selmon->sel))
@ -1444,18 +1313,10 @@ resizemouse(const Arg *arg)
restack(selmon); restack(selmon);
ocx = c->x; ocx = c->x;
ocy = c->y; ocy = c->y;
ocx2 = c->x + c->w;
ocy2 = c->y + c->h;
if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess) None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
return; return;
if (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui)) XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
return;
horizcorner = nx < c->w / 2;
vertcorner = ny < c->h / 2;
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
horizcorner ? (-c->bw) : (c->w + c->bw - 1),
vertcorner ? (-c->bw) : (c->h + c->bw - 1));
do { do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch(ev.type) { switch(ev.type) {
@ -1469,10 +1330,8 @@ resizemouse(const Arg *arg)
continue; continue;
lasttime = ev.xmotion.time; lasttime = ev.xmotion.time;
nx = horizcorner ? ev.xmotion.x : c->x; nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
ny = vertcorner ? ev.xmotion.y : c->y; nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
nw = MAX(horizcorner ? (ocx2 - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1);
nh = MAX(vertcorner ? (ocy2 - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1);
if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww
&& c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh) && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
{ {
@ -1485,9 +1344,7 @@ resizemouse(const Arg *arg)
break; break;
} }
} while (ev.type != ButtonRelease); } while (ev.type != ButtonRelease);
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
horizcorner ? (-c->bw) : (c->w + c->bw - 1),
vertcorner ? (-c->bw) : (c->h + c->bw - 1));
XUngrabPointer(dpy, CurrentTime); XUngrabPointer(dpy, CurrentTime);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
@ -1704,8 +1561,8 @@ setup(void)
drw = drw_create(dpy, screen, root, sw, sh); drw = drw_create(dpy, screen, root, sw, sh);
if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
die("no fonts could be loaded."); die("no fonts could be loaded.");
lrpad = drw->fonts->h + horizpadbar; lrpad = drw->fonts->h;
bh = drw->fonts->h + vertpadbar; bh = drw->fonts->h + 2;
updategeom(); updategeom();
/* init atoms */ /* init atoms */
utf8string = XInternAtom(dpy, "UTF8_STRING", False); utf8string = XInternAtom(dpy, "UTF8_STRING", False);
@ -1727,8 +1584,7 @@ setup(void)
cursor[CurResize] = drw_cur_create(drw, XC_sizing); cursor[CurResize] = drw_cur_create(drw, XC_sizing);
cursor[CurMove] = drw_cur_create(drw, XC_fleur); cursor[CurMove] = drw_cur_create(drw, XC_fleur);
/* init appearance */ /* init appearance */
scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *)); scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3);
for (i = 0; i < LENGTH(colors); i++) for (i = 0; i < LENGTH(colors); i++)
scheme[i] = drw_scm_create(drw, colors[i], 3); scheme[i] = drw_scm_create(drw, colors[i], 3);
/* init bars */ /* init bars */
@ -1828,13 +1684,40 @@ tagmon(const Arg *arg)
sendmon(selmon->sel, dirtomon(arg->i)); sendmon(selmon->sel, dirtomon(arg->i));
} }
void
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++);
if (n == 0)
return;
if (n > m->nmaster)
mw = m->nmaster ? m->ww * m->mfact : 0;
else
mw = m->ww;
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
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);
if (my + HEIGHT(c) < m->wh)
my += HEIGHT(c);
} else {
h = (m->wh - ty) / (n - i);
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
if (ty + HEIGHT(c) < m->wh)
ty += HEIGHT(c);
}
}
void void
togglebar(const Arg *arg) togglebar(const Arg *arg)
{ {
selmon->showbar = !selmon->showbar; selmon->showbar = !selmon->showbar;
updatebarpos(selmon); updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + gappx, selmon->by + gappx, selmon->ww - 2 * gappx, bh); XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + gappx, selmon->eby - gappx, selmon->ww - 2 * gappx, bh);
arrange(selmon); arrange(selmon);
} }
@ -1852,13 +1735,6 @@ togglefloating(const Arg *arg)
arrange(selmon); arrange(selmon);
} }
void
togglefullscr(const Arg *arg)
{
if(selmon->sel)
setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
}
void void
toggletag(const Arg *arg) toggletag(const Arg *arg)
{ {
@ -1950,30 +1826,14 @@ updatebars(void)
}; };
XClassHint ch = {"dwm", "dwm"}; XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) { for (m = mons; m; m = m->next) {
if (!m->barwin) { if (m->barwin)
m->barwin = XCreateWindow(dpy, root, m->wx + gappx, m->by + gappx, m->ww - 2 * gappx, bh, 0, DefaultDepth(dpy, screen), continue;
CopyFromParent, DefaultVisual(dpy, screen), m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); CopyFromParent, DefaultVisual(dpy, screen),
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
XMapRaised(dpy, m->barwin); XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
XSetClassHint(dpy, m->barwin, &ch); XMapRaised(dpy, m->barwin);
} XSetClassHint(dpy, m->barwin, &ch);
if (!m->extrabarwin) {
m->extrabarwin = XCreateWindow(dpy, root, m->wx + gappx, m->eby - gappx, m->ww - 2 * gappx, bh, 0, DefaultDepth(dpy, screen),
CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
XDefineCursor(dpy, m->extrabarwin, cursor[CurNormal]->cursor);
XMapRaised(dpy, m->extrabarwin);
XSetClassHint(dpy, m->extrabarwin, &ch);
}
// if (m->barwin)
// continue;
// m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
// CopyFromParent, DefaultVisual(dpy, screen),
// CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
// XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
// XMapRaised(dpy, m->barwin);
// XSetClassHint(dpy, m->barwin, &ch);
} }
} }
@ -1982,17 +1842,12 @@ updatebarpos(Monitor *m)
{ {
m->wy = m->my; m->wy = m->my;
m->wh = m->mh; m->wh = m->mh;
m->wh -= bh * m->showbar * 2;
m->wy = m->showbar ? m->wy + bh + gappx : m->wy;
if (m->showbar) { if (m->showbar) {
m->by = m->topbar ? m->wy - bh - gappx : m->wy + m->wh + gappx; m->wh -= bh;
m->eby = m->topbar ? m->wy + m->wh - gappx : m->wy - bh - gappx * 2; m->by = m->topbar ? m->wy : m->wy + m->wh;
m->wy = topbar ? m->wy : m->wy - gappx * 2; m->wy = m->topbar ? m->wy + bh : m->wy;
m->wh = topbar ? m->wh - gappx * 2 : m->wh + gappx * 2; } else
} else { m->by = -bh;
m->by = -bh - gappx;
m->eby = -bh + gappx;
}
} }
void void
@ -2150,20 +2005,8 @@ updatesizehints(Client *c)
void void
updatestatus(void) updatestatus(void)
{ {
char text[2048]; if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
if (!gettextprop(root, XA_WM_NAME, text, sizeof(text))) {
strcpy(stext, "dwm-"VERSION); strcpy(stext, "dwm-"VERSION);
estext[0] = '\0';
} else {
char *e = strchr(text, statussep);
if (e) {
*e = '\0'; e++;
strncpy(estext, e, sizeof(estext) - 1);
} else {
estext[0] = '\0';
}
strncpy(stext, text, sizeof(stext) - 1);
}
drawbar(selmon); drawbar(selmon);
} }
@ -2242,7 +2085,7 @@ wintomon(Window w)
if (w == root && getrootptr(&x, &y)) if (w == root && getrootptr(&x, &y))
return recttomon(x, y, 1, 1); return recttomon(x, y, 1, 1);
for (m = mons; m; m = m->next) for (m = mons; m; m = m->next)
if (w == m->barwin || w == m->extrabarwin) if (w == m->barwin)
return m; return m;
if ((c = wintoclient(w))) if ((c = wintoclient(w)))
return c->mon; return c->mon;
@ -2318,8 +2161,5 @@ main(int argc, char *argv[])
run(); run();
cleanup(); cleanup();
XCloseDisplay(dpy); XCloseDisplay(dpy);
if (restart == 1) {
execlp("dwm", "dwm", NULL);
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

BIN
dwm.o

Binary file not shown.

107
layouts.c
View File

@ -1,44 +1,30 @@
// TODO: FIX GAPS IN GRID LAYOUT
void void
tile(Monitor *m) grid(Monitor *m) {
{ unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows;
unsigned int i, n, h, mw, my, ty;
Client *c; Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next))
if (n == 0) n++;
return;
if (n > m->nmaster) /* grid dimensions */
mw = m->nmaster ? m->ww * m->mfact : 0; for(rows = 0; rows <= n/2; rows++)
else if(rows*rows >= n)
mw = m->ww - gappx; break;
for (i = 0, my = ty = gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
if (i < m->nmaster) {
h = (m->wh - my) / (MIN(n, m->nmaster) - i) - gappx;
resize(c, m->wx + gappx, m->wy + my, mw - (2*c->bw) - gappx, h - (2*c->bw), 0);
if (my + HEIGHT(c) + gappx < m->wh)
my += HEIGHT(c) + gappx;
} else {
h = (m->wh - ty) / (n - i) - gappx;
resize(c, m->wx + mw + gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*gappx, h - (2*c->bw), 0);
if (ty + HEIGHT(c) + gappx < m->wh)
ty += HEIGHT(c) + gappx;
}
}
void /* window geoms (cell height/width) */
monocle(Monitor *m) ch = (m->wh - m->gappx) / (rows ? rows : 1);
{ cw = (m->ww - m->gappx) / (cols ? cols : 1);
unsigned int n = 0; for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
Client *c; cx = m->wx + (i / rows) * cw;
cy = m->wy + (i % rows) * ch;
for (c = m->clients; c; c = c->next) /* adjust height/width of last row/column's windows */
if (ISVISIBLE(c)) ah = ((i + 1) % rows == 0) ? m->wh - m->gappx * (rows + 1) - ch * rows : 0;
n++; aw = (i >= rows * (cols - 1)) ? m->ww - m->gappx * (cols + 1) - cw * cols : 0;
if (n > 0) /* override layout symbol */ resize(c, cx + m->gappx * (i / rows + 1), cy + m->gappx * (i % rows + 1), cw - 2 * c->bw + aw, ch - 2 * c->bw + ah, False);
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); i++;
for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) }
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
} }
void void
@ -59,16 +45,16 @@ gaplessgrid(Monitor *m) {
rows = n/cols; rows = n/cols;
/* window geometries */ /* window geometries */
cw = cols ? (m->ww - gappx) / cols : m->ww - gappx; cw = cols ? (m->ww - m->gappx) / cols : m->ww - m->gappx;
cn = 0; /* current column number */ cn = 0; /* current column number */
rn = 0; /* current row number */ rn = 0; /* current row number */
for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) { for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
if(i/rows + 1 > cols - n%cols) if(i/rows + 1 > cols - n%cols)
rows = n/cols + 1; rows = n/cols + 1;
ch = rows ? (m->wh - gappx) / rows : m->wh - gappx; ch = rows ? (m->wh - m->gappx) / rows : m->wh - m->gappx;
cx = m->wx + cn*cw; cx = m->wx + cn*cw;
cy = m->wy + rn*ch; cy = m->wy + rn*ch;
resize(c, cx + gappx, cy + gappx, cw - 2 * c->bw - gappx, ch - 2 * c->bw - gappx, False); resize(c, cx + m->gappx, cy + m->gappx, cw - 2 * c->bw - m->gappx, ch - 2 * c->bw - m->gappx, False);
rn++; rn++;
if(rn >= rows) { if(rn >= rows) {
rn = 0; rn = 0;
@ -76,3 +62,46 @@ gaplessgrid(Monitor *m) {
} }
} }
} }
void
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++);
if (n == 0)
return;
if (n > m->nmaster)
mw = m->nmaster ? m->ww * m->mfact : 0;
else
mw = m->ww - m->gappx;
for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
if (my + HEIGHT(c) + m->gappx < m->wh)
my += HEIGHT(c) + m->gappx;
} else {
h = (m->wh - ty) / (n - i) - m->gappx;
resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
if (ty + HEIGHT(c) + m->gappx < m->wh)
ty += HEIGHT(c) + m->gappx;
}
}
void
monocle(Monitor *m)
{
unsigned int n = 0;
Client *c;
for (c = m->clients; c; c = c->next)
if (ISVISIBLE(c))
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))
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
}