#include <sys/ioctl.h>
#endif /* ! defined (BSD_SYSTEM) */
-#include "systty.h"
#include "systime.h"
#ifndef INCLUDED_FCNTL
void x_set_window_size P_ ((struct frame *, int, int, int));
void x_wm_set_window_state P_ ((struct frame *, int));
void x_wm_set_icon_pixmap P_ ((struct frame *, int));
+struct display *x_create_frame_display P_ ((struct x_display_info *));
+void x_delete_frame_display P_ ((struct display *));
void x_initialize P_ ((void));
static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
static int x_compute_min_glyph_bounds P_ ((struct frame *));
static void x_update_end P_ ((struct frame *));
static void XTframe_up_to_date P_ ((struct frame *));
-static void XTset_terminal_modes P_ ((void));
-static void XTreset_terminal_modes P_ ((void));
-static void x_clear_frame P_ ((void));
+static void XTset_terminal_modes P_ ((struct display *));
+static void XTreset_terminal_modes P_ ((struct display *));
+static void x_clear_frame P_ ((struct frame *));
static void frame_highlight P_ ((struct frame *));
static void frame_unhighlight P_ ((struct frame *));
static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *));
{
Lisp_Object rest, frame;
FOR_EACH_FRAME (rest, frame)
- x_flush (XFRAME (frame));
+ if (FRAME_X_P (XFRAME (frame)))
+ x_flush (XFRAME (frame));
}
else if (FRAME_X_P (f))
XFlush (FRAME_X_DISPLAY (f));
/* Nothing to do. */
}
-
/* Start update of window W. Set the global variable updated_window
to the window being updated and set output_cursor to the cursor
position of W. */
rarely happens). */
static void
-XTset_terminal_modes ()
+XTset_terminal_modes (struct display *display)
{
}
the X-windows go away, and suspending requires no action. */
static void
-XTreset_terminal_modes ()
+XTreset_terminal_modes (struct display *display)
{
}
for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
if (GC_FRAMEP (XCAR (tail))
&& (f = XFRAME (XCAR (tail)),
- (f->output_data.nothing != 1
+ (FRAME_X_P (f)
+ && f->output_data.nothing != 1
&& FRAME_X_DISPLAY_INFO (f) == dpyinfo))
&& f->output_data.x->widget == widget)
return f;
for X frames. */
static void
-x_delete_glyphs (n)
+x_delete_glyphs (f, n)
+ struct frame *f;
register int n;
{
abort ();
}
-/* Clear entire frame. If updating_frame is non-null, clear that
- frame. Otherwise clear the selected frame. */
+/* Clear an entire frame. */
static void
-x_clear_frame ()
+x_clear_frame (struct frame *f)
{
- struct frame *f;
-
- if (updating_frame)
- f = updating_frame;
- else
- f = SELECTED_FRAME ();
-
/* Clearing the frame will erase any cursor, so mark them all as no
longer visible. */
mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f)));
lines or deleting -N lines at vertical position VPOS. */
static void
-x_ins_del_lines (vpos, n)
+x_ins_del_lines (f, vpos, n)
+ struct frame *f;
int vpos, n;
{
abort ();
/* Clear the mouse-moved flag for every frame on this display. */
FOR_EACH_FRAME (tail, frame)
- if (FRAME_X_DISPLAY (XFRAME (frame)) == FRAME_X_DISPLAY (*fp))
+ if (FRAME_X_P (XFRAME (frame))
+ && FRAME_X_DISPLAY (XFRAME (frame)) == FRAME_X_DISPLAY (*fp))
XFRAME (frame)->mouse_moved = 0;
last_mouse_scroll_bar = Qnil;
if (! GC_FRAMEP (frame))
abort ();
+ if (! FRAME_X_P (XFRAME (frame)))
+ continue;
+
/* Scan this frame's scroll bar list for a scroll bar with the
right window ID. */
condemned = FRAME_CONDEMNED_SCROLL_BARS (XFRAME (frame));
XGCTYPE (tail) == Lisp_Cons;
tail = XCDR (tail))
{
- Lisp_Object frame = XCAR (tail);
- Widget menu_bar = XFRAME (frame)->output_data.x->menubar_widget;
+ if (FRAME_X_P (XFRAME (XCAR (tail))))
+ {
+ Lisp_Object frame = XCAR (tail);
+ Widget menu_bar = XFRAME (frame)->output_data.x->menubar_widget;
- if (menu_bar && xlwmenu_window_p (menu_bar, window))
- return menu_bar;
+ if (menu_bar && xlwmenu_window_p (menu_bar, window))
+ return menu_bar;
+ }
}
return NULL;
orig_keysym = keysym;
- /* Common for all keysym input events. */
- XSETFRAME (inev.frame_or_window, f);
- inev.modifiers
- = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f), modifiers);
- inev.timestamp = event.xkey.time;
-
- /* First deal with keysyms which have defined
- translations to characters. */
- if (keysym >= 32 && keysym < 128)
- /* Avoid explicitly decoding each ASCII character. */
- {
- inev.kind = ASCII_KEYSTROKE_EVENT;
- inev.code = keysym;
- goto done_keysym;
- }
-
- /* Now non-ASCII. */
- if (HASH_TABLE_P (Vx_keysym_table)
- && (NATNUMP (c = Fgethash (make_number (keysym),
- Vx_keysym_table,
- Qnil))))
- {
- inev.kind = (SINGLE_BYTE_CHAR_P (XFASTINT (c))
- ? ASCII_KEYSTROKE_EVENT
- : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
- inev.code = XFASTINT (c);
- goto done_keysym;
- }
-
- /* Random non-modifier sorts of keysyms. */
- if (((keysym >= XK_BackSpace && keysym <= XK_Escape)
+ /* Common for all keysym input events. */
+ XSETFRAME (inev.frame_or_window, f);
+ inev.modifiers
+ = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f), modifiers);
+ inev.timestamp = event.xkey.time;
+
+ /* First deal with keysyms which have defined
+ translations to characters. */
+ if (keysym >= 32 && keysym < 128)
+ /* Avoid explicitly decoding each ASCII character. */
+ {
+ inev.kind = ASCII_KEYSTROKE_EVENT;
+ inev.code = keysym;
+ goto done_keysym;
+ }
+
+ /* Now non-ASCII. */
+ if (HASH_TABLE_P (Vx_keysym_table)
+ && (NATNUMP (c = Fgethash (make_number (keysym),
+ Vx_keysym_table,
+ Qnil))))
+ {
+ inev.kind = (SINGLE_BYTE_CHAR_P (XFASTINT (c))
+ ? ASCII_KEYSTROKE_EVENT
+ : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
+ inev.code = XFASTINT (c);
+ goto done_keysym;
+ }
+
+ /* Random non-modifier sorts of keysyms. */
+ if (((keysym >= XK_BackSpace && keysym <= XK_Escape)
|| keysym == XK_Delete
#ifdef XK_ISO_Left_Tab
|| (keysym >= XK_ISO_Left_Tab
EXPECTED is nonzero if the caller knows input is available. */
static int
-XTread_socket (sd, expected, hold_quit)
- register int sd;
+XTread_socket (display, expected, hold_quit)
+ struct display *display;
int expected;
struct input_event *hold_quit;
{
}
#ifndef XFlush
- if (updating_frame != f)
- XFlush (FRAME_X_DISPLAY (f));
+ XFlush (FRAME_X_DISPLAY (f));
#endif
}
{
Lisp_Object first = XCAR (old_val);
Display *dpy = XSAVE_VALUE (first)->pointer;
-
+
/* The display may have been closed before this function is called.
Check if it is still open before calling XSync. */
if (x_display_info_for_display (dpy) != 0)
struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
Lisp_Object frame, tail;
int count;
+ int index = SPECPDL_INDEX ();
error_msg = (char *) alloca (strlen (error_message) + 1);
strcpy (error_msg, error_message);
if (dpyinfo)
dpyinfo->display = 0;
+ /* Inhibit redisplay while frames are being deleted. */
+ specbind (Qinhibit_redisplay, Qt);
+
/* First delete frames whose mini-buffers are on frames
that are on the dead display. */
FOR_EACH_FRAME (tail, frame)
x_uncatch_errors (dpy, count);
- if (x_display_list == 0)
+ if (display_list == 0)
{
fprintf (stderr, "%s\n", error_msg);
shut_down_emacs (0, 0, Qnil);
sigunblock (sigmask (SIGALRM));
TOTALLY_UNBLOCK_INPUT;
+ unbind_to (index, Qnil);
clear_waiting_for_input ();
error ("%s", error_msg);
}
FOR_EACH_FRAME (tail, frame)
{
struct frame *f = XFRAME (frame);
- if (FRAME_X_DISPLAY_INFO (f) == dpyinfo)
+ if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo)
{
FRAME_XIC (f) = NULL;
xic_free_xfontset (f);
{
struct frame *f = XFRAME (frame);
- if (FRAME_X_DISPLAY_INFO (f) == xim_inst->dpyinfo)
+ if (FRAME_X_P (f)
+ && FRAME_X_DISPLAY_INFO (f) == xim_inst->dpyinfo)
if (FRAME_XIC (f) == NULL)
{
create_frame_xic (f);
{
int connection;
Display *dpy;
+ struct display *display;
struct x_display_info *dpyinfo;
XrmDatabase xrdb;
dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info));
bzero (dpyinfo, sizeof *dpyinfo);
+ display = x_create_frame_display (dpyinfo);
+
#ifdef MULTI_KBOARD
{
struct x_display_info *share;
dpyinfo->display = dpy;
+ /* Set the name of the display. */
+ display->name = (char *) xmalloc (SBYTES (display_name) + 1);
+ strncpy (display->name, SDATA (display_name), SBYTES (display_name));
+ display->name[SBYTES (display_name)] = 0;
+
#if 0
XSetAfterFunction (x_current_display, x_trace_wire);
#endif /* ! 0 */
struct x_display_info *dpyinfo;
{
int i;
-
+
+ {
+ /* Delete the generic struct display for this X display. */
+ struct display *d;
+ for (d = display_list; d; d = d->next_display)
+ if (d->type == output_x_window && d->display_info.x == dpyinfo)
+ {
+ delete_display (d);
+ break;
+ }
+ }
+
delete_keyboard_wait_descriptor (dpyinfo->connection);
/* Discard this display from x_display_name_list and x_display_list.
xfree (dpyinfo->font_table[i].name);
}
- if (dpyinfo->font_table->font_encoder)
+ if (dpyinfo->font_table && dpyinfo->font_table->font_encoder)
xfree (dpyinfo->font_table->font_encoder);
- xfree (dpyinfo->font_table);
+ if (dpyinfo->font_table)
+ xfree (dpyinfo->font_table);
xfree (dpyinfo->x_id_name);
xfree (dpyinfo->color_cells);
xfree (dpyinfo);
extern frame_parm_handler x_frame_parm_handlers[];
static struct redisplay_interface x_redisplay_interface =
-{
- x_frame_parm_handlers,
- x_produce_glyphs,
- x_write_glyphs,
- x_insert_glyphs,
- x_clear_end_of_line,
- x_scroll_run,
- x_after_update_window_line,
- x_update_window_begin,
- x_update_window_end,
- x_cursor_to,
- x_flush,
+ {
+ x_frame_parm_handlers,
+ x_produce_glyphs,
+ x_write_glyphs,
+ x_insert_glyphs,
+ x_clear_end_of_line,
+ x_scroll_run,
+ x_after_update_window_line,
+ x_update_window_begin,
+ x_update_window_end,
+ x_cursor_to,
+ x_flush,
#ifdef XFlush
- x_flush,
+ x_flush,
#else
- 0, /* flush_display_optional */
+ 0, /* flush_display_optional */
#endif
- x_clear_window_mouse_face,
- x_get_glyph_overhangs,
- x_fix_overlapping_area,
- x_draw_fringe_bitmap,
- 0, /* define_fringe_bitmap */
- 0, /* destroy_fringe_bitmap */
- x_per_char_metric,
- x_encode_char,
- x_compute_glyph_string_overhangs,
- x_draw_glyph_string,
- x_define_frame_cursor,
- x_clear_frame_area,
- x_draw_window_cursor,
- x_draw_vertical_window_border,
- x_shift_glyphs_for_insert
-};
+ x_clear_window_mouse_face,
+ x_get_glyph_overhangs,
+ x_fix_overlapping_area,
+ x_draw_fringe_bitmap,
+ 0, /* define_fringe_bitmap */
+ 0, /* destroy_fringe_bitmap */
+ x_per_char_metric,
+ x_encode_char,
+ x_compute_glyph_string_overhangs,
+ x_draw_glyph_string,
+ x_define_frame_cursor,
+ x_clear_frame_area,
+ x_draw_window_cursor,
+ x_draw_vertical_window_border,
+ x_shift_glyphs_for_insert
+ };
+
+
+/* This function is called when the last frame on a display is deleted. */
+void
+x_delete_frame_display (struct display *display)
+{
+ /* We don't do anything, the connection to the X server must remain
+ open. */
+}
+
+
+struct display *
+x_create_frame_display (struct x_display_info *dpyinfo)
+{
+ struct display *display;
+
+ display = create_display ();
+
+ display->type = output_x_window;
+ display->display_info.x = dpyinfo;
+ dpyinfo->frame_display = display;
+
+ display->clear_frame_hook = x_clear_frame;
+ display->ins_del_lines_hook = x_ins_del_lines;
+ display->delete_glyphs_hook = x_delete_glyphs;
+ display->ring_bell_hook = XTring_bell;
+ display->reset_terminal_modes_hook = XTreset_terminal_modes;
+ display->set_terminal_modes_hook = XTset_terminal_modes;
+ display->update_begin_hook = x_update_begin;
+ display->update_end_hook = x_update_end;
+ display->set_terminal_window_hook = XTset_terminal_window;
+ display->read_socket_hook = XTread_socket;
+ display->frame_up_to_date_hook = XTframe_up_to_date;
+ display->mouse_position_hook = XTmouse_position;
+ display->frame_rehighlight_hook = XTframe_rehighlight;
+ display->frame_raise_lower_hook = XTframe_raise_lower;
+ display->set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar;
+ display->condemn_scroll_bars_hook = XTcondemn_scroll_bars;
+ display->redeem_scroll_bar_hook = XTredeem_scroll_bar;
+ display->judge_scroll_bars_hook = XTjudge_scroll_bars;
+
+ display->delete_frame_hook = x_destroy_window;
+ display->delete_display_hook = x_delete_frame_display;
+
+ display->rif = &x_redisplay_interface;
+ display->scroll_region_ok = 1; /* We'll scroll partial frames. */
+ display->char_ins_del_ok = 1;
+ display->line_ins_del_ok = 1; /* We'll just blt 'em. */
+ display->fast_clear_end_of_line = 1; /* X does this well. */
+ display->memory_below_frame = 0; /* We don't remember what scrolls
+ off the bottom. */
+
+ return display;
+}
void
x_initialize ()
{
- rif = &x_redisplay_interface;
-
- clear_frame_hook = x_clear_frame;
- ins_del_lines_hook = x_ins_del_lines;
- delete_glyphs_hook = x_delete_glyphs;
- ring_bell_hook = XTring_bell;
- reset_terminal_modes_hook = XTreset_terminal_modes;
- set_terminal_modes_hook = XTset_terminal_modes;
- update_begin_hook = x_update_begin;
- update_end_hook = x_update_end;
- set_terminal_window_hook = XTset_terminal_window;
- read_socket_hook = XTread_socket;
- frame_up_to_date_hook = XTframe_up_to_date;
- mouse_position_hook = XTmouse_position;
- frame_rehighlight_hook = XTframe_rehighlight;
- frame_raise_lower_hook = XTframe_raise_lower;
- set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar;
- condemn_scroll_bars_hook = XTcondemn_scroll_bars;
- redeem_scroll_bar_hook = XTredeem_scroll_bar;
- judge_scroll_bars_hook = XTjudge_scroll_bars;
-
- scroll_region_ok = 1; /* we'll scroll partial frames */
- char_ins_del_ok = 1;
- line_ins_del_ok = 1; /* we'll just blt 'em */
- fast_clear_end_of_line = 1; /* X does this well */
- memory_below_frame = 0; /* we don't remember what scrolls
- off the bottom */
baud_rate = 19200;
x_noop_count = 0;
XSetIOErrorHandler (x_io_error_quitter);
/* Disable Window Change signals; they are handled by X events. */
+#if 0 /* Don't. We may want to open tty frames later. */
#ifdef SIGWINCH
signal (SIGWINCH, SIG_DFL);
#endif /* SIGWINCH */
+#endif
signal (SIGPIPE, x_connection_signal);
}