aboutsummaryrefslogtreecommitdiffstats
path: root/src/xselect.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/xselect.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/xselect.c')
-rw-r--r--src/xselect.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/src/xselect.c b/src/xselect.c
index ab199e0b9b9..de9386bd7d9 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -247,9 +247,9 @@ symbol_to_x_atom (struct x_display_info *dpyinfo, Lisp_Object sym)
247 if (!SYMBOLP (sym)) emacs_abort (); 247 if (!SYMBOLP (sym)) emacs_abort ();
248 248
249 TRACE1 (" XInternAtom %s", SSDATA (SYMBOL_NAME (sym))); 249 TRACE1 (" XInternAtom %s", SSDATA (SYMBOL_NAME (sym)));
250 BLOCK_INPUT; 250 block_input ();
251 val = XInternAtom (dpyinfo->display, SSDATA (SYMBOL_NAME (sym)), False); 251 val = XInternAtom (dpyinfo->display, SSDATA (SYMBOL_NAME (sym)), False);
252 UNBLOCK_INPUT; 252 unblock_input ();
253 return val; 253 return val;
254} 254}
255 255
@@ -307,16 +307,16 @@ x_atom_to_symbol (Display *dpy, Atom atom)
307 if (atom == dpyinfo->Xatom_NULL) 307 if (atom == dpyinfo->Xatom_NULL)
308 return QNULL; 308 return QNULL;
309 309
310 BLOCK_INPUT; 310 block_input ();
311 str = XGetAtomName (dpy, atom); 311 str = XGetAtomName (dpy, atom);
312 UNBLOCK_INPUT; 312 unblock_input ();
313 TRACE1 ("XGetAtomName --> %s", str); 313 TRACE1 ("XGetAtomName --> %s", str);
314 if (! str) return Qnil; 314 if (! str) return Qnil;
315 val = intern (str); 315 val = intern (str);
316 BLOCK_INPUT; 316 block_input ();
317 /* This was allocated by Xlib, so use XFree. */ 317 /* This was allocated by Xlib, so use XFree. */
318 XFree (str); 318 XFree (str);
319 UNBLOCK_INPUT; 319 unblock_input ();
320 return val; 320 return val;
321} 321}
322 322
@@ -336,12 +336,12 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value,
336 Time timestamp = last_event_timestamp; 336 Time timestamp = last_event_timestamp;
337 Atom selection_atom = symbol_to_x_atom (dpyinfo, selection_name); 337 Atom selection_atom = symbol_to_x_atom (dpyinfo, selection_name);
338 338
339 BLOCK_INPUT; 339 block_input ();
340 x_catch_errors (display); 340 x_catch_errors (display);
341 XSetSelectionOwner (display, selection_atom, selecting_window, timestamp); 341 XSetSelectionOwner (display, selection_atom, selecting_window, timestamp);
342 x_check_errors (display, "Can't set selection: %s"); 342 x_check_errors (display, "Can't set selection: %s");
343 x_uncatch_errors (); 343 x_uncatch_errors ();
344 UNBLOCK_INPUT; 344 unblock_input ();
345 345
346 /* Now update the local cache */ 346 /* Now update the local cache */
347 { 347 {
@@ -469,12 +469,12 @@ x_decline_selection_request (struct input_event *event)
469 469
470 /* The reason for the error may be that the receiver has 470 /* The reason for the error may be that the receiver has
471 died in the meantime. Handle that case. */ 471 died in the meantime. Handle that case. */
472 BLOCK_INPUT; 472 block_input ();
473 x_catch_errors (reply->display); 473 x_catch_errors (reply->display);
474 XSendEvent (reply->display, reply->requestor, False, 0L, &reply_base); 474 XSendEvent (reply->display, reply->requestor, False, 0L, &reply_base);
475 XFlush (reply->display); 475 XFlush (reply->display);
476 x_uncatch_errors (); 476 x_uncatch_errors ();
477 UNBLOCK_INPUT; 477 unblock_input ();
478} 478}
479 479
480/* This is the selection request currently being processed. 480/* This is the selection request currently being processed.
@@ -536,9 +536,9 @@ x_selection_request_lisp_error (Lisp_Object ignore)
536static Lisp_Object 536static Lisp_Object
537x_catch_errors_unwind (Lisp_Object dummy) 537x_catch_errors_unwind (Lisp_Object dummy)
538{ 538{
539 BLOCK_INPUT; 539 block_input ();
540 x_uncatch_errors (); 540 x_uncatch_errors ();
541 UNBLOCK_INPUT; 541 unblock_input ();
542 return Qnil; 542 return Qnil;
543} 543}
544 544
@@ -610,7 +610,7 @@ x_reply_selection_request (struct input_event *event,
610 if (reply->property == None) 610 if (reply->property == None)
611 reply->property = reply->target; 611 reply->property = reply->target;
612 612
613 BLOCK_INPUT; 613 block_input ();
614 /* The protected block contains wait_for_property_change, which can 614 /* The protected block contains wait_for_property_change, which can
615 run random lisp code (process handlers) or signal. Therefore, we 615 run random lisp code (process handlers) or signal. Therefore, we
616 put the x_uncatch_errors call in an unwind. */ 616 put the x_uncatch_errors call in an unwind. */
@@ -682,7 +682,7 @@ x_reply_selection_request (struct input_event *event,
682 { 682 {
683 int format_bytes = cs->format / 8; 683 int format_bytes = cs->format / 8;
684 int had_errors = x_had_errors_p (display); 684 int had_errors = x_had_errors_p (display);
685 UNBLOCK_INPUT; 685 unblock_input ();
686 686
687 bytes_remaining = cs->size; 687 bytes_remaining = cs->size;
688 bytes_remaining *= format_bytes; 688 bytes_remaining *= format_bytes;
@@ -703,7 +703,7 @@ x_reply_selection_request (struct input_event *event,
703 int i = ((bytes_remaining < max_bytes) 703 int i = ((bytes_remaining < max_bytes)
704 ? bytes_remaining 704 ? bytes_remaining
705 : max_bytes) / format_bytes; 705 : max_bytes) / format_bytes;
706 BLOCK_INPUT; 706 block_input ();
707 707
708 cs->wait_object 708 cs->wait_object
709 = expect_property_change (display, window, cs->property, 709 = expect_property_change (display, window, cs->property,
@@ -722,7 +722,7 @@ x_reply_selection_request (struct input_event *event,
722 : format_bytes); 722 : format_bytes);
723 XFlush (display); 723 XFlush (display);
724 had_errors = x_had_errors_p (display); 724 had_errors = x_had_errors_p (display);
725 UNBLOCK_INPUT; 725 unblock_input ();
726 726
727 if (had_errors) break; 727 if (had_errors) break;
728 728
@@ -735,7 +735,7 @@ x_reply_selection_request (struct input_event *event,
735 735
736 /* Now write a zero-length chunk to the property to tell the 736 /* Now write a zero-length chunk to the property to tell the
737 requestor that we're done. */ 737 requestor that we're done. */
738 BLOCK_INPUT; 738 block_input ();
739 if (! waiting_for_other_props_on_window (display, window)) 739 if (! waiting_for_other_props_on_window (display, window))
740 XSelectInput (display, window, 0L); 740 XSelectInput (display, window, 0L);
741 741
@@ -757,15 +757,15 @@ x_reply_selection_request (struct input_event *event,
757 /* 2004-09-10: XSync and UNBLOCK so that possible protocol errors are 757 /* 2004-09-10: XSync and UNBLOCK so that possible protocol errors are
758 delivered before uncatch errors. */ 758 delivered before uncatch errors. */
759 XSync (display, False); 759 XSync (display, False);
760 UNBLOCK_INPUT; 760 unblock_input ();
761 761
762 /* GTK queues events in addition to the queue in Xlib. So we 762 /* GTK queues events in addition to the queue in Xlib. So we
763 UNBLOCK to enter the event loop and get possible errors delivered, 763 UNBLOCK to enter the event loop and get possible errors delivered,
764 and then BLOCK again because x_uncatch_errors requires it. */ 764 and then BLOCK again because x_uncatch_errors requires it. */
765 BLOCK_INPUT; 765 block_input ();
766 /* This calls x_uncatch_errors. */ 766 /* This calls x_uncatch_errors. */
767 unbind_to (count, Qnil); 767 unbind_to (count, Qnil);
768 UNBLOCK_INPUT; 768 unblock_input ();
769} 769}
770 770
771/* Handle a SelectionRequest event EVENT. 771/* Handle a SelectionRequest event EVENT.
@@ -1232,7 +1232,7 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
1232 if (! NILP (time_stamp)) 1232 if (! NILP (time_stamp))
1233 CONS_TO_INTEGER (time_stamp, Time, requestor_time); 1233 CONS_TO_INTEGER (time_stamp, Time, requestor_time);
1234 1234
1235 BLOCK_INPUT; 1235 block_input ();
1236 TRACE2 ("Get selection %s, type %s", 1236 TRACE2 ("Get selection %s, type %s",
1237 XGetAtomName (display, type_atom), 1237 XGetAtomName (display, type_atom),
1238 XGetAtomName (display, target_property)); 1238 XGetAtomName (display, target_property));
@@ -1257,7 +1257,7 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
1257 record_unwind_protect (queue_selection_requests_unwind, Qnil); 1257 record_unwind_protect (queue_selection_requests_unwind, Qnil);
1258#endif 1258#endif
1259 1259
1260 UNBLOCK_INPUT; 1260 unblock_input ();
1261 1261
1262 /* This allows quits. Also, don't wait forever. */ 1262 /* This allows quits. Also, don't wait forever. */
1263 timeout = max (0, x_selection_timeout); 1263 timeout = max (0, x_selection_timeout);
@@ -1309,7 +1309,7 @@ x_get_window_property (Display *display, Window window, Atom property,
1309 ? min (PTRDIFF_MAX, SIZE_MAX) - 1 1309 ? min (PTRDIFF_MAX, SIZE_MAX) - 1
1310 : LONG_MAX * x_long_size); 1310 : LONG_MAX * x_long_size);
1311 1311
1312 BLOCK_INPUT; 1312 block_input ();
1313 1313
1314 /* First probe the thing to find out how big it is. */ 1314 /* First probe the thing to find out how big it is. */
1315 result = XGetWindowProperty (display, window, property, 1315 result = XGetWindowProperty (display, window, property,
@@ -1410,19 +1410,19 @@ x_get_window_property (Display *display, Window window, Atom property,
1410 data[offset] = '\0'; 1410 data[offset] = '\0';
1411 1411
1412 done: 1412 done:
1413 UNBLOCK_INPUT; 1413 unblock_input ();
1414 *data_ret = data; 1414 *data_ret = data;
1415 *bytes_ret = offset; 1415 *bytes_ret = offset;
1416 return; 1416 return;
1417 1417
1418 size_overflow: 1418 size_overflow:
1419 free (data); 1419 free (data);
1420 UNBLOCK_INPUT; 1420 unblock_input ();
1421 memory_full (SIZE_MAX); 1421 memory_full (SIZE_MAX);
1422 1422
1423 memory_exhausted: 1423 memory_exhausted:
1424 free (data); 1424 free (data);
1425 UNBLOCK_INPUT; 1425 unblock_input ();
1426 memory_full (total_size + 1); 1426 memory_full (total_size + 1);
1427} 1427}
1428 1428
@@ -1454,7 +1454,7 @@ receive_incremental_selection (Display *display, Window window, Atom property,
1454 that property, then reading the property, then deleting it to ack. 1454 that property, then reading the property, then deleting it to ack.
1455 We are done when the sender places a property of length 0. 1455 We are done when the sender places a property of length 0.
1456 */ 1456 */
1457 BLOCK_INPUT; 1457 block_input ();
1458 XSelectInput (display, window, STANDARD_EVENT_SET | PropertyChangeMask); 1458 XSelectInput (display, window, STANDARD_EVENT_SET | PropertyChangeMask);
1459 TRACE1 (" Delete property %s", 1459 TRACE1 (" Delete property %s",
1460 SDATA (SYMBOL_NAME (x_atom_to_symbol (display, property)))); 1460 SDATA (SYMBOL_NAME (x_atom_to_symbol (display, property))));
@@ -1464,7 +1464,7 @@ receive_incremental_selection (Display *display, Window window, Atom property,
1464 wait_object = expect_property_change (display, window, property, 1464 wait_object = expect_property_change (display, window, property,
1465 PropertyNewValue); 1465 PropertyNewValue);
1466 XFlush (display); 1466 XFlush (display);
1467 UNBLOCK_INPUT; 1467 unblock_input ();
1468 1468
1469 while (1) 1469 while (1)
1470 { 1470 {
@@ -1496,14 +1496,14 @@ receive_incremental_selection (Display *display, Window window, Atom property,
1496 break; 1496 break;
1497 } 1497 }
1498 1498
1499 BLOCK_INPUT; 1499 block_input ();
1500 TRACE1 (" ACK by deleting property %s", 1500 TRACE1 (" ACK by deleting property %s",
1501 XGetAtomName (display, property)); 1501 XGetAtomName (display, property));
1502 XDeleteProperty (display, window, property); 1502 XDeleteProperty (display, window, property);
1503 wait_object = expect_property_change (display, window, property, 1503 wait_object = expect_property_change (display, window, property,
1504 PropertyNewValue); 1504 PropertyNewValue);
1505 XFlush (display); 1505 XFlush (display);
1506 UNBLOCK_INPUT; 1506 unblock_input ();
1507 1507
1508 if (*size_bytes_ret - offset < tmp_size_bytes) 1508 if (*size_bytes_ret - offset < tmp_size_bytes)
1509 *data_ret = xpalloc (*data_ret, size_bytes_ret, 1509 *data_ret = xpalloc (*data_ret, size_bytes_ret,
@@ -1545,10 +1545,10 @@ x_get_window_property_as_lisp_data (Display *display, Window window,
1545 if (! data) 1545 if (! data)
1546 { 1546 {
1547 int there_is_a_selection_owner; 1547 int there_is_a_selection_owner;
1548 BLOCK_INPUT; 1548 block_input ();
1549 there_is_a_selection_owner 1549 there_is_a_selection_owner
1550 = XGetSelectionOwner (display, selection_atom); 1550 = XGetSelectionOwner (display, selection_atom);
1551 UNBLOCK_INPUT; 1551 unblock_input ();
1552 if (there_is_a_selection_owner) 1552 if (there_is_a_selection_owner)
1553 signal_error ("Selection owner couldn't convert", 1553 signal_error ("Selection owner couldn't convert",
1554 actual_type 1554 actual_type
@@ -1565,22 +1565,22 @@ x_get_window_property_as_lisp_data (Display *display, Window window,
1565 /* That wasn't really the data, just the beginning. */ 1565 /* That wasn't really the data, just the beginning. */
1566 1566
1567 unsigned int min_size_bytes = * ((unsigned int *) data); 1567 unsigned int min_size_bytes = * ((unsigned int *) data);
1568 BLOCK_INPUT; 1568 block_input ();
1569 /* Use xfree, not XFree, because x_get_window_property 1569 /* Use xfree, not XFree, because x_get_window_property
1570 calls xmalloc itself. */ 1570 calls xmalloc itself. */
1571 xfree (data); 1571 xfree (data);
1572 UNBLOCK_INPUT; 1572 unblock_input ();
1573 receive_incremental_selection (display, window, property, target_type, 1573 receive_incremental_selection (display, window, property, target_type,
1574 min_size_bytes, &data, &bytes, 1574 min_size_bytes, &data, &bytes,
1575 &actual_type, &actual_format, 1575 &actual_type, &actual_format,
1576 &actual_size); 1576 &actual_size);
1577 } 1577 }
1578 1578
1579 BLOCK_INPUT; 1579 block_input ();
1580 TRACE1 (" Delete property %s", XGetAtomName (display, property)); 1580 TRACE1 (" Delete property %s", XGetAtomName (display, property));
1581 XDeleteProperty (display, window, property); 1581 XDeleteProperty (display, window, property);
1582 XFlush (display); 1582 XFlush (display);
1583 UNBLOCK_INPUT; 1583 unblock_input ();
1584 1584
1585 /* It's been read. Now convert it to a lisp object in some semi-rational 1585 /* It's been read. Now convert it to a lisp object in some semi-rational
1586 manner. */ 1586 manner. */
@@ -2096,13 +2096,13 @@ On MS-DOS, all this does is return non-nil if we own the selection. */)
2096 2096
2097 selection_atom = symbol_to_x_atom (dpyinfo, selection); 2097 selection_atom = symbol_to_x_atom (dpyinfo, selection);
2098 2098
2099 BLOCK_INPUT; 2099 block_input ();
2100 if (NILP (time_object)) 2100 if (NILP (time_object))
2101 timestamp = last_event_timestamp; 2101 timestamp = last_event_timestamp;
2102 else 2102 else
2103 CONS_TO_INTEGER (time_object, Time, timestamp); 2103 CONS_TO_INTEGER (time_object, Time, timestamp);
2104 XSetSelectionOwner (dpyinfo->display, selection_atom, None, timestamp); 2104 XSetSelectionOwner (dpyinfo->display, selection_atom, None, timestamp);
2105 UNBLOCK_INPUT; 2105 unblock_input ();
2106 2106
2107 /* It doesn't seem to be guaranteed that a SelectionClear event will be 2107 /* It doesn't seem to be guaranteed that a SelectionClear event will be
2108 generated for a window which owns the selection when that window sets 2108 generated for a window which owns the selection when that window sets
@@ -2179,9 +2179,9 @@ On Nextstep, TERMINAL is unused. */)
2179 2179
2180 atom = symbol_to_x_atom (dpyinfo, selection); 2180 atom = symbol_to_x_atom (dpyinfo, selection);
2181 if (atom == 0) return Qnil; 2181 if (atom == 0) return Qnil;
2182 BLOCK_INPUT; 2182 block_input ();
2183 owner = XGetSelectionOwner (dpyinfo->display, atom); 2183 owner = XGetSelectionOwner (dpyinfo->display, atom);
2184 UNBLOCK_INPUT; 2184 unblock_input ();
2185 return (owner ? Qt : Qnil); 2185 return (owner ? Qt : Qnil);
2186} 2186}
2187 2187
@@ -2353,9 +2353,9 @@ x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format)
2353 val = cons_to_signed (o, LONG_MIN, LONG_MAX); 2353 val = cons_to_signed (o, LONG_MIN, LONG_MAX);
2354 else if (STRINGP (o)) 2354 else if (STRINGP (o))
2355 { 2355 {
2356 BLOCK_INPUT; 2356 block_input ();
2357 val = (long) XInternAtom (dpy, SSDATA (o), False); 2357 val = (long) XInternAtom (dpy, SSDATA (o), False);
2358 UNBLOCK_INPUT; 2358 unblock_input ();
2359 } 2359 }
2360 else 2360 else
2361 error ("Wrong type, must be string, number or cons"); 2361 error ("Wrong type, must be string, number or cons");
@@ -2413,7 +2413,7 @@ mouse_position_for_drop (FRAME_PTR f, int *x, int *y)
2413 Window root, dummy_window; 2413 Window root, dummy_window;
2414 int dummy; 2414 int dummy;
2415 2415
2416 BLOCK_INPUT; 2416 block_input ();
2417 2417
2418 XQueryPointer (FRAME_X_DISPLAY (f), 2418 XQueryPointer (FRAME_X_DISPLAY (f),
2419 DefaultRootWindow (FRAME_X_DISPLAY (f)), 2419 DefaultRootWindow (FRAME_X_DISPLAY (f)),
@@ -2439,7 +2439,7 @@ mouse_position_for_drop (FRAME_PTR f, int *x, int *y)
2439 *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f); 2439 *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
2440 *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f); 2440 *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
2441 2441
2442 UNBLOCK_INPUT; 2442 unblock_input ();
2443} 2443}
2444 2444
2445DEFUN ("x-get-atom-name", Fx_get_atom_name, 2445DEFUN ("x-get-atom-name", Fx_get_atom_name,
@@ -2462,7 +2462,7 @@ If the value is 0 or the atom is not known, return the empty string. */)
2462 2462
2463 CONS_TO_INTEGER (value, Atom, atom); 2463 CONS_TO_INTEGER (value, Atom, atom);
2464 2464
2465 BLOCK_INPUT; 2465 block_input ();
2466 x_catch_errors (dpy); 2466 x_catch_errors (dpy);
2467 name = atom ? XGetAtomName (dpy, atom) : empty; 2467 name = atom ? XGetAtomName (dpy, atom) : empty;
2468 had_errors = x_had_errors_p (dpy); 2468 had_errors = x_had_errors_p (dpy);
@@ -2474,7 +2474,7 @@ If the value is 0 or the atom is not known, return the empty string. */)
2474 if (atom && name) XFree (name); 2474 if (atom && name) XFree (name);
2475 if (NILP (ret)) ret = empty_unibyte_string; 2475 if (NILP (ret)) ret = empty_unibyte_string;
2476 2476
2477 UNBLOCK_INPUT; 2477 unblock_input ();
2478 2478
2479 return ret; 2479 return ret;
2480} 2480}
@@ -2496,9 +2496,9 @@ FRAME is on. If FRAME is nil, the selected frame is used. */)
2496 x_atom = symbol_to_x_atom (dpyinfo, atom); 2496 x_atom = symbol_to_x_atom (dpyinfo, atom);
2497 else if (STRINGP (atom)) 2497 else if (STRINGP (atom))
2498 { 2498 {
2499 BLOCK_INPUT; 2499 block_input ();
2500 x_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (atom), False); 2500 x_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (atom), False);
2501 UNBLOCK_INPUT; 2501 unblock_input ();
2502 } 2502 }
2503 else 2503 else
2504 error ("ATOM must be a symbol or a string"); 2504 error ("ATOM must be a symbol or a string");
@@ -2657,7 +2657,7 @@ x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from,
2657 if (wdest == 0) wdest = dpyinfo->root_window; 2657 if (wdest == 0) wdest = dpyinfo->root_window;
2658 to_root = wdest == dpyinfo->root_window; 2658 to_root = wdest == dpyinfo->root_window;
2659 2659
2660 BLOCK_INPUT; 2660 block_input ();
2661 2661
2662 event.xclient.message_type = message_type; 2662 event.xclient.message_type = message_type;
2663 event.xclient.display = dpyinfo->display; 2663 event.xclient.display = dpyinfo->display;
@@ -2683,7 +2683,7 @@ x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from,
2683 XFlush (dpyinfo->display); 2683 XFlush (dpyinfo->display);
2684 } 2684 }
2685 x_uncatch_errors (); 2685 x_uncatch_errors ();
2686 UNBLOCK_INPUT; 2686 unblock_input ();
2687} 2687}
2688 2688
2689 2689