diff options
| author | Karl Heuer | 1995-01-25 08:58:33 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-01-25 08:58:33 +0000 |
| commit | 612b78eff8de9cafe373180daab89f8236304624 (patch) | |
| tree | 85cb1d931574e93bb7342c62eebb89e840525bdf /src | |
| parent | 5fc12a7870637b40e8563c9f19f365d496aa226e (diff) | |
| download | emacs-612b78eff8de9cafe373180daab89f8236304624.tar.gz emacs-612b78eff8de9cafe373180daab89f8236304624.zip | |
(the_only_perd): Define this var here.
(kbd_buffer, kbd_fetch_ptr, kbd_store_ptr): Delete; now part of perd.
(find_active_event_queue): New function.
(readable_events, kbd_buffer_get_event, swallow_events): Use it.
(kbd_buffer_store_event): Store in EVENT's frame's queue.
(Fdiscard_input, stuff_buffered_input): Use perd.
(init_keyboard): Initialize the new vars.
kbd_buffer is now a pointer, not an array.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 172 |
1 files changed, 84 insertions, 88 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index caba4bbbcc3..4b55cb03303 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -95,6 +95,8 @@ struct backtrace | |||
| 95 | char evalargs; | 95 | char evalargs; |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | PERD the_only_perd; | ||
| 99 | |||
| 98 | /* Non-nil disable property on a command means | 100 | /* Non-nil disable property on a command means |
| 99 | do not execute it; call disabled-command-hook's value instead. */ | 101 | do not execute it; call disabled-command-hook's value instead. */ |
| 100 | Lisp_Object Qdisabled, Qdisabled_command_hook; | 102 | Lisp_Object Qdisabled, Qdisabled_command_hook; |
| @@ -325,9 +327,6 @@ int meta_key; | |||
| 325 | 327 | ||
| 326 | extern char *pending_malloc_warning; | 328 | extern char *pending_malloc_warning; |
| 327 | 329 | ||
| 328 | /* Circular buffer for pre-read keyboard input. */ | ||
| 329 | static struct input_event kbd_buffer[KBD_BUFFER_SIZE]; | ||
| 330 | |||
| 331 | /* Vector to GCPRO the frames and windows mentioned in kbd_buffer. | 330 | /* Vector to GCPRO the frames and windows mentioned in kbd_buffer. |
| 332 | 331 | ||
| 333 | The interrupt-level event handlers will never enqueue an event on a | 332 | The interrupt-level event handlers will never enqueue an event on a |
| @@ -351,31 +350,11 @@ static struct input_event kbd_buffer[KBD_BUFFER_SIZE]; | |||
| 351 | event queue. That way, they'll be dequeued as dead frames or | 350 | event queue. That way, they'll be dequeued as dead frames or |
| 352 | windows, but still valid lisp objects. | 351 | windows, but still valid lisp objects. |
| 353 | 352 | ||
| 354 | If kbd_buffer[i].kind != no_event, then | 353 | If perd->kbd_buffer[i].kind != no_event, then |
| 355 | (XVECTOR (kbd_buffer_frame_or_window)->contents[i] | 354 | (XVECTOR (kbd_buffer_frame_or_window)->contents[i] |
| 356 | == kbd_buffer[i].frame_or_window. */ | 355 | == perd->kbd_buffer[i].frame_or_window. */ |
| 357 | static Lisp_Object kbd_buffer_frame_or_window; | 356 | static Lisp_Object kbd_buffer_frame_or_window; |
| 358 | 357 | ||
| 359 | /* Pointer to next available character in kbd_buffer. | ||
| 360 | If kbd_fetch_ptr == kbd_store_ptr, the buffer is empty. | ||
| 361 | This may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the the | ||
| 362 | next available char is in kbd_buffer[0]. */ | ||
| 363 | static struct input_event *kbd_fetch_ptr; | ||
| 364 | |||
| 365 | /* Pointer to next place to store character in kbd_buffer. This | ||
| 366 | may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the next | ||
| 367 | character should go in kbd_buffer[0]. */ | ||
| 368 | static volatile struct input_event *kbd_store_ptr; | ||
| 369 | |||
| 370 | /* The above pair of variables forms a "queue empty" flag. When we | ||
| 371 | enqueue a non-hook event, we increment kbd_write_count. When we | ||
| 372 | dequeue a non-hook event, we increment kbd_read_count. We say that | ||
| 373 | there is input available iff the two counters are not equal. | ||
| 374 | |||
| 375 | Why not just have a flag set and cleared by the enqueuing and | ||
| 376 | dequeuing functions? Such a flag could be screwed up by interrupts | ||
| 377 | at inopportune times. */ | ||
| 378 | |||
| 379 | #ifdef HAVE_MOUSE | 358 | #ifdef HAVE_MOUSE |
| 380 | /* If this flag is a frame, we check mouse_moved to see when the | 359 | /* If this flag is a frame, we check mouse_moved to see when the |
| 381 | mouse moves, and motion events will appear in the input stream. | 360 | mouse moves, and motion events will appear in the input stream. |
| @@ -389,17 +368,9 @@ static Lisp_Object do_mouse_tracking; | |||
| 389 | it unless you're prepared to substantiate the claim! */ | 368 | it unless you're prepared to substantiate the claim! */ |
| 390 | int mouse_moved; | 369 | int mouse_moved; |
| 391 | 370 | ||
| 392 | /* True iff there is an event in kbd_buffer, or if mouse tracking is | 371 | #define MOUSE_ACTIVITY_AVAILABLE (FRAMEP (do_mouse_tracking) && mouse_moved) |
| 393 | enabled and there is a new mouse position in the mouse movement | ||
| 394 | buffer. Note that if this is false, that doesn't mean that there | ||
| 395 | is readable input; all the events in the queue might be button-up | ||
| 396 | events, and do_mouse_tracking might be off. */ | ||
| 397 | #define EVENT_QUEUES_EMPTY \ | ||
| 398 | ((kbd_fetch_ptr == kbd_store_ptr) \ | ||
| 399 | && (! FRAMEP (do_mouse_tracking) || !mouse_moved)) | ||
| 400 | |||
| 401 | #else /* Not HAVE_MOUSE. */ | 372 | #else /* Not HAVE_MOUSE. */ |
| 402 | #define EVENT_QUEUES_EMPTY (kbd_fetch_ptr == kbd_store_ptr) | 373 | #define MOUSE_ACTIVITY_AVAILABLE 0 |
| 403 | #endif /* HAVE_MOUSE. */ | 374 | #endif /* HAVE_MOUSE. */ |
| 404 | 375 | ||
| 405 | /* Symbols to head events. */ | 376 | /* Symbols to head events. */ |
| @@ -2001,12 +1972,25 @@ Normally, mouse motion is ignored.") | |||
| 2001 | mouse_moved indicates when the mouse has moved again, and | 1972 | mouse_moved indicates when the mouse has moved again, and |
| 2002 | *mouse_position_hook provides the mouse position. */ | 1973 | *mouse_position_hook provides the mouse position. */ |
| 2003 | 1974 | ||
| 1975 | static PERD * | ||
| 1976 | find_active_event_queue () | ||
| 1977 | { | ||
| 1978 | PERD *perd; | ||
| 1979 | perd = &the_only_perd; | ||
| 1980 | /* FOR_ALL_PERDS (perd) */ | ||
| 1981 | { | ||
| 1982 | if (perd->kbd_fetch_ptr != perd->kbd_store_ptr) | ||
| 1983 | return perd; | ||
| 1984 | } | ||
| 1985 | return 0; | ||
| 1986 | } | ||
| 1987 | |||
| 2004 | /* Return true iff there are any events in the queue that read-char | 1988 | /* Return true iff there are any events in the queue that read-char |
| 2005 | would return. If this returns false, a read-char would block. */ | 1989 | would return. If this returns false, a read-char would block. */ |
| 2006 | static int | 1990 | static int |
| 2007 | readable_events () | 1991 | readable_events () |
| 2008 | { | 1992 | { |
| 2009 | return ! EVENT_QUEUES_EMPTY; | 1993 | return find_active_event_queue () != NULL || MOUSE_ACTIVITY_AVAILABLE; |
| 2010 | } | 1994 | } |
| 2011 | 1995 | ||
| 2012 | /* Set this for debugging, to have a way to get out */ | 1996 | /* Set this for debugging, to have a way to get out */ |
| @@ -2018,6 +2002,8 @@ void | |||
| 2018 | kbd_buffer_store_event (event) | 2002 | kbd_buffer_store_event (event) |
| 2019 | register struct input_event *event; | 2003 | register struct input_event *event; |
| 2020 | { | 2004 | { |
| 2005 | PERD *perd = get_perd (XFRAME (event->frame_or_window)); | ||
| 2006 | |||
| 2021 | if (event->kind == no_event) | 2007 | if (event->kind == no_event) |
| 2022 | abort (); | 2008 | abort (); |
| 2023 | 2009 | ||
| @@ -2065,38 +2051,39 @@ kbd_buffer_store_event (event) | |||
| 2065 | } | 2051 | } |
| 2066 | } | 2052 | } |
| 2067 | 2053 | ||
| 2068 | if (kbd_store_ptr - kbd_buffer == KBD_BUFFER_SIZE) | 2054 | if (perd->kbd_store_ptr - perd->kbd_buffer == KBD_BUFFER_SIZE) |
| 2069 | kbd_store_ptr = kbd_buffer; | 2055 | perd->kbd_store_ptr = perd->kbd_buffer; |
| 2070 | 2056 | ||
| 2071 | /* Don't let the very last slot in the buffer become full, | 2057 | /* Don't let the very last slot in the buffer become full, |
| 2072 | since that would make the two pointers equal, | 2058 | since that would make the two pointers equal, |
| 2073 | and that is indistinguishable from an empty buffer. | 2059 | and that is indistinguishable from an empty buffer. |
| 2074 | Discard the event if it would fill the last slot. */ | 2060 | Discard the event if it would fill the last slot. */ |
| 2075 | if (kbd_fetch_ptr - 1 != kbd_store_ptr) | 2061 | if (perd->kbd_fetch_ptr - 1 != perd->kbd_store_ptr) |
| 2076 | { | 2062 | { |
| 2077 | kbd_store_ptr->kind = event->kind; | 2063 | volatile struct input_event *sp = perd->kbd_store_ptr; |
| 2064 | sp->kind = event->kind; | ||
| 2078 | if (event->kind == selection_request_event) | 2065 | if (event->kind == selection_request_event) |
| 2079 | { | 2066 | { |
| 2080 | /* We must not use the ordinary copying code for this case, | 2067 | /* We must not use the ordinary copying code for this case, |
| 2081 | since `part' is an enum and copying it might not copy enough | 2068 | since `part' is an enum and copying it might not copy enough |
| 2082 | in this case. */ | 2069 | in this case. */ |
| 2083 | bcopy (event, (char *) kbd_store_ptr, sizeof (*event)); | 2070 | bcopy (event, (char *) sp, sizeof (*event)); |
| 2084 | } | 2071 | } |
| 2085 | else | 2072 | else |
| 2086 | { | 2073 | { |
| 2087 | kbd_store_ptr->code = event->code; | 2074 | sp->code = event->code; |
| 2088 | kbd_store_ptr->part = event->part; | 2075 | sp->part = event->part; |
| 2089 | kbd_store_ptr->frame_or_window = event->frame_or_window; | 2076 | sp->frame_or_window = event->frame_or_window; |
| 2090 | kbd_store_ptr->modifiers = event->modifiers; | 2077 | sp->modifiers = event->modifiers; |
| 2091 | kbd_store_ptr->x = event->x; | 2078 | sp->x = event->x; |
| 2092 | kbd_store_ptr->y = event->y; | 2079 | sp->y = event->y; |
| 2093 | kbd_store_ptr->timestamp = event->timestamp; | 2080 | sp->timestamp = event->timestamp; |
| 2094 | } | 2081 | } |
| 2095 | (XVECTOR (kbd_buffer_frame_or_window)->contents[kbd_store_ptr | 2082 | (XVECTOR (kbd_buffer_frame_or_window)->contents[perd->kbd_store_ptr |
| 2096 | - kbd_buffer] | 2083 | - perd->kbd_buffer] |
| 2097 | = event->frame_or_window); | 2084 | = event->frame_or_window); |
| 2098 | 2085 | ||
| 2099 | kbd_store_ptr++; | 2086 | perd->kbd_store_ptr++; |
| 2100 | } | 2087 | } |
| 2101 | } | 2088 | } |
| 2102 | 2089 | ||
| @@ -2109,6 +2096,7 @@ kbd_buffer_store_event (event) | |||
| 2109 | static Lisp_Object | 2096 | static Lisp_Object |
| 2110 | kbd_buffer_get_event () | 2097 | kbd_buffer_get_event () |
| 2111 | { | 2098 | { |
| 2099 | PERD *perd; | ||
| 2112 | register int c; | 2100 | register int c; |
| 2113 | Lisp_Object obj; | 2101 | Lisp_Object obj; |
| 2114 | 2102 | ||
| @@ -2122,7 +2110,8 @@ kbd_buffer_get_event () | |||
| 2122 | /* Wait until there is input available. */ | 2110 | /* Wait until there is input available. */ |
| 2123 | for (;;) | 2111 | for (;;) |
| 2124 | { | 2112 | { |
| 2125 | if (!EVENT_QUEUES_EMPTY) | 2113 | perd = find_active_event_queue (); |
| 2114 | if (perd || MOUSE_ACTIVITY_AVAILABLE) | ||
| 2126 | break; | 2115 | break; |
| 2127 | 2116 | ||
| 2128 | /* If the quit flag is set, then read_char will return | 2117 | /* If the quit flag is set, then read_char will return |
| @@ -2140,14 +2129,15 @@ kbd_buffer_get_event () | |||
| 2140 | #ifdef SIGIO | 2129 | #ifdef SIGIO |
| 2141 | gobble_input (0); | 2130 | gobble_input (0); |
| 2142 | #endif /* SIGIO */ | 2131 | #endif /* SIGIO */ |
| 2143 | if (EVENT_QUEUES_EMPTY) | 2132 | perd = find_active_event_queue (); |
| 2133 | if (!(perd || MOUSE_ACTIVITY_AVAILABLE)) | ||
| 2144 | { | 2134 | { |
| 2145 | Lisp_Object minus_one; | 2135 | Lisp_Object minus_one; |
| 2146 | 2136 | ||
| 2147 | XSETINT (minus_one, -1); | 2137 | XSETINT (minus_one, -1); |
| 2148 | wait_reading_process_input (0, 0, minus_one, 1); | 2138 | wait_reading_process_input (0, 0, minus_one, 1); |
| 2149 | 2139 | ||
| 2150 | if (!interrupt_input && EVENT_QUEUES_EMPTY) | 2140 | if (!interrupt_input && find_active_event_queue () == NULL) |
| 2151 | /* Pass 1 for EXPECT since we just waited to have input. */ | 2141 | /* Pass 1 for EXPECT since we just waited to have input. */ |
| 2152 | read_avail_input (1); | 2142 | read_avail_input (1); |
| 2153 | } | 2143 | } |
| @@ -2157,13 +2147,13 @@ kbd_buffer_get_event () | |||
| 2157 | /* At this point, we know that there is a readable event available | 2147 | /* At this point, we know that there is a readable event available |
| 2158 | somewhere. If the event queue is empty, then there must be a | 2148 | somewhere. If the event queue is empty, then there must be a |
| 2159 | mouse movement enabled and available. */ | 2149 | mouse movement enabled and available. */ |
| 2160 | if (kbd_fetch_ptr != kbd_store_ptr) | 2150 | if (perd) |
| 2161 | { | 2151 | { |
| 2162 | struct input_event *event; | 2152 | struct input_event *event; |
| 2163 | 2153 | ||
| 2164 | event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE) | 2154 | event = ((perd->kbd_fetch_ptr < perd->kbd_buffer + KBD_BUFFER_SIZE) |
| 2165 | ? kbd_fetch_ptr | 2155 | ? perd->kbd_fetch_ptr |
| 2166 | : kbd_buffer); | 2156 | : perd->kbd_buffer); |
| 2167 | 2157 | ||
| 2168 | last_event_timestamp = event->timestamp; | 2158 | last_event_timestamp = event->timestamp; |
| 2169 | 2159 | ||
| @@ -2176,7 +2166,7 @@ kbd_buffer_get_event () | |||
| 2176 | { | 2166 | { |
| 2177 | #ifdef HAVE_X11 | 2167 | #ifdef HAVE_X11 |
| 2178 | x_handle_selection_request (event); | 2168 | x_handle_selection_request (event); |
| 2179 | kbd_fetch_ptr = event + 1; | 2169 | perd->kbd_fetch_ptr = event + 1; |
| 2180 | #else | 2170 | #else |
| 2181 | /* We're getting selection request events, but we don't have | 2171 | /* We're getting selection request events, but we don't have |
| 2182 | a window system. */ | 2172 | a window system. */ |
| @@ -2188,7 +2178,7 @@ kbd_buffer_get_event () | |||
| 2188 | { | 2178 | { |
| 2189 | #ifdef HAVE_X11 | 2179 | #ifdef HAVE_X11 |
| 2190 | x_handle_selection_clear (event); | 2180 | x_handle_selection_clear (event); |
| 2191 | kbd_fetch_ptr = event + 1; | 2181 | perd->kbd_fetch_ptr = event + 1; |
| 2192 | #else | 2182 | #else |
| 2193 | /* We're getting selection request events, but we don't have | 2183 | /* We're getting selection request events, but we don't have |
| 2194 | a window system. */ | 2184 | a window system. */ |
| @@ -2201,40 +2191,40 @@ kbd_buffer_get_event () | |||
| 2201 | /* Make an event (delete-frame (FRAME)). */ | 2191 | /* Make an event (delete-frame (FRAME)). */ |
| 2202 | obj = Fcons (event->frame_or_window, Qnil); | 2192 | obj = Fcons (event->frame_or_window, Qnil); |
| 2203 | obj = Fcons (Qdelete_frame, Fcons (obj, Qnil)); | 2193 | obj = Fcons (Qdelete_frame, Fcons (obj, Qnil)); |
| 2204 | kbd_fetch_ptr = event + 1; | 2194 | perd->kbd_fetch_ptr = event + 1; |
| 2205 | } | 2195 | } |
| 2206 | else if (event->kind == iconify_event) | 2196 | else if (event->kind == iconify_event) |
| 2207 | { | 2197 | { |
| 2208 | /* Make an event (iconify-frame (FRAME)). */ | 2198 | /* Make an event (iconify-frame (FRAME)). */ |
| 2209 | obj = Fcons (event->frame_or_window, Qnil); | 2199 | obj = Fcons (event->frame_or_window, Qnil); |
| 2210 | obj = Fcons (Qiconify_frame, Fcons (obj, Qnil)); | 2200 | obj = Fcons (Qiconify_frame, Fcons (obj, Qnil)); |
| 2211 | kbd_fetch_ptr = event + 1; | 2201 | perd->kbd_fetch_ptr = event + 1; |
| 2212 | } | 2202 | } |
| 2213 | else if (event->kind == deiconify_event) | 2203 | else if (event->kind == deiconify_event) |
| 2214 | { | 2204 | { |
| 2215 | /* Make an event (make-frame-visible (FRAME)). */ | 2205 | /* Make an event (make-frame-visible (FRAME)). */ |
| 2216 | obj = Fcons (event->frame_or_window, Qnil); | 2206 | obj = Fcons (event->frame_or_window, Qnil); |
| 2217 | obj = Fcons (Qmake_frame_visible, Fcons (obj, Qnil)); | 2207 | obj = Fcons (Qmake_frame_visible, Fcons (obj, Qnil)); |
| 2218 | kbd_fetch_ptr = event + 1; | 2208 | perd->kbd_fetch_ptr = event + 1; |
| 2219 | } | 2209 | } |
| 2220 | #endif | 2210 | #endif |
| 2221 | else if (event->kind == menu_bar_event) | 2211 | else if (event->kind == menu_bar_event) |
| 2222 | { | 2212 | { |
| 2223 | /* The event value is in the frame_or_window slot. */ | 2213 | /* The event value is in the frame_or_window slot. */ |
| 2224 | obj = event->frame_or_window; | 2214 | obj = event->frame_or_window; |
| 2225 | kbd_fetch_ptr = event + 1; | 2215 | perd->kbd_fetch_ptr = event + 1; |
| 2226 | } | 2216 | } |
| 2227 | else if (event->kind == buffer_switch_event) | 2217 | else if (event->kind == buffer_switch_event) |
| 2228 | { | 2218 | { |
| 2229 | /* The value doesn't matter here; only the type is tested. */ | 2219 | /* The value doesn't matter here; only the type is tested. */ |
| 2230 | XSETBUFFER (obj, current_buffer); | 2220 | XSETBUFFER (obj, current_buffer); |
| 2231 | kbd_fetch_ptr = event + 1; | 2221 | perd->kbd_fetch_ptr = event + 1; |
| 2232 | } | 2222 | } |
| 2233 | /* Just discard these, by returning nil. | 2223 | /* Just discard these, by returning nil. |
| 2234 | (They shouldn't be found in the buffer, | 2224 | (They shouldn't be found in the buffer, |
| 2235 | but on some machines it appears they do show up.) */ | 2225 | but on some machines it appears they do show up.) */ |
| 2236 | else if (event->kind == no_event) | 2226 | else if (event->kind == no_event) |
| 2237 | kbd_fetch_ptr = event + 1; | 2227 | perd->kbd_fetch_ptr = event + 1; |
| 2238 | 2228 | ||
| 2239 | /* If this event is on a different frame, return a switch-frame this | 2229 | /* If this event is on a different frame, return a switch-frame this |
| 2240 | time, and leave the event in the queue for next time. */ | 2230 | time, and leave the event in the queue for next time. */ |
| @@ -2267,10 +2257,10 @@ kbd_buffer_get_event () | |||
| 2267 | 2257 | ||
| 2268 | /* Wipe out this event, to catch bugs. */ | 2258 | /* Wipe out this event, to catch bugs. */ |
| 2269 | event->kind = no_event; | 2259 | event->kind = no_event; |
| 2270 | (XVECTOR (kbd_buffer_frame_or_window)->contents[event - kbd_buffer] | 2260 | (XVECTOR (kbd_buffer_frame_or_window)->contents[event - perd->kbd_buffer] |
| 2271 | = Qnil); | 2261 | = Qnil); |
| 2272 | 2262 | ||
| 2273 | kbd_fetch_ptr = event + 1; | 2263 | perd->kbd_fetch_ptr = event + 1; |
| 2274 | } | 2264 | } |
| 2275 | } | 2265 | } |
| 2276 | } | 2266 | } |
| @@ -2337,13 +2327,14 @@ kbd_buffer_get_event () | |||
| 2337 | void | 2327 | void |
| 2338 | swallow_events () | 2328 | swallow_events () |
| 2339 | { | 2329 | { |
| 2340 | while (kbd_fetch_ptr != kbd_store_ptr) | 2330 | PERD *perd; |
| 2331 | while ((perd = find_active_event_queue ()) != NULL) | ||
| 2341 | { | 2332 | { |
| 2342 | struct input_event *event; | 2333 | struct input_event *event; |
| 2343 | 2334 | ||
| 2344 | event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE) | 2335 | event = ((perd->kbd_fetch_ptr < perd->kbd_buffer + KBD_BUFFER_SIZE) |
| 2345 | ? kbd_fetch_ptr | 2336 | ? perd->kbd_fetch_ptr |
| 2346 | : kbd_buffer); | 2337 | : perd->kbd_buffer); |
| 2347 | 2338 | ||
| 2348 | last_event_timestamp = event->timestamp; | 2339 | last_event_timestamp = event->timestamp; |
| 2349 | 2340 | ||
| @@ -2353,7 +2344,7 @@ swallow_events () | |||
| 2353 | { | 2344 | { |
| 2354 | #ifdef HAVE_X11 | 2345 | #ifdef HAVE_X11 |
| 2355 | x_handle_selection_request (event); | 2346 | x_handle_selection_request (event); |
| 2356 | kbd_fetch_ptr = event + 1; | 2347 | perd->kbd_fetch_ptr = event + 1; |
| 2357 | #else | 2348 | #else |
| 2358 | /* We're getting selection request events, but we don't have | 2349 | /* We're getting selection request events, but we don't have |
| 2359 | a window system. */ | 2350 | a window system. */ |
| @@ -2365,7 +2356,7 @@ swallow_events () | |||
| 2365 | { | 2356 | { |
| 2366 | #ifdef HAVE_X11 | 2357 | #ifdef HAVE_X11 |
| 2367 | x_handle_selection_clear (event); | 2358 | x_handle_selection_clear (event); |
| 2368 | kbd_fetch_ptr = event + 1; | 2359 | perd->kbd_fetch_ptr = event + 1; |
| 2369 | #else | 2360 | #else |
| 2370 | /* We're getting selection request events, but we don't have | 2361 | /* We're getting selection request events, but we don't have |
| 2371 | a window system. */ | 2362 | a window system. */ |
| @@ -5677,6 +5668,7 @@ DEFUN ("discard-input", Fdiscard_input, Sdiscard_input, 0, 0, 0, | |||
| 5677 | Also cancel any kbd macro being defined.") | 5668 | Also cancel any kbd macro being defined.") |
| 5678 | () | 5669 | () |
| 5679 | { | 5670 | { |
| 5671 | PERD *perd = &the_only_perd; | ||
| 5680 | defining_kbd_macro = 0; | 5672 | defining_kbd_macro = 0; |
| 5681 | update_mode_lines++; | 5673 | update_mode_lines++; |
| 5682 | 5674 | ||
| @@ -5688,7 +5680,7 @@ Also cancel any kbd macro being defined.") | |||
| 5688 | /* Without the cast, GCC complains that this assignment loses the | 5680 | /* Without the cast, GCC complains that this assignment loses the |
| 5689 | volatile qualifier of kbd_store_ptr. Is there anything wrong | 5681 | volatile qualifier of kbd_store_ptr. Is there anything wrong |
| 5690 | with that? */ | 5682 | with that? */ |
| 5691 | kbd_fetch_ptr = (struct input_event *) kbd_store_ptr; | 5683 | perd->kbd_fetch_ptr = (struct input_event *) perd->kbd_store_ptr; |
| 5692 | Ffillarray (kbd_buffer_frame_or_window, Qnil); | 5684 | Ffillarray (kbd_buffer_frame_or_window, Qnil); |
| 5693 | input_pending = 0; | 5685 | input_pending = 0; |
| 5694 | 5686 | ||
| @@ -5758,11 +5750,12 @@ On such systems, Emacs starts a subshell instead of suspending.") | |||
| 5758 | stuff_buffered_input (stuffstring) | 5750 | stuff_buffered_input (stuffstring) |
| 5759 | Lisp_Object stuffstring; | 5751 | Lisp_Object stuffstring; |
| 5760 | { | 5752 | { |
| 5761 | register unsigned char *p; | ||
| 5762 | |||
| 5763 | /* stuff_char works only in BSD, versions 4.2 and up. */ | 5753 | /* stuff_char works only in BSD, versions 4.2 and up. */ |
| 5764 | #ifdef BSD | 5754 | #ifdef BSD |
| 5765 | #ifndef BSD4_1 | 5755 | #ifndef BSD4_1 |
| 5756 | register unsigned char *p; | ||
| 5757 | PERD *perd = &the_only_perd; /* We really want the primary display's perd */ | ||
| 5758 | |||
| 5766 | if (STRINGP (stuffstring)) | 5759 | if (STRINGP (stuffstring)) |
| 5767 | { | 5760 | { |
| 5768 | register int count; | 5761 | register int count; |
| @@ -5774,17 +5767,17 @@ stuff_buffered_input (stuffstring) | |||
| 5774 | stuff_char ('\n'); | 5767 | stuff_char ('\n'); |
| 5775 | } | 5768 | } |
| 5776 | /* Anything we have read ahead, put back for the shell to read. */ | 5769 | /* Anything we have read ahead, put back for the shell to read. */ |
| 5777 | while (kbd_fetch_ptr != kbd_store_ptr) | 5770 | while (perd->kbd_fetch_ptr != perd->kbd_store_ptr) |
| 5778 | { | 5771 | { |
| 5779 | if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE) | 5772 | if (perd->kbd_fetch_ptr == perd->kbd_buffer + KBD_BUFFER_SIZE) |
| 5780 | kbd_fetch_ptr = kbd_buffer; | 5773 | perd->kbd_fetch_ptr = perd->kbd_buffer; |
| 5781 | if (kbd_fetch_ptr->kind == ascii_keystroke) | 5774 | if (perd->kbd_fetch_ptr->kind == ascii_keystroke) |
| 5782 | stuff_char (kbd_fetch_ptr->code); | 5775 | stuff_char (perd->kbd_fetch_ptr->code); |
| 5783 | kbd_fetch_ptr->kind = no_event; | 5776 | perd->kbd_fetch_ptr->kind = no_event; |
| 5784 | (XVECTOR (kbd_buffer_frame_or_window)->contents[kbd_fetch_ptr | 5777 | (XVECTOR (kbd_buffer_frame_or_window)->contents[perd->kbd_fetch_ptr |
| 5785 | - kbd_buffer] | 5778 | - perd->kbd_buffer] |
| 5786 | = Qnil); | 5779 | = Qnil); |
| 5787 | kbd_fetch_ptr++; | 5780 | perd->kbd_fetch_ptr++; |
| 5788 | } | 5781 | } |
| 5789 | input_pending = 0; | 5782 | input_pending = 0; |
| 5790 | #endif | 5783 | #endif |
| @@ -6054,8 +6047,11 @@ init_keyboard () | |||
| 6054 | unread_command_char = -1; | 6047 | unread_command_char = -1; |
| 6055 | total_keys = 0; | 6048 | total_keys = 0; |
| 6056 | recent_keys_index = 0; | 6049 | recent_keys_index = 0; |
| 6057 | kbd_fetch_ptr = kbd_buffer; | 6050 | the_only_perd.kbd_buffer |
| 6058 | kbd_store_ptr = kbd_buffer; | 6051 | = (struct input_event *)xmalloc (KBD_BUFFER_SIZE |
| 6052 | * sizeof (struct input_event)); | ||
| 6053 | the_only_perd.kbd_fetch_ptr = the_only_perd.kbd_buffer; | ||
| 6054 | the_only_perd.kbd_store_ptr = the_only_perd.kbd_buffer; | ||
| 6059 | #ifdef HAVE_MOUSE | 6055 | #ifdef HAVE_MOUSE |
| 6060 | do_mouse_tracking = Qnil; | 6056 | do_mouse_tracking = Qnil; |
| 6061 | #endif | 6057 | #endif |