aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c80
1 files changed, 31 insertions, 49 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 7e61cc4d8ea..9ab53dc087a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -21,17 +21,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21/* Xt features made by Fred Pierresteguy. */ 21/* Xt features made by Fred Pierresteguy. */
22 22
23#include <config.h> 23#include <config.h>
24#include <signal.h>
25#include <stdio.h> 24#include <stdio.h>
26#include <setjmp.h>
27 25
28#ifdef HAVE_X_WINDOWS 26#ifdef HAVE_X_WINDOWS
29 27
30#include "lisp.h" 28#include "lisp.h"
31#include "blockinput.h" 29#include "blockinput.h"
32
33/* Need syssignal.h for various externs and definitions that may be required
34 by some configurations for calls to signal later in this source file. */
35#include "syssignal.h" 30#include "syssignal.h"
36 31
37/* This may include sys/types.h, and that somehow loses 32/* This may include sys/types.h, and that somehow loses
@@ -51,7 +46,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
51 46
52#include <fcntl.h> 47#include <fcntl.h>
53#include <errno.h> 48#include <errno.h>
54#include <setjmp.h>
55#include <sys/stat.h> 49#include <sys/stat.h>
56/* Caused redefinition of DBL_DIG on Netbsd; seems not to be needed. */ 50/* Caused redefinition of DBL_DIG on Netbsd; seems not to be needed. */
57/* #include <sys/param.h> */ 51/* #include <sys/param.h> */
@@ -165,13 +159,6 @@ struct x_display_info *x_display_list;
165 159
166Lisp_Object x_display_name_list; 160Lisp_Object x_display_name_list;
167 161
168/* Frame being updated by update_frame. This is declared in term.c.
169 This is set by update_begin and looked at by all the XT functions.
170 It is zero while not inside an update. In that case, the XT
171 functions assume that `selected_frame' is the frame to apply to. */
172
173extern struct frame *updating_frame;
174
175/* This is a frame waiting to be auto-raised, within XTread_socket. */ 162/* This is a frame waiting to be auto-raised, within XTread_socket. */
176 163
177static struct frame *pending_autoraise_frame; 164static struct frame *pending_autoraise_frame;
@@ -1474,7 +1461,7 @@ x_frame_of_widget (Widget widget)
1474 && f->output_data.x->widget == widget) 1461 && f->output_data.x->widget == widget)
1475 return f; 1462 return f;
1476 1463
1477 abort (); 1464 emacs_abort ();
1478} 1465}
1479 1466
1480/* Allocate a color which is lighter or darker than *PIXEL by FACTOR 1467/* Allocate a color which is lighter or darker than *PIXEL by FACTOR
@@ -2703,7 +2690,7 @@ x_draw_underwave (struct glyph_string *s)
2703 y2 += dy; 2690 y2 += dy;
2704 2691
2705 if (INT_MAX - dx < xmax) 2692 if (INT_MAX - dx < xmax)
2706 abort (); 2693 emacs_abort ();
2707 2694
2708 while (x1 <= xmax) 2695 while (x1 <= xmax)
2709 { 2696 {
@@ -2812,7 +2799,7 @@ x_draw_glyph_string (struct glyph_string *s)
2812 break; 2799 break;
2813 2800
2814 default: 2801 default:
2815 abort (); 2802 emacs_abort ();
2816 } 2803 }
2817 2804
2818 if (!s->for_overlaps) 2805 if (!s->for_overlaps)
@@ -2986,6 +2973,7 @@ x_draw_glyph_string (struct glyph_string *s)
2986 XSetClipMask (next->display, next->gc, None); 2973 XSetClipMask (next->display, next->gc, None);
2987 next->hl = save; 2974 next->hl = save;
2988 next->num_clips = 0; 2975 next->num_clips = 0;
2976 next->clip_head = s->next;
2989 } 2977 }
2990 } 2978 }
2991 } 2979 }
@@ -3012,7 +3000,7 @@ x_shift_glyphs_for_insert (struct frame *f, int x, int y, int width, int height,
3012static void 3000static void
3013x_delete_glyphs (struct frame *f, register int n) 3001x_delete_glyphs (struct frame *f, register int n)
3014{ 3002{
3015 abort (); 3003 emacs_abort ();
3016} 3004}
3017 3005
3018 3006
@@ -3285,7 +3273,7 @@ XTset_terminal_window (struct frame *f, int n)
3285static void 3273static void
3286x_ins_del_lines (struct frame *f, int vpos, int n) 3274x_ins_del_lines (struct frame *f, int vpos, int n)
3287{ 3275{
3288 abort (); 3276 emacs_abort ();
3289} 3277}
3290 3278
3291 3279
@@ -4122,7 +4110,7 @@ x_window_to_scroll_bar (Display *display, Window window_id)
4122 frame = XCAR (tail); 4110 frame = XCAR (tail);
4123 /* All elements of Vframe_list should be frames. */ 4111 /* All elements of Vframe_list should be frames. */
4124 if (! FRAMEP (frame)) 4112 if (! FRAMEP (frame))
4125 abort (); 4113 emacs_abort ();
4126 4114
4127 if (! FRAME_X_P (XFRAME (frame))) 4115 if (! FRAME_X_P (XFRAME (frame)))
4128 continue; 4116 continue;
@@ -5441,7 +5429,7 @@ XTredeem_scroll_bar (struct window *window)
5441 5429
5442 /* We can't redeem this window's scroll bar if it doesn't have one. */ 5430 /* We can't redeem this window's scroll bar if it doesn't have one. */
5443 if (NILP (window->vertical_scroll_bar)) 5431 if (NILP (window->vertical_scroll_bar))
5444 abort (); 5432 emacs_abort ();
5445 5433
5446 bar = XSCROLL_BAR (window->vertical_scroll_bar); 5434 bar = XSCROLL_BAR (window->vertical_scroll_bar);
5447 5435
@@ -5460,7 +5448,7 @@ XTredeem_scroll_bar (struct window *window)
5460 else 5448 else
5461 /* If its prev pointer is nil, it must be at the front of 5449 /* If its prev pointer is nil, it must be at the front of
5462 one or the other! */ 5450 one or the other! */
5463 abort (); 5451 emacs_abort ();
5464 } 5452 }
5465 else 5453 else
5466 XSCROLL_BAR (bar->prev)->next = bar->next; 5454 XSCROLL_BAR (bar->prev)->next = bar->next;
@@ -5558,7 +5546,7 @@ static void
5558x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_event *emacs_event) 5546x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_event *emacs_event)
5559{ 5547{
5560 if (! WINDOWP (bar->window)) 5548 if (! WINDOWP (bar->window))
5561 abort (); 5549 emacs_abort ();
5562 5550
5563 emacs_event->kind = SCROLL_BAR_CLICK_EVENT; 5551 emacs_event->kind = SCROLL_BAR_CLICK_EVENT;
5564 emacs_event->code = event->xbutton.button - Button1; 5552 emacs_event->code = event->xbutton.button - Button1;
@@ -6464,7 +6452,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6464 } 6452 }
6465 else if (status_return != XLookupKeySym 6453 else if (status_return != XLookupKeySym
6466 && status_return != XLookupBoth) 6454 && status_return != XLookupBoth)
6467 abort (); 6455 emacs_abort ();
6468 } 6456 }
6469 else 6457 else
6470 nbytes = XLookupString (&event.xkey, (char *) copy_bufptr, 6458 nbytes = XLookupString (&event.xkey, (char *) copy_bufptr,
@@ -7141,25 +7129,17 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold
7141 if (interrupt_input_blocked) 7129 if (interrupt_input_blocked)
7142 { 7130 {
7143 interrupt_input_pending = 1; 7131 interrupt_input_pending = 1;
7144#ifdef SYNC_INPUT
7145 pending_signals = 1; 7132 pending_signals = 1;
7146#endif
7147 return -1; 7133 return -1;
7148 } 7134 }
7149 7135
7150 interrupt_input_pending = 0; 7136 interrupt_input_pending = 0;
7151#ifdef SYNC_INPUT
7152 pending_signals = pending_atimers; 7137 pending_signals = pending_atimers;
7153#endif
7154 BLOCK_INPUT; 7138 BLOCK_INPUT;
7155 7139
7156 /* So people can tell when we have read the available input. */ 7140 /* So people can tell when we have read the available input. */
7157 input_signal_count++; 7141 input_signal_count++;
7158 7142
7159#ifndef SYNC_INPUT
7160 ++handling_signal;
7161#endif
7162
7163 /* For debugging, this gives a way to fake an I/O error. */ 7143 /* For debugging, this gives a way to fake an I/O error. */
7164 if (terminal->display_info.x == XTread_socket_fake_io_error) 7144 if (terminal->display_info.x == XTread_socket_fake_io_error)
7165 { 7145 {
@@ -7248,9 +7228,6 @@ XTread_socket (struct terminal *terminal, int expected, struct input_event *hold
7248 pending_autoraise_frame = 0; 7228 pending_autoraise_frame = 0;
7249 } 7229 }
7250 7230
7251#ifndef SYNC_INPUT
7252 --handling_signal;
7253#endif
7254 UNBLOCK_INPUT; 7231 UNBLOCK_INPUT;
7255 7232
7256 return count; 7233 return count;
@@ -7503,7 +7480,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, int
7503 break; 7480 break;
7504 7481
7505 default: 7482 default:
7506 abort (); 7483 emacs_abort ();
7507 } 7484 }
7508 } 7485 }
7509 7486
@@ -7773,7 +7750,9 @@ x_connection_signal (int signalnum) /* If we don't have an argument, */
7773#ifdef USG 7750#ifdef USG
7774 /* USG systems forget handlers when they are used; 7751 /* USG systems forget handlers when they are used;
7775 must reestablish each time */ 7752 must reestablish each time */
7776 signal (signalnum, x_connection_signal); 7753 struct sigaction action;
7754 emacs_sigaction_init (&action, x_connection_signal);
7755 sigaction (signalnum, &action, 0);
7777#endif /* USG */ 7756#endif /* USG */
7778} 7757}
7779 7758
@@ -7798,7 +7777,6 @@ x_connection_closed (Display *dpy, const char *error_message)
7798 7777
7799 error_msg = alloca (strlen (error_message) + 1); 7778 error_msg = alloca (strlen (error_message) + 1);
7800 strcpy (error_msg, error_message); 7779 strcpy (error_msg, error_message);
7801 handling_signal = 0;
7802 7780
7803 /* Inhibit redisplay while frames are being deleted. */ 7781 /* Inhibit redisplay while frames are being deleted. */
7804 specbind (Qinhibit_redisplay, Qt); 7782 specbind (Qinhibit_redisplay, Qt);
@@ -7850,13 +7828,13 @@ x_connection_closed (Display *dpy, const char *error_message)
7850 (https://bugzilla.gnome.org/show_bug.cgi?id=85715). Once, 7828 (https://bugzilla.gnome.org/show_bug.cgi?id=85715). Once,
7851 the resulting Glib error message loop filled a user's disk. 7829 the resulting Glib error message loop filled a user's disk.
7852 To avoid this, kill Emacs unconditionally on disconnect. */ 7830 To avoid this, kill Emacs unconditionally on disconnect. */
7853 shut_down_emacs (0, 0, Qnil); 7831 shut_down_emacs (0, Qnil);
7854 fprintf (stderr, "%s\n\ 7832 fprintf (stderr, "%s\n\
7855When compiled with GTK, Emacs cannot recover from X disconnects.\n\ 7833When compiled with GTK, Emacs cannot recover from X disconnects.\n\
7856This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\ 7834This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\
7857For details, see etc/PROBLEMS.\n", 7835For details, see etc/PROBLEMS.\n",
7858 error_msg); 7836 error_msg);
7859 abort (); 7837 emacs_abort ();
7860#endif /* USE_GTK */ 7838#endif /* USE_GTK */
7861 7839
7862 /* Indicate that this display is dead. */ 7840 /* Indicate that this display is dead. */
@@ -7866,7 +7844,7 @@ For details, see etc/PROBLEMS.\n",
7866 dpyinfo->terminal->reference_count--; 7844 dpyinfo->terminal->reference_count--;
7867 if (dpyinfo->reference_count != 0) 7845 if (dpyinfo->reference_count != 0)
7868 /* We have just closed all frames on this display. */ 7846 /* We have just closed all frames on this display. */
7869 abort (); 7847 emacs_abort ();
7870 7848
7871 { 7849 {
7872 Lisp_Object tmp; 7850 Lisp_Object tmp;
@@ -7883,10 +7861,15 @@ For details, see etc/PROBLEMS.\n",
7883 } 7861 }
7884 7862
7885 /* Ordinary stack unwind doesn't deal with these. */ 7863 /* Ordinary stack unwind doesn't deal with these. */
7886#ifdef SIGIO 7864 {
7887 sigunblock (sigmask (SIGIO)); 7865 sigset_t unblocked;
7866 sigemptyset (&unblocked);
7867#ifdef USABLE_SIGIO
7868 sigaddset (&unblocked, SIGIO);
7888#endif 7869#endif
7889 sigunblock (sigmask (SIGALRM)); 7870 sigaddset (&unblocked, SIGALRM);
7871 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
7872 }
7890 TOTALLY_UNBLOCK_INPUT; 7873 TOTALLY_UNBLOCK_INPUT;
7891 7874
7892 unbind_to (idx, Qnil); 7875 unbind_to (idx, Qnil);
@@ -10424,10 +10407,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10424 fcntl (connection, F_SETOWN, getpid ()); 10407 fcntl (connection, F_SETOWN, getpid ());
10425#endif /* ! defined (F_SETOWN) */ 10408#endif /* ! defined (F_SETOWN) */
10426 10409
10427#ifdef SIGIO
10428 if (interrupt_input) 10410 if (interrupt_input)
10429 init_sigio (connection); 10411 init_sigio (connection);
10430#endif /* ! defined (SIGIO) */
10431 10412
10432#ifdef USE_LUCID 10413#ifdef USE_LUCID
10433 { 10414 {
@@ -10443,7 +10424,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10443 to.addr = (XPointer)&font; 10424 to.addr = (XPointer)&font;
10444 x_catch_errors (dpy); 10425 x_catch_errors (dpy);
10445 if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL)) 10426 if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL))
10446 abort (); 10427 emacs_abort ();
10447 if (x_had_errors_p (dpy) || !XQueryFont (dpy, font)) 10428 if (x_had_errors_p (dpy) || !XQueryFont (dpy, font))
10448 XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15"); 10429 XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15");
10449 x_uncatch_errors (); 10430 x_uncatch_errors ();
@@ -10609,8 +10590,6 @@ x_activate_timeout_atimer (void)
10609 10590
10610/* Set up use of X before we make the first connection. */ 10591/* Set up use of X before we make the first connection. */
10611 10592
10612extern frame_parm_handler x_frame_parm_handlers[];
10613
10614static struct redisplay_interface x_redisplay_interface = 10593static struct redisplay_interface x_redisplay_interface =
10615 { 10594 {
10616 x_frame_parm_handlers, 10595 x_frame_parm_handlers,
@@ -10768,6 +10747,8 @@ x_create_terminal (struct x_display_info *dpyinfo)
10768void 10747void
10769x_initialize (void) 10748x_initialize (void)
10770{ 10749{
10750 struct sigaction action;
10751
10771 baud_rate = 19200; 10752 baud_rate = 19200;
10772 10753
10773 x_noop_count = 0; 10754 x_noop_count = 0;
@@ -10814,7 +10795,8 @@ x_initialize (void)
10814 XSetErrorHandler (x_error_handler); 10795 XSetErrorHandler (x_error_handler);
10815 XSetIOErrorHandler (x_io_error_quitter); 10796 XSetIOErrorHandler (x_io_error_quitter);
10816 10797
10817 signal (SIGPIPE, x_connection_signal); 10798 emacs_sigaction_init (&action, x_connection_signal);
10799 sigaction (SIGPIPE, &action, 0);
10818} 10800}
10819 10801
10820 10802