Compare commits
5 Commits
684ff9bb71
...
7ffccdd3c9
Author | SHA1 | Date | |
---|---|---|---|
|
7ffccdd3c9 | ||
|
c88efa050f | ||
|
9ef6996bd6 | ||
|
1241bda940 | ||
|
8b5f4911c1 |
@ -4,6 +4,7 @@
|
||||
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 unsigned int minwsz = 20; /* Minimal heigt of a client for smfact */
|
||||
static const int showbar = 1; /* 0 means no standard bar */
|
||||
static const int topbar = 1; /* 0 means standard bar at bottom */
|
||||
static const int extrabar = 1; /* 0 means no extra bar */
|
||||
@ -51,6 +52,7 @@ static const Rule rules[] = {
|
||||
#define WFDEFAULT WFINACTIVE
|
||||
|
||||
/* layout(s) */
|
||||
static const float smfact = 0.00; /* factor of tiled clients [0.00..0.95] */
|
||||
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 */
|
||||
@ -94,6 +96,8 @@ static const Key keys[] = {
|
||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY|ShiftMask, XK_h, setsmfact, {.f = +0.05} },
|
||||
{ MODKEY|ShiftMask, XK_l, setsmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_Return, zoom, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||
|
76
dwm.c
76
dwm.c
@ -80,6 +80,7 @@ typedef union {
|
||||
int i;
|
||||
unsigned int ui;
|
||||
float f;
|
||||
float sf;
|
||||
const void *v;
|
||||
} Arg;
|
||||
|
||||
@ -128,6 +129,7 @@ struct Monitor {
|
||||
char ltsymbol[16];
|
||||
char wfsymbol[2];
|
||||
float mfact;
|
||||
float smfact;
|
||||
int nmaster;
|
||||
int num;
|
||||
int by; /* bar geometry */
|
||||
@ -232,6 +234,7 @@ static void setfocus(Client *c);
|
||||
static void setfullscreen(Client *c, int fullscreen);
|
||||
static void setlayout(const Arg *arg);
|
||||
static void setmfact(const Arg *arg);
|
||||
static void setsmfact(const Arg *arg);
|
||||
static void setup(void);
|
||||
static void seturgent(Client *c, int urg);
|
||||
static void show(const Arg *arg);
|
||||
@ -265,7 +268,6 @@ static void updatetitle(Client *c);
|
||||
static void updatewindowtype(Client *c);
|
||||
static void updatewmhints(Client *c);
|
||||
static void view(const Arg *arg);
|
||||
static void warp(const Client *c);
|
||||
static Client *wintoclient(Window w);
|
||||
static Monitor *wintomon(Window w);
|
||||
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||
@ -332,6 +334,7 @@ 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 */
|
||||
float smfacts[LENGTH(tags) + 1]; /* smfacts 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 */
|
||||
@ -783,6 +786,7 @@ createmon(void)
|
||||
m = ecalloc(1, sizeof(Monitor));
|
||||
m->tagset[0] = m->tagset[1] = 1;
|
||||
m->mfact = mfact;
|
||||
m->smfact = smfact;
|
||||
m->nmaster = nmaster;
|
||||
m->showbar = showbar;
|
||||
m->topbar = topbar;
|
||||
@ -796,6 +800,7 @@ createmon(void)
|
||||
for (i = 0; i <= LENGTH(tags); i++) {
|
||||
m->pertag->nmasters[i] = m->nmaster;
|
||||
m->pertag->mfacts[i] = m->mfact;
|
||||
m->pertag->smfacts[i] = m->smfact;
|
||||
|
||||
m->pertag->ltidxs[i][0] = m->lt[0];
|
||||
m->pertag->ltidxs[i][1] = m->lt[1];
|
||||
@ -1048,7 +1053,6 @@ focusmon(const Arg *arg)
|
||||
unfocus(selmon->sel, 0);
|
||||
selmon = m;
|
||||
focus(NULL);
|
||||
warp(selmon->sel);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1766,8 +1770,6 @@ restack(Monitor *m)
|
||||
wc.sibling = c->win;
|
||||
}
|
||||
}
|
||||
if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && m->lt[m->sellt]->arrange != &monocle)
|
||||
warp(m->sel);
|
||||
XSync(dpy, False);
|
||||
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
@ -1956,6 +1958,28 @@ setmfact(const Arg *arg)
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
setsmfact(const Arg *arg) {
|
||||
float sf;
|
||||
unsigned int i;
|
||||
|
||||
if(!arg || !selmon->lt[selmon->sellt]->arrange)
|
||||
return;
|
||||
sf = arg->sf < 1.0 ? arg->sf + selmon->smfact : arg->sf - 1.0;
|
||||
if(sf < 0 || sf > 0.9)
|
||||
return;
|
||||
selmon->smfact = sf;
|
||||
for(i=0; i<LENGTH(tags); ++i)
|
||||
if(selmon->tagset[selmon->seltags] & 1<<i)
|
||||
selmon->pertag->smfacts[i+1] = sf;
|
||||
|
||||
if(selmon->pertag->curtag == 0)
|
||||
{
|
||||
selmon->pertag->smfacts[0] = sf;
|
||||
}
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
setup(void)
|
||||
{
|
||||
@ -2178,7 +2202,7 @@ tagmon(const Arg *arg)
|
||||
void
|
||||
tile(Monitor *m)
|
||||
{
|
||||
unsigned int i, n, h, mw, my, ty;
|
||||
unsigned int i, n, h, smh, mw, my, ty;
|
||||
Client *c;
|
||||
|
||||
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||
@ -2196,9 +2220,25 @@ tile(Monitor *m)
|
||||
if (my + HEIGHT(c) < m->wh)
|
||||
my += HEIGHT(c);
|
||||
} else {
|
||||
|
||||
smh = m->mh * m->smfact;
|
||||
if(!(nexttiled(c->next)))
|
||||
h = (m->wh - ty) / (n - i);
|
||||
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
||||
else
|
||||
h = (m->wh - smh - ty) / (n - i);
|
||||
if(h < minwsz) {
|
||||
c->isfloating = True;
|
||||
XRaiseWindow(dpy, c->win);
|
||||
resize(c, m->mx + (m->mw / 2 - WIDTH(c) / 2), m->my + (m->mh / 2 - HEIGHT(c) / 2), m->ww - mw - (2*c->bw), h - (2*c->bw), False);
|
||||
ty -= HEIGHT(c);
|
||||
}
|
||||
else
|
||||
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False);
|
||||
if(!(nexttiled(c->next))) {
|
||||
if (ty + HEIGHT(c) < m->wh)
|
||||
ty += HEIGHT(c) + smh;
|
||||
}
|
||||
else if (ty + HEIGHT(c) < m->wh)
|
||||
ty += HEIGHT(c);
|
||||
}
|
||||
}
|
||||
@ -2303,6 +2343,7 @@ toggleview(const Arg *arg)
|
||||
/* apply settings for this view */
|
||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
selmon->smfact = selmon->pertag->smfacts[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];
|
||||
@ -2700,6 +2741,7 @@ view(const Arg *arg)
|
||||
|
||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
selmon->smfact = selmon->pertag->smfacts[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];
|
||||
@ -2841,28 +2883,6 @@ swallowingclient(Window w)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
warp(const Client *c)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (!c) {
|
||||
XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww / 2, selmon->wy + selmon->wh / 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getrootptr(&x, &y) ||
|
||||
(x > c->x - c->bw &&
|
||||
y > c->y - c->bw &&
|
||||
x < c->x + c->w + c->bw*2 &&
|
||||
y < c->y + c->h + c->bw*2) ||
|
||||
(y > c->mon->by && y < c->mon->by + bh) ||
|
||||
(c->mon->topbar && !y))
|
||||
return;
|
||||
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
|
||||
}
|
||||
|
||||
Client *
|
||||
wintoclient(Window w)
|
||||
{
|
||||
|
@ -1,79 +0,0 @@
|
||||
From a229c36f51ad6f8b40109ed53c643f242351962a Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Dujava <jonas.dujava@gmail.com>
|
||||
Date: Fri, 26 May 2023 22:14:48 +0200
|
||||
Subject: [PATCH] Warp patch
|
||||
|
||||
Warps the mouse cursor to the center of the currently focused
|
||||
window or screen when the mouse cursor is
|
||||
(a) on a different screen, or
|
||||
(b) on top of a different window.
|
||||
|
||||
This version properly handles warping to windows that have not been
|
||||
mapped yet (before it resulted in a change of the stack order).
|
||||
See the discussion in (thanks goes to Bakkeby):
|
||||
https://github.com/bakkeby/patches/issues/60
|
||||
---
|
||||
dwm.c | 26 ++++++++++++++++++++++++++
|
||||
1 file changed, 26 insertions(+)
|
||||
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index e5efb6a..7ea6c14 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -228,6 +228,7 @@ static void updatetitle(Client *c);
|
||||
static void updatewindowtype(Client *c);
|
||||
static void updatewmhints(Client *c);
|
||||
static void view(const Arg *arg);
|
||||
+static void warp(const Client *c);
|
||||
static Client *wintoclient(Window w);
|
||||
static Monitor *wintomon(Window w);
|
||||
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||
@@ -834,6 +835,7 @@ focusmon(const Arg *arg)
|
||||
unfocus(selmon->sel, 0);
|
||||
selmon = m;
|
||||
focus(NULL);
|
||||
+ warp(selmon->sel);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1366,6 +1368,8 @@ restack(Monitor *m)
|
||||
wc.sibling = c->win;
|
||||
}
|
||||
}
|
||||
+ if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && m->lt[m->sellt]->arrange != &monocle)
|
||||
+ warp(m->sel);
|
||||
XSync(dpy, False);
|
||||
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
@@ -2044,6 +2048,28 @@ view(const Arg *arg)
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
+void
|
||||
+warp(const Client *c)
|
||||
+{
|
||||
+ int x, y;
|
||||
+
|
||||
+ if (!c) {
|
||||
+ XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww / 2, selmon->wy + selmon->wh / 2);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (!getrootptr(&x, &y) ||
|
||||
+ (x > c->x - c->bw &&
|
||||
+ y > c->y - c->bw &&
|
||||
+ x < c->x + c->w + c->bw*2 &&
|
||||
+ y < c->y + c->h + c->bw*2) ||
|
||||
+ (y > c->mon->by && y < c->mon->by + bh) ||
|
||||
+ (c->mon->topbar && !y))
|
||||
+ return;
|
||||
+
|
||||
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
|
||||
+}
|
||||
+
|
||||
Client *
|
||||
wintoclient(Window w)
|
||||
{
|
||||
--
|
||||
2.40.1
|
||||
|
117
patches/functions/dwm-6.0-smfact.diff
Normal file
117
patches/functions/dwm-6.0-smfact.diff
Normal file
@ -0,0 +1,117 @@
|
||||
--- config.def.h 2013-04-06 21:01:27.750829760 +0200
|
||||
+++ config.def.h 2013-04-06 21:02:19.557495556 +0200
|
||||
@@ -10,6 +10,7 @@ static const char selbgcolor[] = "#
|
||||
static const char selfgcolor[] = "#eeeeee";
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
+static const unsigned int minwsz = 20; /* Minimal heigt of a client for smfact */
|
||||
static const Bool showbar = True; /* False means no bar */
|
||||
static const Bool topbar = True; /* False means bottom bar */
|
||||
|
||||
@@ -24,6 +25,7 @@ static const Rule rules[] = {
|
||||
|
||||
/* layout(s) */
|
||||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||
+static const float smfact = 0.00; /* factor of tiled clients [0.00..0.95] */
|
||||
static const int nmaster = 1; /* number of clients in master area */
|
||||
static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
|
||||
|
||||
@@ -60,6 +62,8 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
+ { MODKEY|ShiftMask, XK_h, setsmfact, {.f = +0.05} },
|
||||
+ { MODKEY|ShiftMask, XK_l, setsmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_Return, zoom, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||
--- dwm.c 2011-12-19 16:02:46.000000000 +0100
|
||||
+++ dwm.c 2013-04-06 21:00:46.620830452 +0200
|
||||
@@ -69,6 +69,7 @@ typedef union {
|
||||
int i;
|
||||
unsigned int ui;
|
||||
float f;
|
||||
+ float sf;
|
||||
const void *v;
|
||||
} Arg;
|
||||
|
||||
@@ -127,6 +128,7 @@ typedef struct {
|
||||
struct Monitor {
|
||||
char ltsymbol[16];
|
||||
float mfact;
|
||||
+ float smfact;
|
||||
int nmaster;
|
||||
int num;
|
||||
int by; /* bar geometry */
|
||||
@@ -220,6 +222,7 @@ static void setfocus(Client *c);
|
||||
static void setfullscreen(Client *c, Bool fullscreen);
|
||||
static void setlayout(const Arg *arg);
|
||||
static void setmfact(const Arg *arg);
|
||||
+static void setsmfact(const Arg *arg);
|
||||
static void setup(void);
|
||||
static void showhide(Client *c);
|
||||
static void sigchld(int unused);
|
||||
@@ -651,6 +654,7 @@ createmon(void) {
|
||||
die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
|
||||
m->tagset[0] = m->tagset[1] = 1;
|
||||
m->mfact = mfact;
|
||||
+ m->smfact = smfact;
|
||||
m->nmaster = nmaster;
|
||||
m->showbar = showbar;
|
||||
m->topbar = topbar;
|
||||
@@ -1581,6 +1585,19 @@ setmfact(const Arg *arg) {
|
||||
}
|
||||
|
||||
void
|
||||
+setsmfact(const Arg *arg) {
|
||||
+ float sf;
|
||||
+
|
||||
+ if(!arg || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+ sf = arg->sf < 1.0 ? arg->sf + selmon->smfact : arg->sf - 1.0;
|
||||
+ if(sf < 0 || sf > 0.9)
|
||||
+ return;
|
||||
+ selmon->smfact = sf;
|
||||
+ arrange(selmon);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
setup(void) {
|
||||
XSetWindowAttributes wa;
|
||||
|
||||
@@ -1703,7 +1720,7 @@ textnw(const char *text, unsigned int le
|
||||
|
||||
void
|
||||
tile(Monitor *m) {
|
||||
- unsigned int i, n, h, mw, my, ty;
|
||||
+ unsigned int i, n, h, smh, mw, my, ty;
|
||||
Client *c;
|
||||
|
||||
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||
@@ -1721,9 +1738,23 @@ tile(Monitor *m) {
|
||||
my += HEIGHT(c);
|
||||
}
|
||||
else {
|
||||
- h = (m->wh - ty) / (n - i);
|
||||
- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False);
|
||||
- ty += HEIGHT(c);
|
||||
+ smh = m->mh * m->smfact;
|
||||
+ if(!(nexttiled(c->next)))
|
||||
+ h = (m->wh - ty) / (n - i);
|
||||
+ else
|
||||
+ h = (m->wh - smh - ty) / (n - i);
|
||||
+ if(h < minwsz) {
|
||||
+ c->isfloating = True;
|
||||
+ XRaiseWindow(dpy, c->win);
|
||||
+ resize(c, m->mx + (m->mw / 2 - WIDTH(c) / 2), m->my + (m->mh / 2 - HEIGHT(c) / 2), m->ww - mw - (2*c->bw), h - (2*c->bw), False);
|
||||
+ ty -= HEIGHT(c);
|
||||
+ }
|
||||
+ else
|
||||
+ resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False);
|
||||
+ if(!(nexttiled(c->next)))
|
||||
+ ty += HEIGHT(c) + smh;
|
||||
+ else
|
||||
+ ty += HEIGHT(c);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user