From 541b3508144be8d19956c2bd2ae3170e4e31f10f Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Thu, 14 Jun 2012 22:22:30 +0300 Subject: reduce some computations while cycling desktops --- monsterwm.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'monsterwm.c') diff --git a/monsterwm.c b/monsterwm.c index 734a111..fae5639 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -323,13 +323,13 @@ void deletewindow(Window w) { * once the info is collected, immediately flush the stream */ void desktopinfo(void) { Bool urgent = False; - int cd = current_desktop, n=0, d=0; - for (client *c; dnext, ++n) if (c->isurgent) urgent = True; - fprintf(stdout, "%d:%d:%d:%d:%d%c", d, n, mode, current_desktop == cd, urgent, d+1==DESKTOPS?'\n':' '); + int cd = current_desktop, n=0, nd=-1; + for (client *c; ndnext, ++n) if (c->isurgent) urgent = True; + fprintf(stdout, "%d:%d:%d:%d:%d%c", nd, n, mode, current_desktop == cd, urgent, nd==DESKTOPS-1?'\n':' '); } fflush(stdout); - if (cd != d-1) select_desktop(cd); + if (cd != nd) select_desktop(cd); } /* a destroy notification is received when a window is being closed @@ -648,14 +648,14 @@ void quit(void) { * else if c was the current one, current must be updated. */ void removeclient(client *c) { client **p = NULL; - int nd = 0, cd = current_desktop; - for (Bool found = False; ndnext); + int nd = -1, cd = current_desktop; + for (Bool found = False; ndnext); *p = c->next; if (c == prevfocus) prevfocus = prev_client(current); if (c == current || (head && !head->next)) update_current(prevfocus); free(c); c = NULL; - if (cd == nd -1) tile(); else select_desktop(cd); + if (cd == nd) tile(); else select_desktop(cd); } /* main event loop - on receival of an event call the appropriate event handler */ @@ -869,10 +869,10 @@ void update_current(client *c) { /* find to which client the given window belongs to */ client* wintoclient(Window w) { client *c = NULL; - int d = 0, cd = current_desktop; - for (Bool found = False; dwin)); c=c->next); - if (cd != d-1) select_desktop(cd); + int nd = -1, cd = current_desktop; + for (Bool found = False; ndwin)); c=c->next); + if (cd != nd) select_desktop(cd); return c; } -- cgit v1.3.1