Commit 7a13e894 authored by Richard M. Stallman's avatar Richard M. Stallman

(x_catch_errors, x_check_errors, x_had_errors_p)

(x_uncatch_errors): Make the argument a display, not a frame.

(XTread_socket_fake_io_error): New variable.
(XTread_socket): Obey XTread_socket_fake_io_error.

(x_initialize): Init x_noop_count, x_focus_frame
and x_highlight_frame here.
(x_term_init): Not here.

(x_term_init): Open the connection first thing;
if that fails, don't allocate dpyinfo.

(x_delete_display): New function.
(x_connection_closed): New args dpyinfo and error_message.
Delete all frames on the dead display
and all frames using them for minibuffers.
Call x_delete_display.
Maybe signal a Lisp error.

(x_term_init): Don't report error here--just return 0.

(x_scroll_bar_report_motion): Store proper value in
*bar_window (the Emacs window, not the X window number).

(x_scroll_bar_report_motion): Don't clear *fp.

(x_wm_set_icon_pixmap): Use x_bitmap_pixmap.

(show_mouse_face): New arg dpyinfo.  All callers changed.
(clear_mouse_face): New arg dpyinfo.  All callers changed.

(scratch_cursor_gc): Variable deleted.
(dumpglyphs): Use scratch_cursor_gc in x_display_info.

(syms_of_xterm): Don't staticpro mouse_face_window.

(expose_all_windows, expose_all_icons): Variables deleted.
(BLOCK_INPUT_mask): Variable deleted.

(x_term_init): Set up x_id_name field.
(x_id_name): Variable deleted.

(x_font_table, x_font_table_size, x_n_fonts): Vars deleted.
(x_new_font): Use new fields.
(warp_mouse_on_deiconify): Unused variable deleted.

(x_term_init): Set up dpyinfo->xrdb.
Set up dpyinfo->vertical_scroll_bar_cursor.
(x_scroll_bar_create): Use vertical_scroll_bar_cursor slot.
(x_vertical_scroll_bar_cursor): Variable deleted.

(x_term_init): Really return dpyinfo.

(x_term_init): Call add_keyboard_wait_descriptor,
not change_keyboard_wait_descriptor.

(x_term_init): Pass new arg to init_sigio.
Don't set old_fcntl_owner.
Don't call change_input_fd.
(XTread_socket): Loop over displays and process input from each.

(x_display_name_list): New variable.
(syms_of_xterm): staticpro it.
Don't staticpro slots in the_x_screen.
(x_term_init): Update x_display_name_list along with x_display_list.
Actually malloc the x_display_info.
(the_x_screen): Variable deleted.
parent c4ec904f
......@@ -66,6 +66,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <sys/stat.h>
#include <sys/param.h>
#include "frame.h"
#include "dispextern.h"
#include "termhooks.h"
#include "termopts.h"
......@@ -75,7 +76,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "sinkmask.h"
#endif /* ! 0 */
#include "gnu.h"
#include "frame.h"
#include "disptab.h"
#include "buffer.h"
#include "window.h"
......@@ -129,39 +129,18 @@ extern void _XEditResCheckMessages ();
#define min(a,b) ((a)<(b) ? (a) : (b))
#define max(a,b) ((a)>(b) ? (a) : (b))
/* Nonzero means we must reprint all windows
because 1) we received an ExposeWindow event
or 2) we received too many ExposeRegion events to record.
This is never needed under X11. */
static int expose_all_windows;
/* Nonzero means we must reprint all icon windows. */
static int expose_all_icons;
#if defined (SIGIO) && defined (FIONREAD)
int BLOCK_INPUT_mask;
#endif /* ! defined (SIGIO) && defined (FIONREAD) */
/* Stuff for dealing with the main icon title. */
extern Lisp_Object Vcommand_line_args, Vsystem_name;
char *x_id_name;
/* Initial values of argv and argc. */
extern char **initial_argv;
extern int initial_argc;
/* For now, we have just one x_display structure since we only support
one X display. */
static struct x_display_info the_x_screen;
/* This is a chain of structures for all the X displays currently in use. */
struct x_display_info *x_display_list;
/* The cursor to use for vertical scroll bars on x_current_display. */
static Cursor x_vertical_scroll_bar_cursor;
/* This is a list of cons cells, each of the form (NAME . FONT-LIST-CACHE),
one for each element of x_display_list and in the same order.
NAME is the name of the frame.
FONT-LIST-CACHE records previous values returned by x-list-fonts. */
Lisp_Object x_display_name_list;
/* Frame being updated by update_frame. This is declared in term.c.
This is set by update_begin and looked at by all the
......@@ -193,11 +172,6 @@ struct frame *x_focus_event_frame;
minibuffer. */
static struct frame *x_highlight_frame;
/* From .Xdefaults, the value of "emacs.WarpMouse". If non-zero,
mouse is moved to inside of frame when frame is de-iconified. */
static int warp_mouse_on_deiconify;
/* During an update, maximum vpos for ins/del line operations to affect. */
static int flexlines;
......@@ -212,9 +186,6 @@ static int highlight;
static int curs_x;
static int curs_y;
/* Reusable Graphics Context for drawing a cursor in a non-default face. */
static GC scratch_cursor_gc;
/* Mouse movement.
In order to avoid asking for motion events and then throwing most
......@@ -256,28 +227,6 @@ static Lisp_Object last_mouse_scroll_bar;
it's somewhat accurate. */
static Time last_mouse_movement_time;
/* These variables describe the range of text currently shown
in its mouse-face, together with the window they apply to.
As long as the mouse stays within this range, we need not
redraw anything on its account. */
static int mouse_face_beg_row, mouse_face_beg_col;
static int mouse_face_end_row, mouse_face_end_col;
static int mouse_face_past_end;
static Lisp_Object mouse_face_window;
static int mouse_face_face_id;
/* 1 if a mouse motion event came and we didn't handle it right away because
gc was in progress. */
static int mouse_face_deferred_gc;
/* FRAME and X, Y position of mouse when last checked for
highlighting. X and Y can be negative or out of range for the frame. */
static FRAME_PTR mouse_face_mouse_frame;
static int mouse_face_mouse_x, mouse_face_mouse_y;
/* Nonzero means defer mouse-motion highlighting. */
static int mouse_face_defer;
/* Incremented by XTread_socket whenever it really tries to read events. */
#ifdef __STDC__
static int volatile input_signal_count;
......@@ -285,35 +234,33 @@ static int volatile input_signal_count;
static int input_signal_count;
#endif
/* Tells if a window manager is present or not. */
/* Used locally within XTread_socket. */
static int x_noop_count;
extern Lisp_Object Vx_no_window_manager;
/* Initial values of argv and argc. */
extern char **initial_argv;
extern int initial_argc;
/* Timestamp that we requested selection data was made. */
extern Time requestor_time;
extern Lisp_Object Vcommand_line_args, Vsystem_name;
/* ID of the window requesting selection data. */
extern Window requestor_window;
/* Tells if a window manager is present or not. */
extern Lisp_Object Vx_no_window_manager;
/* Nonzero enables some debugging for the X interface code. */
extern int _Xdebug;
extern Lisp_Object Qface, Qmouse_face;
static int x_noop_count;
extern int errno;
/* A mask of extra modifier bits to put into every keyboard char. */
extern int extra_keyboard_modifiers;
extern Display *XOpenDisplay ();
extern Window XCreateWindow ();
extern Cursor XCreateCursor ();
extern XFontStruct *XOpenFont ();
extern XrmDatabase x_load_resources ();
void x_delete_display ();
static void flashback ();
static void redraw_previous_char ();
static void redraw_following_char ();
......@@ -325,9 +272,9 @@ static void clear_mouse_face ();
static void show_mouse_face ();
static void do_line_dance ();
void dumpborder ();
static int XTcursor_to ();
static int XTclear_end_of_line ();
static int x_io_error_quitter ();
/* Return the struct x_display_info corresponding to DPY. */
......@@ -353,8 +300,6 @@ x_display_info_for_display (dpy)
should never be called except during an update, the only exceptions
being XTcursor_to, XTwrite_glyphs and XTreassert_line_highlight. */
extern int mouse_track_top, mouse_track_left, mouse_track_width;
static
XTupdate_begin (f)
struct frame *f;
......@@ -369,14 +314,14 @@ XTupdate_begin (f)
BLOCK_INPUT;
if (f == mouse_face_mouse_frame)
if (f == FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_frame)
{
/* Don't do highlighting for mouse motion during the update. */
mouse_face_defer = 1;
if (!NILP (mouse_face_window))
FRAME_X_DISPLAY_INFO (f)->mouse_face_defer = 1;
if (!NILP (FRAME_X_DISPLAY_INFO (f)->mouse_face_window))
{
int firstline, lastline, i;
struct window *w = XWINDOW (mouse_face_window);
struct window *w = XWINDOW (FRAME_X_DISPLAY_INFO (f)->mouse_face_window);
/* Find the first, and the last+1, lines affected by redisplay. */
for (firstline = 0; firstline < f->height; firstline++)
......@@ -397,7 +342,7 @@ XTupdate_begin (f)
if (! (firstline > (XFASTINT (w->top) + window_internal_height (w))
|| lastline < XFASTINT (w->top)))
/* Otherwise turn off the mouse highlight now. */
clear_mouse_face ();
clear_mouse_face (FRAME_X_DISPLAY_INFO (f));
}
}
......@@ -415,8 +360,8 @@ XTupdate_end (f)
do_line_dance ();
x_display_cursor (f, 1);
if (f == mouse_face_mouse_frame)
mouse_face_defer = 0;
if (f == FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_frame)
FRAME_X_DISPLAY_INFO (f)->mouse_face_defer = 0;
#if 0
/* This fails in the case of having updated only the echo area
if we have switched buffers. In that case, FRAME_CURRENT_GLYPHS
......@@ -424,8 +369,9 @@ XTupdate_end (f)
have no relation to the contents of the window-buffer.
I don't know a clean way to check
for that case. window_end_valid isn't set up yet. */
if (f == mouse_face_mouse_frame)
note_mouse_highlight (f, mouse_face_mouse_x, mouse_face_mouse_y);
if (f == FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_frame)
note_mouse_highlight (f, FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_x,
FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_y);
#endif
XFlush (FRAME_X_DISPLAY (f));
......@@ -438,11 +384,13 @@ static
XTframe_up_to_date (f)
FRAME_PTR f;
{
if (mouse_face_deferred_gc || f == mouse_face_mouse_frame)
if (FRAME_X_DISPLAY_INFO (f)->mouse_face_deferred_gc
|| f == FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_frame)
{
note_mouse_highlight (mouse_face_mouse_frame,
mouse_face_mouse_x, mouse_face_mouse_y);
mouse_face_deferred_gc = 0;
note_mouse_highlight (FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_frame,
FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_x,
FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_y);
FRAME_X_DISPLAY_INFO (f)->mouse_face_deferred_gc = 0;
}
}
......@@ -583,7 +531,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
/* HL = 3 means use a mouse face previously chosen. */
if (hl == 3)
cf = mouse_face_face_id;
cf = FRAME_X_DISPLAY_INFO (f)->mouse_face_face_id;
/* First look at the face of the text itself. */
if (cf != 0)
......@@ -658,12 +606,14 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground)
xgcv.font = face->font->fid;
xgcv.graphics_exposures = 0;
mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
if (scratch_cursor_gc)
XChangeGC (FRAME_X_DISPLAY (f), scratch_cursor_gc, mask, &xgcv);
if (FRAME_X_DISPLAY_INFO (f)->scratch_cursor_gc)
XChangeGC (FRAME_X_DISPLAY (f),
FRAME_X_DISPLAY_INFO (f)->scratch_cursor_gc,
mask, &xgcv);
else
scratch_cursor_gc
FRAME_X_DISPLAY_INFO (f)->scratch_cursor_gc
= XCreateGC (FRAME_X_DISPLAY (f), window, mask, &xgcv);
gc = scratch_cursor_gc;
gc = FRAME_X_DISPLAY_INFO (f)->scratch_cursor_gc;
#if 0
/* If this code is restored, it must also reset to the default stipple
if necessary. */
......@@ -1241,6 +1191,11 @@ XTset_terminal_window (n)
flexlines = n;
}
/* These variables need not be per frame
because redisplay is done on a frame-by-frame basis
and the line dance for one frame is finished before
anything is done for anoter frame. */
/* Array of line numbers from cached insert/delete operations.
line_dance[i] is the old position of the line that we want
to move to line i, or -1 if we want a blank line there. */
......@@ -1896,16 +1851,16 @@ note_mouse_highlight (f, x, y)
if (disable_mouse_highlight)
return;
mouse_face_mouse_x = x;
mouse_face_mouse_y = y;
mouse_face_mouse_frame = f;
FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_x = x;
FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_y = y;
FRAME_X_DISPLAY_INFO (f)->mouse_face_mouse_frame = f;
if (mouse_face_defer)
if (FRAME_X_DISPLAY_INFO (f)->mouse_face_defer)
return;
if (gc_in_progress)
{
mouse_face_deferred_gc = 1;
FRAME_X_DISPLAY_INFO (f)->mouse_face_deferred_gc = 1;
return;
}
......@@ -1918,8 +1873,8 @@ note_mouse_highlight (f, x, y)
w = XWINDOW (window);
/* If we were displaying active text in another window, clear that. */
if (! EQ (window, mouse_face_window))
clear_mouse_face ();
if (! EQ (window, FRAME_X_DISPLAY_INFO (f)->mouse_face_window))
clear_mouse_face (FRAME_X_DISPLAY_INFO (f));
/* Are we in a window whose display is up to date?
And verify the buffer's text has not changed. */
......@@ -1938,13 +1893,15 @@ note_mouse_highlight (f, x, y)
pos = ptr[i];
/* Is it outside the displayed active region (if any)? */
if (pos <= 0)
clear_mouse_face ();
else if (! (EQ (window, mouse_face_window)
&& row >= mouse_face_beg_row
&& row <= mouse_face_end_row
&& (row > mouse_face_beg_row || column >= mouse_face_beg_col)
&& (row < mouse_face_end_row || column < mouse_face_end_col
|| mouse_face_past_end)))
clear_mouse_face (FRAME_X_DISPLAY_INFO (f));
else if (! (EQ (window, FRAME_X_DISPLAY_INFO (f)->mouse_face_window)
&& row >= FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_row
&& row <= FRAME_X_DISPLAY_INFO (f)->mouse_face_end_row
&& (row > FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_row
|| column >= FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_col)
&& (row < FRAME_X_DISPLAY_INFO (f)->mouse_face_end_row
|| column < FRAME_X_DISPLAY_INFO (f)->mouse_face_end_col
|| FRAME_X_DISPLAY_INFO (f)->mouse_face_past_end)))
{
Lisp_Object mouse_face, overlay, position;
Lisp_Object *overlay_vec;
......@@ -1966,7 +1923,7 @@ note_mouse_highlight (f, x, y)
ZV = Z;
/* Yes. Clear the display of the old active region, if any. */
clear_mouse_face ();
clear_mouse_face (FRAME_X_DISPLAY_INFO (f));
/* Is this char mouse-active? */
XSETINT (position, pos);
......@@ -2007,17 +1964,20 @@ note_mouse_highlight (f, x, y)
before = Foverlay_start (overlay);
after = Foverlay_end (overlay);
/* Record this as the current active region. */
fast_find_position (window, before, &mouse_face_beg_col,
&mouse_face_beg_row);
mouse_face_past_end
= !fast_find_position (window, after, &mouse_face_end_col,
&mouse_face_end_row);
mouse_face_window = window;
mouse_face_face_id = compute_char_face (f, w, pos, 0, 0,
&ignore, pos + 1, 1);
fast_find_position (window, before,
&FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_col,
&FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_row);
FRAME_X_DISPLAY_INFO (f)->mouse_face_past_end
= !fast_find_position (window, after,
&FRAME_X_DISPLAY_INFO (f)->mouse_face_end_col,
&FRAME_X_DISPLAY_INFO (f)->mouse_face_end_row);
FRAME_X_DISPLAY_INFO (f)->mouse_face_window = window;
FRAME_X_DISPLAY_INFO (f)->mouse_face_face_id
= compute_char_face (f, w, pos, 0, 0,
&ignore, pos + 1, 1);
/* Display it as active. */
show_mouse_face (1);
show_mouse_face (FRAME_X_DISPLAY_INFO (f), 1);
}
/* Handle the text property case. */
else if (! NILP (mouse_face))
......@@ -2038,18 +1998,20 @@ note_mouse_highlight (f, x, y)
= Fnext_single_property_change (position, Qmouse_face,
w->buffer, end);
/* Record this as the current active region. */
fast_find_position (window, before, &mouse_face_beg_col,
&mouse_face_beg_row);
mouse_face_past_end
= !fast_find_position (window, after, &mouse_face_end_col,
&mouse_face_end_row);
mouse_face_window = window;
mouse_face_face_id
fast_find_position (window, before,
&FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_col,
&FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_row);
FRAME_X_DISPLAY_INFO (f)->mouse_face_past_end
= !fast_find_position (window, after,
&FRAME_X_DISPLAY_INFO (f)->mouse_face_end_col,
&FRAME_X_DISPLAY_INFO (f)->mouse_face_end_row);
FRAME_X_DISPLAY_INFO (f)->mouse_face_window = window;
FRAME_X_DISPLAY_INFO (f)->mouse_face_face_id
= compute_char_face (f, w, pos, 0, 0,
&ignore, pos + 1, 1);
/* Display it as active. */
show_mouse_face (1);
show_mouse_face (FRAME_X_DISPLAY_INFO (f), 1);
}
BEGV = obegv;
ZV = ozv;
......@@ -2122,10 +2084,11 @@ fast_find_position (window, pos, columnp, rowp)
in its mouse-face if HL > 0, in its normal face if HL = 0. */
static void
show_mouse_face (hl)
show_mouse_face (dpyinfo, hl)
struct x_display_info *dpyinfo;
int hl;
{
struct window *w = XWINDOW (mouse_face_window);
struct window *w = XWINDOW (dpyinfo->mouse_face_window);
int width = window_internal_width (w);
FRAME_PTR f = XFRAME (WINDOW_FRAME (w));
int i;
......@@ -2139,16 +2102,22 @@ show_mouse_face (hl)
curs_x = f->phys_cursor_x;
curs_y = f->phys_cursor_y;
for (i = mouse_face_beg_row; i <= mouse_face_end_row; i++)
for (i = FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_row;
i <= FRAME_X_DISPLAY_INFO (f)->mouse_face_end_row; i++)
{
int column = (i == mouse_face_beg_row ? mouse_face_beg_col : w->left);
int endcolumn = (i == mouse_face_end_row ? mouse_face_end_col : w->left + width);
int column = (i == FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_row
? FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_col
: w->left);
int endcolumn = (i == FRAME_X_DISPLAY_INFO (f)->mouse_face_end_row
? FRAME_X_DISPLAY_INFO (f)->mouse_face_end_col
: w->left + width);
endcolumn = min (endcolumn, FRAME_CURRENT_GLYPHS (f)->used[i]);
/* If the cursor's in the text we are about to rewrite,
turn the cursor off. */
if (i == curs_y
&& curs_x >= mouse_face_beg_col - 1 && curs_x <= mouse_face_end_col)
&& curs_x >= FRAME_X_DISPLAY_INFO (f)->mouse_face_beg_col - 1
&& curs_x <= FRAME_X_DISPLAY_INFO (f)->mouse_face_end_col)
{
x_display_cursor (f, 0);
cursor_off = 1;
......@@ -2183,14 +2152,15 @@ show_mouse_face (hl)
Redraw it unhighlighted first. */
static void
clear_mouse_face ()
clear_mouse_face (dpyinfo)
struct x_display_info *dpyinfo;
{
if (! NILP (mouse_face_window))
show_mouse_face (0);
if (! NILP (dpyinfo->mouse_face_window))
show_mouse_face (dpyinfo, 0);
mouse_face_beg_row = mouse_face_beg_col = -1;
mouse_face_end_row = mouse_face_end_col = -1;
mouse_face_window = Qnil;
dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
dpyinfo->mouse_face_window = Qnil;
}
static struct scroll_bar *x_window_to_scroll_bar ();
......@@ -2422,7 +2392,7 @@ x_scroll_bar_create (window, top, left, width, height)
a.event_mask = (ButtonPressMask | ButtonReleaseMask
| ButtonMotionMask | PointerMotionHintMask
| ExposureMask);
a.cursor = x_vertical_scroll_bar_cursor;
a.cursor = FRAME_X_DISPLAY_INFO (f)->vertical_scroll_bar_cursor;
mask = (CWBackPixel | CWEventMask | CWCursor);
......@@ -2976,7 +2946,7 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
/* Mouse buttons and modifier keys. */
&dummy_mask))
*fp = 0;
;
else
{
int inside_height
......@@ -2995,7 +2965,7 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
win_y = top_range;
*fp = f;
*bar_window = w;
*bar_window = bar->window;
if (! NILP (bar->dragging))
*part = scroll_bar_handle;
......@@ -3162,6 +3132,10 @@ static XComposeStatus compose_status;
int temp_index;
short temp_buffer[100];
/* Set this to nonzero to fake an "X I/O error"
on a particular display. */
struct x_display_info *XTread_socket_fake_io_error;
/* Read events coming from the X server.
This routine is called by the SIGIO handler.
We return as soon as there are no more events to be read.
......@@ -3202,635 +3176,586 @@ XTread_socket (sd, bufp, numchars, waitp, expected)
interrupt_input_pending = 0;
BLOCK_INPUT;
/* Find the display we are supposed to read input for.
It's the one communicating on descriptor SD. */
for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
if (dpyinfo->connection == sd)
break;
if (dpyinfo == 0)
abort ();
/* So people can tell when we have read the available input. */
input_signal_count++;
if (numchars <= 0)
abort (); /* Don't think this happens. */
/* Find the display we are supposed to read input for.
It's the one communicating on descriptor SD. */
for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
{
#if 0 /* This ought to be unnecessary; let's verify it. */
#ifdef FIOSNBIO
/* If available, Xlib uses FIOSNBIO to make the socket
non-blocking, and then looks for EWOULDBLOCK. If O_NDELAY is set,
FIOSNBIO is ignored, and instead of signalling EWOULDBLOCK,
a read returns 0, which Xlib interprets as equivalent to EPIPE. */
fcntl (sd, F_SETFL, 0);
/* If available, Xlib uses FIOSNBIO to make the socket
non-blocking, and then looks for EWOULDBLOCK. If O_NDELAY is set,
FIOSNBIO is ignored, and instead of signalling EWOULDBLOCK,
a read returns 0, which Xlib interprets as equivalent to EPIPE. */
fcntl (dpyinfo->connection, F_SETFL, 0);
#endif /* ! defined (FIOSNBIO) */
#endif
#if 0 /* This code can't be made to work, with multiple displays,
and appears not to be used on any system any more.
Also keyboard.c doesn't turn O_NDELAY on and off
for X connections. */
#ifndef SIGIO
#ifndef HAVE_SELECT
if (! (fcntl (sd, F_GETFL, 0) & O_NDELAY))
{
extern int read_alarm_should_throw;
read_alarm_should_throw = 1;
XPeekEvent (dpyinfo->display, &event);
read_alarm_should_throw = 0;
}
if (! (fcntl (dpyinfo->connection, F_GETFL, 0) & O_NDELAY))
{
extern int read_alarm_should_throw;
read_alarm_should_throw = 1;
XPeekEvent (dpyinfo->display, &event);
read_alarm_should_throw = 0;
}
#endif /* HAVE_SELECT */
#endif /* SIGIO */
#endif
while (XPending (dpyinfo->display) != 0)
{
XNextEvent (dpyinfo->display, &event);
event_found = 1;
/* For debugging, this gives a way to fake an I/O error. */
if (dpyinfo == XTread_socket_fake_io_error)
{
XTread_socket_fake_io_error = 0;
x_io_error_quitter (dpyinfo->display);
}
switch (event.type)
while (XPending (dpyinfo->display) != 0)
{
case ClientMessage:
{
if (event.xclient.message_type
== dpyinfo->Xatom_wm_protocols
&& event.xclient.format == 32)
XNextEvent (dpyinfo->display, &event);
event_found = 1;
switch (event.type)
{
case ClientMessage:
{
if (event.xclient.data.l[0]
== dpyinfo->Xatom_wm_take_focus)
if (event.xclient.message_type
== dpyinfo->Xatom_wm_protocols
&& event.xclient.format == 32)
{
f = x_window_to_frame (event.xclient.window);
/* Since we set WM_TAKE_FOCUS, we must call
XSetInputFocus explicitly. But not if f is null,
since that might be an event for a deleted frame. */
if (f)
XSetInputFocus (event.xclient.display,
event.xclient.window,
RevertToPointerRoot,
event.xclient.data.l[1]);
/* Not certain about handling scroll bars here */
}
else if (event.xclient.data.l[0]
== dpyinfo->Xatom_wm_save_yourself)
{
/* Save state modify the WM_COMMAND property to
something which can reinstate us. This notifies
the session manager, who's looking for such a
PropertyNotify. Can restart processing when
a keyboard or mouse event arrives. */
if (numchars > 0)
if (event.xclient.data.l[0]
== dpyinfo->Xatom_wm_take_focus)
{
f = x_top_window_to_frame (event.xclient.window);
/* This is just so we only give real data once
for a single Emacs process. */
if (f == selected_frame)
XSetCommand (FRAME_X_DISPLAY (f),
event.xclient.window,
initial_argv, initial_argc);
else
XSetCommand (FRAME_X_DISPLAY (f),
event.xclient.window,
0, 0);
f = x_window_to_frame (event.xclient.window);
/* Since we set WM_TAKE_FOCUS, we must call
XSetInputFocus explicitly. But not if f is null,
since that might be an event for a deleted frame. */
if (f)
XSetInputFocus (event.xclient.display,
event.xclient.window,
RevertToPointerRoot,
event.xclient.data.l[1]);
/* Not certain about handling scroll bars here */
}
}
else if (event.xclient.data.l[0]