diff --git a/Makefile b/Makefile index c05dbdd..ffa69b4 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,7 @@ include config.mk SRC = drw.c dwm.c util.c OBJ = ${SRC:.c=.o} -all: options dwm - -options: - @echo dwm build options: - @echo "CFLAGS = ${CFLAGS}" - @echo "LDFLAGS = ${LDFLAGS}" - @echo "CC = ${CC}" +all: dwm .c.o: ${CC} -c ${CFLAGS} $< @@ -26,7 +20,7 @@ dwm: ${OBJ} ${CC} -o $@ ${OBJ} ${LDFLAGS} clean: - rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz config.h + rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz dist: clean mkdir -p dwm-${VERSION} @@ -48,4 +42,4 @@ uninstall: rm -f ${DESTDIR}${PREFIX}/bin/dwm\ ${DESTDIR}${MANPREFIX}/man1/dwm.1 -.PHONY: all options clean dist install uninstall +.PHONY: all clean dist install uninstall diff --git a/PATCHES b/PATCHES new file mode 100644 index 0000000..28ce814 --- /dev/null +++ b/PATCHES @@ -0,0 +1,4 @@ +fullgaps +status2d +extrabar +gaplessgrid diff --git a/config.def.h b/config.def.h index 81ba959..9efa774 100644 --- a/config.def.h +++ b/config.def.h @@ -1,74 +1,34 @@ /* See LICENSE file for copyright and license details. */ -#include - /* appearance */ - -static const unsigned int borderpx = 4; -static const unsigned int gappx = 15; +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 showextrabar = 1; /* 0 means no bar */ -// TODO: FIX THAT SHIT static const int topbar = 1; /* 0 means bottom bar */ -static const char statussep = ';'; -static const int horizpadbar = 8; -static const int vertpadbar = 12; -static const int vertpadstat = 0; -static const char *fonts[] = { - "Ubuntu Mono:style=Bold:size=12:antialias=true:autohint=true", - "Font Awesome 6 Free Solid:style=Solid:size=12:antialias=true:autohint=true", - "Font Awesome 6 Brands Regular:style=Regular:size=12:antialias=true:autohint=true" -}; -static char dmenufont[] = "Ubuntu Mono:size=12"; -static char normbgcolor[] = "#222222"; -static char normbordercolor[] = "#444444"; -static char normfgcolor[] = "#bbbbbb"; -static char selfgcolor[] = "#eeeeee"; -static char selbordercolor[] = "#005577"; -static char selbgcolor[] = "#005577"; -static char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, - [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, +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 }, }; /* tagging */ -static const char *tags[] = { "", "", "", "", "", "", "", "", "", "0", "-", "=" }; -static const int taglayouts[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +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 */ - // ----- 1 ----- - { "st-256color", NULL, NULL, 0, 0, -1 }, - // ----- 2 ----- - { "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 }, -// { NULL, NULL, "broken", 1 << 9, 0, -1 }, + /* class instance title tags mask isfloating monitor */ + { "Gimp", NULL, NULL, 0, 1, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, }; /* layout(s) */ @@ -77,108 +37,80 @@ 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 */ -#include "layouts.c" static const Layout layouts[] = { /* symbol arrange function */ - { "###", gaplessgrid }, { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, - { "HHH", grid }, }; /* key definitions */ -#define SUPERKEY Mod4Mask -#define ALTKEY Mod1Mask - +#define MODKEY Mod1Mask #define TAGKEYS(KEY,TAG) \ - { SUPERKEY, KEY, view, {.ui = 1 << TAG} }, \ - { SUPERKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ - { SUPERKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ - { SUPERKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << 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 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 const char *lockcmd[] = { "slock", NULL }; - -static const char *dmenucmd[] = { "dmenu_run", "-g", "15", "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL }; +static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ +static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *termcmd[] = { "st", NULL }; static const Key keys[] = { - /* modifier key function argument */ - { 0, XF86XK_ModeLock, spawn, {.v = lockcmd } }, - { 0, XK_Print, spawn, {.v = screenshot } }, - { ShiftMask, XK_Print, spawn, {.v = screenshotarea } }, - { 0, XF86XK_AudioRaiseVolume, spawn, {.v = volup } }, - { 0, XF86XK_AudioLowerVolume, spawn, {.v = voldown } }, - { 0, XF86XK_MonBrightnessUp, spawn, {.v = backlightup } }, - { 0, XF86XK_MonBrightnessDown, spawn, {.v = backlightdown } }, - { 0, XF86XK_AudioMute, spawn, {.v = volmute } }, - { SUPERKEY, XK_d, spawn, {.v = dmenucmd } }, - { SUPERKEY, XK_Return, spawn, {.v = termcmd } }, - { SUPERKEY, XK_b, togglebar, {.i = 1} }, - { SUPERKEY|ShiftMask, XK_b, togglebar, {.i = 2} }, - { ALTKEY, XK_Tab, focusstack, {.i = +1 } }, - { SUPERKEY, XK_i, incnmaster, {.i = +1 } }, - { SUPERKEY, XK_p, incnmaster, {.i = -1 } }, - { SUPERKEY, XK_o, setmfact, {.f = -0.05} }, - { SUPERKEY, XK_l, setmfact, {.f = +0.05} }, - { SUPERKEY|ShiftMask, XK_Return, zoom, {0} }, - { SUPERKEY, XK_q, killclient, {0} }, - { SUPERKEY, XK_t, setlayout, {.v = &layouts[1]} }, - { SUPERKEY, XK_f, setlayout, {.v = &layouts[2]} }, - { SUPERKEY, XK_m, setlayout, {.v = &layouts[3]} }, - { SUPERKEY|ShiftMask, XK_g, setlayout, {.v = &layouts[4]} }, - { SUPERKEY, XK_g, setlayout, {.v = &layouts[0]} }, - { SUPERKEY|ShiftMask, XK_space, togglefloating, {0} }, -// { SUPERKEY, XK_comma, focusmon, {.i = -1 } }, -// { SUPERKEY, XK_period, focusmon, {.i = +1 } }, -// { SUPERKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, -// { SUPERKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, -// { SUPERKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, - { SUPERKEY|ShiftMask, XK_t, togglealwaysontop, {0} }, - { SUPERKEY|ShiftMask, XK_f, togglefullscr, {0} }, - { SUPERKEY, XK_F5, xrdb, {.v = NULL } }, - TAGKEYS( XK_1, 0) - TAGKEYS( XK_2, 1) - TAGKEYS( XK_3, 2) - TAGKEYS( XK_4, 3) - TAGKEYS( XK_5, 4) - TAGKEYS( XK_6, 5) - TAGKEYS( XK_7, 6) - TAGKEYS( XK_8, 7) - TAGKEYS( XK_9, 8) - TAGKEYS( XK_0, 9) - TAGKEYS( XK_minus, 10) - TAGKEYS( XK_equal, 11) - { SUPERKEY|ShiftMask, XK_q, quitprompt, {0} }, + /* modifier key function argument */ + { MODKEY, XK_p, spawn, {.v = dmenucmd } }, + { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY, XK_i, incnmaster, {.i = +1 } }, + { MODKEY, XK_d, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, 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, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) + TAGKEYS( XK_4, 3) + TAGKEYS( XK_5, 4) + TAGKEYS( XK_6, 5) + TAGKEYS( XK_7, 6) + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) + { MODKEY|ShiftMask, XK_q, quit, {0} }, }; /* 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]} }, - { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, - { ClkClientWin, SUPERKEY, Button1, movemouse, {0} }, - { ClkClientWin, SUPERKEY, Button2, togglefloating, {0} }, - { ClkClientWin, SUPERKEY, Button3, resizemouse, {0} }, - { ClkTagBar, 0, Button1, view, {0} }, - { ClkTagBar, 0, Button3, toggleview, {0} }, - { ClkTagBar, SUPERKEY, Button1, tag, {0} }, - { ClkTagBar, SUPERKEY, Button3, toggletag, {0} }, + /* click event mask button function argument */ + { ClkLtSymbol, 0, Button1, setlayout, {0} }, + { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, + { 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} }, }; diff --git a/config.h b/config.h index 81ba959..9efa774 100644 --- a/config.h +++ b/config.h @@ -1,74 +1,34 @@ /* See LICENSE file for copyright and license details. */ -#include - /* appearance */ - -static const unsigned int borderpx = 4; -static const unsigned int gappx = 15; +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 showextrabar = 1; /* 0 means no bar */ -// TODO: FIX THAT SHIT static const int topbar = 1; /* 0 means bottom bar */ -static const char statussep = ';'; -static const int horizpadbar = 8; -static const int vertpadbar = 12; -static const int vertpadstat = 0; -static const char *fonts[] = { - "Ubuntu Mono:style=Bold:size=12:antialias=true:autohint=true", - "Font Awesome 6 Free Solid:style=Solid:size=12:antialias=true:autohint=true", - "Font Awesome 6 Brands Regular:style=Regular:size=12:antialias=true:autohint=true" -}; -static char dmenufont[] = "Ubuntu Mono:size=12"; -static char normbgcolor[] = "#222222"; -static char normbordercolor[] = "#444444"; -static char normfgcolor[] = "#bbbbbb"; -static char selfgcolor[] = "#eeeeee"; -static char selbordercolor[] = "#005577"; -static char selbgcolor[] = "#005577"; -static char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, - [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, +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 }, }; /* tagging */ -static const char *tags[] = { "", "", "", "", "", "", "", "", "", "0", "-", "=" }; -static const int taglayouts[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +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 */ - // ----- 1 ----- - { "st-256color", NULL, NULL, 0, 0, -1 }, - // ----- 2 ----- - { "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 }, -// { NULL, NULL, "broken", 1 << 9, 0, -1 }, + /* class instance title tags mask isfloating monitor */ + { "Gimp", NULL, NULL, 0, 1, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, }; /* layout(s) */ @@ -77,108 +37,80 @@ 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 */ -#include "layouts.c" static const Layout layouts[] = { /* symbol arrange function */ - { "###", gaplessgrid }, { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, - { "HHH", grid }, }; /* key definitions */ -#define SUPERKEY Mod4Mask -#define ALTKEY Mod1Mask - +#define MODKEY Mod1Mask #define TAGKEYS(KEY,TAG) \ - { SUPERKEY, KEY, view, {.ui = 1 << TAG} }, \ - { SUPERKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ - { SUPERKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ - { SUPERKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << 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 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 const char *lockcmd[] = { "slock", NULL }; - -static const char *dmenucmd[] = { "dmenu_run", "-g", "15", "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL }; +static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ +static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *termcmd[] = { "st", NULL }; static const Key keys[] = { - /* modifier key function argument */ - { 0, XF86XK_ModeLock, spawn, {.v = lockcmd } }, - { 0, XK_Print, spawn, {.v = screenshot } }, - { ShiftMask, XK_Print, spawn, {.v = screenshotarea } }, - { 0, XF86XK_AudioRaiseVolume, spawn, {.v = volup } }, - { 0, XF86XK_AudioLowerVolume, spawn, {.v = voldown } }, - { 0, XF86XK_MonBrightnessUp, spawn, {.v = backlightup } }, - { 0, XF86XK_MonBrightnessDown, spawn, {.v = backlightdown } }, - { 0, XF86XK_AudioMute, spawn, {.v = volmute } }, - { SUPERKEY, XK_d, spawn, {.v = dmenucmd } }, - { SUPERKEY, XK_Return, spawn, {.v = termcmd } }, - { SUPERKEY, XK_b, togglebar, {.i = 1} }, - { SUPERKEY|ShiftMask, XK_b, togglebar, {.i = 2} }, - { ALTKEY, XK_Tab, focusstack, {.i = +1 } }, - { SUPERKEY, XK_i, incnmaster, {.i = +1 } }, - { SUPERKEY, XK_p, incnmaster, {.i = -1 } }, - { SUPERKEY, XK_o, setmfact, {.f = -0.05} }, - { SUPERKEY, XK_l, setmfact, {.f = +0.05} }, - { SUPERKEY|ShiftMask, XK_Return, zoom, {0} }, - { SUPERKEY, XK_q, killclient, {0} }, - { SUPERKEY, XK_t, setlayout, {.v = &layouts[1]} }, - { SUPERKEY, XK_f, setlayout, {.v = &layouts[2]} }, - { SUPERKEY, XK_m, setlayout, {.v = &layouts[3]} }, - { SUPERKEY|ShiftMask, XK_g, setlayout, {.v = &layouts[4]} }, - { SUPERKEY, XK_g, setlayout, {.v = &layouts[0]} }, - { SUPERKEY|ShiftMask, XK_space, togglefloating, {0} }, -// { SUPERKEY, XK_comma, focusmon, {.i = -1 } }, -// { SUPERKEY, XK_period, focusmon, {.i = +1 } }, -// { SUPERKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, -// { SUPERKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, -// { SUPERKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, - { SUPERKEY|ShiftMask, XK_t, togglealwaysontop, {0} }, - { SUPERKEY|ShiftMask, XK_f, togglefullscr, {0} }, - { SUPERKEY, XK_F5, xrdb, {.v = NULL } }, - TAGKEYS( XK_1, 0) - TAGKEYS( XK_2, 1) - TAGKEYS( XK_3, 2) - TAGKEYS( XK_4, 3) - TAGKEYS( XK_5, 4) - TAGKEYS( XK_6, 5) - TAGKEYS( XK_7, 6) - TAGKEYS( XK_8, 7) - TAGKEYS( XK_9, 8) - TAGKEYS( XK_0, 9) - TAGKEYS( XK_minus, 10) - TAGKEYS( XK_equal, 11) - { SUPERKEY|ShiftMask, XK_q, quitprompt, {0} }, + /* modifier key function argument */ + { MODKEY, XK_p, spawn, {.v = dmenucmd } }, + { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY, XK_i, incnmaster, {.i = +1 } }, + { MODKEY, XK_d, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, 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, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) + TAGKEYS( XK_4, 3) + TAGKEYS( XK_5, 4) + TAGKEYS( XK_6, 5) + TAGKEYS( XK_7, 6) + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) + { MODKEY|ShiftMask, XK_q, quit, {0} }, }; /* 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]} }, - { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, - { ClkClientWin, SUPERKEY, Button1, movemouse, {0} }, - { ClkClientWin, SUPERKEY, Button2, togglefloating, {0} }, - { ClkClientWin, SUPERKEY, Button3, resizemouse, {0} }, - { ClkTagBar, 0, Button1, view, {0} }, - { ClkTagBar, 0, Button3, toggleview, {0} }, - { ClkTagBar, SUPERKEY, Button1, tag, {0} }, - { ClkTagBar, SUPERKEY, Button3, toggletag, {0} }, + /* click event mask button function argument */ + { ClkLtSymbol, 0, Button1, setlayout, {0} }, + { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, + { 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} }, }; diff --git a/config.mk b/config.mk index 497a567..8efca9a 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,5 @@ # dwm version -VERSION = bit_1.1 +VERSION = 6.5 # Customize below to fit your system @@ -26,7 +26,7 @@ INCS = -I${X11INC} -I${FREETYPEINC} LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} # flags -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} LDFLAGS = ${LIBS} diff --git a/drw.c b/drw.c index f8a82f5..a58a2b4 100644 --- a/drw.c +++ b/drw.c @@ -195,7 +195,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname) /* 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, char *clrnames[], size_t clrcount) +drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) { size_t i; Clr *ret; diff --git a/drw.h b/drw.h index bdbf950..6471431 100644 --- a/drw.h +++ b/drw.h @@ -40,7 +40,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, char *clrnames[], size_t clrcount); +Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); /* Cursor abstraction */ Cur *drw_cur_create(Drw *drw, int shape); diff --git a/dwm b/dwm index 41343c5..42f76ca 100755 Binary files a/dwm and b/dwm differ diff --git a/dwm.c b/dwm.c index 6d05335..f1d86b2 100644 --- a/dwm.c +++ b/dwm.c @@ -1,4 +1,3 @@ - /* See LICENSE file for copyright and license details. * * dynamic window manager is designed like any other X client as well. It is @@ -36,7 +35,6 @@ #include #include #include -#include #include #ifdef XINERAMA #include @@ -58,21 +56,6 @@ #define HEIGHT(X) ((X)->h + 2 * (X)->bw) #define TAGMASK ((1 << LENGTH(tags)) - 1) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) -#define XRDB_LOAD_COLOR(R,V) if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \ - if (value.addr != NULL && strnlen(value.addr, 8) == 7 && value.addr[0] == '#') { \ - int i = 1; \ - for (; i <= 6; i++) { \ - if (value.addr[i] < 48) break; \ - if (value.addr[i] > 57 && value.addr[i] < 65) break; \ - if (value.addr[i] > 70 && value.addr[i] < 97) break; \ - if (value.addr[i] > 102) break; \ - } \ - if (i == 7) { \ - strncpy(V, value.addr, 7); \ - V[7] = '\0'; \ - } \ - } \ - } /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ @@ -81,8 +64,8 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ -enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkClientWin, - ClkRootWin, ClkLast }; /* clicks */ +enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, + ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ typedef union { int i; @@ -109,7 +92,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int bw, oldbw; unsigned int tags; - int isfixed, iscentered, isfloating, isalwaysontop, isurgent, neverfocus, oldstate, isfullscreen; + int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; Client *next; Client *snext; Monitor *mon; @@ -128,31 +111,25 @@ typedef struct { void (*arrange)(Monitor *); } Layout; -typedef struct Pertag Pertag; struct Monitor { char ltsymbol[16]; float mfact; int nmaster; int num; int by; /* bar geometry */ - int eby; /* bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ - int gappx; unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; int showbar; - int showextrabar; int topbar; Client *clients; Client *sel; Client *stack; Monitor *next; Window barwin; - Window extrabarwin; const Layout *lt[2]; - Pertag *pertag; }; typedef struct { @@ -186,7 +163,6 @@ static void detachstack(Client *c); static Monitor *dirtomon(int dir); static void drawbar(Monitor *m); static void drawbars(void); -static int drawstatusbar(Monitor *m, int bh, int extra, char* text); static void enternotify(XEvent *e); static void expose(XEvent *e); static void focus(Client *c); @@ -202,17 +178,16 @@ static void grabkeys(void); static void incnmaster(const Arg *arg); static void keypress(XEvent *e); static void killclient(const Arg *arg); -static void loadxrdb(void); static void manage(Window w, XWindowAttributes *wa); static void mappingnotify(XEvent *e); 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 void pop(Client *c); static void propertynotify(XEvent *e); static void quit(const Arg *arg); -static void quitprompt(const Arg *arg); 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 resizeclient(Client *c, int x, int y, int w, int h); @@ -225,20 +200,17 @@ static void sendmon(Client *c, Monitor *m); static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); -static void setgaps(const Arg *arg); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); static void showhide(Client *c); -static void sigchld(int unused); static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); +static void tile(Monitor *m); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); -static void togglefullscr(const Arg *arg); -static void togglealwaysontop(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); static void unfocus(Client *c, int setfocus); @@ -255,23 +227,20 @@ static void updatetitle(Client *c); static void updatewindowtype(Client *c); static void updatewmhints(Client *c); static void view(const Arg *arg); -static Client *wintoclient(Window w);static Monitor *wintomon(Window w); +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 xrdb(const Arg *arg); static void zoom(const Arg *arg); /* variables */ static const char broken[] = "broken"; -static char stext[1024]; -static char estext[2048]; +static char stext[256]; static int screen; static int sw, sh; /* X display screen geometry width, height */ static int bh; /* bar height */ static int lrpad; /* sum of left and right padding for text */ -static int vpb; -static int hpb; static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int numlockmask = 0; static void (*handler[LASTEvent]) (XEvent *) = { @@ -292,7 +261,6 @@ static void (*handler[LASTEvent]) (XEvent *) = { }; static Atom wmatom[WMLast], netatom[NetLast]; static int running = 1; -static int restart = 1; static Cur *cursor[CurLast]; static Clr **scheme; static Display *dpy; @@ -303,15 +271,6 @@ static Window root, wmcheckwin; /* 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]; }; @@ -480,11 +439,12 @@ buttonpress(XEvent *e) if (i < LENGTH(tags)) { click = ClkTagBar; arg.ui = 1 << i; - } else if (ev->x < x + TEXTW(selmon->ltsymbol)) { + } else if (ev->x < x + TEXTW(selmon->ltsymbol)) click = ClkLtSymbol; - } else if (ev->x > selmon->ww - TEXTW(selmon->ltsymbol)) { + else if (ev->x > selmon->ww - (int)TEXTW(stext)) click = ClkStatusText; - } + else + click = ClkWinTitle; } else if ((c = wintoclient(ev->window))) { focus(c); restack(selmon); @@ -526,7 +486,7 @@ cleanup(void) cleanupmon(mons); for (i = 0; i < CurLast; 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); XDestroyWindow(dpy, wmcheckwin); @@ -548,9 +508,7 @@ cleanupmon(Monitor *mon) m->next = mon->next; } XUnmapWindow(dpy, mon->barwin); - XUnmapWindow(dpy, mon->extrabarwin); XDestroyWindow(dpy, mon->barwin); - XDestroyWindow(dpy, mon->extrabarwin); free(mon); } @@ -612,8 +570,7 @@ configurenotify(XEvent *e) for (c = m->clients; c; c = c->next) if (c->isfullscreen) resizeclient(c, m->mx, m->my, m->mw, m->mh); - XMoveResizeWindow(dpy, m->barwin, m->wx + hpb, m->by + vpb, m->ww - 2 * hpb, bh); - XMoveResizeWindow(dpy, m->extrabarwin, m->wx + hpb, m->eby - vpb, m->ww - 2 * hpb, bh); + XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); } focus(NULL); arrange(NULL); @@ -677,43 +634,16 @@ Monitor * createmon(void) { Monitor *m; - unsigned int i; m = ecalloc(1, sizeof(Monitor)); m->tagset[0] = m->tagset[1] = 1; m->mfact = mfact; m->nmaster = nmaster; - m->showbar = showbar; - m->showextrabar = showextrabar; + m->showbar = showbar; m->topbar = topbar; - m->gappx = gappx; -// 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]; - if (i >= 1) { - m->pertag->ltidxs[i][0] = &layouts[taglayouts[i-1]]; - } - else { - m->pertag->ltidxs[i][0] = &layouts[0]; - } - m->pertag->ltidxs[i][1] = m->lt[1]; - m->pertag->sellts[i] = m->sellt; - - m->pertag->showbars[i] = m->showbar; - } - - m->lt[0] = m->pertag->ltidxs[1][0]; + m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; - strncpy(m->ltsymbol, m->pertag->ltidxs[1][0]->symbol, sizeof m->ltsymbol); - + strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); return m; } @@ -765,241 +695,24 @@ dirtomon(int dir) return m; } -int -drawstatusbar(Monitor *m, int bh, int extra, char* stext) { - int ret, i, w, w2, x, x2, len, len2; - short isCode = 0, isCode2 = 0; - char *text, *text2; - char *p, *p2; - char stext2[1024]; - - char *st = strchr(stext, statussep); - if (st) { - *st = '\0'; st++; - strncpy(stext2, st, sizeof(stext2) - 1); - } else { - stext2[0] = '\0'; - } - - len2 = strlen(stext2) + 1; - if (!(text2 = (char*) malloc(sizeof(char)*len2))) - die("malloc"); - - p2 = text2; - memcpy(text2, stext2, len2); - - 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) { - w2 = 0; - i = -1; - while (text2[++i]) { - if (text2[i] == '^') { - if (!isCode2) { - isCode2 = 1; - text2[i] = '\0'; - w2 += TEXTW(text2) - lrpad; - text2[i] = '^'; - if (text2[++i] == 'f') - w2 += atoi(text2 + ++i); - } else { - isCode2 = 0; - text2 = text2 + i + 1; - i = -1; - } - } - } - if (!isCode2) - w2 += TEXTW(text2) - lrpad; - else - isCode2 = 0; - text2 = p2; - } - - if (extra) { - w = m->ww; - w = m->ww - w - 2 * hpb; - ret = m->ww - w; - x = 0 - 1; - x2 = m->ww - w2 - 2 * hpb; - } else { -// w += 2; /* 1px padding on both sides */ - ret = m->ww - w; - x = ret - 2 * hpb; - } - - 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, vertpadstat, w, bh - 2 * vertpadstat, 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 (extra) { - drw_setscheme(drw, scheme[LENGTH(colors)]); - drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; - drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; - drw_rect(drw, m->ww - w2, 0, w2, bh, 1, 1); - x2++; - - i = -1; - while (text2[++i]) { - if (text2[i] == '^' && !isCode2) { - isCode2 = 1; - - text2[i] = '\0'; - w2 = TEXTW(text2) - lrpad; - drw_text(drw, x2, vertpadstat, w2, bh - 2 * vertpadstat, 0, text2, 0); - - x2 += w2; - - /* process code */ - while (text2[++i] != '^') { - if (text2[i] == 'c') { - char buf[8]; - memcpy(buf, (char*)text2+i+1, 7); - buf[7] = '\0'; - drw_clr_create(drw, &drw->scheme[ColFg], buf); - i += 7; - } else if (text2[i] == 'b') { - char buf[8]; - memcpy(buf, (char*)text2+i+1, 7); - buf[7] = '\0'; - drw_clr_create(drw, &drw->scheme[ColBg], buf); - i += 7; - } else if (text2[i] == 'd') { - drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; - drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; - } else if (text2[i] == 'r') { - int rx = atoi(text2 + ++i); - while (text2[++i] != ','); - int ry = atoi(text2 + ++i); - while (text2[++i] != ','); - int rw = atoi(text2 + ++i); - while (text2[++i] != ','); - int rh = atoi(text2 + ++i); - - drw_rect(drw, rx + x2, ry, rw, rh, 1, 0); - } else if (text2[i] == 'f') { - x2 += atoi(text2 + ++i); - } - } - - text2 = text2 + i + 1; - i=-1; - isCode2 = 0; - } - } - } - - if (!isCode) { - w = TEXTW(text) - lrpad; - drw_text(drw, x, 0, w, bh, 0, text, 0); - } - - if (!isCode2) { - w2 = TEXTW(text2) - lrpad; - drw_text(drw, m->ww - w2 - hpb * 2, 0, w2, bh, 0, text2, 0); - } - - drw_setscheme(drw, scheme[SchemeNorm]); - free(p); - - return ret; -} - void drawbar(Monitor *m) { - int x, w, tw = 0; - unsigned int i, occ = 0, urg = 0; - Client *c; + int x, w, tw = 0; + int boxs = drw->fonts->h / 9; + int boxw = drw->fonts->h / 6 + 2; + unsigned int i, occ = 0, urg = 0; + Client *c; - if (m->showbar) { - /* draw status first so it can be overdrawn by tags later */ - if (m == selmon) { /* status is only drawn on selected monitor */ - tw = m->ww - drawstatusbar(m, bh, 0, stext); - } - } + if (!m->showbar) + return; + + /* draw status first so it can be overdrawn by tags later */ + if (m == selmon) { /* status is only drawn on selected monitor */ + drw_setscheme(drw, scheme[SchemeNorm]); + tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ + drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); + } for (c = m->clients; c; c = c->next) { occ |= c->tags; @@ -1011,15 +724,10 @@ drawbar(Monitor *m) w = TEXTW(tags[i]); drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); - if (occ & 1 << i) { - drw_rect(drw, x + w / 3, 0, w / 3, 2, 0, 0); - drw_rect(drw, x + w / 3, bh - 2, w / 3, 2, 0, 0); - if (m == selmon && selmon->sel && selmon->sel->tags & 1 << i) { - drw_rect(drw, x, 0, w, 2, 0, 0); - drw_rect(drw, x, bh - 2, w, 2, 0, 0); - } - } - + if (occ & 1 << i) + drw_rect(drw, x + boxs, boxs, boxw, boxw, + m == selmon && selmon->sel && selmon->sel->tags & 1 << i, + urg & 1 << i); x += w; } w = TEXTW(m->ltsymbol); @@ -1027,20 +735,17 @@ drawbar(Monitor *m) x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); if ((w = m->ww - tw - x) > bh) { - drw_setscheme(drw, scheme[SchemeNorm]); - drw_rect(drw, x, 0, w - 2 * hpb, bh, 1, 1); + 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); + } } - - if (m->showbar) - drw_map(drw, m->barwin, 0, 0, m->ww, bh); - - if (m->showextrabar) { - if (m == selmon) { /* extra status is only drawn on selected monitor */ - sw = drawstatusbar(m, bh, 1, estext); - drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh); - } - } - + drw_map(drw, m->barwin, 0, 0, m->ww, bh); } void @@ -1249,23 +954,33 @@ grabkeys(void) { updatenumlockmask(); { - unsigned int i, j; + unsigned int i, j, k; unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; - KeyCode code; + int start, end, skip; + KeySym *syms; XUngrabKey(dpy, AnyKey, AnyModifier, root); - for (i = 0; i < LENGTH(keys); i++) - if ((code = XKeysymToKeycode(dpy, keys[i].keysym))) - for (j = 0; j < LENGTH(modifiers); j++) - XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, - True, GrabModeAsync, GrabModeAsync); + XDisplayKeycodes(dpy, &start, &end); + syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip); + if (!syms) + return; + for (k = start; k <= end; k++) + for (i = 0; i < LENGTH(keys); i++) + /* skip modifier codes, we do that ourselves */ + if (keys[i].keysym == syms[(k - start) * skip]) + for (j = 0; j < LENGTH(modifiers); j++) + XGrabKey(dpy, k, + keys[i].mod | modifiers[j], + root, True, + GrabModeAsync, GrabModeAsync); + XFree(syms); } } void incnmaster(const Arg *arg) { - selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0); + selmon->nmaster = MAX(selmon->nmaster + arg->i, 0); arrange(selmon); } @@ -1313,37 +1028,6 @@ killclient(const Arg *arg) } } -void -loadxrdb() -{ - Display *display; - char * resm; - XrmDatabase xrdb; - char *type; - XrmValue value; - - display = XOpenDisplay(NULL); - - if (display != NULL) { - resm = XResourceManagerString(display); - - if (resm != NULL) { - xrdb = XrmGetStringDatabase(resm); - - if (xrdb != NULL) { - XRDB_LOAD_COLOR("dwm.normbordercolor", normbordercolor); - XRDB_LOAD_COLOR("dwm.normbgcolor", normbgcolor); - XRDB_LOAD_COLOR("dwm.normfgcolor", normfgcolor); - XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor); - XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor); - XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor); - } - } - } - - XCloseDisplay(display); -} - void manage(Window w, XWindowAttributes *wa) { @@ -1426,6 +1110,21 @@ maprequest(XEvent *e) 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 motionnotify(XEvent *e) { @@ -1546,8 +1245,11 @@ propertynotify(XEvent *e) drawbars(); break; } - if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) + if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { updatetitle(c); + if (c == c->mon->sel) + drawbar(c->mon); + } if (ev->atom == netatom[NetWMWindowType]) updatewindowtype(c); } @@ -1559,32 +1261,6 @@ quit(const Arg *arg) running = 0; } -void -quitprompt(const Arg *arg) -{ - FILE *pp = popen("echo \"lock\nrestart\nexit\nreboot\nshutdown\" | dmenu -i -sb red -p \"exit:\"", "r"); - - char buf[16]; - - if(pp == NULL || fscanf(pp, "%15[a-zA-Z -]", buf) == EOF) { - fputs("Quitprompt: Error reading pipe!", stderr); - goto close_streams; - } - - int sysret; - - if(strcmp(buf, "lock") == 0) sysret = system("slock"); - else if(strcmp(buf, "restart") == 0) quit(&(const Arg){1}); - else if(strcmp(buf, "exit") == 0) quit(&(const Arg){0}); - else if(strcmp(buf, "reboot") == 0) sysret = system("systemctl reboot"); - else if(strcmp(buf, "shutdown") == 0) sysret = system("systemctl poweroff -i"); - - if(sysret); - -close_streams: - pclose(pp); -} - Monitor * recttomon(int x, int y, int w, int h) { @@ -1625,14 +1301,9 @@ void resizemouse(const Arg *arg) { int ocx, ocy, nw, nh; - int ocx2, ocy2, nx, ny; Client *c; Monitor *m; XEvent ev; - int horizcorner, vertcorner; - int di; - unsigned int dui; - Window dummy; Time lasttime = 0; if (!(c = selmon->sel)) @@ -1642,19 +1313,10 @@ resizemouse(const Arg *arg) restack(selmon); ocx = c->x; ocy = c->y; - ocx2 = c->x + c->w; - ocy2 = c->y + c->h; if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess) return; -// XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); - if (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui)) - 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)); + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); do { XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); switch(ev.type) { @@ -1668,13 +1330,8 @@ resizemouse(const Arg *arg) continue; lasttime = ev.xmotion.time; -// nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); -// nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); - nx = horizcorner ? ev.xmotion.x : c->x; - ny = vertcorner ? ev.xmotion.y : c->y; - 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); - + nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); + nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); 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) { @@ -1683,15 +1340,11 @@ resizemouse(const Arg *arg) togglefloating(NULL); } if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) -// resize(c, c->x, c->y, nw, nh, 1); - resize(c, nx, ny, nw, nh, 1); + resize(c, c->x, c->y, nw, nh, 1); break; } } while (ev.type != ButtonRelease); -// XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); - 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)); + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); XUngrabPointer(dpy, CurrentTime); while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { @@ -1713,17 +1366,6 @@ restack(Monitor *m) return; if (m->sel->isfloating || !m->lt[m->sellt]->arrange) XRaiseWindow(dpy, m->sel->win); - - /* raise the aot window */ - for(Monitor *m_search = mons; m_search; m_search = m_search->next){ - for(c = m_search->clients; c; c = c->next){ - if(c->isalwaysontop){ - XRaiseWindow(dpy, c->win); - break; - } - } - } - if (m->lt[m->sellt]->arrange) { wc.stack_mode = Below; wc.sibling = m->barwin; @@ -1865,24 +1507,13 @@ setfullscreen(Client *c, int fullscreen) } } -void -setgaps(const Arg *arg) -{ - if ((arg->i == 0) || (selmon->gappx + arg->i < 0)) { - selmon->gappx = 0; - } else { - selmon->gappx += arg->i; - } - arrange(selmon); -} - void setlayout(const Arg *arg) { if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) - selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1; + selmon->sellt ^= 1; if (arg && arg->v) - selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v; + selmon->lt[selmon->sellt] = (Layout *)arg->v; strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); if (selmon->sel) arrange(selmon); @@ -1901,7 +1532,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 = selmon->pertag->mfacts[selmon->pertag->curtag] = f; + selmon->mfact = f; arrange(selmon); } @@ -1911,9 +1542,16 @@ setup(void) int i; XSetWindowAttributes wa; Atom utf8string; + struct sigaction sa; - /* clean up any zombies immediately */ - sigchld(0); + /* do not transform children into zombies when they terminate */ + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT | SA_RESTART; + sa.sa_handler = SIG_IGN; + sigaction(SIGCHLD, &sa, NULL); + + /* clean up any zombies (inherited from .xinitrc etc) immediately */ + while (waitpid(-1, NULL, WNOHANG) > 0); /* init screen */ screen = DefaultScreen(dpy); @@ -1923,10 +1561,8 @@ setup(void) drw = drw_create(dpy, screen, root, sw, sh); if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) die("no fonts could be loaded."); - lrpad = drw->fonts->h + horizpadbar; - bh = drw->fonts->h + vertpadbar; - hpb = gappx; - vpb = (topbar == 1) ? gappx : -gappx; + lrpad = drw->fonts->h; + bh = drw->fonts->h + 2; updategeom(); /* init atoms */ utf8string = XInternAtom(dpy, "UTF8_STRING", False); @@ -1948,8 +1584,7 @@ setup(void) cursor[CurResize] = drw_cur_create(drw, XC_sizing); cursor[CurMove] = drw_cur_create(drw, XC_fleur); /* init appearance */ - scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *)); - scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3); + scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); for (i = 0; i < LENGTH(colors); i++) scheme[i] = drw_scm_create(drw, colors[i], 3); /* init bars */ @@ -2009,21 +1644,23 @@ showhide(Client *c) } } -void -sigchld(int unused) -{ - if (signal(SIGCHLD, sigchld) == SIG_ERR) - die("can't install SIGCHLD handler:"); - while (0 < waitpid(-1, NULL, WNOHANG)); -} - void spawn(const Arg *arg) { + struct sigaction sa; + + if (arg->v == dmenucmd) + dmenumon[0] = '0' + selmon->num; if (fork() == 0) { if (dpy) close(ConnectionNumber(dpy)); setsid(); + + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = SIG_DFL; + sigaction(SIGCHLD, &sa, NULL); + execvp(((char **)arg->v)[0], (char **)arg->v); die("dwm: execvp '%s' failed:", ((char **)arg->v)[0]); } @@ -2047,20 +1684,40 @@ tagmon(const Arg *arg) 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 togglebar(const Arg *arg) { - if (arg->i == 1 || arg->i == 0) { - selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar; - updatebarpos(selmon); - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + hpb, selmon->by + vpb, selmon->ww - 2 * hpb, bh); - } - if (arg->i == 2 || arg->i == 0) { - selmon->showextrabar = !selmon->showextrabar; - updatebarpos(selmon); - XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + hpb, selmon->eby - vpb, selmon->ww - 2 * hpb, bh); - } - + selmon->showbar = !selmon->showbar; + updatebarpos(selmon); + XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); arrange(selmon); } @@ -2075,38 +1732,6 @@ togglefloating(const Arg *arg) if (selmon->sel->isfloating) resize(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h, 0); - else - selmon->sel->isalwaysontop = 0; /* disabled, turn this off too */ - arrange(selmon); -} - -void -togglefullscr(const Arg *arg) -{ - if(selmon->sel) - setfullscreen(selmon->sel, !selmon->sel->isfullscreen); -} - -void -togglealwaysontop(const Arg *arg) -{ - if (!selmon->sel) - return; - if (selmon->sel->isfullscreen) - return; - - if(selmon->sel->isalwaysontop){ - selmon->sel->isalwaysontop = 0; - }else{ - /* disable others */ - for(Monitor *m = mons; m; m = m->next) - for(Client *c = m->clients; c; c = c->next) - c->isalwaysontop = 0; - - /* turn on, make it float too */ - selmon->sel->isfloating = 1; - selmon->sel->isalwaysontop = 1; - } arrange(selmon); } @@ -2129,33 +1754,9 @@ 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); } @@ -2225,22 +1826,14 @@ updatebars(void) }; XClassHint ch = {"dwm", "dwm"}; for (m = mons; m; m = m->next) { - if (!m->barwin) { - m->barwin = XCreateWindow(dpy, root, m->wx + hpb, m->by + vpb, m->ww - 2 * hpb, 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); - } - if (!m->extrabarwin) { - m->extrabarwin = XCreateWindow(dpy, root, m->wx + hpb, m->eby - vpb, m->ww - 2 * hpb, 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); } } @@ -2249,23 +1842,12 @@ updatebarpos(Monitor *m) { m->wy = m->my; m->wh = m->mh; - m->wh -= bh * m->showbar + bh * m->showextrabar; - m->wy = m->showbar ? m->wy + bh + vpb : m->wy; - - if (m->showbar && m->showextrabar) { - m->by = m->topbar ? m->wy - gappx - bh : m->wy + m->wh + gappx; - m->eby = m->topbar ? m->wy + m->wh + gappx - vpb * 2 : m->wy - gappx - bh - vpb * 2; - m->wy = topbar ? m->wy : m->wy - vpb * 2; - m->wh = topbar ? m->wh - vpb * 2 : m->wh + vpb * 2; - } else if (m->showbar || m->showextrabar) { - m->by = m->topbar ? m->wy - gappx - bh : m->wy + m->wh + gappx; - m->eby = m->topbar ? m->wy + m->wh + gappx - vpb : m->wy - gappx - bh - vpb; - m->wy = topbar ? m->wy : m->wy - vpb; - m->wh = topbar ? m->wh - vpb: m->wh + vpb; - } else { - m->by = -bh - vpb; - m->eby = -bh + vpb; - } + if (m->showbar) { + m->wh -= bh; + m->by = m->topbar ? m->wy : m->wy + m->wh; + m->wy = m->topbar ? m->wy + bh : m->wy; + } else + m->by = -bh; } void @@ -2423,22 +2005,8 @@ updatesizehints(Client *c) void updatestatus(void) { - char text[3072]; - if (!gettextprop(root, XA_WM_NAME, text, sizeof(text))) { + if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) 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); } @@ -2485,38 +2053,11 @@ updatewmhints(Client *c) void view(const Arg *arg) { - int i; - unsigned int tmptag; - if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) return; selmon->seltags ^= 1; /* toggle sel tagset */ - if (arg->ui & TAGMASK) { + if (arg->ui & TAGMASK) selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; - 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); - focus(NULL); arrange(selmon); } @@ -2544,7 +2085,7 @@ wintomon(Window w) if (w == root && getrootptr(&x, &y)) return recttomon(x, y, 1, 1); for (m = mons; m; m = m->next) - if (w == m->barwin || w == m->extrabarwin) + if (w == m->barwin) return m; if ((c = wintoclient(w))) return c->mon; @@ -2557,11 +2098,6 @@ wintomon(Window w) int xerror(Display *dpy, XErrorEvent *ee) { - int opcode, event, error; - if(XQueryExtension(dpy, "RENDER", &opcode, &event, &error) - || (ee->request_code == opcode && ee->error_code == BadLength)) - return 0; - if (ee->error_code == BadWindow || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable) @@ -2592,17 +2128,6 @@ xerrorstart(Display *dpy, XErrorEvent *ee) return -1; } -void -xrdb(const Arg *arg) -{ - loadxrdb(); - int i; - for (i = 0; i < LENGTH(colors); i++) - scheme[i] = drw_scm_create(drw, colors[i], 3); - focus(NULL); - arrange(NULL); -} - void zoom(const Arg *arg) { @@ -2627,8 +2152,6 @@ main(int argc, char *argv[]) if (!(dpy = XOpenDisplay(NULL))) die("dwm: cannot open display"); checkotherwm(); - XrmInitialize(); - loadxrdb(); setup(); #ifdef __OpenBSD__ if (pledge("stdio rpath proc exec", NULL) == -1) @@ -2638,8 +2161,5 @@ main(int argc, char *argv[]) run(); cleanup(); XCloseDisplay(dpy); - if (restart == 1) { - execlp("dwm", "dwm", NULL); - } return EXIT_SUCCESS; } diff --git a/dwm.o b/dwm.o index 388545e..d36568d 100644 Binary files a/dwm.o and b/dwm.o differ