From 573818ebc33b316b65533c8be4df37452058dbc3 Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Thu, 28 Jun 2012 19:47:11 +0300 Subject: rework change_desktop function - no need for prevdeskidx prevdeskidx is only needed when last_desktop function is introduced. no need to keep yet another global variable that remains unused. --- monsterwm.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/monsterwm.c b/monsterwm.c index 5ee39f8..855ec99 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -150,7 +150,7 @@ static int xerrorstart(); #include "config.h" static Bool running = True; -static int prevdeskidx = 0, currdeskidx = 0; +static int currdeskidx = 0; static int screen, wh, ww, mode = DEFAULT_MODE; static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int numlockmask = 0, win_unfocus, win_focus; @@ -213,11 +213,8 @@ void buttonpress(XEvent *e) { * first all others then the current */ void change_desktop(const Arg *arg) { if (arg->i == currdeskidx) return; - prevdeskidx = currdeskidx; - selectdesktop(arg->i); - if (curr) XMapWindow(dis, curr->win); - for (Client *c=head; c; c=c->next) XMapWindow(dis, c->win); - selectdesktop(prevdeskidx); + if (desktops[arg->i].curr) XMapWindow(dis, desktops[arg->i].curr->win); + for (Client *c=desktops[arg->i].head; c; c=c->next) XMapWindow(dis, c->win); for (Client *c=head; c; c=c->next) if (c != curr) XUnmapWindow(dis, c->win); if (curr) XUnmapWindow(dis, curr->win); selectdesktop(arg->i); -- cgit v1.3.1