From xemacs-m  Fri May 30 09:53:06 1997
Received: from newman.aventail.com (root@newman.aventail.com [199.238.236.1])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id JAA27436
	for <xemacs-beta@xemacs.org>; Fri, 30 May 1997 09:53:05 -0500 (CDT)
Received: from kramer.in.aventail.com.aventail.com (wmperry@kramer.in.aventail.com [192.168.1.12])
	by newman.aventail.com (8.8.5/8.8.5) with SMTP id HAA14798
	for <xemacs-beta@xemacs.org>; Fri, 30 May 1997 07:53:05 -0700 (PDT)
Date: Fri, 30 May 1997 07:53:05 -0700 (PDT)
Message-Id: <199705301453.HAA14798@newman.aventail.com>
From: "William M. Perry" <wmperry@aventail.com>
To: xemacs-beta@xemacs.org
Subject: GPM Patches
Errors-to: wmperry@aventail.com
Reply-to: wmperry@aventail.com
X-Face: O~Rn;(l][/-o1sALg4A@xpE:9-"'IR[%;,,!m7</SYF`{vYQ(&RI1&EiH[FvT;J}@f!4kfz
 x_!Y#=y{Uuj9GvUi=cPuajQ(Z42R[wE@{G,sn$qGr5g/wnb*"*ktI+,CD}1Z'wxrM2ag-r0p5I6\nA
 [WJopW_J.WY;

Makes it so it doesn't **ck up the mouse stuff on an XTerm, and resets the
internal GPM variables for the width and height of the screen when we get a 
sigwinch.

-Bill P.

*** device-tty.c	1997/05/30 14:12:07	1.1
--- device-tty.c	1997/05/30 14:12:11
***************
*** 38,43 ****
--- 38,47 ----
  
  #include "syssignal.h" /* for SIGWINCH */
  
+ #ifdef HAVE_GPM
+ #include <gpm.h>
+ #endif
+ 
  #include <errno.h>
  
  Lisp_Object Qinit_pre_tty_win, Qinit_post_tty_win;
***************
*** 153,158 ****
--- 157,171 ----
  	  CONSOLE_TTY_DATA (con)->width = width;
  	  CONSOLE_TTY_DATA (con)->height = height;
  
+ #ifdef HAVE_GPM
+ 	  /* We need to tell GPM how big our screen is now
+ 	  ** I am pretty sure the GPM library will get incredibly confused
+ 	  ** if you try to connect to more than one mouse-capable device,
+ 	  ** so I don't think it will cause any more damage in that case.
+ 	  */
+ 	  gpm_mx = width;
+ 	  gpm_my = height;
+ #endif
  	  for (tail = DEVICE_FRAME_LIST (d);
  	       !NILP (tail);
  	       tail = XCDR (tail))

*** gpmevent.c	1997/05/30 14:10:42	1.1
--- gpmevent.c	1997/05/30 14:10:48
***************
*** 92,111 ****
    /* Only do this if we are running after dumping and really interactive */
    if (!noninteractive && initialized) {
      /* We really only want to do this on a TTY */
      if (EQ (CONSOLE_TYPE (con), Qtty)) {
        Gpm_Connect conn;
  
        conn.eventMask = GPM_DOWN|GPM_UP|GPM_MOVE;
        conn.defaultMask = GPM_MOVE;
        conn.minMod = 0;
        conn.maxMod = ((1<<KG_SHIFT)|(1<<KG_ALT)|(1<<KG_CTRL));
  
!       if (Gpm_Open (&conn, 0) == -1) {
! 	CONSOLE_TTY_MOUSE_FD (con) = -1;
! 	return(0);
        }
-       set_descriptor_non_blocking (gpm_fd);
-       CONSOLE_TTY_MOUSE_FD (con) = gpm_fd;
      }
    }
  }
--- 92,118 ----
    /* Only do this if we are running after dumping and really interactive */
    if (!noninteractive && initialized) {
      /* We really only want to do this on a TTY */
+     CONSOLE_TTY_MOUSE_FD (con) = -1;
      if (EQ (CONSOLE_TYPE (con), Qtty)) {
        Gpm_Connect conn;
+       int rval;
  
        conn.eventMask = GPM_DOWN|GPM_UP|GPM_MOVE;
        conn.defaultMask = GPM_MOVE;
        conn.minMod = 0;
        conn.maxMod = ((1<<KG_SHIFT)|(1<<KG_ALT)|(1<<KG_CTRL));
  
!       rval = Gpm_Open (&conn, 0);
!       switch (rval) {
!       case -1: /* General failure */
! 	break;
!       case -2: /* We are running under an XTerm */
! 	Gpm_Close();
! 	break;
!       default:
! 	set_descriptor_non_blocking (gpm_fd);
! 	CONSOLE_TTY_MOUSE_FD (con) = gpm_fd;
        }
      }
    }
  }

