浏览代码

Move nrowgrid function

master
父节点
当前提交
efb13be2db
共有 5 个文件被更改,包括 66 次插入36 次删除
  1. +1
    -2
      TODO
  2. +8
    -7
      config.h
  3. +54
    -0
      dwm.c
  4. +0
    -27
      layouts.c
  5. +3
    -0
      movestack.c

+ 1
- 2
TODO 查看文件

@@ -8,8 +8,6 @@ fullgaps (might be shortcuts)
awesomebar: hidewindow() function crashes dwm and tag background color is weird awesomebar: hidewindow() function crashes dwm and tag background color is weird
maybe manage hidden windows with dmenu maybe manage hidden windows with dmenu
use dmenu for selecting and focusing window use dmenu for selecting and focusing window
undo fullgaps and add useless gaps instead for more generality
add patch for moving slave windows
correct tag colors correct tag colors


hide border of nonfocused windows or make transparent hide border of nonfocused windows or make transparent
@@ -28,3 +26,4 @@ specified from known directories and used in dmenu), and pointing to specific
file to update it's position (ctrlp hook script should be possible) file to update it's position (ctrlp hook script should be possible)
add shortcut for focusing master add shortcut for focusing master
add scratchpad that opens in a special session add scratchpad that opens in a special session
maybe make width and height of outer gaps equal

+ 8
- 7
config.h 查看文件

@@ -5,13 +5,13 @@ static const char *fonts[] = {
"SauceCodePro NF:size=10" "SauceCodePro NF:size=10"
}; };
static const char dmenufont[] = "SauceCodePro NF:size=10"; static const char dmenufont[] = "SauceCodePro NF:size=10";
static const char normbordercolor[] = "#444444";
static const char normbordercolor[] = "#000000";
static const char normbgcolor[] = "#222222"; static const char normbgcolor[] = "#222222";
static const char normfgcolor[] = "#bbbbbb"; static const char normfgcolor[] = "#bbbbbb";
static const char selbordercolor[] = "#333544";
static const char selbordercolor[] = "#ffffff";
static const char selbgcolor[] = "#005577"; static const char selbgcolor[] = "#005577";
static const char selfgcolor[] = "#eeeeee"; static const char selfgcolor[] = "#eeeeee";
static const unsigned int borderpx = 5; /* border pixel of windows */
static const unsigned int borderpx = 2; /* border pixel of windows */
static const Gap default_gap = {.ogap = 10, .isgap = 1, .realgap = 10, .gappx = 10}; static const Gap default_gap = {.ogap = 10, .isgap = 1, .realgap = 10, .gappx = 10};
static const unsigned int snap = 32; /* snap pixel */ static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 0; /* 0 means no bar */ static const int showbar = 0; /* 0 means no bar */
@@ -36,7 +36,7 @@ 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 = 1; /* 1 means respect size hints in tiled resizals */
static int attachbelow = 1; /* 1 means attach after the currently active window */ static int attachbelow = 1; /* 1 means attach after the currently active window */


#include "layouts.c"
#define FORCE_VSPLIT 1
static const Layout layouts[] = { static const Layout layouts[] = {
/* symbol arrange function */ /* symbol arrange function */
{ "|M|", centeredmaster }, { "|M|", centeredmaster },
@@ -44,7 +44,7 @@ static const Layout layouts[] = {
{ "[M]", monocle }, { "[M]", monocle },
{ "[]=", tile }, /* first entry is default */ { "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */ { "><>", NULL }, /* no layout function means floating behavior */
{ "HHH", grid },
{ "###", nrowgrid },
}; };


/* key definitions */ /* key definitions */
@@ -62,8 +62,9 @@ static const Layout layouts[] = {
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL }; static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *termcmd[] = { "st", NULL }; static const char *termcmd[] = { "st", NULL };
static const char scratchpadname[] = "scratchpad";
static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL };
static const char scratchpadname[] = "Scratchpad";
static const char *scratchpadcmd[] = { "st", "-t", scratchpadname,
"-g", "120x34", "-e", "tmux", "new-session", "-As", "scratchpad", NULL};


#include "movestack.c" #include "movestack.c"
static Key keys[] = { static Key keys[] = {


+ 54
- 0
dwm.c 查看文件

@@ -209,6 +209,7 @@ static void maprequest(XEvent *e);
static void monocle(Monitor *m); static void monocle(Monitor *m);
static void motionnotify(XEvent *e); static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg); static void movemouse(const Arg *arg);
static void nrowgrid(Monitor *m);
static Client *nexttiled(Client *c); static Client *nexttiled(Client *c);
static void pop(Client *); static void pop(Client *);
static void propertynotify(XEvent *e); static void propertynotify(XEvent *e);
@@ -2662,3 +2663,56 @@ focusmaster(const Arg *arg)
if (c) if (c)
focus(c); focus(c);
} }

void
nrowgrid(Monitor *m)
{
unsigned int n = 0, i = 0, ri = 0, ci = 0; /* counters */
unsigned int cx, cy, cw, ch; /* client geometry */
unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */
unsigned int cols, rows = m->nmaster + 1;
Client *c;

/* count clients */
for (c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);

/* nothing to do here */
if (n == 0)
return;

/* force 2 clients to always split vertically */
if (FORCE_VSPLIT && n == 2)
rows = 1;

/* never allow empty rows */
if (n < rows)
rows = n;

/* define first row */
cols = n / rows;
uc = cols;
cy = m->wy;
ch = m->wh / rows;
uh = ch;

for (c = nexttiled(m->clients); c; c = nexttiled(c->next), i++, ci++) {
if (ci == cols) {
uw = 0;
ci = 0;
ri++;

/* next row */
cols = (n - uc) / (rows - ri);
uc += cols;
cy = m->wy + uh;
ch = (m->wh - uh) / (rows - ri);
uh += ch;
}

cx = m->wx + uw;
cw = (m->ww - uw) / (cols - ci);
uw += cw;

resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, 0);
}
}

+ 0
- 27
layouts.c 查看文件

@@ -1,27 +0,0 @@
void
grid(Monitor *m) {
unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows;
Client *c;

for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next))
n++;

/* grid dimensions */
for(rows = 0; rows <= n/2; rows++)
if(rows*rows >= n)
break;
cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;

/* window geoms (cell height/width) */
ch = m->wh / (rows ? rows : 1);
cw = m->ww / (cols ? cols : 1);
for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
cx = m->wx + (i / rows) * cw;
cy = m->wy + (i % rows) * ch;
/* adjust height/width of last row/column's windows */
ah = ((i + 1) % rows == 0) ? m->wh - ch * rows : 0;
aw = (i >= rows * (cols - 1)) ? m->ww - cw * cols : 0;
resize(c, cx, cy, cw - 2 * c->bw + aw, ch - 2 * c->bw + ah, False);
i++;
}
}

+ 3
- 0
movestack.c 查看文件

@@ -27,10 +27,13 @@ movestack(const Arg *arg) {
pc = i; pc = i;
} }


/* printf("%s", c->name); */
/* swap c and selmon->sel selmon->clients in the selmon->clients list */ /* swap c and selmon->sel selmon->clients in the selmon->clients list */
if(c && c != selmon->sel) { if(c && c != selmon->sel) {
Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next; Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
/* Client *temp = selmon->sel; */
selmon->sel->next = c->next==selmon->sel?c:c->next; selmon->sel->next = c->next==selmon->sel?c:c->next;
/* selmon->sel->next = c->next; */
c->next = temp; c->next = temp;


if(p && p != c) if(p && p != c)


正在加载...
取消
保存