apply patch dwm-winview-gaplessgrid-gridall-6.5.diff
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include "gaplessgrid.c"
|
||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
@@ -51,6 +52,7 @@ static const Layout layouts[] = {
|
|||||||
{ "[]=", tile }, /* first entry is default */
|
{ "[]=", tile }, /* first entry is default */
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
{ "[M]", monocle },
|
{ "[M]", monocle },
|
||||||
|
{ "HHH", gaplessgrid },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
@@ -130,7 +132,10 @@ static const Key keys[] = {
|
|||||||
{ MODKEY|ShiftMask, XK_a, focusbynum, {.i = 7} },
|
{ MODKEY|ShiftMask, XK_a, focusbynum, {.i = 7} },
|
||||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||||
{ MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
|
{ MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
|
||||||
{ MODKEY|ShiftMask, XK_e, exitdwm, {0} },
|
{ MODKEY|ShiftMask, XK_e, exitdwm, {0} },
|
||||||
|
{ MODKEY, XK_o, winview, {0} },
|
||||||
|
{ MODKEY, XK_g, gridall, {} },
|
||||||
|
{ MODKEY, XK_r, winviewmono, {} },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* button definitions */
|
/* button definitions */
|
||||||
|
|||||||
3
dwm.1
3
dwm.1
@@ -110,6 +110,9 @@ Increase master area size.
|
|||||||
.B Mod1\-h
|
.B Mod1\-h
|
||||||
Decrease master area size.
|
Decrease master area size.
|
||||||
.TP
|
.TP
|
||||||
|
.B Mod1\-o
|
||||||
|
Select view of the window in focus. The list of tags to be displayed is matched to the window tag list.
|
||||||
|
.TP
|
||||||
.B Mod1\-Return
|
.B Mod1\-Return
|
||||||
Zooms/cycles focused window to/from master area (tiled layouts only).
|
Zooms/cycles focused window to/from master area (tiled layouts only).
|
||||||
.TP
|
.TP
|
||||||
|
|||||||
38
dwm.c
38
dwm.c
@@ -250,10 +250,13 @@ static void view(const Arg *arg);
|
|||||||
static void warp(const Client *c);
|
static void warp(const Client *c);
|
||||||
static Client *wintoclient(Window w);
|
static Client *wintoclient(Window w);
|
||||||
static Monitor *wintomon(Window w);
|
static Monitor *wintomon(Window w);
|
||||||
|
static void winview(const Arg* arg);
|
||||||
static int xerror(Display *dpy, XErrorEvent *ee);
|
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
static void zoom(const Arg *arg);
|
static void zoom(const Arg *arg);
|
||||||
|
static void gridall(const Arg *arg);
|
||||||
|
static void winviewmono(const Arg *arg);
|
||||||
|
|
||||||
/* variables */
|
/* variables */
|
||||||
static const char broken[] = "broken";
|
static const char broken[] = "broken";
|
||||||
@@ -2496,6 +2499,41 @@ wintomon(Window w)
|
|||||||
return selmon;
|
return selmon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* by desgua */
|
||||||
|
void
|
||||||
|
gridall(const Arg *arg)
|
||||||
|
{
|
||||||
|
setlayout(&(Arg){.v = &layouts[3]});
|
||||||
|
view(&(Arg){.ui = ~0});
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
winviewmono(const Arg *arg)
|
||||||
|
{
|
||||||
|
winview(&(Arg){0});
|
||||||
|
setlayout(&(Arg){.v = &layouts[2]});
|
||||||
|
}
|
||||||
|
|
||||||
/* There's no way to check accesses to destroyed windows, thus those cases are
|
/* There's no way to check accesses to destroyed windows, thus those cases are
|
||||||
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
||||||
* default error handler, which may call exit. */
|
* default error handler, which may call exit. */
|
||||||
|
|||||||
35
gaplessgrid.c
Normal file
35
gaplessgrid.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
void
|
||||||
|
gaplessgrid(Monitor *m) {
|
||||||
|
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
|
||||||
|
if(n == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* grid dimensions */
|
||||||
|
for(cols = 0; cols <= n/2; cols++)
|
||||||
|
if(cols*cols >= n)
|
||||||
|
break;
|
||||||
|
if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
|
||||||
|
cols = 2;
|
||||||
|
rows = n/cols;
|
||||||
|
|
||||||
|
/* window geometries */
|
||||||
|
cw = cols ? m->ww / cols : m->ww;
|
||||||
|
cn = 0; /* current column number */
|
||||||
|
rn = 0; /* current row number */
|
||||||
|
for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
|
||||||
|
if(i/rows + 1 > cols - n%cols)
|
||||||
|
rows = n/cols + 1;
|
||||||
|
ch = rows ? m->wh / rows : m->wh;
|
||||||
|
cx = m->wx + cn*cw;
|
||||||
|
cy = m->wy + rn*ch;
|
||||||
|
resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
|
||||||
|
rn++;
|
||||||
|
if(rn >= rows) {
|
||||||
|
rn = 0;
|
||||||
|
cn++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user