diff -Naur --exclude=.deps --exclude=config.log --exclude=ChangeLog --exclude=Makefile --exclude=config.status libX11-1.0.3/src/Makefile.in libX11-1.0.3-patched/src/Makefile.in
--- libX11-1.0.3/src/Makefile.in	2006-11-22 13:05:55.000000000 +0100
+++ libX11-1.0.3-patched/src/Makefile.in	2006-11-22 12:21:03.000000000 +0100
@@ -259,7 +259,7 @@
 KEYSYMDEF = @KEYSYMDEF@
 LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
+LIBS = @LIBS@ -lerdm -leripc
 LIBTOOL = @LIBTOOL@
 LIB_MAN_DIR = @LIB_MAN_DIR@
 LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
diff -Naur --exclude=.deps --exclude=config.log --exclude=ChangeLog --exclude=Makefile --exclude=config.status libX11-1.0.3/src/XlibInt.c libX11-1.0.3-patched/src/XlibInt.c
--- libX11-1.0.3/src/XlibInt.c	2006-06-30 04:41:23.000000000 +0200
+++ libX11-1.0.3-patched/src/XlibInt.c	2006-12-03 10:46:05.000000000 +0100
@@ -50,6 +50,10 @@
 #include <direct.h>
 #endif
 
+#if 1
+#include "iliad_refresh.c"
+#endif
+
 #ifdef XTHREADS
 #include "locking.h"
 
@@ -1628,6 +1632,9 @@
 {
     register unsigned long	newseq, lastseq;
 
+#if 1
+	iliad_refresh("_XSetLastRequestRead");
+#endif
     lastseq = dpy->last_request_read;
     /*
      * KeymapNotify has no sequence number, but is always guaranteed
diff -Naur --exclude=.deps --exclude=config.log --exclude=ChangeLog --exclude=Makefile --exclude=config.status libX11-1.0.3/src/iliad_refresh.c libX11-1.0.3-patched/src/iliad_refresh.c
--- libX11-1.0.3/src/iliad_refresh.c	1970-01-01 01:00:00.000000000 +0100
+++ libX11-1.0.3-patched/src/iliad_refresh.c	2006-12-03 10:45:47.000000000 +0100
@@ -0,0 +1,173 @@
+/*
+ * iliad_refresh.c
+ *
+ * gcc -c iliad_refresh.c 
+ *
+ * gcc -o program program_main.c iliad_refresh.o -lerdm -leripc
+ * 
+ * History:
+ *         18/11/06 Creation
+ *         30/11/06 Add debug information. Fix FDRD define. Move
+ *                  erDm/erIpc to child. Close unneeded opened files
+ *                  on child.
+ *          3/12/06 Add more credits. Add the possibility of using Full
+ *                  refresh. Add the configuration file iliad_refresh.conf
+ *                  Stop the busy led after refresh.
+ *
+ * Author: Dario Rodriguez dario@softhome.net, darirf@yahoo.es
+ *         Iliad interfacing code from Scotty1024's posts on MobileRead.com
+ * This program is in the public domain
+ */
+
+/* header files */
+#include <stdio.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#ifndef FIONREAD
+#include <sys/filio.h>
+#endif
+#include <liberdm/erdm.h>
+#include <liberipc/eripcviewer.h>
+#include <liberipc/eripctoolbar.h>
+#include <liberipc/eripcbusyd.h>
+
+
+#define CONF_FILE "iliad_refresh.conf"
+
+#if 0
+#include <stdio.h>
+#define DEBUG_PRINTF(a) printf a , fflush(stdout)
+#define DUMMY_LIB
+#else
+#define DEBUG_PRINTF(a)
+#endif
+
+/* constants */
+#define FDRD 0
+#define FDWR 1
+
+/* globals */
+erClientChannel_t erbusyChannel;
+erClientChannel_t ertoolbarChannel;
+
+/* prototypes of local functions */
+static void iliad_config_read(char *conf_file, int *is_full,  long *default_timeout);
+
+/* exported functions */
+static void
+iliad_refresh(char *DebugText)
+{
+	static int init=0;
+	static int fds[2];
+	if(!init) {
+		init=1;
+		// communication with the child
+		pipe(fds);
+		if(fork()==0) {
+			char c;
+			int nc;
+			int pending=0;
+			fd_set set;
+			struct timeval tm;
+			int is_full=0;
+			long default_timeout=100; 
+			iliad_config_read(CONF_FILE,&is_full,&default_timeout);
+#ifndef DUMMY_LIB		
+			// Turn off busy LED
+		        erIpcStartClient(ER_BUSYD_CHANNEL, &erbusyChannel);
+		        busySetBusy(erbusyChannel, ccBusyState_Off);
+			// set-up comms with toolbar
+			erIpcStartClient(ER_TOOLBAR_CHANNEL, &ertoolbarChannel);
+			tbSelectIconSet(ertoolbarChannel, ER_PDF_VIEWER_UA_ID);
+			tbClearIconSet(ertoolbarChannel, ER_PDF_VIEWER_UA_ID);
+			// turn off trashcan
+			tbAppendPlatformIcon(ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_trashcan, -1);
+			tbSetStatePlatformIcon(ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_trashcan, iconState_grey );
+			// Enable keyboard
+			tbAppendPlatformIcon(  ertoolbarChannel, ER_PDF_VIEWER_UA_ID, iconID_keyboard, -1);
+#endif
+			close(fds[FDWR]);
+			// Close unneeded fds
+			for(nc=3;nc<1024;nc++) {
+				if(nc==fds[FDRD])
+					continue;
+				close(nc);
+			}
+			// Main loop
+			while(1) {
+				FD_ZERO(&set);
+				FD_SET(fds[FDRD],&set);
+				if(pending) {
+					tm.tv_sec=default_timeout/1000;
+					tm.tv_usec=(default_timeout%1000)*1000;
+				} else {
+					tm.tv_sec=3600;
+					tm.tv_usec=0;
+				}
+				if(select(fds[FDRD]+1,&set,NULL,NULL,&tm)!=0) { 
+					pending=1;
+					// check if parent closed pipe (or died)
+					nc=0;
+					if(ioctl(fds[FDRD],FIONREAD,&nc)==0 && nc==0) {
+						DEBUG_PRINTF(("iliad_refresh: %s: close\n",DebugText));
+						close(fds[FDRD]);
+						exit (0);
+					}
+					read(fds[FDRD],&c,1);
+					DEBUG_PRINTF(("iliad_refresh: %s: transaction\n",DebugText));
+				} else if(pending) {
+					pending=0;
+#ifndef DUMMY_LIB					
+					// code to force an update
+					dmDisplay(dmCmdPriorUrgent, (is_full!=0)?dmQFull:dmQTyping); 
+		        		busySetBusy(erbusyChannel, ccBusyState_Off);
+#endif
+					DEBUG_PRINTF(("iliad_refresh: %s: UPDATE\n",DebugText));
+				}
+			}
+			exit(0);
+		} else {
+			close(fds[FDRD]);
+		}
+	}
+	write(fds[FDWR],".",1);
+	DEBUG_PRINTF(("iliad_refresh: %s: function trap\n",DebugText));
+}
+
+static void 
+iliad_config_read(char *conf_file, int *is_full,  long *default_timeout)
+{
+	int fd;
+	int len;
+	char buf[64]={0};
+	static char str_full[]={"Full "};
+	static char str_typing[]={"Typing "};
+	if((fd=open(conf_file,O_RDONLY))<0) {
+		if((fd=open(conf_file,O_WRONLY|O_TRUNC|O_CREAT,0777))>=0) {
+			len=sprintf(buf,"%s%li\n",(*is_full!=0)?str_full:str_typing,*default_timeout);
+			write(fd,buf,len);
+			close(fd);
+
+		}
+
+	} else {
+		read(fd,buf,sizeof(buf)-1);
+		if(memcmp(buf,str_full,sizeof(str_full)-1)==0) {
+			*is_full=1;
+			*default_timeout=atol(buf+sizeof(str_full)-1);
+		} else if(memcmp(buf,str_typing,sizeof(str_typing)-1)==0) {
+			*is_full=0;
+			*default_timeout=atol(buf+sizeof(str_typing)-1);
+		} else {
+			// we ignore configuration errors.
+			fprintf(stderr,"%s: unrecognized refresh type: %s\n",conf_file,buf); 
+		}
+		close(fd);
+	}
+	if(*default_timeout<=0)
+		*default_timeout=100;
+}
