comparison src/xterm.c @ 13205:8eac10febc8e

(x_connection_signal_1): New function. (x_connection_signal): Try all the server connections to see which one was lost. (XTcondemn_scroll_bars): No error if FRAME_CONDEMNED_SCROLL_BARS is non-nil already. Just move all the scroll bars into there.
author Richard M. Stallman <rms@gnu.org>
date Thu, 12 Oct 1995 22:58:04 +0000
parents ce60b1a64399
children e31057e55df7
comparison
equal deleted inserted replaced
13204:abf9c5bc5a0f 13205:8eac10febc8e
2763 `*redeem_scroll_bar_hook' is applied to its window before the judgement. */ 2763 `*redeem_scroll_bar_hook' is applied to its window before the judgement. */
2764 static void 2764 static void
2765 XTcondemn_scroll_bars (frame) 2765 XTcondemn_scroll_bars (frame)
2766 FRAME_PTR frame; 2766 FRAME_PTR frame;
2767 { 2767 {
2768 /* The condemned list should be empty at this point; if it's not, 2768 /* Transfer all the scroll bars to FRAME_CONDEMNED_SCROLL_BARS. */
2769 then the rest of Emacs isn't using the condemn/redeem/judge 2769 while (! NILP (FRAME_SCROLL_BARS (frame)))
2770 protocol correctly. */ 2770 {
2771 if (! NILP (FRAME_CONDEMNED_SCROLL_BARS (frame))) 2771 Lisp_Object bar;
2772 abort (); 2772 bar = FRAME_SCROLL_BARS (frame);
2773 2773 FRAME_SCROLL_BARS (frame) = XSCROLL_BAR (bar)->next;
2774 /* Move them all to the "condemned" list. */ 2774 XSCROLL_BAR (bar)->next = FRAME_CONDEMNED_SCROLL_BARS (frame);
2775 FRAME_CONDEMNED_SCROLL_BARS (frame) = FRAME_SCROLL_BARS (frame); 2775 XSCROLL_BAR (bar)->prev = Qnil;
2776 FRAME_SCROLL_BARS (frame) = Qnil; 2776 if (! NILP (FRAME_CONDEMNED_SCROLL_BARS (frame)))
2777 XSCROLL_BAR (FRAME_CONDEMNED_SCROLL_BARS (frame))->prev = bar;
2778 FRAME_CONDEMNED_SCROLL_BARS (frame) = bar;
2779 }
2777 } 2780 }
2778 2781
2779 /* Unmark WINDOW's scroll bar for deletion in this judgement cycle. 2782 /* Unmark WINDOW's scroll bar for deletion in this judgement cycle.
2780 Note that WINDOW isn't necessarily condemned at all. */ 2783 Note that WINDOW isn't necessarily condemned at all. */
2781 static void 2784 static void
3794 f = x_any_window_to_frame (dpyinfo, event.xfocus.window); 3797 f = x_any_window_to_frame (dpyinfo, event.xfocus.window);
3795 if (event.xfocus.detail != NotifyPointer) 3798 if (event.xfocus.detail != NotifyPointer)
3796 dpyinfo->x_focus_event_frame = f; 3799 dpyinfo->x_focus_event_frame = f;
3797 if (f) 3800 if (f)
3798 x_new_focus_frame (dpyinfo, f); 3801 x_new_focus_frame (dpyinfo, f);
3802
3799 #ifdef USE_X_TOOLKIT 3803 #ifdef USE_X_TOOLKIT
3800 goto OTHER; 3804 goto OTHER;
3801 #endif /* USE_X_TOOLKIT */ 3805 #endif /* USE_X_TOOLKIT */
3802 break; 3806 break;
3803 3807
3831 if (event.xfocus.detail != NotifyPointer 3835 if (event.xfocus.detail != NotifyPointer
3832 && f == dpyinfo->x_focus_event_frame) 3836 && f == dpyinfo->x_focus_event_frame)
3833 dpyinfo->x_focus_event_frame = 0; 3837 dpyinfo->x_focus_event_frame = 0;
3834 if (f && f == dpyinfo->x_focus_frame) 3838 if (f && f == dpyinfo->x_focus_frame)
3835 x_new_focus_frame (dpyinfo, 0); 3839 x_new_focus_frame (dpyinfo, 0);
3840
3836 #ifdef USE_X_TOOLKIT 3841 #ifdef USE_X_TOOLKIT
3837 goto OTHER; 3842 goto OTHER;
3838 #endif /* USE_X_TOOLKIT */ 3843 #endif /* USE_X_TOOLKIT */
3839 break; 3844 break;
3840 3845
4528 TOTALLY_UNBLOCK_INPUT; 4533 TOTALLY_UNBLOCK_INPUT;
4529 4534
4530 error ("%s", error_message); 4535 error ("%s", error_message);
4531 } 4536 }
4532 4537
4533 static SIGTYPE
4534 x_connection_signal (signalnum) /* If we don't have an argument, */
4535 int signalnum; /* some compilers complain in signal calls. */
4536 {
4537 /* We really ought to close the connection to the display
4538 that actually failed.
4539 But do we actually get this signal ever with X11? */
4540 fprintf (stderr, "X connection closed");
4541 shut_down_emacs (0, 0, Qnil);
4542 exit (70);
4543 }
4544
4545 /* This is the usual handler for X protocol errors. 4538 /* This is the usual handler for X protocol errors.
4546 It kills all frames on the display that we got the error for. 4539 It kills all frames on the display that we got the error for.
4547 If that was the only one, it prints an error message and kills Emacs. */ 4540 If that was the only one, it prints an error message and kills Emacs. */
4548 4541
4549 static int 4542 static int
4572 { 4565 {
4573 char buf[256]; 4566 char buf[256];
4574 4567
4575 sprintf (buf, "Connection lost to X server `%s'", DisplayString (display)); 4568 sprintf (buf, "Connection lost to X server `%s'", DisplayString (display));
4576 x_connection_closed (display, buf); 4569 x_connection_closed (display, buf);
4570 }
4571
4572 /* Handle SIGPIPE, which can happen when the connection to a server
4573 simply goes away. SIGPIPE is handled by x_connection_signal.
4574 It works by sending a no-op command to each X server connection.
4575 When we try a connection that has closed, we get SIGPIPE again.
4576 But this time, it is handled by x_connection_signal_1.
4577 That function knows which connection we were testing,
4578 so it closes that one.
4579
4580 x_connection_closed never returns,
4581 so if more than one connection was lost at once,
4582 we only find one. But XTread_socket keeps trying them all,
4583 so it will notice the other closed one sooner or later. */
4584
4585
4586 static struct x_display_info *x_connection_signal_dpyinfo;
4587
4588 static SIGTYPE x_connection_signal ();
4589
4590 static SIGTYPE
4591 x_connection_signal_1 (signalnum) /* If we don't have an argument, */
4592 int signalnum; /* some compilers complain in signal calls. */
4593 {
4594 signal (SIGPIPE, x_connection_signal);
4595 x_connection_closed (x_connection_signal_dpyinfo,
4596 "connection was lost");
4597 }
4598
4599 static SIGTYPE
4600 x_connection_signal (signalnum) /* If we don't have an argument, */
4601 int signalnum; /* some compilers complain in signal calls. */
4602 {
4603 x_connection_signal_dpyinfo = x_display_list;
4604
4605 sigunblock (SIGPIPE);
4606
4607 while (x_connection_signal_dpyinfo)
4608 {
4609 signal (SIGPIPE, x_connection_signal_1);
4610
4611 XNoOp (x_connection_signal_dpyinfo->display);
4612 XSync (x_connection_signal_dpyinfo->display, False);
4613
4614 /* Each time we get here, cycle through the displays now open. */
4615 x_connection_signal_dpyinfo = x_connection_signal_dpyinfo->next;
4616 }
4617
4618 /* We should have found some closed connection. */
4619 abort ();
4577 } 4620 }
4578 4621
4579 /* A buffer for storing X error messages. */ 4622 /* A buffer for storing X error messages. */
4580 static char *x_caught_error_message; 4623 static char *x_caught_error_message;
4581 #define X_CAUGHT_ERROR_MESSAGE_SIZE 200 4624 #define X_CAUGHT_ERROR_MESSAGE_SIZE 200