GPM patch for Links on framebuffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here it is -- patch for reporting mouse movement in pixels.

When application sets bit GPM_SMOOTH in both defaultMask and eventMask,
gpm reports dx and dy in pixels, not in characters (and acknowledges it by
setting GPM_SMOOTH in event.type).

Included is also patch for framebuffer.c in links to take adventage of
this feature.

GPM-UNLINK-PID is a simple fix for bug, that gpm doesn't delete gpm.pid on
errors, thus preventing next starts of gpm.

BTW: why does gpm-1.20 have so agressive debugging messages enabled???
Libgpm on client writes on terminal, gpm daemon writes to log every
connect including the file and line in sources where is it processed.
Could it be turned off?

Mikulas
--- src/gpm.c_	Sat Jun  8 14:14:19 2002
+++ src/gpm.c	Sat Jun  8 14:51:18 2002
@@ -106,6 +106,11 @@
 static int mouse_argc[3]; /* 0 for default (unused) and two mice */
 static char **mouse_argv[3]; /* 0 for default (unused) and two mice */
 
+/* pixel-level mouse delta. Should be in event, but I don't want to break interface */
+static int smooth_dx, smooth_dy;
+
+static int number_of_smooth_clients = 0;
+
 /*===================================================================*/
 /*
  *      first, all the stuff that used to be in gpn.c (i.e., not main-loop)
@@ -317,7 +322,15 @@
 
    /* WARNING */ /* This can generate a SIGPIPE... I'd better catch it */
    MAGIC_P((write(fd,&magic, sizeof(int))));
-   write(fd,event, sizeof(Gpm_Event));
+   if (info.eventMask & info.defaultMask & GPM_SMOOTH && !m_type->absolute) {
+      Gpm_Event new = *event;
+      new.dx = smooth_dx;
+      new.dy = smooth_dy;
+      new.type |= GPM_SMOOTH;
+      write(fd,&new, sizeof(Gpm_Event));
+   } else {
+      write(fd,event, sizeof(Gpm_Event));
+   }
 
    return info.defaultMask & GPM_HARD ? res : 1; /* HARD forces pass-on */
 
@@ -503,6 +516,7 @@
 
    /* use fine delta values now, if delta is the information */
    if (!(m_type)->absolute) {
+      smooth_dx=event->dx;            smooth_dy=event->dy;
       fine_dx+=event->dx;             fine_dy+=event->dy;
       event->dx=fine_dx/opt_scale;    event->dy=fine_dy/opt_scaley;
       fine_dx %= opt_scale;           fine_dy %= opt_scaley;
@@ -511,7 +525,7 @@
    /* up and down, up and down, ... who does a do..while(0) loop ???
       and then makes a break into it... argh ! */
 
-   if (!event->dx && !event->dy && (event->buttons==oldB))
+   if (!event->dx && !event->dy && (event->buttons==oldB) && !number_of_smooth_clients)
       do { /* so to break */
          static long awaketime;
          /*
@@ -680,6 +694,7 @@
       FD_CLR(ci->fd,&readySet);
       if (cinfo[vc]->fd == ci->fd) { /* it was on top of the stack */
          cinfoPtr = cinfo[vc];
+	 if (cinfoPtr->data.eventMask & cinfoPtr->data.defaultMask & GPM_SMOOTH) number_of_smooth_clients--;
          cinfo[vc]=cinfo[vc]->next; /* pop the stack */
          free(cinfoPtr);
          return -1;
@@ -850,6 +865,8 @@
       }
       free(tty); /* at least here it's not needed anymore */
    }
+
+   if (info->data.eventMask & info->data.defaultMask & GPM_SMOOTH) number_of_smooth_clients++;
 
    /* register the connection information in the right place */
    info->next=next=cinfo[vc];
--- src/headers/gpm.h_	Sat Jun  8 13:20:25 2002
+++ src/headers/gpm.h	Sat Jun  8 14:52:35 2002
@@ -102,8 +102,15 @@
                    used event to pass over to another handler */
 
   GPM_ENTER=512,            /* enter event, user in Roi's */
-  GPM_LEAVE=1024            /* leave event, used in Roi's */
+  GPM_LEAVE=1024,           /* leave event, used in Roi's */
+
+  GPM_SMOOTH=2048,          /* if application want to receive smooth movement,
+                   it sets GPM_SMOOTH in both eventMask and defaultMask.
+                   In returned event, type GPM_SMOOTH signals that dx and dy
+		   are smooth */
 };
+
+#define GPM_HAVE_SMOOTH     /* so that apps can #ifdef for old/new version */
 
 #define Gpm_StrictSingle(type) (((type)&GPM_SINGLE) && !((type)&GPM_MFLAG))
 #define Gpm_AnySingle(type)     ((type)&GPM_SINGLE)
--- report.c_	Sat Jun  8 13:10:24 2002
+++ report.c	Sat Jun  8 13:16:05 2002
@@ -121,6 +121,7 @@
                vfprintf(stderr,text,ap);
                fprintf(stderr,"\n");
 
+               unlink(GPM_NODE_PID);
                exit(1); /*we should have a oops()function, but this works, too*/
                break;
          }
@@ -178,6 +179,7 @@
                vfprintf(stderr,text,ap);
                fprintf(stderr,"\n");
 
+               unlink(GPM_NODE_PID);
                _exit(1); /* we are the fork()-child */
                break;
          }
@@ -207,7 +209,10 @@
          vfprintf(console,text,ap);
          fprintf(console,"\n");
          
-         if(stat == GPM_STAT_OOPS) exit(1);
+         if(stat == GPM_STAT_OOPS) {
+            unlink(GPM_NODE_PID);
+            exit(1);
+	 }
 
          break;
    } /* switch for current modus */
--- framebuffer.c_	Sat Jun  8 13:27:18 2002
+++ framebuffer.c	Sat Jun  8 14:57:23 2002
@@ -35,6 +35,12 @@
 
 #include "arrow.inc"
 
+#ifdef GPM_HAVE_SMOOTH
+#define gpm_smooth GPM_SMOOTH
+#else
+#define gpm_smooth 0
+#endif
+
 #define TTY 0
 
 #ifndef USE_GPM_DX
@@ -885,8 +891,13 @@
 	}
 #else
 	if (gev.dx || gev.dy) {
-		mouse_x += gev.dx * 8;
-		mouse_y += gev.dy * 8;
+		if (!(gev.type & gpm_smooth)) {
+			mouse_x += gev.dx * 8;
+			mouse_y += gev.dy * 8;
+		} else {
+			mouse_x += gev.dx;
+			mouse_y += gev.dy;
+		}
 	}
 #endif
 	ev.ev = EV_MOUSE;
@@ -895,14 +906,14 @@
 	if (mouse_x < 0) mouse_x = 0;
 	if (mouse_y < 0) mouse_y = 0;
 
-	if (gev.dx || gev.dy) {
+	if (!gev.type & gpm_smooth && (gev.dx || gev.dy)) {
 		mouse_x = (mouse_x + 8) / 8 * 8 - 4;
 		mouse_y = (mouse_y + 8) / 8 * 8 - 4;
+		if (mouse_x >= fb_xsize) mouse_x = fb_xsize - 1;
+		if (mouse_y >= fb_ysize) mouse_y = fb_ysize - 1;
+		if (mouse_x < 0) mouse_x = 0;
+		if (mouse_y < 0) mouse_y = 0;
 	}
-	if (mouse_x >= fb_xsize) mouse_x = fb_xsize - 1;
-	if (mouse_y >= fb_ysize) mouse_y = fb_ysize - 1;
-	if (mouse_x < 0) mouse_x = 0;
-	if (mouse_y < 0) mouse_y = 0;
 
 	ev.x = mouse_x;
 	ev.y = mouse_y;
@@ -956,7 +967,7 @@
 	get_terminal_size(1, &fb_txt_xsize, &fb_txt_ysize);
 #endif
 	conn.eventMask = ~0;
-	conn.defaultMask = 0;
+	conn.defaultMask = gpm_smooth;
 	conn.minMod = 0;
 	conn.maxMod = -1;
 	if ((fb_hgpm = Gpm_Open(&conn, 0)) < 0) {
@@ -1172,6 +1183,7 @@
 	global_mouse_hidden=1;
 	show_mouse();
 	if (handle_fb_mouse()) {
+		fb_driver.shutdown_device(mouse_graphics_device);
 		mem_free(mouse_buffer);
 		mem_free(background_buffer);
 		mem_free(new_background_buffer);

[Index of Archives]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Gimp]     [Yosemite News]