aboutsummaryrefslogtreecommitdiff
path: root/monsterwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'monsterwm.c')
-rw-r--r--monsterwm.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/monsterwm.c b/monsterwm.c
index 008e421..71e2d04 100644
--- a/monsterwm.c
+++ b/monsterwm.c
@@ -81,6 +81,7 @@ typedef struct {
static void change_desktop(const Arg *arg);
static void client_to_desktop(const Arg *arg);
static void killclient();
+static void last_desktop();
static void move_down();
static void move_up();
static void moveresize(const Arg *arg);
@@ -177,7 +178,7 @@ static int xerrorstart(Display *dis, XErrorEvent *ee);
* currdeskidx - which desktop is currently active
*/
static Bool running = True;
-static int wh, ww, currdeskidx;
+static int wh, ww, currdeskidx, prevdeskidx;
static unsigned int numlockmask, win_unfocus, win_focus;
static Display *dis;
static Window root;
@@ -262,7 +263,7 @@ void buttonpress(XEvent *e) {
*/
void change_desktop(const Arg *arg) {
if (arg->i == currdeskidx || arg->i < 0 || arg->i >= DESKTOPS) return;
- Desktop *d = &desktops[currdeskidx], *n = &desktops[(currdeskidx = arg->i)];
+ Desktop *d = &desktops[(prevdeskidx = currdeskidx)], *n = &desktops[(currdeskidx = arg->i)];
if (n->curr) XMapWindow(dis, n->curr->win);
for (Client *c = n->head; c; c = c->next) XMapWindow(dis, c->win);
XChangeWindowAttributes(dis, root, CWEventMask, &(XSetWindowAttributes){.do_not_propagate_mask = SubstructureNotifyMask});
@@ -657,6 +658,13 @@ void killclient(void) {
}
/**
+ * focus the previously/last focused desktop
+ */
+void last_desktop(void) {
+ change_desktop(&(Arg){.i = prevdeskidx});
+}
+
+/**
* a map request is received when a window wants to display itself.
* if the window has override_redirect flag set,
* then it should not be handled by the wm.