[comp.emacs] gnu emacs 18.50 and X11R2 - it works, but why

turner@daisy.UUCP (D'arc Angel) (04/05/88)

after giving up in frustration on getting the mouse to work with 18.50
(see my last posting), I moved on to my next problem; getting unexec
to work (I had defined CANNOT_DUMP). After some fiddling with the h files
I got it to work and lo and behold the mouse worked, why? i dunno...

Anyways the moral of the story is that if you want X to completely work
with 18.50, you need to get dump to work.


-- 
Laissez les bons temps rouler                     -  Queen Ida
...{decwrl|ucbvax}!imagen!atari!daisy!turner (James M. Turner)
Daisy Systems, 700 E. Middlefield Rd, P.O. Box 7006, 
Mountain View CA 94039-7006.                          (415)960-0123

weltyc@nysernic (Christopher A. Welty) (04/05/88)

In article <993@daisy.UUCP> turner@daisy.UUCP (D'arc Angel) writes:
>Anyways the moral of the story is that if you want X to completely work
>with 18.50, you need to get dump to work.

	I just got five mail messages for X11 emacs fixes, so rather
than pass the buck to Rob, I'll just post the fixes here.  Once again,
send mail to rfrench@athena.mit.edu to be added to the list of people
interested in getting updates to X11 emacs before it is released by
fsf...  In the future this will probably mean testing `beta' versions...

These are the diffs to GNU Emacs 18.50.

------------------------------------------------------------------------------

Follow these steps to patch the X11 support in a standard 18.50 GNU
Emacs distribution:

1) Apply the diffs below to change:

	lisp/x-mouse.el
	lisp/term/x-win.el
	src/dispnew.c
	src/emacs.c
	src/keyboard.c
	src/process.c
	src/x11fns.c
	src/x11term.c
	src/x11term.h

2) Install the new files:

	src/sink_11.h
	src/sinkmask_11.h
================================= Diffs ==================================
diff -rc2 dist-18.50/lisp/x-mouse.el dist-18.51/lisp/x-mouse.el
*** dist-18.50/lisp/x-mouse.el	Sat Mar  5 13:17:12 1988
--- dist-18.51/lisp/x-mouse.el	Sun Apr  3 00:52:21 1988
***************
*** 235,246 ****
      (and selection (call-interactively selection))))
  
! (define-key mouse-map x-button-c-s-middle 'x-help)
! (define-key mouse-map x-button-c-s-left 'x-buffer-menu)
! (define-key mouse-map x-button-right 'x-mouse-select)
! (define-key mouse-map x-button-left 'x-mouse-set-mark)
  (define-key mouse-map x-button-c-s-right 'x-mouse-keep-one-window)
  (define-key mouse-map x-button-c-right 'x-mouse-select-and-split)
- (define-key mouse-map x-button-middle 'x-mouse-set-point)
  (define-key mouse-map x-button-s-middle 'x-cut-text)
  (define-key mouse-map x-button-s-right 'x-paste-text)
  (define-key mouse-map x-button-c-middle 'x-cut-and-wipe-text)
--- 235,282 ----
      (and selection (call-interactively selection))))
  
! ; Prevent beeps on button-up.  If the button isn't bound to anything, it
! ; will beep on button-down.
! (define-key mouse-map x-button-right-up 'x-mouse-ignore)
! (define-key mouse-map x-button-middle-up 'x-mouse-ignore)
! (define-key mouse-map x-button-left-up 'x-mouse-ignore)
! (define-key mouse-map x-button-s-right-up 'x-mouse-ignore)
! (define-key mouse-map x-button-s-middle-up 'x-mouse-ignore)
! (define-key mouse-map x-button-s-left-up 'x-mouse-ignore)
! (define-key mouse-map x-button-m-right-up 'x-mouse-ignore)
! (define-key mouse-map x-button-m-middle-up 'x-mouse-ignore)
! (define-key mouse-map x-button-m-left-up 'x-mouse-ignore)
! (define-key mouse-map x-button-c-right-up 'x-mouse-ignore)
! (define-key mouse-map x-button-c-middle-up 'x-mouse-ignore)
! (define-key mouse-map x-button-c-left-up 'x-mouse-ignore)
! (define-key mouse-map x-button-m-s-right-up 'x-mouse-ignore)
! (define-key mouse-map x-button-m-s-middle-up 'x-mouse-ignore)
! (define-key mouse-map x-button-m-s-left-up 'x-mouse-ignore)
! (define-key mouse-map x-button-c-s-right-up 'x-mouse-ignore)
! (define-key mouse-map x-button-c-s-middle-up 'x-mouse-ignore)
! (define-key mouse-map x-button-c-s-left-up 'x-mouse-ignore)
! (define-key mouse-map x-button-c-m-right-up 'x-mouse-ignore)
! (define-key mouse-map x-button-c-m-middle-up 'x-mouse-ignore)
! (define-key mouse-map x-button-c-m-left-up 'x-mouse-ignore)
! (define-key mouse-map x-button-c-m-s-right-up 'x-mouse-ignore)
! (define-key mouse-map x-button-c-m-s-middle-up 'x-mouse-ignore)
! (define-key mouse-map x-button-c-m-s-left-up 'x-mouse-ignore)
! 
  (define-key mouse-map x-button-c-s-right 'x-mouse-keep-one-window)
  (define-key mouse-map x-button-c-right 'x-mouse-select-and-split)
  (define-key mouse-map x-button-s-middle 'x-cut-text)
  (define-key mouse-map x-button-s-right 'x-paste-text)
  (define-key mouse-map x-button-c-middle 'x-cut-and-wipe-text)
+ 
+ (if (or (not (boundp 'window-system-version))
+ 	(eq window-system-version 10))
+     (progn
+       (define-key mouse-map x-button-c-s-middle 'x-help)
+       (define-key mouse-map x-button-c-s-left 'x-buffer-menu)
+       (define-key mouse-map x-button-right 'x-mouse-select)
+       (define-key mouse-map x-button-left 'x-mouse-set-mark)
+       (define-key mouse-map x-button-middle 'x-mouse-set-point))
+   (define-key mouse-map x-button-c-s-middle 'x-mouse-ignore)
+   (define-key mouse-map x-button-c-s-left 'x-mouse-ignore)
+   (define-key mouse-map x-button-right 'x-cut-text)
+   (define-key mouse-map x-button-left 'x-mouse-set-point)
+   (define-key mouse-map x-button-middle 'x-paste-text))
diff -rc2 dist-18.50/lisp/term/x-win.el dist-18.51/lisp/term/x-win.el
*** dist-18.50/lisp/term/x-win.el	Sat Mar  5 13:16:00 1988
--- dist-18.51/lisp/term/x-win.el	Sun Apr  3 00:52:31 1988
***************
*** 28,45 ****
    (setq x-switches '((\"-r\" . t) (\"-font\" . \"foo\") (\"-b\" . \"8\")))")
  
! (setq command-switch-alist
!       (append '(("-r" . x-handle-switch)
! 		("-i" . x-handle-switch)
! 		("-font" . x-handle-switch)
! 		("-w" . x-handle-switch)
! 		("-b" . x-handle-switch)
! 		("-ib" . x-handle-switch)
! 		("-fg" . x-handle-switch)
! 		("-bg" . x-handle-switch)
! 		("-bd" . x-handle-switch)
! 		("-cr" . x-handle-switch)
! 		("-ms" . x-handle-switch))
! 	      command-switch-alist))
  
  ;; This is run after the command args are parsed.
  (defun x-handle-switch (switch)
--- 28,69 ----
    (setq x-switches '((\"-r\" . t) (\"-font\" . \"foo\") (\"-b\" . \"8\")))")
  
! (if (or (not (boundp 'window-system-version))
! 	(eq window-system-version 10))
!     (setq command-switch-alist
! 	  (append '(("-r" . x-handle-switch)
! 		    ("-i" . x-handle-switch)
! 		    ("-font" . x-handle-switch)
! 		    ("-w" . x-handle-switch)
! 		    ("-b" . x-handle-switch)
! 		    ("-ib" . x-handle-switch)
! 		    ("-fg" . x-handle-switch)
! 		    ("-bg" . x-handle-switch)
! 		    ("-bd" . x-handle-switch)
! 		    ("-cr" . x-handle-switch)
! 		    ("-ms" . x-handle-switch))
! 		  command-switch-alist))
!   (setq command-switch-alist
! 	(append '(("-r" . ignore)
! 		  ("-i" . ignore)
! 		  ("-rn" . xignore)
! 		  ("-font" . xignore)
! 		  ("-fn" . xignore)
! 		  ("-wn" . xignore)
! 		  ("-in" . xignore)
! 		  ("-w" . xignore)
! 		  ("-geometry" . xignore)
! 		  ("-b" . xignore)
! 		  ("-ib" . xignore)
! 		  ("-fg" . xignore)
! 		  ("-bg" . xignore)
! 		  ("-bd" . xignore)
! 		  ("-cr" . xignore)
! 		  ("-ms" . xignore)
! 		  ("-rn" . xignore))
! 		command-switch-alist)))
  
+ (defun xignore (&rest ignore)
+   (setq command-line-args-left (cdr command-line-args-left)))
+ 
  ;; This is run after the command args are parsed.
  (defun x-handle-switch (switch)
***************
*** 160,173 ****
  ;; only if Emacs has been compiled to support direct interface to X.
  
! (if (fboundp 'x-change-display)
      (progn
-       ;; xterm.c depends on using interrupt-driven input.
-       (set-input-mode t nil)
- 
-       ;; Not defvar!  This is not DEFINING this variable, just specifying
-       ;; a value for it.
-       (setq window-setup-hook 'x-pop-up-window)
- 
        (require 'x-mouse)
  
        (put 'suspend-emacs 'disabled
--- 184,202 ----
  ;; only if Emacs has been compiled to support direct interface to X.
  
! (if (eq window-system 'x)
      (progn
        (require 'x-mouse)
+       (if (or (not (boundp 'window-system-version))
+ 	      (eq window-system-version 10))
+ 	  (progn
+ 	    ;; xterm.c depends on using interrupt-driven input.
+ 	    (set-input-mode t nil)
+ 	    
+ 	    ;; Not defvar!  This is not DEFINING this variable, just specifying
+ 	    ;; a value for it.
+ 	    (setq term-setup-hook 'x-pop-up-window)
+ 	    (while x-switches
+ 	      (x-handle-switch-1 (car (car x-switches)) (cdr (car x-switches)))
+ 	      (setq x-switches (cdr x-switches)))))
  
        (put 'suspend-emacs 'disabled
***************
*** 177,185 ****
        (substitute-key-definition 'suspend-emacs nil global-map)
        (substitute-key-definition 'suspend-emacs nil esc-map)
!       (substitute-key-definition 'suspend-emacs nil ctl-x-map)
!       ;; Not needed any more -- done in C.
!       ;; (if (not x-processed-defaults) (x-get-default-args))
!       ;; Process switch settings made by .emacs file.
!       (while x-switches
! 	(x-handle-switch-1 (car (car x-switches)) (cdr (car x-switches)))
! 	(setq x-switches (cdr x-switches)))))
--- 206,208 ----
        (substitute-key-definition 'suspend-emacs nil global-map)
        (substitute-key-definition 'suspend-emacs nil esc-map)
!       (substitute-key-definition 'suspend-emacs nil ctl-x-map)))
diff -rc2 dist-18.50/src/dispnew.c dist-18.51/src/dispnew.c
*** dist-18.50/src/dispnew.c	Mon Feb 29 12:46:38 1988
--- dist-18.51/src/dispnew.c	Sun Apr  3 00:47:46 1988
***************
*** 95,98 ****
--- 95,102 ----
  				   ('x is the only current possibility) */
  
+ Lisp_Object Vwindow_system_version;	/* Version of the window system;
+ 					   current values for 'x are
+ 					   10 and 11 */
+ 
  /* Nonzero means reading single-character input with prompt
     so put cursor on minibuffer after the prompt.  */
***************
*** 131,134 ****
--- 135,146 ----
  int free_line_count;
  
+ /* Set if we are currently in an update_screen */
+ 
+ int in_update_screen = 0;
+ 
+ /* Set if change_screen_size was called while in update_screen */
+ 
+ int change_screen_size_update = 0;
+ 
  /* Allocate as many display_line structures
     as we are ever supposed to need.
***************
*** 554,557 ****
--- 566,571 ----
      if (screen_height == 0) abort (); /* Some bug zeros some core */
  
+     in_update_screen = 1;
+     
      bcopy (PhysScreen, OPhysScreen, sizeof PhysScreen);
  
***************
*** 682,685 ****
--- 696,707 ----
      bzero (OPhysScreen, (screen_height + 1) * sizeof OPhysScreen[0]);
      bzero (DesiredScreen, (screen_height + 1) * sizeof DesiredScreen[0]);
+     in_update_screen = 0;
+     if (change_screen_size_update)
+       {
+         change_screen_size_update = 0;
+         make_display_lines ();
+         calculate_costs ();
+         DoDsp (1);
+       }    
      return pause;
  }
***************
*** 1112,1118 ****
  	ScreenCols = newwidth;
      }
!   make_display_lines ();
!   calculate_costs ();
!   DoDsp (1);
  }
  
--- 1134,1144 ----
  	ScreenCols = newwidth;
      }
!   if (!in_update_screen)
!     {
!       make_display_lines ();
!       calculate_costs ();
!       DoDsp (1);
!     }
!   else change_screen_size_update = 1;
  }
  
***************
*** 1295,1300 ****
  #ifdef HAVE_X_WINDOWS
    extern Lisp_Object Vxterm;
    Vxterm = Qnil;
! #endif
  
    MetaFlag = 0;
--- 1321,1328 ----
  #ifdef HAVE_X_WINDOWS
    extern Lisp_Object Vxterm;
+   extern Lisp_Object Vwindow_system_version;
+ 
    Vxterm = Qnil;
! #endif /* HAVE_X_WINDOWS */
  
    MetaFlag = 0;
***************
*** 1303,1306 ****
--- 1331,1335 ----
    terminal_type = (char *) 0;
  
+   Vxterm = Qnil;
    if (!inhibit_window_system)
      {
***************
*** 1307,1318 ****
  #ifdef HAVE_X_WINDOWS
        extern char *alternate_display;
!       if (alternate_display || egetenv ("DISPLAY"))
  	{
  	  x_term_init ();
  	  Vxterm = Qt;
  #ifdef X11
! 	  Vwindow_system = intern ("x11");
  #else
! 	  Vwindow_system = intern ("x");
  #endif /* X11 */
  	  goto term_init_done;
--- 1336,1351 ----
  #ifdef HAVE_X_WINDOWS
        extern char *alternate_display;
!       /* Changed to deal with KSH lossage */
!       char *disp = egetenv ("DISPLAY");
! 
!       if (alternate_display || (disp && *disp))
  	{
  	  x_term_init ();
  	  Vxterm = Qt;
+ 	  Vwindow_system = intern ("x");
  #ifdef X11
! 	  XSET (Vwindow_system_version, Lisp_Int, 11);
  #else
! 	  XSET (Vwindow_system_version, Lisp_Int, 10);
  #endif /* X11 */
  	  goto term_init_done;
***************
*** 1376,1379 ****
--- 1409,1416 ----
  \(such as `x') or nil if emacs is running on an ordinary terminal.");
    Vwindow_system = Qnil;
+   DEFVAR_LISP ("window-system-version", &Vwindow_system_version,
+     "A symbol naming the version of the window-system under which emacs\n\
+ is running.");
+   Vwindow_system_version = Qnil;
    DEFVAR_BOOL ("cursor-in-echo-area", &cursor_in_echo_area,
      "Non-nil means put cursor in minibuffer after any message displayed there.");
diff -rc2 dist-18.50/src/emacs.c dist-18.51/src/emacs.c
*** dist-18.50/src/emacs.c	Mon Feb 29 12:46:41 1988
--- dist-18.51/src/emacs.c	Sun Apr  3 00:47:56 1988
***************
*** 73,79 ****
     the display to use.  */
  char *alternate_display;
  char **xargv;
  int xargc;
! #endif /* HAVE_X_WINDOWS */
  
  /* Nonzero means running Emacs without interactive terminal.  */
--- 73,82 ----
     the display to use.  */
  char *alternate_display;
+ #endif /* HAVE_X_WINDOWS */
+ 
+ #ifdef X11
  char **xargv;
  int xargc;
! #endif /* X11 */
  
  /* Nonzero means running Emacs without interactive terminal.  */
***************
*** 224,231 ****
    inhibit_window_system = 0;
  
! #ifdef HAVE_X_WINDOWS
    xargv = argv;
    xargc = argc;
! #endif
  
  /* Handle the -t switch, which specifies filename to use as terminal */
--- 227,234 ----
    inhibit_window_system = 0;
  
! #ifdef X11
    xargv = argv;
    xargc = argc;
! #endif /* X11 */
  
  /* Handle the -t switch, which specifies filename to use as terminal */
diff -rc2 dist-18.50/src/keyboard.c dist-18.51/src/keyboard.c
*** dist-18.50/src/keyboard.c	Mon Feb 29 12:46:46 1988
--- dist-18.51/src/keyboard.c	Sun Apr  3 00:48:03 1988
***************
*** 19,22 ****
--- 19,24 ----
  and this notice must be preserved on all copies.  */
  
+ /*** For version 19, can simplify this by making interrupt_input 1 on VMS.  */
+ 
  /* Allow config.h to undefine symbols found here.  */
  #include <signal.h>
***************
*** 34,37 ****
--- 36,40 ----
  #include "buffer.h"
  #include <setjmp.h>
+ #include <errno.h>
  
  /* Get FIONREAD, if it is available.  */
***************
*** 197,200 ****
--- 200,206 ----
  #endif
  
+ static void read_avail_input ();
+ static void get_input_pending ();
+ 
  static char KeyBuf[40];		/* Buffer for keys from get_char () */
  static NextK;			/* Next index into KeyBuf */
***************
*** 909,912 ****
--- 915,921 ----
  	quit_throw_to_get_char ();
  
+       /* One way or another, wait until input is available; then, if
+ 	 interrupt handlers have not read it, read it now.  */
+ 
  #ifdef VMS
        set_waiting_for_input (0);
***************
*** 941,945 ****
  	  if (!interrupt_input && !kbd_count)
  	    {
! 	      read_avail_input ();
  	    }
  	}
--- 950,954 ----
  	  if (!interrupt_input && !kbd_count)
  	    {
! 	      read_avail_input (0);
  	    }
  	}
***************
*** 957,960 ****
--- 966,970 ----
     even if FIONREAD does not exist.  */
  
+ static void
  get_input_pending (addr)
       int *addr;
***************
*** 963,977 ****
    /* On VMS, we always have something in the buffer
       if any input is available.  */
    *addr = kbd_count | !NULL (Vquit_flag);
  #else
  #ifdef FIONREAD
!   if (interrupt_input && ! interrupts_deferred)
!     *addr = kbd_count;
!   else if (ioctl (0, FIONREAD, addr) < 0)
      *addr = 0;
! #else /* no FIONREAD */
!   read_avail_input ();
    *addr = kbd_count;
- #endif /* no FIONREAD */
  #endif
  }
--- 973,998 ----
    /* On VMS, we always have something in the buffer
       if any input is available.  */
+   /*** It might be simpler to make interrupt_input 1 on VMS ***/
    *addr = kbd_count | !NULL (Vquit_flag);
  #else
+   /* First of all, have we already counted some input?  */
+   *addr = kbd_count | !NULL (Vquit_flag);
+   /* If input is being read as it arrives, and we have none, there is none.  */
+   if (*addr > 0 || (interrupt_input && ! interrupts_deferred))
+     return;
  #ifdef FIONREAD
!   /* If we can count the input without reading it, do so.  */
!   if (ioctl (0, FIONREAD, addr) < 0)
      *addr = 0;
!   if (*addr == 0 || read_socket_hook == 0)
!     return;
!   /* If the input consists of window-events, not all of them
!      are necessarily kbd chars.  So process all the input
!      and see how many kbd chars we got.  */
! #endif
!   /* If we can't count the input, read it (if any) and see what we got.  */
!   if (!kbd_count)
!     read_avail_input (*addr);
    *addr = kbd_count;
  #endif
  }
***************
*** 979,984 ****
  /* Read any terminal input already buffered up by the system
     into the kbd_buffer, assuming the buffer is currently empty.
!    Never waits.
  
     Input gets into the kbd_buffer either through this function
     (at main program level) or at interrupt level if input
--- 1000,1008 ----
  /* Read any terminal input already buffered up by the system
     into the kbd_buffer, assuming the buffer is currently empty.
!    Never waits.  We assume that kbd_buffer is empty before you call.
  
+    If NREAD is nonzero, assume it contains # chars of raw data waiting.
+    If it is zero, we determine that datum.
+ 
     Input gets into the kbd_buffer either through this function
     (at main program level) or at interrupt level if input
***************
*** 985,1017 ****
     is interrupt-driven.  */
  
! read_avail_input ()
  {
! /* There is no need to do anything on VMS, since input will
!    automatically come in asynchronously.  */
  #ifndef VMS
  #ifdef FIONREAD
!   int nread;
!   get_input_pending (&nread);
!   if (!nread)
      return;
!   set_waiting_for_input (0);
    if (read_socket_hook)
!     {
!       kbd_count = (*read_socket_hook) (0, kbd_buffer, sizeof kbd_buffer);
!       if (!kbd_count)
! 	return;
!     }
    else
      {
!       if (nread > sizeof kbd_buffer)
! 	nread = sizeof kbd_buffer;
!       kbd_count = read (0, kbd_buffer, nread);
      }
!   clear_waiting_for_input ();
!   kbd_ptr = kbd_buffer;
  #else /* no FIONREAD */
  #ifdef USG
-   /* Assume this is only done when the buffer is empty.
-      It's stupid to call this function without checking kbd_count.  */
    if (kbd_count)
      abort ();
--- 1009,1052 ----
     is interrupt-driven.  */
  
! static void
! read_avail_input (nread)
!      int nread;
  {
!   /* This function is not used on VMS.  */
  #ifndef VMS
  #ifdef FIONREAD
!   char buf[64 * BUFFER_SIZE_FACTOR];
!   register char *p;
!   register int i;
! 
!   if (kbd_count)
!     abort ();
! 
!   if (nread == 0)
!     get_input_pending (&nread);
!   if (nread == 0)
      return;
!   if (nread > sizeof buf)
!     nread = sizeof buf;
! 
!   /* Read what is waiting.  */
    if (read_socket_hook)
!     nread = (*read_socket_hook) (0, buf, nread);
    else
+     nread = read (0, buf, nread);
+ 
+   /* Scan the chars for C-g and store them in kbd_buffer.  */
+   kbd_ptr = kbd_buffer;
+   for (i = 0; i < nread; i++)
      {
!       kbd_buffer_store_char (buf[i]);
!       /* Don't look at input that follows a C-g too closely.
! 	 This reduces lossage due to autorepeat on C-g.  */
!       if (buf[i] == Ctl ('G'))
! 	break;
      }
! 
  #else /* no FIONREAD */
  #ifdef USG
    if (kbd_count)
      abort ();
***************
*** 1025,1028 ****
--- 1060,1065 ----
    else
      kbd_count = read (fileno (stdin), kbd_buffer, sizeof kbd_buffer);
+   if (kbd_count == -1 && errno == EAGAIN)
+     kbd_count = 0;
    fcntl (fileno (stdin), F_SETFL, 0);
  #else /* not USG */
***************
*** 1036,1039 ****
--- 1073,1079 ----
  /* Note SIGIO has been undef'd if FIONREAD is missing.  */
  
+ /* If using interrupt input and some input chars snuck into the
+    buffer before we enabled interrupts, fake an interrupt for them.  */
+ 
  gobble_input ()
  {
***************
*** 1041,1050 ****
    if (interrupt_input)
      {
- #ifdef FIONREAD
        if (ioctl (0, FIONREAD, &nread) < 0)
  	nread = 0;
- #else /* no FIONREAD */
-       lossage
- #endif /* no FIONREAD */
        if (nread)
  	{
--- 1081,1086 ----
***************
*** 1081,1090 ****
    while (1)
      {
- #ifdef FIONREAD
        if (ioctl (0, FIONREAD, &nread) < 0)
  	nread = 0;
- #else /* no FIONREAD */
-       lossage
- #endif /* no FIONREAD */
        if (nread <= 0)
  	break;
--- 1117,1122 ----
***************
*** 1458,1467 ****
  {
    if (!input_pending)
!     {
!       if (kbd_count)
! 	input_pending = kbd_count;
!       else
! 	get_input_pending (&input_pending);
!     }
    return input_pending;
  }
--- 1490,1495 ----
  {
    if (!input_pending)
!     get_input_pending (&input_pending);
! 
    return input_pending;
  }
diff -rc2 dist-18.50/src/process.c dist-18.51/src/process.c
*** dist-18.50/src/process.c	Mon Feb 29 12:46:53 1988
--- dist-18.51/src/process.c	Sun Apr  3 00:48:10 1988
***************
*** 1233,1237 ****
    int wait_channel = 0;
    struct Lisp_Process *wait_proc = 0;
!   extern kbd_count;
  
    /* Detect when read_kbd is really the address of a Lisp_Process.  */
--- 1233,1237 ----
    int wait_channel = 0;
    struct Lisp_Process *wait_proc = 0;
!   extern kbd_count, interrupt_input;
  
    /* Detect when read_kbd is really the address of a Lisp_Process.  */
***************
*** 1380,1385 ****
  	 to give it higher priority than subprocesses */
  
!       if (read_kbd && (kbd_count || !NULL (Vquit_flag)))
! 	break;
  
        if (read_kbd && (Available & ChannelMask (0)))
--- 1380,1390 ----
  	 to give it higher priority than subprocesses */
  
!       if (read_kbd)
! 	{      
!           if (interrupt_input && (kbd_count || !NULL (Vquit_flag)))
!             break;
!           if (!interrupt_input && detect_input_pending())
! 	    break;
!         } 
  
        if (read_kbd && (Available & ChannelMask (0)))
diff -rc2 dist-18.50/src/x11fns.c dist-18.51/src/x11fns.c
*** dist-18.50/src/x11fns.c	Mon Feb 29 12:46:57 1988
--- dist-18.51/src/x11fns.c	Sun Apr  3 00:48:14 1988
***************
*** 73,77 ****
  extern unsigned long back;
  extern unsigned long brdr;
- extern unsigned long mous;
  extern unsigned long curs;
  
--- 73,76 ----
***************
*** 103,106 ****
--- 102,107 ----
  extern int XXpid;
  
+ extern char *XXidentity;
+ 
  extern Display *XXdisplay;
  extern int bitblt, CursorExists, VisibleX, VisibleY;
***************
*** 313,319 ****
  {
  	int mask;
- 	XColor cdef;
  	char *save_color;
! 
  	check_xterm ();
  	CHECK_STRING (arg,1);
--- 314,320 ----
  {
  	int mask;
  	char *save_color;
! 	XColor forec, backc;
! 	
  	check_xterm ();
  	CHECK_STRING (arg,1);
***************
*** 324,341 ****
  	mask = sigblock (sigmask (SIGIO));
  
! 	if (mous_color && XXisColor &&
! 	    XParseColor (XXdisplay, XXColorMap, mous_color, &cdef) &&
! 	    XAllocColor (XXdisplay, XXColorMap, &cdef))
! 		mous = cdef.pixel;
! 	else
! 		if (mous_color && !strcmp (mous_color, "black"))
! 			mous = BlackPixel(XXdisplay,0);
! 		else
! 			if (mous_color && !strcmp (mous_color, "white"))
! 				mous = WhitePixel(XXdisplay,0);
! 			else
! 				mous_color = save_color;
  
- 	XRecolorCursor (XXdisplay, EmacsCursor, mous, back);
  	XFlush (XXdisplay);
  	
--- 325,333 ----
  	mask = sigblock (sigmask (SIGIO));
  
! 	if (XXisColor && mous_color &&
! 	    XParseColor (XXdisplay, XXColorMap, mous_color, &forec) &&
! 	    XParseColor (XXdisplay, XXColorMap, back_color, &backc))
! 	  XRecolorCursor (XXdisplay, EmacsCursor, &forec, &backc);
  
  	XFlush (XXdisplay);
  	
***************
*** 423,427 ****
  	default_name = (char *) XSTRING (arg)->data;
  
! 	value = XGetDefault (progname, default_name);
  	if (value)
  		return build_string (value);
--- 415,423 ----
  	default_name = (char *) XSTRING (arg)->data;
  
! 	if (XXidentity)
! 		value = XGetDefault (XXdisplay, XXidentity, default_name);
! 	else
! 		value = XGetDefault (XXdisplay, CLASS, default_name);
! 	
  	if (value)
  		return build_string (value);
***************
*** 657,664 ****
  	sigsetmask (mask);
  
- #if 0
- 	if (QLength(XXdisplay) > 0)
- #endif		read_events_block ();
- 
  	return Qt;
  }
--- 653,656 ----
***************
*** 684,692 ****
  	XSetWindowSize(screen_height,screen_width);
  	sigsetmask (mask);
- 
- #if 0
- 	if (QLength(XXdisplay) > 0)
- 		read_events_block ();
- #endif
  
  	return Qt;
--- 676,679 ----
diff -rc2 dist-18.50/src/x11term.c dist-18.51/src/x11term.c
*** dist-18.50/src/x11term.c	Mon Feb 29 12:47:04 1988
--- dist-18.51/src/x11term.c	Sun Apr  3 00:48:22 1988
***************
*** 23,42 ****
  /* Thanks to Mark Biggers for all of the Window Manager support */
  
- /* PLEASE NOTE!
-  *
-  * This is only a test copy of the X11 code -- it is NOT suitable
-  * for distribution beyond test sites!!!!
-  *
-  */
- 
  /*
!  *	$Source: /mit/emacs/src/RCS/xterm_11.c,v $
   *	$Author: rfrench $
   *	$Locker:  $
!  *	$Header: xterm_11.c,v 1.9 88/01/16 15:33:35 rfrench Exp $
   */
  
  #ifndef lint
! static char *rcsid_xterm_c = "$Header: xterm_11.c,v 1.9 88/01/16 15:33:35 rfrench Exp $";
  #endif	lint
  
--- 23,35 ----
  /* Thanks to Mark Biggers for all of the Window Manager support */
  
  /*
!  *	$Source: /mit/emacs/src/RCS/x11term.c,v $
   *	$Author: rfrench $
   *	$Locker:  $
!  *	$Header: x11term.c,v 1.12 88/02/29 14:11:07 rfrench Exp $
   */
  
  #ifndef lint
! static char *rcsid_xterm_c = "$Header: x11term.c,v 1.12 88/02/29 14:11:07 rfrench Exp $";
  #endif	lint
  
***************
*** 54,59 ****
   * if this is not done before the other system files.  */
  
- /*#include "xdebug.h"*/
- 
  #include "x11term.h"
  
--- 47,50 ----
***************
*** 80,85 ****
  #include "termchar.h"
  
! #include "sink.h"
! #include "sinkmask.h"
  
  #define min(a,b) ((a)<(b) ? (a) : (b))
--- 71,76 ----
  #include "termchar.h"
  
! #include "sink_11.h"
! #include "sinkmask_11.h"
  
  #define min(a,b) ((a)<(b) ? (a) : (b))
***************
*** 96,101 ****
  #define MAXHEIGHT 300	/* In lines */
  
- #define CLASS  "emacs"	/* class id for GNU Emacs, used in .Xdefaults, etc. */
- 
  int pixelwidth,pixelheight;
  char *progname;
--- 87,90 ----
***************
*** 125,130 ****
  int WindowMapped;
  
! static char  *XXidentity;	/* Resource name of this invocation of Emacs */
  static char  *XXicon_name;	/* user-supplied icon info */
  static char  *XXheader;		/* user-supplied window header info */
  
--- 114,120 ----
  int WindowMapped;
  
! char  *XXidentity;		/* Resource name of this invocation of Emacs */
  static char  *XXicon_name;	/* user-supplied icon info */
+ static int   XXicon_usebitmap;	/* Use bitmap or not */
  static char  *XXheader;		/* user-supplied window header info */
  
***************
*** 139,142 ****
--- 129,135 ----
  
  int CursorExists;		/* during updates cursor is turned off */
+ int CursorOutline; 	    	/* when the pointer is not in the Emacs
+     	    	    	    	 * widow the cursor should be drawn in
+     	    	    	         * outline form a la xterm */
  static int InUpdate;		/* many of functions here may be invoked
  				 * even if no update in progress; when
***************
*** 161,165 ****
  unsigned long brdr;
  unsigned long curs;
- unsigned long mous;
  
  char *desiredwindow;
--- 154,157 ----
***************
*** 171,175 ****
--- 163,189 ----
  int updated[MAXHEIGHT];
  
+ static char  *temp_font;                /* needed because of loading hacks */
+ static char  *temp_reverseVideo;
+ static char  *temp_borderWidth;
+ static char  *temp_internalBorder;
  
+ static struct _xdeftab {
+     char *iname;			/* instance name */
+     char *cname;			/* class name (fake it) */
+     char **varp;			/* variable to set */
+ } xDefaultsValueTable[] = {
+     { "reverseVideo",	"ReverseVideo",		&temp_reverseVideo },
+     { "borderWidth",	"BorderWidth",		&temp_borderWidth },
+     { "internalBorder",	"BorderWidth",		&temp_internalBorder },
+     { "borderColor",	"BorderColor",		&brdr_color },
+     { "background",	"Background",		&back_color },
+     { "foreground",	"Foreground",		&fore_color },
+     { "pointerColor",	"Foreground",		&mous_color },
+     { "cursorColor",	"Foreground",		&curs_color },
+     { "font",		"Font",			&temp_font },
+     { "geometry",	"Geometry",		&desiredwindow },
+     { NULL,		NULL,			NULL }
+ };
+ 
  int (*handler)();
  
***************
*** 176,183 ****
  char *rindex();
  
- #ifdef BIGDEBUG
- char debug_string[500000];
- #endif BIGDEBUG
- 
  /* HLmode -- Changes the GX function for output strings.  Could be used to
   * change font.  Check an XText library function call. 
--- 190,193 ----
***************
*** 230,233 ****
--- 240,244 ----
  	if (!initialized) {
  		CursorExists = 0;
+ 		CursorOutline = 1;
  		VisibleX = 0;
  		VisibleY = 0;
***************
*** 234,244 ****
  	}
  	XTclear_screen ();
- #if 0
- #ifdef FIONREAD
- 	ioctl (0, FIONREAD, &stuffpending);
- 	if (stuffpending)
- 		read_events_block ();
- #endif
- #endif /* 0 */
  }
  
--- 245,248 ----
***************
*** 505,522 ****
  }
  
- /* The following routine is for the deaf or for the pervert who prefers 
-  * that his terminal flashes at him rather than beep at him.
-  */
- 
- static int flashedback;
- 
  XTflash ()
  {
  	XGCValues gcv_temp;
! 	struct itimerval itimer;
  	int mask = sigblock (sigmask (SIGIO));
  
- 	extern int flashback ();
- 
  #ifdef XDEBUG
  	fprintf (stderr, "XTflash\n");
--- 509,518 ----
  }
  
  XTflash ()
  {
  	XGCValues gcv_temp;
! 	struct timeval to;
  	int mask = sigblock (sigmask (SIGIO));
  
  #ifdef XDEBUG
  	fprintf (stderr, "XTflash\n");
***************
*** 528,540 ****
  		  AllPlanes);
  	
- 	signal (SIGALRM, flashback);
- 	getitimer (ITIMER_REAL, &itimer);
- 	itimer.it_value.tv_usec += 250000;
- 	itimer.it_interval.tv_sec = 0;
- 	itimer.it_interval.tv_usec = 0;
- 	flashedback = 0;
- 
- 	setitimer (ITIMER_REAL, &itimer, 0);
- 
  	XFillRectangle (XXdisplay, XXwindow, XXgc_temp, 0, 0,
  			screen_width*XXfontw+2*XXInternalBorder,
--- 524,527 ----
***************
*** 544,565 ****
  	sigsetmask (mask);
  
! 	while (!flashedback)
! 		pause ();
! 
! 	XFreeGC(XXdisplay, XXgc_temp);
! }
! 
! flashback ()
! {
! 	int mask = sigblock (sigmask (SIGIO) | sigmask (SIGALRM));
! 
  	XFillRectangle (XXdisplay, XXwindow, XXgc_temp, 0, 0,
  			screen_width*XXfontw+2*XXInternalBorder,
  	  	 	screen_height*XXfonth+2*XXInternalBorder);
  	XFlush (XXdisplay);
- 
- 	flashedback = 1;
  	sigsetmask (mask);
! }	
  
  XTfeep ()
--- 531,547 ----
  	sigsetmask (mask);
  
! 	to.tv_sec = 0;
! 	to.tv_usec = 250000;
! 	
! 	select(0, 0, 0, 0, &to);
! 	
! 	mask = sigblock (sigmask (SIGIO));
  	XFillRectangle (XXdisplay, XXwindow, XXgc_temp, 0, 0,
  			screen_width*XXfontw+2*XXInternalBorder,
  	  	 	screen_height*XXfonth+2*XXInternalBorder);
+ 	XFreeGC(XXdisplay, XXgc_temp);
  	XFlush (XXdisplay);
  	sigsetmask (mask);
! }
  
  XTfeep ()
***************
*** 587,590 ****
--- 569,573 ----
  	if (!WindowMapped) {
  		CursorExists = 0;
+ 		CursorOutline = 1;
  		return 0;
  		/* Currently the return values are not */
***************
*** 611,615 ****
  				    &ActiveScreen[VisibleY+1]->body[VisibleX],
  				    1);
! 		else
  			XDrawImageString(XXdisplay, XXwindow, XXgc_curs,
  				    VisibleX*XXfontw+XXInternalBorder,
--- 594,608 ----
  				    &ActiveScreen[VisibleY+1]->body[VisibleX],
  				    1);
! 		else if (CursorOutline) {
! 			XDrawImageString(XXdisplay, XXwindow, XXgc_norm,
! 				    VisibleX*XXfontw+XXInternalBorder,
! 				    VisibleY*XXfonth+XXInternalBorder+XXbase,
! 				    &ActiveScreen[VisibleY+1]->body[VisibleX],
! 				    1);
! 			XDrawRectangle (XXdisplay, XXwindow, XXgc_norm,
! 					VisibleX*XXfontw+XXInternalBorder,
! 					VisibleY*XXfonth+XXInternalBorder,
! 					XXfontw - 1, XXfonth - 1);
! 		} else
  			XDrawImageString(XXdisplay, XXwindow, XXgc_curs,
  				    VisibleX*XXfontw+XXInternalBorder,
***************
*** 623,631 ****
  				    VisibleY*XXfonth+XXInternalBorder,
  				    XXfontw, XXfonth, 0);
! 		else
! 			XFillRectangle (XXdisplay, XXwindow, XXgc_norm,
  					VisibleX*XXfontw+XXInternalBorder,
  					VisibleY*XXfonth+XXInternalBorder,
! 					XXfontw, XXfonth);
  
  	CursorExists = !CursorExists;
--- 616,629 ----
  				    VisibleY*XXfonth+XXInternalBorder,
  				    XXfontw, XXfonth, 0);
! 		else if (CursorOutline)
! 			XDrawRectangle (XXdisplay, XXwindow, XXgc_norm,
  					VisibleX*XXfontw+XXInternalBorder,
  					VisibleY*XXfonth+XXInternalBorder,
! 					XXfontw - 1, XXfonth - 1);
! 		else
! 			XDrawImageString(XXdisplay, XXwindow, XXgc_curs,
! 				    VisibleX*XXfontw+XXInternalBorder,
! 				    VisibleY*XXfonth+XXInternalBorder+XXbase,
! 				    " ", 1);
  
  	CursorExists = !CursorExists;
***************
*** 650,653 ****
--- 648,652 ----
  	if (!WindowMapped) {
  		CursorExists = 0;
+ 		CursorOutline = 1;
  		sigsetmask (mask);
  		return;
***************
*** 946,950 ****
  #endif
  
! 	return (internal_socket_read (bufp, numchars, 0));
  }
  
--- 945,949 ----
  #endif
  
! 	return (internal_socket_read (bufp, numchars));
  }
  
***************
*** 1037,1041 ****
--- 1036,1042 ----
  	}
  }
+ 
  #else
+ 
  char *stringFuncVal(keycode)
  	KeySym keycode;
***************
*** 1087,1091 ****
  		return("34");
  	
! 	case XK_Find :
  		return("1");
  	case XK_Insert:
--- 1088,1092 ----
  		return("34");
  	
! 	case XK_Find:
  		return("1");
  	case XK_Insert:
***************
*** 1103,1149 ****
  	}
  }
- #endif sun
  
! #if 0
! /* All input is supposed to go through
!    the usual mechanisms in keyboard.c, which do the actual I/O
!    by calling XTread_socket via read_socket_hook.  A side-path such
!    as this is not clean.
  
!    Since keyboard input is normally done in a signal handler, any
!    attempt to do it elsewhere is not only unmodular but risks a timing
!    error as well.  It is also superfluous, unless there is a bug in
!    the usual mechanisms or the use of read_socket_hook.  If so, fix it
!    there; don't create a redundant mechanism here.  -- RMS.  */
! 
! read_events_block ()
! {
! 	unsigned char buf[64];
! 	int i, nread;
! 
! #ifdef XDEBUG
! 	fprintf(stderr,"read_events_block\n");
! #endif
! 	
! 	nread = internal_socket_read (buf, sizeof buf, 0);
! 	if (!nread)
! 		return (0);
! 	
! 	for (i=0; i < nread; i++) {
! 		kbd_buffer_store_char (buf[i]);
! 		/* Don't look at input that follows a C-g too closely.
! 		 * This reduces lossage due to autorepeat on C-g.  */
! 		if (buf[i] == ('G' & 037))
! 			break;
! 	}
! 	return (nread);
! }
! 
! #endif /* 0 */
! 	
! internal_socket_read(bufp, numchars, stopatkey)
  	register unsigned char *bufp;
  	register int numchars;
- 	int stopatkey;
  {
  	int count,nbytes,rows,cols;
--- 1104,1113 ----
  	}
  }
  
! #endif /* sun */
  
! internal_socket_read(bufp, numchars)
  	register unsigned char *bufp;
  	register int numchars;
  {
  	int count,nbytes,rows,cols;
***************
*** 1154,1189 ****
  	KeySym keysym;
  	
- 	extern int input_pending;
- 
  	count = 0;
  
- #ifdef BIGDEBUG
- 	my_log("Entering internal_socket_read input_pending = %d\n",input_pending);
- #endif BIGDEBUG
- 	
  	while (XPending (XXdisplay)) {
- 		if (stopatkey) {
- 			XPeekEvent(XXdisplay,&event);
- 			if ((event.type & 0177) == KeyPress) {
- 				if (XLookupString (&event,
- 						   mapping_buf, 20, &keysym,
- 						   &status) ||
- 				    keysym == XK_Left ||
- 				    keysym == XK_Right ||
- 				    keysym == XK_Up ||
- 				    keysym == XK_Down)
- 					return (1);
- 			}
- 			if (((event.type & 0177) == ButtonPress) ||
- 			    ((event.type & 0177) == ButtonRelease))
- 				return (1);
- 		}
  		XNextEvent (XXdisplay,&event);
  		event.type &= 0177;       /* Mask out XSendEvent indication */
  
- #ifdef BIGDEBUG
- 		my_log("Got event %d\n",event.type);
- #endif BIGDEBUG
- 
  		switch (event.type) {
  
--- 1118,1127 ----
***************
*** 1191,1194 ****
--- 1129,1136 ----
  			break;
  
+ 		case MappingNotify:
+ 			XRefreshKeyboardMapping(&event);
+ 			break;
+ 			
  		case MapNotify:
  			WindowMapped = 1;
***************
*** 1214,1218 ****
  			pixelwidth = cols*XXfontw+2*XXInternalBorder;
  			pixelheight = rows*XXfonth+2*XXInternalBorder;
- 
  			break;
  
--- 1156,1159 ----
***************
*** 1219,1229 ****
  		case Expose:
  			if (configure_pending) {
  				if (event.xexpose.count)
  					break;
! 				change_screen_size ((pixelheight-2*XXInternalBorder)/XXfonth,
! 						    (pixelwidth-2*XXInternalBorder)/XXfontw);
  				configure_pending = 0;
  				break;
! 			} 
  			dumprectangle (event.xexpose.y-XXInternalBorder,
  				       event.xexpose.x-XXInternalBorder,
--- 1160,1179 ----
  		case Expose:
  			if (configure_pending) {
+ 				int width,height;
  				if (event.xexpose.count)
  					break;
! 				/* This is absolutely, amazingly gross.
! 				 * However, without it, emacs will core
! 				 * dump if the window gets too small.  And
! 				 * uwm is too brain-damaged to handle
! 				 * large minimum size windows. */
! 				width = (pixelwidth-2*XXInternalBorder)/XXfontw;
! 				height = (pixelheight-2*XXInternalBorder)/XXfonth;
! 				if (width > 11 && height > 4)
! 					change_screen_size (height, width, 0);
! 				dumprectangle (0,0,pixelheight,pixelwidth);
  				configure_pending = 0;
  				break;
! 			}
  			dumprectangle (event.xexpose.y-XXInternalBorder,
  				       event.xexpose.x-XXInternalBorder,
***************
*** 1242,1245 ****
--- 1192,1213 ----
  			break;
  			
+ 		/*
+ 		 * NOTE: No 'Focus' management is being done yet. If
+ 		 * some other window has grabbed the focus, emacs will
+ 		 * still show a filled cursor whenever the pointer
+ 		 * enters the emacs window.
+ 		 */ 
+ 		case EnterNotify:
+ 			CursorToggle ();
+     	    	    	CursorOutline = 0;
+ 			CursorToggle ();
+     	    	    	break;
+ 
+ 		case LeaveNotify:
+ 			CursorToggle ();
+     	    	    	CursorOutline = 1;
+ 			CursorToggle ();
+     	    	    	break;
+ 
  		case KeyPress:
  			nbytes = XLookupString (&event,
***************
*** 1246,1249 ****
--- 1214,1222 ----
  						mapping_buf, 20, &keysym,
  						&status);
+ 			/*
+ 			 * Someday this will be unnecessary as we will
+ 			 * be able to use XRebindKeysym so XLookupString
+ 			 * will have already given us the string we want.
+ 			 */
  			if (IsFunctionKey(keysym) ||
  			    IsMiscFunctionKey(keysym)) {
***************
*** 1254,1261 ****
  #else
  				strcat(mapping_buf,"~");
! #endif sun
  				nbytes = strlen(mapping_buf);
  			}
  			else {
  				switch (keysym) {
  				case XK_Left:
--- 1227,1236 ----
  #else
  				strcat(mapping_buf,"~");
! #endif /* sun */
  				nbytes = strlen(mapping_buf);
  			}
  			else {
+ 				/* This is rather gross...must be a nicer
+ 				 * way */
  				switch (keysym) {
  				case XK_Left:
***************
*** 1275,1279 ****
  					nbytes = 1;
  					break;
! 				}
  			} 
  			if (nbytes) {
--- 1250,1254 ----
  					nbytes = 1;
  					break;
! 				} 
  			} 
  			if (nbytes) {
***************
*** 1350,1354 ****
   */
  static int  reversevideo;
- static char  *temp_font;
  
  static int
--- 1325,1328 ----
***************
*** 1356,1396 ****
      char  *class;
  {
!     char  *option;
!     char  *tfont;
!     
  
!     if (option = XGetDefault(XXdisplay, class, "ReverseVideo"))
! 	if (!strcmp (option, "on"))
! 	    reversevideo = 1;
  
!     if (option = XGetDefault(XXdisplay, class, "BorderWidth"))
! 	XXborder = atoi (option);
  
!     if (option = XGetDefault(XXdisplay, class, "InternalBorder"))
! 	XXInternalBorder = atoi (option);
  
!     if (!(brdr_color = XGetDefault(XXdisplay, class, "Border")))
! 	brdr_color = XGetDefault(XXdisplay, class, "BorderColor");
  
!     if (option = XGetDefault(XXdisplay, class, "Background"))
! 	back_color = XGetDefault(XXdisplay, class, "Background");
  
!     if (option = XGetDefault(XXdisplay, class, "Foreground"))
! 	fore_color = XGetDefault(XXdisplay, class, "Foreground");
  
!     if (option = XGetDefault(XXdisplay, class, "Mouse"))
! 	mous_color = XGetDefault(XXdisplay, class, "Mouse");
! 
!     if (option = XGetDefault(XXdisplay, class, "Cursor"))
! 	curs_color = XGetDefault(XXdisplay, class, "Cursor");
!     
!     if (option = XGetDefault(XXdisplay, class, "Geometry"))
! 	desiredwindow = option;
! 
!     if (option = XGetDefault(XXdisplay, class, "BodyFont"))
! 	temp_font = option;
  }
  
- 
  x_term_init ()
  {
--- 1330,1371 ----
      char  *class;
  {
!     register char *option;
!     register struct _xdeftab *entry;
  
!     /*
!      * Walk the table reading in the resources.  Instance names superceed
!      * class names.
!      */
  
!     for (entry = xDefaultsValueTable; entry->iname; entry++) {
! 	if (!(option = XGetDefault (XXdisplay, class, entry->iname)))
! 	  option = XGetDefault (XXdisplay, class, entry->cname);
! 	if (option && entry->varp)
! 	  *entry->varp = option;
!     }
  
!     /*
!      * Now set global variables that aren't character strings; yes it would
!      * be nice to do this automatically as part of the scanning step, but this
!      * is less likely to screw up.  The real answer is to use the resource
!      * manager.
!      */
  
!     if (temp_reverseVideo) {
! 	if (strcmp (temp_reverseVideo, "on") == 0)
! 	  reversevideo = 1;
! 	else if (strcmp (temp_reverseVideo, "off") == 0)
! 	  reversevideo = 0;
!     }
  
!     if (temp_borderWidth) 
!       XXborder = atoi (temp_borderWidth);
  
!     if (temp_internalBorder)
!       XXInternalBorder = atoi (temp_internalBorder);
  
!     return 0;
  }
  
  x_term_init ()
  {
***************
*** 1398,1401 ****
--- 1373,1377 ----
  	register int xxargc;
  	register char **xxargv;
+ 	char *ptr;
  	extern char *getenv ();
  	extern XTinterrupt_signal ();
***************
*** 1402,1406 ****
  	extern char *malloc ();
  	XColor cdef;
- 	XColor cursor_fore, cursor_back;
  	extern Lisp_Object Vxterm, Vxterm1, Qt;
  	extern void init_sigio (), request_sigio (), unrequest_sigio ();
--- 1378,1381 ----
***************
*** 1481,1486 ****
--- 1456,1465 ----
  	XXheader = (char *) NULL;
  
+ 	XXicon_usebitmap = 0;
+ 	
  	temp_font = "fixed";
  	progname = xargv[0];
+ 	if (ptr = rindex(progname, '/'))
+ 		progname = ptr+1;
  	XXpid = getpid ();
  	default_window = "=80x24+0+0";
***************
*** 1568,1571 ****
--- 1547,1555 ----
  			xxargv++;
  		}
+ 		if (xxargc && !strcmp (*xxargv, "-i")) {
+ 			xxargc--;
+ 			xxargv++;
+ 			XXicon_usebitmap = 1;
+ 		} 
  		if ((xxargc > 1) && !strcmp (*xxargv, "-b")) {
  			xxargc--;
***************
*** 1582,1586 ****
  			xxargv++;
  		}
! 		if ((xxargc > 1) && !strcmp (*xxargv, "-w")) {
  			xxargc--;
  			xxargv++;
--- 1566,1571 ----
  			xxargv++;
  		}
! 		if ((xxargc > 1) && (!strcmp (*xxargv, "-w") ||
! 				     !strcmp (*xxargv, "-geometry"))) {
  			xxargc--;
  			xxargv++;
***************
*** 1683,1695 ****
  		}
  
- 		if (mous_color &&
- 		    XParseColor (XXdisplay, XXColorMap, mous_color, &cdef) &&
- 		    XAllocColor (XXdisplay, XXColorMap, &cdef))
- 			mous = cdef.pixel;
- 		else {
- 			mous_color = "black";
- 			mous = BlackPixel(XXdisplay,0);
- 		}
- 
  		if (brdr_color &&
  		    XParseColor (XXdisplay, XXColorMap, brdr_color, &cdef) &&
--- 1668,1671 ----
***************
*** 1703,1707 ****
  	else {
  		fore_color  = curs_color = mous_color = brdr_color = "black";
! 		fore = curs = mous = brdr = BlackPixel(XXdisplay,0);
  		back_color = "white";
  		back = WhitePixel(XXdisplay,0);
--- 1679,1683 ----
  	else {
  		fore_color  = curs_color = mous_color = brdr_color = "black";
! 		fore = curs = brdr = BlackPixel(XXdisplay,0);
  		back_color = "white";
  		back = WhitePixel(XXdisplay,0);
***************
*** 1728,1739 ****
  			curs_color = "white";
  		}
- 		if (mous == WhitePixel(XXdisplay,0)) {
- 			mous = BlackPixel(XXdisplay,0);
- 			mous_color = "black";
- 		}
- 		else if (mous == BlackPixel(XXdisplay,0)) {
- 			mous = WhitePixel(XXdisplay,0);
- 			mous_color = "white";
- 		}
  	}
  
--- 1704,1707 ----
***************
*** 1763,1783 ****
  	XInitWindow ();
  
- 
- 	cursor_fore.pixel = fore;
- 	cursor_fore.flags = 0;
- 	cursor_back.pixel = back;
- 	cursor_back.flags = 0;
- 
- 
  	Fset_input_mode (Qt, Qnil);
  	request_sigio();
  
- #ifdef BIGDEBUG
- 	*debug_string = '\0';
- 	if (1) {
- 		int dump_log();
- 		signal(SIGUSR1,dump_log);
- 	} 
- #endif BIGDEBUG	
  }
  
--- 1731,1737 ----
***************
*** 1859,1866 ****
  	{
  	    sigsetmask (mask);
- #if 0
- 	    if (QLength (XXdisplay) > 0)
- 		read_events_block ();
- #endif
  	    return  -1;
  	}
--- 1813,1816 ----
***************
*** 1878,1885 ****
  
  	sigsetmask (mask);
! #if 0
! 	if (QLength (XXdisplay) > 0)
! 		read_events_block ();
! #endif	
  	return 0;
  }
--- 1828,1832 ----
  
  	sigsetmask (mask);
! 	
  	return 0;
  }
***************
*** 1892,1896 ****
  	char *tempname;
  	int mask = sigblock (sigmask (SIGIO));
! 
  	CursorToggle ();
  	XSetWindowBackground(XXdisplay, XXwindow, fore);
--- 1839,1844 ----
  	char *tempname;
  	int mask = sigblock (sigmask (SIGIO));
! 	XColor forec, backc;
! 	
  	CursorToggle ();
  	XSetWindowBackground(XXdisplay, XXwindow, fore);
***************
*** 1914,1917 ****
--- 1862,1870 ----
  	XXgc_rev = XXgc_temp;
  
+ 	if (XXisColor && mous_color &&
+ 	    XParseColor (XXdisplay, XXColorMap, mous_color, &forec) &&
+ 	    XParseColor (XXdisplay, XXColorMap, back_color, &backc))
+ 	  XRecolorCursor (XXdisplay, EmacsCursor, &forec, &backc);
+ 
  	XRedrawDisplay ();
  	if (curs == WhitePixel(XXdisplay,0)) {
***************
*** 1926,1938 ****
  	XSetState (XXdisplay, XXgc_curs, back, curs, GXinvert, AllPlanes);
  
- 	if (mous == WhitePixel(XXdisplay,0)) {
- 		mous = BlackPixel(XXdisplay,0);
- 		mous_color = "black";
- 	}
- 	else
- 		if (mous == BlackPixel(XXdisplay,0)) {
- 			mous = WhitePixel(XXdisplay,0);
- 			mous_color = "white";
- 		}
  	CursorToggle ();
  	XFlush (XXdisplay);
--- 1879,1882 ----
***************
*** 2088,2094 ****
  	sizehints.flags = (do_resize) ? USSize : USPosition|USSize;
  
-     sizehints.flags |= PResizeInc|PMinSize;
- 
- 
      sizehints.x = x;
      sizehints.y = y;
--- 2032,2035 ----
***************
*** 2109,2113 ****
      }
  
! 
      sizehints.width_inc = XXfontw;
      sizehints.height_inc = XXfonth;
--- 2050,2055 ----
      }
  
!     sizehints.flags |= PResizeInc|PMinSize;
!     
      sizehints.width_inc = XXfontw;
      sizehints.height_inc = XXfonth;
***************
*** 2116,2119 ****
--- 2058,2077 ----
      sizehints.min_height = XXfonth*MINHEIGHT+2*XXInternalBorder;
  
+     /*
+      * Until the new X Inter-Client Communications Conventions are adopted,
+      * the minimum sizes are really the base sizes.
+      */
+ #ifdef XICCC
+     sizehints.base_width = 2 * XXInternalBorder;
+     sizehints.base_height = 2 * XXInternalBorder;
+     sizehints.min_width = XXfontw * MINWIDTH + sizehints.base_width;
+     sizehints.min_height = XXfonth * MINHEIGHT + sizehints.base_height;
+     sizehints.flags |= PBaseSize;
+ #else
+     /* old, broken versions */
+     sizehints.min_width = 2 * XXInternalBorder;
+     sizehints.min_height = 2 * XXInternalBorder;
+ #endif
+ 
      XSetNormalHints(XXdisplay, w, &sizehints);
  }
***************
*** 2139,2146 ****
      XWMHints  wmhints;
  
- 
-     wmhints.flags = InputHint | StateHint |
- 	    IconPixmapHint | IconMaskHint;
      
      wmhints.input = True;
      wmhints.initial_state = NormalState;
--- 2097,2105 ----
      XWMHints  wmhints;
  
      
+     wmhints.flags = InputHint | StateHint;
+     if (XXicon_usebitmap)
+ 	    wmhints.flags |= IconPixmapHint | IconMaskHint;
+     
      wmhints.input = True;
      wmhints.initial_state = NormalState;
***************
*** 2149,2153 ****
  					sink_bits, sink_width,
  					sink_height);
- 
      SinkMaskPixmap = XCreateBitmapFromData (XXdisplay, w,
  					    sink_mask_bits,
--- 2108,2111 ----
***************
*** 2154,2159 ****
  					    sink_mask_width,
  					    sink_mask_height);
!     wmhints.icon_pixmap = SinkPixmap;
!     wmhints.icon_mask = SinkMaskPixmap;
  
      XSetWMHints(XXdisplay, w, &wmhints);
--- 2112,2123 ----
  					    sink_mask_width,
  					    sink_mask_height);
!     if (XXicon_usebitmap) {
! 	    wmhints.icon_pixmap = SinkPixmap;
! 	    wmhints.icon_mask = SinkMaskPixmap;
!     }
!     else {
! 	    wmhints.icon_pixmap = 0;
! 	    wmhints.icon_mask = 0;
!     } 
  
      XSetWMHints(XXdisplay, w, &wmhints);
***************
*** 2181,2189 ****
      char  *dp;
      Window  desktop;
  
- 
      if ( (fontinfo = XT_CalcForFont(XXcurrentfont))
  	== (XFontStruct *) NULL)
      {
  	exit (-98);
      }
--- 2145,2156 ----
      char  *dp;
      Window  desktop;
+     XColor forec, backc;
  
      if ( (fontinfo = XT_CalcForFont(XXcurrentfont))
  	== (XFontStruct *) NULL)
      {
+ 	fprintf (stderr, "X server unable to find requested font '%s'!.\n",
+ 		 (XXcurrentfont == NULL) ? "(null)" :  XXcurrentfont);
+ 	fflush (stderr);
  	exit (-98);
      }
***************
*** 2204,2208 ****
      else
      {
! 	desktop = RootWindow(XXdisplay, 0);
      }
  
--- 2171,2175 ----
      else
      {
! 	desktop = RootWindow(XXdisplay, DefaultScreen(XXdisplay));
      }
  
***************
*** 2236,2243 ****
  			  &XXgcv);
      
!     EmacsCursor = XCreateFontCursor(XXdisplay, XC_left_ptr);
      XDefineCursor (XXdisplay, XXwindow, EmacsCursor);
      
      CursorExists = 0;
      VisibleX = 0;
      VisibleY = 0;
--- 2203,2217 ----
  			  &XXgcv);
      
!     EmacsCursor = XCreateFontCursor(XXdisplay, XC_left_ptr);    
! 
!     if (XXisColor && mous_color &&
! 	XParseColor (XXdisplay, XXColorMap, mous_color, &forec) &&
! 	XParseColor (XXdisplay, XXColorMap, back_color, &backc))
!       XRecolorCursor (XXdisplay, EmacsCursor, &forec, &backc);
! 
      XDefineCursor (XXdisplay, XXwindow, EmacsCursor);
      
      CursorExists = 0;
+     CursorOutline = 1;
      VisibleX = 0;
      VisibleY = 0;
***************
*** 2255,2258 ****
--- 2229,2233 ----
      XSelectInput(XXdisplay, XXwindow, KeyPressMask | 
  		 ExposureMask | ButtonPressMask | ButtonReleaseMask |
+ 		 EnterWindowMask | LeaveWindowMask |
  		 StructureNotifyMask);
  
***************
*** 2261,2286 ****
  }
  
- #ifdef BIGDEBUG
- 
- my_log(s,a,b,c,d,e,f,g,h)
- 	char *s;
- {
- 	char bfr[256];
- 	
- 	sprintf(bfr,s,a,b,c,d,e,f,g,h);
- 
- 	strcat(debug_string,bfr);
- }
- 
- dump_log()
- {
- 	fputs(debug_string,stderr);
- 	fflush(stderr);
- 	*debug_string = '\0';
- }
- 
- #endif BIGDEBUG
- 	
  #endif /* HAVE_X_WINDOWS */
- 
- /*#include "xundebug.h"*/
--- 2236,2238 ----
diff -rc2 dist-18.50/src/x11term.h dist-18.51/src/x11term.h
*** dist-18.50/src/x11term.h	Mon Feb 29 12:51:43 1988
--- dist-18.51/src/x11term.h	Sun Apr  3 00:48:23 1988
***************
*** 1,12 ****
! #include <X/Xlib.h>
! #include <X/Xatom.h>
! #include <X/keysym.h>
! #include <X/cursorfont.h>
! #include <X/Xutil.h>
! #include <X/X10.h>
  
! #ifndef X11
! #define X11
! #endif X11
  
  #define XMOUSEBUFSIZE 64
--- 1,9 ----
! #include <X11/Xlib.h>
! #include <X11/Xatom.h>
! #include <X11/keysym.h>
  
! #include <X11/cursorfont.h>
! #include <X11/Xutil.h>
! #include <X11/X10.h>
  
  #define XMOUSEBUFSIZE 64
***************
*** 15,16 ****
--- 12,15 ----
  #define sigmask(no) (1L << ((no) - 1))
  #endif
+ 
+ #define CLASS  "emacs"	/* class id for GNU Emacs, used in .Xdefaults, etc. */
==================================================== New file src/sink_11.h
/* $Header: sink_11.h,v 1.1 88/02/06 16:55:50 rfrench Exp $ */
#define sink_width 48
#define sink_height 48
static char sink_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
   0xff, 0xff, 0xff, 0xff, 0x80, 0x9f, 
   0xff, 0xff, 0xff, 0xff, 0x9f, 0x9f, 
   0xff, 0xff, 0xff, 0xff, 0x00, 0x80, 
   0xff, 0xff, 0xff, 0x7f, 0xfe, 0xbf, 
   0xff, 0xff, 0xff, 0x7f, 0x03, 0xa0, 
   0xff, 0xff, 0xff, 0x7f, 0xfd, 0xaf, 
   0xff, 0xff, 0xff, 0x3f, 0xf9, 0xaf, 
   0xff, 0xff, 0xff, 0xff, 0xff, 0xaf, 
   0xff, 0xff, 0xff, 0xff, 0xfc, 0xaf, 
   0xff, 0xff, 0xff, 0x7f, 0xf8, 0xaf, 
   0xff, 0xff, 0xff, 0xff, 0xfc, 0xaf, 
   0xff, 0xff, 0xff, 0xff, 0xff, 0xaf, 
   0xff, 0xff, 0xff, 0xbf, 0xf7, 0xaf, 
   0xff, 0xff, 0xff, 0x3f, 0xf3, 0xaf, 
   0xff, 0xff, 0xff, 0xff, 0xfc, 0xaf, 
   0x3f, 0x00, 0x00, 0x00, 0x00, 0x20, 
   0x7f, 0x00, 0x00, 0x00, 0x00, 0xe0, 
   0xdf, 0xf8, 0xff, 0xff, 0xff, 0x07, 
   0xcf, 0xf9, 0x0f, 0xff, 0xff, 0xe7, 
   0xcf, 0xf9, 0xf7, 0xff, 0xff, 0xe7, 
   0xff, 0xf9, 0xf7, 0x63, 0xfb, 0xe7, 
   0xff, 0xf9, 0x37, 0x5a, 0xfb, 0xe7, 
   0xcf, 0xf9, 0xf7, 0x5a, 0xfb, 0xe7, 
   0xcf, 0xf9, 0xf7, 0x5a, 0xf9, 0xe7, 
   0xef, 0xf9, 0x0f, 0xdb, 0xfa, 0xe7, 
   0xff, 0xf9, 0xff, 0xff, 0xff, 0xe7, 
   0xdf, 0xf9, 0xff, 0xff, 0xff, 0xe7, 
   0xcf, 0x19, 0xfc, 0xff, 0xff, 0xe7, 
   0xcf, 0xd9, 0xff, 0xff, 0xff, 0xe7, 
   0xff, 0xd9, 0x47, 0xce, 0x73, 0xe6, 
   0xff, 0x19, 0xb6, 0xb5, 0xad, 0xe7, 
   0xcf, 0xd9, 0xb7, 0xb5, 0x7d, 0xe6, 
   0xc7, 0xd9, 0xb7, 0xb5, 0xed, 0xe5, 
   0xef, 0x19, 0xb4, 0x4d, 0x73, 0xe6, 
   0xff, 0xf1, 0xff, 0xff, 0xff, 0xe3, 
   0xff, 0x03, 0x80, 0x03, 0x00, 0xf0, 
   0xef, 0x07, 0x00, 0x01, 0x00, 0xf8, 
   0xc7, 0xff, 0x3f, 0xf9, 0xff, 0xff, 
   0xe7, 0xff, 0x7f, 0xfd, 0xe0, 0xff, 
   0xff, 0xff, 0x7f, 0x7d, 0xdf, 0xff, 
   0xff, 0xff, 0x7f, 0xbd, 0xb1, 0xff, 
   0xff, 0xff, 0x7f, 0xbb, 0xae, 0xff, 
   0xef, 0xff, 0xff, 0xda, 0xae, 0xff, 
   0xc7, 0xff, 0xff, 0x66, 0xaf, 0xff, 
   0xe7, 0xff, 0xff, 0xbd, 0xaf, 0xff, 
   0xff, 0xff, 0xff, 0xc3, 0xaf, 0xff, 
   0xff, 0xff, 0xff, 0xff, 0xaf, 0xff};
==================================================== New file src/sinkmask_11.h
/* $Header: sinkmask_11.h,v 1.1 88/02/06 16:55:53 rfrench Exp $ */
#define sink_mask_width 48
#define sink_mask_height 48
static char sink_mask_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 


Christopher Welty  ---  Asst. Director, RPI CS Labs
weltyc@cs.rpi.edu       ...!rutgers!nysernic!weltyc

weltyc@nysernic (Christopher A. Welty) (04/06/88)

In article <645@nysernic> weltyc@nisc.nyser.net (Christopher A. Welty) writes:
>
>These are the diffs to GNU Emacs 18.50.
>

	OK, I goofed.   The fixes I posted apparently don't work.  I
thought I had tested them but I never installed them (fooled myself),
and someone else has had problems with them.  I will investigate and
repost the correct diffs.   Please don't hate me.

Christopher Welty  ---  Asst. Director, RPI CS Labs
weltyc@cs.rpi.edu       ...!rutgers!nysernic!weltyc