sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit d9fce82372dd08acbb05640b1bb9e57ca968f2e7
parent a069579f03cc3e24297f368b893dabf74367d411
Author: Georgios Oxinos <oxinosg@gmail.com>
Date:   Fri,  5 Feb 2021 21:11:46 +0100

[dwm][cantogglefloating] single client fix

Diffstat:
Ddwm.suckless.org/patches/cantogglefloating/dwm-cantogglefloating-20210125-fc30936.diff | 148-------------------------------------------------------------------------------
Adwm.suckless.org/patches/cantogglefloating/dwm-cantogglefloating-20210205-f42c25c.diff | 152+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdwm.suckless.org/patches/cantogglefloating/index.md | 2+-
3 files changed, 153 insertions(+), 149 deletions(-)

diff --git a/dwm.suckless.org/patches/cantogglefloating/dwm-cantogglefloating-20210125-fc30936.diff b/dwm.suckless.org/patches/cantogglefloating/dwm-cantogglefloating-20210125-fc30936.diff @@ -1,148 +0,0 @@ -From fc309367ecf8388a77f899d7f007524a84ed3ab7 Mon Sep 17 00:00:00 2001 -From: Georgios Oxinos <georgios.oxinos.extern@elinvar.de> -Date: Mon, 25 Jan 2021 10:24:45 +0100 -Subject: [PATCH] [dwm][patch] patch that allows disabling focus on floating - clients - ---- - config.def.h | 1 + - dwm.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++----- - 2 files changed, 59 insertions(+), 5 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 1c0b587..005fb5d 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -70,6 +70,7 @@ static Key keys[] = { - { MODKEY, XK_d, incnmaster, {.i = -1 } }, - { MODKEY, XK_h, setmfact, {.f = -0.05} }, - { MODKEY, XK_l, setmfact, {.f = +0.05} }, -+ { MODKEY, XK_s, togglecanfocusfloating, {0} }, - { MODKEY, XK_Return, zoom, {0} }, - { MODKEY, XK_Tab, view, {0} }, - { MODKEY|ShiftMask, XK_c, killclient, {0} }, -diff --git a/dwm.c b/dwm.c -index 4465af1..d6417d6 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -92,7 +92,7 @@ struct Client { - int basew, baseh, incw, inch, maxw, maxh, minw, minh; - int bw, oldbw; - unsigned int tags; -- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; -+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, cantfocus; - Client *next; - Client *snext; - Monitor *mon; -@@ -138,6 +138,7 @@ typedef struct { - const char *title; - unsigned int tags; - int isfloating; -+ int cantfocus; - int monitor; - } Rule; - -@@ -191,6 +192,7 @@ static Monitor *recttomon(int x, int y, int w, int h); - static void resize(Client *c, int x, int y, int w, int h, int interact); - static void resizeclient(Client *c, int x, int y, int w, int h); - static void resizemouse(const Arg *arg); -+static void resetcanfocusfloating(); - static void restack(Monitor *m); - static void run(void); - static void scan(void); -@@ -211,6 +213,7 @@ static void tagmon(const Arg *arg); - static void tile(Monitor *); - static void togglebar(const Arg *arg); - static void togglefloating(const Arg *arg); -+static void togglecanfocusfloating(const Arg *arg); - static void toggletag(const Arg *arg); - static void toggleview(const Arg *arg); - static void unfocus(Client *c, int setfocus); -@@ -788,6 +791,8 @@ focus(Client *c) - if (selmon->sel && selmon->sel != c) - unfocus(selmon->sel, 0); - if (c) { -+ if (c->cantfocus) -+ return; - if (c->mon != selmon) - selmon = c->mon; - if (c->isurgent) -@@ -837,16 +842,16 @@ focusstack(const Arg *arg) - if (!selmon->sel) - return; - if (arg->i > 0) { -- for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next); -+ for (c = selmon->sel->next; c && (!ISVISIBLE(c) || c->cantfocus); c = c->next); - if (!c) -- for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next); -+ for (c = selmon->clients; c && (!ISVISIBLE(c) || c->cantfocus); c = c->next); - } else { - for (i = selmon->clients; i != selmon->sel; i = i->next) -- if (ISVISIBLE(i)) -+ if (ISVISIBLE(i) && !i->cantfocus) - c = i; - if (!c) - for (; i; i = i->next) -- if (ISVISIBLE(i)) -+ if (ISVISIBLE(i) && !i->cantfocus) - c = i; - } - if (c) { -@@ -1716,6 +1721,54 @@ togglefloating(const Arg *arg) - if (selmon->sel->isfloating) - resize(selmon->sel, selmon->sel->x, selmon->sel->y, - selmon->sel->w, selmon->sel->h, 0); -+ -+ resetcanfocusfloating(); -+ -+ arrange(selmon); -+} -+ -+void -+resetcanfocusfloating() -+{ -+ unsigned int i, n; -+ Client *c; -+ -+ for (n = 0, c = selmon->clients; c; c = c->next, n++); -+ if (n == 0) -+ return; -+ -+ for (i = 0, c = selmon->clients; c; c = c->next, i++) -+ if (c->isfloating) -+ c->cantfocus = 0; -+ -+ arrange(selmon); -+} -+ -+void -+togglecanfocusfloating(const Arg *arg) -+{ -+ unsigned int i, n, y; -+ Client *c, *tmp; -+ -+ for (n = 0, c = selmon->clients; c; c = c->next, n++); -+ if (n == 0) -+ return; -+ -+ for (i = 0, y = 0, c = selmon->clients; c; c = c->next, i++) -+ if (c->isfloating) { -+ c->cantfocus = !c->cantfocus; -+ y++; -+ } -+ -+ if (y && selmon->sel->isfloating) { -+ tmp = selmon->clients; -+ while (!tmp || tmp->isfloating) { -+ tmp = tmp->next; -+ } -+ -+ focus(tmp); -+ } -+ - arrange(selmon); - } - --- -2.27.0 - diff --git a/dwm.suckless.org/patches/cantogglefloating/dwm-cantogglefloating-20210205-f42c25c.diff b/dwm.suckless.org/patches/cantogglefloating/dwm-cantogglefloating-20210205-f42c25c.diff @@ -0,0 +1,152 @@ +From f42c25cf04c10cd042f36346423256aae4e4b80c Mon Sep 17 00:00:00 2001 +From: Georgios Oxinos <georgios.oxinos.extern@elinvar.de> +Date: Fri, 5 Feb 2021 21:06:04 +0100 +Subject: [PATCH] [dwm][cantogglefloating] patch that allows disabling focus on + floating clients + +--- + config.def.h | 1 + + dwm.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++---- + 2 files changed, 63 insertions(+), 5 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1c0b587..005fb5d 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -70,6 +70,7 @@ static Key keys[] = { + { MODKEY, XK_d, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, ++ { MODKEY, XK_s, togglecanfocusfloating, {0} }, + { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY|ShiftMask, XK_c, killclient, {0} }, +diff --git a/dwm.c b/dwm.c +index 664c527..a80f7b6 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -92,7 +92,7 @@ struct Client { + int basew, baseh, incw, inch, maxw, maxh, minw, minh; + int bw, oldbw; + unsigned int tags; +- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; ++ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, cantfocus; + Client *next; + Client *snext; + Monitor *mon; +@@ -138,6 +138,7 @@ typedef struct { + const char *title; + unsigned int tags; + int isfloating; ++ int cantfocus; + int monitor; + } Rule; + +@@ -192,6 +193,7 @@ static Monitor *recttomon(int x, int y, int w, int h); + static void resize(Client *c, int x, int y, int w, int h, int interact); + static void resizeclient(Client *c, int x, int y, int w, int h); + static void resizemouse(const Arg *arg); ++static void resetcanfocusfloating(); + static void restack(Monitor *m); + static void run(void); + static void scan(void); +@@ -212,6 +214,7 @@ static void tagmon(const Arg *arg); + static void tile(Monitor *); + static void togglebar(const Arg *arg); + static void togglefloating(const Arg *arg); ++static void togglecanfocusfloating(const Arg *arg); + static void toggletag(const Arg *arg); + static void toggleview(const Arg *arg); + static void unfocus(Client *c, int setfocus); +@@ -789,6 +792,8 @@ focus(Client *c) + if (selmon->sel && selmon->sel != c) + unfocus(selmon->sel, 0); + if (c) { ++ if (c->cantfocus) ++ return; + if (c->mon != selmon) + selmon = c->mon; + if (c->isurgent) +@@ -838,16 +843,16 @@ focusstack(const Arg *arg) + if (!selmon->sel) + return; + if (arg->i > 0) { +- for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next); ++ for (c = selmon->sel->next; c && (!ISVISIBLE(c) || c->cantfocus); c = c->next); + if (!c) +- for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next); ++ for (c = selmon->clients; c && (!ISVISIBLE(c) || c->cantfocus); c = c->next); + } else { + for (i = selmon->clients; i != selmon->sel; i = i->next) +- if (ISVISIBLE(i)) ++ if (ISVISIBLE(i) && !i->cantfocus) + c = i; + if (!c) + for (; i; i = i->next) +- if (ISVISIBLE(i)) ++ if (ISVISIBLE(i) && !i->cantfocus) + c = i; + } + if (c) { +@@ -1719,6 +1724,58 @@ togglefloating(const Arg *arg) + if (selmon->sel->isfloating) + resize(selmon->sel, selmon->sel->x, selmon->sel->y, + selmon->sel->w, selmon->sel->h, 0); ++ ++ resetcanfocusfloating(); ++ ++ arrange(selmon); ++} ++ ++void ++resetcanfocusfloating() ++{ ++ unsigned int i, n; ++ Client *c; ++ ++ for (n = 0, c = selmon->clients; c; c = c->next, n++); ++ if (n == 0) ++ return; ++ ++ for (i = 0, c = selmon->clients; c; c = c->next, i++) ++ if (c->isfloating) ++ c->cantfocus = 0; ++ ++ arrange(selmon); ++} ++ ++void ++togglecanfocusfloating(const Arg *arg) ++{ ++ unsigned int i, n, y; ++ Client *c, *tmp; ++ ++ for (n = 0, c = selmon->clients; c; c = c->next) ++ if (c && !c->isfloating) ++ n++; ++ if (n == 0) { ++ resetcanfocusfloating(); ++ return; ++ } ++ ++ for (i = 0, y = 0, c = selmon->clients; c; c = c->next, i++) ++ if (c->isfloating) { ++ c->cantfocus = !c->cantfocus; ++ y++; ++ } ++ ++ if (y && selmon->sel->isfloating) { ++ tmp = selmon->clients; ++ while (!tmp || tmp->isfloating) { ++ tmp = tmp->next; ++ } ++ ++ focus(tmp); ++ } ++ + arrange(selmon); + } + +-- +2.27.0 + diff --git a/dwm.suckless.org/patches/cantogglefloating/index.md b/dwm.suckless.org/patches/cantogglefloating/index.md @@ -9,7 +9,7 @@ Inspired by [canfocusrule](https://dwm.suckless.org/patches/canfocusrule/) patch Download -------- -* [dwm-cantogglefloating-20210125-fc30936.diff](dwm-cantogglefloating-20210125-fc30936.diff) +* [dwm-cantogglefloating-20210205-f42c25c.diff](dwm-cantogglefloating-20210205-f42c25c.diff) Authors -------