[Pkg-wmaker-commits] [wmbutton] 06/09: Import Upstream version 0.7.0

Doug Torrance dtorrance-guest at moszumanska.debian.org
Sun Jul 16 03:13:30 UTC 2017


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

dtorrance-guest pushed a commit to branch master
in repository wmbutton.

commit 5410de1d24abef58e3f533f6c192dfce48a71e52
Author: Doug Torrance <dtorrance at piedmont.edu>
Date:   Sat Jul 15 23:12:02 2017 -0400

    Import Upstream version 0.7.0
---
 Makefile                     |   22 +-
 README                       |    4 +-
 .wmbutton => sample.wmbutton |    0
 wmb_libs.c                   | 1251 +++++++++++++++++++++---------------------
 wmbutton.1                   |  115 ++++
 wmbutton.c                   |  906 +++++++++++++++---------------
 wmbutton.h                   |   77 ++-
 7 files changed, 1275 insertions(+), 1100 deletions(-)

diff --git a/Makefile b/Makefile
index b4b744d..1ac7298 100644
--- a/Makefile
+++ b/Makefile
@@ -1,19 +1,24 @@
-INCLUDES =-I/usr/X11R6/include/X11 -I/usr/local/include -I/usr/include/X11R6/X11
+INCLUDES =-I/usr/include -I/usr/local/include
 LIBINC =-L/usr/X11R6/lib -L/usr/include/lib
 LIBS = -lX11 -lXpm -lXext
 
 TARGET = wmbutton
 OBJECTS = wmbutton.o wmb_libs.o
+DESTDIR = /usr/local
+PREFIX = /usr
+BINDIR = /bin
+CONF   = /etc
+CONFFL = ${CONF}/wmbutton.conf
+INSTALL = /usr/bin/install
 
-CFLAGS += -c -Wall -O2
-
-all: ${TARGET} tags
+CFLAGS += -Wall -O2
+LDFLAGS +=
 
 .c.o:
-	gcc ${CFLAGS} ${INCLUDES} $< -o $*.o
+	gcc -c ${CFLAGS} ${INCLUDES} $< -o $*.o
 
 ${TARGET}: ${OBJECTS}
-	gcc -o ${TARGET} ${OBJECTS} ${LIBINC} ${LIBS}
+	gcc -o ${TARGET} ${OBJECTS}  ${LDFLAGS} ${LIBINC} ${LIBS}
 
 clean::
 	for i in ${OBJECTS}; do if [ -e $$i ] ; then rm $$i; fi; done 
@@ -21,6 +26,11 @@ clean::
 	if [ -e tags ]; then rm tags; fi
 	if [ -e core ]; then rm core; fi
 
+install::
+	$(INSTALL) -d -m 0755 ${DESTDIR}${PREFIX}${BINDIR} ${DESTDIR}${CONF}
+	$(INSTALL) -p -o root -g root -m 755 wmbutton ${DESTDIR}${PREFIX}${BINDIR}
+	$(INSTALL) -p -o root -g root -m 644 sample.wmbutton ${DESTDIR}${CONFFL}
+
 wmbutton.o: wmbutton.c wmbutton.h Makefile
 
 wmb_libs.o: wmb_libs.c wmbutton.h Makefile
diff --git a/README b/README
index 5da98ae..fe0cb79 100644
--- a/README
+++ b/README
@@ -52,10 +52,10 @@ helping out, catching bugs in the code, etc.
 INSTALLATION:
 -------------
 	Untar the file: 
-		tar xvzf wmbutton-0.5.tar.gz
+		tar xvzf wmbutton-0.6.1.tar.gz
 
 	CD to source directory:  
-		cd wmbutton-0.5
+		cd wmbutton-0.6.1
 
 	Edit background xpm, and buttons.xpm to your preferences
 	There are icon files in ./icons to work from
diff --git a/.wmbutton b/sample.wmbutton
similarity index 100%
rename from .wmbutton
rename to sample.wmbutton
diff --git a/wmb_libs.c b/wmb_libs.c
index c9ea4c8..55802ff 100644
--- a/wmb_libs.c
+++ b/wmb_libs.c
@@ -1,6 +1,6 @@
 /* wmb_libs.c - Edward H. Flora - ehf_dockapps at cox.net */
 /* Last Modified: 4/3/04 */
-/* 
+/*
  * These functions are designed to work with wmbutton.
  */
 
@@ -9,14 +9,13 @@
 * Coded in ANSI C, using ANSI prototypes.
 */
 
-/******  Include Files  *************************************************/
+/****** Include Files *************************************************/
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include "wmbutton.h"
 
-
-/******  ToolTip Globals  ***********************************************/
+/****** ToolTip Globals ***********************************************/
 
 static struct timeval _tStart;
 
@@ -25,668 +24,698 @@ int _bTooltip = 0;
 XFontStruct* _fTooltip;
 int _nFontHeight, _nFontY;
 int _nScreenWidth, _nScreenHeight;
-GC _gcMono= 0;
+GC _gcMono = 0;
 Window _wTooltip;
 
-/******  Parse Command Line  ********************************************/
-void parseargs(int argc, char **argv) {
-  int current;
-  char *Home = getenv("HOME");
-
-  while (-1 != (current = getopt(argc, argv, "vhnmsF:b:g:d:f:"))) {
-    switch (current) {
-    case 'v': 
-      Config.Verbose = 1;
-      break;
-    case '?':
-    case 'h':
-      show_usage();
-      break;
-    case 'm':
-      Config.mmouse = 1;
-      break;
-    case 'n':
-      Config.bTooltipDisable = 1;
-      break;
-    case 's':
-      Config.bTooltipSwapColors = 1;
-      break;
-    case 'g':
-      Config.Geometry_str = strdup(optarg);
-      break;
-    case 'd':
-      Config.Display_str = strdup(optarg);
-      break;
-    case 'f':
-      Config.configfile = strdup(optarg);
-      break;
-    case 'F':
-      Config.szTooltipFont = strdup(optarg);
-      break;
-    case 'b':
-      Config.buttonfile = strdup(optarg);
-      break;
-    }
-  }
-
-  if (!Config.configfile) {
-    if (Home != NULL) {
-      Config.configfile = malloc(
-          strlen(Home) + strlen(CONFFILENAME) + 1);
-      sprintf(Config.configfile, "%s%s", Home, CONFFILENAME);
-    }
-  }
-
-  if (!Config.buttonfile) {
-    if (Home != NULL) {
-      Config.buttonfile = malloc(
-          strlen(Home) + strlen(BUTTONFILENAME) + 1);
-      sprintf(Config.buttonfile, "%s%s", Home, BUTTONFILENAME);
-    }
-  }
-
-  if (!Config.Geometry_str)
-    Config.Geometry_str = "64x64+0+0";
-
-  if (!Config.Display_str)
-    Config.Display_str = "";
-
-  if (!Config.szTooltipFont)
-    Config.szTooltipFont = TOOLTIP_FONT;
-
-  if (!Config.bTooltipDisable)
-    Config.bTooltipDisable = !TOOLTIP_SUPPORT;
+/****** Parse Command Line ********************************************/
+void parseargs(int argc, char **argv)
+{
+	int current;
+	char *Home = getenv("HOME");
+
+	while (-1 != (current = getopt(argc, argv, "vhnmsF:b:g:d:f:"))) {
+		switch (current) {
+		case 'v':
+			Config.Verbose = 1;
+			break;
+		case '?':
+		case 'h':
+			show_usage();
+			break;
+		case 'm':
+			Config.mmouse = 1;
+			break;
+		case 'n':
+			Config.bTooltipDisable = 1;
+			break;
+		case 's':
+			Config.bTooltipSwapColors = 1;
+			break;
+		case 'g':
+			Config.Geometry_str = strdup(optarg);
+			break;
+		case 'd':
+			Config.Display_str = strdup(optarg);
+			break;
+		case 'f':
+			Config.configfile = strdup(optarg);
+			break;
+		case 'F':
+			Config.szTooltipFont = strdup(optarg);
+			break;
+		case 'b':
+			Config.buttonfile = strdup(optarg);
+			break;
+		}
+	}
+
+	if (!Config.configfile) {
+		if (Home != NULL) {
+			Config.configfile = malloc(strlen(Home) +
+						   strlen(CONFFILENAME) + 1);
+			sprintf(Config.configfile, "%s%s", Home, CONFFILENAME);
+		}
+	}
+
+	if (!Config.buttonfile) {
+		if (Home != NULL) {
+			Config.buttonfile = malloc(strlen(Home) +
+						   strlen(BUTTONFILENAME) + 1);
+			sprintf(Config.buttonfile, "%s%s", Home, BUTTONFILENAME);
+		}
+	}
+
+	if (!Config.Geometry_str)
+		Config.Geometry_str = "64x64+0+0";
+
+	if (!Config.Display_str)
+		Config.Display_str = "";
+
+	if (!Config.szTooltipFont)
+		Config.szTooltipFont = TOOLTIP_FONT;
+
+	if (!Config.bTooltipDisable)
+		Config.bTooltipDisable = !TOOLTIP_SUPPORT;
 
 }
 
-/******  Show Usage Information  ****************************************/
-void show_usage() {
-  extern char *app_name;
-
-  fprintf(stderr,"\n");
-  fprintf(stderr,"usage: %s [-g geom] [-d dpy] [-f cfgfile] [-b btnfile] "\
-	  "[-F <font>] [-v] [-s] [-n]\n",app_name);
-  fprintf(stderr,"\n");
-  fprintf(stderr," wmbutton Ver %d Rel %d\n",VER,REL);
-  fprintf(stderr,"\n");
-  fprintf(stderr,"-g <geometry>  Window Geometry - ie: 64x64+10+10\n");
-  fprintf(stderr,"-d <display>   Display -  ie: 127.0.0.1:0.0\n"); 
-  fprintf(stderr,"-f <filename>  Full path to configuration file.\n");
-  fprintf(stderr,"-b <filename>  Full path to button xpm.\n");
-  fprintf(stderr,"-F <font>      Custom tooltip font (e.g. -b\\&h-lucidatypewriter-medium-*-*-*-12-*)\n");
-  fprintf(stderr,"-v             Verbose Mode.\n");
-  fprintf(stderr,"-h             Help. This message.\n");
-#if MIDMOUSE
-  fprintf(stderr,"-m             Disable Middle Mouse functionality.\n");
-#else
-  fprintf(stderr,"-m             Enable Middle Mouse functionality.\n");
-#endif
-  fprintf(stderr,"-s             Swap tooltip colors.\n");
-  fprintf(stderr,"-n             Turn off tooltips.\n");
-  fprintf(stderr,"\n");
-  exit(0);
-}/***********************************************************************/
-
-
-/******  Error Handler Routine  *****************************************/
-void err_mess(int err, char *str) {
-
-  switch (err) {
-  case FAILDISP:
-    fprintf(stderr,"Fail: XOpenDisplay for %s\n", str);	
-    exit(err);
-  case FAILSWIN:
-    fprintf(stderr,"Fail: XCreateSimpleWindow\n");	
-    exit(err);
-  case FAILICON: 
-    fprintf(stderr,"Fail: XCreateSimpleWindow\n");	
-    exit(err);
-  case FAILXPM:
-    fprintf(stderr,"Fail: XCreateBitmapFromData\n");
-    break;
-  case FAILWNAM:
-    fprintf(stderr,"%s: Can't set up window name\n", str);
-    exit(err);
-  case FAILGC:
-    fprintf(stderr,"Fail: XCreateGC\n");	
-    exit(err);
-  case FAILCONF:
-    fprintf(stderr, "Fail: Can't Find configuration file %s\n",str);
-    exit(err);
-  case FAILTMPL:
-    fprintf(stderr, "Fail: Can't Create 'template' Pixmap\n");
-    exit(err);
-  case FAILVIS:
-    fprintf(stderr, "Fail: Can't Create 'visible' Pixmap\n");
-    exit(err);
-  case FAILBUT:
-    fprintf(stderr, "Fail: Can't Create 'buttons' Pixmap\n");
-    exit(err);
-  default:
-    fprintf(stderr, "Fail:  UnSpecified Error: %d\n",err);
-    fprintf(stderr, "Fail:  %s\n",str);
-    exit(err);
-  }
-
-}/***********************************************************************/
+/****** Show Usage Information ****************************************/
+void show_usage(void)
+{
+	extern char *app_name;
+
+	fprintf(stderr, "\n");
+	fprintf(stderr, "usage: %s [-g geom] [-d dpy] [-f cfgfile] [-b btnfile] "\
+		"[-F <font>] [-v] [-s] [-n]\n",app_name);
+	fprintf(stderr, "\n");
+	fprintf(stderr, " wmbutton version %s\n", VER_STR);
+	fprintf(stderr, "\n");
+	fprintf(stderr, "-g <geometry>  Window Geometry - ie: 64x64+10+10\n");
+	fprintf(stderr, "-d <display>   Display - ie: 127.0.0.1:0.0\n");
+	fprintf(stderr, "-f <filename>  Full path to configuration file.\n");
+	fprintf(stderr, "-b <filename>  Full path to button xpm.\n");
+	fprintf(stderr, "-F <font>      Custom tooltip font (e.g. -b\\&h-lucidatypewriter-medium-*-*-*-12-*)\n");
+	fprintf(stderr, "-v             Verbose Mode.\n");
+	fprintf(stderr, "-h             Help. This message.\n");
+	fprintf(stderr, "-m             Disable Middle Mouse functionality.\n");
+	fprintf(stderr, "-s             Swap tooltip colors.\n");
+	fprintf(stderr, "-n             Turn off tooltips.\n");
+	fprintf(stderr, "\n");
+	exit(0);
+}
+/***********************************************************************/
+
+/****** Error Handler Routine *****************************************/
+void err_mess(int err, char *str)
+{
+	switch (err) {
+	case FAILDISP:
+		fprintf(stderr, "Fail: XOpenDisplay for %s\n", str);
+		exit(err);
+	case FAILSWIN:
+		fprintf(stderr, "Fail: XCreateSimpleWindow\n");
+		exit(err);
+	case FAILICON:
+		fprintf(stderr, "Fail: XCreateSimpleWindow\n");
+		exit(err);
+	case FAILXPM:
+		fprintf(stderr, "Fail: XCreateBitmapFromData\n");
+		break;
+	case FAILWNAM:
+		fprintf(stderr, "%s: Can't set up window name\n", str);
+		exit(err);
+	case FAILGC:
+		fprintf(stderr, "Fail: XCreateGC\n");
+		exit(err);
+	case FAILCONF:
+		fprintf(stderr, "Fail: Can't Find user or system configuration file.\n");
+		fprintf(stderr, "Fail: User Config: '%s'\n", str);
+		fprintf(stderr, "Fail: System Config: '%s'\n", CONFIGGLOBAL);
+		exit(err);
+	case FAILTMPL:
+		fprintf(stderr, "Fail: Can't Create 'template' Pixmap\n");
+		exit(err);
+	case FAILVIS:
+		fprintf(stderr, "Fail: Can't Create 'visible' Pixmap\n");
+		exit(err);
+	case FAILBUT:
+		fprintf(stderr, "Fail: Can't Create 'buttons' Pixmap\n");
+		exit(err);
+	default:
+		fprintf(stderr, "Fail: UnSpecified Error: %d\n", err);
+		fprintf(stderr, "Fail: %s\n", str);
+		exit(err);
+	}
+}
+/***********************************************************************/
 
 /***********************************************************************
  * RunAppN(int app)
  *
  * Run the command given in the configuration file 'configfile'
  ***********************************************************************/
-void RunAppN( int app ) {
-  char *cmndstr;
-  extern struct Config_t Config;
+void RunAppN(int app)
+{
+	char *cmndstr;
+	extern struct Config_t Config;
 
-  cmndstr = Parse(app);                  // Get command to pass to system
+	cmndstr = Parse(app); /* Get command to pass to system */
 
-  if (Config.Verbose) fprintf(stderr, "Command String: %s", cmndstr);
+	if (Config.Verbose)
+		fprintf(stderr, "Command String: %s", cmndstr);
 
-  if (cmndstr != NULL) {
-    system(cmndstr);  // if there's a command, run it
-    free(cmndstr);
-  }
-}/***********************************************************************/
+	if (cmndstr != NULL) {
+		system(cmndstr); /* if there's a command, run it */
+		free(cmndstr);
+	}
+}
+/***********************************************************************/
 
 /***********************************************************************
  * Parse(int app)
  *
  * Parses the file 'configfile' for command to execute.
  ***********************************************************************/
-char *Parse(int app) {
-  FILE *fp;
-  char Buf[BUFFER_SIZE];
-  char *Ptr;
+char *Parse(int app)
+{
+	FILE *fp;
+	char Buf[BUFFER_SIZE];
+	char *Ptr;
 
-  if ((fp = fopen(Config.configfile, "r")) == NULL)
-    err_mess(FAILCONF,Config.configfile);
+	if ((fp = fopen(Config.configfile, "r")) == NULL)
+		if ((fp = fopen(CONFIGGLOBAL, "r")) == NULL)
+			err_mess(FAILCONF,Config.configfile);
 
-  while ((Ptr = fgets(Buf, BUFFER_SIZE, fp))) {
-    if (atoi(Buf) == app)
-    break;
-  }
+	while ((Ptr = fgets(Buf, BUFFER_SIZE, fp))) {
+		if (atoi(Buf) == app)
+			break;
+	}
 
-  fclose(fp);
-  
-  if (!Ptr)
-    return Ptr;
+	fclose(fp);
 
-  Ptr = strchr(Buf, '\t');                      // find first tab
-  if (Ptr == NULL) Ptr = strchr(Buf, ' ');      // or space charater
-  if (Ptr == NULL) return(NULL);
-  Ptr++;
+	if (!Ptr)
+		return Ptr;
 
-  Ptr = strdup(Ptr);
+	Ptr = strchr(Buf, '\t');        /* find first tab */
+	if (Ptr == NULL)
+		Ptr = strchr(Buf, ' '); /* or space charater */
 
-  return(Ptr);
-}/**********************************************************************/
+	if (Ptr == NULL)
+		return(NULL);
+
+	Ptr++;
+	Ptr = strdup(Ptr);
+
+	return Ptr;
+}
+/**********************************************************************/
 
 /***********************************************************************
- *   initTime
+ * initTime
  *
- *     Copyright (c) 2001 Bruno Essmann <essmann at users.sourceforge.net>
+ * Copyright (c) 2001 Bruno Essmann <essmann at users.sourceforge.net>
  ***********************************************************************/
 
-void initTime () {
-  extern struct Config_t Config;
-
-  if (Config.Verbose) {
-    fprintf(stdout, "[        ] initializing time\n");
-  }
-
-  gettimeofday(&_tStart, NULL);
-}/**********************************************************************/
-
-long currentTimeMillis () {
-  struct timeval tNow;
-  struct timeval tElapsed;
-  
-  gettimeofday(&tNow, NULL);
-  
-  if (_tStart.tv_usec > tNow.tv_usec) {
-    tNow.tv_usec+= 1000000;
-    tNow.tv_sec--;
-  }
-  tElapsed.tv_sec= tNow.tv_sec - _tStart.tv_sec;
-  tElapsed.tv_usec= tNow.tv_usec - _tStart.tv_usec;
-  return (tElapsed.tv_sec * 1000) + (tElapsed.tv_usec / 1000);
-}/**********************************************************************/
-
-
-void getWindowOrigin (Window w, int* nX, int* nY) {
-  extern Display *display;
-  Window wWindow, wParent, wRoot;
-  Window* wChildren;
-  unsigned int nChildren;
-  unsigned int ww, wh, wb, wd;
-  int wx, wy;
-
-  wParent= w;
-  do {
-    wWindow= wParent;
-    if (!XQueryTree(display, wParent, &wRoot, &wParent, &wChildren, &nChildren))
-      return;
-
-    if (wChildren)
-      XFree(wChildren);
-
-  } while (wParent != wRoot);
-
-  if (XGetGeometry(display, wWindow, &wRoot, &wx, &wy, &ww, &wh, &wb, &wd)) {
-    if (nX) {
-      *nX= wx;
-    }
-    if (nY) {
-      *nY= wy;
-    }
-  }
-}/**********************************************************************/
+void initTime(void)
+{
+	extern struct Config_t Config;
+
+	if (Config.Verbose)
+		fprintf(stdout, "[        ] initializing time\n");
+
+	gettimeofday(&_tStart, NULL);
+}
+/**********************************************************************/
+
+long currentTimeMillis(void)
+{
+	struct timeval tNow, tElapsed;
+
+	gettimeofday(&tNow, NULL);
+
+	if (_tStart.tv_usec > tNow.tv_usec) {
+		tNow.tv_usec += 1000000;
+		tNow.tv_sec--;
+	}
+
+	tElapsed.tv_sec = tNow.tv_sec - _tStart.tv_sec;
+	tElapsed.tv_usec = tNow.tv_usec - _tStart.tv_usec;
+	return (tElapsed.tv_sec * 1000) + (tElapsed.tv_usec / 1000);
+}
+/**********************************************************************/
+
+void getWindowOrigin(Window w, int *nX, int *nY)
+{
+	extern Display *display;
+	Window wWindow, wParent, wRoot;
+	Window* wChildren;
+	unsigned int nChildren, ww, wh, wb, wd;
+	int wx, wy;
+
+	wParent = w;
+	do {
+		wWindow = wParent;
+		if (!XQueryTree(display, wParent, &wRoot, &wParent, &wChildren, &nChildren))
+			return;
+
+		if (wChildren)
+			XFree(wChildren);
+
+	} while (wParent != wRoot);
+
+	if (XGetGeometry(display, wWindow, &wRoot, &wx, &wy, &ww, &wh, &wb, &wd)) {
+		if (nX)
+			*nX = wx;
+
+		if (nY)
+			*nY = wy;
+	}
+}
+/**********************************************************************/
 
 /***********************************************************************
- *  getButtonLocation
+ * getButtonLocation
  *
- *  compute location for each button's tooltip (not perfect)
+ * compute location for each button's tooltip (not perfect)
  ***********************************************************************/
-void getButtonLocation (int nButton, int* nLocationX, int* nLocationY) {
-  *nLocationX = 0;
-  *nLocationY = 8;
-  while (nButton > BUTTON_COLS) {
-    *nLocationY += BUTTON_SIZE;
-    nButton -= BUTTON_COLS;
-  }
-  while (nButton > 0) {
-    *nLocationX += BUTTON_SIZE - 1;
-    nButton--;
-  }
-}/**********************************************************************/
+void getButtonLocation (int nButton, int *nLocationX, int *nLocationY)
+{
+	*nLocationX = 0;
+	*nLocationY = 8;
+
+	while (nButton > BUTTON_COLS) {
+		*nLocationY += BUTTON_SIZE;
+		nButton -= BUTTON_COLS;
+	}
+
+	while (nButton > 0) {
+		*nLocationX += BUTTON_SIZE - 1;
+		nButton--;
+	}
+}
+/**********************************************************************/
 
 /* SkipWord & SkipSpaces: utility functions for getNicenedString */
 char *SkipWord(char *Text) {
-  char *Result = Text;
+	char *Result = Text;
+
+	while ((*Result != ' ') && (*Result != '\t') &&
+	       (*Result != '\n') && (*Result != 0x00))
+		Result++;
 
-  while ((*Result != ' ')&&(*Result != '\t')&&
-         (*Result != '\n')&&(*Result != 0x00))
-    Result++;
-  return Result;
+	return Result;
 }
 
 char *SkipSpaces(char *Text) {
-  char *Result = Text;
+	char *Result = Text;
 
-  while ((*Result == ' ')||(*Result == '\t')||(*Result == '\n'))
-    Result++;
-  return Result;
+	while ((*Result == ' ') || (*Result == '\t') || (*Result == '\n'))
+		Result++;
+
+	return Result;
 }
 
 /***********************************************************************
- *  getNicenedString
+ * getNicenedString
  *
- *  nicen the parsed command from the .wmbutton config file
- *    - cut if too long
- *    - remove parameters, whitespace and the '&'...
+ * nicen the parsed command from the .wmbutton config file
+ *  - cut if too long
+ *  - remove parameters, whitespace and the '&'...
  ***********************************************************************/
-char* getNicenedString (char *old, int andAddSeparator) {
-  char *WorkStr;
-  char *WorkStrEnd;
-  char *StartPtr;
-  char *EndPtr;
-
-  char *RetStr;
-
-  if (!old) {
-    if (andAddSeparator)
-      return strdup("-- | ");
-    else
-      return strdup("--");
-  }
-
-  RetStr = malloc(strlen(old) + 3 + 1); // 3 for Seperator
-  *RetStr = 0x00;
-
-  WorkStr = strdup(old);
-  WorkStrEnd = strchr(WorkStr, 0x00);
-  StartPtr = WorkStr;
-
-  while(StartPtr < WorkStrEnd) {
-    StartPtr = SkipSpaces(StartPtr);
-    EndPtr = SkipWord(StartPtr);
-    *EndPtr = 0x00;
-
-    if ((*StartPtr == '&')||(*StartPtr == '-'))
-      break;
-
-    strcat(RetStr, StartPtr);
-    strcat(RetStr, " ");
-    StartPtr = EndPtr+1;
-  }
-
-  free(WorkStr);
-
-  if (andAddSeparator) {
-    strcat(RetStr, "| ");
-  }
-  
-  return RetStr;
+char *getNicenedString(char *old, int andAddSeparator)
+{
+	char *WorkStr, *WorkStrEnd, *StartPtr, *EndPtr, *RetStr;
+
+	if (!old) {
+		if (andAddSeparator)
+			return strdup("-- | ");
+		else
+			return strdup("--");
+	}
+
+	RetStr = malloc(strlen(old) + 3 + 1); /* 3 for Seperator */
+	*RetStr = 0x00;
+
+	WorkStr = strdup(old);
+	WorkStrEnd = strchr(WorkStr, 0x00);
+	StartPtr = WorkStr;
+
+	while (StartPtr < WorkStrEnd) {
+		StartPtr = SkipSpaces(StartPtr);
+		EndPtr = SkipWord(StartPtr);
+		*EndPtr = 0x00;
+
+		if ((*StartPtr == '&') || (*StartPtr == '-'))
+			break;
+
+		strcat(RetStr, StartPtr);
+		strcat(RetStr, " ");
+		StartPtr = EndPtr + 1;
+	}
+
+	free(WorkStr);
+
+	if (andAddSeparator)
+		strcat(RetStr, "| ");
+
+	return RetStr;
 }
 
 /***********************************************************************
- *  getButtonAppNames
+ * getButtonAppNames
  *
- *  returns the 1..3 application names / commands to be shown in tooltip
+ *returns the 1..3 application names / commands to be shown in tooltip
  ***********************************************************************/
-char* getButtonAppNames (int nButton) {
-  char *str = NULL;
-  char *tmp1,*tmp2;
-    
-  if (!( nButton < 0 || nButton > 9 )) {
-
-    // FIXME: _Might_ overflow, but it's unlikely.
-    // Perhaps one should fix this sometime ;)
-    str = (char*) calloc (sizeof(char), BUFFER_SIZE);
-    
-    tmp1 = Parse(nButton + LMASK);
-    tmp2 = getNicenedString(tmp1, 1);
-    strcat(str, tmp2);
-    free(tmp1);
-    free(tmp2);
-    
-    tmp1 = Parse(nButton + MMASK);
-    tmp2 = getNicenedString(tmp1, 1);
-    strcat(str, tmp2);
-    free(tmp1);
-    free(tmp2);
-    
-    tmp1 = Parse(nButton + RMASK);
-    tmp2 = getNicenedString(tmp1, 0);
-    strcat(str, tmp2);
-    free(tmp1);
-    free(tmp2);
-  }
-
-  return(str);
-}/**********************************************************************/
-
-
-int hasTooltipSupport () {
-  return !Config.bTooltipDisable;
-}/**********************************************************************/
-
-void showTooltip (int nButton, int nMouseX, int nMouseY) {
-  Pixmap pixmap, mask;
-  int nMainWinX, nMainWinY;
-  int nButtonX = 0, nButtonY = 0, nButtonWidth = 0, nButtonHeight = 0;
-  int nTextY, nX, nY, nWidth, nHeight, nSide;
-  char* szText;
-  extern struct Config_t Config;
-  extern Window iconwin;
-  extern Pixel bg_pixel, fg_pixel;
-  extern Display *display;
-  extern GC gc;
-
-  if (Config.bTooltipDisable ||  nButton == -1) {
-    return;
-  }
-  if (_bTooltip) {
-    hideTooltip();
-  }
-
-
-  if (Config.Verbose) { 
-    fprintf(stdout, "[%8ld] showing tooltip for button %d at %d, %d\n", 
-	    currentTimeMillis(),
-	    nButton, nMouseX, nMouseY);
-  } 
-
-  szText = getButtonAppNames(nButton);
-  if(!szText)
-    return;
-
-  _bTooltip= 1;
-
-  nWidth= XTextWidth(_fTooltip, szText, strlen(szText)) + 16;
-  nHeight= _nFontHeight + 4;
-  if (nHeight < 16) {
-    nHeight= 16;
-  }
-  if (nWidth < nHeight) {
-    nWidth= nHeight;
-  }
-  if (Config.Verbose) { 
-    fprintf(stdout, "[%8ld] tooltip size: %d, %d\n", 
-	    currentTimeMillis(), nWidth, nHeight);
-  }
-	
-  getWindowOrigin(iconwin, &nMainWinX, &nMainWinY);
-  getButtonLocation(nButton, &nButtonX, &nButtonY);
-  nButtonX+= nMainWinX;
-  nButtonY+= nMainWinY;
-  nButtonWidth  = BUTTON_SIZE;
-  nButtonHeight = BUTTON_SIZE;
-	
-  if (nButtonX + nWidth > _nScreenWidth) {
-    nSide= TOOLTIP_RIGHT;
-    nX= nButtonX - nWidth + nButtonWidth / 2;
-    if (nX < 0) {
-      nX= 0;
-    }
-  } else {
-    nSide= TOOLTIP_LEFT;
-    nX= nButtonX + nButtonWidth / 2;
-  }
-  if (nX + nWidth > _nScreenWidth) {
-    nX= _nScreenWidth - nWidth;
-  }
-
-  if (nButtonY - (nHeight + TOOLTIP_SPACE) < 0) {
-    nSide|= TOOLTIP_TOP;
-    nY= nButtonY + nButtonHeight - 1;
-    nTextY= TOOLTIP_SPACE;
-  } else {
-    nSide|= TOOLTIP_BOTTOM;
-    nY= nButtonY - (nHeight + TOOLTIP_SPACE);
-    nTextY= 0;
-  }
-	
-  pixmap= createTooltipPixmap(nWidth, nHeight, nSide, &mask);
-
-  XSetForeground(display, gc, Config.bTooltipSwapColors ? fg_pixel : bg_pixel);
-  XSetFont(display, gc, _fTooltip->fid);
-  XDrawString(display, pixmap, gc, 
-	      8, nTextY + (nHeight - _nFontHeight) / 2 + _nFontY, 
-	      szText, strlen(szText));
-		
-  XSetWindowBackgroundPixmap(display, _wTooltip, pixmap);
-
-  XResizeWindow(display, _wTooltip, nWidth, nHeight + TOOLTIP_SPACE);
-  XShapeCombineMask(display, _wTooltip, ShapeBounding, 0, 0, mask, ShapeSet);
-  XFreePixmap(display, mask);
-  XMoveWindow(display, _wTooltip, nX, nY);
-  XMapRaised(display, _wTooltip);
-  XFreePixmap(display, pixmap);
-
-  free(szText);
-}/**********************************************************************/
-
-void hideTooltip () {
-  extern struct Config_t Config;
-  extern Display *display;
-
-  if (Config.bTooltipDisable) {
-    return;
-  }
-  if (_bTooltip) {
-    if (Config.Verbose) {
-      fprintf(stdout, "[%8ld] hiding tooltip\n", currentTimeMillis());
-    }
-    XUnmapWindow(display, _wTooltip);
-    _bTooltip= 0;
-  }
-}/**********************************************************************/
-
-int hasTooltip () {
-  if (Config.bTooltipDisable) {
-    return 0;
-  }
-  return _bTooltip;
-}/**********************************************************************/
-
-void initTooltip () {
-  XSetWindowAttributes attribs;
-  unsigned long vmask;
-  extern Display *display;
-  extern char *app_name;
-  extern int screen;
-  extern Window rootwin, win;
-
-  if (Config.bTooltipDisable) {
-    if (Config.Verbose) {
-      fprintf(stdout, "[%8ld] initializing tooltips (disabled)\n", 
-	      currentTimeMillis());
-    }
-
-    return;
-  }
-  if (Config.Verbose) {
-    fprintf(stdout, "[%8ld] initializing tooltips\n", currentTimeMillis());
-  }
-  _fTooltip= XLoadQueryFont(display, Config.szTooltipFont);
-  if (!_fTooltip) {
-    fprintf(stderr, "%s: couldn't allocate font '%s'.\n", app_name, Config.szTooltipFont);
-    if (!strcmp(Config.szTooltipFont, TOOLTIP_FONT))
-      fprintf(stderr, "%s: Use option -F <font>\n", app_name);
-    exit(-1);
-  }
-  _nFontHeight= _fTooltip->ascent + _fTooltip->descent;
-  _nFontY= _fTooltip->ascent;
-  _nScreenWidth= WidthOfScreen(ScreenOfDisplay(display, screen));
-  _nScreenHeight= HeightOfScreen(ScreenOfDisplay(display, screen));
-  if (Config.Verbose) {
-    fprintf(stdout, "[%8ld] configuring tooltip font:\n" \
-	    "[%8ld] - '%s'\n" \
-	    "[%8ld] - font-height= %d, font-ascent= %d\n" \
-	    "[%8ld] configuring screen size: %dx%d\n",
-	    currentTimeMillis(), 
-	    currentTimeMillis(), Config.szTooltipFont, 
-	    currentTimeMillis(), _nFontHeight, _nFontY,
-	    currentTimeMillis(), _nScreenWidth, _nScreenHeight  );
-  }
-
-  vmask= CWSaveUnder | CWOverrideRedirect | CWBorderPixel;
-  attribs.save_under= True;
-  attribs.override_redirect= True;
-  attribs.border_pixel= 0;
-  _wTooltip= XCreateWindow(display, rootwin, 1, 1, 10, 10, 1,
-			   CopyFromParent, CopyFromParent, 
-			   CopyFromParent, vmask, &attribs);
-  if (win == 0) {
-    fprintf(stderr, "Cannot create tooltip window.\n");
-    exit(-1);
-  }
-}/**********************************************************************/
-
-void destroyTooltip () {
-  extern Display *display;
-
-  if (Config.bTooltipDisable) {
-    return;
-  }
-  if (_gcMono) {
-    XFreeGC(display, _gcMono);
-    _gcMono= 0;
-  }
-  XDestroyWindow(display, _wTooltip);
-}/**********************************************************************/
-
-void drawTooltipBalloon (Pixmap pix, GC gc, int x, int y, int w, int h, int side) {
-  extern Display *display;
-  int rad = h*3/10;
-  XPoint pt[3];
-
-  XFillArc(display, pix, gc, x, y, rad, rad, 90*64, 90*64);
-  XFillArc(display, pix, gc, x, y+h-1-rad, rad, rad, 180*64, 90*64);
-
-  XFillArc(display, pix, gc, x+w-1-rad, y, rad, rad, 0*64, 90*64);
-  XFillArc(display, pix, gc, x+w-1-rad, y+h-1-rad, rad, rad, 270*64, 90*64);
-
-  XFillRectangle(display, pix, gc, x, y+rad/2, w, h-rad);
-  XFillRectangle(display, pix, gc, x+rad/2, y, w-rad, h);
-
-  if (side & TOOLTIP_BOTTOM) {
-    pt[0].y = y+h-1;
-    pt[1].y = y+h-1+TOOLTIP_SPACE;
-    pt[2].y = y+h-1;
-  } else {
-    pt[0].y = y;
-    pt[1].y = y-TOOLTIP_SPACE;
-    pt[2].y = y;
-  }
-  if (side & TOOLTIP_RIGHT) {
-    pt[0].x = x+w-h+2*h/16;
-    pt[1].x = x+w-h+11*h/16;
-    pt[2].x = x+w-h+7*h/16;
-  } else {
-    pt[0].x = x+h-2*h/16;
-    pt[1].x = x+h-11*h/16;
-    pt[2].x = x+h-7*h/16;
-  }
-  XFillPolygon(display, pix, gc, pt, 3, Convex, CoordModeOrigin);
-}/**********************************************************************/
-
-Pixmap createTooltipPixmap (int width, int height, int side, Pixmap *mask) {
-  extern Display *display;
-  extern GC gc;
-  extern Pixel bg_pixel, fg_pixel;
-  extern int depth;
-  extern Window rootwin;
-  Pixmap bitmap;
-  Pixmap pixmap;
-  int x, y;
-
-  bitmap = XCreatePixmap(display, rootwin, 
-			 width+TOOLTIP_SPACE, height+TOOLTIP_SPACE, 1);
-
-  if (!_gcMono) {
-    _gcMono= XCreateGC(display, bitmap, 0, NULL);
-  }
-  XSetForeground(display, _gcMono, 0); 
-  XFillRectangle(display, bitmap, _gcMono, 0, 0, 
-		 width+TOOLTIP_SPACE, height+TOOLTIP_SPACE);
-
-  pixmap = XCreatePixmap(display, rootwin, 
-			 width+TOOLTIP_SPACE, height+TOOLTIP_SPACE, depth);
-  XSetForeground(display, gc, Config.bTooltipSwapColors ? fg_pixel : bg_pixel);
-  XFillRectangle(display, pixmap, gc, 0, 0, 
-		 width+TOOLTIP_SPACE, height+TOOLTIP_SPACE);
-
-  if (side & TOOLTIP_BOTTOM) {
-    y = 0;
-  } else {
-    y = TOOLTIP_SPACE;
-  }
-  x = 0;
-
-  XSetForeground(display, _gcMono, 1);
-  drawTooltipBalloon(bitmap, _gcMono, x, y, width, height, side);
-  XSetForeground(display, gc, Config.bTooltipSwapColors ? bg_pixel : fg_pixel);
-  drawTooltipBalloon(pixmap, gc, x+1, y+1, width-2, height-2, side);
-
-  *mask = bitmap;
-
-  return pixmap;
-}/***********************************************************************/
+char *getButtonAppNames(int nButton)
+{
+	char *tmp1, *tmp2, *str = NULL;
+
+	if (!( nButton < 0 || nButton > 9 )) {
+
+		/* FIXME: _Might_ overflow, but it's unlikely.
+		 * Perhaps one should fix this sometime ;) */
+		str = (char*) calloc (sizeof(char), BUFFER_SIZE);
+
+		tmp1 = Parse(nButton + LMASK);
+		tmp2 = getNicenedString(tmp1, 1);
+		strcat(str, tmp2);
+		free(tmp1);
+		free(tmp2);
+
+		tmp1 = Parse(nButton + MMASK);
+		tmp2 = getNicenedString(tmp1, 1);
+		strcat(str, tmp2);
+		free(tmp1);
+		free(tmp2);
+
+		tmp1 = Parse(nButton + RMASK);
+		tmp2 = getNicenedString(tmp1, 0);
+		strcat(str, tmp2);
+		free(tmp1);
+		free(tmp2);
+	}
+
+	return str;
+}
+/**********************************************************************/
+
+
+int hasTooltipSupport(void)
+{
+	return !Config.bTooltipDisable;
+}
+/**********************************************************************/
+
+void showTooltip (int nButton, int nMouseX, int nMouseY)
+{
+	Pixmap pixmap, mask;
+	int nMainWinX, nMainWinY;
+	int nButtonX = 0, nButtonY = 0, nButtonWidth = 0, nButtonHeight = 0;
+	int nTextY, nX, nY, nWidth, nHeight, nSide;
+	char* szText;
+	extern struct Config_t Config;
+	extern Window iconwin;
+	extern Pixel bg_pixel, fg_pixel;
+	extern Display *display;
+	extern GC gc;
+
+	if (Config.bTooltipDisable || nButton == -1)
+		return;
+
+	if (_bTooltip)
+		hideTooltip();
+
+	if (Config.Verbose)
+		fprintf(stdout,
+			"[%8ld] showing tooltip for button %d at %d, %d\n",
+			currentTimeMillis(), nButton, nMouseX, nMouseY);
+
+	szText = getButtonAppNames(nButton);
+	if(!szText)
+		return;
+
+	_bTooltip = 1;
+
+	nWidth = XTextWidth(_fTooltip, szText, strlen(szText)) + 16;
+	nHeight = _nFontHeight + 4;
+	if (nHeight < 16)
+		nHeight = 16;
+
+	if (nWidth < nHeight)
+		nWidth = nHeight;
+
+	if (Config.Verbose)
+		fprintf(stdout, "[%8ld] tooltip size: %d, %d\n",
+			currentTimeMillis(), nWidth, nHeight);
+
+	getWindowOrigin(iconwin, &nMainWinX, &nMainWinY);
+	getButtonLocation(nButton, &nButtonX, &nButtonY);
+	nButtonX += nMainWinX;
+	nButtonY += nMainWinY;
+	nButtonWidth = BUTTON_SIZE;
+	nButtonHeight = BUTTON_SIZE;
+
+	if (nButtonX + nWidth > _nScreenWidth) {
+		nSide = TOOLTIP_RIGHT;
+		nX = nButtonX - nWidth + nButtonWidth / 2;
+		if (nX < 0)
+			nX = 0;
+	} else {
+		nSide = TOOLTIP_LEFT;
+		nX = nButtonX + nButtonWidth / 2;
+	}
+
+	if (nX + nWidth > _nScreenWidth)
+		nX = _nScreenWidth - nWidth;
+
+	if (nButtonY - (nHeight + TOOLTIP_SPACE) < 0) {
+		nSide |= TOOLTIP_TOP;
+		nY = nButtonY + nButtonHeight - 1;
+		nTextY = TOOLTIP_SPACE;
+	} else {
+		nSide |= TOOLTIP_BOTTOM;
+		nY = nButtonY - (nHeight + TOOLTIP_SPACE);
+		nTextY = 0;
+	}
+
+	pixmap = createTooltipPixmap(nWidth, nHeight, nSide, &mask);
+
+	XSetForeground(display, gc, Config.bTooltipSwapColors ? fg_pixel : bg_pixel);
+	XSetFont(display, gc, _fTooltip->fid);
+	XDrawString(display, pixmap, gc,
+		    8, nTextY + (nHeight - _nFontHeight) / 2 + _nFontY,
+		    szText, strlen(szText));
+
+	XSetWindowBackgroundPixmap(display, _wTooltip, pixmap);
+
+	XResizeWindow(display, _wTooltip, nWidth, nHeight + TOOLTIP_SPACE);
+	XShapeCombineMask(display, _wTooltip, ShapeBounding, 0, 0, mask, ShapeSet);
+	XFreePixmap(display, mask);
+	XMoveWindow(display, _wTooltip, nX, nY);
+	XMapRaised(display, _wTooltip);
+	XFreePixmap(display, pixmap);
+
+	free(szText);
+}
+/**********************************************************************/
+
+void hideTooltip(void)
+{
+	extern struct Config_t Config;
+	extern Display *display;
+
+	if (Config.bTooltipDisable)
+		return;
+
+	if (_bTooltip) {
+		if (Config.Verbose)
+			fprintf(stdout, "[%8ld] hiding tooltip\n", currentTimeMillis());
+
+		XUnmapWindow(display, _wTooltip);
+		_bTooltip = 0;
+	}
+}
+/**********************************************************************/
+
+int hasTooltip(void)
+{
+	if (Config.bTooltipDisable)
+		return 0;
+
+	return _bTooltip;
+}
+/**********************************************************************/
+
+void initTooltip(void)
+{
+	XSetWindowAttributes attribs;
+	unsigned long vmask;
+	extern Display *display;
+	extern char *app_name;
+	extern int screen;
+	extern Window rootwin, win;
+
+	if (Config.bTooltipDisable) {
+		if (Config.Verbose)
+			fprintf(stdout, "[%8ld] initializing tooltips (disabled)\n",
+				currentTimeMillis());
+
+		return;
+	}
+	if (Config.Verbose)
+		fprintf(stdout, "[%8ld] initializing tooltips\n", currentTimeMillis());
+
+	_fTooltip = XLoadQueryFont(display, Config.szTooltipFont);
+	if (!_fTooltip) {
+		fprintf(stderr, "%s: couldn't allocate font '%s'.\n", app_name, Config.szTooltipFont);
+		if (!strcmp(Config.szTooltipFont, TOOLTIP_FONT))
+			fprintf(stderr, "%s: Use option -F <font>\n", app_name);
+		exit(-1);
+	}
+
+	_nFontHeight = _fTooltip->ascent + _fTooltip->descent;
+	_nFontY = _fTooltip->ascent;
+	_nScreenWidth = WidthOfScreen(ScreenOfDisplay(display, screen));
+	_nScreenHeight = HeightOfScreen(ScreenOfDisplay(display, screen));
+	if (Config.Verbose)
+		fprintf(stdout, "[%8ld] configuring tooltip font:\n" \
+			"[%8ld] - '%s'\n" \
+			"[%8ld] - font-height= %d, font-ascent= %d\n" \
+			"[%8ld] configuring screen size: %dx%d\n",
+			currentTimeMillis(),
+			currentTimeMillis(), Config.szTooltipFont,
+			currentTimeMillis(), _nFontHeight, _nFontY,
+			currentTimeMillis(), _nScreenWidth, _nScreenHeight);
+
+	vmask = CWSaveUnder | CWOverrideRedirect | CWBorderPixel;
+	attribs.save_under = True;
+	attribs.override_redirect = True;
+	attribs.border_pixel = 0;
+	_wTooltip = XCreateWindow(display, rootwin, 1, 1, 10, 10, 1,
+				  CopyFromParent, CopyFromParent,
+				  CopyFromParent, vmask, &attribs);
+
+	if (win == 0) {
+		fprintf(stderr, "Cannot create tooltip window.\n");
+		exit(-1);
+	}
+}
+/**********************************************************************/
+
+void destroyTooltip(void)
+{
+	extern Display *display;
+
+	if (Config.bTooltipDisable)
+		return;
+
+	if (_gcMono) {
+		XFreeGC(display, _gcMono);
+		_gcMono = 0;
+	}
+
+	XDestroyWindow(display, _wTooltip);
+}
+/**********************************************************************/
+
+void drawTooltipBalloon(Pixmap pix, GC gc, int x, int y, int w, int h, int side)
+{
+	extern Display *display;
+	int rad = h * 3 / 10;
+	XPoint pt[3];
+
+	XFillArc(display, pix, gc, x, y, rad, rad, 90 * 64, 90 * 64);
+	XFillArc(display, pix, gc, x, y + h - 1 - rad, rad, rad, 180 * 64, 90 * 64);
+
+	XFillArc(display, pix, gc, x + w - 1 - rad, y, rad, rad, 0 * 64, 90 * 64);
+	XFillArc(display, pix, gc, x + w - 1 - rad, y + h - 1 - rad, rad, rad, 270 * 64, 90 * 64);
+
+	XFillRectangle(display, pix, gc, x, y + rad / 2, w, h - rad);
+	XFillRectangle(display, pix, gc, x + rad / 2, y, w - rad, h);
+
+	if (side & TOOLTIP_BOTTOM) {
+		pt[0].y = y + h - 1;
+		pt[1].y = y + h - 1 + TOOLTIP_SPACE;
+		pt[2].y = y + h - 1;
+	} else {
+		pt[0].y = y;
+		pt[1].y = y-TOOLTIP_SPACE;
+		pt[2].y = y;
+	}
+
+	if (side & TOOLTIP_RIGHT) {
+		pt[0].x = x + w - h +  2 * h / 16;
+		pt[1].x = x + w - h + 11 * h / 16;
+		pt[2].x = x + w - h +  7 * h / 16;
+	} else {
+		pt[0].x = x + h -  2 * h /16;
+		pt[1].x = x + h - 11 * h /16;
+		pt[2].x = x + h -  7 * h /16;
+	}
+
+	XFillPolygon(display, pix, gc, pt, 3, Convex, CoordModeOrigin);
+}
+/**********************************************************************/
+
+Pixmap createTooltipPixmap(int width, int height, int side, Pixmap *mask)
+{
+	extern Display *display;
+	extern GC gc;
+	extern Pixel bg_pixel, fg_pixel;
+	extern int depth;
+	extern Window rootwin;
+	Pixmap bitmap, pixmap;
+	int x, y;
+
+	bitmap = XCreatePixmap(display, rootwin,
+			       width+TOOLTIP_SPACE, height+TOOLTIP_SPACE, 1);
+
+	if (!_gcMono)
+		_gcMono = XCreateGC(display, bitmap, 0, NULL);
+
+	XSetForeground(display, _gcMono, 0);
+	XFillRectangle(display, bitmap, _gcMono, 0, 0,
+		       width+TOOLTIP_SPACE, height+TOOLTIP_SPACE);
+
+	pixmap = XCreatePixmap(display, rootwin, width+TOOLTIP_SPACE,
+			       height+TOOLTIP_SPACE, depth);
+	XSetForeground(display, gc, Config.bTooltipSwapColors ? fg_pixel : bg_pixel);
+	XFillRectangle(display, pixmap, gc, 0, 0, width+TOOLTIP_SPACE,
+		       height+TOOLTIP_SPACE);
+
+	if (side & TOOLTIP_BOTTOM)
+		y = 0;
+	else
+		y = TOOLTIP_SPACE;
+
+	x = 0;
+
+	XSetForeground(display, _gcMono, 1);
+	drawTooltipBalloon(bitmap, _gcMono, x, y, width, height, side);
+	XSetForeground(display, gc, Config.bTooltipSwapColors ? bg_pixel : fg_pixel);
+	drawTooltipBalloon(pixmap, gc, x+1, y+1, width-2, height-2, side);
+
+	*mask = bitmap;
+
+	return pixmap;
+}
+/***********************************************************************/
 
 
 /***********************************************************************
- *   flush_expose
+ * flush_expose
  *
- *   Everyone else has one of these... Can't hurt to throw it in.
+ * Everyone else has one of these... Can't hurt to throw it in.
  ***********************************************************************/
-int flush_expose(Window w) {
-  extern Display *display;
-  XEvent         dummy;
-  int            i=0;
-
-  while (XCheckTypedWindowEvent(display, w, Expose, &dummy)) i++;
-  return(i);
-}/***********************************************************************/
+int flush_expose(Window w)
+{
+	extern Display *display;
+	XEvent dummy;
+	int i = 0;
+
+	while (XCheckTypedWindowEvent(display, w, Expose, &dummy))
+		i++;
+
+	return i;
+}
+/***********************************************************************/
diff --git a/wmbutton.1 b/wmbutton.1
new file mode 100644
index 0000000..00155d3
--- /dev/null
+++ b/wmbutton.1
@@ -0,0 +1,115 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH WMBUTTON 1 "August 20, 2012"
+.\" Please adjust this date whenever revising the manpage.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh        disable hyphenation
+.\" .hy        enable hyphenation
+.\" .ad l      left justify
+.\" .ad b      justify to both left and right margins
+.\" .nf        disable filling
+.\" .fi        enable filling
+.\" .br        insert line break
+.\" .sp <n>    insert n+1 empty lines
+.\" for manpage-specific macros, see man(7)
+.SH NAME
+wmbutton \- dockable launcher application
+.SH SYNOPSIS
+.B wmbutton
+.\"[-g \fIgeometry\fP] [-d \fIdisplay\fP] [-v] [-f \fIconfigfile\fP] [-h]
+[\fIOPTIONS\fP]
+
+.SH DESCRIPTION
+This manual page documents briefly the
+.B wmbutton
+command.
+.PP
+.\" TeX users may be more comfortable with the \fB<whatever>\fP and
+.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
+.\" respectively.
+\fBwmbutton\fP is a 64x64 pixel application that displays nine buttons and can be used as dockapp for X window managers such as Window Maker, AfterStep, BlackBox, and Enlightenment. Each of these buttons can be configured via a configuration file to run just about any application you would like to. Basically, if you can type it in a shell command, wmbutton can run it.
+
+.PP
+\fBwmbutton\fP is configured using a configuration file, ~/.wmbutton (or /etc/wmbutton.conf). Its format is documented in the "Configuration" section below.
+.SH OPTIONS
+.TP
+.B \-g <geometry>
+Window Geometry - ie: 64x64+10+10
+.TP
+.B \-d  <display>
+Display -  ie: 127.0.0.1:0.0
+.TP
+.B \-f  <filename>
+Full path to configuration file.
+.TP
+.B \-b  <filename>
+Full path to button xpm.
+.TP
+.B \-F  <font>
+Custom tooltip font (e.g. \-b\&h\-lucidatypewriter\-medium\-*\-*\-*\-12\-*)
+.TP
+.B \-v
+Verbose Mode, gives extra debug output.
+.TP
+.B \-h
+Quick overview of available options.
+.TP
+.B \-m
+Disable Middle Mouse functionality.
+.TP
+.B \-s
+Swap tooltip colors.
+.TP
+.B \-n
+Turn off tooltips.
+
+.SH CONFIGURATION
+.TP
+The configuration file is case sensitive. A # starts a comment, and lines consisting entirely of whitespace are ignored. The syntax is simply:
+.TP
+.B <buttonnumber> <command>
+.TP
+\fBcommand\fP can be anything you can type in as a shell command.
+.TP
+Buttons are numbered as follows:
+.TP
+.B Left button
+.nf
+ 	1 2 3
+	4 5 6
+	7 8 9
+.fi
+.TP
+.B Middle button
+.nf
+	11 12 13
+	14 15 16
+	17 18 19
+.fi
+.TP
+.B Right button
+.nf
+	21 22 23
+	24 25 26
+	27 28 29
+.fi
+
+.TP
+To use other icons, wmbutton has to be rebuilt. View /usr/share/doc/wmbutton/README.Debian for further information.
+
+.SH FILES
+.TP
+.I /etc/wmbutton.conf
+system wide wmbutton configuration file.
+.TP
+.I ~/.wmbutton
+per user wmbutton configuration file. If it doesn't exist, the system wide wmbutton configuration file will be used.
+
+
+.SH AUTHOR
+wmbutton was written by Edward H. Flora <ehflora at access1.net>, and is licensed under the terms of the GNU  General Public License.
+.TP
+This manual page was originaly written by Gordon Fraser <gordon at debian.org>, for the Debian GNU/Linux system (but may be used by others). It was updated by Christian Aichinger <Greek0 at gmx.net> and Rodolfo García Peñas (kix) <kix at kix.es>.
diff --git a/wmbutton.c b/wmbutton.c
index a2e46ac..7b061b0 100644
--- a/wmbutton.c
+++ b/wmbutton.c
@@ -9,11 +9,11 @@
  *              Ralf Horstmann <ralf.horstmann at gmx.de>
  *                  Added ability to load pixmaps at startup,
  *                  without having to re-compile
- *              Michael Cohrs <camico at users.sourceforge.net> 
+ *              Michael Cohrs <camico at users.sourceforge.net>
  *                  Added Tool Tips, and updated graphics
  *              Bruno Essmann <essmann at users.sourceforge.net>)
  *                  Creator of wmpager
- *              Casey Harkins <charkins at cs.wisc.edu> 
+ *              Casey Harkins <charkins at cs.wisc.edu>
  *                  Bug fix reading config file path - 3/6/99
  *                  Added button-presses, and other - denoted by *charkins*
  *              Ben Cohen <buddog at aztec.asu.edu>
@@ -22,15 +22,15 @@
  *                  contributor to wmcp
  *              Michael Henderson <mghenderson at lanl.gov>
  *                  Application ideas, suggestions
- *              Ryan ?? <pancake at mindspring.com> 
+ *              Ryan ?? <pancake at mindspring.com>
  *                  Modified wmbutton to asbutton.
- *                  Note: asbutton is a seperate program, not associated 
+ *                  Note: asbutton is a seperate program, not associated
  *                        with wmbutton (just as wmbutton is not associated
  *                        with wmcp)
  *              Jon Bruno
  *                  Web Page Development
- *    The contributors listed above are not necessarily involved with the 
- *    development of wmbutton.  I'm listing them here partially as thanks for 
+ *    The contributors listed above are not necessarily involved with the
+ *    development of wmbutton.  I'm listing them here partially as thanks for
  *    helping out, catching bugs in the code, etc.
  ***********************************************************************/
 #include <stdio.h>
@@ -47,7 +47,7 @@
 #include "mask.xbm"               /* Border Graphic */
 
 /*************** Function Prototypes ***********************************/
-void redraw(void);                 
+void redraw(void);
 void getPixmaps(void);
 int  whichButton(int x, int y);   // determine which button has been pressed
 void SetWmHints();
@@ -67,21 +67,21 @@ Pixel bg_pixel, fg_pixel;
 struct Config_t Config;
 
 typedef struct _XpmIcon {
-  Pixmap pixmap;
-  Pixmap mask;
-  XpmAttributes attributes;
+	Pixmap pixmap;
+	Pixmap mask;
+	XpmAttributes attributes;
 } XpmIcon;
 
 typedef struct _button_region {
-  int x,y;
-  int i,j;
+	int x, y;
+	int i, j;
 } ButtonArea;
 
 ButtonArea button_region[9];
 
 XpmIcon template, visible, buttons;
 
-int border  = 0;
+int border = 0;
 int button_pressed = -1;	/* button to be drawn pressed *charkins*/
 
 char *app_name = "wmbutton";
@@ -89,375 +89,388 @@ char *app_name = "wmbutton";
 /***********************************************************************
  * 		Main
  ***********************************************************************/
-int main( int argc, char ** argv ) {
-
-  XEvent report;
-  XGCValues xgcValues;	
-  XTextProperty app_name_atom;
-  XSizeHints xsizehints;
-
-  Pixmap pixmask;
-
-  int dummy = 0;
-  int N = 1;		        /* Button number pressed to goto app # */
-  
-  /* Added for Tool Tip Support */
-  long nTooltipShowDelay = TOOLTIP_SHOW_DELAY;
-  long nTooltipReshowDelay = TOOLTIP_RESHOW_DELAY;
-  long nTooltipTimer = -1;
-  long nTooltipHideTimer = -1;
-  long nNow;
-  int nTooltipButton = 0, nTooltipX = 0, nTooltipY = 0;
-
-  /* Parse Command Line Arguments */  
-  parseargs(argc, argv);
-
-  /* Open Display */
-  if ( (display = XOpenDisplay(Config.Display_str)) == NULL ) 
-    err_mess(FAILDISP, Config.Display_str);
-  
-  screen  = DefaultScreen(display);
-  rootwin = RootWindow(display,screen);
-  depth   = DefaultDepth(display, screen);
-  
-  bg_pixel = WhitePixel(display, screen ); 
-  fg_pixel = BlackPixel(display, screen ); 
-  
-  xsizehints.flags  = USSize | USPosition;
-  xsizehints.width  = 64;
-  xsizehints.height = 64;
-  
-  /* Parse Geometry string and fill in sizehints fields */
-  XWMGeometry(display, screen, 
-	      Config.Geometry_str, 
-	      NULL, 	
-	      border, 
-	      &xsizehints,
-	      &xsizehints.x, 
-	      &xsizehints.y,
-	      &xsizehints.width,
-	      &xsizehints.height, 
-	      &dummy);
-  
-  if ( (win = XCreateSimpleWindow(display,
-				  rootwin,
-				  xsizehints.x,
-				  xsizehints.y,
-				  xsizehints.width,
-				  xsizehints.height,
-				  border,
-				  fg_pixel, bg_pixel) ) == 0 )
-    err_mess(FAILSWIN, NULL);
-
-  
-  if ( (iconwin = XCreateSimpleWindow(display,
-				      win,
-				      xsizehints.x,
-				      xsizehints.y,
-				      xsizehints.width,
-				      xsizehints.height,
-				      border,
-				      fg_pixel, bg_pixel) ) == 0 )
-    err_mess(FAILICON, NULL);
-
-  /* Set up shaped windows */
-  /*Gives the appicon a border so you can grab and move it. */
-
-  if ( ( pixmask = XCreateBitmapFromData(display, 
-					 win,
-					 mask_bits,
-					 mask_width,
-					 mask_height) )  == 0 )
-    err_mess(FAILXPM,NULL);
-
-  
-  XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet );
-  XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
-
-  /* Convert in pixmaps from .xpm includes. */
-  getPixmaps();
-
-  /* Interclient Communication stuff */
-  /* Appicons don't work with out this stuff */
-  SetWmHints();
-  SetClassHints();
-
-
-  XSetWMNormalHints( display, win, &xsizehints );
-  
-  /* Tell window manager what the title bar name is. We never see */
-  /* this anyways in the WithdrawnState      */
-  if ( XStringListToTextProperty(&app_name, 1, &app_name_atom) == 0 )
-    err_mess(FAILWNAM,app_name);
-  XSetWMName( display, win, &app_name_atom );
-  
-  /* Create Graphic Context */	
-  if (( gc = XCreateGC(display, win,(GCForeground | GCBackground), &xgcValues))
-       == NULL )
-    err_mess(FAILGC,NULL);
-
-  /* XEvent Masks. We want both window to process X events */
-  XSelectInput(display, win,
-	       ExposureMask | 
-	       ButtonPressMask | 
-	       ButtonReleaseMask |    	/* added ButtonReleaseMask *charkins*/
-	       PointerMotionMask |
-	       StructureNotifyMask |
-	       LeaveWindowMask );  
-  XSelectInput(display, iconwin,
-	       ExposureMask | 
-	       ButtonPressMask | 
-	       ButtonReleaseMask |	/* added ButtonReleaseMask *charkins*/
-	       PointerMotionMask |
-	       StructureNotifyMask |
-	       LeaveWindowMask );
-  
-  /* Store the 'state' of the application for restarting */
-  XSetCommand( display, win, argv, argc );	
-
-  /* Window won't ever show up until it is mapped.. then drawn after a 	*/
-  /* ConfigureNotify */
-  XMapWindow( display, win );
-
-  /* Initialize Tooltip Support */
-  initTime();
-  initTooltip(!Config.bTooltipDisable, Config.szTooltipFont, Config.bTooltipSwapColors);
-
-  /* X Event Loop */
-  while (1) {
-    while (XPending(display) || nTooltipTimer == -1) {
-      XNextEvent(display, &report );
-      switch (report.type) {
-      case Expose:
-	if (report.xexpose.count != 0) {	
-	  break;
+int main(int argc, char **argv)
+{
+	XEvent report;
+	XGCValues xgcValues;
+	XTextProperty app_name_atom;
+	XSizeHints xsizehints;
+	Pixmap pixmask;
+
+	int dummy = 0;
+	int N = 1;	/* Button number pressed to goto app # */
+
+	/* Added for Tool Tip Support */
+	long nTooltipShowDelay = TOOLTIP_SHOW_DELAY;
+	long nTooltipReshowDelay = TOOLTIP_RESHOW_DELAY;
+	long nTooltipTimer = -1;
+	long nTooltipHideTimer = -1;
+	long nNow;
+	int nTooltipButton = 0, nTooltipX = 0, nTooltipY = 0;
+
+	/* Parse Command Line Arguments */
+	parseargs(argc, argv);
+
+	/* Open Display */
+	if ((display = XOpenDisplay(Config.Display_str)) == NULL)
+		err_mess(FAILDISP, Config.Display_str);
+
+	screen  = DefaultScreen(display);
+	rootwin = RootWindow(display, screen);
+	depth   = DefaultDepth(display, screen);
+
+	bg_pixel = WhitePixel(display, screen);
+	fg_pixel = BlackPixel(display, screen);
+
+	xsizehints.flags  = USSize | USPosition;
+	xsizehints.width  = 64;
+	xsizehints.height = 64;
+
+	/* Parse Geometry string and fill in sizehints fields */
+	XWMGeometry(display, screen,
+		    Config.Geometry_str,
+		    NULL,
+		    border,
+		    &xsizehints,
+		    &xsizehints.x,
+		    &xsizehints.y,
+		    &xsizehints.width,
+		    &xsizehints.height,
+		    &dummy);
+
+	if ((win = XCreateSimpleWindow(display,
+				       rootwin,
+				       xsizehints.x,
+				       xsizehints.y,
+				       xsizehints.width,
+				       xsizehints.height,
+				       border,
+				       fg_pixel, bg_pixel)) == 0)
+		err_mess(FAILSWIN, NULL);
+
+	if ((iconwin = XCreateSimpleWindow(display,
+					   win,
+					   xsizehints.x,
+					   xsizehints.y,
+					   xsizehints.width,
+					   xsizehints.height,
+					   border,
+					   fg_pixel, bg_pixel)) == 0)
+
+		err_mess(FAILICON, NULL);
+
+	/* Set up shaped windows */
+	/* Gives the appicon a border so you can grab and move it. */
+	if ((pixmask = XCreateBitmapFromData(display,
+					     win,
+					     mask_bits,
+					     mask_width,
+					     mask_height)) == 0)
+		err_mess(FAILXPM, NULL);
+
+	XShapeCombineMask(display, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
+	XShapeCombineMask(display, iconwin, ShapeBounding, 0, 0, pixmask, ShapeSet);
+
+	/* Convert in pixmaps from .xpm includes. */
+	getPixmaps();
+
+	/* Interclient Communication stuff */
+	/* Appicons don't work with out this stuff */
+	SetWmHints();
+	SetClassHints();
+
+	XSetWMNormalHints(display, win, &xsizehints);
+
+	/* Tell window manager what the title bar name is. We never see */
+	/* this anyways in the WithdrawnState      */
+	if (XStringListToTextProperty(&app_name, 1, &app_name_atom) == 0)
+		err_mess(FAILWNAM, app_name);
+
+	XSetWMName(display, win, &app_name_atom);
+
+	/* Create Graphic Context */
+	if ((gc = XCreateGC(display, win, (GCForeground | GCBackground),
+			    &xgcValues)) == NULL)
+		err_mess(FAILGC, NULL);
+
+	/* XEvent Masks. We want both window to process X events */
+	XSelectInput(display, win,
+		     ExposureMask |
+		     ButtonPressMask |
+		     ButtonReleaseMask | /* added ButtonReleaseMask *charkins*/
+		     PointerMotionMask |
+		     StructureNotifyMask |
+		     LeaveWindowMask);
+
+	XSelectInput(display, iconwin,
+		     ExposureMask |
+		     ButtonPressMask |
+		     ButtonReleaseMask | /* added ButtonReleaseMask *charkins*/
+		     PointerMotionMask |
+		     StructureNotifyMask |
+		     LeaveWindowMask);
+
+	/* Store the 'state' of the application for restarting */
+	XSetCommand(display, win, argv, argc);
+
+	/* Window won't ever show up until it is mapped.. then drawn after a 	*/
+	/* ConfigureNotify */
+	XMapWindow(display, win);
+
+	/* Initialize Tooltip Support */
+	initTime();
+	initTooltip();
+
+	/* X Event Loop */
+	while (1) {
+		while (XPending(display) || nTooltipTimer == -1) {
+			XNextEvent(display, &report);
+
+			switch (report.type) {
+			case Expose:
+				if (report.xexpose.count != 0)
+					break;
+
+				if (Config.Verbose)
+					fprintf(stdout, "Event: Expose\n");
+
+				redraw();
+				break;
+
+			case ConfigureNotify:
+				if (Config.Verbose)
+					fprintf(stdout, "Event: ConfigureNotify\n");
+
+				redraw();
+				break;
+
+			case MotionNotify:
+				if (hasTooltipSupport()) {
+					if (!hasTooltip()) {
+						nTooltipTimer = currentTimeMillis();
+						nTooltipX = report.xbutton.x;
+						nTooltipY = report.xbutton.y;
+						nTooltipButton = whichButton(report.xbutton.x, report.xbutton.y);
+					} else {
+						int nButton = whichButton(report.xbutton.x, report.xbutton.y);
+						if (nButton != nTooltipButton) {
+							hideTooltip();
+							nTooltipTimer = -1;
+							nTooltipX = report.xbutton.x;
+							nTooltipY = report.xbutton.y;
+							nTooltipButton = nButton;
+							showTooltip(nTooltipButton, nTooltipX, nTooltipY);
+						}
+					}
+				}
+				break;
+
+			case LeaveNotify:
+				if (Config.Verbose)
+					fprintf(stdout, "Event: LeaveNotify\n");
+
+				if (hasTooltip()) {
+					hideTooltip();
+					nTooltipHideTimer = currentTimeMillis();
+				}
+				nTooltipTimer = -1;
+				break;
+
+			case ButtonPress:	/* draw button pressed, don't launch *charkins*/
+				if (hasTooltip()) {
+					hideTooltip();
+					nTooltipHideTimer = currentTimeMillis();
+				}
+
+				switch (report.xbutton.button) {
+				case Button1:
+					N = whichButton(report.xbutton.x, report.xbutton.y);
+					if ((N >= 0) && (N <= NUMB_OF_APPS)) {
+						button_pressed = N + LMASK;
+						redraw();
+					}
+
+					if (Config.Verbose)
+						fprintf(stdout, "Button 1:x=%d y=%d N=%d\n",
+							report.xbutton.x, report.xbutton.y, N+LMASK);
+					break;
+
+				case Button2:
+					if (!Config.mmouse) {
+						N = whichButton(report.xbutton.x, report.xbutton.y);
+						if ((N >= 0) && (N <= NUMB_OF_APPS)) {
+							button_pressed = N + MMASK;
+							redraw();
+						}
+
+						if (Config.Verbose)
+							fprintf(stdout, "Button 2:x=%d y=%d N=%d\n",
+								report.xbutton.x, report.xbutton.y, N+MMASK);
+					}
+					break;
+
+				case Button3:
+					N = whichButton(report.xbutton.x, report.xbutton.y);
+					if ((N >= 0) && (N <= NUMB_OF_APPS)) {
+						button_pressed = N + RMASK;
+						redraw();
+					}
+
+					if (Config.Verbose)
+						fprintf(stdout, "Button 3:x=%d y=%d N=%d\n",
+							report.xbutton.x, report.xbutton.y, N+RMASK);
+					break;
+				}
+				break;
+
+			case ButtonRelease:   /* launch app here if still over button *charkins*/
+				switch (report.xbutton.button) {
+				case Button1:
+					N = whichButton(report.xbutton.x, report.xbutton.y);
+					if ((N >= 0) && (N <= NUMB_OF_APPS) && (N == button_pressed))
+						RunAppN(N + LMASK);
+
+					button_pressed = -1;
+					redraw();
+
+					if (Config.Verbose)
+						fprintf(stdout, "Button 1:x=%d y=%d N=%d\n",
+							report.xbutton.x, report.xbutton.y, N+LMASK);
+					break;
+
+				case Button2:
+					if (!Config.mmouse) {
+						N = whichButton(report.xbutton.x, report.xbutton.y);
+						if ((N >= 0) && (N <= NUMB_OF_APPS) && (N == button_pressed))
+							RunAppN(N + MMASK);
+
+						button_pressed = -1;
+						redraw();
+
+						if (Config.Verbose)
+							fprintf(stdout, "Button 2:x=%d y=%d N=%d\n",
+								report.xbutton.x, report.xbutton.y, N+MMASK);
+					}
+					break;
+
+				case Button3:
+					N = whichButton(report.xbutton.x, report.xbutton.y);
+					if ((N >= 0) && (N <= NUMB_OF_APPS) && (N == button_pressed))
+						RunAppN(N + RMASK);
+
+					button_pressed = -1;
+					redraw();
+
+					if (Config.Verbose)
+						fprintf(stdout, "Button 3:x=%d y=%d N=%d\n",
+							report.xbutton.x, report.xbutton.y, N+RMASK);
+					break;
+				}
+				break;
+
+			case DestroyNotify:
+				if (Config.Verbose)
+					fprintf(stdout, "Bye\n");
+
+				destroyTooltip();
+				XFreeGC(display, gc);
+				XDestroyWindow(display, win);
+				XDestroyWindow(display, iconwin);
+				XCloseDisplay(display);
+				exit(0);
+				break;
+			}
+		}
+
+		usleep(50000);
+		nNow = currentTimeMillis();
+		if (nTooltipTimer != -1 &&
+		    ((nNow > nTooltipTimer + nTooltipShowDelay) ||
+		     (nNow < nTooltipHideTimer + nTooltipReshowDelay))) {
+			showTooltip(nTooltipButton, nTooltipX, nTooltipY);
+			nTooltipTimer = -1;
+		}
 	}
-	if ( Config.Verbose ) fprintf(stdout,"Event: Expose\n");	
-	redraw();
-	break;      
-
-      case ConfigureNotify:
-	if ( Config.Verbose ) fprintf(stdout,"Event: ConfigureNotify\n");	
-	redraw();
-	break;
-
-      case MotionNotify:
-	if (hasTooltipSupport()) {
-	  if (!hasTooltip()) {
-	    nTooltipTimer= currentTimeMillis();
-	    nTooltipX= report.xbutton.x;
-	    nTooltipY= report.xbutton.y;
-	    nTooltipButton= whichButton(report.xbutton.x, report.xbutton.y);
-	  } else {
-	    int nButton = whichButton(report.xbutton.x, report.xbutton.y);
-	    if (nButton != nTooltipButton) {
-	      hideTooltip();
-	      nTooltipTimer= -1;
-	      nTooltipX = report.xbutton.x;
-	      nTooltipY = report.xbutton.y;
-	      nTooltipButton = nButton;
-	      showTooltip(nTooltipButton, nTooltipX, nTooltipY);
-	    }
-	  }
-	}
-	break;
-      
-      case LeaveNotify:
-	if ( Config.Verbose ) fprintf(stdout,"Event: LeaveNotify\n");	
-	if (hasTooltip()) {
-	  hideTooltip();
-	  nTooltipHideTimer= currentTimeMillis();
-	}
-	nTooltipTimer= -1;
-	break;
-
-      case ButtonPress:	/* draw button pressed, don't launch *charkins*/
-	if (hasTooltip()) {
-	  hideTooltip();
-	  nTooltipHideTimer= currentTimeMillis();
-	}	switch (report.xbutton.button) {
-	case Button1:
-	  N = whichButton(report.xbutton.x, report.xbutton.y );
-	  if ( (N >= 0) && (N <= NUMB_OF_APPS) ) {
-	    button_pressed = N + LMASK;
-	    redraw();
-	  }
-
-	  if ( Config.Verbose ) 
-	    fprintf(stdout,"Button 1:x=%d y=%d N=%d\n", 
-		    report.xbutton.x, report.xbutton.y, N+LMASK);	
-
-	  break;
-	case Button2:
-	  if (Config.mmouse) {
-	    N = whichButton(report.xbutton.x, report.xbutton.y );
-	    if ( (N >= 0) && (N <= NUMB_OF_APPS) ) {
-	      button_pressed = N + MMASK;
-	      redraw();
-	    }
-
-	    if ( Config.Verbose ) 
-	      fprintf(stdout,"Button 2:x=%d y=%d N=%d\n", 
-		      report.xbutton.x, report.xbutton.y, N+MMASK);
-
-	  }
-	  break;
-	case Button3:
-	  N = whichButton(report.xbutton.x, report.xbutton.y );
-	  if ( (N >= 0) && (N <= NUMB_OF_APPS) ) {
-	    button_pressed = N + RMASK;
-	    redraw();
-	  }
-
-	  if ( Config.Verbose ) 
-	    fprintf(stdout,"Button 3:x=%d y=%d N=%d\n", 
-		    report.xbutton.x, report.xbutton.y, N+RMASK);
-
-	  break;
-	}
-	break;
-      case ButtonRelease:   /* launch app here if still over button *charkins*/
-	switch (report.xbutton.button) {
-	case Button1:
-	  N = whichButton(report.xbutton.x, report.xbutton.y );
-	  if ( (N >= 0) && (N <= NUMB_OF_APPS) && (N == button_pressed))
-	    RunAppN( N + LMASK);
-	  button_pressed=-1;
-	  redraw();
-
-	  if ( Config.Verbose ) 
-	    fprintf(stdout,"Button 1:x=%d y=%d N=%d\n", 
-		    report.xbutton.x, report.xbutton.y, N+LMASK);	
-
-	  break;
-	case Button2:
-	  if (Config.mmouse) {
-	    N = whichButton(report.xbutton.x, report.xbutton.y );
-	    if ( (N >= 0) && (N <= NUMB_OF_APPS) && (N == button_pressed))
-	      RunAppN( N + MMASK);
-	    button_pressed=-1;
-	    redraw();
-
-	    if ( Config.Verbose ) 
-	      fprintf(stdout,"Button 2:x=%d y=%d N=%d\n", 
-		      report.xbutton.x, report.xbutton.y, N+MMASK);
-
-	  }
-	  break;
-	case Button3:
-	  N = whichButton(report.xbutton.x, report.xbutton.y );
-	  if ( (N >= 0) && (N <= NUMB_OF_APPS) && (N == button_pressed))
-	    RunAppN( N + RMASK);
-	  button_pressed=-1;
-	  redraw();
-
-	  if ( Config.Verbose ) 
-	    fprintf(stdout,"Button 3:x=%d y=%d N=%d\n", 
-		    report.xbutton.x, report.xbutton.y, N+RMASK);
-
-	  break;
-	}
-	break;
-      case DestroyNotify:
-
-	if ( Config.Verbose ) fprintf(stdout, "Bye\n");
-
-	destroyTooltip();
-	XFreeGC(display, gc);
-	XDestroyWindow(display,win);
-	XDestroyWindow(display,iconwin);
-	XCloseDisplay(display);
-	exit(0);
-	break;
-      }
-    }
-
-    usleep(50000);
-    nNow = currentTimeMillis();
-    if ( nTooltipTimer != -1 && 
-	 ( (nNow > nTooltipTimer + nTooltipShowDelay) || (nNow < nTooltipHideTimer + nTooltipReshowDelay) ) ) {
-      showTooltip(nTooltipButton, nTooltipX, nTooltipY);
-      nTooltipTimer = -1;
-    }
-    
-  }
-
-  return (0);
-}/***********************************************************************/
+
+	return (0);
+}
+/***********************************************************************/
 
 /***********************************************************************
  *   redraw
  *
  *	 Map the button region coordinates.
  *
- *   Draw the appropriate number of buttons on the 'visible' Pixmap 
+ *   Draw the appropriate number of buttons on the 'visible' Pixmap
  *   using data from the 'buttons' pixmap.
  *
  *   Then, copy the 'visible' pixmap to the two windows ( the withdrawn
  *   main window and the icon window which is the main window's icon image.)
  ***********************************************************************/
 void redraw() {
-  int n;
-  int i,j;
-  int dest_x, dest_y;
-  int space;
-  int offset;
-  int bsize = 18;
-
-  if ( Config.Verbose ) fprintf(stdout,"In Redraw()\n");	
-  space = 0;
-  offset = 5;
-  XCopyArea(display, template.pixmap, visible.pixmap, gc, 0, 0,
-	    template.attributes.width, template.attributes.height, 0, 0 ); 
- 
-  for ( j=0; j < 3; j++ ) {
-    for ( i=0; i < 3; i++ ) {
-      n = i + j * 3;
-      dest_x = i*(bsize + space) + offset + space;
-      dest_y = j*(bsize + space) + offset + space;
-      
-      /* Define button mouse coords */
-      button_region[n].x = dest_x;
-      button_region[n].y = dest_y;
-      button_region[n].i = dest_x + bsize - 1;
-      button_region[n].j = dest_y + bsize - 1; 
-      
-      /* Copy button images for valid apps */
-      if (  (n + 1) <= NUMB_OF_APPS ) {
-        XCopyArea(display, buttons.pixmap, visible.pixmap, gc, 
-	          i * bsize, j * bsize, bsize, bsize, dest_x, dest_y);
-      } 
-    }
-  }
-
-  if ( button_pressed>0 ) {	/* draw pressed button *charkins*/
-    if(button_pressed>RMASK) button_pressed-=RMASK;
-    else if(button_pressed>MMASK) button_pressed-=MMASK;
-    else if(button_pressed>LMASK) button_pressed-=LMASK;
-    i = (button_pressed-1) % 3;	/* get col of button */
-    j = (button_pressed-1) / 3;	/* get row of button */
-    dest_x = i * (bsize + space) + offset + space;
-    dest_y = j * (bsize + space) + offset + space;
-    XSetForeground(display, gc, bg_pixel);
-    XDrawLine(display, visible.pixmap, gc,
-	      dest_x+1, dest_y+bsize-1, dest_x+bsize-1, dest_y+bsize-1);
-    XDrawLine(display, visible.pixmap, gc,
-	      dest_x+bsize-1, dest_y+bsize-1, dest_x+bsize-1, dest_y+1);
-    XSetForeground(display, gc, fg_pixel);
-    XDrawLine(display, visible.pixmap, gc,
-	      dest_x, dest_y, dest_x+bsize-2, dest_y);
-    XDrawLine(display, visible.pixmap, gc,
-	      dest_x, dest_y, dest_x, dest_y+bsize-2);
-  } /*charkins*/
-  
-  flush_expose( win ); 
-  XCopyArea(display, visible.pixmap, win, gc, 0, 0,
-	    visible.attributes.width, visible.attributes.height, 0, 0 ); 
-  flush_expose( iconwin ); 
-  XCopyArea(display, visible.pixmap, iconwin, gc, 0, 0,
-	    visible.attributes.width, visible.attributes.height, 0, 0 );
-
-}/***********************************************************************/
+	int n, i, j, dest_x, dest_y, space, offset, bsize = 18;
+
+	if (Config.Verbose)
+		fprintf(stdout, "In Redraw()\n");
+
+	space = 0;
+	offset = 5;
+	XCopyArea(display, template.pixmap, visible.pixmap, gc, 0, 0,
+		  template.attributes.width, template.attributes.height, 0, 0);
+
+	for (j = 0; j < 3; j++) {
+		for (i = 0; i < 3; i++) {
+			n = i + j * 3;
+			dest_x = i * (bsize + space) + offset + space;
+			dest_y = j * (bsize + space) + offset + space;
+
+			/* Define button mouse coords */
+			button_region[n].x = dest_x;
+			button_region[n].y = dest_y;
+			button_region[n].i = dest_x + bsize - 1;
+			button_region[n].j = dest_y + bsize - 1;
+
+			/* Copy button images for valid apps */
+			if ((n + 1) <= NUMB_OF_APPS)
+				XCopyArea(display, buttons.pixmap, visible.pixmap, gc,
+					  i * bsize, j * bsize, bsize, bsize, dest_x, dest_y);
+		}
+	}
+
+	if (button_pressed > 0) {	/* draw pressed button *charkins*/
+		if (button_pressed > RMASK)
+			button_pressed -= RMASK;
+		else if (button_pressed > MMASK)
+			button_pressed -= MMASK;
+		else if (button_pressed > LMASK)
+			button_pressed -= LMASK;
+
+		i = (button_pressed - 1) % 3;	/* get col of button */
+		j = (button_pressed - 1) / 3;	/* get row of button */
+		dest_x = i * (bsize + space) + offset + space;
+		dest_y = j * (bsize + space) + offset + space;
+		XSetForeground(display, gc, bg_pixel);
+		XDrawLine(display, visible.pixmap, gc,
+			  dest_x + 1, dest_y + bsize - 1,
+			  dest_x + bsize - 1, dest_y + bsize - 1);
+		XDrawLine(display, visible.pixmap, gc,
+			  dest_x + bsize - 1, dest_y + bsize - 1,
+			  dest_x + bsize - 1, dest_y + 1);
+		XSetForeground(display, gc, fg_pixel);
+		XDrawLine(display, visible.pixmap, gc,
+			  dest_x, dest_y, dest_x + bsize - 2, dest_y);
+		XDrawLine(display, visible.pixmap, gc,
+			  dest_x, dest_y, dest_x, dest_y + bsize - 2);
+	} /*charkins*/
+
+	flush_expose(win);
+	XCopyArea(display, visible.pixmap, win, gc, 0, 0,
+		  visible.attributes.width, visible.attributes.height, 0, 0);
+	flush_expose(iconwin);
+	XCopyArea(display, visible.pixmap, iconwin, gc, 0, 0,
+		  visible.attributes.width, visible.attributes.height, 0, 0);
+}
+/***********************************************************************/
 
 /***********************************************************************
  *  whichButton
@@ -465,93 +478,102 @@ void redraw() {
  *  Return the button that at the x,y coordinates. The button need not
  *  be visible ( drawn ). Return -1 if no button match.
  ***********************************************************************/
-int whichButton( int x, int y ) {
-  int index;
-
-  for ( index=0; index < NUMB_OF_APPS; index++ ) {
-    if ( x >= button_region[index].x &&
-	 x <= button_region[index].i &&
-	 y >= button_region[index].y &&
-	 y <= button_region[index].j  ) {
-      return( index + 1);
-    }
-  }
-  return(-1);
-}/***********************************************************************/
+int whichButton(int x, int y)
+{
+	int index;
+
+	for (index = 0; index < NUMB_OF_APPS; index++) {
+		if (x >= button_region[index].x &&
+		    x <= button_region[index].i &&
+		    y >= button_region[index].y &&
+		    y <= button_region[index].j)
+			return(index + 1);
+	}
+	return -1;
+}
+/***********************************************************************/
 
 
 /***********************************************************************
  *   getPixmaps
- *    
+ *
  *   Load XPM data into X Pixmaps.
- *  
+ *
  *   Pixmap template contains the untouched window backdrop image.
  *   Pixmap visible is the template pixmap with buttons drawn on it.
  *          -- what is seen by the user.
  *   Pixmap buttons holds the images for individual buttons that are
  *          later copied onto Pixmap visible.
  ***********************************************************************/
-void getPixmaps() {
-  int loaded = 0;
-  template.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
-  visible.attributes.valuemask  |= (XpmReturnPixels | XpmReturnExtensions);
-  buttons.attributes.valuemask  |= (XpmReturnPixels | XpmReturnExtensions);
-  
-
-  if (Config.Verbose) fprintf(stdout, "In getPixmaps\n");
-  /* Template Pixmap. Never Drawn To. */
-  if ( XpmCreatePixmapFromData(	display, rootwin, backdrop_xpm,
-				&template.pixmap, &template.mask, 
-				&template.attributes) != XpmSuccess )
-    err_mess(FAILTMPL, NULL);
-
-  /* Visible Pixmap. Copied from template Pixmap and then drawn to. */
-  if ( XpmCreatePixmapFromData(	display, rootwin, backdrop_xpm,
-				&visible.pixmap, &visible.mask, 
-				&visible.attributes) != XpmSuccess )
-    err_mess(FAILVIS, NULL);
-  
-  /* Button Pixmap.  */
-  if ( access( Config.buttonfile, R_OK  ) == 0 ) {
-    /* load buttons from file */
-    if ( XpmReadFileToPixmap( display, rootwin, Config.buttonfile,
-      			      &buttons.pixmap, &buttons.mask, 
-			      &buttons.attributes) != XpmSuccess ) {
-      err_mess(FAILBUT, NULL); 
-    } else {
-      loaded = 1;
-    }
-  }
-  if (! loaded) { 
-    /* Use Builtin Button Pixmap.  */
-    if (Config.Verbose) fprintf(stdout, "Using builtin buttons pixmap\n");
-    if ( XpmCreatePixmapFromData( display, rootwin, buttons_xpm,
-				  &buttons.pixmap, &buttons.mask, 
-				  &buttons.attributes) != XpmSuccess )
-      err_mess(FAILBUT, NULL); 
-  }
-  if (Config.Verbose) fprintf(stdout, "Leaving getPixmaps\n");
-
-}/*********************************************************************/
-
-void SetWmHints() {
-  XWMHints *xwmhints;
-
-  xwmhints = XAllocWMHints();
-  xwmhints->flags = WindowGroupHint | IconWindowHint | StateHint;	
-  xwmhints->icon_window = iconwin;
-  xwmhints->window_group = win;
-  xwmhints->initial_state = WithdrawnState;  
-  XSetWMHints( display, win, xwmhints );
+void getPixmaps()
+{
+	int loaded = 0;
+	template.attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);
+	visible.attributes.valuemask  |= (XpmReturnPixels | XpmReturnExtensions);
+	buttons.attributes.valuemask  |= (XpmReturnPixels | XpmReturnExtensions);
+
+	if (Config.Verbose)
+		fprintf(stdout, "In getPixmaps\n");
+
+	/* Template Pixmap. Never Drawn To. */
+	if (XpmCreatePixmapFromData(display, rootwin, backdrop_xpm,
+				&template.pixmap, &template.mask,
+				&template.attributes) != XpmSuccess)
+		err_mess(FAILTMPL, NULL);
+
+	/* Visible Pixmap. Copied from template Pixmap and then drawn to. */
+	if (XpmCreatePixmapFromData(display, rootwin, backdrop_xpm,
+				&visible.pixmap, &visible.mask,
+				&visible.attributes) != XpmSuccess)
+		err_mess(FAILVIS, NULL);
+
+	/* Button Pixmap.  */
+	if (access(Config.buttonfile, R_OK) == 0) {
+		/* load buttons from file */
+		if (XpmReadFileToPixmap(display, rootwin, Config.buttonfile,
+					&buttons.pixmap, &buttons.mask,
+					&buttons.attributes) != XpmSuccess)
+			err_mess(FAILBUT, NULL);
+		else
+			loaded = 1;
+	}
+
+	if (!loaded) {
+		/* Use Builtin Button Pixmap.  */
+		if (Config.Verbose)
+			fprintf(stdout, "Using builtin buttons pixmap\n");
+
+		if (XpmCreatePixmapFromData(display, rootwin, buttons_xpm,
+					    &buttons.pixmap, &buttons.mask,
+					    &buttons.attributes) != XpmSuccess)
+			err_mess(FAILBUT, NULL);
+	}
+
+	if (Config.Verbose)
+		fprintf(stdout, "Leaving getPixmaps\n");
+
+}
+/*********************************************************************/
+
+void SetWmHints()
+{
+	XWMHints *xwmhints;
+
+	xwmhints = XAllocWMHints();
+	xwmhints->flags = WindowGroupHint | IconWindowHint | StateHint;
+	xwmhints->icon_window = iconwin;
+	xwmhints->window_group = win;
+	xwmhints->initial_state = WithdrawnState;
+	XSetWMHints(display, win, xwmhints);
 	XFree(xwmhints);
 	xwmhints = NULL;
 }
 
-void SetClassHints() {
-  XClassHint xclasshint;
+void SetClassHints()
+{
+	XClassHint xclasshint;
 
-  xclasshint.res_name = "wmbutton";
-  xclasshint.res_class = "Wmbutton";
-  XSetClassHint( display, win, &xclasshint );
+	xclasshint.res_name = "wmbutton";
+	xclasshint.res_class = "Wmbutton";
+	XSetClassHint(display, win, &xclasshint);
 }
-
diff --git a/wmbutton.h b/wmbutton.h
index 178f896..b653e7d 100644
--- a/wmbutton.h
+++ b/wmbutton.h
@@ -2,11 +2,11 @@
 /* Last Modified 3/27/04 */
 
 /******  Include Files ***************************************************/
-#include <Xlib.h>
-#include <Xutil.h>
-#include <xpm.h>
-#include <extensions/shape.h>
-#include <keysym.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/xpm.h>
+#include <X11/extensions/shape.h>
+#include <X11/keysym.h>
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
@@ -16,11 +16,11 @@
 
 /******  Define Config File Info  ***************************************/
 #define CONFFILENAME  "/.wmbutton"   /* Default conf filename $HOME/.wmbutton */
+#define CONFIGGLOBAL "/etc/wmbutton.conf" /* system configuration */
 #define BUTTONFILENAME "/.wmbutton.xpm"
 
-/******  Version / Release Number ***************************************/
-#define VER           0     /* Version Number */     
-#define REL           6     /* Release Number */
+/******  Version Number *************************************************/
+#define VER_STR       "0.7.0"     /* Version Number String */
 
 /******  Define Error Codes *********************************************/
 #define FAILDISP      20
@@ -36,7 +36,6 @@
 
 /******   Define Other Options  ****************************************/
 #define VERB          0      /* Enable=1, Disable=0: Debugging (verbose) Mode*/
-#define MIDMOUSE      1      /* Define Middle Mouse functionality */
 #define LMASK         0      /* left button mask: run app # mask + button #*/
 #define MMASK         10     /* middle button mask: run app # mask + button #*/
 #define RMASK         20     /* right button mask: run app # mask + button #*/
@@ -44,7 +43,7 @@
 
 #define EOLN '\n'	     /* Defines the new line character */
 #define SIZE1 20	     /* Defines the increment to increase the */
-			     /*   string by until a newline of EOF is found */
+			     /* string by until a newline of EOF is found */
 
 /******   Defines for Tool Tips  ***************************************/
 #define TOOLTIP_SUPPORT      1
@@ -67,41 +66,41 @@
 /******  Typedefs  *******************************************/
 
 struct Config_t {
-  char *configfile;
-  char *buttonfile;
-  char *Geometry_str;
-  char *Display_str;
-  int mmouse;
-  int Verbose;
-  char* szTooltipFont;
-  int bTooltipSwapColors;
-  int bTooltipDisable;
+	char *configfile;
+	char *buttonfile;
+	char *Geometry_str;
+	char *Display_str;
+	int mmouse;
+	int Verbose;
+	char* szTooltipFont;
+	int bTooltipSwapColors;
+	int bTooltipDisable;
 };
 
 /******  Function Prototyes  *******************************************/
-void RunAppN(int app);             // function to run app N as found in conf file
-char *Parse(int app);              // parse data in config file
+void RunAppN(int app);             /* function to run app N as found in conf file */
+char *Parse(int app);              /* parse data in config file */
 void parseargs(int argc, char **argv);
-char *readln(FILE *fp);            // read line from file, return pointer to it
-void err_mess(int err, char *str); // Error Handling Routine
-void show_usage(void);            // show usage message to stderr
-int  flush_expose(Window w);
+char *readln(FILE *fp);            /* read line from file, return pointer to it */
+void err_mess(int err, char *str); /* Error Handling Routine */
+void show_usage(void);             /* show usage message to stderr */
+int flush_expose(Window w);
 
 
 /******  Tooltip Function Prototypes  **********************************/
-void initTooltip();
-void destroyTooltip ();
-int hasTooltipSupport ();
-void showTooltip (int nButton, int nMouseX, int nMouseY);
-void hideTooltip ();
-int hasTooltip ();
-void drawTooltipBalloon (Pixmap pix, GC gc, int x, int y, int w, int h, int side);
-Pixmap createTooltipPixmap (int width, int height, int side, Pixmap *mask);
-
-void initTime ();
-long currentTimeMillis ();
-void getWindowOrigin (Window w, int* nX, int* nY);
-void getButtonLocation (int nButton, int* nLocationX, int* nLocationY);
-char *getButtonAppNames (int nButton);
+void initTooltip(void);
+void destroyTooltip(void);
+int hasTooltipSupport(void);
+void showTooltip(int nButton, int nMouseX, int nMouseY);
+void hideTooltip(void);
+int hasTooltip(void);
+void drawTooltipBalloon(Pixmap pix, GC gc, int x, int y, int w, int h, int side);
+Pixmap createTooltipPixmap(int width, int height, int side, Pixmap *mask);
+
+void initTime(void);
+long currentTimeMillis(void);
+void getWindowOrigin(Window w, int *nX, int *nY);
+void getButtonLocation(int nButton, int *nLocationX, int *nLocationY);
+char *getButtonAppNames(int nButton);
 
 /**********************************************************************/

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



More information about the Pkg-wmaker-commits mailing list