[Pkg-wmaker-commits] [wmsysmon] 12/13: *: more cleanups

Doug Torrance dtorrance-guest at moszumanska.debian.org
Tue Nov 22 19:52:03 UTC 2016


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch upstream
in repository wmsysmon.

commit 325e70aa900ca428814bcdcf0e1f18c6e61a73a1
Author: Vito Caputo <vcaputo at gnugeneration.com>
Date:   Sat Aug 8 02:33:51 2015 -0700

    *: more cleanups
---
 src/wmgeneral.c | 73 +++++++++++++++++++++----------------------
 src/wmsysmon.c  | 96 ++++++++++++++++++++++++++-------------------------------
 2 files changed, 81 insertions(+), 88 deletions(-)

diff --git a/src/wmgeneral.c b/src/wmgeneral.c
index c902e72..aad4008 100644
--- a/src/wmgeneral.c
+++ b/src/wmgeneral.c
@@ -70,29 +70,29 @@ static Pixel GetColor(char *name) {
 
 
 void RedrawWindow(void) {
-	if (wmgen.dirty_w && wmgen.dirty_h)
-	XCopyArea(display,
-		  wmgen.pixmap,
-		  iconwin,
-		  NormalGC, 
-		  wmgen.dirty_x,
-		  wmgen.dirty_y,
-		  wmgen.dirty_w,
-		  wmgen.dirty_h,
-		  wmgen.dirty_x,
-		  wmgen.dirty_y);
-
-	if (wmgen.dirty_w && wmgen.dirty_h)
-	XCopyArea(display,
-		  wmgen.pixmap,
-		  win,
-		  NormalGC,
-		  wmgen.dirty_x,
-		  wmgen.dirty_y,
-		  wmgen.dirty_w,
-		  wmgen.dirty_h,
-		  wmgen.dirty_x,
-		  wmgen.dirty_y);
+	if (wmgen.dirty_w && wmgen.dirty_h) {
+		XCopyArea(display,
+			  wmgen.pixmap,
+			  iconwin,
+			  NormalGC,
+			  wmgen.dirty_x,
+			  wmgen.dirty_y,
+			  wmgen.dirty_w,
+			  wmgen.dirty_h,
+			  wmgen.dirty_x,
+			  wmgen.dirty_y);
+
+		XCopyArea(display,
+			  wmgen.pixmap,
+			  win,
+			  NormalGC,
+			  wmgen.dirty_x,
+			  wmgen.dirty_y,
+			  wmgen.dirty_w,
+			  wmgen.dirty_h,
+			  wmgen.dirty_x,
+			  wmgen.dirty_y);
+	}
 
 #ifdef MONDEBUG
 	printf("Dirty X: %i Y: %i width: %i height: %i\n",
@@ -112,14 +112,14 @@ void RedrawWindow(void) {
 
 void RedrawWindowXY(int x, int y) {
 	XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, 
-				x, y, wmgen.attributes.width, wmgen.attributes.height, 0,0);
+		  x, y, wmgen.attributes.width, wmgen.attributes.height, 0,0);
 	XCopyArea(display, wmgen.pixmap, win, NormalGC,
-				x, y, wmgen.attributes.width, wmgen.attributes.height, 0,0);
+		  x, y, wmgen.attributes.width, wmgen.attributes.height, 0,0);
 }
 
 
 void DirtyWindow(int x, int y, unsigned int w, unsigned int h) {
-	static	int	nx, ny, nw, nh;
+	int	nx, ny, nw, nh;
 
 #ifdef MONDEBUG
 	printf("currently dirty: X: %i Y: %i W: %u H: %u new: X: %i Y: %i W: %u H: %u\n",
@@ -133,22 +133,23 @@ void DirtyWindow(int x, int y, unsigned int w, unsigned int h) {
 		h);
 #endif
 
-        if (x < wmgen.dirty_x) nx = x;
-        else nx = wmgen.dirty_x;
+	if (x < wmgen.dirty_x) nx = x;
+	else nx = wmgen.dirty_x;
 
-        if (y < wmgen.dirty_y) ny = y;
-        else ny = wmgen.dirty_y;
+	if (y < wmgen.dirty_y) ny = y;
+	else ny = wmgen.dirty_y;
 
-        if ((x + w) > (wmgen.dirty_x + wmgen.dirty_w)) nw = (x + w) - nx;
-        else nw = (wmgen.dirty_x + wmgen.dirty_w) - nx;
+	if ((x + w) > (wmgen.dirty_x + wmgen.dirty_w)) nw = (x + w) - nx;
+	else nw = (wmgen.dirty_x + wmgen.dirty_w) - nx;
 
-        if ((y + h) > (wmgen.dirty_y + wmgen.dirty_h)) nh = (y + h) - ny;
-        else nh = (wmgen.dirty_y + wmgen.dirty_h) - ny;
+	if ((y + h) > (wmgen.dirty_y + wmgen.dirty_h)) nh = (y + h) - ny;
+	else nh = (wmgen.dirty_y + wmgen.dirty_h) - ny;
 
 	wmgen.dirty_x = nx;
 	wmgen.dirty_y = ny;
 	wmgen.dirty_w = nw;
 	wmgen.dirty_h = nh;
+
 #ifdef MONDEBUG
 	printf("Dirty: X: %i Y: %i W: %i H: %i\n",
 		wmgen.dirty_x,
@@ -173,7 +174,7 @@ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) {
 		zero <<=8;
 		zero |= xpm[1][k];
 	}
-        
+
 	for (i=numcol+1; i < numcol+sy+1; i++) {
 		bcount = 0;
 		bwrite = 0;
@@ -185,7 +186,7 @@ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) {
 				curpixel <<=8;
 				curpixel |= xpm[i][j+k];
 			}
-                
+
 			if (curpixel != zero) {
 				bwrite += 128;
 			}
diff --git a/src/wmsysmon.c b/src/wmsysmon.c
index a94a042..2c99151 100644
--- a/src/wmsysmon.c
+++ b/src/wmsysmon.c
@@ -153,7 +153,7 @@ int main(int argc, char *argv[]) {
 
 	last_ints = _last_ints;
 	ints = _ints;
-    
+
 	/* Parse Command Line */
 
 	ProgName = argv[0];
@@ -212,9 +212,9 @@ void wmsysmon_routine(int argc, char **argv)
 	FILE		*fp;
 	int		xfd;
 	struct pollfd	pfd;
-    
+
 	createXBMfromXPM(wmsysmon_mask_bits, wmsysmon_master_xpm, wmsysmon_mask_width, wmsysmon_mask_height);
-    
+
 	xfd = openXwindow(argc, argv, wmsysmon_master_xpm, wmsysmon_mask_bits, wmsysmon_mask_width, wmsysmon_mask_height);
 	if (xfd < 0) exit(1);
 
@@ -226,7 +226,7 @@ void wmsysmon_routine(int argc, char **argv)
 	bzero(&_ints, sizeof(_ints));
 	bzero(&int_peaks, sizeof(int_peaks));
 
-    
+
 	/* init uptime */
 	fp = fopen("/proc/uptime", "r");
 	if (fp) {
@@ -264,7 +264,7 @@ void wmsysmon_routine(int argc, char **argv)
 		DrawStuff();
 		DrawMem();
 		RedrawWindow();
-        
+
 		/* X Events */
 		poll(&pfd, 1, update_rate);
 		while (XPending(display)) {
@@ -294,7 +294,7 @@ void wmsysmon_routine(int argc, char **argv)
 
 void DrawMeter(unsigned int level, unsigned int peak, int dx, int dy)
 {
-	static unsigned int	a;
+	unsigned int	a;
 
 	/* meters are on a per interruptscale, dictated by the peak, maintain
 	 * this peak outside of here, you can use a fixed peak for all ints but
@@ -324,14 +324,11 @@ void DrawMeter(unsigned int level, unsigned int peak, int dx, int dy)
 
 void DrawBar(int sx, int sy, int w, int h, float percent, int dx, int dy)
 {
-	static int	tx;
-
-	tx = (float)((float)w * ((float)percent / (float)100.0));
+	int	tx = (float)((float)w * ((float)percent / (float)100.0));
 
 	copyXPMArea(sx, sy, tx, h, dx, dy);
 
 	copyXPMArea(sx, sy + h + 1, w - tx, h, dx + tx, dy);
-
 }
 
 
@@ -355,9 +352,9 @@ void DrawLite(int state, int dx, int dy)
 void DrawUptime(void)
 {
 	static int	first = 1;
-	static int	old_days = 0, old_hours = 0, old_minutes = 0;
-	static long	uptime;
-	static int	i;
+	static int	old_days, old_hours, old_minutes;
+	long		uptime;
+	int		i;
 
 	uptime = curtime - start_uptime + start_time;
 
@@ -374,7 +371,7 @@ void DrawUptime(void)
 		BlitString(buf, 45, 37);
 #endif
 	}
-    
+
 	/* blit hours */
 	uptime /=60;
 	i = uptime % 24;
@@ -388,7 +385,7 @@ void DrawUptime(void)
 		BlitString(buf, 29, 37);
 #endif
 	}
-    
+
 	/* blit days */
 	uptime /= 24;
 	i = uptime;
@@ -408,29 +405,28 @@ void DrawUptime(void)
 
 void DrawStuff( void )
 {
-	static int	io_last = 0, first = 1;
+	static int	io_last, first = 1;
 #ifdef HI_INTS
-	static int	int_lites[24] =
-	{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+	static int	int_lites[24];
 		/* to keep track of on/off status */
 #else
-    	static int	int_lites[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+	static int	int_lites[16];
 #endif
-	static int	pagein_lite = 0, pageout_lite = 0, swapin_lite = 0, swapout_lite = 0;
-    	static char	*tok;
+	static int	pagein_lite, pageout_lite, swapin_lite, swapout_lite;
+	char		*tok;
 	static char	seps[] = {" "};
-	static int	i, ents;
+	int		i, ents;
 
-	static long	io;
-	static long	iodiff;
-	static int	iopercent;
+	long		io;
+	long		iodiff;
+	int		iopercent;
 
-	static long	pageins;
-	static long	pageouts;
-	static long	swapins;
-	static long	swapouts;
-	static long	intdiff;
-	static long	*tints;
+	long		pageins;
+	long		pageouts;
+	long		swapins;
+	long		swapouts;
+	long		intdiff;
+	long		*tints;
 
 	io = iodiff = iopercent = pageins = pageouts = swapins = swapouts = 0;
 
@@ -507,13 +503,13 @@ void DrawStuff( void )
 
 	/* ------------------ IO bar ------------------ */
 	if (io_max == 0) io_max = io;
-    
+
 	if (io > io_max) iodiff = abs(io_max - io);
 	else iodiff = 0;
 
 	io_max = io;
 
-    
+
 	if (io_max_diff !=0) iopercent = ((float) iodiff / (float) io_max_diff) * 100.0;
 	else iopercent = 0;
 
@@ -714,18 +710,17 @@ void DrawStuff( void )
 
 void DrawMem(void)
 {
-	static int	last_mem = 0, last_swap = 0, first = 1;
-	static long 	mem_total = 0;
-	static long 	mem_used = 0;
-	static long 	mem_buffers = 0;
-	static long 	mem_cache = 0;
-	static long 	swap_total = 0;
-	static long 	swap_used = 0;
-	static long 	swap_free = 0;
-
-	static int 	mempercent = 0;
-	static int 	swappercent = 0;
-	static int	i, ents;
+	static int	last_mem, last_swap, first = 1;
+	long		mem_total;
+	long		mem_used;
+	long		mem_buffers;
+	long		mem_cache;
+	long		swap_total;
+	long		swap_used;
+	long		swap_free;
+	int		mempercent;
+	int		swappercent;
+	int		i, ents;
 
 	counter--;
 
@@ -754,13 +749,10 @@ void DrawMem(void)
 	/* could speed this up but we'd lose precision, look more into it to see
 	 * if precision change would be noticable, and if speed diff is significant
 	 */
-	mempercent = ((float)(mem_used - mem_buffers - mem_cache)
-		     /
-		     (float)mem_total) * 100;
+	mempercent = ((float)(mem_used - mem_buffers - mem_cache) /
+		      (float)mem_total) * 100;
 
-	swappercent = ((float)(swap_used)
-		      /
-		      (float)swap_total) * 100;
+	swappercent = ((float)(swap_used) / (float)swap_total) * 100;
 
 	if (mempercent != last_mem || first) {
 		last_mem = mempercent;
@@ -810,7 +802,7 @@ void BlitNum(int num, int x, int y)
 	sprintf(buf, "%03i", num);
 	BlitString(buf, x, y);
 }
-    
+
 
 void usage(void)
 {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmsysmon.git



More information about the Pkg-wmaker-commits mailing list