Init
This commit is contained in:
321
patches/dwm-alttab-20220709-d3f93c7.diff
Normal file
321
patches/dwm-alttab-20220709-d3f93c7.diff
Normal file
@@ -0,0 +1,321 @@
|
||||
From ec9fcfe019623ec6aff6476b6838eb4863098cf0 Mon Sep 17 00:00:00 2001
|
||||
From: ViliamKovac1223 <viliamkovac1223@gmail.com>
|
||||
Date: Sat, 9 Jul 2022 02:58:18 +0200
|
||||
Subject: [PATCH] add alt-tab functionality
|
||||
|
||||
---
|
||||
config.def.h | 11 ++-
|
||||
dwm.c | 218 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 228 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..3760870 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -1,5 +1,13 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
+/* alt-tab configuration */
|
||||
+static const unsigned int tabModKey = 0x40; /* if this key is hold the alt-tab functionality stays acitve. This key must be the same as key that is used to active functin altTabStart `*/
|
||||
+static const unsigned int tabCycleKey = 0x17; /* if this key is hit the alt-tab program moves one position forward in clients stack. This key must be the same as key that is used to active functin altTabStart */
|
||||
+static const unsigned int tabPosY = 1; /* tab position on Y axis, 0 = bottom, 1 = center, 2 = top */
|
||||
+static const unsigned int tabPosX = 1; /* tab position on X axis, 0 = left, 1 = center, 2 = right */
|
||||
+static const unsigned int maxWTab = 600; /* tab menu width */
|
||||
+static const unsigned int maxHTab = 200; /* tab menu height */
|
||||
+
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
@@ -72,7 +80,7 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY, XK_Return, zoom, {0} },
|
||||
- { MODKEY, XK_Tab, view, {0} },
|
||||
+ { MODKEY, XK_q, view, {0} },
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
@@ -85,6 +93,7 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||
+ { Mod1Mask, XK_Tab, altTabStart, {0} },
|
||||
TAGKEYS( XK_1, 0)
|
||||
TAGKEYS( XK_2, 1)
|
||||
TAGKEYS( XK_3, 2)
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 5646a5c..90edf9b 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif /* XINERAMA */
|
||||
#include <X11/Xft/Xft.h>
|
||||
+#include <time.h>
|
||||
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
@@ -119,6 +120,11 @@ struct Monitor {
|
||||
int by; /* bar geometry */
|
||||
int mx, my, mw, mh; /* screen size */
|
||||
int wx, wy, ww, wh; /* window area */
|
||||
+ int altTabN; /* move that many clients forward */
|
||||
+ int nTabs; /* number of active clients in tag */
|
||||
+ int isAlt; /* 1,0 */
|
||||
+ int maxWTab;
|
||||
+ int maxHTab;
|
||||
unsigned int seltags;
|
||||
unsigned int sellt;
|
||||
unsigned int tagset[2];
|
||||
@@ -127,8 +133,10 @@ struct Monitor {
|
||||
Client *clients;
|
||||
Client *sel;
|
||||
Client *stack;
|
||||
+ Client ** altsnext; /* array of all clients in the tag */
|
||||
Monitor *next;
|
||||
Window barwin;
|
||||
+ Window tabwin;
|
||||
const Layout *lt[2];
|
||||
};
|
||||
|
||||
@@ -234,6 +242,9 @@ static int xerror(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
+void drawTab(int nwins, int first, Monitor *m);
|
||||
+void altTabStart(const Arg *arg);
|
||||
+static void altTabEnd();
|
||||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
@@ -477,6 +488,7 @@ cleanup(void)
|
||||
Monitor *m;
|
||||
size_t i;
|
||||
|
||||
+ altTabEnd();
|
||||
view(&a);
|
||||
selmon->lt[selmon->sellt] = &foo;
|
||||
for (m = mons; m; m = m->next)
|
||||
@@ -644,6 +656,7 @@ createmon(void)
|
||||
m->topbar = topbar;
|
||||
m->lt[0] = &layouts[0];
|
||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||
+ m->nTabs = 0;
|
||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||
return m;
|
||||
}
|
||||
@@ -1659,6 +1672,211 @@ spawn(const Arg *arg)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+altTab()
|
||||
+{
|
||||
+ /* move to next window */
|
||||
+ if (selmon->sel != NULL && selmon->sel->snext != NULL) {
|
||||
+ selmon->altTabN++;
|
||||
+ if (selmon->altTabN >= selmon->nTabs)
|
||||
+ selmon->altTabN = 0; /* reset altTabN */
|
||||
+
|
||||
+ focus(selmon->altsnext[selmon->altTabN]);
|
||||
+ restack(selmon);
|
||||
+ }
|
||||
+
|
||||
+ /* redraw tab */
|
||||
+ XRaiseWindow(dpy, selmon->tabwin);
|
||||
+ drawTab(selmon->nTabs, 0, selmon);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+altTabEnd()
|
||||
+{
|
||||
+ if (selmon->isAlt == 0)
|
||||
+ return;
|
||||
+
|
||||
+ /*
|
||||
+ * move all clients between 1st and choosen position,
|
||||
+ * one down in stack and put choosen client to the first position
|
||||
+ * so they remain in right order for the next time that alt-tab is used
|
||||
+ */
|
||||
+ if (selmon->nTabs > 1) {
|
||||
+ if (selmon->altTabN != 0) { /* if user picked original client do nothing */
|
||||
+ Client *buff = selmon->altsnext[selmon->altTabN];
|
||||
+ if (selmon->altTabN > 1)
|
||||
+ for (int i = selmon->altTabN;i > 0;i--)
|
||||
+ selmon->altsnext[i] = selmon->altsnext[i - 1];
|
||||
+ else /* swap them if there are just 2 clients */
|
||||
+ selmon->altsnext[selmon->altTabN] = selmon->altsnext[0];
|
||||
+ selmon->altsnext[0] = buff;
|
||||
+ }
|
||||
+
|
||||
+ /* restack clients */
|
||||
+ for (int i = selmon->nTabs - 1;i >= 0;i--) {
|
||||
+ focus(selmon->altsnext[i]);
|
||||
+ restack(selmon);
|
||||
+ }
|
||||
+
|
||||
+ free(selmon->altsnext); /* free list of clients */
|
||||
+ }
|
||||
+
|
||||
+ /* turn off/destroy the window */
|
||||
+ selmon->isAlt = 0;
|
||||
+ selmon->nTabs = 0;
|
||||
+ XUnmapWindow(dpy, selmon->tabwin);
|
||||
+ XDestroyWindow(dpy, selmon->tabwin);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+drawTab(int nwins, int first, Monitor *m)
|
||||
+{
|
||||
+ /* little documentation of 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_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); */
|
||||
+
|
||||
+ Client *c;
|
||||
+ int h;
|
||||
+
|
||||
+ if (first) {
|
||||
+ Monitor *m = selmon;
|
||||
+ XSetWindowAttributes wa = {
|
||||
+ .override_redirect = True,
|
||||
+ .background_pixmap = ParentRelative,
|
||||
+ .event_mask = ButtonPressMask|ExposureMask
|
||||
+ };
|
||||
+
|
||||
+ selmon->maxWTab = maxWTab;
|
||||
+ selmon->maxHTab = maxHTab;
|
||||
+
|
||||
+ /* decide position of tabwin */
|
||||
+ int posX = 0;
|
||||
+ int posY = 0;
|
||||
+ if (tabPosX == 0)
|
||||
+ posX = 0;
|
||||
+ if (tabPosX == 1)
|
||||
+ posX = (selmon->mw / 2) - (maxWTab / 2);
|
||||
+ if (tabPosX == 2)
|
||||
+ posX = selmon->mw - maxWTab;
|
||||
+
|
||||
+ if (tabPosY == 0)
|
||||
+ posY = selmon->mh - maxHTab;
|
||||
+ if (tabPosY == 1)
|
||||
+ posY = (selmon->mh / 2) - (maxHTab / 2);
|
||||
+ if (tabPosY == 2)
|
||||
+ posY = 0;
|
||||
+
|
||||
+ h = selmon->maxHTab;
|
||||
+ /* XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual, valuemask, attributes); just reference */
|
||||
+ m->tabwin = XCreateWindow(dpy, root, posX, posY, selmon->maxWTab, selmon->maxHTab, 2, DefaultDepth(dpy, screen),
|
||||
+ CopyFromParent, DefaultVisual(dpy, screen),
|
||||
+ CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); /* create tabwin */
|
||||
+
|
||||
+ XDefineCursor(dpy, m->tabwin, cursor[CurNormal]->cursor);
|
||||
+ XMapRaised(dpy, m->tabwin);
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ h = selmon->maxHTab / m->nTabs;
|
||||
+
|
||||
+ int y = 0;
|
||||
+ int n = 0;
|
||||
+ for (int i = 0;i < m->nTabs;i++) { /* draw all clients into tabwin */
|
||||
+ c = m->altsnext[i];
|
||||
+ if(!ISVISIBLE(c)) continue;
|
||||
+ /* if (HIDDEN(c)) continue; uncomment if you're using awesomebar patch */
|
||||
+
|
||||
+ n++;
|
||||
+ drw_setscheme(drw, scheme[(c == m->sel) ? SchemeSel : SchemeNorm]);
|
||||
+ drw_text(drw, 0, y, selmon->maxWTab, h, 0, c->name, 0);
|
||||
+ y += h;
|
||||
+ }
|
||||
+
|
||||
+ drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
+ drw_map(drw, m->tabwin, 0, 0, selmon->maxWTab, selmon->maxHTab);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+altTabStart(const Arg *arg)
|
||||
+{
|
||||
+ selmon->altsnext = NULL;
|
||||
+ if (selmon->tabwin)
|
||||
+ altTabEnd();
|
||||
+
|
||||
+ if (selmon->isAlt == 1) {
|
||||
+ altTabEnd();
|
||||
+ } else {
|
||||
+ selmon->isAlt = 1;
|
||||
+ selmon->altTabN = 0;
|
||||
+
|
||||
+ Client *c;
|
||||
+ Monitor *m = selmon;
|
||||
+
|
||||
+ m->nTabs = 0;
|
||||
+ for(c = m->clients; c; c = c->next) { /* count clients */
|
||||
+ if(!ISVISIBLE(c)) continue;
|
||||
+ /* if (HIDDEN(c)) continue; uncomment if you're using awesomebar patch */
|
||||
+
|
||||
+ ++m->nTabs;
|
||||
+ }
|
||||
+
|
||||
+ if (m->nTabs > 0) {
|
||||
+ m->altsnext = (Client **) malloc(m->nTabs * sizeof(Client *));
|
||||
+
|
||||
+ int listIndex = 0;
|
||||
+ for(c = m->stack; c; c = c->snext) { /* add clients to the list */
|
||||
+ if(!ISVISIBLE(c)) continue;
|
||||
+ /* if (HIDDEN(c)) continue; uncomment if you're using awesomebar patch */
|
||||
+
|
||||
+ m->altsnext[listIndex++] = c;
|
||||
+ }
|
||||
+
|
||||
+ drawTab(m->nTabs, 1, m);
|
||||
+
|
||||
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 };
|
||||
+
|
||||
+ /* grab keyboard (take all input from keyboard) */
|
||||
+ int grabbed = 1;
|
||||
+ for (int i = 0;i < 1000;i++) {
|
||||
+ if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
|
||||
+ break;
|
||||
+ nanosleep(&ts, NULL);
|
||||
+ if (i == 1000 - 1)
|
||||
+ grabbed = 0;
|
||||
+ }
|
||||
+
|
||||
+ XEvent event;
|
||||
+ altTab();
|
||||
+ if (grabbed == 0) {
|
||||
+ altTabEnd();
|
||||
+ } else {
|
||||
+ while (grabbed) {
|
||||
+ XNextEvent(dpy, &event);
|
||||
+ if (event.type == KeyPress || event.type == KeyRelease) {
|
||||
+ if (event.type == KeyRelease && event.xkey.keycode == tabModKey) { /* if super key is released break cycle */
|
||||
+ break;
|
||||
+ } else if (event.type == KeyPress) {
|
||||
+ if (event.xkey.keycode == tabCycleKey) {/* if XK_s is pressed move to the next window */
|
||||
+ altTab();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ c = selmon->sel;
|
||||
+ altTabEnd(); /* end the alt-tab functionality */
|
||||
+ /* XUngrabKeyboard(display, time); just a reference */
|
||||
+ XUngrabKeyboard(dpy, CurrentTime); /* stop taking all input from keyboard */
|
||||
+ focus(c);
|
||||
+ restack(selmon);
|
||||
+ }
|
||||
+ } else {
|
||||
+ altTabEnd(); /* end the alt-tab functionality */
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
tag(const Arg *arg)
|
||||
{
|
||||
--
|
||||
2.35.1
|
||||
|
||||
12
patches/dwm-alwayscenter-20200625-f04cac6.diff
Normal file
12
patches/dwm-alwayscenter-20200625-f04cac6.diff
Normal file
@@ -0,0 +1,12 @@
|
||||
diff -up dwm/dwm.c dwmmod/dwm.c
|
||||
--- dwm/dwm.c 2020-06-25 00:21:30.383692180 -0300
|
||||
+++ dwmmod/dwm.c 2020-06-25 00:20:35.643692330 -0300
|
||||
@@ -1057,6 +1057,8 @@ manage(Window w, XWindowAttributes *wa)
|
||||
updatewindowtype(c);
|
||||
updatesizehints(c);
|
||||
updatewmhints(c);
|
||||
+ c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
|
||||
+ c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
|
||||
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||
grabbuttons(c, 0);
|
||||
if (!c->isfloating)
|
||||
93
patches/dwm-cyclelayouts-20180524-6.2.diff
Normal file
93
patches/dwm-cyclelayouts-20180524-6.2.diff
Normal file
@@ -0,0 +1,93 @@
|
||||
From a09e766a4342f580582082a92b2de65f33208eb4 Mon Sep 17 00:00:00 2001
|
||||
From: Christopher Drelich <cd@cdrakka.com>
|
||||
Date: Thu, 24 May 2018 00:56:56 -0400
|
||||
Subject: [PATCH] Function to cycle through available layouts.
|
||||
|
||||
MOD-CTRL-, and MOD-CTRL-.
|
||||
cycle backwards and forwards through available layouts.
|
||||
Probably only useful if you have a lot of additional layouts.
|
||||
The NULL, NULL layout should always be the last layout in your list,
|
||||
in order to guarantee consistent behavior.
|
||||
---
|
||||
config.def.h | 3 +++
|
||||
dwm.1 | 6 ++++++
|
||||
dwm.c | 18 ++++++++++++++++++
|
||||
3 files changed, 27 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a9ac303..153b880 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -41,6 +41,7 @@ static const Layout layouts[] = {
|
||||
{ "[]=", tile }, /* first entry is default */
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
+ { NULL, NULL },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
@@ -76,6 +77,8 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
+ { MODKEY|ControlMask, XK_comma, cyclelayout, {.i = -1 } },
|
||||
+ { MODKEY|ControlMask, XK_period, cyclelayout, {.i = +1 } },
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
diff --git a/dwm.1 b/dwm.1
|
||||
index 13b3729..165891b 100644
|
||||
--- a/dwm.1
|
||||
+++ b/dwm.1
|
||||
@@ -92,6 +92,12 @@ Sets monocle layout.
|
||||
.B Mod1\-space
|
||||
Toggles between current and previous layout.
|
||||
.TP
|
||||
+.B Mod1\-Control\-,
|
||||
+Cycles backwards in layout list.
|
||||
+.TP
|
||||
+.B Mod1\-Control\-.
|
||||
+Cycles forwards in layout list.
|
||||
+.TP
|
||||
.B Mod1\-j
|
||||
Focus next window.
|
||||
.TP
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index bb95e26..db73000 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -157,6 +157,7 @@ static void configure(Client *c);
|
||||
static void configurenotify(XEvent *e);
|
||||
static void configurerequest(XEvent *e);
|
||||
static Monitor *createmon(void);
|
||||
+static void cyclelayout(const Arg *arg);
|
||||
static void destroynotify(XEvent *e);
|
||||
static void detach(Client *c);
|
||||
static void detachstack(Client *c);
|
||||
@@ -645,6 +646,23 @@ createmon(void)
|
||||
}
|
||||
|
||||
void
|
||||
+cyclelayout(const Arg *arg) {
|
||||
+ Layout *l;
|
||||
+ for(l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++);
|
||||
+ if(arg->i > 0) {
|
||||
+ if(l->symbol && (l + 1)->symbol)
|
||||
+ setlayout(&((Arg) { .v = (l + 1) }));
|
||||
+ else
|
||||
+ setlayout(&((Arg) { .v = layouts }));
|
||||
+ } else {
|
||||
+ if(l != layouts && (l - 1)->symbol)
|
||||
+ setlayout(&((Arg) { .v = (l - 1) }));
|
||||
+ else
|
||||
+ setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] }));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
destroynotify(XEvent *e)
|
||||
{
|
||||
Client *c;
|
||||
--
|
||||
2.7.4
|
||||
|
||||
114
patches/dwm-fibonacci-6.2.diff
Normal file
114
patches/dwm-fibonacci-6.2.diff
Normal file
@@ -0,0 +1,114 @@
|
||||
From ec9f55b6005cfa3b025b3d700c61af3ce539d057 Mon Sep 17 00:00:00 2001
|
||||
From: Niki Yoshiuchi <nyoshiuchi@gmail.com>
|
||||
Date: Sat, 18 Apr 2020 09:55:26 -0700
|
||||
Subject: [PATCH] Adding the fibonacci layout patch
|
||||
|
||||
---
|
||||
config.def.h | 5 ++++
|
||||
fibonacci.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 71 insertions(+)
|
||||
create mode 100644 fibonacci.c
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..5708487 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -36,11 +36,14 @@ 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 */
|
||||
|
||||
+#include "fibonacci.c"
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
{ "[]=", tile }, /* first entry is default */
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
+ { "[@]", spiral },
|
||||
+ { "[\\]", dwindle },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
@@ -76,6 +79,8 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
+ { MODKEY, XK_r, setlayout, {.v = &layouts[3]} },
|
||||
+ { MODKEY|ShiftMask, XK_r, setlayout, {.v = &layouts[4]} },
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
diff --git a/fibonacci.c b/fibonacci.c
|
||||
new file mode 100644
|
||||
index 0000000..fce0a57
|
||||
--- /dev/null
|
||||
+++ b/fibonacci.c
|
||||
@@ -0,0 +1,66 @@
|
||||
+void
|
||||
+fibonacci(Monitor *mon, int s) {
|
||||
+ unsigned int i, n, nx, ny, nw, nh;
|
||||
+ Client *c;
|
||||
+
|
||||
+ for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++);
|
||||
+ if(n == 0)
|
||||
+ return;
|
||||
+
|
||||
+ nx = mon->wx;
|
||||
+ ny = 0;
|
||||
+ nw = mon->ww;
|
||||
+ nh = mon->wh;
|
||||
+
|
||||
+ for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) {
|
||||
+ if((i % 2 && nh / 2 > 2 * c->bw)
|
||||
+ || (!(i % 2) && nw / 2 > 2 * c->bw)) {
|
||||
+ if(i < n - 1) {
|
||||
+ if(i % 2)
|
||||
+ nh /= 2;
|
||||
+ else
|
||||
+ nw /= 2;
|
||||
+ if((i % 4) == 2 && !s)
|
||||
+ nx += nw;
|
||||
+ else if((i % 4) == 3 && !s)
|
||||
+ ny += nh;
|
||||
+ }
|
||||
+ if((i % 4) == 0) {
|
||||
+ if(s)
|
||||
+ ny += nh;
|
||||
+ else
|
||||
+ ny -= nh;
|
||||
+ }
|
||||
+ else if((i % 4) == 1)
|
||||
+ nx += nw;
|
||||
+ else if((i % 4) == 2)
|
||||
+ ny += nh;
|
||||
+ else if((i % 4) == 3) {
|
||||
+ if(s)
|
||||
+ nx += nw;
|
||||
+ else
|
||||
+ nx -= nw;
|
||||
+ }
|
||||
+ if(i == 0)
|
||||
+ {
|
||||
+ if(n != 1)
|
||||
+ nw = mon->ww * mon->mfact;
|
||||
+ ny = mon->wy;
|
||||
+ }
|
||||
+ else if(i == 1)
|
||||
+ nw = mon->ww - nw;
|
||||
+ i++;
|
||||
+ }
|
||||
+ resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+dwindle(Monitor *mon) {
|
||||
+ fibonacci(mon, 1);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+spiral(Monitor *mon) {
|
||||
+ fibonacci(mon, 0);
|
||||
+}
|
||||
--
|
||||
2.20.1
|
||||
|
||||
46
patches/dwm-focusmaster-20210804-138b405.diff
Normal file
46
patches/dwm-focusmaster-20210804-138b405.diff
Normal file
@@ -0,0 +1,46 @@
|
||||
From 3e020d93df3aaec92d2daa142cd1f0d5301b3197 Mon Sep 17 00:00:00 2001
|
||||
From: Mateus Auler <mateusauler@protonmail.com>
|
||||
Date: Fri, 17 Jul 2020 12:36:36 -0300
|
||||
Subject: [PATCH] Ability to map a key combination to switch focus to
|
||||
the master window.
|
||||
|
||||
---
|
||||
dwm.c | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 9fd0286..be01927 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -235,6 +235,8 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
|
||||
+static void focusmaster(const Arg *arg);
|
||||
+
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
static char stext[256];
|
||||
@@ -2150,3 +2152,19 @@ main(int argc, char *argv[])
|
||||
XCloseDisplay(dpy);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+
|
||||
+void
|
||||
+focusmaster(const Arg *arg)
|
||||
+{
|
||||
+ Client *c;
|
||||
+
|
||||
+ if (selmon->nmaster < 1)
|
||||
+ return;
|
||||
+ if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
|
||||
+ return;
|
||||
+
|
||||
+ c = nexttiled(selmon->clients);
|
||||
+
|
||||
+ if (c)
|
||||
+ focus(c);
|
||||
+}
|
||||
--
|
||||
2.27.0
|
||||
|
||||
177
patches/dwm-pertag-20200914-61bb8b2.diff
Normal file
177
patches/dwm-pertag-20200914-61bb8b2.diff
Normal file
@@ -0,0 +1,177 @@
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 664c527..ac8e4ec 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -111,6 +111,7 @@ typedef struct {
|
||||
void (*arrange)(Monitor *);
|
||||
} Layout;
|
||||
|
||||
+typedef struct Pertag Pertag;
|
||||
struct Monitor {
|
||||
char ltsymbol[16];
|
||||
float mfact;
|
||||
@@ -130,6 +131,7 @@ struct Monitor {
|
||||
Monitor *next;
|
||||
Window barwin;
|
||||
const Layout *lt[2];
|
||||
+ Pertag *pertag;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -272,6 +274,15 @@ static Window root, wmcheckwin;
|
||||
/* configuration, allows nested code to access above variables */
|
||||
#include "config.h"
|
||||
|
||||
+struct Pertag {
|
||||
+ unsigned int curtag, prevtag; /* current and previous tag */
|
||||
+ int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
|
||||
+ float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
|
||||
+ unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
|
||||
+ const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
|
||||
+ int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
|
||||
+};
|
||||
+
|
||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||
|
||||
@@ -632,6 +643,7 @@ Monitor *
|
||||
createmon(void)
|
||||
{
|
||||
Monitor *m;
|
||||
+ unsigned int i;
|
||||
|
||||
m = ecalloc(1, sizeof(Monitor));
|
||||
m->tagset[0] = m->tagset[1] = 1;
|
||||
@@ -642,6 +654,20 @@ createmon(void)
|
||||
m->lt[0] = &layouts[0];
|
||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||
+ m->pertag = ecalloc(1, sizeof(Pertag));
|
||||
+ m->pertag->curtag = m->pertag->prevtag = 1;
|
||||
+
|
||||
+ for (i = 0; i <= LENGTH(tags); i++) {
|
||||
+ m->pertag->nmasters[i] = m->nmaster;
|
||||
+ m->pertag->mfacts[i] = m->mfact;
|
||||
+
|
||||
+ m->pertag->ltidxs[i][0] = m->lt[0];
|
||||
+ m->pertag->ltidxs[i][1] = m->lt[1];
|
||||
+ m->pertag->sellts[i] = m->sellt;
|
||||
+
|
||||
+ m->pertag->showbars[i] = m->showbar;
|
||||
+ }
|
||||
+
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -967,7 +993,7 @@ grabkeys(void)
|
||||
void
|
||||
incnmaster(const Arg *arg)
|
||||
{
|
||||
- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
@@ -1502,9 +1528,9 @@ void
|
||||
setlayout(const Arg *arg)
|
||||
{
|
||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||
- selmon->sellt ^= 1;
|
||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
||||
if (arg && arg->v)
|
||||
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
||||
if (selmon->sel)
|
||||
arrange(selmon);
|
||||
@@ -1523,7 +1549,7 @@ setmfact(const Arg *arg)
|
||||
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
||||
if (f < 0.05 || f > 0.95)
|
||||
return;
|
||||
- selmon->mfact = f;
|
||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
@@ -1702,7 +1728,7 @@ tile(Monitor *m)
|
||||
void
|
||||
togglebar(const Arg *arg)
|
||||
{
|
||||
- selmon->showbar = !selmon->showbar;
|
||||
+ selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
|
||||
updatebarpos(selmon);
|
||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
||||
arrange(selmon);
|
||||
@@ -1741,9 +1767,33 @@ void
|
||||
toggleview(const Arg *arg)
|
||||
{
|
||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
||||
+ int i;
|
||||
|
||||
if (newtagset) {
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
+
|
||||
+ if (newtagset == ~0) {
|
||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
+ selmon->pertag->curtag = 0;
|
||||
+ }
|
||||
+
|
||||
+ /* test if the user did not select the same tag */
|
||||
+ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
+ for (i = 0; !(newtagset & 1 << i); i++) ;
|
||||
+ selmon->pertag->curtag = i + 1;
|
||||
+ }
|
||||
+
|
||||
+ /* apply settings for this view */
|
||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||
+
|
||||
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||
+ togglebar(NULL);
|
||||
+
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
}
|
||||
@@ -2038,11 +2088,37 @@ updatewmhints(Client *c)
|
||||
void
|
||||
view(const Arg *arg)
|
||||
{
|
||||
+ int i;
|
||||
+ unsigned int tmptag;
|
||||
+
|
||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||
return;
|
||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||
- if (arg->ui & TAGMASK)
|
||||
+ if (arg->ui & TAGMASK) {
|
||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
+
|
||||
+ if (arg->ui == ~0)
|
||||
+ selmon->pertag->curtag = 0;
|
||||
+ else {
|
||||
+ for (i = 0; !(arg->ui & 1 << i); i++) ;
|
||||
+ selmon->pertag->curtag = i + 1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ tmptag = selmon->pertag->prevtag;
|
||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
+ selmon->pertag->curtag = tmptag;
|
||||
+ }
|
||||
+
|
||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||
+
|
||||
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
||||
+ togglebar(NULL);
|
||||
+
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
}
|
||||
101
patches/dwm-uselessgap-20211119-58414bee958f2.diff
Normal file
101
patches/dwm-uselessgap-20211119-58414bee958f2.diff
Normal file
@@ -0,0 +1,101 @@
|
||||
From 58414bee958f2e7ed91d6fe31f503ec4a406981b Mon Sep 17 00:00:00 2001
|
||||
From: cirala <thim@cederlund.de>
|
||||
Date: Fri, 19 Nov 2021 18:14:07 +0100
|
||||
Subject: [PATCH] Fix for dwm-uselessgap
|
||||
Previous versions of the patch doubles the
|
||||
gap between the master and slave stacks.
|
||||
|
||||
---
|
||||
config.def.h | 3 ++-
|
||||
dwm.c | 38 +++++++++++++++++++++++++++++++-------
|
||||
2 files changed, 33 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..17a205f 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
+static const unsigned int gappx = 6; /* gaps between 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 */
|
||||
@@ -34,7 +35,7 @@ static const Rule rules[] = {
|
||||
/* 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 resizehints = 0; /* 1 means respect size hints in tiled resizals */
|
||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||
|
||||
static const Layout layouts[] = {
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 5e4d494..b626e89 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -52,8 +52,8 @@
|
||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||
-#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||
-#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||
+#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
|
||||
+#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
|
||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
|
||||
@@ -1277,12 +1277,36 @@ void
|
||||
resizeclient(Client *c, int x, int y, int w, int h)
|
||||
{
|
||||
XWindowChanges wc;
|
||||
+ unsigned int n;
|
||||
+ unsigned int gapoffset;
|
||||
+ unsigned int gapincr;
|
||||
+ Client *nbc;
|
||||
|
||||
- c->oldx = c->x; c->x = wc.x = x;
|
||||
- c->oldy = c->y; c->y = wc.y = y;
|
||||
- c->oldw = c->w; c->w = wc.width = w;
|
||||
- c->oldh = c->h; c->h = wc.height = h;
|
||||
wc.border_width = c->bw;
|
||||
+
|
||||
+ /* Get number of clients for the client's monitor */
|
||||
+ for (n = 0, nbc = nexttiled(c->mon->clients); nbc; nbc = nexttiled(nbc->next), n++);
|
||||
+
|
||||
+ /* Do nothing if layout is floating */
|
||||
+ if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
|
||||
+ gapincr = gapoffset = 0;
|
||||
+ } else {
|
||||
+ /* Remove border and gap if layout is monocle or only one client */
|
||||
+ if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) {
|
||||
+ gapoffset = 0;
|
||||
+ gapincr = -2 * borderpx;
|
||||
+ wc.border_width = 0;
|
||||
+ } else {
|
||||
+ gapoffset = gappx;
|
||||
+ gapincr = 2 * gappx;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ c->oldx = c->x; c->x = wc.x = x + gapoffset;
|
||||
+ c->oldy = c->y; c->y = wc.y = y + gapoffset;
|
||||
+ c->oldw = c->w; c->w = wc.width = w - gapincr;
|
||||
+ c->oldh = c->h; c->h = wc.height = h - gapincr;
|
||||
+
|
||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
||||
configure(c);
|
||||
XSync(dpy, False);
|
||||
@@ -1688,7 +1712,7 @@ tile(Monitor *m)
|
||||
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||
if (i < m->nmaster) {
|
||||
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||
- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
||||
+ resize(c, m->wx, m->wy + my, mw - (2*c->bw) + (n > 1 ? gappx : 0), h - (2*c->bw), 0);
|
||||
if (my + HEIGHT(c) < m->wh)
|
||||
my += HEIGHT(c);
|
||||
} else {
|
||||
--
|
||||
2.33.1
|
||||
|
||||
Reference in New Issue
Block a user