aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1992-06-10 03:53:16 +0000
committerJim Blandy1992-06-10 03:53:16 +0000
commit1113d9db4b32832799c1e686900d5655d5d3e5ba (patch)
tree745eca3a9161a151be76c8f54b4b7706c02e2862 /src
parent492878e483c355e6851d72cb4e395f069cd02964 (diff)
downloademacs-1113d9db4b32832799c1e686900d5655d5d3e5ba.tar.gz
emacs-1113d9db4b32832799c1e686900d5655d5d3e5ba.zip
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/dispnew.c31
-rw-r--r--src/frame.c82
-rw-r--r--src/keyboard.c35
-rw-r--r--src/search.c90
-rw-r--r--src/termhooks.h2
-rw-r--r--src/window.c9
-rw-r--r--src/xfns.c29
-rw-r--r--src/xselect.c.old58
-rw-r--r--src/xterm.c39
9 files changed, 282 insertions, 93 deletions
diff --git a/src/dispnew.c b/src/dispnew.c
index 8b4abb24a21..b1ea5d22664 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -96,8 +96,9 @@ Lisp_Object Vglyph_table;
96Lisp_Object Vstandard_display_table; 96Lisp_Object Vstandard_display_table;
97 97
98/* Nonzero means reading single-character input with prompt 98/* Nonzero means reading single-character input with prompt
99 so put cursor on minibuffer after the prompt. */ 99 so put cursor on minibuffer after the prompt.
100 100 positive means at end of text in echo area;
101 negative means at beginning of line. */
101int cursor_in_echo_area; 102int cursor_in_echo_area;
102 103
103/* The currently selected screen. 104/* The currently selected screen.
@@ -1056,16 +1057,19 @@ update_screen (s, force, inhibit_hairy_id)
1056 /* Now just clean up termcap drivers and set cursor, etc. */ 1057 /* Now just clean up termcap drivers and set cursor, etc. */
1057 if (!pause) 1058 if (!pause)
1058 { 1059 {
1059 1060 if (cursor_in_echo_area)
1060 if (s == selected_screen && cursor_in_echo_area < 0) 1061 {
1061 cursor_to (SCREEN_HEIGHT (s) - 1, 0); 1062 if (s == selected_screen
1062 else if (s == selected_screen && cursor_in_echo_area 1063 && cursor_in_echo_area < 0)
1063 && !desired_screen->used[SCREEN_HEIGHT (s) - 1]) 1064 cursor_to (SCREEN_HEIGHT (s) - 1, 0);
1064 cursor_to (SCREEN_HEIGHT (s), 0); 1065 else if (s == selected_screen
1065 else if (cursor_in_echo_area) 1066 && ! current_screen->enable[SCREEN_HEIGHT (s) - 1])
1066 cursor_to (SCREEN_HEIGHT (s) - 1, 1067 cursor_to (SCREEN_HEIGHT (s) - 1, 0);
1067 min (SCREEN_WIDTH (s) - 1, 1068 else
1068 desired_screen->used[SCREEN_HEIGHT (s) - 1])); 1069 cursor_to (SCREEN_HEIGHT (s) - 1,
1070 min (SCREEN_WIDTH (s) - 1,
1071 current_screen->used[SCREEN_HEIGHT (s) - 1]));
1072 }
1069 else 1073 else
1070 cursor_to (SCREEN_CURSOR_Y (s), max (min (SCREEN_CURSOR_X (s), 1074 cursor_to (SCREEN_CURSOR_Y (s), max (min (SCREEN_CURSOR_X (s),
1071 SCREEN_WIDTH (s) - 1), 0)); 1075 SCREEN_WIDTH (s) - 1), 0));
@@ -1906,9 +1910,10 @@ Value is t if waited the full time with no input arriving.")
1906 Lisp_Object arg, millisec, nodisp; 1910 Lisp_Object arg, millisec, nodisp;
1907{ 1911{
1908 int usec = 0; 1912 int usec = 0;
1909 int sec = 0; 1913 int sec;
1910 1914
1911 CHECK_NUMBER (arg, 0); 1915 CHECK_NUMBER (arg, 0);
1916 sec = XINT (arg);
1912 1917
1913 if (!NILP (millisec)) 1918 if (!NILP (millisec))
1914 { 1919 {
diff --git a/src/frame.c b/src/frame.c
index b1c452afc23..da42dd27f95 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1,11 +1,11 @@
1/* Generic screen functions. 1/* Generic screen functions.
2 Copyright (C) 1989 Free Software Foundation. 2 Copyright (C) 1989, 1992 Free Software Foundation.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
6GNU Emacs is free software; you can redistribute it and/or modify 6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by 7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option) 8the Free Software Foundation; either version 2, or (at your option)
9any later version. 9any later version.
10 10
11GNU Emacs is distributed in the hope that it will be useful, 11GNU Emacs is distributed in the hope that it will be useful,
@@ -194,7 +194,9 @@ make_screen_without_minibuffer (mini_window)
194 if (NILP (mini_window)) 194 if (NILP (mini_window))
195 { 195 {
196 if (XTYPE (Vdefault_minibuffer_screen) != Lisp_Screen) 196 if (XTYPE (Vdefault_minibuffer_screen) != Lisp_Screen)
197 error ("default-minibuffer-screen must be set when creating minibufferless screens."); 197 error ("default-minibuffer-screen must be set when creating minibufferless screens");
198 if (! SCREEN_LIVE_P (XSCREEN (Vdefault_minibuffer_screen)))
199 error ("default-minibuffer-screen must be a live screen");
198 mini_window = XSCREEN (Vdefault_minibuffer_screen)->minibuffer_window; 200 mini_window = XSCREEN (Vdefault_minibuffer_screen)->minibuffer_window;
199 } 201 }
200 else 202 else
@@ -492,16 +494,22 @@ A screen may not be deleted if its minibuffer is used by other screens.")
492 minibuffer for any other screen? */ 494 minibuffer for any other screen? */
493 if (SCREEN_HAS_MINIBUF (XSCREEN (screen))) 495 if (SCREEN_HAS_MINIBUF (XSCREEN (screen)))
494 { 496 {
495 Lisp_Object screen2; 497 Lisp_Object screens;
496 498
497 for (screen2 = Vscreen_list; CONSP (2); screen2 = XCONS (screen2)->cdr) 499 for (screens = Vscreen_list;
498 if (! EQ (screen2, screen) 500 CONSP (screens);
499 && EQ (screen, 501 screens = XCONS (screens)->cdr)
500 (WINDOW_SCREEN 502 {
501 (XWINDOW 503 Lisp_Object this = XCONS (screens)->car;
502 (SCREEN_MINIBUF_WINDOW 504
503 (XSCREEN (screen2))))))) 505 if (! EQ (this, screen)
504 error ("Attempt to delete a surrogate minibuffer screen"); 506 && EQ (screen,
507 (WINDOW_SCREEN
508 (XWINDOW
509 (SCREEN_MINIBUF_WINDOW
510 (XSCREEN (this)))))))
511 error ("Attempt to delete a surrogate minibuffer screen");
512 }
505 } 513 }
506 514
507 /* Don't let the screen remain selected. */ 515 /* 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.")
530 another one. */ 538 another one. */
531 if (s == last_nonminibuf_screen) 539 if (s == last_nonminibuf_screen)
532 { 540 {
541 Lisp_Object screens;
542
533 last_nonminibuf_screen = 0; 543 last_nonminibuf_screen = 0;
534 544
535 for (screen = Vscreen_list; CONSP (screen); screen = XCONS (screen)->cdr) 545 for (screens = Vscreen_list;
546 CONSP (screens);
547 screen = XCONS (screens)->cdr)
536 { 548 {
537 s = XSCREEN (XCONS (screen)->car); 549 s = XSCREEN (XCONS (screens)->car);
538 if (!SCREEN_MINIBUF_ONLY_P (s)) 550 if (!SCREEN_MINIBUF_ONLY_P (s))
539 { 551 {
540 last_nonminibuf_screen = s; 552 last_nonminibuf_screen = s;
@@ -543,6 +555,46 @@ A screen may not be deleted if its minibuffer is used by other screens.")
543 } 555 }
544 } 556 }
545 557
558 /* If we've deleted Vdefault_minibuffer_screen, try to find another
559 one. Prefer minibuffer-only screens, but also notice screens
560 with other windows. */
561 if (EQ (screen, Vdefault_minibuffer_screen))
562 {
563 Lisp_Object screens;
564
565 /* The last screen we saw with a minibuffer, minibuffer-only or not. */
566 Lisp_Object screen_with_minibuf = Qnil;
567
568 for (screens = Vscreen_list;
569 CONSP (screens);
570 screens = XCONS (screens)->cdr)
571 {
572 Lisp_Object this = XCONS (screens)->car;
573
574 if (XTYPE (this) != Lisp_Screen)
575 abort ();
576 s = XSCREEN (this);
577
578 if (SCREEN_HAS_MINIBUF (s))
579 {
580 screen_with_minibuf = this;
581 if (SCREEN_MINIBUF_ONLY_P (s))
582 break;
583 }
584 }
585
586 /* We know that there must be some screen with a minibuffer out
587 there. If this were not true, all of the screens present
588 would have to be minibufferless, which implies that at some
589 point their minibuffer screens must have been deleted, but
590 that is prohibited at the top; you can't delete surrogate
591 minibuffer screens. */
592 if (NILP (screen_with_minibuf))
593 abort ();
594
595 Vdefault_minibuffer_screen = screen_with_minibuf;
596 }
597
546 return Qnil; 598 return Qnil;
547} 599}
548 600
diff --git a/src/keyboard.c b/src/keyboard.c
index 56d94a2c2e9..2afccde9315 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -210,7 +210,8 @@ Lisp_Object Vmouse_motion_handler;
210 new screen. */ 210 new screen. */
211Lisp_Object Vlast_event_screen; 211Lisp_Object Vlast_event_screen;
212 212
213/* X Windows wants this for selection ownership. */ 213/* The timestamp of the last input event we received from the X server.
214 X Windows wants this for selection ownership. */
214unsigned long last_event_timestamp; 215unsigned long last_event_timestamp;
215 216
216Lisp_Object Qself_insert_command; 217Lisp_Object Qself_insert_command;
@@ -1610,7 +1611,7 @@ kbd_buffer_get_event ()
1610 if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE) 1611 if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
1611 kbd_fetch_ptr = kbd_buffer; 1612 kbd_fetch_ptr = kbd_buffer;
1612 XSET (Vlast_event_screen, Lisp_Screen, kbd_fetch_ptr->screen); 1613 XSET (Vlast_event_screen, Lisp_Screen, kbd_fetch_ptr->screen);
1613 last_event_timestamp = XINT (kbd_fetch_ptr->timestamp); 1614 last_event_timestamp = kbd_fetch_ptr->timestamp;
1614 obj = make_lispy_event (kbd_fetch_ptr); 1615 obj = make_lispy_event (kbd_fetch_ptr);
1615 kbd_fetch_ptr->kind = no_event; 1616 kbd_fetch_ptr->kind = no_event;
1616 kbd_fetch_ptr++; 1617 kbd_fetch_ptr++;
@@ -1791,7 +1792,8 @@ make_lispy_event (event)
1791 Fcons (window, 1792 Fcons (window,
1792 Fcons (posn, 1793 Fcons (posn,
1793 Fcons (Fcons (event->x, event->y), 1794 Fcons (Fcons (event->x, event->y),
1794 Fcons (event->timestamp, 1795 Fcons (make_number
1796 (event->timestamp),
1795 Qnil))))); 1797 Qnil)))));
1796 } 1798 }
1797 1799
@@ -1810,7 +1812,8 @@ make_lispy_event (event)
1810 Fcons (SCREEN_SELECTED_WINDOW (event->screen), 1812 Fcons (SCREEN_SELECTED_WINDOW (event->screen),
1811 Fcons (button, 1813 Fcons (button,
1812 Fcons (Fcons (event->x, event->y), 1814 Fcons (Fcons (event->x, event->y),
1813 Fcons (event->timestamp, 1815 Fcons (make_number
1816 (event->timestamp),
1814 Qnil))))); 1817 Qnil)))));
1815 } 1818 }
1816 1819
@@ -1872,8 +1875,8 @@ format_modifiers (modifiers, buf)
1872{ 1875{
1873 char *p = buf; 1876 char *p = buf;
1874 1877
1875 if (modifiers & meta_modifier) { *p++ = 'M'; *p++ = '-'; }
1876 if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; } 1878 if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; }
1879 if (modifiers & meta_modifier) { *p++ = 'M'; *p++ = '-'; }
1877 if (modifiers & shift_modifier) { *p++ = 'S'; *p++ = '-'; } 1880 if (modifiers & shift_modifier) { *p++ = 'S'; *p++ = '-'; }
1878 if (modifiers & up_modifier) { *p++ = 'U'; *p++ = '-'; } 1881 if (modifiers & up_modifier) { *p++ = 'U'; *p++ = '-'; }
1879 *p = '\0'; 1882 *p = '\0';
@@ -2982,17 +2985,31 @@ DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_
2982 Vobarray, Qcommandp, 2985 Vobarray, Qcommandp,
2983 Qt, Qnil, Qnil); 2986 Qt, Qnil, Qnil);
2984 2987
2985 /* Add the text read to this_command_keys. */ 2988 /* Set this_command_keys to the concatenation of saved_keys and
2989 function, followed by a RET. */
2986 { 2990 {
2987 struct Lisp_String *func_str = XSTRING (function); 2991 struct Lisp_String *str;
2988 int i; 2992 int i;
2989 Lisp_Object tem; 2993 Lisp_Object tem;
2990 2994
2991 for (i = 0; i < func_str->size; i++) 2995 this_command_key_count = 0;
2996
2997 str = XSTRING (saved_keys);
2998 for (i = 0; i < str->size; i++)
2992 { 2999 {
2993 XSET (tem, Lisp_Int, func_str->data[i]); 3000 XFASTINT (tem) = str->data[i];
2994 add_command_key (tem); 3001 add_command_key (tem);
2995 } 3002 }
3003
3004 str = XSTRING (function);
3005 for (i = 0; i < str->size; i++)
3006 {
3007 XFASTINT (tem) = str->data[i];
3008 add_command_key (tem);
3009 }
3010
3011 XFASTINT (tem) = '\015';
3012 add_command_key (tem);
2996 } 3013 }
2997 3014
2998 UNGCPRO; 3015 UNGCPRO;
diff --git a/src/search.c b/src/search.c
index 5f1f17f2d53..88eb72ab1f4 100644
--- a/src/search.c
+++ b/src/search.c
@@ -47,8 +47,16 @@ Lisp_Object last_regexp;
47 47
48 Since the registers are now dynamically allocated, we need to make 48 Since the registers are now dynamically allocated, we need to make
49 sure not to refer to the Nth register before checking that it has 49 sure not to refer to the Nth register before checking that it has
50 been allocated. */ 50 been allocated by checking search_regs.num_regs.
51 51
52 The regex code keeps track of whether it has allocated the search
53 buffer using bits in searchbuf. This means that whenever you
54 compile a new pattern, it completely forgets whether it has
55 allocated any registers, and will allocate new registers the next
56 time you call a searching or matching function. Therefore, we need
57 to call re_set_registers after compiling a new pattern or after
58 setting the match registers, so that the regex functions will be
59 able to free or re-allocate it properly. */
52static struct re_registers search_regs; 60static struct re_registers search_regs;
53 61
54/* Nonzero if search_regs are indices in a string; 0 if in a buffer. */ 62/* Nonzero if search_regs are indices in a string; 0 if in a buffer. */
@@ -73,9 +81,10 @@ matcher_overflow ()
73 81
74/* Compile a regexp and signal a Lisp error if anything goes wrong. */ 82/* Compile a regexp and signal a Lisp error if anything goes wrong. */
75 83
76compile_pattern (pattern, bufp, translate) 84compile_pattern (pattern, bufp, regp, translate)
77 Lisp_Object pattern; 85 Lisp_Object pattern;
78 struct re_pattern_buffer *bufp; 86 struct re_pattern_buffer *bufp;
87 struct re_registers *regp;
79 char *translate; 88 char *translate;
80{ 89{
81 CONST char *val; 90 CONST char *val;
@@ -84,6 +93,7 @@ compile_pattern (pattern, bufp, translate)
84 if (EQ (pattern, last_regexp) 93 if (EQ (pattern, last_regexp)
85 && translate == bufp->translate) 94 && translate == bufp->translate)
86 return; 95 return;
96
87 last_regexp = Qnil; 97 last_regexp = Qnil;
88 bufp->translate = translate; 98 bufp->translate = translate;
89 val = re_compile_pattern ((char *) XSTRING (pattern)->data, 99 val = re_compile_pattern ((char *) XSTRING (pattern)->data,
@@ -95,7 +105,13 @@ compile_pattern (pattern, bufp, translate)
95 while (1) 105 while (1)
96 Fsignal (Qinvalid_regexp, Fcons (dummy, Qnil)); 106 Fsignal (Qinvalid_regexp, Fcons (dummy, Qnil));
97 } 107 }
108
98 last_regexp = pattern; 109 last_regexp = pattern;
110
111 /* Advise the searching functions about the space we have allocated
112 for register data. */
113 re_set_registers (bufp, regp, regp->num_regs, regp->start, regp->end);
114
99 return; 115 return;
100} 116}
101 117
@@ -124,7 +140,7 @@ data if you want to preserve them.")
124 register int i; 140 register int i;
125 141
126 CHECK_STRING (string, 0); 142 CHECK_STRING (string, 0);
127 compile_pattern (string, &searchbuf, 143 compile_pattern (string, &searchbuf, &search_regs,
128 !NILP (current_buffer->case_fold_search) ? DOWNCASE_TABLE : 0); 144 !NILP (current_buffer->case_fold_search) ? DOWNCASE_TABLE : 0);
129 145
130 immediate_quit = 1; 146 immediate_quit = 1;
@@ -196,7 +212,7 @@ matched by parenthesis constructs in the pattern.")
196 args_out_of_range (string, start); 212 args_out_of_range (string, start);
197 } 213 }
198 214
199 compile_pattern (regexp, &searchbuf, 215 compile_pattern (regexp, &searchbuf, &search_regs,
200 !NILP (current_buffer->case_fold_search) ? DOWNCASE_TABLE : 0); 216 !NILP (current_buffer->case_fold_search) ? DOWNCASE_TABLE : 0);
201 immediate_quit = 1; 217 immediate_quit = 1;
202 val = re_search (&searchbuf, (char *) XSTRING (string)->data, 218 val = re_search (&searchbuf, (char *) XSTRING (string)->data,
@@ -506,7 +522,7 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt)
506 return pos; 522 return pos;
507 523
508 if (RE) 524 if (RE)
509 compile_pattern (string, &searchbuf, (char *) trt); 525 compile_pattern (string, &searchbuf, &search_regs, (char *) trt);
510 526
511 if (RE /* Here we detect whether the */ 527 if (RE /* Here we detect whether the */
512 /* generality of an RE search is */ 528 /* generality of an RE search is */
@@ -768,6 +784,22 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt)
768 if (i + direction == 0) 784 if (i + direction == 0)
769 { 785 {
770 cursor -= direction; 786 cursor -= direction;
787
788 /* Make sure we have registers in which to store
789 the match position. */
790 if (search_regs.num_regs == 0)
791 {
792 regoff_t *starts, *ends;
793
794 starts =
795 (regoff_t *) xmalloc (2 * sizeof (regoff_t));
796 ends =
797 (regoff_t *) xmalloc (2 * sizeof (regoff_t));
798 re_set_registers (&searchbuf,
799 &search_regs,
800 2, starts, ends);
801 }
802
771 search_regs.start[0] 803 search_regs.start[0]
772 = pos + cursor - p2 + ((direction > 0) 804 = pos + cursor - p2 + ((direction > 0)
773 ? 1 - len : 0); 805 ? 1 - len : 0);
@@ -827,6 +859,22 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt)
827 if (i + direction == 0) 859 if (i + direction == 0)
828 { 860 {
829 pos -= direction; 861 pos -= direction;
862
863 /* Make sure we have registers in which to store
864 the match position. */
865 if (search_regs.num_regs == 0)
866 {
867 regoff_t *starts, *ends;
868
869 starts =
870 (regoff_t *) xmalloc (2 * sizeof (regoff_t));
871 ends =
872 (regoff_t *) xmalloc (2 * sizeof (regoff_t));
873 re_set_registers (&searchbuf,
874 &search_regs,
875 2, starts, ends);
876 }
877
830 search_regs.start[0] 878 search_regs.start[0]
831 = pos + ((direction > 0) ? 1 - len : 0); 879 = pos + ((direction > 0) ? 1 - len : 0);
832 search_regs.end[0] = len + search_regs.start[0]; 880 search_regs.end[0] = len + search_regs.start[0];
@@ -1004,6 +1052,7 @@ Otherwise treat `\\' as special:\n\
1004 `\\N' means substitute what matched the Nth `\\(...\\)'.\n\ 1052 `\\N' means substitute what matched the Nth `\\(...\\)'.\n\
1005 If Nth parens didn't match, substitute nothing.\n\ 1053 If Nth parens didn't match, substitute nothing.\n\
1006 `\\\\' means insert one `\\'.\n\ 1054 `\\\\' means insert one `\\'.\n\
1055FIXEDCASE and LITERAL are optional arguments.\n\
1007Leaves point at end of replacement text.") 1056Leaves point at end of replacement text.")
1008 (string, fixedcase, literal) 1057 (string, fixedcase, literal)
1009 Lisp_Object string, fixedcase, literal; 1058 Lisp_Object string, fixedcase, literal;
@@ -1221,20 +1270,25 @@ LIST should have been created by calling `match-data' previously.")
1221 1270
1222 if (length > search_regs.num_regs) 1271 if (length > search_regs.num_regs)
1223 { 1272 {
1224 if (search_regs.start) 1273 if (search_regs.num_regs == 0)
1225 search_regs.start = 1274 {
1226 (regoff_t *) realloc (search_regs.start, 1275 search_regs.start
1227 length * sizeof (regoff_t)); 1276 = (regoff_t *) xmalloc (length * sizeof (regoff_t));
1228 else 1277 search_regs.end
1229 search_regs.start = (regoff_t *) malloc (length * sizeof (regoff_t)); 1278 = (regoff_t *) xmalloc (length * sizeof (regoff_t));
1230 if (search_regs.end) 1279 }
1231 search_regs.end =
1232 (regoff_t *) realloc (search_regs.end,
1233 length * sizeof (regoff_t));
1234 else 1280 else
1235 search_regs.end = (regoff_t *) malloc (length * sizeof (regoff_t)); 1281 {
1282 search_regs.start
1283 = (regoff_t *) xrealloc (search_regs.start,
1284 length * sizeof (regoff_t));
1285 search_regs.end
1286 = (regoff_t *) xrealloc (search_regs.end,
1287 length * sizeof (regoff_t));
1288 }
1236 1289
1237 search_regs.num_regs = length; 1290 re_set_registers (&searchbuf, &search_regs, length,
1291 search_regs.start, search_regs.end);
1238 } 1292 }
1239 } 1293 }
1240 1294
diff --git a/src/termhooks.h b/src/termhooks.h
index 08c8e818e80..b9363eb16d7 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -105,7 +105,7 @@ struct input_event {
105 .modifiers holds the state of the 105 .modifiers holds the state of the
106 modifier keys. 106 modifier keys.
107 .x and .y give the mouse position, 107 .x and .y give the mouse position,
108 in pixels, within the window. 108 in characters, within the window.
109 .screen gives the screen the mouse 109 .screen gives the screen the mouse
110 click occurred in. 110 click occurred in.
111 .timestamp gives a timestamp (in 111 .timestamp gives a timestamp (in
diff --git a/src/window.c b/src/window.c
index 5f888f8a732..41171a3585e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,12 +1,12 @@
1/* Window creation, deletion and examination for GNU Emacs. 1/* Window creation, deletion and examination for GNU Emacs.
2 Does not include redisplay. 2 Does not include redisplay.
3 Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc. 3 Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
7GNU Emacs is free software; you can redistribute it and/or modify 7GNU Emacs is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by 8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 1, or (at your option) 9the Free Software Foundation; either version 2, or (at your option)
10any later version. 10any later version.
11 11
12GNU Emacs is distributed in the hope that it will be useful, 12GNU Emacs is distributed in the hope that it will be useful,
@@ -357,7 +357,10 @@ coordinates_in_window (w, x, y)
357DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, 357DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p,
358 Scoordinates_in_window_p, 2, 2, 0, 358 Scoordinates_in_window_p, 2, 2, 0,
359 "Return non-nil if COORDINATES are in WINDOW.\n\ 359 "Return non-nil if COORDINATES are in WINDOW.\n\
360COORDINATES is a cons of the form (X . Y), X and Y being screen-relative.\n\ 360COORDINATES is a cons of the form (X . Y), X and Y being distances\n\
361measured in characters from the upper-left corner of the screen.\n\
362(0 . 0) denotes the character in the upper left corner of the\n\
363screen.\n\
361If COORDINATES are in the text portion of WINDOW,\n\ 364If COORDINATES are in the text portion of WINDOW,\n\
362 the coordinates relative to the window are returned.\n\ 365 the coordinates relative to the window are returned.\n\
363If they are in the mode line of WINDOW, 'mode-line is returned.\n\ 366If they are in the mode line of WINDOW, 'mode-line is returned.\n\
diff --git a/src/xfns.c b/src/xfns.c
index b445fb00f57..6d32925f95b 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1,11 +1,11 @@
1/* Functions for the X window system. 1/* Functions for the X window system.
2 Copyright (C) 1989 Free Software Foundation. 2 Copyright (C) 1989, 1992 Free Software Foundation.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
6GNU Emacs is free software; you can redistribute it and/or modify 6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by 7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option) 8the Free Software Foundation; either version 2, or (at your option)
9any later version. 9any later version.
10 10
11GNU Emacs is distributed in the hope that it will be useful, 11GNU Emacs is distributed in the hope that it will be useful,
@@ -1045,6 +1045,17 @@ x_set_name (s, arg, oldval)
1045 1045
1046 if (s->display.x->window_desc) 1046 if (s->display.x->window_desc)
1047 { 1047 {
1048#ifdef HAVE_X11
1049 XTextProperty prop;
1050 prop.value = XSTRING (arg)->data;
1051 prop.encoding = XA_STRING;
1052 prop.format = 8;
1053 prop.nitems = XSTRING (arg)->size;
1054 BLOCK_INPUT;
1055 XSetWMName (XDISPLAY s->display.x->window_desc, &prop);
1056 XSetWMIconName (XDISPLAY s->display.x->window_desc, &prop);
1057 UNBLOCK_INPUT;
1058#else
1048 s->name = arg; 1059 s->name = arg;
1049 BLOCK_INPUT; 1060 BLOCK_INPUT;
1050 XStoreName (XDISPLAY s->display.x->window_desc, 1061 XStoreName (XDISPLAY s->display.x->window_desc,
@@ -1052,6 +1063,7 @@ x_set_name (s, arg, oldval)
1052 XSetIconName (XDISPLAY s->display.x->window_desc, 1063 XSetIconName (XDISPLAY s->display.x->window_desc,
1053 (char *) XSTRING (arg)->data); 1064 (char *) XSTRING (arg)->data);
1054 UNBLOCK_INPUT; 1065 UNBLOCK_INPUT;
1066#endif
1055 } 1067 }
1056} 1068}
1057 1069
@@ -2102,8 +2114,19 @@ be shared by the new screen.")
2102 x_set_resize_hint (s); 2114 x_set_resize_hint (s);
2103 2115
2104 /* Tell the server the window's default name. */ 2116 /* Tell the server the window's default name. */
2105 2117#ifdef HAVE_X11
2118 {
2119 XTextProperty prop;
2120 prop.value = XSTRING (s->name)->data;
2121 prop.encoding = XA_STRING;
2122 prop.format = 8;
2123 prop.nitems = XSTRING (s->name)->size;
2124 XSetWMName (XDISPLAY s->display.x->window_desc, &prop);
2125 }
2126#else
2106 XStoreName (XDISPLAY s->display.x->window_desc, XSTRING (s->name)->data); 2127 XStoreName (XDISPLAY s->display.x->window_desc, XSTRING (s->name)->data);
2128#endif
2129
2107 /* Now override the defaults with all the rest of the specified 2130 /* Now override the defaults with all the rest of the specified
2108 parms. */ 2131 parms. */
2109 tem = x_get_arg (parms, intern ("unsplittable"), 0, 0); 2132 tem = x_get_arg (parms, intern ("unsplittable"), 0, 0);
diff --git a/src/xselect.c.old b/src/xselect.c.old
index a88208bece9..dea8a1cfca9 100644
--- a/src/xselect.c.old
+++ b/src/xselect.c.old
@@ -29,11 +29,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
29#define MAX_SELECTION(dpy) (((dpy)->max_request_size << 2) - 100) 29#define MAX_SELECTION(dpy) (((dpy)->max_request_size << 2) - 100)
30#define SELECTION_LENGTH(len,format) ((len) * ((format) >> 2)) 30#define SELECTION_LENGTH(len,format) ((len) * ((format) >> 2))
31 31
32/* The last 23 bits of the timestamp of the last mouse button event. */ 32/* The timestamp of the last input event we received from the X server. */
33extern Time mouse_timestamp; 33unsigned long last_event_timestamp;
34
35/* An expedient hack! Fix this! */
36#define last_event_timestamp CurrentTime
37 34
38/* t if a mouse button is depressed. */ 35/* t if a mouse button is depressed. */
39extern Lisp_Object Vmouse_grabbed; 36extern Lisp_Object Vmouse_grabbed;
@@ -56,8 +53,10 @@ Lisp_Object Vx_selection_value;
56/* The value of the current SECONDARY selection. */ 53/* The value of the current SECONDARY selection. */
57Lisp_Object Vx_secondary_selection_value; 54Lisp_Object Vx_secondary_selection_value;
58 55
59/* Types of selections we may make. */ 56/* Types of selections we may make. Note that Qcut_buffer0 isn't really
60Lisp_Object Qprimary, Qsecondary, Qclipboard; 57 a selection, but it acts like one for the sake of Fx_own_selection and
58 Fx_selection_value. */
59Lisp_Object Qprimary, Qsecondary, Qclipboard, Qcut_buffer0;
61 60
62/* Emacs' selection property identifiers. */ 61/* Emacs' selection property identifiers. */
63Atom Xatom_emacs_selection; 62Atom Xatom_emacs_selection;
@@ -146,13 +145,18 @@ own_selection (selection_type, time)
146DEFUN ("x-own-selection", Fx_own_selection, Sx_own_selection, 145DEFUN ("x-own-selection", Fx_own_selection, Sx_own_selection,
147 1, 2, "", 146 1, 2, "",
148 "Make STRING the selection value. Default is the primary selection,\n\ 147 "Make STRING the selection value. Default is the primary selection,\n\
149but optional second argument TYPE may specify secondary or clipboard.") 148but optional second argument TYPE may specify secondary or clipboard.\n\
149\n\
150TYPE may also be cut-buffer0, indicating that Emacs should set the X\n\
151cut buffer 0 to STRING. This is for compatibility with older X\n\
152applications which still use the cut buffers; new applications should\n\
153use X selections.")
150 (string, type) 154 (string, type)
151 register Lisp_Object string, type; 155 register Lisp_Object string, type;
152{ 156{
153 Atom selection_type; 157 Atom selection_type;
154 Lisp_Object val; 158 Lisp_Object val;
155 Time event_time = mouse_timestamp; 159 Time event_time = last_event_timestamp;
156 CHECK_STRING (string, 0); 160 CHECK_STRING (string, 0);
157 161
158 if (NILP (type) || EQ (type, Qprimary)) 162 if (NILP (type) || EQ (type, Qprimary))
@@ -163,7 +167,7 @@ but optional second argument TYPE may specify secondary or clipboard.")
163 x_begin_selection_own = event_time; 167 x_begin_selection_own = event_time;
164 val = Vx_selection_value = string; 168 val = Vx_selection_value = string;
165 } 169 }
166 UNBLOCK_INPUT; 170 UNBLOCK_INPUT;
167 } 171 }
168 else if (EQ (type, Qsecondary)) 172 else if (EQ (type, Qsecondary))
169 { 173 {
@@ -180,10 +184,18 @@ but optional second argument TYPE may specify secondary or clipboard.")
180 BLOCK_INPUT; 184 BLOCK_INPUT;
181 if (own_selection (Xatom_clipboard, event_time)) 185 if (own_selection (Xatom_clipboard, event_time))
182 { 186 {
183 x_begin_clipboard_own = event_time; 187 x_begin_clipboard_own = event_time;
184 val = Vx_clipboard_value = string; 188 val = Vx_clipboard_value = string;
185 } 189 }
186 UNBLOCK_INPUT; 190 UNBLOCK_INPUT;
191 }
192 else if (EQ (type, Qcut_buffer0))
193 {
194 BLOCK_INPUT;
195 XStoreBytes (x_current_display,
196 XSTRING (string)->data,
197 XSTRING (string)->size);
198 UNBLOCK_INPUT;
187 } 199 }
188 else 200 else
189 error ("Invalid X selection type"); 201 error ("Invalid X selection type");
@@ -230,7 +242,7 @@ int x_selection_alloc_error;
230int x_converting_selection; 242int x_converting_selection;
231 243
232/* Reply to some client's request for our selection data. Data is 244/* Reply to some client's request for our selection data. Data is
233 placed in a propery supplied by the requesting window. 245 placed in a property supplied by the requesting window.
234 246
235 If the data exceeds the maximum amount the server can send, 247 If the data exceeds the maximum amount the server can send,
236 then prepare to send it incrementally, and reply to the client with 248 then prepare to send it incrementally, and reply to the client with
@@ -518,7 +530,7 @@ get_selection_value (type)
518 Window requestor_window; 530 Window requestor_window;
519 531
520 BLOCK_INPUT; 532 BLOCK_INPUT;
521 requestor_time = mouse_timestamp; 533 requestor_time = last_event_timestamp;
522 requestor_window = selected_screen->display.x->window_desc; 534 requestor_window = selected_screen->display.x->window_desc;
523 XConvertSelection (x_current_display, type, XA_STRING, 535 XConvertSelection (x_current_display, type, XA_STRING,
524 Xatom_emacs_selection, requestor_window, requestor_time); 536 Xatom_emacs_selection, requestor_window, requestor_time);
@@ -566,6 +578,22 @@ selection, but optional argument TYPE may specify secondary or clipboard.")
566 578
567 return get_selection_value (Xatom_clipboard); 579 return get_selection_value (Xatom_clipboard);
568 } 580 }
581 else if (EQ (type, Qcut_buffer0))
582 {
583 char *data;
584 int size;
585 Lisp_Object string;
586
587 BLOCK_INPUT;
588 data = XFetchBytes (x_current_display, &size);
589 if (data == 0)
590 string = Qnil;
591 else
592 string = make_string (data, size);
593 UNBLOCK_INPUT;
594
595 return string;
596 }
569 else 597 else
570 error ("Invalid X selection type"); 598 error ("Invalid X selection type");
571} 599}
@@ -704,6 +732,8 @@ syms_of_xselect ()
704 staticpro (&Qsecondary); 732 staticpro (&Qsecondary);
705 Qclipboard = intern ("clipboard"); 733 Qclipboard = intern ("clipboard");
706 staticpro (&Qclipboard); 734 staticpro (&Qclipboard);
735 Qcut_buffer0 = intern ("cut-buffer0");
736 staticpro (&Qcut_buffer0);
707 737
708 defsubr (&Sx_own_selection); 738 defsubr (&Sx_own_selection);
709 defsubr (&Sx_selection_value); 739 defsubr (&Sx_selection_value);
diff --git a/src/xterm.c b/src/xterm.c
index 69c16d843b3..7bf039a1cf1 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1465,10 +1465,9 @@ construct_mouse_click (result, event, s, part, prefix)
1465 otherwise. */ 1465 otherwise. */
1466 result->kind = no_event; 1466 result->kind = no_event;
1467 XSET (result->code, Lisp_Int, event->button); 1467 XSET (result->code, Lisp_Int, event->button);
1468 XSET (result->timestamp, Lisp_Int, event->time); 1468 result->timestamp = event->time;
1469 result->modifiers = (x_convert_modifiers (event->state) 1469 result->modifiers = (x_convert_modifiers (event->state)
1470 | (event->type == ButtonRelease ? up_modifier : 0)); 1470 | (event->type == ButtonRelease ? up_modifier : 0));
1471 XSET (result->timestamp, Lisp_Int, (event->time & 0x7fffff));
1472 1471
1473 /* Notice if the mouse is still grabbed. */ 1472 /* Notice if the mouse is still grabbed. */
1474 if (event->type == ButtonPress) 1473 if (event->type == ButtonPress)
@@ -1998,7 +1997,7 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
1998 XSET (bufp->code, Lisp_Int, (unsigned) keysym - 0xff50); 1997 XSET (bufp->code, Lisp_Int, (unsigned) keysym - 0xff50);
1999 bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s)); 1998 bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
2000 bufp->modifiers = x_convert_modifiers (modifiers); 1999 bufp->modifiers = x_convert_modifiers (modifiers);
2001 XSET (bufp->timestamp, Lisp_Int, event.xkey.time); 2000 bufp->timestamp = event.xkey.time;
2002 bufp++; 2001 bufp++;
2003 count++; 2002 count++;
2004 numchars--; 2003 numchars--;
@@ -2012,9 +2011,9 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2012 if (modifiers & Mod1Mask) 2011 if (modifiers & Mod1Mask)
2013 *copy_buffer |= METABIT; 2012 *copy_buffer |= METABIT;
2014 bufp->kind = ascii_keystroke; 2013 bufp->kind = ascii_keystroke;
2015 bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
2016 XSET (bufp->code, Lisp_Int, *copy_buffer); 2014 XSET (bufp->code, Lisp_Int, *copy_buffer);
2017 XSET (bufp->timestamp, Lisp_Int, event.xkey.time); 2015 bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
2016 bufp->timestamp = event.xkey.time;
2018 bufp++; 2017 bufp++;
2019 } 2018 }
2020 else 2019 else
@@ -2022,8 +2021,8 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2022 { 2021 {
2023 bufp->kind = ascii_keystroke; 2022 bufp->kind = ascii_keystroke;
2024 XSET (bufp->code, Lisp_Int, copy_buffer[i]); 2023 XSET (bufp->code, Lisp_Int, copy_buffer[i]);
2025 XSET (bufp->timestamp, Lisp_Int, event.xkey.time);
2026 bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s)); 2024 bufp->screen = XSCREEN (SCREEN_FOCUS_SCREEN (s));
2025 bufp->timestamp = event.xkey.time;
2027 bufp++; 2026 bufp++;
2028 } 2027 }
2029 2028
@@ -2167,14 +2166,12 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
2167 break; /* Entering our own subwindow. */ 2166 break; /* Entering our own subwindow. */
2168 2167
2169 { 2168 {
2170 extern int waiting_for_input;
2171 struct screen *old_s = x_input_screen; 2169 struct screen *old_s = x_input_screen;
2172 2170
2173 s = x_window_to_screen (event.window); 2171 s = x_window_to_screen (event.window);
2174 x_mouse_screen = s; 2172 x_mouse_screen = s;
2175 2173
2176 if (waiting_for_input && x_focus_screen == 0) 2174 x_new_focus_screen (s);
2177 x_new_focus_screen (s);
2178 } 2175 }
2179 break; 2176 break;
2180 2177
@@ -2592,6 +2589,14 @@ x_display_box_cursor (s, on)
2592{ 2589{
2593 struct screen_glyphs *current_glyphs = SCREEN_CURRENT_GLYPHS (s); 2590 struct screen_glyphs *current_glyphs = SCREEN_CURRENT_GLYPHS (s);
2594 2591
2592 /* If we're not updating, then we want to use the current screen's
2593 cursor position, not our local idea of where the cursor ought to be. */
2594 if (s != updating_screen)
2595 {
2596 curs_x = SCREEN_CURSOR_X (s);
2597 curs_y = SCREEN_CURSOR_Y (s);
2598 }
2599
2595 if (! s->visible) 2600 if (! s->visible)
2596 return; 2601 return;
2597 2602
@@ -2605,8 +2610,8 @@ x_display_box_cursor (s, on)
2605 erase it. */ 2610 erase it. */
2606 if (s->phys_cursor_x >= 0 2611 if (s->phys_cursor_x >= 0
2607 && (!on 2612 && (!on
2608 || s->phys_cursor_x != s->cursor_x 2613 || s->phys_cursor_x != curs_x
2609 || s->phys_cursor_y != s->cursor_y 2614 || s->phys_cursor_y != curs_y
2610 || (s->display.x->text_cursor_kind != hollow_box_cursor 2615 || (s->display.x->text_cursor_kind != hollow_box_cursor
2611 && (s != x_highlight_screen)))) 2616 && (s != x_highlight_screen))))
2612 { 2617 {
@@ -2626,9 +2631,9 @@ x_display_box_cursor (s, on)
2626 && s == x_highlight_screen))) 2631 && s == x_highlight_screen)))
2627 { 2632 {
2628 s->phys_cursor_glyph 2633 s->phys_cursor_glyph
2629 = ((current_glyphs->enable[s->cursor_y] 2634 = ((current_glyphs->enable[curs_y]
2630 && s->cursor_x < current_glyphs->used[s->cursor_y]) 2635 && curs_x < current_glyphs->used[curs_y])
2631 ? current_glyphs->glyphs[s->cursor_y][s->cursor_x] 2636 ? current_glyphs->glyphs[curs_y][curs_x]
2632 : SPACEGLYPH); 2637 : SPACEGLYPH);
2633 if (s != x_highlight_screen) 2638 if (s != x_highlight_screen)
2634 { 2639 {
@@ -2637,13 +2642,13 @@ x_display_box_cursor (s, on)
2637 } 2642 }
2638 else 2643 else
2639 { 2644 {
2640 x_draw_single_glyph (s, s->cursor_y, s->cursor_x, 2645 x_draw_single_glyph (s, curs_y, curs_x,
2641 s->phys_cursor_glyph, 2); 2646 s->phys_cursor_glyph, 2);
2642 s->display.x->text_cursor_kind = filled_box_cursor; 2647 s->display.x->text_cursor_kind = filled_box_cursor;
2643 } 2648 }
2644 2649
2645 s->phys_cursor_x = s->cursor_x; 2650 s->phys_cursor_x = curs_x;
2646 s->phys_cursor_y = s->cursor_y; 2651 s->phys_cursor_y = curs_y;
2647 } 2652 }
2648 2653
2649 if (updating_screen != s) 2654 if (updating_screen != s)