*** empty log message ***
authorJim Blandy <jimb@redhat.com>
Wed, 10 Jun 1992 03:53:16 +0000 (03:53 +0000)
committerJim Blandy <jimb@redhat.com>
Wed, 10 Jun 1992 03:53:16 +0000 (03:53 +0000)
src/dispnew.c
src/frame.c
src/keyboard.c
src/search.c
src/termhooks.h
src/window.c
src/xfns.c
src/xselect.c.old
src/xterm.c

index 8b4abb2..b1ea5d2 100644 (file)
@@ -96,8 +96,9 @@ Lisp_Object Vglyph_table;
 Lisp_Object Vstandard_display_table;
 
 /* Nonzero means reading single-character input with prompt
-   so put cursor on minibuffer after the prompt.  */
-
+   so put cursor on minibuffer after the prompt.
+   positive means at end of text in echo area;
+   negative means at beginning of line.  */
 int cursor_in_echo_area;
 \f
 /* The currently selected screen.
@@ -1056,16 +1057,19 @@ update_screen (s, force, inhibit_hairy_id)
   /* Now just clean up termcap drivers and set cursor, etc.  */
   if (!pause)
     {
-
-      if (s == selected_screen && cursor_in_echo_area < 0)
-       cursor_to (SCREEN_HEIGHT (s) - 1, 0);
-      else if (s == selected_screen && cursor_in_echo_area
-              && !desired_screen->used[SCREEN_HEIGHT (s) - 1])
-       cursor_to (SCREEN_HEIGHT (s), 0);
-      else if (cursor_in_echo_area)
-       cursor_to (SCREEN_HEIGHT (s) - 1,
-                  min (SCREEN_WIDTH (s) - 1,
-                       desired_screen->used[SCREEN_HEIGHT (s) - 1]));
+      if (cursor_in_echo_area)
+       {
+         if (s == selected_screen
+             && cursor_in_echo_area < 0)
+           cursor_to (SCREEN_HEIGHT (s) - 1, 0);
+         else if (s == selected_screen
+                  && ! current_screen->enable[SCREEN_HEIGHT (s) - 1])
+           cursor_to (SCREEN_HEIGHT (s) - 1, 0);
+         else
+           cursor_to (SCREEN_HEIGHT (s) - 1,
+                      min (SCREEN_WIDTH (s) - 1,
+                           current_screen->used[SCREEN_HEIGHT (s) - 1]));
+       }
       else
        cursor_to (SCREEN_CURSOR_Y (s), max (min (SCREEN_CURSOR_X (s),
                                                  SCREEN_WIDTH (s) - 1), 0));
@@ -1906,9 +1910,10 @@ Value is t if waited the full time with no input arriving.")
      Lisp_Object arg, millisec, nodisp;
 {
   int usec = 0;
-  int sec = 0;
+  int sec;
 
   CHECK_NUMBER (arg, 0);
+  sec = XINT (arg);
 
   if (!NILP (millisec))
     {
index b1c452a..da42dd2 100644 (file)
@@ -1,11 +1,11 @@
 /* Generic screen functions.
-   Copyright (C) 1989 Free Software Foundation.
+   Copyright (C) 1989, 1992 Free Software Foundation.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -194,7 +194,9 @@ make_screen_without_minibuffer (mini_window)
   if (NILP (mini_window))
     {
       if (XTYPE (Vdefault_minibuffer_screen) != Lisp_Screen)
-       error ("default-minibuffer-screen must be set when creating minibufferless screens.");
+       error ("default-minibuffer-screen must be set when creating minibufferless screens");
+      if (! SCREEN_LIVE_P (XSCREEN (Vdefault_minibuffer_screen)))
+       error ("default-minibuffer-screen must be a live screen");
       mini_window = XSCREEN (Vdefault_minibuffer_screen)->minibuffer_window;
     }
   else
@@ -492,16 +494,22 @@ A screen may not be deleted if its minibuffer is used by other screens.")
      minibuffer for any other screen?  */
   if (SCREEN_HAS_MINIBUF (XSCREEN (screen)))
     {
-      Lisp_Object screen2;
-
-      for (screen2 = Vscreen_list; CONSP (2); screen2 = XCONS (screen2)->cdr)
-       if (! EQ (screen2, screen)
-           && EQ (screen,
-                  (WINDOW_SCREEN
-                   (XWINDOW
-                    (SCREEN_MINIBUF_WINDOW
-                     (XSCREEN (screen2)))))))
-         error ("Attempt to delete a surrogate minibuffer screen");
+      Lisp_Object screens;
+
+      for (screens = Vscreen_list;
+          CONSP (screens);
+          screens = XCONS (screens)->cdr)
+       {
+         Lisp_Object this = XCONS (screens)->car;
+
+         if (! EQ (this, screen)
+             && EQ (screen,
+                    (WINDOW_SCREEN
+                     (XWINDOW
+                      (SCREEN_MINIBUF_WINDOW
+                       (XSCREEN (this)))))))
+           error ("Attempt to delete a surrogate minibuffer screen");
+       }
     }
 
   /* Don't let the screen remain selected.  */
@@ -530,11 +538,15 @@ A screen may not be deleted if its minibuffer is used by other screens.")
      another one.  */
   if (s == last_nonminibuf_screen)
     {
+      Lisp_Object screens;
+
       last_nonminibuf_screen = 0;
 
-      for (screen = Vscreen_list; CONSP (screen); screen = XCONS (screen)->cdr)
+      for (screens = Vscreen_list;
+          CONSP (screens);
+          screen = XCONS (screens)->cdr)
        {
-         s = XSCREEN (XCONS (screen)->car);
+         s = XSCREEN (XCONS (screens)->car);
          if (!SCREEN_MINIBUF_ONLY_P (s))
            {
              last_nonminibuf_screen = s;
@@ -543,6 +555,46 @@ A screen may not be deleted if its minibuffer is used by other screens.")
        }
     }
 
+  /* If we've deleted Vdefault_minibuffer_screen, try to find another
+     one.  Prefer minibuffer-only screens, but also notice screens
+     with other windows.  */
+  if (EQ (screen, Vdefault_minibuffer_screen))
+    {
+      Lisp_Object screens;
+
+      /* The last screen we saw with a minibuffer, minibuffer-only or not.  */
+      Lisp_Object screen_with_minibuf = Qnil;
+
+      for (screens = Vscreen_list;
+          CONSP (screens);
+          screens = XCONS (screens)->cdr)
+       {
+         Lisp_Object this = XCONS (screens)->car;
+
+         if (XTYPE (this) != Lisp_Screen)
+           abort ();
+         s = XSCREEN (this);
+
+         if (SCREEN_HAS_MINIBUF (s))
+           {
+             screen_with_minibuf = this;
+             if (SCREEN_MINIBUF_ONLY_P (s))
+               break;
+           }
+       }
+
+      /* We know that there must be some screen with a minibuffer out
+        there.  If this were not true, all of the screens present
+        would have to be minibufferless, which implies that at some
+        point their minibuffer screens must have been deleted, but
+        that is prohibited at the top; you can't delete surrogate
+        minibuffer screens.  */
+      if (NILP (screen_with_minibuf))
+       abort ();
+
+      Vdefault_minibuffer_screen = screen_with_minibuf;
+    }
+
   return Qnil;
 }
 \f
index 56d94a2..2afccde 100644 (file)
@@ -210,7 +210,8 @@ Lisp_Object Vmouse_motion_handler;
    new screen.  */
 Lisp_Object Vlast_event_screen;
 
-/* X Windows wants this for selection ownership.  */
+/* The timestamp of the last input event we received from the X server.
+   X Windows wants this for selection ownership.  */
 unsigned long last_event_timestamp;
 
 Lisp_Object Qself_insert_command;
@@ -1610,7 +1611,7 @@ kbd_buffer_get_event ()
       if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
        kbd_fetch_ptr = kbd_buffer;
       XSET (Vlast_event_screen, Lisp_Screen, kbd_fetch_ptr->screen);
-      last_event_timestamp = XINT (kbd_fetch_ptr->timestamp);
+      last_event_timestamp = kbd_fetch_ptr->timestamp;
       obj = make_lispy_event (kbd_fetch_ptr);
       kbd_fetch_ptr->kind = no_event;
       kbd_fetch_ptr++;
@@ -1791,7 +1792,8 @@ make_lispy_event (event)
                      Fcons (window,
                             Fcons (posn,
                                    Fcons (Fcons (event->x, event->y),
-                                          Fcons (event->timestamp,
+                                          Fcons (make_number
+                                                 (event->timestamp),
                                                  Qnil)))));
       }
 
@@ -1810,7 +1812,8 @@ make_lispy_event (event)
                      Fcons (SCREEN_SELECTED_WINDOW (event->screen),
                             Fcons (button,
                                    Fcons (Fcons (event->x, event->y),
-                                          Fcons (event->timestamp,
+                                          Fcons (make_number
+                                                 (event->timestamp),
                                                  Qnil)))));
       }
 
@@ -1872,8 +1875,8 @@ format_modifiers (modifiers, buf)
 {
   char *p = buf;
 
-  if (modifiers & meta_modifier) { *p++ = 'M'; *p++ = '-'; }
   if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; }
+  if (modifiers & meta_modifier) { *p++ = 'M'; *p++ = '-'; }
   if (modifiers & shift_modifier) { *p++ = 'S'; *p++ = '-'; }
   if (modifiers & up_modifier) { *p++ = 'U'; *p++ = '-'; }
   *p = '\0';
@@ -2982,17 +2985,31 @@ DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_
                               Vobarray, Qcommandp,
                               Qt, Qnil, Qnil);
 
-  /* Add the text read to this_command_keys.  */
+  /* Set this_command_keys to the concatenation of saved_keys and
+     function, followed by a RET.  */
   {
-    struct Lisp_String *func_str = XSTRING (function);
+    struct Lisp_String *str;
     int i;
     Lisp_Object tem;
 
-    for (i = 0; i < func_str->size; i++)
+    this_command_key_count = 0;
+
+    str = XSTRING (saved_keys);
+    for (i = 0; i < str->size; i++)
       {
-       XSET (tem, Lisp_Int, func_str->data[i]);
+       XFASTINT (tem) = str->data[i];
        add_command_key (tem);
       }
+
+    str = XSTRING (function);
+    for (i = 0; i < str->size; i++)
+      {
+       XFASTINT (tem) = str->data[i];
+       add_command_key (tem);
+      }
+
+    XFASTINT (tem) = '\015';
+    add_command_key (tem);
   }
 
   UNGCPRO;
index 5f1f17f..88eb72a 100644 (file)
@@ -47,8 +47,16 @@ Lisp_Object last_regexp;
 
    Since the registers are now dynamically allocated, we need to make
    sure not to refer to the Nth register before checking that it has
-   been allocated.  */
-
+   been allocated by checking search_regs.num_regs.
+
+   The regex code keeps track of whether it has allocated the search
+   buffer using bits in searchbuf.  This means that whenever you
+   compile a new pattern, it completely forgets whether it has
+   allocated any registers, and will allocate new registers the next
+   time you call a searching or matching function.  Therefore, we need
+   to call re_set_registers after compiling a new pattern or after
+   setting the match registers, so that the regex functions will be
+   able to free or re-allocate it properly.  */
 static struct re_registers search_regs;
 
 /* Nonzero if search_regs are indices in a string; 0 if in a buffer.  */
@@ -73,9 +81,10 @@ matcher_overflow ()
 
 /* Compile a regexp and signal a Lisp error if anything goes wrong.  */
 
-compile_pattern (pattern, bufp, translate)
+compile_pattern (pattern, bufp, regp, translate)
      Lisp_Object pattern;
      struct re_pattern_buffer *bufp;
+     struct re_registers *regp;
      char *translate;
 {
   CONST char *val;
@@ -84,6 +93,7 @@ compile_pattern (pattern, bufp, translate)
   if (EQ (pattern, last_regexp)
       && translate == bufp->translate)
     return;
+
   last_regexp = Qnil;
   bufp->translate = translate;
   val = re_compile_pattern ((char *) XSTRING (pattern)->data,
@@ -95,7 +105,13 @@ compile_pattern (pattern, bufp, translate)
       while (1)
        Fsignal (Qinvalid_regexp, Fcons (dummy, Qnil));
     }
+
   last_regexp = pattern;
+
+  /* Advise the searching functions about the space we have allocated
+     for register data.  */
+  re_set_registers (bufp, regp, regp->num_regs, regp->start, regp->end);
+
   return;
 }
 
@@ -124,7 +140,7 @@ data if you want to preserve them.")
   register int i;
 
   CHECK_STRING (string, 0);
-  compile_pattern (string, &searchbuf,
+  compile_pattern (string, &searchbuf, &search_regs,
                   !NILP (current_buffer->case_fold_search) ? DOWNCASE_TABLE : 0);
 
   immediate_quit = 1;
@@ -196,7 +212,7 @@ matched by parenthesis constructs in the pattern.")
        args_out_of_range (string, start);
     }
 
-  compile_pattern (regexp, &searchbuf,
+  compile_pattern (regexp, &searchbuf, &search_regs,
                   !NILP (current_buffer->case_fold_search) ? DOWNCASE_TABLE : 0);
   immediate_quit = 1;
   val = re_search (&searchbuf, (char *) XSTRING (string)->data,
@@ -506,7 +522,7 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt)
     return pos;
 
   if (RE)
-    compile_pattern (string, &searchbuf, (char *) trt);
+    compile_pattern (string, &searchbuf, &search_regs, (char *) trt);
   
   if (RE                       /* Here we detect whether the */
                                /* generality of an RE search is */
@@ -768,6 +784,22 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt)
                  if (i + direction == 0)
                    {
                      cursor -= direction;
+
+                     /* Make sure we have registers in which to store
+                        the match position.  */
+                     if (search_regs.num_regs == 0)
+                       {
+                         regoff_t *starts, *ends;
+
+                         starts =
+                           (regoff_t *) xmalloc (2 * sizeof (regoff_t));
+                         ends =
+                           (regoff_t *) xmalloc (2 * sizeof (regoff_t));
+                         re_set_registers (&searchbuf,
+                                           &search_regs,
+                                           2, starts, ends);
+                       }
+
                      search_regs.start[0]
                        = pos + cursor - p2 + ((direction > 0)
                                               ? 1 - len : 0);
@@ -827,6 +859,22 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt)
                  if (i + direction == 0)
                    {
                      pos -= direction;
+
+                     /* Make sure we have registers in which to store
+                        the match position.  */
+                     if (search_regs.num_regs == 0)
+                       {
+                         regoff_t *starts, *ends;
+
+                         starts =
+                           (regoff_t *) xmalloc (2 * sizeof (regoff_t));
+                         ends =
+                           (regoff_t *) xmalloc (2 * sizeof (regoff_t));
+                         re_set_registers (&searchbuf,
+                                           &search_regs,
+                                           2, starts, ends);
+                       }
+
                      search_regs.start[0]
                        = pos + ((direction > 0) ? 1 - len : 0);
                      search_regs.end[0] = len + search_regs.start[0];
@@ -1004,6 +1052,7 @@ Otherwise treat `\\' as special:\n\
   `\\N' means substitute what matched the Nth `\\(...\\)'.\n\
        If Nth parens didn't match, substitute nothing.\n\
   `\\\\' means insert one `\\'.\n\
+FIXEDCASE and LITERAL are optional arguments.\n\
 Leaves point at end of replacement text.")
   (string, fixedcase, literal)
      Lisp_Object string, fixedcase, literal;
@@ -1221,20 +1270,25 @@ LIST should have been created by calling `match-data' previously.")
 
     if (length > search_regs.num_regs)
       {
-       if (search_regs.start)
-         search_regs.start =
-           (regoff_t *) realloc (search_regs.start,
-                                 length * sizeof (regoff_t));
-       else
-         search_regs.start = (regoff_t *) malloc (length * sizeof (regoff_t));
-       if (search_regs.end)
-         search_regs.end =
-           (regoff_t *) realloc (search_regs.end,
-                                 length * sizeof (regoff_t));
+       if (search_regs.num_regs == 0)
+         {
+           search_regs.start
+             = (regoff_t *) xmalloc (length * sizeof (regoff_t));
+           search_regs.end
+             = (regoff_t *) xmalloc (length * sizeof (regoff_t));
+         }
        else
-         search_regs.end = (regoff_t *) malloc (length * sizeof (regoff_t));
+         {
+           search_regs.start
+             = (regoff_t *) xrealloc (search_regs.start,
+                                      length * sizeof (regoff_t));
+           search_regs.end
+             = (regoff_t *) xrealloc (search_regs.end,
+                                      length * sizeof (regoff_t));
+         }
 
-       search_regs.num_regs = length;
+       re_set_registers (&searchbuf, &search_regs, length,
+                         search_regs.start, search_regs.end);
       }
   }
 
index 08c8e81..b9363eb 100644 (file)
@@ -105,7 +105,7 @@ struct input_event {
                                   .modifiers holds the state of the
                                   modifier keys.
                                   .x and .y give the mouse position,
-                                  in pixels, within the window.
+                                  in characters, within the window.
                                   .screen gives the screen the mouse
                                   click occurred in.
                                   .timestamp gives a timestamp (in
index 5f888f8..41171a3 100644 (file)
@@ -1,12 +1,12 @@
 /* Window creation, deletion and examination for GNU Emacs.
    Does not include redisplay.
-   Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -357,7 +357,10 @@ coordinates_in_window (w, x, y)
 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p,
   Scoordinates_in_window_p, 2, 2, 0,
   "Return non-nil if COORDINATES are in WINDOW.\n\
-COORDINATES is a cons of the form (X . Y), X and Y being screen-relative.\n\
+COORDINATES is a cons of the form (X . Y), X and Y being distances\n\
+measured in characters from the upper-left corner of the screen.\n\
+(0 .  0) denotes the character in the upper left corner of the\n\
+screen.\n\
 If COORDINATES are in the text portion of WINDOW,\n\
    the coordinates relative to the window are returned.\n\
 If they are in the mode line of WINDOW, 'mode-line is returned.\n\
index b445fb0..6d32925 100644 (file)
@@ -1,11 +1,11 @@
 /* Functions for the X window system.
-   Copyright (C) 1989 Free Software Foundation.
+   Copyright (C) 1989, 1992 Free Software Foundation.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -1045,6 +1045,17 @@ x_set_name (s, arg, oldval)
 
   if (s->display.x->window_desc)
     {
+#ifdef HAVE_X11
+      XTextProperty prop;
+      prop.value = XSTRING (arg)->data;
+      prop.encoding = XA_STRING;
+      prop.format = 8;
+      prop.nitems = XSTRING (arg)->size;
+      BLOCK_INPUT;
+      XSetWMName (XDISPLAY s->display.x->window_desc, &prop);
+      XSetWMIconName (XDISPLAY s->display.x->window_desc, &prop);
+      UNBLOCK_INPUT;
+#else
       s->name = arg;
       BLOCK_INPUT;
       XStoreName (XDISPLAY s->display.x->window_desc,
@@ -1052,6 +1063,7 @@ x_set_name (s, arg, oldval)
       XSetIconName (XDISPLAY s->display.x->window_desc,
                    (char *) XSTRING (arg)->data);
       UNBLOCK_INPUT;
+#endif
     }
 }
 
@@ -2102,8 +2114,19 @@ be shared by the new screen.")
   x_set_resize_hint (s);
 
   /* Tell the server the window's default name.  */
-
+#ifdef HAVE_X11
+  {
+    XTextProperty prop;
+    prop.value = XSTRING (s->name)->data;
+    prop.encoding = XA_STRING;
+    prop.format = 8;
+    prop.nitems = XSTRING (s->name)->size;
+    XSetWMName (XDISPLAY s->display.x->window_desc, &prop);
+  }
+#else
   XStoreName (XDISPLAY s->display.x->window_desc, XSTRING (s->name)->data);
+#endif
+
   /* Now override the defaults with all the rest of the specified
      parms.  */
   tem = x_get_arg (parms, intern ("unsplittable"), 0, 0);
index a88208b..dea8a1c 100644 (file)
@@ -29,11 +29,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define MAX_SELECTION(dpy) (((dpy)->max_request_size << 2) - 100)
 #define SELECTION_LENGTH(len,format) ((len) * ((format) >> 2))
 
-/* The last 23 bits of the timestamp of the last mouse button event. */
-extern Time mouse_timestamp;
-
-/* An expedient hack!  Fix this!  */
-#define last_event_timestamp CurrentTime
+/* The timestamp of the last input event we received from the X server.  */
+unsigned long last_event_timestamp;
 
 /* t if a mouse button is depressed. */
 extern Lisp_Object Vmouse_grabbed;
@@ -56,8 +53,10 @@ Lisp_Object Vx_selection_value;
 /* The value of the current SECONDARY selection. */
 Lisp_Object Vx_secondary_selection_value;
 
-/* Types of selections we may make. */
-Lisp_Object Qprimary, Qsecondary, Qclipboard;
+/* Types of selections we may make.  Note that Qcut_buffer0 isn't really
+   a selection, but it acts like one for the sake of Fx_own_selection and
+   Fx_selection_value.  */
+Lisp_Object Qprimary, Qsecondary, Qclipboard, Qcut_buffer0;
 
 /* Emacs' selection property identifiers. */
 Atom Xatom_emacs_selection;
@@ -146,13 +145,18 @@ own_selection (selection_type, time)
 DEFUN ("x-own-selection", Fx_own_selection, Sx_own_selection,
   1, 2, "",
   "Make STRING the selection value.  Default is the primary selection,\n\
-but optional second argument TYPE may specify secondary or clipboard.")
+but optional second argument TYPE may specify secondary or clipboard.\n\
+\n\
+TYPE may also be cut-buffer0, indicating that Emacs should set the X\n\
+cut buffer 0 to STRING.  This is for compatibility with older X\n\
+applications which still use the cut buffers; new applications should\n\
+use X selections.")
   (string, type)
      register Lisp_Object string, type;
 {
   Atom selection_type;
   Lisp_Object val;
-  Time event_time = mouse_timestamp;
+  Time event_time = last_event_timestamp;
   CHECK_STRING (string, 0);
 
   if (NILP (type) || EQ (type, Qprimary))
@@ -163,7 +167,7 @@ but optional second argument TYPE may specify secondary or clipboard.")
          x_begin_selection_own = event_time;
          val = Vx_selection_value = string;
        }
-         UNBLOCK_INPUT;
+      UNBLOCK_INPUT;
     }
   else if (EQ (type, Qsecondary))
     {
@@ -180,10 +184,18 @@ but optional second argument TYPE may specify secondary or clipboard.")
       BLOCK_INPUT;
       if (own_selection (Xatom_clipboard, event_time))
        {
-  x_begin_clipboard_own = event_time;
+         x_begin_clipboard_own = event_time;
          val = Vx_clipboard_value = string;
        }
-  UNBLOCK_INPUT;
+      UNBLOCK_INPUT;
+    }
+  else if (EQ (type, Qcut_buffer0))
+    {
+      BLOCK_INPUT;
+      XStoreBytes (x_current_display,
+                  XSTRING (string)->data,
+                  XSTRING (string)->size);
+      UNBLOCK_INPUT;
     }
   else
     error ("Invalid X selection type");
@@ -230,7 +242,7 @@ int x_selection_alloc_error;
 int x_converting_selection;
 
 /* Reply to some client's request for our selection data.  Data is
-   placed in a propery supplied by the requesting window.
+   placed in a property supplied by the requesting window.
 
    If the data exceeds the maximum amount the server can send,
    then prepare to send it incrementally, and reply to the client with
@@ -518,7 +530,7 @@ get_selection_value (type)
   Window requestor_window;
 
   BLOCK_INPUT;
-  requestor_time = mouse_timestamp;
+  requestor_time = last_event_timestamp;
   requestor_window = selected_screen->display.x->window_desc;
   XConvertSelection (x_current_display, type, XA_STRING,
                     Xatom_emacs_selection, requestor_window, requestor_time);
@@ -566,6 +578,22 @@ selection, but optional argument TYPE may specify secondary or clipboard.")
 
       return get_selection_value (Xatom_clipboard);
     }
+  else if (EQ (type, Qcut_buffer0))
+    {
+      char *data;
+      int size;
+      Lisp_Object string;
+
+      BLOCK_INPUT;
+      data = XFetchBytes (x_current_display, &size);
+      if (data == 0)
+       string = Qnil;
+      else
+       string = make_string (data, size);
+      UNBLOCK_INPUT;
+      
+      return string;
+    }
   else
     error ("Invalid X selection type");
 }
@@ -704,6 +732,8 @@ syms_of_xselect ()
   staticpro (&Qsecondary);
   Qclipboard = intern ("clipboard");
   staticpro (&Qclipboard);
+  Qcut_buffer0 = intern ("cut-buffer0");
+  staticpro (&Qcut_buffer0);
 
   defsubr (&Sx_own_selection);
   defsubr (&Sx_selection_value);
index 69c16d8..7bf039a 100644 (file)
@@ -1465,10 +1465,9 @@ construct_mouse_click (result, event, s, part, prefix)
      otherwise.  */
   result->kind = no_event;
   XSET (result->code, Lisp_Int, event->button);
-  XSET (result->timestamp, Lisp_Int, event->time);
+  result->timestamp = event->time;
   result->modifiers = (x_convert_modifiers (event->state)
                       | (event->type == ButtonRelease ? up_modifier : 0));
-  XSET (result->timestamp, Lisp_Int, (event->time & 0x7fffff));
 
   /* Notice if the mouse is still grabbed.  */
   if (event->type == ButtonPress)
@@ -1998,7 +1997,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
                      XSET (bufp->code, Lisp_Int, (unsigned) keysym - 0xff50);
                      bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
                      bufp->modifiers = x_convert_modifiers (modifiers);
-                     XSET (bufp->timestamp, Lisp_Int, event.xkey.time);
+                     bufp->timestamp = event.xkey.time;
                      bufp++;
                      count++;
                      numchars--;
@@ -2012,9 +2011,9 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
                          if (modifiers & Mod1Mask)
                            *copy_buffer |= METABIT;
                          bufp->kind = ascii_keystroke;
-                         bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
                          XSET (bufp->code, Lisp_Int, *copy_buffer);
-                         XSET (bufp->timestamp, Lisp_Int, event.xkey.time);
+                         bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
+                         bufp->timestamp = event.xkey.time;
                          bufp++;
                        }
                      else
@@ -2022,8 +2021,8 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
                          {
                            bufp->kind = ascii_keystroke;
                            XSET (bufp->code, Lisp_Int, copy_buffer[i]);
-                           XSET (bufp->timestamp, Lisp_Int, event.xkey.time);
                            bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
+                           bufp->timestamp = event.xkey.time;
                            bufp++;
                          }
 
@@ -2167,14 +2166,12 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
            break;              /* Entering our own subwindow.  */
 
          {
-           extern int waiting_for_input;
            struct screen *old_s = x_input_screen;
 
            s = x_window_to_screen (event.window);
            x_mouse_screen = s;
 
-           if (waiting_for_input && x_focus_screen == 0)
-             x_new_focus_screen (s);
+           x_new_focus_screen (s);
          }
          break;
 
@@ -2592,6 +2589,14 @@ x_display_box_cursor (s, on)
 {
   struct screen_glyphs *current_glyphs = SCREEN_CURRENT_GLYPHS (s);
 
+  /* If we're not updating, then we want to use the current screen's
+     cursor position, not our local idea of where the cursor ought to be.  */
+  if (s != updating_screen)
+    {
+      curs_x = SCREEN_CURSOR_X (s);
+      curs_y = SCREEN_CURSOR_Y (s);
+    }
+
   if (! s->visible)
     return;
 
@@ -2605,8 +2610,8 @@ x_display_box_cursor (s, on)
      erase it.  */
   if (s->phys_cursor_x >= 0
       && (!on
-         || s->phys_cursor_x != s->cursor_x
-         || s->phys_cursor_y != s->cursor_y
+         || s->phys_cursor_x != curs_x
+         || s->phys_cursor_y != curs_y
          || (s->display.x->text_cursor_kind != hollow_box_cursor
              && (s != x_highlight_screen))))
     {
@@ -2626,9 +2631,9 @@ x_display_box_cursor (s, on)
              && s == x_highlight_screen)))
     {
       s->phys_cursor_glyph
-       = ((current_glyphs->enable[s->cursor_y]
-           && s->cursor_x < current_glyphs->used[s->cursor_y])
-          ? current_glyphs->glyphs[s->cursor_y][s->cursor_x]
+       = ((current_glyphs->enable[curs_y]
+           && curs_x < current_glyphs->used[curs_y])
+          ? current_glyphs->glyphs[curs_y][curs_x]
           : SPACEGLYPH);
       if (s != x_highlight_screen)
        {
@@ -2637,13 +2642,13 @@ x_display_box_cursor (s, on)
        }
       else
        {
-         x_draw_single_glyph (s, s->cursor_y, s->cursor_x,
+         x_draw_single_glyph (s, curs_y, curs_x,
                               s->phys_cursor_glyph, 2);
          s->display.x->text_cursor_kind = filled_box_cursor;
        }
 
-      s->phys_cursor_x = s->cursor_x;
-      s->phys_cursor_y = s->cursor_y;
+      s->phys_cursor_x = curs_x;
+      s->phys_cursor_y = curs_y;
     }
 
   if (updating_screen != s)