diff options
author | Suleyman Farajli <suleyman@farajli.net> | 2024-08-29 13:18:14 +0400 |
---|---|---|
committer | Suleyman Farajli <suleyman@farajli.net> | 2024-08-29 13:18:14 +0400 |
commit | 098c1e81c5024c792af36547475896e325fe7b20 (patch) | |
tree | 9e937752e3d1da95ad18dd64877b485a3dd31643 | |
parent | d53e17f288580e81b574ba608d36cda731f790d5 (diff) |
float mode focus and tiling mode focus seperated
-rw-r--r-- | config.h | 3 | ||||
-rw-r--r-- | dwm.c | 72 |
2 files changed, 61 insertions, 14 deletions
@@ -4,7 +4,7 @@ /* appearance */ static const unsigned int borderpx = 2; /* border pixel of windows */ -static const int startwithgaps = 1; /* 1 means gaps are used by default */ +static const int startwithgaps = 1; /* 1 means gaps are used by default */ static const unsigned int gappx = 16; /* default gap between windows in pixels */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ @@ -103,6 +103,7 @@ static const Key keys[] = { { MODKEY, XK_equal, setgaps, {.i = +1 } }, { MODKEY, XK_v, focusmaster, {0} }, + { MODKEY, XK_a, togglefocusfloat, {0} }, { MODKEY, XK_s, togglescratch, {.v = scratchpadcmd } }, @@ -215,6 +215,7 @@ static void tagmon(const Arg *arg); static void tile(Monitor *m); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); +static void togglefocusfloat(const Arg *arg); static void togglescratch(const Arg *arg); static void togglefullscr(const Arg *arg); static void toggletag(const Arg *arg); @@ -269,6 +270,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { }; static Atom wmatom[WMLast], netatom[NetLast]; static int running = 1; +static int focusfloat = 0; static Cur *cursor[CurLast]; static Clr **scheme; static Display *dpy; @@ -826,6 +828,12 @@ focus(Client *c) XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XDeleteProperty(dpy, root, netatom[NetActiveWindow]); } + + if (c && c->isfloating) + focusfloat = 1; + else if (c && !c->isfloating) + focusfloat = 0; + selmon->sel = c; drawbars(); } @@ -862,17 +870,37 @@ focusstack(const Arg *arg) if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen)) return; if (arg->i > 0) { - for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next); - if (!c) - for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next); + if (focusfloat) + for (c = selmon->sel->next; c && (!ISVISIBLE(c) || !c->isfloating); c = c->next); + else + for (c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next); + if (focusfloat && !c) + for (c = selmon->clients; c && (!ISVISIBLE(c) || !c->isfloating); c = c->next); + if (!focusfloat && !c) + for (c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next); } else { - for (i = selmon->clients; i != selmon->sel; i = i->next) - if (ISVISIBLE(i)) - c = i; - if (!c) - for (; i; i = i->next) - if (ISVISIBLE(i)) + for (i = selmon->clients; i != selmon->sel; i = i->next) { + if(!focusfloat) { + if (ISVISIBLE(i) && !i->isfloating) c = i; + } else { + if (ISVISIBLE(i) && i->isfloating) + c = i; + } + } + + if (!c) { + for (; i; i = i->next) { + if(!focusfloat) { + if (ISVISIBLE(i) && !i->isfloating) + c = i; + } else { + if (ISVISIBLE(i) && i->isfloating) + c = i; + + } + } + } } if (c) { focus(c); @@ -880,6 +908,23 @@ focusstack(const Arg *arg) } } +void +togglefocusfloat(const Arg *arg) +{ + Client *c = NULL; + + if(focusfloat) { + c = nexttiled(selmon->clients); + } else if (!selmon->sel->isfullscreen) { /* Prevent focus shifting in fullscreen */ + for (c = selmon->clients; c; c = c->next) + if (c->isfloating) + break; + } + + if(c) + focus(c); +} + Atom getatomprop(Client *c, Atom prop) { @@ -1459,12 +1504,12 @@ setborderpx(const Arg *arg) if (arg->i == 0) selmon->borderpx = borderpx; else if (selmon->borderpx + arg->i < 0) - selmon->borderpx = 0; + selmon->borderpx = 0; else - selmon->borderpx += arg->i; - + selmon->borderpx += arg->i; + for (c = selmon->clients; c; c = c->next) - { + { if (c->bw + arg->i < 0) c->bw = selmon->borderpx = 0; else @@ -1792,6 +1837,7 @@ togglefloating(const Arg *arg) if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ return; selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; + focusfloat = !focusfloat; if (selmon->sel->isfloating) resize(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h, 0); |