aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
authorPaul Eggert2012-09-23 01:44:20 -0700
committerPaul Eggert2012-09-23 01:44:20 -0700
commit4d7e6e51dd4acecff466a28d958c50f34fc130b8 (patch)
tree5e340d48fb69f9a40a4304cc94db2006caefe51f /src/xterm.c
parent8f4635e97e1587c4026ec83fc1bd9f8954775915 (diff)
downloademacs-4d7e6e51dd4acecff466a28d958c50f34fc130b8.tar.gz
emacs-4d7e6e51dd4acecff466a28d958c50f34fc130b8.zip
Simplify and avoid signal-handling races.
* nt/inc/ms-w32.h (emacs_raise): New macro. * src/alloc.c (die): * src/sysdep.c (emacs_abort) [HAVE_NTGUI]: Avoid recursive loop if there's a fatal error in the function itself. * src/atimer.c (pending_atimers): * src/blockinput.h: Don't include "atimer.h"; no longer needed. (interrupt_input_pending): Remove. All uses removed. pending_signals now counts both atimers and ordinary interrupts. This is less racy than having three separate pending-signal flags. (block_input, unblock_input, totally_unblock_input, unblock_input_to) (input_blocked_p): Rename from their upper-case counterparts BLOCK_INPUT, UNBLOCK_INPUT, TOTALLY_UNBLOCK_INPUT, UNBLOCK_INPUT_TO, INPUT_BLOCKED_P, and turn into functions. All uses changed. This makes it easier to access volatile variables more accurately. (BLOCK_INPUT_RESIGNAL): Remove. All uses replaced by unblock_input (). (input_blocked_p): Prefer this to 'interrupt_input_blocked', as that's more reliable if the code is buggy and sets interrupt_input_blocked to a negative value. All uses changed. * src/atimer.c (deliver_alarm_signal): Remove. No need to deliver this to the parent; any thread can handle this signal now. All uses replaced by underlying handler. * src/atimer.c (turn_on_atimers): * src/dispnew.c (handle_window_change_signal): * src/emacs.c (handle_danger_signal): * src/keyboard.c (kbd_buffer_get_event): Don't reestablish signal handler; not needed with sigaction. * src/blockinput.h (UNBLOCK_INPUT_TO, TOTALLY_UNBLOCK_INPUT) (UNBLOCK_INPUT_TO): Rework to avoid unnecessary accesses to volatile variables. (UNBLOCK_INPUT_TO): Now a function. (totally_unblock_input, unblock_input): New decls. * src/data.c (handle_arith_signal, deliver_arith_signal): Move to sysdep.c (init_data): Remove. Necessary stuff now done in init_signal. * src/emacs.c, src/xdisp.c: Include "atimer.h", since we invoke atimer functions. * src/emacs.c (handle_fatal_signal, deliver_fatal_signal): Move to sysdep.c. (fatal_error_code): Remove; no longer needed. (terminate_due_to_signal): Rename from fatal_error_backtrace, since it doesn't always backtrace. All uses changed. No need to reset signal to default, since sigaction and/or die does that for us now. Use emacs_raise (FOO), not kill (getpid (), FOO). (main): Check more-accurately whether we're dumping. Move fatal-error setup to sysdep.c * src/floatfns.c: Do not include "syssignal.h"; no longer needed. * src/gtkutil.c (xg_get_file_name, xg_get_font): Remove no-longer-needed signal-mask manipulation. * src/keyboard.c, src/process.c (POLL_FOR_INPUT): Don't depend on USE_ASYNC_EVENTS, a symbol that is never defined. * src/keyboard.c (read_avail_input): Remove. All uses replaced by gobble_input. (Ftop_level): Use TOTALLY_UNBLOCK_INPUT rather than open code. (kbd_buffer_store_event_hold, gobble_input): (record_asynch_buffer_change) [USABLE_SIGIO]: (store_user_signal_events): No need to mess with signal mask. (gobble_input): If blocking input and there are terminals, simply set pending_signals to 1 and return. All hooks changed to not worry about whether input is blocked. (process_pending_signals): Clear pending_signals before processing them, in case a signal comes in while we're processing. By convention callers now test pending_signals before calling us. (UNBLOCK_INPUT_TO, unblock_input, totally_unblock_input): New functions, to support changes to blockinput.h. (handle_input_available_signal): Now extern. (reinvoke_input_signal): Remove. All uses replaced by handle_async_input. (quit_count): Now volatile, since a signal handler uses it. (handle_interrupt): Now takes bool IN_SIGNAL_HANDLER as arg. All callers changed. Block SIGINT only if not already blocked. Clear sigmask reliably, even if Fsignal returns, which it can. Omit unnecessary accesses to volatile var. (quit_throw_to_read_char): No need to restore sigmask. * src/keyboard.c (gobble_input, handle_user_signal): * src/process.c (wait_reading_process_output): Call signal-handling code rather than killing ourselves. * src/lisp.h: Include <float.h>, for... (IEEE_FLOATING_POINT): New macro, moved here to avoid duplication. (pending_signals): Now volatile. (syms_of_data): Now const if IEEE floating point. (handle_input_available_signal) [USABLE_SIGIO]: (terminate_due_to_signal, record_child_status_change): New decls. * src/process.c (create_process): Avoid disaster if memory is exhausted while we're processing a vfork, by tightening the critical section around the vfork. (send_process_frame, process_sent_to, handle_pipe_signal) (deliver_pipe_signal): Remove. No longer needed, as Emacs now ignores SIGPIPE. (send_process): No need for setjmp/longjmp any more, since the SIGPIPE stuff is now gone. Instead, report an error if errno is EPIPE. (record_child_status_change): Now extern. PID and W are now args. Return void, not bool. All callers changed. * src/sysdep.c (wait_debugging) [(BSD_SYSTEM || HPUX) && !defined (__GNU__)]: Remove. All uses removed. This bug should be fixed now in a different way. (wait_for_termination_1): Use waitpid rather than sigsuspend, and record the child status change directly. This avoids the need to futz with the signal mask. (process_fatal_action): Move here from emacs.c. (emacs_sigaction_flags): New function, containing much of what used to be in emacs_sigaction_init. (emacs_sigaction_init): Use it. Block nonfatal system signals that are caught by emacs, to make races less likely. (deliver_process_signal): Rename from handle_on_main_thread. All uses changed. (BACKTRACE_LIMIT_MAX): Now at top level. (thread_backtrace_buffer, threadback_backtrace_pointers): New static vars. (deliver_thread_signal, deliver_fatal_thread_signal): New functions, for more-accurate delivery of thread-specific signals. (handle_fatal_signal, deliver_fatal_signal): Move here from emacs.c. (deliver_arith_signal): Handle in this thread, not in the main thread, since it's triggered by this thread. (maybe_fatal_sig): New function. (init_signals): New arg DUMPING so that we can be more accurate about whether we're dumping. Caller changed. Treat thread-specific signals differently from process-general signals. Block all signals while handling fatal error; that's safer. xsignal from SIGFPE only on non-IEEE hosts, treating it as fatal on IEEE hosts. When batch, ignore SIGHUP, SIGINT, SIGTERM if they were already ignored. Ignore SIGPIPE unless batch. (emacs_backtrace): Output backtrace for the appropriate thread, which is not necessarily the main thread. * src/syssignal.h: Include <stdbool.h>. (emacs_raise): New macro. * src/xterm.c (x_connection_signal): Remove; no longer needed now that we use sigaction. (x_connection_closed): No need to mess with sigmask now. (x_initialize): No need to reset SIGPIPE handler here, since init_signals does this for us now. Fixes: debbugs:12471
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c302
1 files changed, 129 insertions, 173 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 8c955d0e576..5b34cc39815 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -353,7 +353,7 @@ x_flush (struct frame *f)
353 if (!NILP (Vinhibit_redisplay)) 353 if (!NILP (Vinhibit_redisplay))
354 return; 354 return;
355 355
356 BLOCK_INPUT; 356 block_input ();
357 if (f == NULL) 357 if (f == NULL)
358 { 358 {
359 Lisp_Object rest, frame; 359 Lisp_Object rest, frame;
@@ -363,7 +363,7 @@ x_flush (struct frame *f)
363 } 363 }
364 else if (FRAME_X_P (f)) 364 else if (FRAME_X_P (f))
365 XFlush (FRAME_X_DISPLAY (f)); 365 XFlush (FRAME_X_DISPLAY (f));
366 UNBLOCK_INPUT; 366 unblock_input ();
367} 367}
368 368
369 369
@@ -564,7 +564,7 @@ x_update_window_begin (struct window *w)
564 updated_window = w; 564 updated_window = w;
565 set_output_cursor (&w->cursor); 565 set_output_cursor (&w->cursor);
566 566
567 BLOCK_INPUT; 567 block_input ();
568 568
569 if (f == hlinfo->mouse_face_mouse_frame) 569 if (f == hlinfo->mouse_face_mouse_frame)
570 { 570 {
@@ -577,7 +577,7 @@ x_update_window_begin (struct window *w)
577 hlinfo->mouse_face_window = Qnil; 577 hlinfo->mouse_face_window = Qnil;
578 } 578 }
579 579
580 UNBLOCK_INPUT; 580 unblock_input ();
581} 581}
582 582
583 583
@@ -618,7 +618,7 @@ x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritt
618 618
619 if (!w->pseudo_window_p) 619 if (!w->pseudo_window_p)
620 { 620 {
621 BLOCK_INPUT; 621 block_input ();
622 622
623 if (cursor_on_p) 623 if (cursor_on_p)
624 display_and_set_cursor (w, 1, output_cursor.hpos, 624 display_and_set_cursor (w, 1, output_cursor.hpos,
@@ -628,7 +628,7 @@ x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritt
628 if (draw_window_fringes (w, 1)) 628 if (draw_window_fringes (w, 1))
629 x_draw_vertical_border (w); 629 x_draw_vertical_border (w);
630 630
631 UNBLOCK_INPUT; 631 unblock_input ();
632 } 632 }
633 633
634 /* If a row with mouse-face was overwritten, arrange for 634 /* If a row with mouse-face was overwritten, arrange for
@@ -654,9 +654,9 @@ x_update_end (struct frame *f)
654 MOUSE_HL_INFO (f)->mouse_face_defer = 0; 654 MOUSE_HL_INFO (f)->mouse_face_defer = 0;
655 655
656#ifndef XFlush 656#ifndef XFlush
657 BLOCK_INPUT; 657 block_input ();
658 XFlush (FRAME_X_DISPLAY (f)); 658 XFlush (FRAME_X_DISPLAY (f));
659 UNBLOCK_INPUT; 659 unblock_input ();
660#endif 660#endif
661} 661}
662 662
@@ -675,13 +675,13 @@ XTframe_up_to_date (struct frame *f)
675 if (hlinfo->mouse_face_deferred_gc 675 if (hlinfo->mouse_face_deferred_gc
676 || f == hlinfo->mouse_face_mouse_frame) 676 || f == hlinfo->mouse_face_mouse_frame)
677 { 677 {
678 BLOCK_INPUT; 678 block_input ();
679 if (hlinfo->mouse_face_mouse_frame) 679 if (hlinfo->mouse_face_mouse_frame)
680 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, 680 note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
681 hlinfo->mouse_face_mouse_x, 681 hlinfo->mouse_face_mouse_x,
682 hlinfo->mouse_face_mouse_y); 682 hlinfo->mouse_face_mouse_y);
683 hlinfo->mouse_face_deferred_gc = 0; 683 hlinfo->mouse_face_deferred_gc = 0;
684 UNBLOCK_INPUT; 684 unblock_input ();
685 } 685 }
686 } 686 }
687} 687}
@@ -722,13 +722,13 @@ x_after_update_window_line (struct glyph_row *desired_row)
722 { 722 {
723 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y)); 723 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
724 724
725 BLOCK_INPUT; 725 block_input ();
726 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 726 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
727 0, y, width, height, False); 727 0, y, width, height, False);
728 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 728 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
729 FRAME_PIXEL_WIDTH (f) - width, 729 FRAME_PIXEL_WIDTH (f) - width,
730 y, width, height, False); 730 y, width, height, False);
731 UNBLOCK_INPUT; 731 unblock_input ();
732 } 732 }
733} 733}
734 734
@@ -1789,10 +1789,10 @@ x_copy_color (struct frame *f, long unsigned int pixel)
1789 XColor color; 1789 XColor color;
1790 1790
1791 color.pixel = pixel; 1791 color.pixel = pixel;
1792 BLOCK_INPUT; 1792 block_input ();
1793 x_query_color (f, &color); 1793 x_query_color (f, &color);
1794 XAllocColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &color); 1794 XAllocColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &color);
1795 UNBLOCK_INPUT; 1795 unblock_input ();
1796#ifdef DEBUG_X_COLORS 1796#ifdef DEBUG_X_COLORS
1797 register_color (pixel); 1797 register_color (pixel);
1798#endif 1798#endif
@@ -3028,7 +3028,7 @@ x_clear_frame (struct frame *f)
3028 3028
3029 /* We don't set the output cursor here because there will always 3029 /* We don't set the output cursor here because there will always
3030 follow an explicit cursor_to. */ 3030 follow an explicit cursor_to. */
3031 BLOCK_INPUT; 3031 block_input ();
3032 3032
3033 XClearWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); 3033 XClearWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
3034 3034
@@ -3045,7 +3045,7 @@ x_clear_frame (struct frame *f)
3045 3045
3046 XFlush (FRAME_X_DISPLAY (f)); 3046 XFlush (FRAME_X_DISPLAY (f));
3047 3047
3048 UNBLOCK_INPUT; 3048 unblock_input ();
3049} 3049}
3050 3050
3051 3051
@@ -3055,7 +3055,7 @@ x_clear_frame (struct frame *f)
3055static void 3055static void
3056XTflash (struct frame *f) 3056XTflash (struct frame *f)
3057{ 3057{
3058 BLOCK_INPUT; 3058 block_input ();
3059 3059
3060 { 3060 {
3061#ifdef USE_GTK 3061#ifdef USE_GTK
@@ -3208,14 +3208,14 @@ XTflash (struct frame *f)
3208 } 3208 }
3209 } 3209 }
3210 3210
3211 UNBLOCK_INPUT; 3211 unblock_input ();
3212} 3212}
3213 3213
3214 3214
3215static void 3215static void
3216XTtoggle_invisible_pointer (FRAME_PTR f, int invisible) 3216XTtoggle_invisible_pointer (FRAME_PTR f, int invisible)
3217{ 3217{
3218 BLOCK_INPUT; 3218 block_input ();
3219 if (invisible) 3219 if (invisible)
3220 { 3220 {
3221 if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor != 0) 3221 if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor != 0)
@@ -3226,7 +3226,7 @@ XTtoggle_invisible_pointer (FRAME_PTR f, int invisible)
3226 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 3226 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3227 f->output_data.x->current_cursor); 3227 f->output_data.x->current_cursor);
3228 f->pointer_invisible = invisible; 3228 f->pointer_invisible = invisible;
3229 UNBLOCK_INPUT; 3229 unblock_input ();
3230} 3230}
3231 3231
3232 3232
@@ -3241,10 +3241,10 @@ XTring_bell (struct frame *f)
3241 XTflash (f); 3241 XTflash (f);
3242 else 3242 else
3243 { 3243 {
3244 BLOCK_INPUT; 3244 block_input ();
3245 XBell (FRAME_X_DISPLAY (f), 0); 3245 XBell (FRAME_X_DISPLAY (f), 0);
3246 XFlush (FRAME_X_DISPLAY (f)); 3246 XFlush (FRAME_X_DISPLAY (f));
3247 UNBLOCK_INPUT; 3247 unblock_input ();
3248 } 3248 }
3249 } 3249 }
3250} 3250}
@@ -3341,7 +3341,7 @@ x_scroll_run (struct window *w, struct run *run)
3341 height = run->height; 3341 height = run->height;
3342 } 3342 }
3343 3343
3344 BLOCK_INPUT; 3344 block_input ();
3345 3345
3346 /* Cursor off. Will be switched on again in x_update_window_end. */ 3346 /* Cursor off. Will be switched on again in x_update_window_end. */
3347 updated_window = w; 3347 updated_window = w;
@@ -3354,7 +3354,7 @@ x_scroll_run (struct window *w, struct run *run)
3354 width, height, 3354 width, height,
3355 x, to_y); 3355 x, to_y);
3356 3356
3357 UNBLOCK_INPUT; 3357 unblock_input ();
3358} 3358}
3359 3359
3360 3360
@@ -3371,7 +3371,7 @@ frame_highlight (struct frame *f)
3371 the ICCCM (section 4.1.6) says that the window's border pixmap 3371 the ICCCM (section 4.1.6) says that the window's border pixmap
3372 and border pixel are window attributes which are "private to the 3372 and border pixel are window attributes which are "private to the
3373 client", so we can always change it to whatever we want. */ 3373 client", so we can always change it to whatever we want. */
3374 BLOCK_INPUT; 3374 block_input ();
3375 /* I recently started to get errors in this XSetWindowBorder, depending on 3375 /* I recently started to get errors in this XSetWindowBorder, depending on
3376 the window-manager in use, tho something more is at play since I've been 3376 the window-manager in use, tho something more is at play since I've been
3377 using that same window-manager binary for ever. Let's not crash just 3377 using that same window-manager binary for ever. Let's not crash just
@@ -3380,7 +3380,7 @@ frame_highlight (struct frame *f)
3380 XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 3380 XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3381 f->output_data.x->border_pixel); 3381 f->output_data.x->border_pixel);
3382 x_uncatch_errors (); 3382 x_uncatch_errors ();
3383 UNBLOCK_INPUT; 3383 unblock_input ();
3384 x_update_cursor (f, 1); 3384 x_update_cursor (f, 1);
3385 x_set_frame_alpha (f); 3385 x_set_frame_alpha (f);
3386} 3386}
@@ -3392,13 +3392,13 @@ frame_unhighlight (struct frame *f)
3392 the ICCCM (section 4.1.6) says that the window's border pixmap 3392 the ICCCM (section 4.1.6) says that the window's border pixmap
3393 and border pixel are window attributes which are "private to the 3393 and border pixel are window attributes which are "private to the
3394 client", so we can always change it to whatever we want. */ 3394 client", so we can always change it to whatever we want. */
3395 BLOCK_INPUT; 3395 block_input ();
3396 /* Same as above for XSetWindowBorder (bug#9310). */ 3396 /* Same as above for XSetWindowBorder (bug#9310). */
3397 x_catch_errors (FRAME_X_DISPLAY (f)); 3397 x_catch_errors (FRAME_X_DISPLAY (f));
3398 XSetWindowBorderPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 3398 XSetWindowBorderPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3399 f->output_data.x->border_tile); 3399 f->output_data.x->border_tile);
3400 x_uncatch_errors (); 3400 x_uncatch_errors ();
3401 UNBLOCK_INPUT; 3401 unblock_input ();
3402 x_update_cursor (f, 1); 3402 x_update_cursor (f, 1);
3403 x_set_frame_alpha (f); 3403 x_set_frame_alpha (f);
3404} 3404}
@@ -3765,9 +3765,9 @@ x_get_keysym_name (int keysym)
3765{ 3765{
3766 char *value; 3766 char *value;
3767 3767
3768 BLOCK_INPUT; 3768 block_input ();
3769 value = XKeysymToString (keysym); 3769 value = XKeysymToString (keysym);
3770 UNBLOCK_INPUT; 3770 unblock_input ();
3771 3771
3772 return value; 3772 return value;
3773} 3773}
@@ -3897,7 +3897,7 @@ XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
3897{ 3897{
3898 FRAME_PTR f1; 3898 FRAME_PTR f1;
3899 3899
3900 BLOCK_INPUT; 3900 block_input ();
3901 3901
3902 if (! NILP (last_mouse_scroll_bar) && insist == 0) 3902 if (! NILP (last_mouse_scroll_bar) && insist == 0)
3903 x_scroll_bar_report_motion (fp, bar_window, part, x, y, timestamp); 3903 x_scroll_bar_report_motion (fp, bar_window, part, x, y, timestamp);
@@ -4078,7 +4078,7 @@ XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
4078 } 4078 }
4079 } 4079 }
4080 4080
4081 UNBLOCK_INPUT; 4081 unblock_input ();
4082} 4082}
4083 4083
4084 4084
@@ -4267,7 +4267,7 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole)
4267 struct frame *f = XFRAME (w->frame); 4267 struct frame *f = XFRAME (w->frame);
4268 ptrdiff_t i; 4268 ptrdiff_t i;
4269 4269
4270 BLOCK_INPUT; 4270 block_input ();
4271 4271
4272 /* Construct a ClientMessage event to send to the frame. */ 4272 /* Construct a ClientMessage event to send to the frame. */
4273 ev->type = ClientMessage; 4273 ev->type = ClientMessage;
@@ -4314,7 +4314,7 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole)
4314 be sent to the client that created the window, and if that 4314 be sent to the client that created the window, and if that
4315 window no longer exists, no event will be sent. */ 4315 window no longer exists, no event will be sent. */
4316 XSendEvent (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), False, 0, &event); 4316 XSendEvent (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), False, 0, &event);
4317 UNBLOCK_INPUT; 4317 unblock_input ();
4318} 4318}
4319 4319
4320 4320
@@ -4405,9 +4405,9 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4405 int slider_size; 4405 int slider_size;
4406 4406
4407 /* Get the slider size. */ 4407 /* Get the slider size. */
4408 BLOCK_INPUT; 4408 block_input ();
4409 XtVaGetValues (widget, XmNsliderSize, &slider_size, NULL); 4409 XtVaGetValues (widget, XmNsliderSize, &slider_size, NULL);
4410 UNBLOCK_INPUT; 4410 unblock_input ();
4411 4411
4412 whole = XM_SB_MAX - slider_size; 4412 whole = XM_SB_MAX - slider_size;
4413 portion = min (cs->value, whole); 4413 portion = min (cs->value, whole);
@@ -4528,9 +4528,9 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4528 int part; 4528 int part;
4529 4529
4530 /* Get the size of the thumb, a value between 0 and 1. */ 4530 /* Get the size of the thumb, a value between 0 and 1. */
4531 BLOCK_INPUT; 4531 block_input ();
4532 XtVaGetValues (widget, XtNshown, &shown, XtNheight, &height, NULL); 4532 XtVaGetValues (widget, XtNshown, &shown, XtNheight, &height, NULL);
4533 UNBLOCK_INPUT; 4533 unblock_input ();
4534 4534
4535 whole = 10000000; 4535 whole = 10000000;
4536 portion = shown < 1 ? top * whole : 0; 4536 portion = shown < 1 ? top * whole : 0;
@@ -4570,9 +4570,9 @@ xaw_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4570 int part; 4570 int part;
4571 4571
4572 /* Get the height of the scroll bar. */ 4572 /* Get the height of the scroll bar. */
4573 BLOCK_INPUT; 4573 block_input ();
4574 XtVaGetValues (widget, XtNheight, &height, NULL); 4574 XtVaGetValues (widget, XtNheight, &height, NULL);
4575 UNBLOCK_INPUT; 4575 unblock_input ();
4576 4576
4577 if (eabs (position) >= height) 4577 if (eabs (position) >= height)
4578 part = (position < 0) ? scroll_bar_above_handle : scroll_bar_below_handle; 4578 part = (position < 0) ? scroll_bar_above_handle : scroll_bar_below_handle;
@@ -4603,11 +4603,11 @@ x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar)
4603{ 4603{
4604 const char *scroll_bar_name = SCROLL_BAR_NAME; 4604 const char *scroll_bar_name = SCROLL_BAR_NAME;
4605 4605
4606 BLOCK_INPUT; 4606 block_input ();
4607 xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback), 4607 xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback),
4608 G_CALLBACK (xg_end_scroll_callback), 4608 G_CALLBACK (xg_end_scroll_callback),
4609 scroll_bar_name); 4609 scroll_bar_name);
4610 UNBLOCK_INPUT; 4610 unblock_input ();
4611} 4611}
4612 4612
4613#else /* not USE_GTK */ 4613#else /* not USE_GTK */
@@ -4622,7 +4622,7 @@ x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar)
4622 const char *scroll_bar_name = SCROLL_BAR_NAME; 4622 const char *scroll_bar_name = SCROLL_BAR_NAME;
4623 unsigned long pixel; 4623 unsigned long pixel;
4624 4624
4625 BLOCK_INPUT; 4625 block_input ();
4626 4626
4627#ifdef USE_MOTIF 4627#ifdef USE_MOTIF
4628 /* Set resources. Create the widget. */ 4628 /* Set resources. Create the widget. */
@@ -4806,7 +4806,7 @@ x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar)
4806 xwindow = XtWindow (widget); 4806 xwindow = XtWindow (widget);
4807 bar->x_window = xwindow; 4807 bar->x_window = xwindow;
4808 4808
4809 UNBLOCK_INPUT; 4809 unblock_input ();
4810} 4810}
4811#endif /* not USE_GTK */ 4811#endif /* not USE_GTK */
4812 4812
@@ -4830,7 +4830,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
4830 Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); 4830 Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar);
4831 float top, shown; 4831 float top, shown;
4832 4832
4833 BLOCK_INPUT; 4833 block_input ();
4834 4834
4835#ifdef USE_MOTIF 4835#ifdef USE_MOTIF
4836 4836
@@ -4921,7 +4921,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
4921 } 4921 }
4922#endif /* !USE_MOTIF */ 4922#endif /* !USE_MOTIF */
4923 4923
4924 UNBLOCK_INPUT; 4924 unblock_input ();
4925} 4925}
4926#endif /* not USE_GTK */ 4926#endif /* not USE_GTK */
4927 4927
@@ -4946,7 +4946,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
4946 = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, x_window, PVEC_OTHER); 4946 = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, x_window, PVEC_OTHER);
4947 Lisp_Object barobj; 4947 Lisp_Object barobj;
4948 4948
4949 BLOCK_INPUT; 4949 block_input ();
4950 4950
4951#ifdef USE_TOOLKIT_SCROLL_BARS 4951#ifdef USE_TOOLKIT_SCROLL_BARS
4952 x_create_toolkit_scroll_bar (f, bar); 4952 x_create_toolkit_scroll_bar (f, bar);
@@ -5034,7 +5034,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
5034 XMapRaised (FRAME_X_DISPLAY (f), bar->x_window); 5034 XMapRaised (FRAME_X_DISPLAY (f), bar->x_window);
5035#endif /* not USE_TOOLKIT_SCROLL_BARS */ 5035#endif /* not USE_TOOLKIT_SCROLL_BARS */
5036 5036
5037 UNBLOCK_INPUT; 5037 unblock_input ();
5038 return bar; 5038 return bar;
5039} 5039}
5040 5040
@@ -5068,7 +5068,7 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild
5068 && end == bar->end) 5068 && end == bar->end)
5069 return; 5069 return;
5070 5070
5071 BLOCK_INPUT; 5071 block_input ();
5072 5072
5073 { 5073 {
5074 int inside_width = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, bar->width); 5074 int inside_width = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, bar->width);
@@ -5144,7 +5144,7 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild
5144 5144
5145 } 5145 }
5146 5146
5147 UNBLOCK_INPUT; 5147 unblock_input ();
5148} 5148}
5149 5149
5150#endif /* !USE_TOOLKIT_SCROLL_BARS */ 5150#endif /* !USE_TOOLKIT_SCROLL_BARS */
@@ -5156,7 +5156,7 @@ static void
5156x_scroll_bar_remove (struct scroll_bar *bar) 5156x_scroll_bar_remove (struct scroll_bar *bar)
5157{ 5157{
5158 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 5158 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
5159 BLOCK_INPUT; 5159 block_input ();
5160 5160
5161#ifdef USE_TOOLKIT_SCROLL_BARS 5161#ifdef USE_TOOLKIT_SCROLL_BARS
5162#ifdef USE_GTK 5162#ifdef USE_GTK
@@ -5171,7 +5171,7 @@ x_scroll_bar_remove (struct scroll_bar *bar)
5171 /* Dissociate this scroll bar from its window. */ 5171 /* Dissociate this scroll bar from its window. */
5172 wset_vertical_scroll_bar (XWINDOW (bar->window), Qnil); 5172 wset_vertical_scroll_bar (XWINDOW (bar->window), Qnil);
5173 5173
5174 UNBLOCK_INPUT; 5174 unblock_input ();
5175} 5175}
5176 5176
5177 5177
@@ -5239,7 +5239,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5239 { 5239 {
5240 if (width > 0 && height > 0) 5240 if (width > 0 && height > 0)
5241 { 5241 {
5242 BLOCK_INPUT; 5242 block_input ();
5243#ifdef USE_TOOLKIT_SCROLL_BARS 5243#ifdef USE_TOOLKIT_SCROLL_BARS
5244 if (fringe_extended_p) 5244 if (fringe_extended_p)
5245 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5245 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
@@ -5248,7 +5248,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5248#endif 5248#endif
5249 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5249 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5250 left, top, width, height, False); 5250 left, top, width, height, False);
5251 UNBLOCK_INPUT; 5251 unblock_input ();
5252 } 5252 }
5253 5253
5254 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height); 5254 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height);
@@ -5260,7 +5260,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5260 5260
5261 bar = XSCROLL_BAR (w->vertical_scroll_bar); 5261 bar = XSCROLL_BAR (w->vertical_scroll_bar);
5262 5262
5263 BLOCK_INPUT; 5263 block_input ();
5264 5264
5265 if (sb_left != bar->left) 5265 if (sb_left != bar->left)
5266 mask |= CWX; 5266 mask |= CWX;
@@ -5357,7 +5357,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5357 bar->width = sb_width; 5357 bar->width = sb_width;
5358 bar->height = height; 5358 bar->height = height;
5359 5359
5360 UNBLOCK_INPUT; 5360 unblock_input ();
5361 } 5361 }
5362 5362
5363#ifdef USE_TOOLKIT_SCROLL_BARS 5363#ifdef USE_TOOLKIT_SCROLL_BARS
@@ -5508,7 +5508,7 @@ x_scroll_bar_expose (struct scroll_bar *bar, XEvent *event)
5508 GC gc = f->output_data.x->normal_gc; 5508 GC gc = f->output_data.x->normal_gc;
5509 int width_trim = VERTICAL_SCROLL_BAR_WIDTH_TRIM; 5509 int width_trim = VERTICAL_SCROLL_BAR_WIDTH_TRIM;
5510 5510
5511 BLOCK_INPUT; 5511 block_input ();
5512 5512
5513 x_scroll_bar_set_handle (bar, bar->start, bar->end, 1); 5513 x_scroll_bar_set_handle (bar, bar->start, bar->end, 1);
5514 5514
@@ -5530,7 +5530,7 @@ x_scroll_bar_expose (struct scroll_bar *bar, XEvent *event)
5530 XSetForeground (FRAME_X_DISPLAY (f), gc, 5530 XSetForeground (FRAME_X_DISPLAY (f), gc,
5531 FRAME_FOREGROUND_PIXEL (f)); 5531 FRAME_FOREGROUND_PIXEL (f));
5532 5532
5533 UNBLOCK_INPUT; 5533 unblock_input ();
5534 5534
5535} 5535}
5536#endif /* not USE_TOOLKIT_SCROLL_BARS */ 5536#endif /* not USE_TOOLKIT_SCROLL_BARS */
@@ -5643,7 +5643,7 @@ x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window,
5643 int dummy_coord; 5643 int dummy_coord;
5644 unsigned int dummy_mask; 5644 unsigned int dummy_mask;
5645 5645
5646 BLOCK_INPUT; 5646 block_input ();
5647 5647
5648 /* Get the mouse's position relative to the scroll bar window, and 5648 /* Get the mouse's position relative to the scroll bar window, and
5649 report that. */ 5649 report that. */
@@ -5695,7 +5695,7 @@ x_scroll_bar_report_motion (FRAME_PTR *fp, Lisp_Object *bar_window,
5695 5695
5696 *timestamp = last_mouse_movement_time; 5696 *timestamp = last_mouse_movement_time;
5697 5697
5698 UNBLOCK_INPUT; 5698 unblock_input ();
5699} 5699}
5700 5700
5701 5701
@@ -5816,7 +5816,7 @@ event_handler_gdk (GdkXEvent *gxev, GdkEvent *ev, gpointer data)
5816{ 5816{
5817 XEvent *xev = (XEvent *) gxev; 5817 XEvent *xev = (XEvent *) gxev;
5818 5818
5819 BLOCK_INPUT; 5819 block_input ();
5820 if (current_count >= 0) 5820 if (current_count >= 0)
5821 { 5821 {
5822 struct x_display_info *dpyinfo; 5822 struct x_display_info *dpyinfo;
@@ -5831,7 +5831,7 @@ event_handler_gdk (GdkXEvent *gxev, GdkEvent *ev, gpointer data)
5831 && dpyinfo 5831 && dpyinfo
5832 && x_filter_event (dpyinfo, xev)) 5832 && x_filter_event (dpyinfo, xev))
5833 { 5833 {
5834 UNBLOCK_INPUT; 5834 unblock_input ();
5835 return GDK_FILTER_REMOVE; 5835 return GDK_FILTER_REMOVE;
5836 } 5836 }
5837#endif 5837#endif
@@ -5846,7 +5846,7 @@ event_handler_gdk (GdkXEvent *gxev, GdkEvent *ev, gpointer data)
5846 else 5846 else
5847 current_finish = x_dispatch_event (xev, xev->xany.display); 5847 current_finish = x_dispatch_event (xev, xev->xany.display);
5848 5848
5849 UNBLOCK_INPUT; 5849 unblock_input ();
5850 5850
5851 if (current_finish == X_EVENT_GOTO_OUT || current_finish == X_EVENT_DROP) 5851 if (current_finish == X_EVENT_GOTO_OUT || current_finish == X_EVENT_DROP)
5852 return GDK_FILTER_REMOVE; 5852 return GDK_FILTER_REMOVE;
@@ -7041,10 +7041,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
7041 default: 7041 default:
7042 OTHER: 7042 OTHER:
7043#ifdef USE_X_TOOLKIT 7043#ifdef USE_X_TOOLKIT
7044 BLOCK_INPUT; 7044 block_input ();
7045 if (*finish != X_EVENT_DROP) 7045 if (*finish != X_EVENT_DROP)
7046 XtDispatchEvent (&event); 7046 XtDispatchEvent (&event);
7047 UNBLOCK_INPUT; 7047 unblock_input ();
7048#endif /* USE_X_TOOLKIT */ 7048#endif /* USE_X_TOOLKIT */
7049 break; 7049 break;
7050 } 7050 }
@@ -7122,16 +7122,7 @@ XTread_socket (struct terminal *terminal, struct input_event *hold_quit)
7122 int count = 0; 7122 int count = 0;
7123 int event_found = 0; 7123 int event_found = 0;
7124 7124
7125 if (interrupt_input_blocked) 7125 block_input ();
7126 {
7127 interrupt_input_pending = 1;
7128 pending_signals = 1;
7129 return -1;
7130 }
7131
7132 interrupt_input_pending = 0;
7133 pending_signals = pending_atimers;
7134 BLOCK_INPUT;
7135 7126
7136 /* So people can tell when we have read the available input. */ 7127 /* So people can tell when we have read the available input. */
7137 input_signal_count++; 7128 input_signal_count++;
@@ -7224,7 +7215,7 @@ XTread_socket (struct terminal *terminal, struct input_event *hold_quit)
7224 pending_autoraise_frame = 0; 7215 pending_autoraise_frame = 0;
7225 } 7216 }
7226 7217
7227 UNBLOCK_INPUT; 7218 unblock_input ();
7228 7219
7229 return count; 7220 return count;
7230} 7221}
@@ -7660,7 +7651,7 @@ x_uncatch_errors (void)
7660{ 7651{
7661 struct x_error_message_stack *tmp; 7652 struct x_error_message_stack *tmp;
7662 7653
7663 BLOCK_INPUT; 7654 block_input ();
7664 7655
7665 /* The display may have been closed before this function is called. 7656 /* The display may have been closed before this function is called.
7666 Check if it is still open before calling XSync. */ 7657 Check if it is still open before calling XSync. */
@@ -7670,7 +7661,7 @@ x_uncatch_errors (void)
7670 tmp = x_error_message; 7661 tmp = x_error_message;
7671 x_error_message = x_error_message->prev; 7662 x_error_message = x_error_message->prev;
7672 xfree (tmp); 7663 xfree (tmp);
7673 UNBLOCK_INPUT; 7664 unblock_input ();
7674} 7665}
7675 7666
7676/* If any X protocol errors have arrived since the last call to 7667/* If any X protocol errors have arrived since the last call to
@@ -7733,26 +7724,6 @@ x_trace_wire (void)
7733#endif /* ! 0 */ 7724#endif /* ! 0 */
7734 7725
7735 7726
7736/* Handle SIGPIPE, which can happen when the connection to a server
7737 simply goes away. SIGPIPE is handled by x_connection_signal.
7738 Don't need to do anything, because the write which caused the
7739 SIGPIPE will fail, causing Xlib to invoke the X IO error handler,
7740 which will do the appropriate cleanup for us. */
7741
7742static void
7743x_connection_signal (int signalnum) /* If we don't have an argument, */
7744 /* some compilers complain in signal calls. */
7745{
7746#ifdef USG
7747 /* USG systems forget handlers when they are used;
7748 must reestablish each time */
7749 struct sigaction action;
7750 emacs_sigaction_init (&action, x_connection_signal);
7751 sigaction (signalnum, &action, 0);
7752#endif /* USG */
7753}
7754
7755
7756/************************************************************************ 7727/************************************************************************
7757 Handling X errors 7728 Handling X errors
7758 ************************************************************************/ 7729 ************************************************************************/
@@ -7856,17 +7827,7 @@ For details, see etc/PROBLEMS.\n",
7856 /* NOTREACHED */ 7827 /* NOTREACHED */
7857 } 7828 }
7858 7829
7859 /* Ordinary stack unwind doesn't deal with these. */ 7830 totally_unblock_input ();
7860 {
7861 sigset_t unblocked;
7862 sigemptyset (&unblocked);
7863#ifdef USABLE_SIGIO
7864 sigaddset (&unblocked, SIGIO);
7865#endif
7866 sigaddset (&unblocked, SIGALRM);
7867 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
7868 }
7869 TOTALLY_UNBLOCK_INPUT;
7870 7831
7871 unbind_to (idx, Qnil); 7832 unbind_to (idx, Qnil);
7872 clear_waiting_for_input (); 7833 clear_waiting_for_input ();
@@ -8005,9 +7966,9 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
8005 if (FRAME_XIC (f) 7966 if (FRAME_XIC (f)
8006 && (FRAME_XIC_STYLE (f) & (XIMPreeditPosition | XIMStatusArea))) 7967 && (FRAME_XIC_STYLE (f) & (XIMPreeditPosition | XIMStatusArea)))
8007 { 7968 {
8008 BLOCK_INPUT; 7969 block_input ();
8009 xic_set_xfontset (f, SSDATA (fontset_ascii (fontset))); 7970 xic_set_xfontset (f, SSDATA (fontset_ascii (fontset)));
8010 UNBLOCK_INPUT; 7971 unblock_input ();
8011 } 7972 }
8012#endif 7973#endif
8013 7974
@@ -8033,7 +7994,7 @@ xim_destroy_callback (XIM xim, XPointer client_data, XPointer call_data)
8033 struct x_display_info *dpyinfo = (struct x_display_info *) client_data; 7994 struct x_display_info *dpyinfo = (struct x_display_info *) client_data;
8034 Lisp_Object frame, tail; 7995 Lisp_Object frame, tail;
8035 7996
8036 BLOCK_INPUT; 7997 block_input ();
8037 7998
8038 /* No need to call XDestroyIC.. */ 7999 /* No need to call XDestroyIC.. */
8039 FOR_EACH_FRAME (tail, frame) 8000 FOR_EACH_FRAME (tail, frame)
@@ -8049,7 +8010,7 @@ xim_destroy_callback (XIM xim, XPointer client_data, XPointer call_data)
8049 /* No need to call XCloseIM. */ 8010 /* No need to call XCloseIM. */
8050 dpyinfo->xim = NULL; 8011 dpyinfo->xim = NULL;
8051 XFree (dpyinfo->xim_styles); 8012 XFree (dpyinfo->xim_styles);
8052 UNBLOCK_INPUT; 8013 unblock_input ();
8053} 8014}
8054 8015
8055#endif /* HAVE_X11R6 */ 8016#endif /* HAVE_X11R6 */
@@ -8124,7 +8085,7 @@ xim_instantiate_callback (Display *display, XPointer client_data, XPointer call_
8124 { 8085 {
8125 Lisp_Object tail, frame; 8086 Lisp_Object tail, frame;
8126 8087
8127 BLOCK_INPUT; 8088 block_input ();
8128 FOR_EACH_FRAME (tail, frame) 8089 FOR_EACH_FRAME (tail, frame)
8129 { 8090 {
8130 struct frame *f = XFRAME (frame); 8091 struct frame *f = XFRAME (frame);
@@ -8144,7 +8105,7 @@ xim_instantiate_callback (Display *display, XPointer client_data, XPointer call_
8144 } 8105 }
8145 } 8106 }
8146 8107
8147 UNBLOCK_INPUT; 8108 unblock_input ();
8148 } 8109 }
8149} 8110}
8150 8111
@@ -8291,7 +8252,7 @@ x_set_offset (struct frame *f, register int xoff, register int yoff, int change_
8291 } 8252 }
8292 x_calc_absolute_position (f); 8253 x_calc_absolute_position (f);
8293 8254
8294 BLOCK_INPUT; 8255 block_input ();
8295 x_wm_set_size_hint (f, (long) 0, 0); 8256 x_wm_set_size_hint (f, (long) 0, 0);
8296 8257
8297 modified_left = f->left_pos; 8258 modified_left = f->left_pos;
@@ -8330,7 +8291,7 @@ x_set_offset (struct frame *f, register int xoff, register int yoff, int change_
8330 && FRAME_X_OUTPUT (f)->move_offset_top == 0)))) 8291 && FRAME_X_OUTPUT (f)->move_offset_top == 0))))
8331 x_check_expected_move (f, modified_left, modified_top); 8292 x_check_expected_move (f, modified_left, modified_top);
8332 8293
8333 UNBLOCK_INPUT; 8294 unblock_input ();
8334} 8295}
8335 8296
8336/* Return non-zero if _NET_SUPPORTING_WM_CHECK window exists and _NET_SUPPORTED 8297/* Return non-zero if _NET_SUPPORTING_WM_CHECK window exists and _NET_SUPPORTED
@@ -8353,7 +8314,7 @@ wm_supports (struct frame *f, Atom want_atom)
8353 unsigned char *tmp_data = NULL; 8314 unsigned char *tmp_data = NULL;
8354 Atom target_type = XA_WINDOW; 8315 Atom target_type = XA_WINDOW;
8355 8316
8356 BLOCK_INPUT; 8317 block_input ();
8357 8318
8358 x_catch_errors (dpy); 8319 x_catch_errors (dpy);
8359 rc = XGetWindowProperty (dpy, target_window, 8320 rc = XGetWindowProperty (dpy, target_window,
@@ -8366,7 +8327,7 @@ wm_supports (struct frame *f, Atom want_atom)
8366 { 8327 {
8367 if (tmp_data) XFree (tmp_data); 8328 if (tmp_data) XFree (tmp_data);
8368 x_uncatch_errors (); 8329 x_uncatch_errors ();
8369 UNBLOCK_INPUT; 8330 unblock_input ();
8370 return 0; 8331 return 0;
8371 } 8332 }
8372 8333
@@ -8379,7 +8340,7 @@ wm_supports (struct frame *f, Atom want_atom)
8379 if (x_had_errors_p (dpy)) 8340 if (x_had_errors_p (dpy))
8380 { 8341 {
8381 x_uncatch_errors (); 8342 x_uncatch_errors ();
8382 UNBLOCK_INPUT; 8343 unblock_input ();
8383 return 0; 8344 return 0;
8384 } 8345 }
8385 8346
@@ -8404,7 +8365,7 @@ wm_supports (struct frame *f, Atom want_atom)
8404 { 8365 {
8405 if (tmp_data) XFree (tmp_data); 8366 if (tmp_data) XFree (tmp_data);
8406 x_uncatch_errors (); 8367 x_uncatch_errors ();
8407 UNBLOCK_INPUT; 8368 unblock_input ();
8408 return 0; 8369 return 0;
8409 } 8370 }
8410 8371
@@ -8419,7 +8380,7 @@ wm_supports (struct frame *f, Atom want_atom)
8419 rc = dpyinfo->net_supported_atoms[i] == want_atom; 8380 rc = dpyinfo->net_supported_atoms[i] == want_atom;
8420 8381
8421 x_uncatch_errors (); 8382 x_uncatch_errors ();
8422 UNBLOCK_INPUT; 8383 unblock_input ();
8423 8384
8424 return rc; 8385 return rc;
8425} 8386}
@@ -8478,7 +8439,7 @@ get_current_wm_state (struct frame *f,
8478 *sticky = 0; 8439 *sticky = 0;
8479 *size_state = FULLSCREEN_NONE; 8440 *size_state = FULLSCREEN_NONE;
8480 8441
8481 BLOCK_INPUT; 8442 block_input ();
8482 x_catch_errors (dpy); 8443 x_catch_errors (dpy);
8483 rc = XGetWindowProperty (dpy, window, dpyinfo->Xatom_net_wm_state, 8444 rc = XGetWindowProperty (dpy, window, dpyinfo->Xatom_net_wm_state,
8484 0, max_len, False, target_type, 8445 0, max_len, False, target_type,
@@ -8489,7 +8450,7 @@ get_current_wm_state (struct frame *f,
8489 { 8450 {
8490 if (tmp_data) XFree (tmp_data); 8451 if (tmp_data) XFree (tmp_data);
8491 x_uncatch_errors (); 8452 x_uncatch_errors ();
8492 UNBLOCK_INPUT; 8453 unblock_input ();
8493 return ! f->iconified; 8454 return ! f->iconified;
8494 } 8455 }
8495 8456
@@ -8524,7 +8485,7 @@ get_current_wm_state (struct frame *f,
8524 } 8485 }
8525 8486
8526 if (tmp_data) XFree (tmp_data); 8487 if (tmp_data) XFree (tmp_data);
8527 UNBLOCK_INPUT; 8488 unblock_input ();
8528 return ! is_hidden; 8489 return ! is_hidden;
8529} 8490}
8530 8491
@@ -8604,10 +8565,10 @@ XTfullscreen_hook (FRAME_PTR f)
8604{ 8565{
8605 if (f->async_visible) 8566 if (f->async_visible)
8606 { 8567 {
8607 BLOCK_INPUT; 8568 block_input ();
8608 x_check_fullscreen (f); 8569 x_check_fullscreen (f);
8609 x_sync (f); 8570 x_sync (f);
8610 UNBLOCK_INPUT; 8571 unblock_input ();
8611 } 8572 }
8612} 8573}
8613 8574
@@ -8792,10 +8753,10 @@ x_wait_for_event (struct frame *f, int eventtype)
8792 8753
8793 while (pending_event_wait.eventtype) 8754 while (pending_event_wait.eventtype)
8794 { 8755 {
8795 interrupt_input_pending = 1; 8756 pending_signals = 1;
8796 TOTALLY_UNBLOCK_INPUT; 8757 totally_unblock_input ();
8797 /* XTread_socket is called after unblock. */ 8758 /* XTread_socket is called after unblock. */
8798 BLOCK_INPUT; 8759 block_input ();
8799 interrupt_input_blocked = level; 8760 interrupt_input_blocked = level;
8800 8761
8801 FD_ZERO (&fds); 8762 FD_ZERO (&fds);
@@ -8886,7 +8847,7 @@ x_set_window_size_1 (struct frame *f, int change_gravity, int cols, int rows)
8886void 8847void
8887x_set_window_size (struct frame *f, int change_gravity, int cols, int rows) 8848x_set_window_size (struct frame *f, int change_gravity, int cols, int rows)
8888{ 8849{
8889 BLOCK_INPUT; 8850 block_input ();
8890 8851
8891 if (NILP (tip_frame) || XFRAME (tip_frame) != f) 8852 if (NILP (tip_frame) || XFRAME (tip_frame) != f)
8892 { 8853 {
@@ -8934,7 +8895,7 @@ x_set_window_size (struct frame *f, int change_gravity, int cols, int rows)
8934 so don't try--just let the highlighting be done afresh with new size. */ 8895 so don't try--just let the highlighting be done afresh with new size. */
8935 cancel_mouse_face (f); 8896 cancel_mouse_face (f);
8936 8897
8937 UNBLOCK_INPUT; 8898 unblock_input ();
8938} 8899}
8939 8900
8940/* Mouse warping. */ 8901/* Mouse warping. */
@@ -8953,11 +8914,11 @@ x_set_mouse_position (struct frame *f, int x, int y)
8953 if (pix_y < 0) pix_y = 0; 8914 if (pix_y < 0) pix_y = 0;
8954 if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f); 8915 if (pix_y > FRAME_PIXEL_HEIGHT (f)) pix_y = FRAME_PIXEL_HEIGHT (f);
8955 8916
8956 BLOCK_INPUT; 8917 block_input ();
8957 8918
8958 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f), 8919 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f),
8959 0, 0, 0, 0, pix_x, pix_y); 8920 0, 0, 0, 0, pix_x, pix_y);
8960 UNBLOCK_INPUT; 8921 unblock_input ();
8961} 8922}
8962 8923
8963/* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F. */ 8924/* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F. */
@@ -8965,11 +8926,11 @@ x_set_mouse_position (struct frame *f, int x, int y)
8965void 8926void
8966x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y) 8927x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
8967{ 8928{
8968 BLOCK_INPUT; 8929 block_input ();
8969 8930
8970 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f), 8931 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f),
8971 0, 0, 0, 0, pix_x, pix_y); 8932 0, 0, 0, 0, pix_x, pix_y);
8972 UNBLOCK_INPUT; 8933 unblock_input ();
8973} 8934}
8974 8935
8975/* Raise frame F. */ 8936/* Raise frame F. */
@@ -8977,12 +8938,12 @@ x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
8977void 8938void
8978x_raise_frame (struct frame *f) 8939x_raise_frame (struct frame *f)
8979{ 8940{
8980 BLOCK_INPUT; 8941 block_input ();
8981 if (f->async_visible) 8942 if (f->async_visible)
8982 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); 8943 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
8983 8944
8984 XFlush (FRAME_X_DISPLAY (f)); 8945 XFlush (FRAME_X_DISPLAY (f));
8985 UNBLOCK_INPUT; 8946 unblock_input ();
8986} 8947}
8987 8948
8988/* Lower frame F. */ 8949/* Lower frame F. */
@@ -8992,10 +8953,10 @@ x_lower_frame (struct frame *f)
8992{ 8953{
8993 if (f->async_visible) 8954 if (f->async_visible)
8994 { 8955 {
8995 BLOCK_INPUT; 8956 block_input ();
8996 XLowerWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); 8957 XLowerWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
8997 XFlush (FRAME_X_DISPLAY (f)); 8958 XFlush (FRAME_X_DISPLAY (f));
8998 UNBLOCK_INPUT; 8959 unblock_input ();
8999 } 8960 }
9000} 8961}
9001 8962
@@ -9104,7 +9065,7 @@ x_make_frame_visible (struct frame *f)
9104 9065
9105 retry: 9066 retry:
9106 9067
9107 BLOCK_INPUT; 9068 block_input ();
9108 9069
9109 type = x_icon_type (f); 9070 type = x_icon_type (f);
9110 if (!NILP (type)) 9071 if (!NILP (type))
@@ -9163,7 +9124,7 @@ x_make_frame_visible (struct frame *f)
9163 original_top = f->top_pos; 9124 original_top = f->top_pos;
9164 9125
9165 /* This must come after we set COUNT. */ 9126 /* This must come after we set COUNT. */
9166 UNBLOCK_INPUT; 9127 unblock_input ();
9167 9128
9168 /* We unblock here so that arriving X events are processed. */ 9129 /* We unblock here so that arriving X events are processed. */
9169 9130
@@ -9186,7 +9147,7 @@ x_make_frame_visible (struct frame *f)
9186 int x, y; 9147 int x, y;
9187 unsigned int width, height, border, depth; 9148 unsigned int width, height, border, depth;
9188 9149
9189 BLOCK_INPUT; 9150 block_input ();
9190 9151
9191 /* On some window managers (such as FVWM) moving an existing 9152 /* On some window managers (such as FVWM) moving an existing
9192 window, even to the same place, causes the window manager 9153 window, even to the same place, causes the window manager
@@ -9202,7 +9163,7 @@ x_make_frame_visible (struct frame *f)
9202 XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), 9163 XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
9203 original_left, original_top); 9164 original_left, original_top);
9204 9165
9205 UNBLOCK_INPUT; 9166 unblock_input ();
9206 } 9167 }
9207 9168
9208 XSETFRAME (frame, f); 9169 XSETFRAME (frame, f);
@@ -9269,7 +9230,7 @@ x_make_frame_invisible (struct frame *f)
9269 if (FRAME_X_DISPLAY_INFO (f)->x_highlight_frame == f) 9230 if (FRAME_X_DISPLAY_INFO (f)->x_highlight_frame == f)
9270 FRAME_X_DISPLAY_INFO (f)->x_highlight_frame = 0; 9231 FRAME_X_DISPLAY_INFO (f)->x_highlight_frame = 0;
9271 9232
9272 BLOCK_INPUT; 9233 block_input ();
9273 9234
9274 /* Before unmapping the window, update the WM_SIZE_HINTS property to claim 9235 /* Before unmapping the window, update the WM_SIZE_HINTS property to claim
9275 that the current position of the window is user-specified, rather than 9236 that the current position of the window is user-specified, rather than
@@ -9292,7 +9253,7 @@ x_make_frame_invisible (struct frame *f)
9292 if (! XWithdrawWindow (FRAME_X_DISPLAY (f), window, 9253 if (! XWithdrawWindow (FRAME_X_DISPLAY (f), window,
9293 DefaultScreen (FRAME_X_DISPLAY (f)))) 9254 DefaultScreen (FRAME_X_DISPLAY (f))))
9294 { 9255 {
9295 UNBLOCK_INPUT_RESIGNAL; 9256 unblock_input ();
9296 error ("Can't notify window manager of window withdrawal"); 9257 error ("Can't notify window manager of window withdrawal");
9297 } 9258 }
9298 } 9259 }
@@ -9309,7 +9270,7 @@ x_make_frame_invisible (struct frame *f)
9309 9270
9310 x_sync (f); 9271 x_sync (f);
9311 9272
9312 UNBLOCK_INPUT; 9273 unblock_input ();
9313} 9274}
9314 9275
9315/* Change window state from mapped to iconified. */ 9276/* Change window state from mapped to iconified. */
@@ -9329,7 +9290,7 @@ x_iconify_frame (struct frame *f)
9329 if (f->async_iconified) 9290 if (f->async_iconified)
9330 return; 9291 return;
9331 9292
9332 BLOCK_INPUT; 9293 block_input ();
9333 9294
9334 FRAME_SAMPLE_VISIBILITY (f); 9295 FRAME_SAMPLE_VISIBILITY (f);
9335 9296
@@ -9348,7 +9309,7 @@ x_iconify_frame (struct frame *f)
9348 f->visible = 1; 9309 f->visible = 1;
9349 f->async_iconified = 1; 9310 f->async_iconified = 1;
9350 f->async_visible = 0; 9311 f->async_visible = 0;
9351 UNBLOCK_INPUT; 9312 unblock_input ();
9352 return; 9313 return;
9353 } 9314 }
9354#endif 9315#endif
@@ -9368,14 +9329,14 @@ x_iconify_frame (struct frame *f)
9368 f->visible = 1; 9329 f->visible = 1;
9369 f->async_iconified = 1; 9330 f->async_iconified = 1;
9370 f->async_visible = 0; 9331 f->async_visible = 0;
9371 UNBLOCK_INPUT; 9332 unblock_input ();
9372 return; 9333 return;
9373 } 9334 }
9374 9335
9375 result = XIconifyWindow (FRAME_X_DISPLAY (f), 9336 result = XIconifyWindow (FRAME_X_DISPLAY (f),
9376 XtWindow (f->output_data.x->widget), 9337 XtWindow (f->output_data.x->widget),
9377 DefaultScreen (FRAME_X_DISPLAY (f))); 9338 DefaultScreen (FRAME_X_DISPLAY (f)));
9378 UNBLOCK_INPUT; 9339 unblock_input ();
9379 9340
9380 if (!result) 9341 if (!result)
9381 error ("Can't notify window manager of iconification"); 9342 error ("Can't notify window manager of iconification");
@@ -9384,9 +9345,9 @@ x_iconify_frame (struct frame *f)
9384 f->async_visible = 0; 9345 f->async_visible = 0;
9385 9346
9386 9347
9387 BLOCK_INPUT; 9348 block_input ();
9388 XFlush (FRAME_X_DISPLAY (f)); 9349 XFlush (FRAME_X_DISPLAY (f));
9389 UNBLOCK_INPUT; 9350 unblock_input ();
9390#else /* not USE_X_TOOLKIT */ 9351#else /* not USE_X_TOOLKIT */
9391 9352
9392 /* Make sure the X server knows where the window should be positioned, 9353 /* Make sure the X server knows where the window should be positioned,
@@ -9416,7 +9377,7 @@ x_iconify_frame (struct frame *f)
9416 SubstructureRedirectMask | SubstructureNotifyMask, 9377 SubstructureRedirectMask | SubstructureNotifyMask,
9417 &msg)) 9378 &msg))
9418 { 9379 {
9419 UNBLOCK_INPUT_RESIGNAL; 9380 unblock_input ();
9420 error ("Can't notify window manager of iconification"); 9381 error ("Can't notify window manager of iconification");
9421 } 9382 }
9422 } 9383 }
@@ -9435,7 +9396,7 @@ x_iconify_frame (struct frame *f)
9435 f->async_visible = 0; 9396 f->async_visible = 0;
9436 9397
9437 XFlush (FRAME_X_DISPLAY (f)); 9398 XFlush (FRAME_X_DISPLAY (f));
9438 UNBLOCK_INPUT; 9399 unblock_input ();
9439#endif /* not USE_X_TOOLKIT */ 9400#endif /* not USE_X_TOOLKIT */
9440} 9401}
9441 9402
@@ -9452,7 +9413,7 @@ x_free_frame_resources (struct frame *f)
9452 struct scroll_bar *b; 9413 struct scroll_bar *b;
9453#endif 9414#endif
9454 9415
9455 BLOCK_INPUT; 9416 block_input ();
9456 9417
9457 /* If a display connection is dead, don't try sending more 9418 /* If a display connection is dead, don't try sending more
9458 commands to the X server. */ 9419 commands to the X server. */
@@ -9555,7 +9516,7 @@ x_free_frame_resources (struct frame *f)
9555 hlinfo->mouse_face_mouse_frame = 0; 9516 hlinfo->mouse_face_mouse_frame = 0;
9556 } 9517 }
9557 9518
9558 UNBLOCK_INPUT; 9519 unblock_input ();
9559} 9520}
9560 9521
9561 9522
@@ -9935,7 +9896,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
9935 Mouse_HLInfo *hlinfo; 9896 Mouse_HLInfo *hlinfo;
9936 ptrdiff_t lim; 9897 ptrdiff_t lim;
9937 9898
9938 BLOCK_INPUT; 9899 block_input ();
9939 9900
9940 if (!x_initialized) 9901 if (!x_initialized)
9941 { 9902 {
@@ -10067,7 +10028,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10067 /* Detect failure. */ 10028 /* Detect failure. */
10068 if (dpy == 0) 10029 if (dpy == 0)
10069 { 10030 {
10070 UNBLOCK_INPUT; 10031 unblock_input ();
10071 return 0; 10032 return 0;
10072 } 10033 }
10073 10034
@@ -10114,12 +10075,12 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10114 10075
10115 /* Temporarily hide the partially initialized terminal. */ 10076 /* Temporarily hide the partially initialized terminal. */
10116 terminal_list = terminal->next_terminal; 10077 terminal_list = terminal->next_terminal;
10117 UNBLOCK_INPUT; 10078 unblock_input ();
10118 kset_system_key_alist 10079 kset_system_key_alist
10119 (terminal->kboard, 10080 (terminal->kboard,
10120 call1 (Qvendor_specific_keysyms, 10081 call1 (Qvendor_specific_keysyms,
10121 vendor ? build_string (vendor) : empty_unibyte_string)); 10082 vendor ? build_string (vendor) : empty_unibyte_string));
10122 BLOCK_INPUT; 10083 block_input ();
10123 terminal->next_terminal = terminal_list; 10084 terminal->next_terminal = terminal_list;
10124 terminal_list = terminal; 10085 terminal_list = terminal;
10125 UNGCPRO; 10086 UNGCPRO;
@@ -10468,7 +10429,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10468 x_session_initialize (dpyinfo); 10429 x_session_initialize (dpyinfo);
10469#endif 10430#endif
10470 10431
10471 UNBLOCK_INPUT; 10432 unblock_input ();
10472 10433
10473 return dpyinfo; 10434 return dpyinfo;
10474} 10435}
@@ -10548,7 +10509,7 @@ x_delete_display (struct x_display_info *dpyinfo)
10548static void 10509static void
10549x_process_timeouts (struct atimer *timer) 10510x_process_timeouts (struct atimer *timer)
10550{ 10511{
10551 BLOCK_INPUT; 10512 block_input ();
10552 x_timeout_atimer_activated_flag = 0; 10513 x_timeout_atimer_activated_flag = 0;
10553 if (toolkit_scroll_bar_interaction || popup_activated ()) 10514 if (toolkit_scroll_bar_interaction || popup_activated ())
10554 { 10515 {
@@ -10557,7 +10518,7 @@ x_process_timeouts (struct atimer *timer)
10557 /* Reactivate the atimer for next time. */ 10518 /* Reactivate the atimer for next time. */
10558 x_activate_timeout_atimer (); 10519 x_activate_timeout_atimer ();
10559 } 10520 }
10560 UNBLOCK_INPUT; 10521 unblock_input ();
10561} 10522}
10562 10523
10563/* Install an asynchronous timer that processes Xt timeout events 10524/* Install an asynchronous timer that processes Xt timeout events
@@ -10571,14 +10532,14 @@ x_process_timeouts (struct atimer *timer)
10571void 10532void
10572x_activate_timeout_atimer (void) 10533x_activate_timeout_atimer (void)
10573{ 10534{
10574 BLOCK_INPUT; 10535 block_input ();
10575 if (!x_timeout_atimer_activated_flag) 10536 if (!x_timeout_atimer_activated_flag)
10576 { 10537 {
10577 EMACS_TIME interval = make_emacs_time (0, 100 * 1000 * 1000); 10538 EMACS_TIME interval = make_emacs_time (0, 100 * 1000 * 1000);
10578 start_atimer (ATIMER_RELATIVE, interval, x_process_timeouts, 0); 10539 start_atimer (ATIMER_RELATIVE, interval, x_process_timeouts, 0);
10579 x_timeout_atimer_activated_flag = 1; 10540 x_timeout_atimer_activated_flag = 1;
10580 } 10541 }
10581 UNBLOCK_INPUT; 10542 unblock_input ();
10582} 10543}
10583 10544
10584#endif /* USE_X_TOOLKIT */ 10545#endif /* USE_X_TOOLKIT */
@@ -10631,7 +10592,7 @@ x_delete_terminal (struct terminal *terminal)
10631 if (!terminal->name) 10592 if (!terminal->name)
10632 return; 10593 return;
10633 10594
10634 BLOCK_INPUT; 10595 block_input ();
10635#ifdef HAVE_X_I18N 10596#ifdef HAVE_X_I18N
10636 /* We must close our connection to the XIM server before closing the 10597 /* We must close our connection to the XIM server before closing the
10637 X display. */ 10598 X display. */
@@ -10686,7 +10647,7 @@ x_delete_terminal (struct terminal *terminal)
10686 /* Mark as dead. */ 10647 /* Mark as dead. */
10687 dpyinfo->display = NULL; 10648 dpyinfo->display = NULL;
10688 x_delete_display (dpyinfo); 10649 x_delete_display (dpyinfo);
10689 UNBLOCK_INPUT; 10650 unblock_input ();
10690} 10651}
10691 10652
10692/* Create a struct terminal, initialize it with the X11 specific 10653/* Create a struct terminal, initialize it with the X11 specific
@@ -10743,8 +10704,6 @@ x_create_terminal (struct x_display_info *dpyinfo)
10743void 10704void
10744x_initialize (void) 10705x_initialize (void)
10745{ 10706{
10746 struct sigaction action;
10747
10748 baud_rate = 19200; 10707 baud_rate = 19200;
10749 10708
10750 x_noop_count = 0; 10709 x_noop_count = 0;
@@ -10790,9 +10749,6 @@ x_initialize (void)
10790 original error handler. */ 10749 original error handler. */
10791 XSetErrorHandler (x_error_handler); 10750 XSetErrorHandler (x_error_handler);
10792 XSetIOErrorHandler (x_io_error_quitter); 10751 XSetIOErrorHandler (x_io_error_quitter);
10793
10794 emacs_sigaction_init (&action, x_connection_signal);
10795 sigaction (SIGPIPE, &action, 0);
10796} 10752}
10797 10753
10798 10754