add patch/function 'goback'
This commit is contained in:
@@ -85,6 +85,7 @@ static const Key keys[] = {
|
|||||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
{ MODKEY, XK_Return, zoom, {0} },
|
{ MODKEY, XK_Return, zoom, {0} },
|
||||||
{ MODKEY, XK_Tab, view, {0} },
|
{ MODKEY, XK_Tab, view, {0} },
|
||||||
|
{ MODKEY, XK_g, goback, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
|
|||||||
31
dwm.c
31
dwm.c
@@ -180,6 +180,7 @@ static Atom getatomprop(Client *c, Atom prop);
|
|||||||
static int getrootptr(int *x, int *y);
|
static int getrootptr(int *x, int *y);
|
||||||
static long getstate(Window w);
|
static long getstate(Window w);
|
||||||
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||||
|
static void goback(const Arg *arg);
|
||||||
static void grabbuttons(Client *c, int focused);
|
static void grabbuttons(Client *c, int focused);
|
||||||
static void grabkeys(void);
|
static void grabkeys(void);
|
||||||
static void hide(const Arg *arg);
|
static void hide(const Arg *arg);
|
||||||
@@ -287,7 +288,7 @@ static Cur *cursor[CurLast];
|
|||||||
static Clr **scheme, **schemedark, **schemelight;
|
static Clr **scheme, **schemedark, **schemelight;
|
||||||
static Display *dpy;
|
static Display *dpy;
|
||||||
static Drw *drw;
|
static Drw *drw;
|
||||||
static Monitor *mons, *selmon;
|
static Monitor *mons, *selmon, *prevmon;
|
||||||
static Window root, wmcheckwin;
|
static Window root, wmcheckwin;
|
||||||
static const char **dmenucmd;
|
static const char **dmenucmd;
|
||||||
static int colormodechanged;
|
static int colormodechanged;
|
||||||
@@ -452,6 +453,7 @@ buttonpress(XEvent *e)
|
|||||||
/* focus monitor if necessary */
|
/* focus monitor if necessary */
|
||||||
if ((m = wintomon(ev->window)) && m != selmon) {
|
if ((m = wintomon(ev->window)) && m != selmon) {
|
||||||
unfocus(selmon->sel, 1);
|
unfocus(selmon->sel, 1);
|
||||||
|
prevmon = selmon;
|
||||||
selmon = m;
|
selmon = m;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
@@ -840,6 +842,7 @@ enternotify(XEvent *e)
|
|||||||
m = c ? c->mon : wintomon(ev->window);
|
m = c ? c->mon : wintomon(ev->window);
|
||||||
if (m != selmon) {
|
if (m != selmon) {
|
||||||
unfocus(selmon->sel, 1);
|
unfocus(selmon->sel, 1);
|
||||||
|
prevmon = selmon;
|
||||||
selmon = m;
|
selmon = m;
|
||||||
} else if (!c || c == selmon->sel)
|
} else if (!c || c == selmon->sel)
|
||||||
return;
|
return;
|
||||||
@@ -872,8 +875,10 @@ focus(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c) {
|
if (c) {
|
||||||
if (c->mon != selmon)
|
if (c->mon != selmon) {
|
||||||
|
prevmon = selmon;
|
||||||
selmon = c->mon;
|
selmon = c->mon;
|
||||||
|
}
|
||||||
if (c->isurgent)
|
if (c->isurgent)
|
||||||
seturgent(c, 0);
|
seturgent(c, 0);
|
||||||
detachstack(c);
|
detachstack(c);
|
||||||
@@ -909,6 +914,7 @@ focusmon(const Arg *arg)
|
|||||||
if ((m = dirtomon(arg->i)) == selmon)
|
if ((m = dirtomon(arg->i)) == selmon)
|
||||||
return;
|
return;
|
||||||
unfocus(selmon->sel, 0);
|
unfocus(selmon->sel, 0);
|
||||||
|
prevmon = selmon;
|
||||||
selmon = m;
|
selmon = m;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
warp(selmon->sel);
|
warp(selmon->sel);
|
||||||
@@ -1031,6 +1037,21 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
goback(const Arg *arg)
|
||||||
|
{
|
||||||
|
if (prevmon == NULL) {
|
||||||
|
Arg a = {0};
|
||||||
|
view(&a);
|
||||||
|
} else if (prevmon != selmon) {
|
||||||
|
unfocus(selmon->sel, 0);
|
||||||
|
Monitor *p = selmon;
|
||||||
|
selmon = prevmon;
|
||||||
|
focus(NULL);
|
||||||
|
prevmon = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grabbuttons(Client *c, int focused)
|
grabbuttons(Client *c, int focused)
|
||||||
{
|
{
|
||||||
@@ -1291,6 +1312,8 @@ motionnotify(XEvent *e)
|
|||||||
return;
|
return;
|
||||||
if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
|
if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
|
||||||
unfocus(selmon->sel, 1);
|
unfocus(selmon->sel, 1);
|
||||||
|
if (m != selmon)
|
||||||
|
prevmon = selmon;
|
||||||
selmon = m;
|
selmon = m;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
@@ -1352,6 +1375,7 @@ movemouse(const Arg *arg)
|
|||||||
XUngrabPointer(dpy, CurrentTime);
|
XUngrabPointer(dpy, CurrentTime);
|
||||||
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
|
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
|
||||||
sendmon(c, m);
|
sendmon(c, m);
|
||||||
|
prevmon = selmon;
|
||||||
selmon = m;
|
selmon = m;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
@@ -1543,6 +1567,7 @@ resizemouse(const Arg *arg)
|
|||||||
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
|
if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
|
||||||
sendmon(c, m);
|
sendmon(c, m);
|
||||||
|
prevmon = selmon;
|
||||||
selmon = m;
|
selmon = m;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
@@ -2081,6 +2106,7 @@ toggleview(const Arg *arg)
|
|||||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
||||||
|
|
||||||
if (newtagset) {
|
if (newtagset) {
|
||||||
|
prevmon = NULL;
|
||||||
selmon->tagset[selmon->seltags] = newtagset;
|
selmon->tagset[selmon->seltags] = newtagset;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
@@ -2409,6 +2435,7 @@ view(const Arg *arg)
|
|||||||
{
|
{
|
||||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||||
return;
|
return;
|
||||||
|
prevmon = NULL;
|
||||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||||
if (arg->ui & TAGMASK)
|
if (arg->ui & TAGMASK)
|
||||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||||
|
|||||||
Reference in New Issue
Block a user