From f60b0b5121fb68e4dbb76036ec3efd24fe6c904c Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sun, 15 Sep 2019 23:33:43 +0200 Subject: [PATCH] Adding winview patch --- README.md | 8 ++++++++ config.def.h | 33 ++++++++++++++++++++++----------- patch/include.c | 4 ++++ patch/include.h | 4 ++++ patch/selfrestart.c | 4 ++-- patch/winview.c | 20 ++++++++++++++++++++ patch/winview.h | 1 + patch/xrdb.c | 8 ++++---- patches.h | 9 ++++++++- 9 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 patch/winview.c create mode 100644 patch/winview.h diff --git a/README.md b/README.md index c770f66..0252bd2 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2019-09-15 - Added xrdb and winview patches + 2019-09-14 - Added setborderpx, selfrestart and push (no master variant), sticky and warp patches 2019-09-13 - Added titlecolor and push patches @@ -162,6 +164,12 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - sometimes a single application opens different windows depending on the task at hand and this is often reflected in the WM_WINDOW_ROLE(STRING) x property - this patch adds the role field to the rule configuration so that one can differentiate between, say, Firefox "browser" vs "Preferences" vs "Manager" or Google-chrome "browser" vs "pop-up". + - [winview](http://dwm.suckless.org/patches/winview/) + - allows switching the view to that of a given client from the all-window view (Mod-0) using a keyboard shortcut + + - [xrdb](http://dwm.suckless.org/patches/xrdb/) + - allows dwm to read colors from xrdb (.Xresources) during runtime + - [zoomswap](https://dwm.suckless.org/patches/zoomswap/) - allows a master and a stack window to swap places rather than every window on the screen changing position diff --git a/config.def.h b/config.def.h index fc5b9f9..55d20c1 100644 --- a/config.def.h +++ b/config.def.h @@ -29,14 +29,14 @@ static char normfgcolor[] = "#bbbbbb"; static char normbgcolor[] = "#222222"; static char normbordercolor[] = "#444444"; #if FLOAT_BORDER_COLOR_PATCH -static char normflcolor[] = "#db8fd9"; +static char normfloatcolor[] = "#db8fd9"; #endif // FLOAT_BORDER_COLOR_PATCH static char selfgcolor[] = "#eeeeee"; static char selbgcolor[] = "#005577"; static char selbordercolor[] = "#005577"; #if FLOAT_BORDER_COLOR_PATCH -static char selflcolor[] = "#005577"; +static char selfloatcolor[] = "#005577"; #endif // FLOAT_BORDER_COLOR_PATCH #if AWESOMEBAR_PATCH @@ -44,7 +44,7 @@ static char hidfgcolor[] = "#005577"; static char hidbgcolor[] = "#222222"; static char hidbordercolor[] = "#005577"; #if FLOAT_BORDER_COLOR_PATCH -static char hidflcolor[] = "#f76e0c"; +static char hidfloatcolor[] = "#f76e0c"; #endif // FLOAT_BORDER_COLOR_PATCH #endif // AWESOMEBAR_PATCH @@ -53,7 +53,7 @@ static char titlefgcolor[] = "#eeeeee"; static char titlebgcolor[] = "#005577"; static char titlebordercolor[] = "#005577"; #if FLOAT_BORDER_COLOR_PATCH -static char titleflcolor[] = "#005577"; +static char titlefloatcolor[] = "#005577"; #endif // FLOAT_BORDER_COLOR_PATCH #endif // TITLECOLOR_PATCH @@ -73,19 +73,27 @@ static const unsigned int alphas[][3] = { }; #endif // ALPHA_PATCH #if FLOAT_BORDER_COLOR_PATCH -static char *colors[][4] = { - /* fg bg border float */ - [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor, normflcolor }, - [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor, selflcolor }, +static +#if !XRDB_PATCH +const +#endif // XRDB_PATCH +char *colors[][4] = { + /* fg bg border float */ + [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor, normfloatcolor }, + [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor, selfloatcolor }, #if AWESOMEBAR_PATCH - [SchemeHid] = { hidfgcolor, hidbgcolor, hidbordercolor, hidflcolor }, + [SchemeHid] = { hidfgcolor, hidbgcolor, hidbordercolor, hidfloatcolor }, #endif // AWESOMEBAR_PATCH #if TITLECOLOR_PATCH - [SchemeTitle] = { titlefgcolor, titlebgcolor, titlebordercolor, titleflcolor }, + [SchemeTitle] = { titlefgcolor, titlebgcolor, titlebordercolor, titlefloatcolor }, #endif // TITLECOLOR_PATCH }; #else -static char *colors[][3] = { +static +#if !XRDB_PATCH +const +#endif // XRDB_PATCH +char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, @@ -304,6 +312,9 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_r, self_restart, {0} }, #endif // SELFRESTART_PATCH { MODKEY|ShiftMask, XK_q, quit, {0} }, + #if WINVIEW_PATCH + { MODKEY, XK_o, winview, {0} }, + #endif // WINVIEW_PATCH #if XRDB_PATCH { MODKEY|ShiftMask, XK_F5, xrdb, {.v = NULL } }, #endif // XRDB_PATCH diff --git a/patch/include.c b/patch/include.c index 4597d51..bae6733 100644 --- a/patch/include.c +++ b/patch/include.c @@ -86,6 +86,10 @@ #include "warp.c" #endif +#if WINVIEW_PATCH +#include "winview.c" +#endif + #if ZOOMSWAP_PATCH #include "zoomswap.c" #endif diff --git a/patch/include.h b/patch/include.h index 2a6001b..cf4b9a4 100644 --- a/patch/include.h +++ b/patch/include.h @@ -82,6 +82,10 @@ #include "warp.h" #endif +#if WINVIEW_PATCH +#include "winview.h" +#endif + #if ZOOMSWAP_PATCH #include "zoomswap.h" #endif diff --git a/patch/selfrestart.c b/patch/selfrestart.c index 4fa6527..c3b88c1 100644 --- a/patch/selfrestart.c +++ b/patch/selfrestart.c @@ -43,7 +43,7 @@ char *get_dwm_path() perror("readlink:"); return NULL; } - } while(r >= length); + } while (r >= length); path[r] = '\0'; @@ -65,4 +65,4 @@ void self_restart(const Arg *arg) } execv(argv[0], argv); -} \ No newline at end of file +} diff --git a/patch/winview.c b/patch/winview.c new file mode 100644 index 0000000..a73ee66 --- /dev/null +++ b/patch/winview.c @@ -0,0 +1,20 @@ +/* Selects for the view of the focused window. The list of tags */ +/* to be displayed is matched to the focused window tag list. */ +void +winview(const Arg* arg) +{ + Window win, win_r, win_p, *win_c; + unsigned nc; + int unused; + Client* c; + Arg a; + + if (!XGetInputFocus(dpy, &win, &unused)) return; + while (XQueryTree(dpy, win, &win_r, &win_p, &win_c, &nc) + && win_p != win_r) win = win_p; + + if (!(c = wintoclient(win))) return; + + a.ui = c->tags; + view(&a); +} \ No newline at end of file diff --git a/patch/winview.h b/patch/winview.h new file mode 100644 index 0000000..a240533 --- /dev/null +++ b/patch/winview.h @@ -0,0 +1 @@ +static void winview(const Arg* arg); \ No newline at end of file diff --git a/patch/xrdb.c b/patch/xrdb.c index 07c6d96..c5ffa76 100644 --- a/patch/xrdb.c +++ b/patch/xrdb.c @@ -20,14 +20,14 @@ loadxrdb() XRDB_LOAD_COLOR("dwm.normbgcolor", normbgcolor); XRDB_LOAD_COLOR("dwm.normbordercolor", normbordercolor); #if FLOAT_BORDER_COLOR_PATCH - XRDB_LOAD_COLOR("dwm.normflcolor", normflcolor); + XRDB_LOAD_COLOR("dwm.normfloatcolor", normfloatcolor); #endif // FLOAT_BORDER_COLOR_PATCH XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor); XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor); XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor); #if FLOAT_BORDER_COLOR_PATCH - XRDB_LOAD_COLOR("dwm.selflcolor", selflcolor); + XRDB_LOAD_COLOR("dwm.selfloatcolor", selfloatcolor); #endif // FLOAT_BORDER_COLOR_PATCH #if AWESOMEBAR_PATCH @@ -35,7 +35,7 @@ loadxrdb() XRDB_LOAD_COLOR("dwm.hidbgcolor", hidbgcolor); XRDB_LOAD_COLOR("dwm.hidbordercolor", hidbordercolor); #if FLOAT_BORDER_COLOR_PATCH - XRDB_LOAD_COLOR("dwm.hidflcolor", hidflcolor); + XRDB_LOAD_COLOR("dwm.hidfloatcolor", hidfloatcolor); #endif // FLOAT_BORDER_COLOR_PATCH #endif // AWESOMEBAR_PATCH @@ -44,7 +44,7 @@ loadxrdb() XRDB_LOAD_COLOR("dwm.titlebgcolor", titlebgcolor); XRDB_LOAD_COLOR("dwm.titlebordercolor", titlebordercolor); #if FLOAT_BORDER_COLOR_PATCH - XRDB_LOAD_COLOR("dwm.titleflcolor", titleflcolor); + XRDB_LOAD_COLOR("dwm.titlefloatcolor", titlefloatcolor); #endif // FLOAT_BORDER_COLOR_PATCH #endif // TITLECOLOR_PATCH } diff --git a/patches.h b/patches.h index 3ddb5c5..b24dc49 100644 --- a/patches.h +++ b/patches.h @@ -285,7 +285,14 @@ */ #define WINDOWROLERULE_PATCH 0 -/* Allows dwm to read colors from xrdb (.Xresources) at run time. +/* The winview patch allows switching the view to that of a given client from the all-window + * view (Mod-0) using a keyboard shortcut. + * http://dwm.suckless.org/patches/winview/ + */ +#define WINVIEW_PATCH 0 + +/* Allows dwm to read colors from xrdb (.Xresources) during runtime. Compatible with + * the float border color, awesomebar and titlecolor patches. * https://dwm.suckless.org/patches/xrdb/ */ #define XRDB_PATCH 0