[Pkg-wmaker-commits] [wmsysmon] 02/37: Imported Upstream version 0.7.6
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Tue Aug 25 03:09:45 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmsysmon.
commit 2dbcbf4d688ef407319cae50f174bc46739cff6d
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date: Sun Jul 12 10:01:20 2015 -0600
Imported Upstream version 0.7.6
---
BUGS | 13 -
CHANGES | 10 -
ChangeLog | 80 ++
FAQ | 7 +
README | 107 +--
meminfotest/Makefile | 10 +
meminfotest/README | 21 +
meminfotest/test.c | 18 +
profiles/profile-0.6.0 | 15 +
profiles/profile-0.7.5 | 22 +
profiles/profile-0.7.6 | 22 +
src/Makefile | 21 +
src/Makefile-profile | 29 +
src/wmgeneral.c | 436 ++++++++++
{wmgeneral => src}/wmgeneral.h | 11 +-
.../wmsysmon-master-alpha.xpm | 227 ++---
.../wmsysmon-master-i386.xpm | 27 +-
src/wmsysmon.c | 949 +++++++++++++++++++++
wmgeneral/list.c | 169 ----
wmgeneral/list.h | 59 --
wmgeneral/misc.c | 164 ----
wmgeneral/misc.h | 9 -
wmgeneral/wmgeneral.c | 481 -----------
wmsysmon/Makefile | 28 -
wmsysmon/wmsysmon.c | 742 ----------------
25 files changed, 1806 insertions(+), 1871 deletions(-)
diff --git a/BUGS b/BUGS
deleted file mode 100644
index aeac773..0000000
--- a/BUGS
+++ /dev/null
@@ -1,13 +0,0 @@
-Known 'features and easter eggs'
-
-wmsysmon 0.2
--------------------------------------------------------------
- Well, it sucks CPU. I've known this from the start
- but i've had a few complaints. Use -r to reduce the
- update rate and it should make it more livable. There
- are some optimizations that can be made... Maybe next
- release... :)
-
-wmsysmon 0.1
--------------------------------------------------------------
- * First initial BETA release.
diff --git a/CHANGES b/CHANGES
deleted file mode 100644
index 8e05e0a..0000000
--- a/CHANGES
+++ /dev/null
@@ -1,10 +0,0 @@
-Version Description
---------------------------------------------------------------
-
-0.2
- * Added -r option to allow easy control of update rate.
- * Updated sparse docs to be a little less sparse :)
- * Implemented the swap in/out lights.
-0.1
- * First initial public release.
-
\ No newline at end of file
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..6a707a6
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,80 @@
+-- end --
+
+- Jul 11 2000 - Vito Caputo (swivel at gnugeneration.com) -
+ * eliminated the memcpy() used for copying interrupt statistics into
+ backups for comparison in next iteration, now simply swaps pointers.
+ * made new profile, organized existing profiles.
+
+- Jun 29 2000 - Vito Caputo (swivel at gnugeneration.com) -
+ * added profiling instrumentation to code for TAU
+ * optimized DrawMem() routine, which profiling revealed as being 96%
+ of the total CPU time used in 0.6.0.
+ * optimized DrawStuff() routine
+ * added simple drawing management code, not quite drawing list but
+ more efficient in most cases than blitting whole tile. Anything
+ more complex will probably outweigh the benefits since we're
+ dealing with such a small area.
+ * removed some unused routines that were left behind from Dave Clarks
+ release, and some junk in wmgeneral.c, next release may have no
+ wmgeneral.c, even though it would be pointless to remove it since
+ the same code would be sitting in wmsysmon.c, its probably more
+ tidy as-is.
+ * after extensive profiling, it has been discovered that polling
+ /proc/meminfo is expensive no matter how you go about parsing it,
+ linux 2.4 in theory does this faster, but I have changed the meminfo
+ polling to be a fraction of the refresh rate used, this makes things
+ alot more CPU (system) friendly.
+ * fix to drawing management code, was not adding all dirty's properly
+ * added small test program for benchmarking /proc/meminfo
+ * line #'s are calculated at startup now for /proc/meminfo and
+ /proc/stat entries we use, so no strchr()'s every iteration, and order
+ changes in /proc/meminfo and /proc/stat formatting shouldnt break it.
+ * some code cleanup
+ * fix to Makefile, some systems were not finding includes in
+ /usr/X11R6/include without -I/usr/X11R6/include
+
+- Apr 24 2000 - Vito Caputo (swivel at gnugeneration.com) -
+ * added interrupt meters, i like i like :)
+ * set intterrupt meters to default behavior, added -l to arguements
+ to set old lights behavior and to help screen.
+ * new feature, 0.6.0 now :)
+
+- Apr 2 2000 - Vito Caputo (swivel at gnugeneration.com) -
+ * fixed some problems with parsing files in /proc, much much faster
+ now. (toyed with drawing lists and some other things but broke most
+ of wmsysmon, will be rewriting the stuff in wmgeneral.c eventually)
+
+- Mar 5 2000 - Vito Caputo (swivel at gnugeneration.com) -
+ * fixed typo in HI_INTS version of help (wmsysmon -h) interrupts 0-24
+ to 0-23
+ * upped version # to 0.5.1
+ * another fix to the lights, Ignacy's fix fixed blinking but broke
+ optimization (if lights were off they were always refreshed)
+
+- Mar 5 2000 - Ignacy Gawedzki (ouaou at relou.net)
+ * little fix to the lights, which kept blinking.
+
+- Feb 12 2000 - Vito Caputo (swivel at gnugeneration.com) -
+ * created this changelog
+ * reformatted code to my liking
+ * converted c++ style comments (bleh, ick) to C style.
+ * upgraded version # to 0.5
+ * changed link to old non-maintained (dead?) wmsysmon site in usage
+ to GNU Generation site with maintained wmsysmon.
+ * added the ascii diagram to the usage dialog
+ * removed wmgeneral/ and misc.c and list.c, pointless.
+ * added proper GNU GPL notice to wmsysmon.c
+
+- Jan 25 2000 - Vito Caputo (swivel at gnugeneration.com) -
+ * After sending updates to previous maintainer decided to simply
+ takeover maintennance of wmsysmon, if anyone objects, tough, get off
+ your a*s and maintain it yourself, nothings stopping you, behold the
+ power of the GNU GPL.
+ * optimized uptime refresh to only redraw uptime when changed
+ * optimized swap & mem usage percent bars to only redraw when changed
+ * optimized IO usage percent bar to only redraw when changed
+ * optimized interrupt lites to only redraw when changed
+ * rewrote Makefile, chaged ALPHA_VERSION to HI_INTS (SMP x86 boxes use
+ this too so its not alpha only)
+
+-- begin --
diff --git a/FAQ b/FAQ
new file mode 100644
index 0000000..9c13a15
--- /dev/null
+++ b/FAQ
@@ -0,0 +1,7 @@
+Q: Why does wmsysmon use so much CPU time? (4-6% on some systems)
+A: On some machines, polling /proc/meminfo turns out to be an expensive
+ task, this is for the most part fixed in kernel 2.4, but still happens
+ on kernel 2.2. We have included a test program so you may see if there
+ is such a bottleneck on your system. For this does not happen on all
+ 2.2 machines, we have also cut down the /proc/meminfo polling in 0.7.0+
+ of wmsysmon, so this should not be a problem any longer. see: meminfotest/README
diff --git a/README b/README
index b0c4bbf..550c9e8 100644
--- a/README
+++ b/README
@@ -1,70 +1,37 @@
-wmsysmon 0.2 beta Public Release
---------------------------------------------------------------
-Author...: Dave Clark (clarkd at skynet.ca)
-
-Homepage : http://www.neotokyo.org
-
-Description
---------------------------------------------------------------
-Well, i was bored this afternoon, so i decided to code this.
-
-Its a system monitor util for your wm/afterstep dock.
-
-It monitors Memory, Swap, Disk IO, uptime and interrupts.
-
-kinda pretty looking.
-
-ok ok, everyone has been complaining about the docs (or lack thereof)
-
-here's how the applet is laid out:
-
--------------------
-|[---------------]| <--- Memory Use %
-|[---------------]| <--- Swap Use %
-|[---------------]| <--- I/O %
-| |
-| 000:00:00 | <--- Uptime days:hours:minutes
-| |
-| 01234567 WX | <--- 0-F are hardware interrupts 0-15
-| 89ABCDEF YZ | <--- W,X are Page IN/OUT
-------------------- <--- Y,Z are Swap IN/OUT
-
-
-That should explain things a little better. Phew.. I love asci drawings.
-
-Mail me with ideas/comments/bug reports, etc....
-
-Installing
---------------------------------------------------------------
-cd wmsysmon
-make
-make install
-
-should do it.
-
-Options
---------------------------------------------------------------
-Do a 'wmsysmon -h' to see the options...
-
-
-Files
---------------------------------------------------------------
-README This file.
-BUGS Things you don't want to know ;-)
-CHANGES Description of changes.
-COPYING GNU General Public License Version 2.
-
-
-Bugs
---------------------------------------------------------------
-If you discover any bugs in this software, please send a
-bugreport to clarkd at skynet.ca and describe the
-problem as detailed! as you can.
-
-
-Copyright
---------------------------------------------------------------
-wmsysmon is copyright (c) 1998/99 by Dave Clark
-
-wmsysmon is licensed through the GNU General Public License.
-Read the COPYING file for the complete GNU license.
+You have downloaded wmsysmon, a small dock application for use with
+WindowMaker (www.windowmaker.org) to show system information on interrupt
+activity, memory use, swap use, and IO. wmsysmon was originally written by
+Dave Clark, I saw room for improvement in wmsysmon and sent some updates in
+to Dave Clark, after nearly a month went by with no response I decided to
+takeover development. Dave Clark is OK with this, it appears he is
+too overworked to keep up with everything, if you are management over Dave
+Clark give him a break :). This program is licensed under the GNU GPL, see
+file COPYING.
+
+Simply enter the 'src' directory and type 'make' to build wmsysmon, if you are
+using a SMP x86 machine or an alpha machine you may want to edit the Makefile
+and uncomment -DHI_INTS before building, this enables monitoring the 24
+interrupts available on such machines. After building successfully, execute
+'make install' to install the binary into /usr/local/bin, root will be required
+to write the binary in /usr/local/bin, but it is not required to install the
+binary in /usr/local/bin to use wmsysmon, it may be run from anywhere in
+the filesystem, but on a multi-user system it is preferred to have it available
+for everyone to use, hence /usr/local/bin.
+
+For information on running wmsysmon, execute 'wmsysmon -h' afer building (and
+installing) using the above instructions.
+
+I have also added some profiling output in the directory "profiles", you can
+see in these files the improvements that have been done (scientific proof)
+to wmsysmon.
+
+The Makefile-profile makefile is used for building wmsysmon with profiling
+enabled, this requires the profiling tools to be installed and configured.
+You probably dont care about this.
+
+Cheers.
+
+- Vito Caputo
+ swivel at gnugeneration.com
+ GNU Generation
+ www.gnugeneration.com
diff --git a/meminfotest/Makefile b/meminfotest/Makefile
new file mode 100644
index 0000000..53114b7
--- /dev/null
+++ b/meminfotest/Makefile
@@ -0,0 +1,10 @@
+CC := gcc
+
+BIN := test
+OBJ := test.o
+
+$(BIN): $(OBJ)
+ $(CC) -o $(BIN) $(OBJ)
+
+clean:
+ rm -f $(OBJ) $(BIN)
diff --git a/meminfotest/README b/meminfotest/README
new file mode 100644
index 0000000..596d53c
--- /dev/null
+++ b/meminfotest/README
@@ -0,0 +1,21 @@
+This is a program used to benchmark your /proc/meminfo, you need to time it
+using the time program (TIME(1)), simply run make to build it, then execute
+it like so:
+
+time ./test
+
+If the results are over 30s of system time, your /proc/meminfo is slow.
+On my P166MMX overclocked to 187Mhz it takes 12s system time, on a dual
+ppro 180Mhz we tested it took 1:02s (yes, thats 1 minute and 2 seconds).
+Both were running kernel 2.2.
+
+We also ran the same test on a 400Mhz celeron using both 2.2 and 2.4, on 2.2
+it took 11s, on 2.4 it took 4s.
+
+I would love to hear the results of any tests you perform using this, email
+results to me.
+
+- Vito Caputo
+ swivel at gnugeneration.com
+ GNU Generation
+ www.gnugeneration.com
diff --git a/meminfotest/test.c b/meminfotest/test.c
new file mode 100644
index 0000000..6a321ab
--- /dev/null
+++ b/meminfotest/test.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <dirent.h>
+
+
+main(void)
+{
+ char buf[128];
+ FILE *fp;
+ int i = 0;
+
+ fp = fopen("/proc/meminfo", "r");
+
+ while(i < 1000) {
+ freopen("/proc/meminfo", "r", fp);
+ while(fgets(buf, 128, fp));
+ i++;
+ }
+}
diff --git a/profiles/profile-0.6.0 b/profiles/profile-0.6.0
new file mode 100644
index 0000000..6a33732
--- /dev/null
+++ b/profiles/profile-0.6.0
@@ -0,0 +1,15 @@
+Reading Profile files in /home/swivel/src/wmsysmon/src/profile.*
+
+NODE 0;CONTEXT 0;THREAD 0:
+---------------------------------------------------------------------------------------
+%Time Exclusive Inclusive #Call #Subrs Inclusive Name
+ msec total msec usec/call
+---------------------------------------------------------------------------------------
+100.0 0 10,480 1 1 10480000 main() int(int, char **)
+100.0 60 10,480 1 3000 10480000 wmsysmon_routine() (int, char **)
+ 93.9 9,840 9,840 1000 2 9840 DrawMem()
+ 5.4 200 570 1000 16011 570 DrawStuff()
+ 3.4 360 360 16000 0 22 DrawMeter() (int, unsigned int, int, int)
+ 0.1 10 10 13 0 769 DrawBar() (int, int, int, int, float, int, int)
+ 0.1 10 10 1000 4 10 DrawUptime()
+ 0.0 0 0 4 0 0 BlitString() (char *, int, int)
diff --git a/profiles/profile-0.7.5 b/profiles/profile-0.7.5
new file mode 100644
index 0000000..2befb26
--- /dev/null
+++ b/profiles/profile-0.7.5
@@ -0,0 +1,22 @@
+Reading Profile files in /home/swivel/src/wmsysmon/src/profile.*
+
+NODE 0;CONTEXT 0;THREAD 0:
+---------------------------------------------------------------------------------------
+%Time Exclusive Inclusive #Call #Subrs Inclusive Name
+ msec total msec usec/call
+---------------------------------------------------------------------------------------
+100.0 0 40 1 1 40000 main() int(int, char **)
+100.0 0 40 1 4116 40000 wmsysmon_routine() (int, char **)
+ 50.0 20 20 1000 2 20 DrawMem()
+ 50.0 20 20 1 0 20000 GetXPM (XpmIcon *, char *)
+ 0.0 0 0 3 8 0 BlitString() (char *, int, int)
+ 0.0 0 0 16140 0 0 DirtyWindow (int, int, int, int)
+ 0.0 0 0 5 10 0 DrawBar() (int, int, int, int, float, int, int)
+ 0.0 0 0 12 12 0 DrawLite() (int, int, int)
+ 0.0 0 0 16000 15999 0 DrawMeter() (int, unsigned int, int, int)
+ 0.0 0 0 1000 16015 0 DrawStuff()
+ 0.0 0 0 1000 3 0 DrawUptime()
+ 0.0 0 0 2 0 0 GetColor Pixel
+ 0.0 0 0 1000 0 0 RedrawWindow
+ 0.0 0 0 16029 16028 0 copyXPMArea (int, int, int, int, int, int)
+ 0.0 0 0 1 0 0 createXBMfromXPM (char *, char **, int, int)
diff --git a/profiles/profile-0.7.6 b/profiles/profile-0.7.6
new file mode 100644
index 0000000..e52ae4a
--- /dev/null
+++ b/profiles/profile-0.7.6
@@ -0,0 +1,22 @@
+Reading Profile files in profile.*
+
+NODE 0;CONTEXT 0;THREAD 0:
+---------------------------------------------------------------------------------------
+%Time Exclusive Inclusive #Call #Subrs Inclusive Name
+ msec total msec usec/call
+---------------------------------------------------------------------------------------
+100.0 0 70 1 1 70000 main() int(int, char **)
+100.0 30 70 1 17 70000 wmsysmon_routine() (int, char **)
+ 42.9 30 30 1 0 30000 GetXPM (XpmIcon *, char *)
+ 28.6 20 20 1000 16912 20 DrawStuff()
+ 0.0 0 0 3 8 0 BlitString() (char *, int, int)
+ 0.0 0 0 17398 0 0 DirtyWindow (int, int, unsigned int, unsigned int)
+ 0.0 0 0 365 730 0 DrawBar() (int, int, int, int, float, int, int)
+ 0.0 0 0 550 550 0 DrawLite() (int, int, int)
+ 0.0 0 0 1000 4102 0 DrawMem()
+ 0.0 0 0 16000 15999 0 DrawMeter() (int, unsigned int, int, int)
+ 0.0 0 0 1000 3 0 DrawUptime()
+ 0.0 0 0 2 0 0 GetColor Pixel
+ 0.0 0 0 1000 0 0 RedrawWindow
+ 0.0 0 0 17287 17286 0 copyXPMArea (int, int, int, int, int, int)
+ 0.0 0 0 1 0 0 createXBMfromXPM (char *, char **, int, int)
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..b629a5e
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,21 @@
+CC = gcc
+
+LIBDIR += -L/usr/X11R6/lib
+LDFLAGS += -lXpm -lXext -lX11 -lm -s
+#CFLAGS = -g #-DMONDEBUG
+CFLAGS += -O3 -m486 -fomit-frame-pointer -I/usr/X11R6/include #-DHI_INTS #undefine HI_INTS if your x86 SMP or alpha
+
+BIN = wmsysmon
+OBJS = wmgeneral.o \
+ wmsysmon.o
+
+$(BIN): $(OBJS)
+ $(CC) -o $(BIN) $(OBJS) $(LIBDIR) $(LDFLAGS)
+
+all: wmsysmon
+
+clean:
+ rm -f $(OBJS) $(BIN)
+
+install:
+ install -g root -o root $(BIN) /usr/local/bin
diff --git a/src/Makefile-profile b/src/Makefile-profile
new file mode 100644
index 0000000..5cb3c68
--- /dev/null
+++ b/src/Makefile-profile
@@ -0,0 +1,29 @@
+TAUROOTDIR := /home/swivel/tau
+
+include $(TAUROOTDIR)/include/Makefile
+
+CFLAGS := $(TAU_INCLUDE) $(TAU_DEFS)
+LIBS := $(TAU_LIBS) -lpthread
+
+CC = $(TAU_CC)
+CXX = $(TAU_CXX)
+
+LIBDIR += -L/usr/X11R6/lib
+LDFLAGS += -g -lXpm -lXext -lX11 -lm
+#CFLAGS = -p #-DMONDEBUG
+CFLAGS += -O3 -DPROF #-DHI_INTS #undefine HI_INTS if your x86 smp or alpha
+
+BIN = wmsysmon
+OBJS = wmgeneral.o \
+ wmsysmon.o
+
+$(BIN): $(OBJS)
+ $(CXX) -o $(BIN) $(OBJS) $(LIBDIR) $(LDFLAGS) $(LIBS)
+
+all: wmsysmon
+
+clean:
+ rm -f $(OBJS) $(BIN)
+
+install:
+ install -g root -o root $(BIN) /usr/local/bin
diff --git a/src/wmgeneral.c b/src/wmgeneral.c
new file mode 100644
index 0000000..dfc4184
--- /dev/null
+++ b/src/wmgeneral.c
@@ -0,0 +1,436 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <stdarg.h>
+
+#include <X11/Xlib.h>
+#include <X11/xpm.h>
+#include <X11/extensions/shape.h>
+#ifdef PROF
+#include <Profile/Profiler.h>
+#endif
+
+#include "wmgeneral.h"
+
+Window Root;
+int screen;
+int x_fd;
+int d_depth;
+XSizeHints mysizehints;
+XWMHints mywmhints;
+Pixel back_pix, fore_pix;
+char *Geometry = "";
+Window iconwin, win;
+GC NormalGC;
+XpmIcon wmgen;
+Pixmap pixmask;
+
+
+static void GetXPM(XpmIcon *, char **);
+static Pixel GetColor(char *);
+void RedrawWindow(void);
+
+
+static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) {
+
+ XWindowAttributes attributes;
+ int err;
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "GetXPM", "(XpmIcon *, char *)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ /* For the colormap */
+ XGetWindowAttributes(display, Root, &attributes);
+
+ wmgen->attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
+
+ err = XpmCreatePixmapFromData(display, Root, pixmap_bytes, &(wmgen->pixmap),
+ &(wmgen->mask), &(wmgen->attributes));
+ wmgen->dirty_x = wmgen->attributes.width;
+ wmgen->dirty_y = wmgen->attributes.height;
+ wmgen->dirty_w = 0;
+ wmgen->dirty_h = 0;
+
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+ if (err != XpmSuccess) {
+ fprintf(stderr, "Not enough free colorcells.\n");
+ exit(1);
+ }
+}
+
+
+static Pixel GetColor(char *name) {
+
+ XColor color;
+ XWindowAttributes attributes;
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "GetColor", "Pixel", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ XGetWindowAttributes(display, Root, &attributes);
+
+ color.pixel = 0;
+ if (!XParseColor(display, attributes.colormap, name, &color)) {
+ fprintf(stderr, "wm.app: can't parse %s.\n", name);
+ } else if (!XAllocColor(display, attributes.colormap, &color)) {
+ fprintf(stderr, "wm.app: can't allocate %s.\n", name);
+ }
+
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+ return color.pixel;
+}
+
+
+void RedrawWindow(void) {
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "RedrawWindow", "", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ 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);
+
+#ifdef MONDEBUG
+ printf("Dirty X: %i Y: %i width: %i height: %i\n",
+ wmgen.dirty_x,
+ wmgen.dirty_y,
+ wmgen.dirty_w,
+ wmgen.dirty_h);
+#endif
+
+ XFlush(display);
+ wmgen.dirty_x = wmgen.attributes.width;
+ wmgen.dirty_y = wmgen.attributes.height;
+ wmgen.dirty_w = 0;
+ wmgen.dirty_h = 0;
+
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+void RedrawWindowXY(int x, int y) {
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "RedrawWindowXY", "(int, int)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
+ 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);
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+void DirtyWindow(int x, int y, unsigned int w, unsigned int h) {
+ static nx, ny, nw, nh;
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "DirtyWindow", "(int, int, unsigned int, unsigned int)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+#ifdef MONDEBUG
+ printf("currently dirty: X: %i Y: %i W: %u H: %u new: X: %i Y: %i W: %u H: %u\n",
+ wmgen.dirty_x,
+ wmgen.dirty_y,
+ wmgen.dirty_w,
+ wmgen.dirty_h,
+ x,
+ y,
+ w,
+ h);
+#endif
+
+ 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((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;
+
+ wmgen.dirty_x = nx;
+ wmgen.dirty_y = ny;
+ wmgen.dirty_w = nw;
+ wmgen.dirty_h = nh;
+#ifdef MONDEBUG
+ printf("Final: X: %i Y: %i W: %u H: %u\n",
+ wmgen.dirty_x,
+ wmgen.dirty_y,
+ wmgen.dirty_w,
+ wmgen.dirty_h);
+
+ printf("Dirty: X: %i Y: %i W: %i H: %i\n",
+ wmgen.dirty_x,
+ wmgen.dirty_y,
+ wmgen.dirty_w,
+ wmgen.dirty_h);
+#endif
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+};
+
+
+void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) {
+
+ int i,j,k;
+ int width, height, numcol, depth;
+ int zero=0;
+ unsigned char bwrite;
+ int bcount;
+ int curpixel;
+
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "createXBMfromXPM", "(char *, char **, int, int)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth);
+
+
+ for (k=0; k!=depth; k++)
+ {
+ zero <<=8;
+ zero |= xpm[1][k];
+ }
+
+ for (i=numcol+1; i < numcol+sy+1; i++) {
+ bcount = 0;
+ bwrite = 0;
+ for (j=0; j<sx*depth; j+=depth) {
+ bwrite >>= 1;
+
+ curpixel=0;
+ for (k=0; k!=depth; k++)
+ {
+ curpixel <<=8;
+ curpixel |= xpm[i][j+k];
+ }
+
+ if ( curpixel != zero ) {
+ bwrite += 128;
+ }
+ bcount++;
+ if (bcount == 8) {
+ *xbm = bwrite;
+ xbm++;
+ bcount = 0;
+ bwrite = 0;
+ }
+ }
+ }
+
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+void copyXPMArea(int sx, int sy, unsigned int w, unsigned int h, int dx, int dy) {
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "copyXPMArea", "(int, int, int, int, int, int)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ XCopyArea(display,
+ wmgen.pixmap,
+ wmgen.pixmap,
+ NormalGC,
+ sx,
+ sy,
+ w,
+ h,
+ dx,
+ dy);
+
+ DirtyWindow(dx, dy, w, h);
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+void copyXBMArea(int sx, int sy, unsigned int w, unsigned int h, int dx, int dy) {
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "copyXBMArea", "(int, int, unsigned int, unsigned int, int, int)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ XCopyArea(display,
+ wmgen.mask,
+ wmgen.pixmap,
+ NormalGC,
+ sx,
+ sy,
+ w,
+ h,
+ dx,
+ dy);
+
+ DirtyWindow(dx, dy, w, h);
+
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+void setMaskXY(int x, int y) {
+
+ XShapeCombineMask(display, win, ShapeBounding, x, y, pixmask, ShapeSet);
+ XShapeCombineMask(display, iconwin, ShapeBounding, x, y, pixmask, ShapeSet);
+}
+
+
+void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, int pixmask_width, int pixmask_height) {
+
+ unsigned int borderwidth = 1;
+ XClassHint classHint;
+ char *display_name = NULL;
+ char *wname = argv[0];
+ XTextProperty name;
+
+ XGCValues gcv;
+ unsigned long gcm;
+
+ char *geometry = NULL;
+
+ int dummy=0;
+ int i, wx, wy;
+
+ for (i=1; argv[i]; i++) {
+ if (!strcmp(argv[i], "-display")) {
+ display_name = argv[i+1];
+ i++;
+ }
+ if (!strcmp(argv[i], "-geometry")) {
+ geometry = argv[i+1];
+ i++;
+ }
+ }
+
+ if (!(display = XOpenDisplay(display_name))) {
+ fprintf(stderr, "%s: can't open display %s\n",
+ wname, XDisplayName(display_name));
+ exit(1);
+ }
+ screen = DefaultScreen(display);
+ Root = RootWindow(display, screen);
+ d_depth = DefaultDepth(display, screen);
+ x_fd = XConnectionNumber(display);
+
+ /* Convert XPM to XImage */
+ GetXPM(&wmgen, pixmap_bytes);
+
+ /* Create a window to hold the stuff */
+ mysizehints.flags = USSize | USPosition;
+ mysizehints.x = 0;
+ mysizehints.y = 0;
+
+ back_pix = GetColor("white");
+ fore_pix = GetColor("black");
+
+ XWMGeometry(display, screen, Geometry, NULL, borderwidth, &mysizehints,
+ &mysizehints.x, &mysizehints.y,&mysizehints.width,&mysizehints.height, &dummy);
+
+ mysizehints.width = 64;
+ mysizehints.height = 64;
+ DirtyWindow(0, 0, 64, 64);
+
+ win = XCreateSimpleWindow(display, Root, mysizehints.x, mysizehints.y,
+ mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
+
+ iconwin = XCreateSimpleWindow(display, win, mysizehints.x, mysizehints.y,
+ mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
+
+ /* Activate hints */
+ XSetWMNormalHints(display, win, &mysizehints);
+ classHint.res_name = wname;
+ classHint.res_class = wname;
+ XSetClassHint(display, win, &classHint);
+
+ XSelectInput(display, win, ExposureMask | StructureNotifyMask);
+ XSelectInput(display, iconwin, ExposureMask | StructureNotifyMask);
+
+ if (XStringListToTextProperty(&wname, 1, &name) == 0) {
+ fprintf(stderr, "%s: can't allocate window name\n", wname);
+ exit(1);
+ }
+
+ XSetWMName(display, win, &name);
+
+ /* Create GC for drawing */
+
+ gcm = GCForeground | GCBackground | GCGraphicsExposures;
+ gcv.foreground = fore_pix;
+ gcv.background = back_pix;
+ gcv.graphics_exposures = 0;
+ NormalGC = XCreateGC(display, Root, gcm, &gcv);
+
+ /* ONLYSHAPE ON */
+
+ pixmask = XCreateBitmapFromData(display, win, pixmask_bits, pixmask_width, pixmask_height);
+
+ XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
+ XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
+
+ /* ONLYSHAPE OFF */
+
+ mywmhints.initial_state = WithdrawnState;
+ mywmhints.icon_window = iconwin;
+ mywmhints.icon_x = mysizehints.x;
+ mywmhints.icon_y = mysizehints.y;
+ mywmhints.window_group = win;
+ mywmhints.flags = StateHint | IconWindowHint | IconPositionHint | WindowGroupHint;
+
+ XSetWMHints(display, win, &mywmhints);
+
+ XSetCommand(display, win, argv, argc);
+ XMapWindow(display, win);
+
+ if (geometry) {
+ if (sscanf(geometry, "+%d+%d", &wx, &wy) != 2) {
+ fprintf(stderr, "Bad geometry string.\n");
+ exit(1);
+ }
+ XMoveWindow(display, win, wx, wy);
+ }
+}
diff --git a/wmgeneral/wmgeneral.h b/src/wmgeneral.h
similarity index 77%
rename from wmgeneral/wmgeneral.h
rename to src/wmgeneral.h
index e9d6ca6..7470f0c 100644
--- a/wmgeneral/wmgeneral.h
+++ b/src/wmgeneral.h
@@ -27,9 +27,11 @@ struct _rckeys2 {
};
typedef struct {
- Pixmap pixmap;
- Pixmap mask;
+ Pixmap pixmap;
+ Pixmap mask;
XpmAttributes attributes;
+ int dirty_x, dirty_y;
+ unsigned int dirty_w, dirty_h;
} XpmIcon;
/*******************/
@@ -50,10 +52,11 @@ void RedrawWindow(void);
void RedrawWindowXY(int x, int y);
void createXBMfromXPM(char *, char **, int, int);
-void copyXPMArea(int, int, int, int, int, int);
-void copyXBMArea(int, int, int, int, int, int);
+void copyXPMArea(int, int, unsigned int, unsigned int, int, int);
+void copyXBMArea(int, int, unsigned int, unsigned int, int, int);
void setMaskXY(int, int);
void parse_rcfile(const char *, rckeys *);
+inline void DirtyWindow(int, int, unsigned int, unsigned int);
#endif
diff --git a/wmsysmon/wmsysmon-master.xpm b/src/wmsysmon-master-alpha.xpm
similarity index 86%
copy from wmsysmon/wmsysmon-master.xpm
copy to src/wmsysmon-master-alpha.xpm
index a3be939..1f18d69 100644
--- a/wmsysmon/wmsysmon-master.xpm
+++ b/src/wmsysmon-master-alpha.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char * wmsysmon_master_xpm[] = {
-"240 100 75 1",
+"240 100 80 1",
". c #0000FF",
" c None",
"+ c #202020",
@@ -10,72 +10,77 @@ static char * wmsysmon_master_xpm[] = {
"% c #20B2AE",
"& c #107D79",
"* c #188A86",
-"= c #00FF0F",
-"- c #04FA0F",
-"; c #09F50F",
-"> c #0DF10F",
-", c #12EC0E",
-"' c #16E80E",
-") c #1BE30E",
-"! c #1FDF0D",
-"~ c #24DA0D",
-"{ c #28D60D",
-"] c #2DD10D",
-"^ c #32CC0C",
-"/ c #36C80C",
-"( c #3BC30C",
-"_ c #3FBF0B",
-": c #44BA0B",
-"< c #48B60B",
-"[ c #4DB10B",
-"} c #51AD0A",
-"| c #56A80A",
-"1 c #5BA30A",
-"2 c #5F9F09",
-"3 c #649A09",
-"4 c #689609",
-"5 c #6D9109",
-"6 c #718D08",
-"7 c #768808",
-"8 c #7A8408",
-"9 c #7F7F07",
-"0 c #847A07",
-"a c #887607",
-"b c #8D7107",
-"c c #916D06",
-"d c #966806",
-"e c #9A6406",
-"f c #9F5F05",
-"g c #A35B05",
-"h c #A85605",
-"i c #AD5105",
-"j c #B14D04",
-"k c #B64804",
-"l c #BA4404",
-"m c #BF3F03",
-"n c #C33B03",
-"o c #C83603",
-"p c #CC3203",
-"q c #D12D02",
-"r c #D62802",
-"s c #DA2402",
-"t c #DF1F01",
-"u c #E31B01",
-"v c #E81601",
-"w c #EC1201",
-"x c #F10D00",
-"y c #F50900",
-"z c #FA0400",
-"A c #FF0000",
-"B c #007D71",
+"= c #007D71",
+"- c #00FF0F",
+"; c #04FA0F",
+"> c #09F50F",
+", c #0DF10F",
+"' c #12EC0E",
+") c #16E80E",
+"! c #1BE30E",
+"~ c #1FDF0D",
+"{ c #24DA0D",
+"] c #28D60D",
+"^ c #2DD10D",
+"/ c #32CC0C",
+"( c #36C80C",
+"_ c #3BC30C",
+": c #3FBF0B",
+"< c #44BA0B",
+"[ c #48B60B",
+"} c #4DB10B",
+"| c #51AD0A",
+"1 c #56A80A",
+"2 c #5BA30A",
+"3 c #5F9F09",
+"4 c #649A09",
+"5 c #689609",
+"6 c #6D9109",
+"7 c #718D08",
+"8 c #768808",
+"9 c #7A8408",
+"0 c #7F7F07",
+"a c #847A07",
+"b c #887607",
+"c c #8D7107",
+"d c #916D06",
+"e c #966806",
+"f c #9A6406",
+"g c #9F5F05",
+"h c #A35B05",
+"i c #A85605",
+"j c #AD5105",
+"k c #B14D04",
+"l c #B64804",
+"m c #BA4404",
+"n c #BF3F03",
+"o c #C33B03",
+"p c #C83603",
+"q c #CC3203",
+"r c #D12D02",
+"s c #D62802",
+"t c #DA2402",
+"u c #DF1F01",
+"v c #E31B01",
+"w c #E81601",
+"x c #EC1201",
+"y c #F10D00",
+"z c #F50900",
+"A c #FA0400",
+"B c #FF0000",
"C c #283C38",
"D c #B60418",
"E c #00EB00",
-"F c #F7F3FF",
-"G c #71E371",
-"H c #494949",
-"I c #7A7A7A",
-"J c #BCBCBC",
+"F c #0E7973",
+"G c #F7F3FF",
+"H c #11817B",
+"I c #E80426",
+"J c #71E371",
+"K c #138984",
+"L c #16918C",
+"M c #494949",
+"N c #7A7A7A",
+"O c #BCBCBC",
"................................................................+...............................................................................................................................................................................",
"................................................................+...............................................................................................................................................................................",
"................................................................+...............................................................................................................................................................................",
@@ -84,48 +89,45 @@ static char * wmsysmon_master_xpm[] = {
".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................",
".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................",
".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................",
-".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................",
-".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+++++++++++++++++++++++++++++++++++++++++++++++++++...........................................................................................................................",
-"..@###########################################################..+.++$$$$+++$$$$+++++++$$$$+++$$$$+++++++$$$$+++$$$$++...........................................................................................................................",
-"................................................................+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................",
-"................................................................+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................",
-"................................................................+.+$++++$+$++++$+++++$++++$+$++++$+++++$++++$+$++++$+...........................................................................................................................",
-"..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+.++$$$$+++$$$$+++++++$$$$+++$$$$+++++++$$$$+++$$$$++...........................................................................................................................",
-".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+$++++$+$++++$+++++$++++$+$++++$+++++$++++$+$++++$+...........................................................................................................................",
-".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................",
+"..@###########################################################..+...............................................................................................................................................................................",
+"................................................................+.+++++++++++++++++++++++++++++++++++++++++++++++++++...........................................................................................................................",
+"................................................................+.++$$$$+++$$$$+++++++$$$$+++$$$$+++++++$$$$+++$$$$++...........................................................................................................................",
+"..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................",
".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................",
+".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+$++++$+$++++$+++++$++++$+$++++$+++++$++++$+$++++$+...........................................................................................................................",
".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.++$$$$+++$$$$+++++++$$$$+++$$$$+++++++$$$$+++$$$$++...........................................................................................................................",
-".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+++++++++++++++++++++++++++++++++++++++++++++++++++...........................................................................................................................",
+".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+.+$++++$+$++++$+++++$++++$+$++++$+++++$++++$+$++++$+...........................................................................................................................",
+"..@###########################################################..+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................",
+"................................................................+.+$++++$+$++++$++$++$++++$+$++++$++$++$++++$+$++++$+...........................................................................................................................",
+"................................................................+.++$$$$+++$$$$+++++++$$$$+++$$$$+++++++$$$$+++$$$$++...........................................................................................................................",
+"..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+.+++++++++++++++++++++++++++++++++++++++++++++++++++...........................................................................................................................",
".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+...............................................................................................................................................................................",
-"..@###########################################################..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................",
-"................................................................+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................",
-"................................................................+..+++%%%%+++$$$$&+&%%%%*+&%%%%&+&$$$$&+&%%%%&+&%%%%*+&%%%%&+&%%%%*+&%%%%*++++++................................................................................................",
+".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................",
+".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................",
+".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..+++%%%%+++$$$$&+&%%%%*+&%%%%&+&$$$$&+&%%%%&+&%%%%*+&%%%%&+&%%%%*+&%%%%*++++++................................................................................................",
+"..@###########################################################..+..++%++++%+$++++%+$++++%+$++++%+%++++%+%++++$+%++++$+$++++%+%++++%+%++++%++%+++................................................................................................",
"................................................................+..++%++++%+$++++%+$++++%+$++++%+%++++%+%++++$+%++++$+$++++%+%++++%+%++++%++%+++................................................................................................",
-"..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+..++%++++%+$++++%+$++++%+$++++%+%++++%+%++++$+%++++$+$++++%+%++++%+%++++%++%+++................................................................................................",
-".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..++%++++%+$++++%+$++++%+$++++%+%++++%+%++++$+%++++$+$++++%+%++++%+%++++%++++++................................................................................................",
-".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..++&$$$$&++$$$$&+&%%%%&+&%%%%&+&%%%%&+&%%%%&+&%%%%&++$$$$&+&%%%%&+&%%%%&++++++................................................................................................",
-".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..++%++++%+$++++%+%++++$+$++++%+$++++%+$++++%+%++++%+$++++%+%++++%+$++++%++++++................................................................................................",
-".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..++%++++%+$++++%+%++++$+$++++%+$++++%+$++++%+%++++%+$++++%+%++++%+$++++%++%+++................................................................................................",
+"................................................................+..++%++++%+$++++%+$++++%+$++++%+%++++%+%++++$+%++++$+$++++%+%++++%+%++++%++++++................................................................................................",
+"................................................................+..++&$$$$&++$$$$&+&%%%%&+&%%%%&+&%%%%&+&%%%%&+&%%%%&++$$$$&+&%%%%&+&%%%%&++++++................................................................................................",
+"..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+..++%++++%+$++++%+%++++$+$++++%+$++++%+$++++%+%++++%+$++++%+%++++%+$++++%++++++................................................................................................",
".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..++%++++%+$++++%+%++++$+$++++%+$++++%+$++++%+%++++%+$++++%+%++++%+$++++%++%+++................................................................................................",
-".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..+++%%%%+++$$$$&+&%%%%&+&%%%%&++$$$$&+&%%%%&+&%%%%&++$$$$&+&%%%%&+&%%%%&++++++................................................................................................",
-"..@###########################################################..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................",
-"................................................................+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................",
-"................................................................+...............................................................................................................................................................................",
-"................................................................+...............................................................................................................................................................................",
-"..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@..+..==-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzA...................................................................................................................",
-".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..==-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzA...................................................................................................................",
-".. at +++++$$$+++$$$+++$$$++++++++$$$+++$$$+++++++$$$+++$$$+++++#..+..==-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzA...................................................................................................................",
-".. at ++++$+++$+$+++$+$+++$++++++$+++$+$+++$+++++$+++$+$+++$++++#..+..==-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzA...................................................................................................................",
-".. at ++++$+++$+$+++$+$+++$++%+++$+++$+$+++$++%++$+++$+$+++$++++#..+..==-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzA...................................................................................................................",
-".. at +++++$$$+++$$$+++$$$+++B++++$$$+++$$$+++B+++$$$+++$$$+++++#..+..==-;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzA...................................................................................................................",
+".. at +++++$$$+++$$$+++$$$++++++++$$$+++$$$+++++++$$$+++$$$+++++#..+..++%++++%+$++++%+%++++$+$++++%+$++++%+$++++%+%++++%+$++++%+%++++%+$++++%++%+++................................................................................................",
+".. at ++++$+++$+$+++$+$+++$++++++$+++$+$+++$+++++$+++$+$+++$++++#..+..+++%%%%+++$$$$&+&%%%%&+&%%%%&++$$$$&+&%%%%&+&%%%%&++$$$$&+&%%%%&+&%%%%&++++++................................................................................................",
+".. at ++++$+++$+$+++$+$+++$++%+++$+++$+$+++$++%++$+++$+$+++$++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................",
+".. at +++++$$$+++$$$+++$$$+++=++++$$$+++$$$+++=+++$$$+++$$$+++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................................",
".. at ++++$+++$+$+++$+$+++$++++++$+++$+$+++$+++++$+++$+$+++$++++#..+...............................................................................................................................................................................",
-".. at ++++$+++$+$+++$+$+++$++%+++$+++$+$+++$++%++$+++$+$+++$++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................",
-".. at +++++$$$+++$$$+++$$$+++B++++$$$+++$$$+++B+++$$$+++$$$+++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................",
-".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................",
-"..############################################################..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................",
-"................................................................+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................",
-"................................................................+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................",
-"..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@....@@@@@@@@@@@@#..+...............................................................................................................................................................................",
+".. at ++++$+++$+$+++$+$+++$++%+++$+++$+$+++$++%++$+++$+$+++$++++#..+...............................................................................................................................................................................",
+".. at +++++$$$+++$$$+++$$$+++=++++$$$+++$$$+++=+++$$$+++$$$+++++#..+..--;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzAB...................................................................................................................",
+".. at ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#..+..--;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzAB...................................................................................................................",
+"..############################################################..+..--;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzAB...................................................................................................................",
+"................................................................+..--;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzAB...................................................................................................................",
+"................................................................+..--;>,')!~{]^/(_:<[}|1234567890abcdefghijklmnopqrstuvwxyzAB...................................................................................................................",
+"..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@....@@@@@@@@@@@@#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................",
+".. at +++++++++++++++++++++++++++++++++++++++++#.... at +++++++++++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................",
+".. at ++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#.... at ++CC+++CC++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................",
+".. at +CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#.... at +CCCC+CCCC+#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................",
+".. at +CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#.... at +CCCC+CCCC+#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................",
+".. at ++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#.... at ++CC+++CC++#..+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..................................................................................................................",
".. at +++++++++++++++++++++++++++++++++++++++++#.... at +++++++++++#..+...............................................................................................................................................................................",
".. at ++CC+++CC+++CC+++CC+++CC+++CC+++CC+++CC++#.... at ++CC+++CC++#..+...............................................................................................................................................................................",
".. at +CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+CCCC+#.... at +CCCC+CCCC+#..+...............................................................................................................................................................................",
@@ -140,24 +142,27 @@ static char * wmsysmon_master_xpm[] = {
"..###########################################....#############..+...............................................................................................................................................................................",
"................................................................+...............................................................................................................................................................................",
"................................................................+...............................................................................................................................................................................",
+"................................................................+...............................................................................................................................................................................",
+"................................................................+...............................................................................................................................................................................",
+"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+...............................................................................................................................................................................",
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.................................................................................................................................................................",
-"++%%%+++$$$B+B%%%B+B%%%B+B$$$B+B%%%B+B%%%B+B%%%B+B%%%B+B%%%B+++++++++++++++++++.................................................................................................................................................................",
-"+%+++%+$+++%+$+++%+$+++%+%+++%+%+++$+%+++$+$+++%+%+++%+%+++%++++++++++++%++++++..+DD+..+EE+..+CC+...............................................................................................................................................",
-"+%+++%+$+++%+$+++%+$+++%+%+++%+%+++$+%+++$+$+++%+%+++%+%+++%++%++++%++++%++++++..DFDD..EFEE..CCCC...............................................................................................................................................",
-"+B$$$B++$$$B+B%%%B++%%%B+B%%%B+B%%%B+B%%%B++$$$B+$%%%$+B%%%B++B++++B+++%+++++++..DDDD..EEEE..CCCC...+%$G........................................................................................................................................",
-"+%+++%+$+++%+%+++$+$+++%+$+++%+$+++%+%+++%+$+++%+%+++%+$+++%+++++++++++%+++++++..+DD+..+EE+..+CC+...............................................................................................................................................",
+"++%%%+++$$$=+=%%%=+=%%%=+=$$$=+=%%%=+=%%%=+=%%%=+=%%%=+=%%%=+++++++++++++++++++.................................................................................................................................................................",
+"+%+++%+$+++%+$+++%+$+++%+%+++%+%+++$+%+++$+$+++%+%+++%+%+++%++++++++++++%++++++..+DD++.+EE++.+CC++..........FFFF....++++....++++....++++....++++................................................................................................",
+"+%+++%+$+++%+$+++%+$+++%+%+++%+%+++$+%+++$+$+++%+%+++%+%+++%++%++++%++++%++++++..DGDD+.EGEE+.CCCC+..........HHHH....HHHH....++++....++++....+II+................................................................................................",
+"+=$$$=++$$$=+=%%%=++%%%=+=%%%=+=%%%=+=%%%=++$$$=+$%%%$+=%%%=++=++++=+++%+++++++..DDDD+.EEEE+.CCCC+..+%$J....KKKK....KKKK....KKKK....++++....+II+................................................................................................",
+"+%+++%+$+++%+%+++$+$+++%+$+++%+$+++%+%+++%+$+++%+%+++%+$+++%+++++++++++%+++++++..+DD++.+EE++.+CC++..........LLLL....LLLL....LLLL....LLLL....++++................................................................................................",
"+%+++%+$+++%+%+++$+$+++%+$+++%+$+++%+%+++%+$+++%+%+++%+$+++%++%++++%++%++++++++.................................................................................................................................................................",
-"++%%%+++$$$%+B%%%B+B%%%B++$$$B+B%%%B+B%%%B++$$$B+B%%%B+B%%%B++B++++B++%++++++++.................................................................................................................................................................",
+"++%%%+++$$$%+=%%%=+=%%%=++$$$=+=%%%=+=%%%=++$$$=+=%%%=+=%%%=++=++++=++%++++++++.................................................................................................................................................................",
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.................................................................................................................................................................",
"................................................................................................................................................................................................................................................",
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................",
-"+$%%%$+B%%%++B%%%B+B%%%++B%%%B+B%%%B+B%%%B+B$$$B++$$$B++$$$B+B$$$B+B$$$++%$$$%+B%%%++B%%%B+B%%%B+B%%%B+B%%%B+B%%%B+B%%%B+B$$$B+B$$$B+B$$$B+B$$$B+B$$$B+B%%%B++++................................................................................",
+"+$%%%$+=%%%++=%%%=+=%%%++=%%%=+=%%%=+=%%%=+=$$$=++$$$=++$$$=+=$$$=+=$$$++%$$$%+=%%%++=%%%=+=%%%=+=%%%=+=%%%=+=%%%=+=%%%=+=$$$=+=$$$=+=$$$=+=$$$=+=$$$=+=%%%=++++................................................................................",
"+%+++%+%+++%+%+++$+%+++%+%+++$+%+++$+%+++$+%+++%+$+++%+$+++%+%+++%+%+++$+%%+%%+%+++%+%+++%+%+++%+%+++%+%+++%+%+++$+$+%+$+%+++%+%+++%+%+++%+%+++%+%+++%+$+++%++++................................................................................",
"+%+++%+%+++%+%+++$+%+++%+%+++$+%+++$+%+++$+%+++%+$+++%+$+++%+%++%$+%+++$+%+%+%+%+++%+%+++%+%+++%+%+++%+%+++%+%+++$+$+%+$+%+++%+%+++%+%+++%+$%+%$+%+++%+$++%$++++................................................................................",
-"+B%%%B+B%%%++B$$$++B$$$B+B%%%++B%%%++B$%%B+B%%%B++$$$B++$$$B+B%%$++B$$$++B$$$B+B$$$B+B$$$B+B%%%B+B%$$B+B%%%++B%%%B++$B$++B$$$B+B$$$B+B$$$B++$%$++B%%%B++$%$+++++................................................................................",
+"+=%%%=+=%%%++=$$$++=$$$=+=%%%++=%%%++=$%%=+=%%%=++$$$=++$$$=+=%%$++=$$$++=$$$=+=$$$=+=$$$=+=%%%=+=%$$=+=%%%++=%%%=++$=$++=$$$=+=$$$=+=$$$=++$%$++=%%%=++$%$+++++................................................................................",
"+%+++%+%+++%+%+++$+%+++%+%+++$+%+++$+%+++%+%+++%+$+++%+$+++%+%++%$+%+++$+%+++%+%+++%+%+++%+%+++$+%+%+%+%+++%+$+++%+$+%+$+%+++%+%+++%+%+%+%+$%+%$+$+++%+$%++$++++................................................................................",
"+%+++%+%+++%+%+++$+%+++%+%+++$+%+++$+%+++%+%+++%+$+++%+$+++%+%+++%+%+++$+%+++%+%+++%+%+++%+%+++$+%++%%+%+++%+$+++%+$+%+$+%+++%+%+++%+%%+%%+%+++%+$+++%+%+++$++++................................................................................",
-"+B$$$B+B%%%++B%%%B+%%%%++B%%%B+%$$$++B%%%B+B$$$B++$$$%+B%%%B+B$$$B+B%%%$+B$$$B+%$$$%+B%%%B+B$$$++B%%%B+B$$$B+B%%%B++$B$++$%%%%++%%%++%$$$%+B$$$%BB%%%B+B%%%B++++................................................................................",
+"+=$$$=+=%%%++=%%%=+%%%%++=%%%=+%$$$++=%%%=+=$$$=++$$$%+=%%%=+=$$$=+=%%%$+=$$$=+%$$$%+=%%%=+=$$$++=%%%=+=$$$=+=%%%=++$=$++$%%%%++%%%++%$$$%+=$$$%==%%%=+=%%%=++++................................................................................",
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++................................................................................",
"................................................................................................................................................................................................................................................",
".... at ++++++++++++++++++++++++++++++++++++++++++++++++++++++#....+...............................................................................................................................................................................",
@@ -172,7 +177,7 @@ static char * wmsysmon_master_xpm[] = {
".....++++++++++++++++++++++++++++++++++++++++++++++++++++++.....................................................................................................................................................................................",
"................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................",
-"$B%.............................................................................................................................................................................................................................................",
-"HIJ.............................................................................................................................................................................................................................................",
+"$=%.............................................................................................................................................................................................................................................",
+"MNO.............................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................"};
diff --git a/wmsysmon/wmsysmon-master.xpm b/src/wmsysmon-master-i386.xpm
similarity index 97%
rename from wmsysmon/wmsysmon-master.xpm
rename to src/wmsysmon-master-i386.xpm
index a3be939..fc172b0 100644
--- a/wmsysmon/wmsysmon-master.xpm
+++ b/src/wmsysmon-master-i386.xpm
@@ -1,6 +1,6 @@
/* XPM */
static char * wmsysmon_master_xpm[] = {
-"240 100 75 1",
+"240 100 80 1",
". c #0000FF",
" c None",
"+ c #202020",
@@ -71,11 +71,16 @@ static char * wmsysmon_master_xpm[] = {
"C c #283C38",
"D c #B60418",
"E c #00EB00",
-"F c #F7F3FF",
-"G c #71E371",
-"H c #494949",
-"I c #7A7A7A",
-"J c #BCBCBC",
+"F c #0E7973",
+"G c #F7F3FF",
+"H c #11817B",
+"I c #E80426",
+"J c #71E371",
+"K c #138984",
+"L c #16918C",
+"M c #494949",
+"N c #7A7A7A",
+"O c #BCBCBC",
"................................................................+...............................................................................................................................................................................",
"................................................................+...............................................................................................................................................................................",
"................................................................+...............................................................................................................................................................................",
@@ -142,10 +147,10 @@ static char * wmsysmon_master_xpm[] = {
"................................................................+...............................................................................................................................................................................",
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.................................................................................................................................................................",
"++%%%+++$$$B+B%%%B+B%%%B+B$$$B+B%%%B+B%%%B+B%%%B+B%%%B+B%%%B+++++++++++++++++++.................................................................................................................................................................",
-"+%+++%+$+++%+$+++%+$+++%+%+++%+%+++$+%+++$+$+++%+%+++%+%+++%++++++++++++%++++++..+DD+..+EE+..+CC+...............................................................................................................................................",
-"+%+++%+$+++%+$+++%+$+++%+%+++%+%+++$+%+++$+$+++%+%+++%+%+++%++%++++%++++%++++++..DFDD..EFEE..CCCC...............................................................................................................................................",
-"+B$$$B++$$$B+B%%%B++%%%B+B%%%B+B%%%B+B%%%B++$$$B+$%%%$+B%%%B++B++++B+++%+++++++..DDDD..EEEE..CCCC...+%$G........................................................................................................................................",
-"+%+++%+$+++%+%+++$+$+++%+$+++%+$+++%+%+++%+$+++%+%+++%+$+++%+++++++++++%+++++++..+DD+..+EE+..+CC+...............................................................................................................................................",
+"+%+++%+$+++%+$+++%+$+++%+%+++%+%+++$+%+++$+$+++%+%+++%+%+++%++++++++++++%++++++..+DD+..+EE+..+CC+...........FFFF....++++....++++....++++....++++................................................................................................",
+"+%+++%+$+++%+$+++%+$+++%+%+++%+%+++$+%+++$+$+++%+%+++%+%+++%++%++++%++++%++++++..DGDD..EGEE..CCCC...........HHHH....HHHH....++++....++++....+II+................................................................................................",
+"+B$$$B++$$$B+B%%%B++%%%B+B%%%B+B%%%B+B%%%B++$$$B+$%%%$+B%%%B++B++++B+++%+++++++..DDDD..EEEE..CCCC...+%$J....KKKK....KKKK....KKKK....++++....+II+................................................................................................",
+"+%+++%+$+++%+%+++$+$+++%+$+++%+$+++%+%+++%+$+++%+%+++%+$+++%+++++++++++%+++++++..+DD+..+EE+..+CC+...........LLLL....LLLL....LLLL....LLLL....++++................................................................................................",
"+%+++%+$+++%+%+++$+$+++%+$+++%+$+++%+%+++%+$+++%+%+++%+$+++%++%++++%++%++++++++.................................................................................................................................................................",
"++%%%+++$$$%+B%%%B+B%%%B++$$$B+B%%%B+B%%%B++$$$B+B%%%B+B%%%B++B++++B++%++++++++.................................................................................................................................................................",
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.................................................................................................................................................................",
@@ -173,6 +178,6 @@ static char * wmsysmon_master_xpm[] = {
"................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................",
"$B%.............................................................................................................................................................................................................................................",
-"HIJ.............................................................................................................................................................................................................................................",
+"MNO.............................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................",
"................................................................................................................................................................................................................................................"};
diff --git a/src/wmsysmon.c b/src/wmsysmon.c
new file mode 100644
index 0000000..522d20f
--- /dev/null
+++ b/src/wmsysmon.c
@@ -0,0 +1,949 @@
+/*
+ wmsysmon -- system monitoring dockapp
+
+ Copyright (C) 1998-1999 Dave Clark - clarkd at skynet.ca
+ Copyright (C) 2000 Vito Caputo - swivel at gnugeneration.com
+
+ wmsysmon is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ wmsysmon is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <math.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <X11/Xlib.h>
+#include <X11/xpm.h>
+#include <X11/extensions/shape.h>
+
+#ifdef PROF
+#include <Profile/Profiler.h>
+#endif
+
+#include "wmgeneral.h"
+
+#ifdef HI_INTS
+#include "wmsysmon-master-alpha.xpm"
+#else
+#include "wmsysmon-master-i386.xpm"
+#endif
+
+#define WMSYSMON_VERSION "0.7.6"
+
+#define CHAR_WIDTH 5
+#define CHAR_HEIGHT 7
+
+#define BCHAR_WIDTH 6
+#define BCHAR_HEIGHT 9
+
+#define BOFFX (93)
+#define BOFFY (66)
+#define BREDX (81)
+#define BREDY (66)
+#define BGREENX (87)
+#define BGREENY (66)
+
+#define LITEW (4)
+#define LITEH (4)
+
+#define B_OFF (0)
+#define B_RED (1)
+#define B_GREEN (2)
+
+/* meter definitions */
+#define VBAR_W (4)
+#define VBAR_H (4)
+
+#define INT_LITES (1)
+#define INT_METERS (2)
+
+char wmsysmon_mask_bits[64*64];
+int wmsysmon_mask_width = 64;
+int wmsysmon_mask_height = 64;
+
+long start_time = 0;
+long start_uptime = 0;
+int counter = 0;
+int Mem_l; /* line in /proc/meminfo "Mem:" is on */
+int Swap_l; /* line in /proc/meminfo "Swap:" is on */
+int intr_l; /* line in /proc/stat "intr" is on */
+int rio_l; /* line in /proc/stat "disk_rio" is on */
+int wio_l; /* line in /proc/stat "disk_wio" is on */
+int page_l; /* line in /proc/stat "page" is on */
+int swap_l; /* line in /proc/stat "swap" is on */
+
+long io_max;
+long io_max_diff;
+
+int meter[4][2];
+
+#ifdef HI_INTS
+long _last_ints[24];
+long _ints[24];
+int int_peaks[24];
+#else
+long _last_ints[16];
+long _ints[16];
+int int_peaks[16];
+#endif
+long *last_ints;
+long *ints;
+long int_mode = INT_METERS;
+
+long last_pageins=0;
+long last_pageouts=0;
+
+long last_swapins=0;
+long last_swapouts=0;
+
+char buf[1024];
+FILE *statfp;
+FILE *memfp;
+
+int update_rate = 100000;
+
+char *ProgName;
+
+time_t curtime;
+time_t prevtime;
+
+
+void usage(void);
+void printversion(void);
+void BlitString(char *name, int x, int y);
+void BlitNum(int num, int x, int y);
+void wmsysmon_routine(int, char **);
+void DrawBar(int sx, int sy, int w, int h, float percent, int dx, int dy);
+void DrawLite(int state, int dx, int dy);
+void DrawUptime(void);
+void DrawStuff( void );
+void DrawMem( void );
+void DrawMeter(unsigned int, unsigned int, int, int);
+
+int main(int argc, char *argv[]) {
+ int i;
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "main()", "int(int, char **)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+ TAU_PROFILE_INIT(argc, argv);
+ TAU_PROFILE_SET_NODE(0);
+#endif
+
+ /* set meter x,y pairs */
+ meter[3][0] = 108;
+ meter[3][1] = 66;
+ meter[2][0] = 116;
+ meter[2][1] = 66;
+ meter[1][0] = 124;
+ meter[1][1] = 66;
+ meter[0][0] = 132;
+ meter[0][1] = 66;
+
+ last_ints = _last_ints;
+ ints = _ints;
+
+ /* Parse Command Line */
+
+ ProgName = argv[0];
+ if (strlen(ProgName) >= 5)
+ ProgName += (strlen(ProgName) - 5);
+
+ for (i = 1; i < argc; i++) {
+ char *arg = argv[i];
+
+ if (*arg == '-') {
+ switch (arg[1]) {
+ case 'd':
+ if (strcmp(arg + 1, "display")) {
+ usage();
+ exit(1);
+ }
+ break;
+ case 'g':
+ if (strcmp(arg+1, "geometry")) {
+ usage();
+ exit(1);
+ }
+ break;
+ case 'v':
+ printversion();
+ exit(0);
+ break;
+ case 'r':
+ if (argc > (i + 1)) {
+ update_rate = (atoi(argv[i + 1]) * 1000);
+ i++;
+ }
+ break;
+ case 'l':
+ int_mode = INT_LITES;
+ break;
+
+ default:
+ usage();
+ exit(0);
+ break;
+ }
+ }
+ }
+
+ wmsysmon_routine(argc, argv);
+
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+
+ return 0;
+}
+
+
+void wmsysmon_routine(int argc, char **argv)
+{
+ int i;
+#ifdef PROF
+ int x = 0;
+#endif
+ XEvent Event;
+ int but_stat = -1;
+ FILE *fp;
+
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "wmsysmon_routine()", "(int, char **)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ createXBMfromXPM(wmsysmon_mask_bits, wmsysmon_master_xpm, wmsysmon_mask_width, wmsysmon_mask_height);
+
+ openXwindow(argc, argv, wmsysmon_master_xpm, wmsysmon_mask_bits, wmsysmon_mask_width, wmsysmon_mask_height);
+
+ /* init ints */
+ bzero(&_last_ints, sizeof(_last_ints));
+ bzero(&_ints, sizeof(_ints));
+ bzero(&int_peaks, sizeof(int_peaks));
+
+
+ /* init uptime */
+ fp = fopen("/proc/uptime", "r");
+ if (fp) {
+ fscanf(fp, "%ld", &start_time);
+ fclose(fp);
+ start_uptime = time(NULL);
+ }
+
+ statfp = fopen("/proc/stat", "r");
+ memfp = fopen("/proc/meminfo", "r");
+
+ /* here we find tags in /proc/stat & /proc/meminfo and note their
+ * lines, for faster lookup throughout execution.
+ */
+ /* /proc/meminfo */
+ for(i = 0; fgets(buf, 1024, memfp); i++) {
+ if(strstr(buf, "Mem:")) Mem_l = i;
+ else if(strstr(buf, "Swap:")) Swap_l = i;
+ }
+
+ /* /proc/stat */
+ for(i = 0; fgets(buf, 1024, statfp); i++) {
+ if(strstr(buf, "disk_wio")) wio_l = i;
+ else if(strstr(buf, "disk_rio")) rio_l = i;
+ else if(strstr(buf, "page")) page_l = i;
+ else if(strstr(buf, "swap")) swap_l = i;
+ else if(strstr(buf, "intr")) intr_l = i;
+ }
+
+#ifdef PROF
+ while (x < 1000) {
+#else
+ while(1) {
+#endif
+
+ curtime = time(0);
+
+#if 1
+ DrawUptime();
+ DrawStuff();
+ DrawMem();
+ RedrawWindow();
+#endif
+
+ /* X Events */
+ while (XPending(display)) {
+ XNextEvent(display, &Event);
+ switch (Event.type) {
+ case Expose:
+ DirtyWindow(Event.xexpose.x,
+ Event.xexpose.y,
+ Event.xexpose.width,
+ Event.xexpose.height);
+ break;
+ case DestroyNotify:
+ XCloseDisplay(display);
+ exit(0);
+ break;
+
+ default:
+#ifdef MONDEBUG
+ printf("got: %i\n", Event.type);
+#endif
+ }
+ }
+#ifdef PROF
+ x++;
+#endif
+
+ usleep(update_rate);
+ }
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+void DrawMeter(unsigned int level, unsigned int peak, int dx, int dy)
+{
+ static unsigned int a;
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "DrawMeter()", "(int, unsigned int, int, int)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ /* 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
+ * since we're using only 4 lines for our level, the timer interrupt
+ * usually kills the peak for the others so they never move. */
+
+ if(peak) {
+ a = level * 3 / peak;
+ } else a = 0;
+
+#ifdef MONDEBUG
+ printf("level: %u peak: %u selection: %u\n", level, peak, a);
+ fflush(stdout);
+#endif
+
+ if(a > 3) a = 3;
+
+ copyXPMArea(meter[a][0],
+ meter[a][1],
+ VBAR_W,
+ VBAR_H,
+ dx,
+ dy);
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+
+void DrawBar(int sx, int sy, int w, int h, float percent, int dx, int dy)
+{
+ static int tx;
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "DrawBar()", "(int, int, int, int, float, int, int)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ 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);
+
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+void DrawLite(int state, int dx, int dy)
+{
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "DrawLite()", "(int, int, int)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ switch(state) {
+ case B_RED:
+ copyXPMArea(BREDX, BREDY, LITEW, LITEH, dx, dy);
+ break;
+ case B_GREEN:
+ copyXPMArea(BGREENX, BGREENY, LITEW, LITEH, dx, dy);
+ break;
+ default:
+ case B_OFF:
+ copyXPMArea(BOFFX, BOFFY, LITEW, LITEH, dx, dy);
+ break;
+ }
+
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+void DrawUptime(void)
+{
+ static int first = 1;
+ static int old_days = 0, old_hours = 0, old_minutes = 0;
+ static long uptime;
+ static int i;
+
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "DrawUptime()", "", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ uptime = curtime - start_uptime + start_time;
+
+ /* blit minutes */
+ uptime /=60;
+ i = uptime % 60;
+
+ if(old_minutes != i || first) {
+ old_minutes = i;
+ sprintf(buf, "%02i", i);
+#ifdef HI_INTS
+ BlitString(buf, 45, 29);
+#else
+ BlitString(buf, 45, 37);
+#endif
+ }
+
+ /* blit hours */
+ uptime /=60;
+ i = uptime % 24;
+
+ if(old_hours != i || first) {
+ old_hours = i;
+ sprintf(buf, "%02i", i);
+#ifdef HI_INTS
+ BlitString(buf, 29, 29);
+#else
+ BlitString(buf, 29, 37);
+#endif
+ }
+
+
+ /* blit days */
+ uptime /= 24;
+ i = uptime;
+ if(old_days != i || first) {
+ old_days = i;
+ sprintf(buf, "%03i", i);
+#ifdef HI_INTS
+ BlitString(buf, 6, 29);
+#else
+ BlitString(buf, 6, 37);
+#endif
+ }
+
+ first = 0;
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+void DrawStuff( void )
+{
+ static int io_last = 0, 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};
+ /* 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};
+#endif
+ static int pagein_lite = 0, pageout_lite = 0, swapin_lite = 0, swapout_lite = 0;
+ static char *tok;
+ static char seps[] = {" "};
+ static int i, ents;
+
+ static long io;
+ static long iodiff;
+ static int iopercent;
+
+ static long pageins;
+ static long pageouts;
+ static long swapins;
+ static long swapouts;
+ static long intdiff;
+ static long stage;
+ static long *tints;
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "DrawStuff()", "", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ stage = io = iodiff = iopercent = pageins = pageouts = swapins = swapouts = 0;
+
+ statfp = freopen("/proc/stat", "r", statfp);
+
+
+ for(i = 0, ents = 0; ents < 5 && fgets(buf, 1024, statfp); i++) {
+ if(i == rio_l) {
+ tok = strtok(buf, seps);
+
+ io += atoi(tok);
+ tok = strtok(NULL, seps);
+
+ io += atoi(tok);
+ tok = strtok(NULL, seps);
+
+ io += atoi(tok);
+ tok = strtok(NULL, seps);
+
+ io += atoi(tok);
+ tok = strtok(NULL, seps);
+ ents++;
+ } else if(i == wio_l) {
+ tok = strtok(buf, seps);
+
+ io += atoi(tok);
+ tok = strtok(NULL, seps);
+
+ io += atoi(tok);
+ tok = strtok(NULL, seps);
+
+ io += atoi(tok);
+ tok = strtok(NULL, seps);
+
+ io += atoi(tok);
+ tok = strtok(NULL, seps);
+ ents++;
+ } else if(i == page_l) {
+ sscanf(buf, "%*s %ld %ld", &pageins, &pageouts);
+ ents++;
+ } else if(i == swap_l) {
+ sscanf(buf, "%*s %ld %ld",
+ &swapins, &swapouts);
+ ents++;
+ } else if(i == intr_l) {
+ sscanf( buf,
+ #ifdef HI_INTS
+ "%*s %*d %ld %ld %ld %ld %ld"
+ "%ld %ld %ld %ld %ld %ld %ld"
+ "%ld %ld %ld %ld %ld %ld %ld"
+ "%ld %ld %ld %ld %ld",
+ &ints[0], &ints[1], &ints[2],
+ &ints[3], &ints[4], &ints[5],
+ &ints[6], &ints[7], &ints[8],
+ &ints[9], &ints[10], &ints[11],
+ &ints[12], &ints[13], &ints[14],
+ &ints[15], &ints[16], &ints[17],
+ &ints[18], &ints[19], &ints[20],
+ &ints[21], &ints[22], &ints[23]);
+ #else
+ "%*s %*d %ld %ld %ld %ld %ld"
+ "%ld %ld %ld %ld %ld %ld %ld"
+ "%ld %ld %ld %ld",
+ &ints[0], &ints[1], &ints[2],
+ &ints[3], &ints[4], &ints[5],
+ &ints[6], &ints[7], &ints[8],
+ &ints[9], &ints[10], &ints[11],
+ &ints[12], &ints[13], &ints[14],
+ &ints[15]);
+ #endif
+ ents++;
+ }
+ }
+
+
+ /* ------------------ 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;
+
+ if(iodiff > io_max_diff) io_max_diff = iodiff;
+
+ if (iopercent > 100) iopercent = 100;
+
+
+ if(iopercent != io_last || first) {
+ io_last = iopercent;
+#ifdef HI_INTS
+ DrawBar(67, 36, 58, 4, iopercent, 3, 20);
+#else
+ DrawBar(67, 36, 58, 6, iopercent, 3, 26);
+#endif
+ }
+
+
+ if(int_mode == INT_LITES) {
+ /* top 8 ints */
+ for (i = 0; i < 8; i++) {
+ if ( ints[i] > last_ints[i] && !int_lites[i]) {
+ int_lites[i] = 1;
+#ifdef HI_INTS
+ DrawLite(B_GREEN, 4 + (i * LITEW) + i, 43);
+#else
+ DrawLite(B_GREEN, 4 + (i * LITEW) + i, 51);
+#endif
+ } else if(ints[i] == last_ints[i] && int_lites[i]) {
+ int_lites[i] = 0;
+#ifdef HI_INTS
+ DrawLite(B_OFF, 4 + (i * LITEW) + i, 43);
+#else
+ DrawLite(B_OFF, 4 + (i * LITEW) + i, 51);
+#endif
+ }
+ }
+ /* middle/bottom 8 */
+ for (i = 8; i < 16; i++) {
+ if ( ints[i] > last_ints[i] && !int_lites[i]) {
+ int_lites[i] = 1;
+#ifdef HI_INTS
+ DrawLite(B_GREEN, 4 + ((i - 8) *LITEW) + (i - 8), 48);
+#else
+ DrawLite(B_GREEN, 4 + ((i - 8) *LITEW) + (i - 8), 56);
+#endif
+ } else if(ints[i] == last_ints[i] && int_lites[i]) {
+ int_lites[i] = 0;
+#ifdef HI_INTS
+ DrawLite(B_OFF, 4 + ((i - 8) * LITEW) + (i - 8), 48);
+#else
+ DrawLite(B_OFF, 4 + ((i - 8) * LITEW) + (i - 8), 56);
+#endif
+ }
+ }
+
+#ifdef HI_INTS
+ /* bottom 8 on alpha/smp x86 */
+ for (i = 16; i < 24; i++) {
+ if (ints[i] > last_ints[i] && !int_lites[i] ) {
+ int_lites[i] = 1;
+ DrawLite(B_GREEN, 4 + ((i - 16) * LITEW) + (i - 16), 53);
+ } else if(ints[i] == last_ints[i] && int_lites[i]) {
+ int_lites[i] = 0;
+ DrawLite(B_OFF, 4 + ((i -16) * LITEW) + (i - 16), 53);
+ }
+ }
+#endif
+ } else if(int_mode == INT_METERS) {
+ for (i = 0; i < 8; i++) {
+ intdiff = ints[i] - last_ints[i];
+ int_peaks[i] = (int_peaks[i] + intdiff) >> 1;
+#ifdef HI_INTS
+ DrawMeter(intdiff,
+ int_peaks[i],
+ VBAR_H + (i * VBAR_W) + i,
+ 43);
+#else
+ DrawMeter(intdiff,
+ int_peaks[i],
+ VBAR_H + (i * VBAR_W) + i,
+ 51);
+#endif
+ }
+
+ for (i = 8; i < 16; i++) {
+ intdiff = ints[i] - last_ints[i];
+ int_peaks[i] = (int_peaks[i] + intdiff) >> 1;
+#ifdef HI_INTS
+ DrawMeter(intdiff,
+ int_peaks[i],
+ VBAR_H + ((i - 8) * VBAR_W) + (i - 8),
+ 48);
+#else
+ DrawMeter(intdiff,
+ int_peaks[i],
+ VBAR_H + ((i - 8) * VBAR_W) + (i - 8),
+ 56);
+#endif
+ }
+
+#ifdef HI_INTS
+ for (i = 16; i < 24; i++) {
+ intdiff = ints[i] - last_ints[i];
+ int_peaks[i] = (int_peaks[i] + intdiff) >> 1;
+
+ DrawMeter(intdiff,
+ int_peaks[i],
+ VBAR_H + ((i - 16) * VBAR_W) + (i - 16),
+ 53);
+ }
+#endif
+ }
+
+ tints = last_ints;
+ last_ints = ints;
+ ints = tints;
+
+ /* page in / out */
+
+ if (pageins > last_pageins && !pagein_lite) {
+ pagein_lite = 1;
+#ifdef HI_INTS
+ DrawLite(B_RED, 51, 43);
+#else
+ DrawLite(B_RED, 51, 51);
+#endif
+ } else if(pagein_lite) {
+ pagein_lite = 0;
+#ifdef HI_INTS
+ DrawLite(B_OFF, 51, 43);
+#else
+ DrawLite(B_OFF, 51, 51);
+#endif
+ }
+
+ if (pageouts > last_pageouts && !pageout_lite) {
+ pageout_lite = 1;
+#ifdef HI_INTS
+ DrawLite(B_RED, 56, 43);
+#else
+ DrawLite(B_RED, 56, 51);
+#endif
+ } else if(pageout_lite) {
+ pageout_lite = 0;
+#ifdef HI_INTS
+ DrawLite(B_OFF, 56, 43);
+#else
+ DrawLite(B_OFF, 56, 51);
+#endif
+ }
+
+ last_pageins = pageins;
+ last_pageouts = pageouts;
+
+ /* swap in/out */
+
+ if(swapins > last_swapins && !swapin_lite) {
+ swapin_lite = 1;
+#ifdef HI_INTS
+ DrawLite(B_RED, 51, 48);
+#else
+ DrawLite(B_RED, 51, 56);
+#endif
+ } else if(swapin_lite) {
+ swapin_lite = 0;
+#ifdef HI_INTS
+ DrawLite(B_OFF, 51, 48);
+#else
+ DrawLite(B_OFF, 51, 56);
+#endif
+ }
+
+ if (swapouts > last_swapouts && !swapout_lite) {
+ swapout_lite = 1;
+#ifdef HI_INTS
+ DrawLite(B_RED, 56, 48);
+#else
+ DrawLite(B_RED, 56, 56);
+#endif
+ } else if(swapout_lite) {
+ swapout_lite = 0;
+#ifdef HI_INTS
+ DrawLite(B_OFF, 56, 48);
+#else
+ DrawLite(B_OFF, 56, 56);
+#endif
+ }
+
+ last_swapins = swapins;
+ last_swapouts = swapouts;
+
+ first = 0;
+
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+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;
+
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "DrawMem()", "", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ counter--;
+
+ if(counter >= 0) return; /* polling /proc/meminfo is EXPENSIVE */
+ counter = 3000000 / update_rate;
+
+ memfp = freopen("/proc/meminfo", "r", memfp);
+
+ for(i = 0, ents = 0; ents < 2 && fgets(buf, 1024, memfp); i++) {
+ if(i == Mem_l) {
+ sscanf(buf, "%*s %ld %ld %*d %*d %ld %ld",
+ &mem_total,
+ &mem_used,
+ &mem_buffers,
+ &mem_cache);
+ ents++;
+ } else if(i == Swap_l) {
+ sscanf(buf, "%*s %ld %ld %ld",
+ &swap_total,
+ &swap_used,
+ &swap_free);
+ ents++;
+ }
+ }
+
+ /* 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;
+
+ swappercent = ((float)(swap_used)
+ /
+ (float)swap_total) * 100;
+
+ if(mempercent != last_mem || first) {
+ last_mem = mempercent;
+#ifdef HI_INTS
+ DrawBar(67, 36, 58,4 , mempercent, 3, 4);
+#else
+ DrawBar(67, 36, 58, 6, mempercent, 3, 4);
+#endif
+ }
+
+ if(swappercent != last_swap || first) {
+ last_swap = swappercent;
+#ifdef HI_INTS
+ DrawBar(67, 36, 58, 4, swappercent, 3, 12);
+#else
+ DrawBar(67, 36, 58, 6, swappercent, 3, 15);
+#endif
+ }
+
+ first = 0;
+
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+/* Blits a string at given co-ordinates */
+void BlitString(char *name, int x, int y)
+{
+ static int i, c, k;
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "BlitString()", "(char *, int, int)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ k = x;
+ for (i=0; name[i]; i++) {
+
+ c = toupper(name[i]);
+ if (c >= 'A' && c <= 'Z') {
+ c -= 'A';
+ copyXPMArea(c * 6, 74, 6, 8, k, y);
+ k += 6;
+ } else {
+ c -= '0';
+ copyXPMArea(c * 6, 64, 6, 8, k, y);
+ k += 6;
+ }
+ }
+
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+void BlitNum(int num, int x, int y)
+{
+ static int newx;
+
+#ifdef PROF
+ TAU_PROFILE_TIMER(tautimer, "BlitNum()", "(int, int, int)", TAU_DEFAULT);
+ TAU_PROFILE_START(tautimer);
+#endif
+
+ newx = x;
+
+ sprintf(buf, "%03i", num);
+
+ BlitString(buf, newx, y);
+
+#ifdef PROF
+ TAU_PROFILE_STOP(tautimer);
+#endif
+}
+
+
+void usage(void)
+{
+ fprintf(stderr, "\nwmsysmon - http://www.gnugeneration.com\n");
+ fprintf(stderr, "\n-------------------\n"
+ "|[---------------]| <--- Memory Use %\n"
+ "|[---------------]| <--- Swap Use %\n"
+ "|[---------------]| <--- I/O %\n"
+ "| |\n"
+ "| 000:00:00 | <--- Uptime days:hours:minutes\n"
+ "| |\n"
+#ifdef HI_INTS
+ "| 01234567 UV | <--- 0-N are hardware interrupts 0-23\n"
+ "| 89ABCDEF WX | <--- U,V are Page IN/OUT, W,X are Swap IN/OUT\n"
+ "| GHIJKLMN YZ |\n"
+#else
+ "| 01234567 WX | <--- 0-F are hardware interrupts 0-15\n"
+ "| 89ABCDEF YZ | <--- W,X are Page IN/OUT, W,X are Swap IN/OUT\n"
+#endif
+ "-------------------\n");
+
+ fprintf(stderr, "usage:\n");
+ fprintf(stderr, "\t-display <display name>\n");
+ fprintf(stderr, "\t-geometry +XPOS+YPOS\tinitial window position\n");
+ fprintf(stderr, "\t-r\t\t\tupdate rate in milliseconds (default:300)\n");
+ fprintf(stderr, "\t-l\t\t\tblinky lights for interrupts vs. meters(default)\n");
+ fprintf(stderr, "\t-h\t\t\tthis help screen\n");
+ fprintf(stderr, "\t-v\t\t\tprint the version number\n");
+ fprintf(stderr, "\n");
+}
+
+
+void printversion(void)
+{
+ fprintf(stderr, "wmsysmon v%s\n", WMSYSMON_VERSION);
+}
diff --git a/wmgeneral/list.c b/wmgeneral/list.c
deleted file mode 100644
index f804b2c..0000000
--- a/wmgeneral/list.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/* Generic single linked list to keep various information
- Copyright (C) 1993, 1994 Free Software Foundation, Inc.
-
-
-Author: Kresten Krab Thorup
-
-Many modifications by Alfredo K. Kojima
-
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-#include "list.h"
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#include <stdlib.h>
-
-/* Return a cons cell produced from (head . tail) */
-
-INLINE LinkedList*
-list_cons(void* head, LinkedList* tail)
-{
- LinkedList* cell;
-
- cell = (LinkedList*)malloc(sizeof(LinkedList));
- cell->head = head;
- cell->tail = tail;
- return cell;
-}
-
-/* Return the length of a list, list_length(NULL) returns zero */
-
-INLINE int
-list_length(LinkedList* list)
-{
- int i = 0;
- while(list)
- {
- i += 1;
- list = list->tail;
- }
- return i;
-}
-
-/* Return the Nth element of LIST, where N count from zero. If N
- larger than the list length, NULL is returned */
-
-INLINE void*
-list_nth(int index, LinkedList* list)
-{
- while(index-- != 0)
- {
- if(list->tail)
- list = list->tail;
- else
- return 0;
- }
- return list->head;
-}
-
-/* Remove the element at the head by replacing it by its successor */
-
-INLINE void
-list_remove_head(LinkedList** list)
-{
- if (!*list) return;
- if ((*list)->tail)
- {
- LinkedList* tail = (*list)->tail; /* fetch next */
- *(*list) = *tail; /* copy next to list head */
- free(tail); /* free next */
- }
- else /* only one element in list */
- {
- free(*list);
- (*list) = 0;
- }
-}
-
-
-/* Remove the element with `car' set to ELEMENT */
-/*
-INLINE void
-list_remove_elem(LinkedList** list, void* elem)
-{
- while (*list)
- {
- if ((*list)->head == elem)
- list_remove_head(list);
- *list = (*list ? (*list)->tail : NULL);
- }
-}*/
-
-INLINE LinkedList *
-list_remove_elem(LinkedList* list, void* elem)
-{
- LinkedList *tmp;
-
- if (list) {
- if (list->head == elem) {
- tmp = list->tail;
- free(list);
- return tmp;
- }
- list->tail = list_remove_elem(list->tail, elem);
- return list;
- }
- return NULL;
-}
-
-
-/* Return element that has ELEM as car */
-
-INLINE LinkedList*
-list_find(LinkedList* list, void* elem)
-{
- while(list)
- {
- if (list->head == elem)
- return list;
- list = list->tail;
- }
- return NULL;
-}
-
-/* Free list (backwards recursive) */
-
-INLINE void
-list_free(LinkedList* list)
-{
- if(list)
- {
- list_free(list->tail);
- free(list);
- }
-}
-
-/* Map FUNCTION over all elements in LIST */
-
-INLINE void
-list_mapcar(LinkedList* list, void(*function)(void*))
-{
- while(list)
- {
- (*function)(list->head);
- list = list->tail;
- }
-}
diff --git a/wmgeneral/list.h b/wmgeneral/list.h
deleted file mode 100644
index af0f22c..0000000
--- a/wmgeneral/list.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Generic single linked list to keep various information
- Copyright (C) 1993, 1994 Free Software Foundation, Inc.
-
-Author: Kresten Krab Thorup
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-#ifndef __LIST_H_
-#define __LIST_H_
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-# define INLINE inline
-#else
-# define INLINE
-#endif
-
-typedef struct LinkedList {
- void *head;
- struct LinkedList *tail;
-} LinkedList;
-
-INLINE LinkedList* list_cons(void* head, LinkedList* tail);
-
-INLINE int list_length(LinkedList* list);
-
-INLINE void* list_nth(int index, LinkedList* list);
-
-INLINE void list_remove_head(LinkedList** list);
-
-INLINE LinkedList *list_remove_elem(LinkedList* list, void* elem);
-
-INLINE void list_mapcar(LinkedList* list, void(*function)(void*));
-
-INLINE LinkedList*list_find(LinkedList* list, void* elem);
-
-INLINE void list_free(LinkedList* list);
-
-#endif
diff --git a/wmgeneral/misc.c b/wmgeneral/misc.c
deleted file mode 100644
index 34281e2..0000000
--- a/wmgeneral/misc.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/* dock.c- built-in Dock module for WindowMaker
- *
- * WindowMaker window manager
- *
- * Copyright (c) 1997 Alfredo K. Kojima
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include "list.h"
-#include "misc.h"
-
-/*
- *----------------------------------------------------------------------
- * parse_command--
- * Divides a command line into a argv/argc pair.
- *----------------------------------------------------------------------
- */
-#define PRC_ALPHA 0
-#define PRC_BLANK 1
-#define PRC_ESCAPE 2
-#define PRC_DQUOTE 3
-#define PRC_EOS 4
-#define PRC_SQUOTE 5
-
-typedef struct {
- short nstate;
- short output;
-} DFA;
-
-
-static DFA mtable[9][6] = {
- {{3,1},{0,0},{4,0},{1,0},{8,0},{6,0}},
- {{1,1},{1,1},{2,0},{3,0},{5,0},{1,1}},
- {{1,1},{1,1},{1,1},{1,1},{5,0},{1,1}},
- {{3,1},{5,0},{4,0},{1,0},{5,0},{6,0}},
- {{3,1},{3,1},{3,1},{3,1},{5,0},{3,1}},
- {{-1,-1},{0,0},{0,0},{0,0},{0,0},{0,0}}, /* final state */
- {{6,1},{6,1},{7,0},{6,1},{5,0},{3,0}},
- {{6,1},{6,1},{6,1},{6,1},{5,0},{6,1}},
- {{-1,-1},{0,0},{0,0},{0,0},{0,0},{0,0}}, /* final state */
-};
-
-char*
-next_token(char *word, char **next)
-{
- char *ptr;
- char *ret, *t;
- int state, ctype;
-
- t = ret = malloc(strlen(word)+1);
- ptr = word;
-
- state = 0;
- *t = 0;
- while (1) {
- if (*ptr==0)
- ctype = PRC_EOS;
- else if (*ptr=='\\')
- ctype = PRC_ESCAPE;
- else if (*ptr=='"')
- ctype = PRC_DQUOTE;
- else if (*ptr=='\'')
- ctype = PRC_SQUOTE;
- else if (*ptr==' ' || *ptr=='\t')
- ctype = PRC_BLANK;
- else
- ctype = PRC_ALPHA;
-
- if (mtable[state][ctype].output) {
- *t = *ptr; t++;
- *t = 0;
- }
- state = mtable[state][ctype].nstate;
- ptr++;
- if (mtable[state][0].output<0) {
- break;
- }
- }
-
- if (*ret==0)
- t = NULL;
- else
- t = strdup(ret);
-
- free(ret);
-
- if (ctype==PRC_EOS)
- *next = NULL;
- else
- *next = ptr;
-
- return t;
-}
-
-
-extern void
-parse_command(char *command, char ***argv, int *argc)
-{
- LinkedList *list = NULL;
- char *token, *line;
- int count, i;
-
- line = command;
- do {
- token = next_token(line, &line);
- if (token) {
- list = list_cons(token, list);
- }
- } while (token!=NULL && line!=NULL);
-
- count = list_length(list);
- *argv = malloc(sizeof(char*)*count);
- i = count;
- while (list!=NULL) {
- (*argv)[--i] = list->head;
- list_remove_head(&list);
- }
- *argc = count;
-}
-
-extern pid_t
-execCommand(char *command)
-{
- pid_t pid;
- char **argv;
- int argc;
-
- parse_command(command, &argv, &argc);
-
- if (argv==NULL) {
- return 0;
- }
-
- if ((pid=fork())==0) {
- char **args;
- int i;
-
- args = malloc(sizeof(char*)*(argc+1));
- if (!args)
- exit(10);
- for (i=0; i<argc; i++) {
- args[i] = argv[i];
- }
- args[argc] = NULL;
- execvp(argv[0], args);
- exit(10);
- }
- return pid;
-}
diff --git a/wmgeneral/misc.h b/wmgeneral/misc.h
deleted file mode 100644
index 602e1b7..0000000
--- a/wmgeneral/misc.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __MISC_H
-#define __MISC_H
-
-#include <unistd.h>
-
-extern void parse_command(char *, char ***, int *);
-
-extern pid_t execCommand(char *);
-#endif /* __MISC_H */
diff --git a/wmgeneral/wmgeneral.c b/wmgeneral/wmgeneral.c
deleted file mode 100644
index 56b7bd6..0000000
--- a/wmgeneral/wmgeneral.c
+++ /dev/null
@@ -1,481 +0,0 @@
-/*
- Best viewed with vim5, using ts=4
-
- wmgeneral was taken from wmppp.
-
- It has a lot of routines which most of the wm* programs use.
-
- ------------------------------------------------------------
-
- Author: Martijn Pieterse (pieterse at xs4all.nl)
-
- ---
- CHANGES:
- ---
- 14/09/1998 (Dave Clark, clarkd at skyia.com)
- * Updated createXBMfromXPM routine
- * Now supports >256 colors
- 11/09/1998 (Martijn Pieterse, pieterse at xs4all.nl)
- * Removed a bug from parse_rcfile. You could
- not use "start" in a command if a label was
- also start.
- * Changed the needed geometry string.
- We don't use window size, and don't support
- negative positions.
- 03/09/1998 (Martijn Pieterse, pieterse at xs4all.nl)
- * Added parse_rcfile2
- 02/09/1998 (Martijn Pieterse, pieterse at xs4all.nl)
- * Added -geometry support (untested)
- 28/08/1998 (Martijn Pieterse, pieterse at xs4all.nl)
- * Added createXBMfromXPM routine
- * Saves a lot of work with changing xpm's.
- 02/05/1998 (Martijn Pieterse, pieterse at xs4all.nl)
- * changed the read_rc_file to parse_rcfile, as suggested by Marcelo E. Magallon
- * debugged the parse_rc file.
- 30/04/1998 (Martijn Pieterse, pieterse at xs4all.nl)
- * Ripped similar code from all the wm* programs,
- and put them in a single file.
-
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <stdarg.h>
-
-#include <X11/Xlib.h>
-#include <X11/xpm.h>
-#include <X11/extensions/shape.h>
-
-#include "wmgeneral.h"
-
- /*****************/
- /* X11 Variables */
-/*****************/
-
-Window Root;
-int screen;
-int x_fd;
-int d_depth;
-XSizeHints mysizehints;
-XWMHints mywmhints;
-Pixel back_pix, fore_pix;
-char *Geometry = "";
-Window iconwin, win;
-GC NormalGC;
-XpmIcon wmgen;
-Pixmap pixmask;
-
- /*****************/
- /* Mouse Regions */
-/*****************/
-
-typedef struct {
- int enable;
- int top;
- int bottom;
- int left;
- int right;
-} MOUSE_REGION;
-
-MOUSE_REGION mouse_region[MAX_MOUSE_REGION];
-
- /***********************/
- /* Function Prototypes */
-/***********************/
-
-static void GetXPM(XpmIcon *, char **);
-static Pixel GetColor(char *);
-void RedrawWindow(void);
-void AddMouseRegion(int, int, int, int, int);
-int CheckMouseRegion(int, int);
-
-/*******************************************************************************\
-|* parse_rcfile *|
-\*******************************************************************************/
-
-void parse_rcfile(const char *filename, rckeys *keys) {
-
- char *p,*q;
- char temp[128];
- char *tokens = " :\t\n";
- FILE *fp;
- int i,key;
-
- fp = fopen(filename, "r");
- if (fp) {
- while (fgets(temp, 128, fp)) {
- key = 0;
- q = strdup(temp);
- q = strtok(q, tokens);
- while (key >= 0 && keys[key].label) {
- if ((!strcmp(q, keys[key].label))) {
- p = strstr(temp, keys[key].label);
- p += strlen(keys[key].label);
- p += strspn(p, tokens);
- if ((i = strcspn(p, "#\n"))) p[i] = 0;
- free(*keys[key].var);
- *keys[key].var = strdup(p);
- key = -1;
- } else key++;
- }
- free(q);
- }
- fclose(fp);
- }
-}
-
-/*******************************************************************************\
-|* parse_rcfile2 *|
-\*******************************************************************************/
-
-void parse_rcfile2(const char *filename, rckeys2 *keys) {
-
- char *p;
- char temp[128];
- char *tokens = " :\t\n";
- FILE *fp;
- int i,key;
- char *family = NULL;
-
- fp = fopen(filename, "r");
- if (fp) {
- while (fgets(temp, 128, fp)) {
- key = 0;
- while (key >= 0 && keys[key].label) {
- if ((p = strstr(temp, keys[key].label))) {
- p += strlen(keys[key].label);
- p += strspn(p, tokens);
- if ((i = strcspn(p, "#\n"))) p[i] = 0;
- free(*keys[key].var);
- *keys[key].var = strdup(p);
- key = -1;
- } else key++;
- }
- }
- fclose(fp);
- }
- free(family);
-}
-
-
-/*******************************************************************************\
-|* GetXPM *|
-\*******************************************************************************/
-
-static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) {
-
- XWindowAttributes attributes;
- int err;
-
- /* For the colormap */
- XGetWindowAttributes(display, Root, &attributes);
-
- wmgen->attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
-
- err = XpmCreatePixmapFromData(display, Root, pixmap_bytes, &(wmgen->pixmap),
- &(wmgen->mask), &(wmgen->attributes));
-
- if (err != XpmSuccess) {
- fprintf(stderr, "Not enough free colorcells.\n");
- exit(1);
- }
-}
-
-/*******************************************************************************\
-|* GetColor *|
-\*******************************************************************************/
-
-static Pixel GetColor(char *name) {
-
- XColor color;
- XWindowAttributes attributes;
-
- XGetWindowAttributes(display, Root, &attributes);
-
- color.pixel = 0;
- if (!XParseColor(display, attributes.colormap, name, &color)) {
- fprintf(stderr, "wm.app: can't parse %s.\n", name);
- } else if (!XAllocColor(display, attributes.colormap, &color)) {
- fprintf(stderr, "wm.app: can't allocate %s.\n", name);
- }
- return color.pixel;
-}
-
-/*******************************************************************************\
-|* flush_expose *|
-\*******************************************************************************/
-
-static int flush_expose(Window w) {
-
- XEvent dummy;
- int i=0;
-
- while (XCheckTypedWindowEvent(display, w, Expose, &dummy))
- i++;
-
- return i;
-}
-
-/*******************************************************************************\
-|* RedrawWindow *|
-\*******************************************************************************/
-
-void RedrawWindow(void) {
-
- flush_expose(iconwin);
- XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
- 0,0, wmgen.attributes.width, wmgen.attributes.height, 0,0);
- flush_expose(win);
- XCopyArea(display, wmgen.pixmap, win, NormalGC,
- 0,0, wmgen.attributes.width, wmgen.attributes.height, 0,0);
-}
-
-/*******************************************************************************\
-|* RedrawWindowXY *|
-\*******************************************************************************/
-
-void RedrawWindowXY(int x, int y) {
-
- flush_expose(iconwin);
- XCopyArea(display, wmgen.pixmap, iconwin, NormalGC,
- x,y, wmgen.attributes.width, wmgen.attributes.height, 0,0);
- flush_expose(win);
- XCopyArea(display, wmgen.pixmap, win, NormalGC,
- x,y, wmgen.attributes.width, wmgen.attributes.height, 0,0);
-}
-
-/*******************************************************************************\
-|* AddMouseRegion *|
-\*******************************************************************************/
-
-void AddMouseRegion(int index, int left, int top, int right, int bottom) {
-
- if (index < MAX_MOUSE_REGION) {
- mouse_region[index].enable = 1;
- mouse_region[index].top = top;
- mouse_region[index].left = left;
- mouse_region[index].bottom = bottom;
- mouse_region[index].right = right;
- }
-}
-
-/*******************************************************************************\
-|* CheckMouseRegion *|
-\*******************************************************************************/
-
-int CheckMouseRegion(int x, int y) {
-
- int i;
- int found;
-
- found = 0;
-
- for (i=0; i<MAX_MOUSE_REGION && !found; i++) {
- if (mouse_region[i].enable &&
- x <= mouse_region[i].right &&
- x >= mouse_region[i].left &&
- y <= mouse_region[i].bottom &&
- y >= mouse_region[i].top)
- found = 1;
- }
- if (!found) return -1;
- return (i-1);
-}
-
-/*******************************************************************************\
-|* createXBMfromXPM *|
-\*******************************************************************************/
-void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) {
-
- int i,j,k;
- int width, height, numcol, depth;
- int zero=0;
- unsigned char bwrite;
- int bcount;
- int curpixel;
-
- sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth);
-
-
- for (k=0; k!=depth; k++)
- {
- zero <<=8;
- zero |= xpm[1][k];
- }
-
- for (i=numcol+1; i < numcol+sy+1; i++) {
- bcount = 0;
- bwrite = 0;
- for (j=0; j<sx*depth; j+=depth) {
- bwrite >>= 1;
-
- curpixel=0;
- for (k=0; k!=depth; k++)
- {
- curpixel <<=8;
- curpixel |= xpm[i][j+k];
- }
-
- if ( curpixel != zero ) {
- bwrite += 128;
- }
- bcount++;
- if (bcount == 8) {
- *xbm = bwrite;
- xbm++;
- bcount = 0;
- bwrite = 0;
- }
- }
- }
-}
-
-/*******************************************************************************\
-|* copyXPMArea *|
-\*******************************************************************************/
-
-void copyXPMArea(int x, int y, int sx, int sy, int dx, int dy) {
-
- XCopyArea(display, wmgen.pixmap, wmgen.pixmap, NormalGC, x, y, sx, sy, dx, dy);
-
-}
-
-/*******************************************************************************\
-|* copyXBMArea *|
-\*******************************************************************************/
-
-void copyXBMArea(int x, int y, int sx, int sy, int dx, int dy) {
-
- XCopyArea(display, wmgen.mask, wmgen.pixmap, NormalGC, x, y, sx, sy, dx, dy);
-}
-
-
-/*******************************************************************************\
-|* setMaskXY *|
-\*******************************************************************************/
-
-void setMaskXY(int x, int y) {
-
- XShapeCombineMask(display, win, ShapeBounding, x, y, pixmask, ShapeSet);
- XShapeCombineMask(display, iconwin, ShapeBounding, x, y, pixmask, ShapeSet);
-}
-
-/*******************************************************************************\
-|* openXwindow *|
-\*******************************************************************************/
-void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, int pixmask_width, int pixmask_height) {
-
- unsigned int borderwidth = 1;
- XClassHint classHint;
- char *display_name = NULL;
- char *wname = argv[0];
- XTextProperty name;
-
- XGCValues gcv;
- unsigned long gcm;
-
- char *geometry = NULL;
-
- int dummy=0;
- int i, wx, wy;
-
- for (i=1; argv[i]; i++) {
- if (!strcmp(argv[i], "-display")) {
- display_name = argv[i+1];
- i++;
- }
- if (!strcmp(argv[i], "-geometry")) {
- geometry = argv[i+1];
- i++;
- }
- }
-
- if (!(display = XOpenDisplay(display_name))) {
- fprintf(stderr, "%s: can't open display %s\n",
- wname, XDisplayName(display_name));
- exit(1);
- }
- screen = DefaultScreen(display);
- Root = RootWindow(display, screen);
- d_depth = DefaultDepth(display, screen);
- x_fd = XConnectionNumber(display);
-
- /* Convert XPM to XImage */
- GetXPM(&wmgen, pixmap_bytes);
-
- /* Create a window to hold the stuff */
- mysizehints.flags = USSize | USPosition;
- mysizehints.x = 0;
- mysizehints.y = 0;
-
- back_pix = GetColor("white");
- fore_pix = GetColor("black");
-
- XWMGeometry(display, screen, Geometry, NULL, borderwidth, &mysizehints,
- &mysizehints.x, &mysizehints.y,&mysizehints.width,&mysizehints.height, &dummy);
-
- mysizehints.width = 64;
- mysizehints.height = 64;
-
- win = XCreateSimpleWindow(display, Root, mysizehints.x, mysizehints.y,
- mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
-
- iconwin = XCreateSimpleWindow(display, win, mysizehints.x, mysizehints.y,
- mysizehints.width, mysizehints.height, borderwidth, fore_pix, back_pix);
-
- /* Activate hints */
- XSetWMNormalHints(display, win, &mysizehints);
- classHint.res_name = wname;
- classHint.res_class = wname;
- XSetClassHint(display, win, &classHint);
-
- XSelectInput(display, win, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
- XSelectInput(display, iconwin, ButtonPressMask | ExposureMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
-
- if (XStringListToTextProperty(&wname, 1, &name) == 0) {
- fprintf(stderr, "%s: can't allocate window name\n", wname);
- exit(1);
- }
-
- XSetWMName(display, win, &name);
-
- /* Create GC for drawing */
-
- gcm = GCForeground | GCBackground | GCGraphicsExposures;
- gcv.foreground = fore_pix;
- gcv.background = back_pix;
- gcv.graphics_exposures = 0;
- NormalGC = XCreateGC(display, Root, gcm, &gcv);
-
- /* ONLYSHAPE ON */
-
- pixmask = XCreateBitmapFromData(display, win, pixmask_bits, pixmask_width, pixmask_height);
-
- XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
- XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
-
- /* ONLYSHAPE OFF */
-
- mywmhints.initial_state = WithdrawnState;
- mywmhints.icon_window = iconwin;
- mywmhints.icon_x = mysizehints.x;
- mywmhints.icon_y = mysizehints.y;
- mywmhints.window_group = win;
- mywmhints.flags = StateHint | IconWindowHint | IconPositionHint | WindowGroupHint;
-
- XSetWMHints(display, win, &mywmhints);
-
- XSetCommand(display, win, argv, argc);
- XMapWindow(display, win);
-
- if (geometry) {
- if (sscanf(geometry, "+%d+%d", &wx, &wy) != 2) {
- fprintf(stderr, "Bad geometry string.\n");
- exit(1);
- }
- XMoveWindow(display, win, wx, wy);
- }
-}
diff --git a/wmsysmon/Makefile b/wmsysmon/Makefile
deleted file mode 100644
index ee33c3c..0000000
--- a/wmsysmon/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-LIBDIR = -L/usr/X11R6/lib
-LIBS = -lXpm -lXext -lX11 -lm
-FLAGS = -O2
-OBJS = wmsysmon.o \
- ../wmgeneral/wmgeneral.o \
- ../wmgeneral/misc.o \
- ../wmgeneral/list.o
-
-.c.o:
- cc -I/usr/X11R6/share/include $(FLAGS) -c -Wall $< -o $*.o
-
-wmsysmon: $(OBJS)
- cc $(FLAGS) -o wmsysmon $^ -lXext $(LIBDIR) $(LIBS)
-
-all:: wmsysmon
-
-clean::
- for i in $(OBJS) ; do \
- rm -f $$i ; \
- done
- rm -f wmsysmon
- rm -f *~
-
-install:: wmsysmon
- cp -f wmsysmon /usr/local/bin/
- chmod 755 /usr/local/bin/wmsysmon
- chown root:root /usr/local/bin/wmsysmon
- @echo "wmsysmon Installation finished..."
diff --git a/wmsysmon/wmsysmon.c b/wmsysmon/wmsysmon.c
deleted file mode 100644
index 88ad097..0000000
--- a/wmsysmon/wmsysmon.c
+++ /dev/null
@@ -1,742 +0,0 @@
-/*
-
- wmsysmon.c -- system monitor thing.
-
- by Dave Clark (clarkd at skynet.ca) (http://www.neotokyo.org/illusion)
-
- This software is licensed through the GNU General Public License.
-
-*/
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <math.h>
-
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-
-#include <X11/Xlib.h>
-#include <X11/xpm.h>
-#include <X11/extensions/shape.h>
-
-#include "../wmgeneral/wmgeneral.h"
-#include "../wmgeneral/misc.h"
-
-#include "wmsysmon-master.xpm"
-char wmsysmon_mask_bits[64*64];
-int wmsysmon_mask_width = 64;
-int wmsysmon_mask_height = 64;
-
-long start_time=0;
-long start_uptime=0;
-
-long io_max;
-long io_max_diff;
-
-#define WMSYSMON_VERSION "0.2"
-
-#define CHAR_WIDTH 5
-#define CHAR_HEIGHT 7
-
-#define BCHAR_WIDTH 6
-#define BCHAR_HEIGHT 9
-
-#define BOFFX (93)
-#define BOFFY (66)
-#define BREDX (81)
-#define BREDY (66)
-#define BGREENX (87)
-#define BGREENY (66)
-
-#define LITEW (4)
-#define LITEH (4)
-
-#define B_OFF (0)
-#define B_RED (1)
-#define B_GREEN (2)
-
-
-long last_ints[16];
-long ints[16];
-
-long last_pageins=0;
-long last_pageouts=0;
-
-long last_swapins=0;
-long last_swapouts=0;
-
-int update_rate=200000;
-
-extern char **environ;
-
-char *ProgName;
-
-char uconfig_file[256];
-
-time_t curtime;
-time_t prevtime;
-
-void usage(void);
-void printversion(void);
-void BlitString(char *name, int x, int y);
-void BlitNum(int num, int x, int y);
-void wmsysmon_routine(int, char **);
-int ReadConfigInt(FILE *fp, char *setting, int *value);
-int ReadConfigString(FILE *fp, char *setting, char *value);
-int Read_Config_File( char *filename );
-void DrawBar(int sx, int sy, int w, int h, float percent, int dx, int dy);
-void DrawLite(int state, int dx, int dy);
-void DrawUptime(void);
-void DrawStuff( void );
-void DrawMem( void );
-
-int main(int argc, char *argv[]) {
-
- int i;
-
- uconfig_file[0] = 0;
-
- /* Parse Command Line */
-
- ProgName = argv[0];
- if (strlen(ProgName) >= 5)
- ProgName += (strlen(ProgName) - 5);
-
- for (i=1; i<argc; i++) {
- char *arg = argv[i];
-
- if (*arg=='-') {
- switch (arg[1]) {
- case 'd' :
- if (strcmp(arg+1, "display")) {
- usage();
- exit(1);
- }
- break;
- case 'g' :
- if (strcmp(arg+1, "geometry")) {
- usage();
- exit(1);
- }
- break;
- case 'v' :
- printversion();
- exit(0);
- break;
- case 'r':
- if (argc > (i+1))
- {
- update_rate = (atoi(argv[i+1]) * 1000);
- i++;
- }
- break;
- case 'c' :
- if (argc > (i+1))
- {
- strcpy(uconfig_file, argv[i+1]);
- i++;
- }
- break;
- default:
- usage();
- exit(0);
- break;
- }
- }
- }
-
- wmsysmon_routine(argc, argv);
-
- return 0;
-}
-
-/*******************************************************************************\
- |* wmsysmon_routine *|
-\*******************************************************************************/
-
-void wmsysmon_routine(int argc, char **argv)
-{
- int i;
- XEvent Event;
- int but_stat = -1;
- FILE *fp;
- struct timeval tv={0,0};
- struct timeval last={0,0};
-
-
-// char config_file[512];
-
- createXBMfromXPM(wmsysmon_mask_bits, wmsysmon_master_xpm, wmsysmon_mask_width, wmsysmon_mask_height);
-
- openXwindow(argc, argv, wmsysmon_master_xpm, wmsysmon_mask_bits, wmsysmon_mask_width, wmsysmon_mask_height);
-
-// AddMouseRegion(0, 5, 6, 58, 16);
-
- // We don't need a config file (yet)...
-#if 0
- // Read config file
-
- if (uconfig_file[0] != 0)
- {
- // user-specified config file
- fprintf(stderr, "Using user-specified config file '%s'.\n", uconfig_file);
- Read_Config_File(uconfig_file);
- }
- else
- {
- sprintf(config_file, "%s/.wmsysmonrc", getenv("HOME"));
-
- if (!Read_Config_File(config_file))
- {
- // Fall back to /etc/wminetrc
- sprintf(config_file, "/etc/wmsysmonrc");
-
- Read_Config_File(config_file);
- }
- }
-#endif
-
- // init ints
- bzero(&last_ints, sizeof(last_ints));
- bzero(&ints, sizeof(ints));
-
-
-
- // init uptime
- fp = fopen("/proc/uptime", "r");
- if (fp)
- {
- fscanf(fp, "%ld", &start_time);
- fclose(fp);
- start_uptime = time(0);
- }
-
- RedrawWindow();
-
-
- while (1)
- {
-
- curtime = time(0);
-
- if (1)
- {
- memcpy(&last, &tv, sizeof(tv));
-
- // Update display
-
- DrawUptime();
-
- DrawStuff();
-
- DrawMem();
-
- RedrawWindow();
- }
-
- // X Events
- while (XPending(display))
- {
- XNextEvent(display, &Event);
- switch (Event.type)
- {
- case Expose:
- RedrawWindow();
- break;
- case DestroyNotify:
- XCloseDisplay(display);
- exit(0);
- break;
- case ButtonPress:
- i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
-
- but_stat = i;
- break;
- case ButtonRelease:
- i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
-
- if (but_stat == i && but_stat >= 0)
- {
- switch (but_stat)
- {
- case 0 :
- break;
- case 1 :
- break;
- case 2:
- break;
- case 3:
- break;
- case 4:
- break;
-
- }
- }
- but_stat = -1;
-// RedrawWindow();
- break;
- }
- }
-
- usleep(update_rate);
- }
-}
-
-void DrawBar(int sx, int sy, int w, int h, float percent, int dx, int dy)
-{
- int tx;
-
- 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);
-
-
-}
-
-void DrawLite(int state, int dx, int dy)
-{
- switch(state)
- {
- case B_RED:
- copyXPMArea(BREDX, BREDY, LITEW, LITEH, dx, dy);
- break;
- case B_GREEN:
- copyXPMArea(BGREENX, BGREENY, LITEW, LITEH, dx, dy);
- break;
- default:
- case B_OFF:
- copyXPMArea(BOFFX, BOFFY, LITEW, LITEH, dx, dy);
- break;
- }
-}
-
-
-void DrawUptime(void)
-{
- long uptime;
- char buf[32];
- int i;
-
- uptime = curtime - start_uptime + start_time;
-
- uptime /=60;
- // blit minutes
- i = uptime % 60;
- uptime /=60;
- sprintf(buf, "%02i", i);
- BlitString(buf, 45, 37);
-
- // blit hours
- i = uptime % 24;
- uptime /=24;
- sprintf(buf, "%02i", i);
- BlitString(buf, 29, 37);
-
- // blit days
- i = uptime;
- sprintf(buf, "%03i", i);
- BlitString(buf, 6, 37);
-}
-
-
-void DrawStuff( void )
-{
- FILE *fp;
- char buf[1024];
- char *tok;
- char seps[]={" "};
- int i;
-
- long io=0;
- long iodiff=0;
- int iopercent=0;
-
- long pageins=0;
- long pageouts=0;
- long swapins=0;
- long swapouts=0;
-
- fp = fopen("/proc/stat", "r");
-
- if (!fp)
- return;
-
- //gather data...
- while( fgets(buf, 127, fp) )
- {
- if (strstr(buf, "disk_rio"))
- {
- tok = strtok(buf, seps);
- for(i=0; i<4; i++)
- {
- io += atoi(tok);
- tok = strtok(NULL, seps);
- }
- }
-
- if (strstr(buf, "disk_wio"))
- {
- tok = strtok(buf, seps);
- for(i=0; i<4; i++)
- {
- io += atoi(tok);
- tok = strtok(NULL, seps);
- }
- }
-
- if (strstr(buf, "intr"))
- {
- sscanf(buf, "intr %*d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld",
- &ints[0], &ints[1], &ints[2], &ints[3], &ints[4], &ints[5], &ints[6], &ints[7],
- &ints[8], &ints[9], &ints[10], &ints[11], &ints[12], &ints[13], &ints[14], &ints[15]);
- }
-
- if (strstr(buf, "page"))
- {
- sscanf(buf, "page %ld %ld", &pageins, &pageouts);
- }
-
- if (strstr(buf, "swap"))
- {
- sscanf(buf, "swap %ld %ld", &swapins, &swapouts);
- }
- }
-
-
- // ------------------ 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;
-
- if (iodiff > io_max_diff)
- io_max_diff=iodiff;
-
- if (iopercent >100)
- iopercent =100;
-
-// printf("io: %i\n", io);
-// printf("io_max: %i\n", io_max);
-// printf("iodiff: %i\n", iodiff);
-// printf("iopercent: %i\n", iopercent);
-
- DrawBar(67, 36, 58, 6, iopercent, 3, 26);
-
- // -------------- ints --------------------
- // top 8
- for (i=0; i<8; i++)
- {
- if ( ints[i] > last_ints[i] )
- {
- DrawLite(B_GREEN, 4 + (i*LITEW), 51);
- }
- else
- {
- DrawLite(B_OFF, 4 + (i*LITEW), 51);
- }
- }
-
- // bottom 8
- for (i=8; i<16; i++)
- {
- if ( ints[i] > last_ints[i] )
- {
- DrawLite(B_GREEN, 4 + ((i-8)*LITEW), 56);
- }
- else
- {
- DrawLite(B_OFF, 4 + ((i-8)*LITEW), 56);
- }
- }
-
- memcpy(&last_ints, &ints, sizeof(ints));
-
- // ----- page in / out ---------------
-
- if (pageins > last_pageins)
- {
- DrawLite(B_RED, 51, 51);
- }
- else
- {
- DrawLite(B_OFF, 51, 51);
- }
-
- if (pageouts > last_pageouts)
- {
- DrawLite(B_RED, 56, 51);
- }
- else
- {
- DrawLite(B_OFF, 56, 51);
- }
-
- last_pageins = pageins;
- last_pageouts = pageouts;
-
- // --------- swap in/out ------------------
-
- if (swapins > last_swapins)
- {
- DrawLite(B_RED, 51, 56);
- }
- else
- {
- DrawLite(B_OFF, 51, 56);
- }
-
- if (swapouts > last_swapouts)
- {
- DrawLite(B_RED, 56, 56);
- }
- else
- {
- DrawLite(B_OFF, 56, 56);
- }
-
- last_swapins = swapins;
- last_swapouts = swapouts;
-
-
- fclose(fp);
-}
-
-
-void DrawMem( void )
-{
- FILE *fp;
- char buf[128];
- long mem_total=0;
- long mem_used=0;
- long mem_free=0;
- long mem_shared=0;
- long mem_buffers=0;
- long mem_cache=0;
- long swap_total=0;
- long swap_used=0;
- long swap_free=0;
-
- int mempercent=0;
- int swappercent=0;
-
- fp = fopen("/proc/meminfo", "r");
-
- if (!fp)
- return;
-
- while (fgets(buf, 127, fp))
- {
- if (strstr(buf, "Mem:"))
- {
- sscanf(buf, "Mem: %ld %ld %ld %ld %ld %ld", &mem_total, &mem_used, &mem_free, &mem_shared, &mem_buffers, &mem_cache);
- }
-
- if (strstr(buf, "Swap:"))
- {
- sscanf(buf, "Swap: %ld %ld %ld", &swap_total, &swap_used, &swap_free);
- }
- }
-
- mempercent = ((float) (mem_used - mem_buffers - mem_cache) / (float) mem_total) * 100;
-
- swappercent = ((float) (swap_used) / (float) swap_total) * 100;
-
-// printf("mempercent: %i\n", mempercent);
-// printf("swappercent: %i\n", swappercent);
-
- DrawBar(67, 36, 58, 6, mempercent, 3, 4);
- DrawBar(67, 36, 58, 6, swappercent, 3, 15);
-
- fclose(fp);
-}
-
-
-
-
-// Blits a string at given co-ordinates
-void BlitString(char *name, int x, int y)
-{
- int i;
- int c;
- int k;
-
- k = x;
- for (i=0; name[i]; i++)
- {
-
- c = toupper(name[i]);
- if (c >= 'A' && c <= 'Z')
- { // its a letter
- c -= 'A';
- copyXPMArea(c * 6, 74, 6, 8, k, y);
- k += 6;
- }
- else
- { // its a number or symbol
- c -= '0';
- copyXPMArea(c * 6, 64, 6, 8, k, y);
- k += 6;
- }
- }
-
-}
-
-void BlitNum(int num, int x, int y)
-{
- char buf[1024];
- int newx=x;
-
- sprintf(buf, "%03i", num);
-
- BlitString(buf, newx, y);
-}
-
-
-// ReadConfigSetting
-int ReadConfigString(FILE *fp, char *setting, char *value)
-{
- char str[1024];
- char buf[1024];
- int i;
- int len;
- int slen;
- char *p=NULL;
-
-
- if (!fp)
- {
- return 0;
- }
-
- sprintf(str, "%s=", setting);
- slen = strlen(str);
-
- fseek(fp, 0, SEEK_SET);
-
- while ( !feof(fp) )
- {
-
- if (!fgets(buf, 512, fp))
- break;
-
- len = strlen(buf);
-
- // strip linefeed
- for (i=0; i!=len; i++)
- {
- if (buf[i] == '\n')
- {
- buf[i] = 0;
- }
- }
-
- //printf("Scanning '%s'...\n", buf);
- if ( strncmp(buf, str, strlen(str)) == 0)
- {
- // found our setting
-
- for(i=0; i!=slen; i++)
- {
- if ( buf[i] == '=' )
- {
- p=buf+i+1;
- strcpy(value, p);
- return 1;
- }
- }
-
- }
- }
-
- return 0;
-}
-
-int ReadConfigInt(FILE *fp, char *setting, int *value)
-{
- char buf[1024];
-
- if (ReadConfigString(fp, setting, (char *) &buf))
- {
- *value = atoi(buf);
- return 1;
- }
-
- return 0;
-}
-
-int Read_Config_File( char *filename )
-{
- FILE *fp;
-
- fp = fopen(filename, "r");
- if (fp)
- {
-
- fclose(fp);
- return 1;
- }
- else
- {
- perror("Read_Config_File");
- fprintf(stderr, "Unable to open %s, no settings read.\n", filename);
- return 0;
- }
-
-}
-
-
-
-
-
-
-
-/*******************************************************************************\
-|* usage *|
-\*******************************************************************************/
-
-void usage(void)
-{
- fprintf(stderr, "\nWMsysmon - illusion <clarkd at skynet.ca> http://www.neotokyo.org/illusion\n\n");
- fprintf(stderr, "usage:\n");
- fprintf(stderr, " -display <display name>\n");
- fprintf(stderr, " -geometry +XPOS+YPOS initial window position\n");
- fprintf(stderr, " -r update rate in milliseconds (default:200)\n");
-
-// fprintf(stderr, " -c <filename> use specified config file\n");
- fprintf(stderr, " -h this help screen\n");
- fprintf(stderr, " -v print the version number\n");
- fprintf(stderr, "\n");
-}
-
-/*******************************************************************************\
-|* printversion *|
-\*******************************************************************************/
-
-void printversion(void)
-{
- fprintf(stderr, "wmsysmon v%s\n", WMSYSMON_VERSION);
-}
--
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