diff options
Diffstat (limited to 'wm')
| -rw-r--r-- | wm/dwm-6.3/cmd.h | 4 | ||||
| -rw-r--r-- | wm/dwm-6.3/config.def.h | 166 | ||||
| -rw-r--r-- | wm/dwm-6.3/config.h | 194 | ||||
| -rw-r--r-- | wm/dwm-6.3/patches/dwm-activetagindicatorbar-6.2.diff | 17 | ||||
| -rw-r--r-- | wm/dwm-6.3/patches/dwm-statuscmd-20210405-67d76bd.diff | 208 | ||||
| -rw-r--r-- | wm/dwm-6.3/patches/dwm-statuscmd-nosignal-20210402-67d76bd.diff | 167 | ||||
| -rw-r--r-- | wm/dwm-6.4/LICENSE (renamed from wm/dwm-6.3/LICENSE) | 1 | ||||
| -rw-r--r-- | wm/dwm-6.4/Makefile (renamed from wm/dwm-6.3/Makefile) | 1 | ||||
| -rw-r--r-- | wm/dwm-6.4/README (renamed from wm/dwm-6.3/README) | 0 | ||||
| -rw-r--r-- | wm/dwm-6.4/config.h | 189 | ||||
| -rw-r--r-- | wm/dwm-6.4/config.mk (renamed from wm/dwm-6.3/config.mk) | 13 | ||||
| -rw-r--r-- | wm/dwm-6.4/drw.c (renamed from wm/dwm-6.3/drw.c) | 179 | ||||
| -rw-r--r-- | wm/dwm-6.4/drw.h (renamed from wm/dwm-6.3/drw.h) | 9 | ||||
| -rw-r--r-- | wm/dwm-6.4/dwm.1 (renamed from wm/dwm-6.3/dwm.1) | 0 | ||||
| -rw-r--r-- | wm/dwm-6.4/dwm.c (renamed from wm/dwm-6.3/dwm.c) | 336 | ||||
| -rw-r--r-- | wm/dwm-6.4/dwm.png (renamed from wm/dwm-6.3/dwm.png) | bin | 373 -> 373 bytes | |||
| -rw-r--r-- | wm/dwm-6.4/patches/dwm-alpha-6.4.diff (renamed from wm/dwm-6.3/patches/dwm-alpha-20201019-61bb8b2.diff) | 105 | ||||
| -rw-r--r-- | wm/dwm-6.4/patches/dwm-cool-autostart-6.2.diff (renamed from wm/dwm-6.3/patches/dwm-cool-autostart-6.2.diff) | 0 | ||||
| -rw-r--r-- | wm/dwm-6.4/patches/dwm-swallow-6.3.diff (renamed from wm/dwm-6.3/patches/dwm-swallow-20201211-61bb8b2.diff) | 42 | ||||
| -rw-r--r-- | wm/dwm-6.4/patches/dwm-vanitygaps-6.2.diff (renamed from wm/dwm-6.3/patches/dwm-vanitygaps-6.2.diff) | 0 | ||||
| -rw-r--r-- | wm/dwm-6.4/patches/dwm-winicon-6.3-v2.1.diff | 371 | ||||
| -rw-r--r-- | wm/dwm-6.4/transient.c (renamed from wm/dwm-6.3/transient.c) | 0 | ||||
| -rw-r--r-- | wm/dwm-6.4/util.c (renamed from wm/dwm-6.3/util.c) | 23 | ||||
| -rw-r--r-- | wm/dwm-6.4/util.h (renamed from wm/dwm-6.3/util.h) | 0 | ||||
| -rw-r--r-- | wm/dwm-6.4/vanitygaps.c (renamed from wm/dwm-6.3/vanitygaps.c) | 106 |
25 files changed, 1070 insertions, 1061 deletions
diff --git a/wm/dwm-6.3/cmd.h b/wm/dwm-6.3/cmd.h deleted file mode 100644 index e734f59..0000000 --- a/wm/dwm-6.3/cmd.h +++ /dev/null @@ -1,4 +0,0 @@ -/* regular shell command spawner using /bin/sh */ -#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } -/* some things need bash */ -#define BASHCMD(cmd) { .v = (const char*[]){ "/bin/bash", "-c", cmd, NULL } } diff --git a/wm/dwm-6.3/config.def.h b/wm/dwm-6.3/config.def.h deleted file mode 100644 index 72aada7..0000000 --- a/wm/dwm-6.3/config.def.h +++ /dev/null @@ -1,166 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* appearance */ -static const unsigned int borderpx = 1; /* border pixel of windows */ -static const unsigned int snap = 32; /* snap pixel */ -static const int swallowfloating = 0; /* 1 means swallow floating windows by default */ -static const int showbar = 1; /* 0 means no bar */ -static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "monospace:size=10" }; -static const char dmenufont[] = "monospace:size=10"; -static const char col_gray1[] = "#222222"; -static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; -static const char col_cyan[] = "#005577"; -static const unsigned int baralpha = 0xd0; -static const unsigned int borderalpha = OPAQUE; -static const char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, -}; -static const unsigned int alphas[][3] = { - /* fg bg border */ - [SchemeNorm] = { OPAQUE, baralpha, borderalpha }, - [SchemeSel] = { OPAQUE, baralpha, borderalpha }, -}; - -static const char *const autostart[] = { - "st", NULL, - NULL /* terminate */ -}; - -/* tagging */ -static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; - -static const Rule rules[] = { - /* xprop(1): - * WM_CLASS(STRING) = instance, class - * WM_NAME(STRING) = title - */ - /* class instance title tags mask isfloating isterminal noswallow monitor */ - { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 }, - { "St", NULL, NULL, 0, 0, 1, 0, -1 }, - { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */ -}; - -/* layout(s) */ -static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ -static const int nmaster = 1; /* number of clients in master area */ -static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ -static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ - -#define FORCE_VSPLIT 1 /* nrowgrid layout: force two clients to always split vertically */ -#include "vanitygaps.c" - -static const Layout layouts[] = { - /* symbol arrange function */ - { "[]=", tile }, /* first entry is default */ - { "[M]", monocle }, - { "[@]", spiral }, - { "[\\]", dwindle }, - { "H[]", deck }, - { "TTT", bstack }, - { "===", bstackhoriz }, - { "HHH", grid }, - { "###", nrowgrid }, - { "---", horizgrid }, - { ":::", gaplessgrid }, - { "|M|", centeredmaster }, - { ">M>", centeredfloatingmaster }, - { "><>", NULL }, /* no layout function means floating behavior */ - { NULL, NULL }, -}; - -/* key definitions */ -#define MODKEY Mod1Mask -#define TAGKEYS(KEY,TAG) \ - { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ - { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, - -/* helper for spawning shell commands in the pre dwm-5.0 fashion */ -#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } - -#define STATUSBAR "dwmblocks" - -/* commands */ -static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -static const char *termcmd[] = { "st", NULL }; - -static Key keys[] = { - /* 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|Mod4Mask, XK_u, incrgaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_u, incrgaps, {.i = -1 } }, - { MODKEY|Mod4Mask, XK_i, incrigaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_i, incrigaps, {.i = -1 } }, - { MODKEY|Mod4Mask, XK_o, incrogaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_o, incrogaps, {.i = -1 } }, - { MODKEY|Mod4Mask, XK_6, incrihgaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_6, incrihgaps, {.i = -1 } }, - { MODKEY|Mod4Mask, XK_7, incrivgaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_7, incrivgaps, {.i = -1 } }, - { MODKEY|Mod4Mask, XK_8, incrohgaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_8, incrohgaps, {.i = -1 } }, - { MODKEY|Mod4Mask, XK_9, incrovgaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_9, incrovgaps, {.i = -1 } }, - { MODKEY|Mod4Mask, XK_0, togglegaps, {0} }, - { MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {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 Button buttons[] = { - /* 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, Button1, sigstatusbar, {.i = 1} }, - { ClkStatusText, 0, Button2, sigstatusbar, {.i = 2} }, - { ClkStatusText, 0, Button3, sigstatusbar, {.i = 3} }, - { 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/wm/dwm-6.3/config.h b/wm/dwm-6.3/config.h deleted file mode 100644 index fc6bb04..0000000 --- a/wm/dwm-6.3/config.h +++ /dev/null @@ -1,194 +0,0 @@ -#include "cmd.h" -/* See LICENSE file for copyright and license details. */ - -/* appearance */ -static const unsigned int borderpx = 1; /* border pixel of windows */ -static const unsigned int snap = 32; /* snap pixel */ -static const int swallowfloating = 0; /* 1 means swallow floating windows by default */ -static const int showbar = 1; /* 0 means no bar */ -static const int topbar = 1; /* 0 means bottom bar */ -static const unsigned int gappih = 10; -static const unsigned int gappiv = 10; -static const unsigned int gappoh = 10; -static const unsigned int gappov = 10; -static int smartgaps = 0; -static const char *fonts[] = { "Source Code Pro:size=9" , "NotoColorEmoji:size=8"}; -static const char dmenufont[] = "Source Code Pro:size=9"; -static const unsigned int baralpha = 0xd0; -static const unsigned int borderalpha = OPAQUE; -#include "../../colors.h" -static const char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, -}; -static const unsigned int alphas[][3] = { - /* fg bg border */ - [SchemeNorm] = { OPAQUE, baralpha, borderalpha }, - [SchemeSel] = { OPAQUE, baralpha, borderalpha }, -}; - -static const char *const autostart[] = { - "sarc.sh", "--redshift", NULL, - "xsetroot", "-name", "Loading dwmblocks...", NULL, - "dwmblocks", NULL, - "fehbg", NULL, - "unclutter", NULL, - "dunst", NULL, - "mpdas", NULL, - "picom", NULL, - NULL /* terminate */ -}; - -/* tagging */ -static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; - -static const Rule rules[] = { - /* xprop(1): - * WM_CLASS(STRING) = instance, class - * WM_NAME(STRING) = title - */ - /* class instance title tags mask isfloating isterminal noswallow monitor */ - { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 }, - { "st", NULL, NULL, 0, 0, 1, 0, -1 }, - { "Galculator", NULL, NULL, 0, 1, 0, 0, -1}, - { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */ -}; - -/* layout(s) */ -static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ -static const int nmaster = 1; /* number of clients in master area */ -static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ -static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ - -#define FORCE_VSPLIT 1 /* nrowgrid layout: force two clients to always split vertically */ -#include "vanitygaps.c" - -static const Layout layouts[] = { - /* symbol arrange function */ - { "[T]", tile }, /* first entry is default */ - { "[M]", monocle }, - { "[@]", spiral }, - { "[\\]", dwindle }, - { "H[]", deck }, - { "TTT", bstack }, - { "===", bstackhoriz }, - { "HHH", grid }, - { "###", nrowgrid }, - { "---", horizgrid }, - { ":::", gaplessgrid }, - { "|M|", centeredmaster }, - { ">M>", centeredfloatingmaster }, - { "><>", NULL }, /* no layout function means floating behavior */ - { NULL, NULL }, -}; - -#define STATUSBAR "dwmblocks" - -/* commands */ -static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -static const char *termcmd[] = { "st", NULL }; -/* key definitions */ -#define MODKEY Mod1Mask -#define WINKEY Mod4Mask -#define TAGKEYS(KEY,TAG) \ - { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ - { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, - -static Key keys[] = { - /* modifier key function argument */ - { MODKEY, XK_d, spawn, {.v = dmenucmd } }, - { MODKEY, XK_Return, spawn, SHCMD("st") }, - { 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_u, incnmaster, {.i = -1 } }, - { MODKEY, XK_h, setmfact, {.f = -0.05} }, - { MODKEY, XK_l, setmfact, {.f = +0.05} }, - { MODKEY|ShiftMask, XK_Return, zoom, {0} }, - { MODKEY, XK_Tab, view, {0} }, - { MODKEY, XK_x, killclient, {0} }, - { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XK_space, setlayout, {0} }, - { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, - { MODKEY, XK_0, view, {.ui = ~0 } }, - { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, - { MODKEY, XK_comma, focusmon, {.i = -1 } }, - { MODKEY, XK_period, focusmon, {.i = +1 } }, - { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, - { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, - { MODKEY, XK_F3, spawn, SHCMD("st ranger") }, - { MODKEY, XK_F5, spawn, SHCMD("st ncmpcpp") }, - { MODKEY, XK_f, spawn, SHCMD("brave") }, - { MODKEY|ShiftMask, XK_f, spawn, SHCMD("brave --incognito") }, - { MODKEY, XK_w, spawn, SHCMD("sarc.sh --get_weather") }, - { MODKEY, XK_F11, spawn, SHCMD("pamixer --allow-boost -i 5; kill -44 $(pidof dwmblocks)") }, - { MODKEY, XK_F10, spawn, SHCMD("pamixer --allow-boost -d 5; kill -44 $(pidof dwmblocks)") }, - { MODKEY|ShiftMask, XK_F10, spawn, SHCMD("pavucontrol") }, - { MODKEY|ShiftMask, XK_F11, spawn, SHCMD("pavucontrol") }, - { MODKEY, XK_F7, spawn, BASHCMD("mpc toggle") }, - { MODKEY, XK_F8, spawn, BASHCMD("mpc prev") }, - { MODKEY, XK_F6, spawn, BASHCMD("mpc next") }, - { MODKEY, XK_F9, spawn, BASHCMD("pamixer -t; kill -44 $(pidof dwmblocks)") }, - { MODKEY|ShiftMask, XK_l, spawn, SHCMD("slock") }, - { MODKEY, XK_n, spawn, SHCMD("dmenuvpn") }, - { MODKEY|ShiftMask, XK_F9, spawn, SHCMD("amixer set Capture toggle") }, - { MODKEY, XK_F1, spawn, SHCMD("xbacklight -dec 1; kill -44 $(pidof dwmblocks)") }, - { MODKEY, XK_z, spawn, SHCMD("passgen --generate") }, - { MODKEY|ShiftMask, XK_z, spawn, SHCMD("passgen --decrypt") }, - { MODKEY, XK_F2, spawn, SHCMD("xbacklight -inc 1; kill -44 $(pidof dwmblocks)") }, - { MODKEY, XK_p, spawn, SHCMD("nsxiv -t ~/Pictures") }, - { MODKEY, XK_F12, spawn, SHCMD("sarc.sh --power") }, - { MODKEY, XK_F4, spawn, SHCMD("galculator") }, - { MODKEY, XK_e, spawn, SHCMD("sarc.sh --unicode") }, - { MODKEY, XK_s, spawn, SHCMD("sarc.sh --search_web") }, - { MODKEY, XK_g, spawn, SHCMD("sarc.sh --goto-website") }, - { MODKEY, XK_t, spawn, SHCMD("st vim ~/.cache/todo") }, - { MODKEY, XK_y, spawn, SHCMD("st mpv -fs `yt-dlp -g -f 18 $(xclip -o)`") }, - { WINKEY, XK_1, spawn, SHCMD("st vim ~/.cache/.sarc_notes.1") }, - { WINKEY, XK_2, spawn, SHCMD("st vim ~/.cache/.sarc_notes.2") }, - { WINKEY, XK_3, spawn, SHCMD("st vim ~/.cache/.sarc_notes.3") }, - { WINKEY, XK_4, spawn, SHCMD("st vim ~/.cache/.sarc_notes.4") }, - { WINKEY, XK_5, spawn, SHCMD("st vim ~/.cache/.sarc_notes.5") }, - { WINKEY, XK_6, spawn, SHCMD("st vim ~/.cache/.sarc_notes.6") }, - { WINKEY, XK_7, spawn, SHCMD("st vim ~/.cache/.sarc_notes.7") }, - { WINKEY, XK_8, spawn, SHCMD("st vim ~/.cache/.sarc_notes.8") }, - { WINKEY, XK_9, spawn, SHCMD("st vim ~/.cache/.sarc_notes.9") }, - 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 Button buttons[] = { - /* 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, Button1, sigstatusbar, {.i = 1} }, - { ClkStatusText, 0, Button2, sigstatusbar, {.i = 2} }, - { ClkStatusText, 0, Button3, sigstatusbar, {.i = 3} }, - { ClkStatusText, 0, Button4, sigstatusbar, {.i = 4} }, - { ClkStatusText, 0, Button5, sigstatusbar, {.i = 5} }, - { 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/wm/dwm-6.3/patches/dwm-activetagindicatorbar-6.2.diff b/wm/dwm-6.3/patches/dwm-activetagindicatorbar-6.2.diff deleted file mode 100644 index 4450099..0000000 --- a/wm/dwm-6.3/patches/dwm-activetagindicatorbar-6.2.diff +++ /dev/null @@ -1,17 +0,0 @@ -diff -up dwm-a/dwm.c dwm-b/dwm.c ---- dwm-a/dwm.c 2019-02-02 06:55:28.000000000 -0600 -+++ dwm-b/dwm.c 2019-02-23 21:43:13.359179100 -0600 -@@ -719,9 +719,10 @@ drawbar(Monitor *m) - drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); - if (occ & 1 << i) -- drw_rect(drw, x + boxs, boxs, boxw, boxw, -- m == selmon && selmon->sel && selmon->sel->tags & 1 << i, -- urg & 1 << i); -+ drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, -+ m == selmon && selmon->sel && selmon->sel->tags & 1 << i, -+ urg & 1 << i); -+ - x += w; - } - w = blw = TEXTW(m->ltsymbol); diff --git a/wm/dwm-6.3/patches/dwm-statuscmd-20210405-67d76bd.diff b/wm/dwm-6.3/patches/dwm-statuscmd-20210405-67d76bd.diff deleted file mode 100644 index 4b26420..0000000 --- a/wm/dwm-6.3/patches/dwm-statuscmd-20210405-67d76bd.diff +++ /dev/null @@ -1,208 +0,0 @@ -From f58c7e4fd05ec13383518ccd51663167d45e92d0 Mon Sep 17 00:00:00 2001 -From: Daniel Bylinka <daniel.bylinka@gmail.com> -Date: Fri, 2 Apr 2021 19:02:58 +0200 -Subject: [PATCH] [statuscmd] Signal mouse button and click location to status - monitor - ---- - config.def.h | 6 +++- - dwm.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++--- - 2 files changed, 100 insertions(+), 6 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 1c0b587..154a59b 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -54,6 +54,8 @@ static const Layout layouts[] = { - /* helper for spawning shell commands in the pre dwm-5.0 fashion */ - #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } - -+#define STATUSBAR "dwmblocks" -+ - /* commands */ - static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ - static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -@@ -103,7 +105,9 @@ static Button buttons[] = { - { ClkLtSymbol, 0, Button1, setlayout, {0} }, - { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, - { ClkWinTitle, 0, Button2, zoom, {0} }, -- { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, -+ { ClkStatusText, 0, Button1, sigstatusbar, {.i = 1} }, -+ { ClkStatusText, 0, Button2, sigstatusbar, {.i = 2} }, -+ { ClkStatusText, 0, Button3, sigstatusbar, {.i = 3} }, - { ClkClientWin, MODKEY, Button1, movemouse, {0} }, - { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, - { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, -diff --git a/dwm.c b/dwm.c -index b0b3466..d871457 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -172,6 +172,7 @@ static void focusstack(const Arg *arg); - static Atom getatomprop(Client *c, Atom prop); - static int getrootptr(int *x, int *y); - static long getstate(Window w); -+static pid_t getstatusbarpid(); - static int gettextprop(Window w, Atom atom, char *text, unsigned int size); - static void grabbuttons(Client *c, int focused); - static void grabkeys(void); -@@ -206,6 +207,7 @@ static void setup(void); - static void seturgent(Client *c, int urg); - static void showhide(Client *c); - static void sigchld(int unused); -+static void sigstatusbar(const Arg *arg); - static void spawn(const Arg *arg); - static void tag(const Arg *arg); - static void tagmon(const Arg *arg); -@@ -238,6 +240,9 @@ static void zoom(const Arg *arg); - /* variables */ - static const char broken[] = "broken"; - static char stext[256]; -+static int statusw; -+static int statussig; -+static pid_t statuspid = -1; - static int screen; - static int sw, sh; /* X display screen geometry width, height */ - static int bh, blw = 0; /* bar geometry */ -@@ -422,6 +427,7 @@ buttonpress(XEvent *e) - Client *c; - Monitor *m; - XButtonPressedEvent *ev = &e->xbutton; -+ char *text, *s, ch; - - click = ClkRootWin; - /* focus monitor if necessary */ -@@ -440,9 +446,23 @@ buttonpress(XEvent *e) - arg.ui = 1 << i; - } else if (ev->x < x + blw) - click = ClkLtSymbol; -- else if (ev->x > selmon->ww - (int)TEXTW(stext)) -+ else if (ev->x > selmon->ww - statusw) { -+ x = selmon->ww - statusw; - click = ClkStatusText; -- else -+ statussig = 0; -+ for (text = s = stext; *s && x <= ev->x; s++) { -+ if ((unsigned char)(*s) < ' ') { -+ ch = *s; -+ *s = '\0'; -+ x += TEXTW(text) - lrpad; -+ *s = ch; -+ text = s + 1; -+ if (x >= ev->x) -+ break; -+ statussig = ch; -+ } -+ } -+ } else - click = ClkWinTitle; - } else if ((c = wintoclient(ev->window))) { - focus(c); -@@ -704,9 +724,24 @@ drawbar(Monitor *m) - - /* draw status first so it can be overdrawn by tags later */ - if (m == selmon) { /* status is only drawn on selected monitor */ -+ char *text, *s, ch; - 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); -+ -+ x = 0; -+ for (text = s = stext; *s; s++) { -+ if ((unsigned char)(*s) < ' ') { -+ ch = *s; -+ *s = '\0'; -+ tw = TEXTW(text) - lrpad; -+ drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0); -+ x += tw; -+ *s = ch; -+ text = s + 1; -+ } -+ } -+ tw = TEXTW(text) - lrpad + 2; -+ drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0); -+ tw = statusw; - } - - for (c = m->clients; c; c = c->next) { -@@ -872,6 +907,30 @@ getatomprop(Client *c, Atom prop) - return atom; - } - -+pid_t -+getstatusbarpid() -+{ -+ char buf[32], *str = buf, *c; -+ FILE *fp; -+ -+ if (statuspid > 0) { -+ snprintf(buf, sizeof(buf), "/proc/%u/cmdline", statuspid); -+ if ((fp = fopen(buf, "r"))) { -+ fgets(buf, sizeof(buf), fp); -+ while ((c = strchr(str, '/'))) -+ str = c + 1; -+ fclose(fp); -+ if (!strcmp(str, STATUSBAR)) -+ return statuspid; -+ } -+ } -+ if (!(fp = popen("pidof -s "STATUSBAR, "r"))) -+ return -1; -+ fgets(buf, sizeof(buf), fp); -+ pclose(fp); -+ return strtol(buf, NULL, 10); -+} -+ - int - getrootptr(int *x, int *y) - { -@@ -1637,6 +1696,20 @@ sigchld(int unused) - while (0 < waitpid(-1, NULL, WNOHANG)); - } - -+void -+sigstatusbar(const Arg *arg) -+{ -+ union sigval sv; -+ -+ if (!statussig) -+ return; -+ sv.sival_int = arg->i; -+ if ((statuspid = getstatusbarpid()) <= 0) -+ return; -+ -+ sigqueue(statuspid, SIGRTMIN+statussig, sv); -+} -+ - void - spawn(const Arg *arg) - { -@@ -1990,8 +2063,25 @@ updatesizehints(Client *c) - void - updatestatus(void) - { -- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) -+ if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) { - strcpy(stext, "dwm-"VERSION); -+ statusw = TEXTW(stext) - lrpad + 2; -+ } else { -+ char *text, *s, ch; -+ -+ statusw = 0; -+ for (text = s = stext; *s; s++) { -+ if ((unsigned char)(*s) < ' ') { -+ ch = *s; -+ *s = '\0'; -+ statusw += TEXTW(text) - lrpad; -+ *s = ch; -+ text = s + 1; -+ } -+ } -+ statusw += TEXTW(text) - lrpad + 2; -+ -+ } - drawbar(selmon); - } - --- -2.31.0 - diff --git a/wm/dwm-6.3/patches/dwm-statuscmd-nosignal-20210402-67d76bd.diff b/wm/dwm-6.3/patches/dwm-statuscmd-nosignal-20210402-67d76bd.diff deleted file mode 100644 index 1dc5c53..0000000 --- a/wm/dwm-6.3/patches/dwm-statuscmd-nosignal-20210402-67d76bd.diff +++ /dev/null @@ -1,167 +0,0 @@ -From 02c4a28dd7f3a88eef3a4e533ace35f79cf09d57 Mon Sep 17 00:00:00 2001 -From: Daniel Bylinka <daniel.bylinka@gmail.com> -Date: Fri, 2 Apr 2021 19:34:38 +0200 -Subject: [PATCH] [statuscmd] Run shell commands based on mouse location and - button - ---- - config.def.h | 10 ++++++- - dwm.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++--- - 2 files changed, 81 insertions(+), 5 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 1c0b587..8f88366 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -59,6 +59,12 @@ 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 }; - -+/* commands spawned when clicking statusbar, the mouse button pressed is exported as BUTTON */ -+static const StatusCmd statuscmds[] = { -+ { "notify-send Mouse$BUTTON", 1 }, -+}; -+static const char *statuscmd[] = { "/bin/sh", "-c", NULL, NULL }; -+ - static Key keys[] = { - /* modifier key function argument */ - { MODKEY, XK_p, spawn, {.v = dmenucmd } }, -@@ -103,7 +109,9 @@ static Button buttons[] = { - { ClkLtSymbol, 0, Button1, setlayout, {0} }, - { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, - { ClkWinTitle, 0, Button2, zoom, {0} }, -- { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, -+ { ClkStatusText, 0, Button1, spawn, {.v = statuscmd } }, -+ { ClkStatusText, 0, Button2, spawn, {.v = statuscmd } }, -+ { ClkStatusText, 0, Button3, spawn, {.v = statuscmd } }, - { ClkClientWin, MODKEY, Button1, movemouse, {0} }, - { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, - { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, -diff --git a/dwm.c b/dwm.c -index b0b3466..eb478a5 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -141,6 +141,11 @@ typedef struct { - int monitor; - } Rule; - -+typedef struct { -+ const char *cmd; -+ int id; -+} StatusCmd; -+ - /* function declarations */ - static void applyrules(Client *c); - static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); -@@ -238,6 +243,9 @@ static void zoom(const Arg *arg); - /* variables */ - static const char broken[] = "broken"; - static char stext[256]; -+static int statusw; -+static int statuscmdn; -+static char lastbutton[] = "-"; - static int screen; - static int sw, sh; /* X display screen geometry width, height */ - static int bh, blw = 0; /* bar geometry */ -@@ -440,8 +448,27 @@ buttonpress(XEvent *e) - arg.ui = 1 << i; - } else if (ev->x < x + blw) - click = ClkLtSymbol; -- else if (ev->x > selmon->ww - (int)TEXTW(stext)) -+ else if (ev->x > selmon->ww - statusw) { -+ char *text, *s, ch; -+ *lastbutton = '0' + ev->button; -+ -+ x = selmon->ww - statusw; - click = ClkStatusText; -+ -+ statuscmdn = 0; -+ for (text = s = stext; *s && x <= ev->x; s++) { -+ if ((unsigned char)(*s) < ' ') { -+ ch = *s; -+ *s = '\0'; -+ x += TEXTW(text) - lrpad; -+ *s = ch; -+ text = s + 1; -+ if (x >= ev->x) -+ break; -+ statuscmdn = ch; -+ } -+ } -+ } - else - click = ClkWinTitle; - } else if ((c = wintoclient(ev->window))) { -@@ -704,9 +731,24 @@ drawbar(Monitor *m) - - /* draw status first so it can be overdrawn by tags later */ - if (m == selmon) { /* status is only drawn on selected monitor */ -+ char *text, *s, ch; - 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); -+ -+ x = 0; -+ for (text = s = stext; *s; s++) { -+ if ((unsigned char)(*s) < ' ') { -+ ch = *s; -+ *s = '\0'; -+ tw = TEXTW(text) - lrpad; -+ drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0); -+ x += tw; -+ *s = ch; -+ text = s + 1; -+ } -+ } -+ tw = TEXTW(text) - lrpad + 2; -+ drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0); -+ tw = statusw; - } - - for (c = m->clients; c; c = c->next) { -@@ -1645,6 +1687,17 @@ spawn(const Arg *arg) - if (fork() == 0) { - if (dpy) - close(ConnectionNumber(dpy)); -+ if (arg->v == statuscmd) { -+ for (int i = 0; i < LENGTH(statuscmds); i++) { -+ if (statuscmdn == statuscmds[i].id) { -+ statuscmd[2] = statuscmds[i].cmd; -+ setenv("BUTTON", lastbutton, 1); -+ break; -+ } -+ } -+ if (!statuscmd[2]) -+ exit(EXIT_SUCCESS); -+ } - setsid(); - execvp(((char **)arg->v)[0], (char **)arg->v); - fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]); -@@ -1990,8 +2043,23 @@ updatesizehints(Client *c) - void - updatestatus(void) - { -- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) -+ if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) { - strcpy(stext, "dwm-"VERSION); -+ statusw = TEXTW(stext) - lrpad + 2; -+ } else { -+ char *text, *s, ch; -+ statusw = 0; -+ for (text = s = stext; *s; s++) { -+ if ((unsigned char)(*s) < ' ') { -+ ch = *s; -+ *s = '\0'; -+ statusw += TEXTW(text) - lrpad; -+ *s = ch; -+ text = s + 1; -+ } -+ } -+ statusw += TEXTW(text) - lrpad + 2; -+ } - drawbar(selmon); - } - --- -2.31.0 - diff --git a/wm/dwm-6.3/LICENSE b/wm/dwm-6.4/LICENSE index d221f09..995172f 100644 --- a/wm/dwm-6.3/LICENSE +++ b/wm/dwm-6.4/LICENSE @@ -17,6 +17,7 @@ MIT/X Consortium License © 2015-2016 Quentin Rameau <quinq@fifth.space> © 2015-2016 Eric Pruitt <eric.pruitt@gmail.com> © 2016-2017 Markus Teich <markus.teich@stusta.mhn.de> +© 2020-2022 Chris Down <chris@chrisdown.name> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), diff --git a/wm/dwm-6.3/Makefile b/wm/dwm-6.4/Makefile index 3009009..77bcbc0 100644 --- a/wm/dwm-6.3/Makefile +++ b/wm/dwm-6.4/Makefile @@ -43,6 +43,7 @@ install: all mkdir -p ${DESTDIR}${MANPREFIX}/man1 sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1 chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1 + uninstall: rm -f ${DESTDIR}${PREFIX}/bin/dwm\ ${DESTDIR}${MANPREFIX}/man1/dwm.1 diff --git a/wm/dwm-6.3/README b/wm/dwm-6.4/README index 95d4fd0..95d4fd0 100644 --- a/wm/dwm-6.3/README +++ b/wm/dwm-6.4/README diff --git a/wm/dwm-6.4/config.h b/wm/dwm-6.4/config.h new file mode 100644 index 0000000..185cea9 --- /dev/null +++ b/wm/dwm-6.4/config.h @@ -0,0 +1,189 @@ +/* See LICENSE file for copyright and license details. */ + +/* appearance */ +static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int snap = 32; /* snap pixel */ +static const unsigned int gappih = 20; /* horiz inner gap between windows */ +static const unsigned int gappiv = 10; /* vert inner gap between windows */ +static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ +static const unsigned int gappov = 10; /* vert outer gap between windows and screen edge */ +static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ +static const int swallowfloating = 0; +static const int showbar = 1; /* 0 means no bar */ +static const int topbar = 1; /* 0 means bottom bar */ +#define ICONSIZE 14 /* icon size */ +#define ICONSPACING 5 /* space between icon and title */ +static const char *fonts[] = { "Source Code Pro:size=9" }; +static const char dmenufont[] = "Source Code Pro:size=9"; +static unsigned int baralpha = 0xd0; +static unsigned int borderalpha = OPAQUE; +#include "../../colors.h" +static const char *colors[][3] = { + /* fg bg border */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, +}; + +static const char *const autostart[] = { + "sarc.sh", "--redshift", NULL, + "xsetroot", "-name", "Loading dwmblocks...", NULL, + "dwmblocks", NULL, + "fehbg", NULL, + "unclutter", NULL, + "dunst", NULL, + "mpdas", NULL, + "picom", NULL, + NULL /* terminate */ +}; + +/* tagging */ +static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + +static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class + * WM_NAME(STRING) = title + */ + /* class instance title tags mask isfloating isterminal noswallow monitor */ + { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 }, + { "st", NULL, NULL, 0, 0, 1, 0, -1 }, + { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */ +}; + +/* layout(s) */ +static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ +static const int nmaster = 1; /* number of clients in master area */ +static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ +static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ + +#define FORCE_VSPLIT 1 /* nrowgrid layout: force two clients to always split vertically */ +#include "vanitygaps.c" + +static const Layout layouts[] = { + /* symbol arrange function */ + { "[]=", tile }, /* first entry is default */ + { "[M]", monocle }, + { "[@]", spiral }, + { "[\\]", dwindle }, + { "H[]", deck }, + { "TTT", bstack }, + { "===", bstackhoriz }, + { "HHH", grid }, + { "###", nrowgrid }, + { "---", horizgrid }, + { ":::", gaplessgrid }, + { "|M|", centeredmaster }, + { ">M>", centeredfloatingmaster }, + { "><>", NULL }, /* no layout function means floating behavior */ + { NULL, NULL }, +}; + +/* key definitions */ +#define MODKEY Mod1Mask +#define WINKEY Mod4Mask +#define TAGKEYS(KEY,TAG) \ + { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ + { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, + +/* helper for spawning shell commands in the pre dwm-5.0 fashion */ +#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } +#define BASHCMD(cmd) { .v = (const char* []){ "/bin/bash", "-c", cmd, NULL } } +/* commands */ +static const char *dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; +static const char *termcmd[] = { "st", NULL }; + +static Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_d, spawn, {.v = dmenucmd } }, + { MODKEY, XK_Return, spawn, SHCMD("st") }, + { 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_u, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY|ShiftMask, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY, XK_x, killclient, {0} }, + { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + { MODKEY, XK_F3, spawn, SHCMD("st ranger") }, + { MODKEY, XK_F5, spawn, SHCMD("st ncmpcpp") }, + { MODKEY, XK_f, spawn, SHCMD("brave") }, + { MODKEY|ShiftMask, XK_f, spawn, SHCMD("brave --incognito") }, + { MODKEY, XK_w, spawn, SHCMD("sarc.sh --get_weather") }, + { MODKEY, XK_F11, spawn, SHCMD("pamixer --allow-boost -i 5; kill -44 $(pidof dwmblocks)") }, + { MODKEY, XK_F10, spawn, SHCMD("pamixer --allow-boost -d 5; kill -44 $(pidof dwmblocks)") }, + { MODKEY|ShiftMask, XK_F10, spawn, SHCMD("pavucontrol") }, + { MODKEY|ShiftMask, XK_F11, spawn, SHCMD("pavucontrol") }, + { MODKEY, XK_F7, spawn, BASHCMD("mpc toggle") }, + { MODKEY, XK_F8, spawn, BASHCMD("mpc prev") }, + { MODKEY, XK_F6, spawn, BASHCMD("mpc next") }, + { MODKEY, XK_F9, spawn, BASHCMD("pamixer -t; kill -44 $(pidof dwmblocks)") +}, + { MODKEY|ShiftMask, XK_l, spawn, SHCMD("slock") }, + { MODKEY, XK_n, spawn, SHCMD("dmenuvpn") }, + { MODKEY|ShiftMask, XK_F9, spawn, SHCMD("amixer set Capture toggle") }, + { MODKEY, XK_F1, spawn, SHCMD("xbacklight -dec 1; kill -44 $(pidof dwmblocks)") }, + { MODKEY, XK_z, spawn, SHCMD("passgen --generate") }, + { MODKEY|ShiftMask, XK_z, spawn, SHCMD("passgen --decrypt") }, + { MODKEY, XK_F2, spawn, SHCMD("xbacklight -inc 1; kill -44 $(pidof dwmblocks)") }, + { MODKEY, XK_p, spawn, SHCMD("nsxiv -t ~/Pictures") }, + { MODKEY, XK_F12, spawn, SHCMD("sarc.sh --power") }, + { MODKEY, XK_F4, spawn, SHCMD("galculator") }, + { MODKEY, XK_e, spawn, SHCMD("sarc.sh --unicode") }, + { MODKEY, XK_s, spawn, SHCMD("sarc.sh --search_web") }, + { MODKEY, XK_g, spawn, SHCMD("sarc.sh --goto-website") }, + { MODKEY, XK_t, spawn, SHCMD("st vim ~/.cache/todo") }, + { MODKEY, XK_y, spawn, SHCMD("st mpv -fs `yt-dlp -g -f 18 $(xclip -o)`") }, + { WINKEY, XK_1, spawn, SHCMD("st vim ~/.cache/.sarc_notes.1") }, + { WINKEY, XK_2, spawn, SHCMD("st vim ~/.cache/.sarc_notes.2") }, + { WINKEY, XK_3, spawn, SHCMD("st vim ~/.cache/.sarc_notes.3") }, + { WINKEY, XK_4, spawn, SHCMD("st vim ~/.cache/.sarc_notes.4") }, + { WINKEY, XK_5, spawn, SHCMD("st vim ~/.cache/.sarc_notes.5") }, + { WINKEY, XK_6, spawn, SHCMD("st vim ~/.cache/.sarc_notes.6") }, + { WINKEY, XK_7, spawn, SHCMD("st vim ~/.cache/.sarc_notes.7") }, + { WINKEY, XK_8, spawn, SHCMD("st vim ~/.cache/.sarc_notes.8") }, + { WINKEY, XK_9, spawn, SHCMD("st vim ~/.cache/.sarc_notes.9") }, + 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]} }, + { 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/wm/dwm-6.3/config.mk b/wm/dwm-6.4/config.mk index ebb872b..8847583 100644 --- a/wm/dwm-6.3/config.mk +++ b/wm/dwm-6.4/config.mk @@ -1,9 +1,12 @@ -include ../../config.mk # dwm version -VERSION = 6.3 +VERSION = 6.4 # Customize below to fit your system +# paths +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/share/man + X11INC = /usr/X11R6/include X11LIB = /usr/X11R6/lib @@ -16,16 +19,16 @@ FREETYPELIBS = -lfontconfig -lXft FREETYPEINC = /usr/include/freetype2 # OpenBSD (uncomment) #FREETYPEINC = ${X11INC}/freetype2 -#KVMLIB = -lkvm +#MANPREFIX = ${PREFIX}/man # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lXrender -lxcb -lxcb-res ${KVMLIB} +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lImlib2 -lXrender -lX11-xcb -lxcb -lxcb-res # flags CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} -CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Ofast ${INCS} ${CPPFLAGS} +CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} LDFLAGS = ${LIBS} # Solaris diff --git a/wm/dwm-6.3/drw.c b/wm/dwm-6.4/drw.c index 45baf67..103b448 100644 --- a/wm/dwm-6.3/drw.c +++ b/wm/dwm-6.4/drw.c @@ -4,6 +4,7 @@ #include <string.h> #include <X11/Xlib.h> #include <X11/Xft/Xft.h> +#include <Imlib2.h> #include "drw.h" #include "util.h" @@ -74,6 +75,7 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h drw->depth = depth; drw->cmap = cmap; drw->drawable = XCreatePixmap(dpy, root, w, h, depth); + drw->picture = XRenderCreatePicture(dpy, drw->drawable, XRenderFindVisualFormat(dpy, visual), 0, NULL); drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL); XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter); @@ -88,14 +90,19 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h) drw->w = w; drw->h = h; + if (drw->picture) + XRenderFreePicture(drw->dpy, drw->picture); if (drw->drawable) XFreePixmap(drw->dpy, drw->drawable); drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth); + drw->picture = XRenderCreatePicture(drw->dpy, drw->drawable, XRenderFindVisualFormat(drw->dpy, drw->visual), 0, NULL); + } void drw_free(Drw *drw) { + XRenderFreePicture(drw->dpy, drw->picture); XFreePixmap(drw->dpy, drw->drawable); XFreeGC(drw->dpy, drw->gc); drw_fontset_free(drw->fonts); @@ -136,7 +143,6 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern) die("no font specified."); } - font = ecalloc(1, sizeof(Fnt)); font->xfont = xfont; font->pattern = pattern; @@ -189,18 +195,16 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha) { if (!drw || !dest || !clrname) return; - - if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap, + if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap, clrname, dest)) die("error, cannot allocate color '%s'", clrname); - - dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24); + dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24); } /* Wrapper to create color schemes. The caller has to call free(3) on the * returned color scheme when done using it. */ Clr * -drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount) +drw_scm_create(Drw *drw, const char *clrnames[], unsigned int clralphas[], size_t clrcount) { size_t i; Clr *ret; @@ -210,7 +214,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], si return NULL; for (i = 0; i < clrcount; i++) - drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]); + drw_clr_create(drw, &ret[i], clrnames[i], clralphas[i]); return ret; } @@ -228,6 +232,67 @@ drw_setscheme(Drw *drw, Clr *scm) drw->scheme = scm; } +Picture +drw_picture_create_resized(Drw *drw, char *src, unsigned int srcw, unsigned int srch, unsigned int dstw, unsigned int dsth) { + Pixmap pm; + Picture pic; + GC gc; + + if (srcw <= (dstw << 1u) && srch <= (dsth << 1u)) { + XImage img = { + srcw, srch, 0, ZPixmap, src, + ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32, + 32, 0, 32, + 0, 0, 0 + }; + XInitImage(&img); + + pm = XCreatePixmap(drw->dpy, drw->root, srcw, srch, 32); + gc = XCreateGC(drw->dpy, pm, 0, NULL); + XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, srcw, srch); + XFreeGC(drw->dpy, gc); + + pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL); + XFreePixmap(drw->dpy, pm); + + XRenderSetPictureFilter(drw->dpy, pic, FilterBilinear, NULL, 0); + XTransform xf; + xf.matrix[0][0] = (srcw << 16u) / dstw; xf.matrix[0][1] = 0; xf.matrix[0][2] = 0; + xf.matrix[1][0] = 0; xf.matrix[1][1] = (srch << 16u) / dsth; xf.matrix[1][2] = 0; + xf.matrix[2][0] = 0; xf.matrix[2][1] = 0; xf.matrix[2][2] = 65536; + XRenderSetPictureTransform(drw->dpy, pic, &xf); + } else { + Imlib_Image origin = imlib_create_image_using_data(srcw, srch, (DATA32 *)src); + if (!origin) return None; + imlib_context_set_image(origin); + imlib_image_set_has_alpha(1); + Imlib_Image scaled = imlib_create_cropped_scaled_image(0, 0, srcw, srch, dstw, dsth); + imlib_free_image_and_decache(); + if (!scaled) return None; + imlib_context_set_image(scaled); + imlib_image_set_has_alpha(1); + + XImage img = { + dstw, dsth, 0, ZPixmap, (char *)imlib_image_get_data_for_reading_only(), + ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32, + 32, 0, 32, + 0, 0, 0 + }; + XInitImage(&img); + + pm = XCreatePixmap(drw->dpy, drw->root, dstw, dsth, 32); + gc = XCreateGC(drw->dpy, pm, 0, NULL); + XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, dstw, dsth); + imlib_free_image_and_decache(); + XFreeGC(drw->dpy, gc); + + pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL); + XFreePixmap(drw->dpy, pm); + } + + return pic; +} + void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert) { @@ -243,12 +308,10 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert) { - char buf[1024]; - int ty; - unsigned int ew; + int i, ty, ellipsis_x = 0; + unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len; XftDraw *d = NULL; Fnt *usedfont, *curfont, *nextfont; - size_t i, len; int utf8strlen, utf8charlen, render = x || y || w || h; long utf8codepoint = 0; const char *utf8str; @@ -256,24 +319,31 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp FcPattern *fcpattern; FcPattern *match; XftResult result; - int charexists = 0; + int charexists = 0, overflow = 0; + /* keep track of a couple codepoints for which we have no match. */ + enum { nomatches_len = 64 }; + static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches; + static unsigned int ellipsis_width = 0; - if (!drw || (render && !drw->scheme) || !text || !drw->fonts) + if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts) return 0; if (!render) { - w = ~w; + w = invert ? invert : ~invert; } else { XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); - d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); + d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); + x += lpad; w -= lpad; } usedfont = drw->fonts; + if (!ellipsis_width && render) + ellipsis_width = drw_fontset_getwidth(drw, "..."); while (1) { - utf8strlen = 0; + ew = ellipsis_len = utf8strlen = 0; utf8str = text; nextfont = NULL; while (*text) { @@ -281,9 +351,27 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp for (curfont = drw->fonts; curfont; curfont = curfont->next) { charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint); if (charexists) { - if (curfont == usedfont) { + drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL); + if (ew + ellipsis_width <= w) { + /* keep track where the ellipsis still fits */ + ellipsis_x = x + ew; + ellipsis_w = w - ew; + ellipsis_len = utf8strlen; + } + + if (ew + tmpw > w) { + overflow = 1; + /* called from drw_fontset_getwidth_clamp(): + * it wants the width AFTER the overflow + */ + if (!render) + x += tmpw; + else + utf8strlen = ellipsis_len; + } else if (curfont == usedfont) { utf8strlen += utf8charlen; text += utf8charlen; + ew += tmpw; } else { nextfont = curfont; } @@ -291,36 +379,25 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp } } - if (!charexists || nextfont) + if (overflow || !charexists || nextfont) break; else charexists = 0; } if (utf8strlen) { - drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL); - /* shorten text if necessary */ - for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--) - drw_font_getexts(usedfont, utf8str, len, &ew, NULL); - - if (len) { - memcpy(buf, utf8str, len); - buf[len] = '\0'; - if (len < utf8strlen) - for (i = len; i && i > len - 3; buf[--i] = '.') - ; /* NOP */ - - if (render) { - ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent; - XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg], - usedfont->xfont, x, ty, (XftChar8 *)buf, len); - } - x += ew; - w -= ew; + if (render) { + ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent; + XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg], + usedfont->xfont, x, ty, (XftChar8 *)utf8str, utf8strlen); } + x += ew; + w -= ew; } + if (render && overflow) + drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert); - if (!*text) { + if (!*text || overflow) { break; } else if (nextfont) { charexists = 0; @@ -330,6 +407,12 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp * character must be drawn. */ charexists = 1; + for (i = 0; i < nomatches_len; ++i) { + /* avoid calling XftFontMatch if we know we won't find a match */ + if (utf8codepoint == nomatches.codepoint[i]) + goto no_match; + } + fccharset = FcCharSetCreate(); FcCharSetAddChar(fccharset, utf8codepoint); @@ -341,7 +424,6 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp fcpattern = FcPatternDuplicate(drw->fonts->pattern); FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset); FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue); - FcPatternAddBool(fcpattern, FC_COLOR, FcFalse); FcConfigSubstitute(NULL, fcpattern, FcMatchPattern); FcDefaultSubstitute(fcpattern); @@ -358,6 +440,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp curfont->next = usedfont; } else { xfont_free(usedfont); + nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint; +no_match: usedfont = drw->fonts; } } @@ -370,6 +454,14 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp } void +drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic) +{ + if (!drw) + return; + XRenderComposite(drw->dpy, PictOpOver, pic, None, drw->picture, 0, 0, 0, 0, x, y, w, h); +} + +void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) { if (!drw) @@ -387,6 +479,15 @@ drw_fontset_getwidth(Drw *drw, const char *text) return drw_text(drw, 0, 0, 0, 0, 0, text, 0); } +unsigned int +drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n) +{ + unsigned int tmp = 0; + if (drw && drw->fonts && text && n) + tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n); + return MIN(n, tmp); +} + void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h) { diff --git a/wm/dwm-6.3/drw.h b/wm/dwm-6.4/drw.h index a56f523..a9a4c86 100644 --- a/wm/dwm-6.3/drw.h +++ b/wm/dwm-6.4/drw.h @@ -24,13 +24,14 @@ typedef struct { unsigned int depth; Colormap cmap; Drawable drawable; + Picture picture; GC gc; Clr *scheme; Fnt *fonts; } Drw; /* Drawable abstraction */ -Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap); +Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual*, unsigned int, Colormap); void drw_resize(Drw *drw, unsigned int w, unsigned int h); void drw_free(Drw *drw); @@ -38,11 +39,12 @@ void drw_free(Drw *drw); Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount); void drw_fontset_free(Fnt* set); unsigned int drw_fontset_getwidth(Drw *drw, const char *text); +unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n); void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); /* Colorscheme abstraction */ void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha); -Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount); +Clr *drw_scm_create(Drw *drw, const char *clrnames[], unsigned int clralphas[], size_t clrcount); /* Cursor abstraction */ Cur *drw_cur_create(Drw *drw, int shape); @@ -52,9 +54,12 @@ void drw_cur_free(Drw *drw, Cur *cursor); void drw_setfontset(Drw *drw, Fnt *set); void drw_setscheme(Drw *drw, Clr *scm); +Picture drw_picture_create_resized(Drw *drw, char *src, unsigned int src_w, unsigned int src_h, unsigned int dst_w, unsigned int dst_h); + /* Drawing functions */ void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); +void drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic); /* Map functions */ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); diff --git a/wm/dwm-6.3/dwm.1 b/wm/dwm-6.4/dwm.1 index ddc8321..ddc8321 100644 --- a/wm/dwm-6.3/dwm.1 +++ b/wm/dwm-6.4/dwm.1 diff --git a/wm/dwm-6.3/dwm.c b/wm/dwm-6.4/dwm.c index b9d29c3..5b918cd 100644 --- a/wm/dwm-6.3/dwm.c +++ b/wm/dwm-6.4/dwm.c @@ -28,6 +28,8 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> +#include <stdint.h> #include <sys/types.h> #include <sys/wait.h> #include <X11/cursorfont.h> @@ -65,10 +67,12 @@ #define OPAQUE 0xffU +#define OPAQUE 0xffU + /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { SchemeNorm, SchemeSel }; /* color schemes */ -enum { NetSupported, NetWMName, NetWMState, NetWMCheck, +enum { NetSupported, NetWMName, NetWMIcon, NetWMState, NetWMCheck, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ @@ -97,10 +101,11 @@ struct Client { float mina, maxa; int x, y, w, h; int oldx, oldy, oldw, oldh; - int basew, baseh, incw, inch, maxw, maxh, minw, minh; + int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int bw, oldbw; unsigned int tags; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow; + unsigned int icw, ich; Picture icon; pid_t pid; Client *next; Client *snext; @@ -186,9 +191,9 @@ static void focusin(XEvent *e); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); static Atom getatomprop(Client *c, Atom prop); +static Picture geticonprop(Window w, unsigned int *icw, unsigned int *ich); static int getrootptr(int *x, int *y); static long getstate(Window w); -static pid_t getstatusbarpid(); static int gettextprop(Window w, Atom atom, char *text, unsigned int size); static void grabbuttons(Client *c, int focused); static void grabkeys(void); @@ -202,7 +207,7 @@ 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 *); +static void pop(Client *c); static void propertynotify(XEvent *e); static void quit(const Arg *arg); static Monitor *recttomon(int x, int y, int w, int h); @@ -223,7 +228,6 @@ static void setup(void); static void seturgent(Client *c, int urg); static void showhide(Client *c); static void sigchld(int unused); -static void sigstatusbar(const Arg *arg); static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); @@ -231,6 +235,7 @@ static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); +static void freeicon(Client *c); static void unfocus(Client *c, int setfocus); static void unmanage(Client *c, int destroyed); static void unmapnotify(XEvent *e); @@ -242,6 +247,7 @@ static void updatenumlockmask(void); static void updatesizehints(Client *c); static void updatestatus(void); static void updatetitle(Client *c); +static void updateicon(Client *c); static void updatewindowtype(Client *c); static void updatewmhints(Client *c); static void view(const Arg *arg); @@ -263,12 +269,9 @@ static pid_t winpid(Window w); /* variables */ static const char broken[] = "broken"; static char stext[256]; -static int statusw; -static int statussig; -static pid_t statuspid = -1; static int screen; static int sw, sh; /* X display screen geometry width, height */ -static int bh, blw = 0; /* bar geometry */ +static int bh; /* bar height */ static int lrpad; /* sum of left and right padding for text */ static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int numlockmask = 0; @@ -297,13 +300,13 @@ static Drw *drw; static Monitor *mons, *selmon; static Window root, wmcheckwin; -static xcb_connection_t *xcon; - static int useargb = 0; static Visual *visual; static int depth; static Colormap cmap; +static xcb_connection_t *xcon; + /* configuration, allows nested code to access above variables */ #include "config.h" @@ -410,6 +413,8 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact) if (*w < bh) *w = bh; if (resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) { + if (!c->hintsvalid) + updatesizehints(c); /* see last two sentences in ICCCM 4.1.2.3 */ baseismin = c->basew == c->minw && c->baseh == c->minh; if (!baseismin) { /* temporarily remove base dimensions */ @@ -534,7 +539,6 @@ buttonpress(XEvent *e) Client *c; Monitor *m; XButtonPressedEvent *ev = &e->xbutton; - char *text, *s, ch; click = ClkRootWin; /* focus monitor if necessary */ @@ -551,25 +555,11 @@ buttonpress(XEvent *e) if (i < LENGTH(tags)) { click = ClkTagBar; arg.ui = 1 << i; - } else if (ev->x < x + blw) + } else if (ev->x < x + TEXTW(selmon->ltsymbol)) click = ClkLtSymbol; - else if (ev->x > selmon->ww - statusw) { - x = selmon->ww - statusw; + else if (ev->x > selmon->ww - (int)TEXTW(stext)) click = ClkStatusText; - statussig = 0; - for (text = s = stext; *s && x <= ev->x; s++) { - if ((unsigned char)(*s) < ' ') { - ch = *s; - *s = '\0'; - x += TEXTW(text) - lrpad; - *s = ch; - text = s + 1; - if (x >= ev->x) - break; - statussig = ch; - } - } - } else + else click = ClkWinTitle; } else if ((c = wintoclient(ev->window))) { focus(c); @@ -614,6 +604,7 @@ cleanup(void) drw_cur_free(drw, cursor[i]); for (i = 0; i < LENGTH(colors); i++) free(scheme[i]); + free(scheme); XDestroyWindow(dpy, wmcheckwin); drw_free(drw); XSync(dpy, False); @@ -841,24 +832,9 @@ drawbar(Monitor *m) /* draw status first so it can be overdrawn by tags later */ if (m == selmon) { /* status is only drawn on selected monitor */ - char *text, *s, ch; drw_setscheme(drw, scheme[SchemeNorm]); - - x = 0; - for (text = s = stext; *s; s++) { - if ((unsigned char)(*s) < ' ') { - ch = *s; - *s = '\0'; - tw = TEXTW(text) - lrpad; - drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0); - x += tw; - *s = ch; - text = s + 1; - } - } - tw = TEXTW(text) - lrpad + 2; - drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0); - tw = statusw; + 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) { @@ -872,20 +848,20 @@ drawbar(Monitor *m) 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 + boxw, 0, w - ( 2 * boxw + 1), boxw, - m == selmon && selmon->sel && selmon->sel->tags & 1 << i, - urg & 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 = blw = TEXTW(m->ltsymbol); + w = TEXTW(m->ltsymbol); drw_setscheme(drw, scheme[SchemeNorm]); x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); if ((w = m->ww - tw - x) > bh) { if (m->sel) { drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); + drw_text(drw, x, 0, w, bh, lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0), m->sel->name, 0); + if (m->sel->icon) drw_pic(drw, x + lrpad / 2, (bh - m->sel->ich) / 2, m->sel->icw, m->sel->ich, m->sel->icon); if (m->sel->isfloating) drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); } else { @@ -1025,28 +1001,65 @@ getatomprop(Client *c, Atom prop) return atom; } -pid_t -getstatusbarpid() -{ - char buf[32], *str = buf, *c; - FILE *fp; - - if (statuspid > 0) { - snprintf(buf, sizeof(buf), "/proc/%u/cmdline", statuspid); - if ((fp = fopen(buf, "r"))) { - fgets(buf, sizeof(buf), fp); - while ((c = strchr(str, '/'))) - str = c + 1; - fclose(fp); - if (!strcmp(str, STATUSBAR)) - return statuspid; +static uint32_t prealpha(uint32_t p) { + uint8_t a = p >> 24u; + uint32_t rb = (a * (p & 0xFF00FFu)) >> 8u; + uint32_t g = (a * (p & 0x00FF00u)) >> 8u; + return (rb & 0xFF00FFu) | (g & 0x00FF00u) | (a << 24u); +} + +Picture +geticonprop(Window win, unsigned int *picw, unsigned int *pich) +{ + int format; + unsigned long n, extra, *p = NULL; + Atom real; + + if (XGetWindowProperty(dpy, win, netatom[NetWMIcon], 0L, LONG_MAX, False, AnyPropertyType, + &real, &format, &n, &extra, (unsigned char **)&p) != Success) + return None; + if (n == 0 || format != 32) { XFree(p); return None; } + + unsigned long *bstp = NULL; + uint32_t w, h, sz; + { + unsigned long *i; const unsigned long *end = p + n; + uint32_t bstd = UINT32_MAX, d, m; + for (i = p; i < end - 1; i += sz) { + if ((w = *i++) >= 16384 || (h = *i++) >= 16384) { XFree(p); return None; } + if ((sz = w * h) > end - i) break; + if ((m = w > h ? w : h) >= ICONSIZE && (d = m - ICONSIZE) < bstd) { bstd = d; bstp = i; } } + if (!bstp) { + for (i = p; i < end - 1; i += sz) { + if ((w = *i++) >= 16384 || (h = *i++) >= 16384) { XFree(p); return None; } + if ((sz = w * h) > end - i) break; + if ((d = ICONSIZE - (w > h ? w : h)) < bstd) { bstd = d; bstp = i; } + } + } + if (!bstp) { XFree(p); return None; } } - if (!(fp = popen("pidof -s "STATUSBAR, "r"))) - return -1; - fgets(buf, sizeof(buf), fp); - pclose(fp); - return strtol(buf, NULL, 10); + + if ((w = *(bstp - 2)) == 0 || (h = *(bstp - 1)) == 0) { XFree(p); return None; } + + uint32_t icw, ich; + if (w <= h) { + ich = ICONSIZE; icw = w * ICONSIZE / h; + if (icw == 0) icw = 1; + } + else { + icw = ICONSIZE; ich = h * ICONSIZE / w; + if (ich == 0) ich = 1; + } + *picw = icw; *pich = ich; + + uint32_t i, *bstp32 = (uint32_t *)bstp; + for (sz = w * h, i = 0; i < sz; ++i) bstp32[i] = prealpha(bstp[i]); + + Picture ret = drw_picture_create_resized(drw, (char *)bstp, w, h, icw, ich); + XFree(p); + + return ret; } int @@ -1089,13 +1102,11 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) text[0] = '\0'; if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems) return 0; - if (name.encoding == XA_STRING) + if (name.encoding == XA_STRING) { strncpy(text, (char *)name.value, size - 1); - else { - if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) { - strncpy(text, *list, size - 1); - XFreeStringList(list); - } + } else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) { + strncpy(text, *list, size - 1); + XFreeStringList(list); } text[size - 1] = '\0'; XFree(name.value); @@ -1209,6 +1220,7 @@ manage(Window w, XWindowAttributes *wa) c->h = c->oldh = wa->height; c->oldbw = wa->border_width; + updateicon(c); updatetitle(c); if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { c->mon = t->mon; @@ -1219,14 +1231,12 @@ manage(Window w, XWindowAttributes *wa) term = termforwin(c); } - if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw) - c->x = c->mon->mx + c->mon->mw - WIDTH(c); - if (c->y + HEIGHT(c) > c->mon->my + c->mon->mh) - c->y = c->mon->my + c->mon->mh - HEIGHT(c); - c->x = MAX(c->x, c->mon->mx); - /* only fix client y-offset, if the client center might cover the bar */ - c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) - && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); + if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww) + c->x = c->mon->wx + c->mon->ww - WIDTH(c); + if (c->y + HEIGHT(c) > c->mon->wy + c->mon->wh) + c->y = c->mon->wy + c->mon->wh - HEIGHT(c); + c->x = MAX(c->x, c->mon->wx); + c->y = MAX(c->y, c->mon->wy); c->bw = borderpx; wc.border_width = c->bw; @@ -1274,9 +1284,7 @@ maprequest(XEvent *e) static XWindowAttributes wa; XMapRequestEvent *ev = &e->xmaprequest; - if (!XGetWindowAttributes(dpy, ev->window, &wa)) - return; - if (wa.override_redirect) + if (!XGetWindowAttributes(dpy, ev->window, &wa) || wa.override_redirect) return; if (!wintoclient(ev->window)) manage(ev->window, &wa); @@ -1410,7 +1418,7 @@ propertynotify(XEvent *e) arrange(c->mon); break; case XA_WM_NORMAL_HINTS: - updatesizehints(c); + c->hintsvalid = 0; break; case XA_WM_HINTS: updatewmhints(c); @@ -1422,6 +1430,11 @@ propertynotify(XEvent *e) if (c == c->mon->sel) drawbar(c->mon); } + else if (ev->atom == netatom[NetWMIcon]) { + updateicon(c); + if (c == c->mon->sel) + drawbar(c->mon); + } if (ev->atom == netatom[NetWMWindowType]) updatewindowtype(c); } @@ -1733,7 +1746,7 @@ setup(void) sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); root = RootWindow(dpy, screen); - xinitvisual(); + xinitvisual(); drw = drw_create(dpy, screen, root, sw, sh, visual, depth, cmap); if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) die("no fonts could be loaded."); @@ -1749,6 +1762,7 @@ setup(void) netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); + netatom[NetWMIcon] = XInternAtom(dpy, "_NET_WM_ICON", False); netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); @@ -1761,8 +1775,9 @@ setup(void) cursor[CurMove] = drw_cur_create(drw, XC_fleur); /* init appearance */ scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); + unsigned int alphas[] = {borderalpha, baralpha, OPAQUE}; for (i = 0; i < LENGTH(colors); i++) - scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3); + scheme[i] = drw_scm_create(drw, colors[i], alphas, 3); /* init bars */ updatebars(); updatestatus(); @@ -1789,7 +1804,6 @@ setup(void) focus(NULL); } - void seturgent(Client *c, int urg) { @@ -1846,32 +1860,14 @@ sigchld(int unused) } void -sigstatusbar(const Arg *arg) -{ - union sigval sv; - - if (!statussig) - return; - sv.sival_int = arg->i; - if ((statuspid = getstatusbarpid()) <= 0) - return; - - sigqueue(statuspid, SIGRTMIN+statussig, sv); -} - -void spawn(const Arg *arg) { - if (arg->v == dmenucmd) - dmenumon[0] = '0' + selmon->num; if (fork() == 0) { if (dpy) close(ConnectionNumber(dpy)); setsid(); execvp(((char **)arg->v)[0], (char **)arg->v); - fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]); - perror(" failed"); - exit(EXIT_SUCCESS); + die("dwm: execvp '%s' failed:", ((char **)arg->v)[0]); } } @@ -1944,6 +1940,15 @@ toggleview(const Arg *arg) } void +freeicon(Client *c) +{ + if (c->icon) { + XRenderFreePicture(dpy, c->icon); + c->icon = None; + } +} + +void unfocus(Client *c, int setfocus) { if (!c) @@ -1978,10 +1983,12 @@ unmanage(Client *c, int destroyed) detach(c); detachstack(c); + freeicon(c); if (!destroyed) { wc.border_width = c->oldbw; XGrabServer(dpy); /* avoid race conditions */ XSetErrorHandler(xerrordummy); + XSelectInput(dpy, c->win, NoEventMask); XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */ XUngrabButton(dpy, AnyButton, AnyModifier, c->win); setclientstate(c, WithdrawnState); @@ -2084,42 +2091,42 @@ updategeom(void) memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo)); XFree(info); nn = j; - if (n <= nn) { /* new monitors available */ - for (i = 0; i < (nn - n); i++) { - for (m = mons; m && m->next; m = m->next); - if (m) - m->next = createmon(); - else - mons = createmon(); + + /* new monitors if nn > n */ + for (i = n; i < nn; i++) { + for (m = mons; m && m->next; m = m->next); + if (m) + m->next = createmon(); + else + mons = createmon(); + } + for (i = 0, m = mons; i < nn && m; m = m->next, i++) + if (i >= n + || unique[i].x_org != m->mx || unique[i].y_org != m->my + || unique[i].width != m->mw || unique[i].height != m->mh) + { + dirty = 1; + m->num = i; + m->mx = m->wx = unique[i].x_org; + m->my = m->wy = unique[i].y_org; + m->mw = m->ww = unique[i].width; + m->mh = m->wh = unique[i].height; + updatebarpos(m); } - for (i = 0, m = mons; i < nn && m; m = m->next, i++) - if (i >= n - || unique[i].x_org != m->mx || unique[i].y_org != m->my - || unique[i].width != m->mw || unique[i].height != m->mh) - { - dirty = 1; - m->num = i; - m->mx = m->wx = unique[i].x_org; - m->my = m->wy = unique[i].y_org; - m->mw = m->ww = unique[i].width; - m->mh = m->wh = unique[i].height; - updatebarpos(m); - } - } else { /* less monitors available nn < n */ - for (i = nn; i < n; i++) { - for (m = mons; m && m->next; m = m->next); - while ((c = m->clients)) { - dirty = 1; - m->clients = c->next; - detachstack(c); - c->mon = mons; - attach(c); - attachstack(c); - } - if (m == selmon) - selmon = mons; - cleanupmon(m); + /* removed monitors if n > nn */ + for (i = nn; i < n; i++) { + for (m = mons; m && m->next; m = m->next); + while ((c = m->clients)) { + dirty = 1; + m->clients = c->next; + detachstack(c); + c->mon = mons; + attach(c); + attachstack(c); } + if (m == selmon) + selmon = mons; + cleanupmon(m); } free(unique); } else @@ -2198,30 +2205,14 @@ updatesizehints(Client *c) } else c->maxa = c->mina = 0.0; c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh); + c->hintsvalid = 1; } void updatestatus(void) { - if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) { + if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) strcpy(stext, "dwm-"VERSION); - statusw = TEXTW(stext) - lrpad + 2; - } else { - char *text, *s, ch; - - statusw = 0; - for (text = s = stext; *s; s++) { - if ((unsigned char)(*s) < ' ') { - ch = *s; - *s = '\0'; - statusw += TEXTW(text) - lrpad; - *s = ch; - text = s + 1; - } - } - statusw += TEXTW(text) - lrpad + 2; - - } drawbar(selmon); } @@ -2235,6 +2226,13 @@ updatetitle(Client *c) } void +updateicon(Client *c) +{ + freeicon(c); + c->icon = geticonprop(c->win, &c->icw, &c->ich); +} + +void updatewindowtype(Client *c) { Atom state = getatomprop(c, netatom[NetWMState]); @@ -2515,12 +2513,10 @@ zoom(const Arg *arg) { Client *c = selmon->sel; - if (!selmon->lt[selmon->sellt]->arrange - || (selmon->sel && selmon->sel->isfloating)) + if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating) + return; + if (c == nexttiled(selmon->clients) && !(c = nexttiled(c->next))) return; - if (c == nexttiled(selmon->clients)) - if (!c || !(c = nexttiled(c->next))) - return; pop(c); } @@ -2536,7 +2532,7 @@ main(int argc, char *argv[]) if (!(dpy = XOpenDisplay(NULL))) die("dwm: cannot open display"); if (!(xcon = XGetXCBConnection(dpy))) - die("dwm: cannot get xcb connection\n"); + die("dwm: cannot get connection\n"); checkotherwm(); autostart_exec(); setup(); diff --git a/wm/dwm-6.3/dwm.png b/wm/dwm-6.4/dwm.png Binary files differindex b1f9ba7..b1f9ba7 100644 --- a/wm/dwm-6.3/dwm.png +++ b/wm/dwm-6.4/dwm.png diff --git a/wm/dwm-6.3/patches/dwm-alpha-20201019-61bb8b2.diff b/wm/dwm-6.4/patches/dwm-alpha-6.4.diff index 9a8e92a..ad4b2b7 100644 --- a/wm/dwm-6.3/patches/dwm-alpha-20201019-61bb8b2.diff +++ b/wm/dwm-6.4/patches/dwm-alpha-6.4.diff @@ -1,45 +1,34 @@ -From 51f9c34480b984e261a738e5295f518b42c2f29c Mon Sep 17 00:00:00 2001 -From: Petrus Karell <pk@petruskarell.fi> -Date: Mon, 19 Oct 2020 19:15:24 +0300 -Subject: [PATCH] Allow dwm to have translucent bars, while keeping all - the text on it opaque, just like the alpha-patch for st. Updated for 61bb8b2 +From 4ee637701f1144e07338d5990fecb3dc44982223 Mon Sep 17 00:00:00 2001 +From: NekoCWD <nekodevelopper@gmail.com> +Date: Fri, 27 Jan 2023 21:59:15 +0300 +Subject: [PATCH] [dwm] update 'alpha' path for dwm6.4 --- - config.def.h | 7 ++++++ + config.def.h | 2 ++ config.mk | 2 +- - drw.c | 26 ++++++++++++----------- + drw.c | 27 +++++++++++----------- drw.h | 9 +++++--- - dwm.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++------ - 5 files changed, 82 insertions(+), 22 deletions(-) + dwm.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++----- + 5 files changed, 80 insertions(+), 23 deletions(-) diff --git a/config.def.h b/config.def.h -index 1c0b587..4f68fe8 100644 +index 061ad66..3a4236d 100644 --- a/config.def.h +++ b/config.def.h -@@ -12,11 +12,18 @@ static const char col_gray2[] = "#444444"; +@@ -7,6 +7,8 @@ static const int showbar = 1; /* 0 means no bar */ + static const int topbar = 1; /* 0 means bottom bar */ + static const char *fonts[] = { "monospace:size=10" }; + static const char dmenufont[] = "monospace:size=10"; ++static unsigned int baralpha = 0xd0; ++static unsigned int borderalpha = OPAQUE; + 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 unsigned int baralpha = 0xd0; -+static const unsigned int borderalpha = OPAQUE; - static const char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, - }; -+static const unsigned int alphas[][3] = { -+ /* fg bg border */ -+ [SchemeNorm] = { OPAQUE, baralpha, borderalpha }, -+ [SchemeSel] = { OPAQUE, baralpha, borderalpha }, -+}; - - /* tagging */ - static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; diff --git a/config.mk b/config.mk -index 7084c33..21b5404 100644 +index ef8acf7..6d41560 100644 --- a/config.mk +++ b/config.mk -@@ -22,7 +22,7 @@ FREETYPEINC = /usr/include/freetype2 +@@ -23,7 +23,7 @@ FREETYPEINC = /usr/include/freetype2 # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} @@ -49,7 +38,7 @@ index 7084c33..21b5404 100644 # flags CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} diff --git a/drw.c b/drw.c -index 4cdbcbe..fe3aadd 100644 +index a58a2b4..10e39f9 100644 --- a/drw.c +++ b/drw.c @@ -61,7 +61,7 @@ utf8decode(const char *c, long *u, size_t clen) @@ -84,7 +73,7 @@ index 4cdbcbe..fe3aadd 100644 } void -@@ -194,21 +197,22 @@ drw_fontset_free(Fnt *font) +@@ -181,21 +184,20 @@ drw_fontset_free(Fnt *font) } void @@ -93,46 +82,46 @@ index 4cdbcbe..fe3aadd 100644 { if (!drw || !dest || !clrname) return; - +- - if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen), - DefaultColormap(drw->dpy, drw->screen), -+ if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap, ++ if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap, clrname, dest)) die("error, cannot allocate color '%s'", clrname); -+ -+ dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24); ++ dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24); } /* Wrapper to create color schemes. The caller has to call free(3) on the * returned color scheme when done using it. */ Clr * -drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) -+drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount) ++drw_scm_create(Drw *drw, const char *clrnames[], unsigned int clralphas[], size_t clrcount) { size_t i; Clr *ret; -@@ -218,7 +222,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) +@@ -205,7 +207,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) return NULL; for (i = 0; i < clrcount; i++) - drw_clr_create(drw, &ret[i], clrnames[i]); -+ drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]); ++ drw_clr_create(drw, &ret[i], clrnames[i], clralphas[i]); return ret; } -@@ -274,9 +278,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp +@@ -263,9 +265,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp } else { XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); - d = XftDrawCreate(drw->dpy, drw->drawable, - DefaultVisual(drw->dpy, drw->screen), - DefaultColormap(drw->dpy, drw->screen)); -+ d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); ++ d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); ++ x += lpad; w -= lpad; } diff --git a/drw.h b/drw.h -index 4bcd5ad..a56f523 100644 +index 6471431..51dc017 100644 --- a/drw.h +++ b/drw.h @@ -20,6 +20,9 @@ typedef struct { @@ -150,35 +139,37 @@ index 4bcd5ad..a56f523 100644 /* Drawable abstraction */ -Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); -+Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap); ++Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual*, unsigned int, Colormap); void drw_resize(Drw *drw, unsigned int w, unsigned int h); void drw_free(Drw *drw); -@@ -38,8 +41,8 @@ unsigned int drw_fontset_getwidth(Drw *drw, const char *text); +@@ -39,8 +42,8 @@ unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); /* Colorscheme abstraction */ -void drw_clr_create(Drw *drw, Clr *dest, const char *clrname); -Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); +void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha); -+Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount); ++Clr *drw_scm_create(Drw *drw, const char *clrnames[], unsigned int clralphas[], size_t clrcount); /* Cursor abstraction */ Cur *drw_cur_create(Drw *drw, int shape); diff --git a/dwm.c b/dwm.c -index 664c527..d8005c7 100644 +index e5efb6a..708ca43 100644 --- a/dwm.c +++ b/dwm.c -@@ -57,6 +57,8 @@ +@@ -57,6 +57,10 @@ #define TAGMASK ((1 << LENGTH(tags)) - 1) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) +#define OPAQUE 0xffU + ++#define OPAQUE 0xffU ++ /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { SchemeNorm, SchemeSel }; /* color schemes */ -@@ -233,6 +235,7 @@ static Monitor *wintomon(Window w); +@@ -233,6 +237,7 @@ 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); @@ -186,7 +177,7 @@ index 664c527..d8005c7 100644 static void zoom(const Arg *arg); /* variables */ -@@ -269,6 +272,11 @@ static Drw *drw; +@@ -269,6 +274,11 @@ static Drw *drw; static Monitor *mons, *selmon; static Window root, wmcheckwin; @@ -198,26 +189,28 @@ index 664c527..d8005c7 100644 /* configuration, allows nested code to access above variables */ #include "config.h" -@@ -1542,7 +1550,8 @@ setup(void) +@@ -1542,7 +1552,8 @@ setup(void) sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); root = RootWindow(dpy, screen); - drw = drw_create(dpy, screen, root, sw, sh); -+ xinitvisual(); ++ xinitvisual(); + drw = drw_create(dpy, screen, root, sw, sh, visual, depth, cmap); if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) die("no fonts could be loaded."); lrpad = drw->fonts->h; -@@ -1570,7 +1579,7 @@ setup(void) +@@ -1569,8 +1580,9 @@ setup(void) + cursor[CurMove] = drw_cur_create(drw, XC_fleur); /* init appearance */ scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); ++ unsigned int alphas[] = {borderalpha, baralpha, OPAQUE}; for (i = 0; i < LENGTH(colors); i++) - scheme[i] = drw_scm_create(drw, colors[i], 3); -+ scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3); ++ scheme[i] = drw_scm_create(drw, colors[i], alphas, 3); /* init bars */ updatebars(); updatestatus(); -@@ -1807,16 +1816,18 @@ updatebars(void) +@@ -1803,16 +1815,18 @@ updatebars(void) Monitor *m; XSetWindowAttributes wa = { .override_redirect = True, @@ -240,7 +233,7 @@ index 664c527..d8005c7 100644 XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); XMapRaised(dpy, m->barwin); XSetClassHint(dpy, m->barwin, &ch); -@@ -2113,6 +2124,43 @@ xerrorstart(Display *dpy, XErrorEvent *ee) +@@ -2110,6 +2124,43 @@ xerrorstart(Display *dpy, XErrorEvent *ee) return -1; } @@ -285,5 +278,5 @@ index 664c527..d8005c7 100644 zoom(const Arg *arg) { -- -2.28.0 +2.39.1 diff --git a/wm/dwm-6.3/patches/dwm-cool-autostart-6.2.diff b/wm/dwm-6.4/patches/dwm-cool-autostart-6.2.diff index 84a93ea..84a93ea 100644 --- a/wm/dwm-6.3/patches/dwm-cool-autostart-6.2.diff +++ b/wm/dwm-6.4/patches/dwm-cool-autostart-6.2.diff diff --git a/wm/dwm-6.3/patches/dwm-swallow-20201211-61bb8b2.diff b/wm/dwm-6.4/patches/dwm-swallow-6.3.diff index 6bc0a1f..47586a0 100644 --- a/wm/dwm-6.3/patches/dwm-swallow-20201211-61bb8b2.diff +++ b/wm/dwm-6.4/patches/dwm-swallow-6.3.diff @@ -1,7 +1,7 @@ -From f0cdf40e0a7126838d051eb84d84b91421b771d6 Mon Sep 17 00:00:00 2001 -From: 0x1bi <ben@0x1bi.net> -Date: Fri, 11 Dec 2020 10:16:25 -0500 -Subject: [PATCH] fix swallow for openbsd +From 0cf9a007511f7dfd7dd94171b172562ebac9b6d5 Mon Sep 17 00:00:00 2001 +From: Tom Schwindl <schwindl@posteo.de> +Date: Sat, 10 Sep 2022 12:51:09 +0200 +Subject: [PATCH] 6.3 swallow patch --- config.def.h | 9 +- @@ -10,7 +10,7 @@ Subject: [PATCH] fix swallow for openbsd 3 files changed, 237 insertions(+), 10 deletions(-) diff --git a/config.def.h b/config.def.h -index 1c0b587..fe51476 100644 +index 061ad662f82a..0b2b8ffd30d5 100644 --- a/config.def.h +++ b/config.def.h @@ -3,6 +3,7 @@ @@ -37,13 +37,13 @@ index 1c0b587..fe51476 100644 /* layout(s) */ diff --git a/config.mk b/config.mk -index 7084c33..ff9e508 100644 +index 81c493ef4aff..52d1ebf30bec 100644 --- a/config.mk +++ b/config.mk -@@ -19,10 +19,11 @@ FREETYPELIBS = -lfontconfig -lXft - FREETYPEINC = /usr/include/freetype2 +@@ -20,10 +20,11 @@ FREETYPEINC = /usr/include/freetype2 # OpenBSD (uncomment) #FREETYPEINC = ${X11INC}/freetype2 + #MANPREFIX = ${PREFIX}/man +#KVMLIB = -lkvm # includes and libs @@ -54,7 +54,7 @@ index 7084c33..ff9e508 100644 # flags CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} diff --git a/dwm.c b/dwm.c -index 664c527..0b20086 100644 +index e5efb6a22806..e68294b6b679 100644 --- a/dwm.c +++ b/dwm.c @@ -40,6 +40,12 @@ @@ -71,7 +71,7 @@ index 664c527..0b20086 100644 #include "drw.h" #include "util.h" @@ -92,9 +98,11 @@ struct Client { - int basew, baseh, incw, inch, maxw, maxh, minw, minh; + int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int bw, oldbw; unsigned int tags; - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; @@ -123,7 +123,7 @@ index 664c527..0b20086 100644 c->isfloating = r->isfloating; c->tags |= r->tags; for (m = mons; m && m->num != r->monitor; m = m->next); -@@ -414,6 +434,53 @@ attachstack(Client *c) +@@ -416,6 +436,53 @@ attachstack(Client *c) c->mon->stack = c; } @@ -177,7 +177,7 @@ index 664c527..0b20086 100644 void buttonpress(XEvent *e) { -@@ -653,6 +720,9 @@ destroynotify(XEvent *e) +@@ -656,6 +723,9 @@ destroynotify(XEvent *e) if ((c = wintoclient(ev->window))) unmanage(c, 1); @@ -187,7 +187,7 @@ index 664c527..0b20086 100644 } void -@@ -1018,12 +1088,13 @@ killclient(const Arg *arg) +@@ -1022,12 +1092,13 @@ killclient(const Arg *arg) void manage(Window w, XWindowAttributes *wa) { @@ -202,15 +202,15 @@ index 664c527..0b20086 100644 /* geometry */ c->x = c->oldx = wa->x; c->y = c->oldy = wa->y; -@@ -1038,6 +1109,7 @@ manage(Window w, XWindowAttributes *wa) +@@ -1042,6 +1113,7 @@ manage(Window w, XWindowAttributes *wa) } else { c->mon = selmon; applyrules(c); + term = termforwin(c); } - if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw) -@@ -1074,6 +1146,8 @@ manage(Window w, XWindowAttributes *wa) + if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww) +@@ -1076,6 +1148,8 @@ manage(Window w, XWindowAttributes *wa) c->mon->sel = c; arrange(c->mon); XMapWindow(dpy, c->win); @@ -219,7 +219,7 @@ index 664c527..0b20086 100644 focus(NULL); } -@@ -1768,6 +1842,20 @@ unmanage(Client *c, int destroyed) +@@ -1763,6 +1837,20 @@ unmanage(Client *c, int destroyed) Monitor *m = c->mon; XWindowChanges wc; @@ -240,7 +240,7 @@ index 664c527..0b20086 100644 detach(c); detachstack(c); if (!destroyed) { -@@ -1782,9 +1870,12 @@ unmanage(Client *c, int destroyed) +@@ -1778,9 +1866,12 @@ unmanage(Client *c, int destroyed) XUngrabServer(dpy); } free(c); @@ -256,7 +256,7 @@ index 664c527..0b20086 100644 } void -@@ -2047,6 +2138,136 @@ view(const Arg *arg) +@@ -2044,6 +2135,136 @@ view(const Arg *arg) arrange(selmon); } @@ -393,7 +393,7 @@ index 664c527..0b20086 100644 Client * wintoclient(Window w) { -@@ -2138,10 +2359,12 @@ main(int argc, char *argv[]) +@@ -2133,10 +2354,12 @@ main(int argc, char *argv[]) fputs("warning: no locale support\n", stderr); if (!(dpy = XOpenDisplay(NULL))) die("dwm: cannot open display"); @@ -408,5 +408,5 @@ index 664c527..0b20086 100644 #endif /* __OpenBSD__ */ scan(); -- -2.28.0 +2.37.2 diff --git a/wm/dwm-6.3/patches/dwm-vanitygaps-6.2.diff b/wm/dwm-6.4/patches/dwm-vanitygaps-6.2.diff index 18cbd6d..18cbd6d 100644 --- a/wm/dwm-6.3/patches/dwm-vanitygaps-6.2.diff +++ b/wm/dwm-6.4/patches/dwm-vanitygaps-6.2.diff diff --git a/wm/dwm-6.4/patches/dwm-winicon-6.3-v2.1.diff b/wm/dwm-6.4/patches/dwm-winicon-6.3-v2.1.diff new file mode 100644 index 0000000..4278431 --- /dev/null +++ b/wm/dwm-6.4/patches/dwm-winicon-6.3-v2.1.diff @@ -0,0 +1,371 @@ +diff --git a/config.def.h b/config.def.h +index a2ac963..322d181 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -5,6 +5,8 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ + static const unsigned int snap = 32; /* snap pixel */ + static const int showbar = 1; /* 0 means no bar */ + static const int topbar = 1; /* 0 means bottom bar */ ++#define ICONSIZE 16 /* icon size */ ++#define ICONSPACING 5 /* space between icon and title */ + static const char *fonts[] = { "monospace:size=10" }; + static const char dmenufont[] = "monospace:size=10"; + static const char col_gray1[] = "#222222"; +diff --git a/config.mk b/config.mk +index b6eb7e0..f3c01b0 100644 +--- a/config.mk ++++ b/config.mk +@@ -22,7 +22,7 @@ FREETYPEINC = /usr/include/freetype2 + + # includes and libs + INCS = -I${X11INC} -I${FREETYPEINC} +-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ++LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender -lImlib2 + + # flags + CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} +diff --git a/drw.c b/drw.c +index 4cdbcbe..9b474c5 100644 +--- a/drw.c ++++ b/drw.c +@@ -4,6 +4,7 @@ + #include <string.h> + #include <X11/Xlib.h> + #include <X11/Xft/Xft.h> ++#include <Imlib2.h> + + #include "drw.h" + #include "util.h" +@@ -71,6 +72,7 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h + drw->w = w; + drw->h = h; + drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen)); ++ drw->picture = XRenderCreatePicture(dpy, drw->drawable, XRenderFindVisualFormat(dpy, DefaultVisual(dpy, screen)), 0, NULL); + drw->gc = XCreateGC(dpy, root, 0, NULL); + XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter); + +@@ -85,14 +87,18 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h) + + drw->w = w; + drw->h = h; ++ if (drw->picture) ++ XRenderFreePicture(drw->dpy, drw->picture); + if (drw->drawable) + XFreePixmap(drw->dpy, drw->drawable); + drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen)); ++ drw->picture = XRenderCreatePicture(drw->dpy, drw->drawable, XRenderFindVisualFormat(drw->dpy, DefaultVisual(drw->dpy, drw->screen)), 0, NULL); + } + + void + drw_free(Drw *drw) + { ++ XRenderFreePicture(drw->dpy, drw->picture); + XFreePixmap(drw->dpy, drw->drawable); + XFreeGC(drw->dpy, drw->gc); + drw_fontset_free(drw->fonts); +@@ -236,6 +242,67 @@ drw_setscheme(Drw *drw, Clr *scm) + drw->scheme = scm; + } + ++Picture ++drw_picture_create_resized(Drw *drw, char *src, unsigned int srcw, unsigned int srch, unsigned int dstw, unsigned int dsth) { ++ Pixmap pm; ++ Picture pic; ++ GC gc; ++ ++ if (srcw <= (dstw << 1u) && srch <= (dsth << 1u)) { ++ XImage img = { ++ srcw, srch, 0, ZPixmap, src, ++ ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32, ++ 32, 0, 32, ++ 0, 0, 0 ++ }; ++ XInitImage(&img); ++ ++ pm = XCreatePixmap(drw->dpy, drw->root, srcw, srch, 32); ++ gc = XCreateGC(drw->dpy, pm, 0, NULL); ++ XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, srcw, srch); ++ XFreeGC(drw->dpy, gc); ++ ++ pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL); ++ XFreePixmap(drw->dpy, pm); ++ ++ XRenderSetPictureFilter(drw->dpy, pic, FilterBilinear, NULL, 0); ++ XTransform xf; ++ xf.matrix[0][0] = (srcw << 16u) / dstw; xf.matrix[0][1] = 0; xf.matrix[0][2] = 0; ++ xf.matrix[1][0] = 0; xf.matrix[1][1] = (srch << 16u) / dsth; xf.matrix[1][2] = 0; ++ xf.matrix[2][0] = 0; xf.matrix[2][1] = 0; xf.matrix[2][2] = 65536; ++ XRenderSetPictureTransform(drw->dpy, pic, &xf); ++ } else { ++ Imlib_Image origin = imlib_create_image_using_data(srcw, srch, (DATA32 *)src); ++ if (!origin) return None; ++ imlib_context_set_image(origin); ++ imlib_image_set_has_alpha(1); ++ Imlib_Image scaled = imlib_create_cropped_scaled_image(0, 0, srcw, srch, dstw, dsth); ++ imlib_free_image_and_decache(); ++ if (!scaled) return None; ++ imlib_context_set_image(scaled); ++ imlib_image_set_has_alpha(1); ++ ++ XImage img = { ++ dstw, dsth, 0, ZPixmap, (char *)imlib_image_get_data_for_reading_only(), ++ ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32, ++ 32, 0, 32, ++ 0, 0, 0 ++ }; ++ XInitImage(&img); ++ ++ pm = XCreatePixmap(drw->dpy, drw->root, dstw, dsth, 32); ++ gc = XCreateGC(drw->dpy, pm, 0, NULL); ++ XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, dstw, dsth); ++ imlib_free_image_and_decache(); ++ XFreeGC(drw->dpy, gc); ++ ++ pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL); ++ XFreePixmap(drw->dpy, pm); ++ } ++ ++ return pic; ++} ++ + void + drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert) + { +@@ -379,6 +446,14 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp + return x + (render ? w : 0); + } + ++void ++drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic) ++{ ++ if (!drw) ++ return; ++ XRenderComposite(drw->dpy, PictOpOver, pic, None, drw->picture, 0, 0, 0, 0, x, y, w, h); ++} ++ + void + drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) + { +diff --git a/drw.h b/drw.h +index 4bcd5ad..71aefa2 100644 +--- a/drw.h ++++ b/drw.h +@@ -21,6 +21,7 @@ typedef struct { + int screen; + Window root; + Drawable drawable; ++ Picture picture; + GC gc; + Clr *scheme; + Fnt *fonts; +@@ -49,9 +50,12 @@ void drw_cur_free(Drw *drw, Cur *cursor); + void drw_setfontset(Drw *drw, Fnt *set); + void drw_setscheme(Drw *drw, Clr *scm); + ++Picture drw_picture_create_resized(Drw *drw, char *src, unsigned int src_w, unsigned int src_h, unsigned int dst_w, unsigned int dst_h); ++ + /* Drawing functions */ + void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); + int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); ++void drw_pic(Drw *drw, int x, int y, unsigned int w, unsigned int h, Picture pic); + + /* Map functions */ + void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); +diff --git a/dwm.c b/dwm.c +index a96f33c..033ccec 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -28,6 +28,8 @@ + #include <stdlib.h> + #include <string.h> + #include <unistd.h> ++#include <limits.h> ++#include <stdint.h> + #include <sys/types.h> + #include <sys/wait.h> + #include <X11/cursorfont.h> +@@ -60,7 +62,7 @@ + /* enums */ + enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ + enum { SchemeNorm, SchemeSel }; /* color schemes */ +-enum { NetSupported, NetWMName, NetWMState, NetWMCheck, ++enum { NetSupported, NetWMName, NetWMIcon, NetWMState, NetWMCheck, + NetWMFullscreen, NetActiveWindow, NetWMWindowType, + NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ + enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ +@@ -93,6 +95,7 @@ struct Client { + int bw, oldbw; + unsigned int tags; + int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; ++ unsigned int icw, ich; Picture icon; + Client *next; + Client *snext; + Monitor *mon; +@@ -170,6 +173,7 @@ static void focusin(XEvent *e); + static void focusmon(const Arg *arg); + static void focusstack(const Arg *arg); + static Atom getatomprop(Client *c, Atom prop); ++static Picture geticonprop(Window w, unsigned int *icw, unsigned int *ich); + static int getrootptr(int *x, int *y); + static long getstate(Window w); + static int gettextprop(Window w, Atom atom, char *text, unsigned int size); +@@ -214,6 +218,7 @@ static void togglebar(const Arg *arg); + static void togglefloating(const Arg *arg); + static void toggletag(const Arg *arg); + static void toggleview(const Arg *arg); ++static void freeicon(Client *c); + static void unfocus(Client *c, int setfocus); + static void unmanage(Client *c, int destroyed); + static void unmapnotify(XEvent *e); +@@ -225,6 +230,7 @@ static void updatenumlockmask(void); + static void updatesizehints(Client *c); + static void updatestatus(void); + static void updatetitle(Client *c); ++static void updateicon(Client *c); + static void updatewindowtype(Client *c); + static void updatewmhints(Client *c); + static void view(const Arg *arg); +@@ -735,7 +741,8 @@ drawbar(Monitor *m) + if ((w = m->ww - tw - x) > bh) { + if (m->sel) { + drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); +- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); ++ drw_text(drw, x, 0, w, bh, lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0), m->sel->name, 0); ++ if (m->sel->icon) drw_pic(drw, x + lrpad / 2, (bh - m->sel->ich) / 2, m->sel->icw, m->sel->ich, m->sel->icon); + if (m->sel->isfloating) + drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); + } else { +@@ -875,6 +882,67 @@ getatomprop(Client *c, Atom prop) + return atom; + } + ++static uint32_t prealpha(uint32_t p) { ++ uint8_t a = p >> 24u; ++ uint32_t rb = (a * (p & 0xFF00FFu)) >> 8u; ++ uint32_t g = (a * (p & 0x00FF00u)) >> 8u; ++ return (rb & 0xFF00FFu) | (g & 0x00FF00u) | (a << 24u); ++} ++ ++Picture ++geticonprop(Window win, unsigned int *picw, unsigned int *pich) ++{ ++ int format; ++ unsigned long n, extra, *p = NULL; ++ Atom real; ++ ++ if (XGetWindowProperty(dpy, win, netatom[NetWMIcon], 0L, LONG_MAX, False, AnyPropertyType, ++ &real, &format, &n, &extra, (unsigned char **)&p) != Success) ++ return None; ++ if (n == 0 || format != 32) { XFree(p); return None; } ++ ++ unsigned long *bstp = NULL; ++ uint32_t w, h, sz; ++ { ++ unsigned long *i; const unsigned long *end = p + n; ++ uint32_t bstd = UINT32_MAX, d, m; ++ for (i = p; i < end - 1; i += sz) { ++ if ((w = *i++) >= 16384 || (h = *i++) >= 16384) { XFree(p); return None; } ++ if ((sz = w * h) > end - i) break; ++ if ((m = w > h ? w : h) >= ICONSIZE && (d = m - ICONSIZE) < bstd) { bstd = d; bstp = i; } ++ } ++ if (!bstp) { ++ for (i = p; i < end - 1; i += sz) { ++ if ((w = *i++) >= 16384 || (h = *i++) >= 16384) { XFree(p); return None; } ++ if ((sz = w * h) > end - i) break; ++ if ((d = ICONSIZE - (w > h ? w : h)) < bstd) { bstd = d; bstp = i; } ++ } ++ } ++ if (!bstp) { XFree(p); return None; } ++ } ++ ++ if ((w = *(bstp - 2)) == 0 || (h = *(bstp - 1)) == 0) { XFree(p); return None; } ++ ++ uint32_t icw, ich; ++ if (w <= h) { ++ ich = ICONSIZE; icw = w * ICONSIZE / h; ++ if (icw == 0) icw = 1; ++ } ++ else { ++ icw = ICONSIZE; ich = h * ICONSIZE / w; ++ if (ich == 0) ich = 1; ++ } ++ *picw = icw; *pich = ich; ++ ++ uint32_t i, *bstp32 = (uint32_t *)bstp; ++ for (sz = w * h, i = 0; i < sz; ++i) bstp32[i] = prealpha(bstp[i]); ++ ++ Picture ret = drw_picture_create_resized(drw, (char *)bstp, w, h, icw, ich); ++ XFree(p); ++ ++ return ret; ++} ++ + int + getrootptr(int *x, int *y) + { +@@ -1034,6 +1102,7 @@ manage(Window w, XWindowAttributes *wa) + c->h = c->oldh = wa->height; + c->oldbw = wa->border_width; + ++ updateicon(c); + updatetitle(c); + if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { + c->mon = t->mon; +@@ -1244,6 +1313,11 @@ propertynotify(XEvent *e) + if (c == c->mon->sel) + drawbar(c->mon); + } ++ else if (ev->atom == netatom[NetWMIcon]) { ++ updateicon(c); ++ if (c == c->mon->sel) ++ drawbar(c->mon); ++ } + if (ev->atom == netatom[NetWMWindowType]) + updatewindowtype(c); + } +@@ -1560,6 +1634,7 @@ setup(void) + netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); + netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); + netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); ++ netatom[NetWMIcon] = XInternAtom(dpy, "_NET_WM_ICON", False); + netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); + netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); + netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); +@@ -1752,6 +1827,15 @@ toggleview(const Arg *arg) + } + } + ++void ++freeicon(Client *c) ++{ ++ if (c->icon) { ++ XRenderFreePicture(dpy, c->icon); ++ c->icon = None; ++ } ++} ++ + void + unfocus(Client *c, int setfocus) + { +@@ -1773,6 +1857,7 @@ unmanage(Client *c, int destroyed) + + detach(c); + detachstack(c); ++ freeicon(c); + if (!destroyed) { + wc.border_width = c->oldbw; + XGrabServer(dpy); /* avoid race conditions */ +@@ -2007,6 +2092,13 @@ updatetitle(Client *c) + strcpy(c->name, broken); + } + ++void ++updateicon(Client *c) ++{ ++ freeicon(c); ++ c->icon = geticonprop(c->win, &c->icw, &c->ich); ++} ++ + void + updatewindowtype(Client *c) + { diff --git a/wm/dwm-6.3/transient.c b/wm/dwm-6.4/transient.c index 040adb5..040adb5 100644 --- a/wm/dwm-6.3/transient.c +++ b/wm/dwm-6.4/transient.c diff --git a/wm/dwm-6.3/util.c b/wm/dwm-6.4/util.c index fe044fc..96b82c9 100644 --- a/wm/dwm-6.3/util.c +++ b/wm/dwm-6.4/util.c @@ -6,18 +6,9 @@ #include "util.h" -void * -ecalloc(size_t nmemb, size_t size) -{ - void *p; - - if (!(p = calloc(nmemb, size))) - die("calloc:"); - return p; -} - void -die(const char *fmt, ...) { +die(const char *fmt, ...) +{ va_list ap; va_start(ap, fmt); @@ -33,3 +24,13 @@ die(const char *fmt, ...) { exit(1); } + +void * +ecalloc(size_t nmemb, size_t size) +{ + void *p; + + if (!(p = calloc(nmemb, size))) + die("calloc:"); + return p; +} diff --git a/wm/dwm-6.3/util.h b/wm/dwm-6.4/util.h index f633b51..f633b51 100644 --- a/wm/dwm-6.3/util.h +++ b/wm/dwm-6.4/util.h diff --git a/wm/dwm-6.3/vanitygaps.c b/wm/dwm-6.4/vanitygaps.c index d81f8c6..3f31593 100644 --- a/wm/dwm-6.3/vanitygaps.c +++ b/wm/dwm-6.4/vanitygaps.c @@ -1,3 +1,13 @@ +/* Key binding functions */ +static void defaultgaps(const Arg *arg); +static void incrgaps(const Arg *arg); +static void incrigaps(const Arg *arg); +static void incrogaps(const Arg *arg); +static void incrohgaps(const Arg *arg); +static void incrovgaps(const Arg *arg); +static void incrihgaps(const Arg *arg); +static void incrivgaps(const Arg *arg); +static void togglegaps(const Arg *arg); /* Layouts (delete the ones you do not need) */ static void bstack(Monitor *m); static void bstackhoriz(Monitor *m); @@ -36,6 +46,100 @@ setgaps(int oh, int ov, int ih, int iv) } void +togglegaps(const Arg *arg) +{ + #if PERTAG_PATCH + selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag]; + #else + enablegaps = !enablegaps; + #endif // PERTAG_PATCH + arrange(NULL); +} + +void +defaultgaps(const Arg *arg) +{ + setgaps(gappoh, gappov, gappih, gappiv); +} + +void +incrgaps(const Arg *arg) +{ + setgaps( + selmon->gappoh + arg->i, + selmon->gappov + arg->i, + selmon->gappih + arg->i, + selmon->gappiv + arg->i + ); +} + +void +incrigaps(const Arg *arg) +{ + setgaps( + selmon->gappoh, + selmon->gappov, + selmon->gappih + arg->i, + selmon->gappiv + arg->i + ); +} + +void +incrogaps(const Arg *arg) +{ + setgaps( + selmon->gappoh + arg->i, + selmon->gappov + arg->i, + selmon->gappih, + selmon->gappiv + ); +} + +void +incrohgaps(const Arg *arg) +{ + setgaps( + selmon->gappoh + arg->i, + selmon->gappov, + selmon->gappih, + selmon->gappiv + ); +} + +void +incrovgaps(const Arg *arg) +{ + setgaps( + selmon->gappoh, + selmon->gappov + arg->i, + selmon->gappih, + selmon->gappiv + ); +} + +void +incrihgaps(const Arg *arg) +{ + setgaps( + selmon->gappoh, + selmon->gappov, + selmon->gappih + arg->i, + selmon->gappiv + ); +} + +void +incrivgaps(const Arg *arg) +{ + setgaps( + selmon->gappoh, + selmon->gappov, + selmon->gappih, + selmon->gappiv + arg->i + ); +} + +void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc) { unsigned int n, oe, ie; @@ -702,4 +806,4 @@ tile(Monitor *m) resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); sy += HEIGHT(c) + ih; } -} +}
\ No newline at end of file |