Skip to content

Commit

Permalink
added reset_view function
Browse files Browse the repository at this point in the history
  • Loading branch information
garybgenett committed Mar 24, 2014
1 parent 2521a74 commit b9f79c3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ 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 nviews = 1; /* number of tags highlighted by default */
static const Bool resizehints = True; /* True means respect size hints in tiled resizals */

static const int master[1]; /* nmaster override per monitor */
//static const int master[] = {1,-1}; /* monitor 0 = nmaster 1, monitor 1 = no nmaster (all vertical) */
static const int views[1]; /* nviews override per monitor */
//static const int views[] = {4,~0}; /* monitor 0 = nviews 4, monitor 1 = all (all highlighted) */

static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
Expand Down Expand Up @@ -91,6 +97,7 @@ static Key keys[] = {
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY, XK_grave, reset_view, {0} },
{ MODKEY|ShiftMask, XK_q, quit, {0} },
};

Expand All @@ -101,6 +108,7 @@ static Button buttons[] = {
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkMonNum, 0, Button1, focusmon, {.i = +1} },
{ ClkMonNum, 0, Button2, reset_view, {0} },
{ ClkMonNum, 0, Button3, focusmon, {.i = -1} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
Expand Down
21 changes: 21 additions & 0 deletions dwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ 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);
static void reset_view(const Arg *arg);

/* variables */
static const char broken[] = "broken";
Expand Down Expand Up @@ -2076,6 +2077,24 @@ zoom(const Arg *arg) {
pop(c);
}

void
reset_view(const Arg *arg) {
const Arg n = {.i = +1};
const Arg m = {.f = 1 + mfact};
const int mon = selmon->num;
Arg i = {.i = 0};
Arg v = {.ui = 0};
do {
focusmon(&n);
i.i = (master[selmon->num] ? master[selmon->num] : nmaster) - selmon->nmaster;
incnmaster(&i);
setmfact(&m);
v.ui = (views[selmon->num] == ~0 ? ~0 : ((1 << (views[selmon->num] ? views[selmon->num] : nviews)) -1));
view(&v);
}
while (selmon->num != mon);
}

int
main(int argc, char *argv[]) {
if(argc == 2 && !strcmp("-v", argv[1]))
Expand All @@ -2089,6 +2108,8 @@ main(int argc, char *argv[]) {
checkotherwm();
setup();
scan();
const Arg r = {0};
reset_view(&r);
run();
cleanup();
XCloseDisplay(dpy);
Expand Down

0 comments on commit b9f79c3

Please sign in to comment.