[gpm]on screen clock

Petr Baudis pasky@pasky.ji.cz
Tue, 30 Oct 2001 13:09:00 +0100


--bCsyhTFzCvuiizWE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

> > What do you think about this patch? It prints the current time when the
> > mouse cursor is moved in the upper left corner of the screen.
> Looks cool ;-). However, there is some polution in the upper right
> (the clock is there, not in the upper left ;) corner, when moving
> with mouse in weird way hiding/unhiding the clock. Also, when i switch
> consoles while clock is on and i move with the mouse, the clock will
> get stuck on the last one. I attached rediffed patch, which fixes this
> two bugs and applies cleanly onto gpm-1.19.6.
Oops, the patch was broken in a nasty way, and restoring of screen content
didn't work properly ;). Apply attached patch on the top of that, it should
fix it :). My apologies..

-- 

				Petr "Pasky" Baudis

UN*X programmer, UN*X administrator, hobbies = IPv6, IRC
Real Users hate Real Programmers.
Public PGP key, geekcode and stuff: http://pasky.ji.cz/~pasky/

--bCsyhTFzCvuiizWE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="clockfix.diff"

diff -ru gpm-1.19.6/src/gpm.c gpm-1.19.6+clockfix/src/gpm.c
--- gpm-1.19.6/src/gpm.c	Tue Oct 30 13:06:40 2001
+++ gpm-1.19.6+clockfix/src/gpm.c	Tue Oct 30 13:03:46 2001
@@ -258,7 +258,7 @@
 	if ((fd = open("/dev/vcsa", O_RDWR)) < 1)
 	    oops("open(\"/dev/vcsa\")");
     }
-    if (restore == 2) {			/* restore the old characters */
+    if (restore == -2) {		/* restore the old characters */
 	lseek(fd, POSITION, 0);
 	write(fd, &save, sizeof(save));
     } else {				/* print the clock */
@@ -267,10 +267,12 @@
 	struct tm *tm;
 	int i, j;
 
-	if (restore == 0) {		/* save the old characters for later */
+	/* save the old characters for later */
+	if (restore == -1) {
 	    lseek(fd, POSITION, 0);
 	    read(fd, &save, sizeof(save));
-	}
+        }
+	
 	t = time(NULL);
 	tm = localtime(&t);
 	sprintf(buf0, CLOCK_FMT, tm->tm_hour, tm->tm_min);
@@ -308,7 +310,7 @@
 	display_clock(clock_printed);	/* print the clock */
 	clock_printed = event->vc;
       } else if (clock_printed == event->vc) {
-	display_clock(2);		/* restore the screen */
+	display_clock(-2);		/* restore the screen */
 	clock_printed = -1;
       }
       selection_copy(x2,y2,x2,y2,3); /* just highlight pointer */

--bCsyhTFzCvuiizWE--