aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2004-01-05 05:54:35 +0000
committerKaroly Lorentey2004-01-05 05:54:35 +0000
commit428a555ec5d5736a3eede739e9b42bd9d33b4364 (patch)
tree3519bb5d304066b1279ffcca377aaf22a83203c2 /src
parentf02480ab7ba2dd3529d252fa5dc5938d6fc32351 (diff)
downloademacs-428a555ec5d5736a3eede739e9b42bd9d33b4364.tar.gz
emacs-428a555ec5d5736a3eede739e9b42bd9d33b4364.zip
Converted display hooks to be display-local. Plus many bugfixes.
lib-src/emacsclient.c (window_change_signal): Renamed to pass_signal_to_emacs. (init_signal): Pass SIGINT and SIGQUIT to the emacs process. lisp/faces.el (face-valid-attribute-values): Use the window-system function, not the variable. (read-face-attribute, face-spec-set-match-display, frame-set-background-mode) (face-set-after-frame-default): Ditto. lisp/frame.el (make-frame-on-tty): Added interactive declaration (suggested by Robert J. Chassell). Use tty-create-frame-with-faces, not make-terminal-frame. src/termhooks.h (struct display_method): Renamed to display for brevity. (struct display): Added all display hook variables as members of this structure. Added next_display, reference_count, type and display_info components. (FRAME_MUST_WRITE_SPACES, FRAME_FAST_CLEAR_END_OF_LINE, FRAME_LINE_INS_DEL_OK) (FRAME_CHAR_INS_DEL_OK, FRAME_SCROLL_REGION_OK, FRAME_SCROLL_REGION_COST) (FRAME_MEMORY_BELOW_FRAME, FRAME_RIF): Updated for struct display. (FRAME_DISPLAY): New macro. (create_display, delete_display): New prototypes. src/frame.h (struct frame): Added `display' member, removed display_method. (FRAME_LIVE_P): Look at f->display, not f->output_data. src/termchar.h (struct tty_display_info): Removed display_method component. (FRAME_TTY): Use the display structure, not output_data. src/term.c (display_list): New variable. (cursor_to_hook, raw_cursor_to_hook, clear_to_end_hook, clear_frame_hook) (clear_end_of_line_hook, ins_del_lines_hook, delete_glyphs_hook) (ring_bell_hook, reset_terminal_modes_hook, set_terminal_modes_hook) (update_begin_hook, update_end_hook, set_terminal_window_hook) (insert_glyphs_hook, write_glyphs_hook, delete_glyphs_hoo, read_socket_hook) (frame_up_to_date_hook, mouse_position_hook, frame_rehighlight_hook) (frame_raise_lower_hook, set_vertical_scroll_bar_hook, condemn_scroll_bars_hook) (redeem_scroll_bar_hook, judge_scroll_bars_hook): Moved to struct display. (tty_display_method_template): Removed. (syms_of_term): Don't initialize tty_display_method_template. (ring_bell, set_terminal_modes, reset_terminal_modes, update_begin) (update_end, set_terminal_window, cursor_to, raw_cursor_to, clear_to_end) (clear_frame, clear_end_of_line, write_glyphs, insert_glyphs) (delete_glyphs, ins_del_lines): Access display hooks through the frame pointer. (Ftty_display_color_p): Use the frame given as a parameter, or else return nil. (Ftty_display_color_cells): Ditto. (get_named_tty): Renamed to get_named_tty_display, changed return type to struct display. (term_dummy_init): Renamed to initial_term_init. Create and return an initial display. (term_init): Initialize a new struct display and return a pointer to it instead of tty_display_info. Removed frame initialization kludge. (Fdelete_tty): Updated for struct display. (delete_tty): The parameter type is now struct display, not tty_display_info. Delete the display, too. (create_tty_output): New function for creating tty_output structures. (delete_tty_output): New function for deleting tty_output structures. (create_display): New function for creating and registering display structures. (delete_display): New function for deleting and unregistering display structures. src/dispextern.h: Updated prototypes. src/dispnew.c: Include frame.h before termhooks.h. (init_display): Updated term_init call to new signature. src/emacs.c: Include frame.h (for termhooks.h). src/keymap.c: Ditto. src/lread.c: Ditto. src/xsmfns.c: Ditto. src/process.c: Include frame.h before termhooks.h. src/frame.c (Fwindow_system): New function. (syms_of_frame): Initialize it. (make_terminal_frame): Open the terminal device before creating the new frame. Disable scrollbars here, term_init cannot do that anymore. (Fdelete_frame): Use the new delete_frame_hook, don't do display-specific frame deletion here. Ditto for delete_display_hook. (Fmouse_position, Fmouse_pixel_position, Fraise_frame, Flower_frame) (Fredirect_frame_focus): Access display hooks through the frame pointer. src/keyboard.c: Include frame.h before termhooks.h. (start_polling, input_polling_used, stop_polling, gobble_input): Ignore read_socket_hook. (kbd_buffer_get_event, Fset_input_mode): Access display hooks through the frame pointer. (read_avail_input): Loop through all display devices for and call all read_socket_hook functions. Check ttys even if read_socket_hook returned an error. src/sysdep.c (discard_tty_input): Ignore read_socket_hook. (stuff_char): Don't do anything if the current frame is not on a termcap display. (request_sigio, unrequest_sigio): Ignore read_socket_hook. (init_sys_modes): Always call narrow_foreground_group. Set up terminal modes and sigio even under X. src/xdisp.c (message2_nolog, message3_nolog, redisplay_internal) (set_vertical_scroll_bar, redisplay_window): Access display hooks through the frame pointer. (echo_area_display): Don't be afraid of termcap frames during an X+tty combo session. src/xfaces.c: Include termhooks.h. (Ftty_supports_face_attributes_p): Use the given frame, not selected_frame. src/xfns.c (x_set_scroll_bar_foreground, x_set_scroll_bar_background): Access display hooks through the frame pointer. (Fx_create_frame, x_create_tip_frame): Initialize the frame's display structure. src/xmenu.c: Include termhooks.h after frame.h. src/xselect.c (x_own_selection, some_frame_on_display, x_get_foreign_selection) (Fx_disown_selection_internal, Fx_get_cut_buffer_internal) (Fx_store_cut_buffer_internal, Fx_rotate_cut_buffers_internal): Don't do anything if the selected frame is not an X frame. src/xterm.c (x_display_method): Removed. (x_create_frame_display, x_delete_frame_display): New functions for handling struct display objects. (x_term_init): Set up a new struct display object, too. (x_delete_display): Delete the struct display corresponding to the X display. (x_initialize): Moved hook initialization to x_create_frame_display. src/xterm.h (x_display_method): Removed. (struct x_display_info): Added frame_display component. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-44
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in22
-rw-r--r--src/cm.c1
-rw-r--r--src/dispextern.h6
-rw-r--r--src/dispnew.c10
-rw-r--r--src/emacs.c1
-rw-r--r--src/frame.c151
-rw-r--r--src/frame.h39
-rw-r--r--src/indent.c1
-rw-r--r--src/keyboard.c51
-rw-r--r--src/keymap.c1
-rw-r--r--src/lread.c1
-rw-r--r--src/print.c1
-rw-r--r--src/process.c2
-rw-r--r--src/scroll.c1
-rw-r--r--src/sysdep.c30
-rw-r--r--src/term.c462
-rw-r--r--src/termchar.h6
-rw-r--r--src/termhooks.h451
-rw-r--r--src/window.c1
-rw-r--r--src/xdisp.c42
-rw-r--r--src/xfaces.c3
-rw-r--r--src/xfns.c24
-rw-r--r--src/xmenu.c2
-rw-r--r--src/xselect.c52
-rw-r--r--src/xsmfns.c1
-rw-r--r--src/xterm.c103
-rw-r--r--src/xterm.h6
27 files changed, 796 insertions, 675 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 32215899a4a..94579aed476 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1047,7 +1047,7 @@ ccl.o: ccl.c ccl.h charset.h coding.h $(config_h)
1047charset.o: charset.c charset.h buffer.h coding.h composite.h disptab.h \ 1047charset.o: charset.c charset.h buffer.h coding.h composite.h disptab.h \
1048 $(config_h) 1048 $(config_h)
1049coding.o: coding.c coding.h ccl.h buffer.h charset.h intervals.h composite.h window.h $(config_h) 1049coding.o: coding.c coding.h ccl.h buffer.h charset.h intervals.h composite.h window.h $(config_h)
1050cm.o: cm.c frame.h cm.h termhooks.h systty.h termchar.h $(config_h) 1050cm.o: cm.c frame.h cm.h termhooks.h termchar.h $(config_h)
1051cmds.o: cmds.c syntax.h buffer.h charset.h commands.h window.h $(config_h) \ 1051cmds.o: cmds.c syntax.h buffer.h charset.h commands.h window.h $(config_h) \
1052 msdos.h dispextern.h 1052 msdos.h dispextern.h
1053pre-crt0.o: pre-crt0.c 1053pre-crt0.o: pre-crt0.c
@@ -1055,7 +1055,7 @@ ecrt0.o: ecrt0.c $(config_h)
1055 CRT0_COMPILE ${srcdir}/ecrt0.c 1055 CRT0_COMPILE ${srcdir}/ecrt0.c
1056dired.o: dired.c commands.h buffer.h $(config_h) charset.h coding.h regex.h \ 1056dired.o: dired.c commands.h buffer.h $(config_h) charset.h coding.h regex.h \
1057 systime.h 1057 systime.h
1058dispnew.o: dispnew.c systty.h systime.h commands.h process.h frame.h \ 1058dispnew.o: dispnew.c systime.h commands.h process.h frame.h \
1059 window.h buffer.h dispextern.h termchar.h termopts.h termhooks.h cm.h \ 1059 window.h buffer.h dispextern.h termchar.h termopts.h termhooks.h cm.h \
1060 disptab.h \ 1060 disptab.h \
1061 xterm.h blockinput.h atimer.h charset.h msdos.h composite.h keyboard.h \ 1061 xterm.h blockinput.h atimer.h charset.h msdos.h composite.h keyboard.h \
@@ -1073,19 +1073,19 @@ fileio.o: fileio.c window.h buffer.h systime.h $(INTERVAL_SRC) charset.h \
1073filelock.o: filelock.c buffer.h systime.h epaths.h $(config_h) 1073filelock.o: filelock.c buffer.h systime.h epaths.h $(config_h)
1074filemode.o: filemode.c $(config_h) 1074filemode.o: filemode.c $(config_h)
1075frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \ 1075frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \
1076 blockinput.h systty.h atimer.h systime.h buffer.h charset.h fontset.h \ 1076 blockinput.h atimer.h systime.h buffer.h charset.h fontset.h \
1077 msdos.h dosfns.h dispextern.h $(config_h) 1077 msdos.h dosfns.h dispextern.h $(config_h)
1078fontset.o: dispextern.h fontset.h fontset.c ccl.h buffer.h charset.h frame.h \ 1078fontset.o: dispextern.h fontset.h fontset.c ccl.h buffer.h charset.h frame.h \
1079 keyboard.h termhooks.h $(config_h) 1079 keyboard.h termhooks.h $(config_h)
1080getloadavg.o: getloadavg.c $(config_h) 1080getloadavg.o: getloadavg.c $(config_h)
1081indent.o: indent.c frame.h window.h systty.h indent.h buffer.h $(config_h) termchar.h \ 1081indent.o: indent.c frame.h window.h indent.h buffer.h $(config_h) termchar.h \
1082 termopts.h disptab.h region-cache.h charset.h composite.h dispextern.h \ 1082 termopts.h disptab.h region-cache.h charset.h composite.h dispextern.h \
1083 keyboard.h 1083 keyboard.h
1084insdel.o: insdel.c window.h buffer.h $(INTERVAL_SRC) blockinput.h charset.h \ 1084insdel.o: insdel.c window.h buffer.h $(INTERVAL_SRC) blockinput.h charset.h \
1085 dispextern.h atimer.h systime.h $(config_h) 1085 dispextern.h atimer.h systime.h $(config_h)
1086keyboard.o: keyboard.c termchar.h termhooks.h termopts.h buffer.h charset.h \ 1086keyboard.o: keyboard.c termchar.h termhooks.h termopts.h buffer.h charset.h \
1087 commands.h frame.h window.h macros.h disptab.h keyboard.h syssignal.h \ 1087 commands.h frame.h window.h macros.h disptab.h keyboard.h syssignal.h \
1088 systty.h systime.h dispextern.h syntax.h $(INTERVAL_SRC) blockinput.h \ 1088 systime.h dispextern.h syntax.h $(INTERVAL_SRC) blockinput.h \
1089 atimer.h xterm.h puresize.h msdos.h $(config_h) 1089 atimer.h xterm.h puresize.h msdos.h $(config_h)
1090keymap.o: keymap.c buffer.h commands.h keyboard.h termhooks.h blockinput.h \ 1090keymap.o: keymap.c buffer.h commands.h keyboard.h termhooks.h blockinput.h \
1091 atimer.h systime.h puresize.h charset.h intervals.h $(config_h) 1091 atimer.h systime.h puresize.h charset.h intervals.h $(config_h)
@@ -1110,7 +1110,7 @@ process.o: process.c process.h buffer.h window.h termhooks.h termopts.h \
1110 keyboard.h $(config_h) 1110 keyboard.h $(config_h)
1111regex.o: regex.c syntax.h buffer.h $(config_h) regex.h category.h charset.h 1111regex.o: regex.c syntax.h buffer.h $(config_h) regex.h category.h charset.h
1112region-cache.o: region-cache.c buffer.h region-cache.h 1112region-cache.o: region-cache.c buffer.h region-cache.h
1113scroll.o: scroll.c systty.h termchar.h dispextern.h frame.h msdos.h keyboard.h \ 1113scroll.o: scroll.c termchar.h dispextern.h frame.h msdos.h keyboard.h \
1114 termhooks.h $(config_h) 1114 termhooks.h $(config_h)
1115search.o: search.c regex.h commands.h buffer.h region-cache.h syntax.h \ 1115search.o: search.c regex.h commands.h buffer.h region-cache.h syntax.h \
1116 blockinput.h atimer.h systime.h category.h charset.h composite.h $(config_h) 1116 blockinput.h atimer.h systime.h category.h charset.h composite.h $(config_h)
@@ -1120,7 +1120,7 @@ syntax.o: syntax.c syntax.h buffer.h commands.h category.h charset.h \
1120sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \ 1120sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \
1121 process.h dispextern.h termhooks.h termchar.h termopts.h \ 1121 process.h dispextern.h termhooks.h termchar.h termopts.h \
1122 frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h $(config_h) 1122 frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h $(config_h)
1123term.o: term.c systty.h termchar.h termhooks.h termopts.h $(config_h) cm.h frame.h \ 1123term.o: term.c termchar.h termhooks.h termopts.h $(config_h) cm.h frame.h \
1124 disptab.h dispextern.h keyboard.h charset.h coding.h ccl.h msdos.h 1124 disptab.h dispextern.h keyboard.h charset.h coding.h ccl.h msdos.h
1125termcap.o: termcap.c $(config_h) 1125termcap.o: termcap.c $(config_h)
1126terminfo.o: terminfo.c $(config_h) 1126terminfo.o: terminfo.c $(config_h)
@@ -1134,18 +1134,18 @@ w16select.o: w16select.c dispextern.h frame.h blockinput.h atimer.h systime.h \
1134 msdos.h $(config_h) 1134 msdos.h $(config_h)
1135widget.o: widget.c xterm.h frame.h dispextern.h widgetprv.h \ 1135widget.o: widget.c xterm.h frame.h dispextern.h widgetprv.h \
1136 $(srcdir)/../lwlib/lwlib.h $(config_h) 1136 $(srcdir)/../lwlib/lwlib.h $(config_h)
1137window.o: window.c indent.h commands.h frame.h window.h buffer.h systty.h termchar.h \ 1137window.o: window.c indent.h commands.h frame.h window.h buffer.h termchar.h \
1138 termhooks.h disptab.h keyboard.h dispextern.h msdos.h composite.h \ 1138 termhooks.h disptab.h keyboard.h dispextern.h msdos.h composite.h \
1139 $(config_h) 1139 $(config_h)
1140xdisp.o: xdisp.c macros.h commands.h process.h indent.h buffer.h dispextern.h coding.h \ 1140xdisp.o: xdisp.c macros.h commands.h process.h indent.h buffer.h dispextern.h coding.h \
1141 systty.h termchar.h frame.h window.h disptab.h termhooks.h charset.h $(config_h) \ 1141 termchar.h frame.h window.h disptab.h termhooks.h charset.h $(config_h) \
1142 msdos.h composite.h fontset.h blockinput.h atimer.h systime.h keymap.h 1142 msdos.h composite.h fontset.h blockinput.h atimer.h systime.h keymap.h
1143xfaces.o: xfaces.c dispextern.h frame.h xterm.h buffer.h blockinput.h \ 1143xfaces.o: xfaces.c dispextern.h frame.h xterm.h buffer.h blockinput.h \
1144 window.h charset.h msdos.h dosfns.h composite.h atimer.h systime.h \ 1144 window.h charset.h msdos.h dosfns.h composite.h atimer.h systime.h \
1145 termchar.h $(config_h) 1145 termchar.h $(config_h)
1146xfns.o: xfns.c buffer.h frame.h window.h keyboard.h xterm.h dispextern.h \ 1146xfns.o: xfns.c buffer.h frame.h window.h keyboard.h xterm.h dispextern.h \
1147 $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h epaths.h \ 1147 $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h epaths.h \
1148 charset.h gtkutil.h systty.h termchar.h $(config_h) 1148 charset.h gtkutil.h termchar.h $(config_h)
1149xmenu.o: xmenu.c xterm.h termhooks.h window.h dispextern.h frame.h buffer.h \ 1149xmenu.o: xmenu.c xterm.h termhooks.h window.h dispextern.h frame.h buffer.h \
1150 keyboard.h $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h \ 1150 keyboard.h $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h \
1151 gtkutil.h msdos.h coding.h $(config_h) 1151 gtkutil.h msdos.h coding.h $(config_h)
@@ -1177,7 +1177,7 @@ floatfns.o: floatfns.c $(config_h)
1177fns.o: fns.c commands.h $(config_h) frame.h buffer.h charset.h keyboard.h \ 1177fns.o: fns.c commands.h $(config_h) frame.h buffer.h charset.h keyboard.h \
1178 frame.h window.h dispextern.h $(INTERVAL_SRC) coding.h md5.h 1178 frame.h window.h dispextern.h $(INTERVAL_SRC) coding.h md5.h
1179print.o: print.c process.h frame.h window.h buffer.h keyboard.h charset.h \ 1179print.o: print.c process.h frame.h window.h buffer.h keyboard.h charset.h \
1180 $(config_h) dispextern.h msdos.h composite.h systty.h termchar.h intervals.h 1180 $(config_h) dispextern.h msdos.h composite.h termchar.h intervals.h
1181lread.o: lread.c commands.h keyboard.h buffer.h epaths.h charset.h $(config_h) \ 1181lread.o: lread.c commands.h keyboard.h buffer.h epaths.h charset.h $(config_h) \
1182 termhooks.h coding.h msdos.h 1182 termhooks.h coding.h msdos.h
1183 1183
diff --git a/src/cm.c b/src/cm.c
index 1f165e90f4a..9073813dd79 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -29,7 +29,6 @@ Boston, MA 02111-1307, USA. */
29 29
30#include "cm.h" 30#include "cm.h"
31#include "termhooks.h" 31#include "termhooks.h"
32#include "systty.h" /* For emacs_tty in termchar.h */
33#include "termchar.h" 32#include "termchar.h"
34 33
35 34
diff --git a/src/dispextern.h b/src/dispextern.h
index 52ea29b8d69..a6c14da3f65 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1249,7 +1249,7 @@ struct glyph_string
1249 DESCENT = FONT->descent 1249 DESCENT = FONT->descent
1250 HEIGHT = FONT_HEIGHT (FONT) 1250 HEIGHT = FONT_HEIGHT (FONT)
1251 F_DESCENT = (FRAME_FONT (F)->descent 1251 F_DESCENT = (FRAME_FONT (F)->descent
1252 - F->output_data.x->baseline_offset) 1252 - F->device->output_data.x->baseline_offset)
1253 F_HEIGHT = FRAME_LINE_HEIGHT (F) 1253 F_HEIGHT = FRAME_LINE_HEIGHT (F)
1254*/ 1254*/
1255 1255
@@ -2748,8 +2748,8 @@ extern int per_line_cost P_ ((char *));
2748extern void calculate_costs P_ ((struct frame *)); 2748extern void calculate_costs P_ ((struct frame *));
2749extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object)); 2749extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object));
2750extern void tty_setup_colors P_ ((struct tty_display_info *, int)); 2750extern void tty_setup_colors P_ ((struct tty_display_info *, int));
2751extern struct tty_display_info *term_init P_ ((Lisp_Object, char *, char *)); 2751extern struct display *term_init P_ ((char *, char *));
2752extern struct tty_display_info *term_dummy_init P_ ((void)); 2752extern struct display *initial_term_init P_ ((void));
2753extern void fatal P_ ((/* char *, ... */)); 2753extern void fatal P_ ((/* char *, ... */));
2754void cursor_to P_ ((int, int)); 2754void cursor_to P_ ((int, int));
2755extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long)); 2755extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long));
diff --git a/src/dispnew.c b/src/dispnew.c
index be6e6330e31..3fbd8305365 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -29,10 +29,8 @@ Boston, MA 02111-1307, USA. */
29#endif 29#endif
30 30
31#include "lisp.h" 31#include "lisp.h"
32#include "systty.h" /* For emacs_tty in termchar.h */
33#include "termchar.h" 32#include "termchar.h"
34#include "termopts.h" 33#include "termopts.h"
35#include "termhooks.h"
36/* cm.h must come after dispextern.h on Windows. */ 34/* cm.h must come after dispextern.h on Windows. */
37#include "dispextern.h" 35#include "dispextern.h"
38#include "cm.h" 36#include "cm.h"
@@ -40,6 +38,7 @@ Boston, MA 02111-1307, USA. */
40#include "charset.h" 38#include "charset.h"
41#include "keyboard.h" 39#include "keyboard.h"
42#include "frame.h" 40#include "frame.h"
41#include "termhooks.h"
43#include "window.h" 42#include "window.h"
44#include "commands.h" 43#include "commands.h"
45#include "disptab.h" 44#include "disptab.h"
@@ -6634,10 +6633,11 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\
6634#endif /* VMS */ 6633#endif /* VMS */
6635 6634
6636 { 6635 {
6637 struct tty_display_info *tty; 6636 struct display *d;
6638 6637
6639 tty = term_init (selected_frame, 0, terminal_type); 6638 d = term_init (0, terminal_type);
6640 change_frame_size (XFRAME (selected_frame), FrameRows (tty), FrameCols (tty), 0, 0, 1); 6639 d->display_info.tty->top_frame = selected_frame;
6640 change_frame_size (XFRAME (selected_frame), FrameRows (d->display_info.tty), FrameCols (d->display_info.tty), 0, 0, 1);
6641 } 6641 }
6642 6642
6643 { 6643 {
diff --git a/src/emacs.c b/src/emacs.c
index d6f040f3f51..25a421cb30e 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -54,6 +54,7 @@ Boston, MA 02111-1307, USA. */
54#include "blockinput.h" 54#include "blockinput.h"
55#include "syssignal.h" 55#include "syssignal.h"
56#include "process.h" 56#include "process.h"
57#include "frame.h"
57#include "termhooks.h" 58#include "termhooks.h"
58#include "keyboard.h" 59#include "keyboard.h"
59#include "keymap.h" 60#include "keymap.h"
diff --git a/src/frame.c b/src/frame.c
index cc971edefc9..86c26b9d86b 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -42,7 +42,6 @@ Boston, MA 02111-1307, USA. */
42#include "fontset.h" 42#include "fontset.h"
43#endif 43#endif
44#include "blockinput.h" 44#include "blockinput.h"
45#include "systty.h" /* For emacs_tty in termchar.h */
46#include "termchar.h" 45#include "termchar.h"
47#include "termhooks.h" 46#include "termhooks.h"
48#include "dispextern.h" 47#include "dispextern.h"
@@ -233,6 +232,30 @@ return values. */)
233 : Qnil); 232 : Qnil);
234} 233}
235 234
235DEFUN ("window-system", Fwindow_system, Swindow_system, 0, 1, 0,
236 doc: /* The name of the window system that FRAME is displaying through.
237The value is a symbol---for instance, 'x' for X windows.
238The value is nil if Emacs is using a text-only terminal.
239
240FRAME defaults to the currently selected frame. */)
241 (frame)
242 Lisp_Object frame;
243{
244 Lisp_Object type;
245 if (NILP (frame))
246 frame = selected_frame;
247
248 type = Fframep (frame);
249
250 if (NILP (type))
251 wrong_type_argument (Qframep, frame);
252
253 if (EQ (type, Qt))
254 return Qnil;
255 else
256 return type;
257}
258
236struct frame * 259struct frame *
237make_frame (mini_p) 260make_frame (mini_p)
238 int mini_p; 261 int mini_p;
@@ -484,6 +507,7 @@ make_terminal_frame (tty_name, tty_type)
484 char *tty_type; 507 char *tty_type;
485{ 508{
486 register struct frame *f; 509 register struct frame *f;
510 struct display *display;
487 Lisp_Object frame; 511 Lisp_Object frame;
488 char name[20]; 512 char name[20];
489 513
@@ -502,6 +526,13 @@ make_terminal_frame (tty_name, tty_type)
502 if (! (NILP (Vframe_list) || CONSP (Vframe_list))) 526 if (! (NILP (Vframe_list) || CONSP (Vframe_list)))
503 Vframe_list = Qnil; 527 Vframe_list = Qnil;
504 528
529 /* Open the display before creating the new frame, because
530 create_tty_display might throw an error. */
531 if (initialized)
532 display = term_init (tty_name, tty_type);
533 else
534 display = initial_term_init ();
535
505 f = make_frame (1); 536 f = make_frame (1);
506 537
507 XSETFRAME (frame, f); 538 XSETFRAME (frame, f);
@@ -540,37 +571,29 @@ make_terminal_frame (tty_name, tty_type)
540#else 571#else
541#ifdef WINDOWSNT 572#ifdef WINDOWSNT
542 f->output_method = output_termcap; 573 f->output_method = output_termcap;
543 f->output_data.x = &tty_display; /* XXX */ 574 f->output_data.x = &tty_display; /* XXX ??? */
544#else 575#else
545#ifdef MAC_OS8 576#ifdef MAC_OS8
546 make_mac_terminal_frame (f); 577 make_mac_terminal_frame (f);
547#else 578#else
548 { 579 {
549 struct tty_display_info *tty;
550 f->output_method = output_termcap; 580 f->output_method = output_termcap;
551 581 f->display = display;
552 f->output_data.tty = (struct tty_output *) xmalloc (sizeof (struct tty_output)); 582 f->display->reference_count++;
553 bzero (f->output_data.tty, sizeof (struct tty_output)); 583 create_tty_output (f);
554 584
555 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR; 585 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
556 FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR; 586 FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
557 587
558 if (initialized) 588 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
559 { 589 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
560 /* Note that term_init may signal an error, but then it is its 590
561 responsibility to make sure this frame is deleted. */
562 f->output_data.tty->display_info = term_init (frame, tty_name, tty_type);
563 }
564 else
565 {
566 /* init_display() will reinitialize the terminal with correct values after dump. */
567 f->output_data.tty->display_info = term_dummy_init ();
568 }
569 FRAME_TTY (f)->reference_count++;
570 f->display_method = FRAME_TTY (f)->display_method;
571#ifdef MULTI_KBOARD 591#ifdef MULTI_KBOARD
572 f->kboard = FRAME_TTY (f)->kboard; 592 f->kboard = FRAME_TTY (f)->kboard;
573#endif 593#endif
594
595 /* Set the top frame to the newly created frame. */
596 FRAME_TTY (f)->top_frame = frame;
574 } 597 }
575 598
576#ifdef CANNOT_DUMP 599#ifdef CANNOT_DUMP
@@ -1397,30 +1420,26 @@ The functions are run with one arg, the frame to be deleted. */)
1397 promise that the display of the frame must be valid until we have 1420 promise that the display of the frame must be valid until we have
1398 called the window-system-dependent frame destruction routine. */ 1421 called the window-system-dependent frame destruction routine. */
1399 1422
1400 /* I think this should be done with a hook. */ 1423 if (FRAME_DISPLAY (f)->delete_frame_hook)
1401#ifdef HAVE_WINDOW_SYSTEM 1424 (*FRAME_DISPLAY (f)->delete_frame_hook) (f);
1402 if (FRAME_WINDOW_P (f)) 1425
1403 x_destroy_window (f); 1426 {
1404#endif 1427 struct display *display = FRAME_DISPLAY (f);
1405 1428
1406 if (FRAME_TERMCAP_P (f)) 1429 f->output_data.nothing = 0;
1407 { 1430 f->display = 0; /* Now the frame is dead. */
1408 int delete = 1; 1431
1409 struct tty_display_info *tty = FRAME_TTY (f); 1432 /* If needed, delete the device that this frame was on.
1410 1433 (This must be done after the frame is killed.) */
1411 if (! --tty->reference_count) 1434 display->reference_count--;
1412 { 1435 if (display->reference_count == 0)
1413 /* delete_tty would call us recursively if we don't kill the
1414 frame now. */
1415 xfree (f->output_data.tty);
1416 f->output_data.nothing = 0;
1417 delete_tty (tty);
1418 }
1419 }
1420 else
1421 { 1436 {
1422 f->output_data.nothing = 0; 1437 if (display->delete_display_hook)
1438 (*display->delete_display_hook) (display);
1439 else
1440 delete_display (display);
1423 } 1441 }
1442 }
1424 1443
1425 /* If we've deleted the last_nonminibuf_frame, then try to find 1444 /* If we've deleted the last_nonminibuf_frame, then try to find
1426 another one. */ 1445 another one. */
@@ -1535,11 +1554,11 @@ and returns whatever that function returns. */)
1535 1554
1536#ifdef HAVE_MOUSE 1555#ifdef HAVE_MOUSE
1537 /* It's okay for the hook to refrain from storing anything. */ 1556 /* It's okay for the hook to refrain from storing anything. */
1538 if (!FRAME_TERMCAP_P (f) && mouse_position_hook) 1557 if (FRAME_DISPLAY (f)->mouse_position_hook)
1539 (*mouse_position_hook) (&f, -1, 1558 (*FRAME_DISPLAY (f)->mouse_position_hook) (&f, -1,
1540 &lispy_dummy, &party_dummy, 1559 &lispy_dummy, &party_dummy,
1541 &x, &y, 1560 &x, &y,
1542 &long_dummy); 1561 &long_dummy);
1543 if (! NILP (x)) 1562 if (! NILP (x))
1544 { 1563 {
1545 col = XINT (x); 1564 col = XINT (x);
@@ -1578,12 +1597,11 @@ and nil for X and Y. */)
1578 1597
1579#ifdef HAVE_MOUSE 1598#ifdef HAVE_MOUSE
1580 /* It's okay for the hook to refrain from storing anything. */ 1599 /* It's okay for the hook to refrain from storing anything. */
1581 if (FRAME_TERMCAP_P (f) 1600 if (FRAME_DISPLAY (f)->mouse_position_hook)
1582 && mouse_position_hook) 1601 (*FRAME_DISPLAY (f)->mouse_position_hook) (&f, -1,
1583 (*mouse_position_hook) (&f, -1, 1602 &lispy_dummy, &party_dummy,
1584 &lispy_dummy, &party_dummy, 1603 &x, &y,
1585 &x, &y, 1604 &long_dummy);
1586 &long_dummy);
1587#endif 1605#endif
1588 XSETFRAME (lispy_dummy, f); 1606 XSETFRAME (lispy_dummy, f);
1589 return Fcons (lispy_dummy, Fcons (x, y)); 1607 return Fcons (lispy_dummy, Fcons (x, y));
@@ -1845,17 +1863,19 @@ doesn't support multiple overlapping frames, this function does nothing. */)
1845 (frame) 1863 (frame)
1846 Lisp_Object frame; 1864 Lisp_Object frame;
1847{ 1865{
1866 struct frame *f;
1848 if (NILP (frame)) 1867 if (NILP (frame))
1849 frame = selected_frame; 1868 frame = selected_frame;
1850 1869
1851 CHECK_LIVE_FRAME (frame); 1870 CHECK_LIVE_FRAME (frame);
1852 1871
1872 f = XFRAME (frame);
1873
1853 /* Do like the documentation says. */ 1874 /* Do like the documentation says. */
1854 Fmake_frame_visible (frame); 1875 Fmake_frame_visible (frame);
1855 1876
1856 if (FRAME_TERMCAP_P (XFRAME (frame)) 1877 if (FRAME_DISPLAY (f)->frame_raise_lower_hook)
1857 && frame_raise_lower_hook) 1878 (*FRAME_DISPLAY (f)->frame_raise_lower_hook) (f, 1);
1858 (*frame_raise_lower_hook) (XFRAME (frame), 1);
1859 1879
1860 return Qnil; 1880 return Qnil;
1861} 1881}
@@ -1869,14 +1889,17 @@ doesn't support multiple overlapping frames, this function does nothing. */)
1869 (frame) 1889 (frame)
1870 Lisp_Object frame; 1890 Lisp_Object frame;
1871{ 1891{
1892 struct frame *f;
1893
1872 if (NILP (frame)) 1894 if (NILP (frame))
1873 frame = selected_frame; 1895 frame = selected_frame;
1874 1896
1875 CHECK_LIVE_FRAME (frame); 1897 CHECK_LIVE_FRAME (frame);
1876 1898
1877 if (FRAME_TERMCAP_P (XFRAME (frame)) 1899 f = XFRAME (frame);
1878 && frame_raise_lower_hook) 1900
1879 (*frame_raise_lower_hook) (XFRAME (frame), 0); 1901 if (FRAME_DISPLAY (f)->frame_raise_lower_hook)
1902 (*FRAME_DISPLAY (f)->frame_raise_lower_hook) (f, 0);
1880 1903
1881 return Qnil; 1904 return Qnil;
1882} 1905}
@@ -1910,6 +1933,8 @@ The redirection lasts until `redirect-frame-focus' is called to change it. */)
1910 (frame, focus_frame) 1933 (frame, focus_frame)
1911 Lisp_Object frame, focus_frame; 1934 Lisp_Object frame, focus_frame;
1912{ 1935{
1936 struct frame *f;
1937
1913 /* Note that we don't check for a live frame here. It's reasonable 1938 /* Note that we don't check for a live frame here. It's reasonable
1914 to redirect the focus of a frame you're about to delete, if you 1939 to redirect the focus of a frame you're about to delete, if you
1915 know what other frame should receive those keystrokes. */ 1940 know what other frame should receive those keystrokes. */
@@ -1918,11 +1943,12 @@ The redirection lasts until `redirect-frame-focus' is called to change it. */)
1918 if (! NILP (focus_frame)) 1943 if (! NILP (focus_frame))
1919 CHECK_LIVE_FRAME (focus_frame); 1944 CHECK_LIVE_FRAME (focus_frame);
1920 1945
1921 XFRAME (frame)->focus_frame = focus_frame; 1946 f = XFRAME (frame);
1947
1948 f->focus_frame = focus_frame;
1922 1949
1923 if (!FRAME_TERMCAP_P (XFRAME (frame)) 1950 if (FRAME_DISPLAY (f)->frame_rehighlight_hook)
1924 && frame_rehighlight_hook) 1951 (*FRAME_DISPLAY (f)->frame_rehighlight_hook) (f);
1925 (*frame_rehighlight_hook) (XFRAME (frame));
1926 1952
1927 return Qnil; 1953 return Qnil;
1928} 1954}
@@ -4198,6 +4224,7 @@ This variable is local to the current terminal and cannot be buffer-local. */);
4198 defsubr (&Sactive_minibuffer_window); 4224 defsubr (&Sactive_minibuffer_window);
4199 defsubr (&Sframep); 4225 defsubr (&Sframep);
4200 defsubr (&Sframe_live_p); 4226 defsubr (&Sframe_live_p);
4227 defsubr (&Swindow_system);
4201 defsubr (&Smake_terminal_frame); 4228 defsubr (&Smake_terminal_frame);
4202 defsubr (&Shandle_switch_frame); 4229 defsubr (&Shandle_switch_frame);
4203 defsubr (&Signore_event); 4230 defsubr (&Signore_event);
diff --git a/src/frame.h b/src/frame.h
index 4bd52204886..9b6d6afa1e6 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -68,7 +68,7 @@ enum text_cursor_kinds
68#define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel) 68#define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
69#define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel) 69#define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
70 70
71struct device; 71struct display;
72 72
73struct frame 73struct frame
74{ 74{
@@ -256,26 +256,24 @@ struct frame
256 /* Canonical Y unit. Height of a line, in pixels. */ 256 /* Canonical Y unit. Height of a line, in pixels. */
257 int line_height; 257 int line_height;
258 258
259 /* The display hooks to use with this frame. */ 259 /* The output method says how the contents of this frame are
260 struct display_method *display_method; 260 displayed. It could be using termcap, or using an X window.
261 261 This must be the same as the display->type. */
262 /* The output method says how the contents of this frame
263 are displayed. It could be using termcap, or using an X window. */
264 enum output_method output_method; 262 enum output_method output_method;
265 263
266 /* A structure of auxiliary data used for displaying the contents. 264 /* The display that this frame uses. If this is NULL, then the
267 struct tty_output is used for termcap frames; 265 frame is deleted. */
268 it is defined in term.h. 266 struct display *display;
269 struct x_output is used for X window frames; 267
270 it is defined in xterm.h. 268 /* Display-dependent, frame-local auxiliary data used for displaying
271 struct w32_output is used for W32 window frames; 269 the contents. When the frame is deleted, this data is deleted as
272 it is defined in w32term.h. */ 270 well. */
273 union output_data 271 union output_data
274 { 272 {
275 struct tty_output *tty; 273 struct tty_output *tty; /* termchar.h */
276 struct x_output *x; 274 struct x_output *x; /* xterm.h */
277 struct w32_output *w32; 275 struct w32_output *w32; /* w32term.h */
278 struct mac_output *mac; 276 struct mac_output *mac; /* macterm.h */
279 EMACS_INT nothing; 277 EMACS_INT nothing;
280 } 278 }
281 output_data; 279 output_data;
@@ -291,11 +289,12 @@ struct frame
291 int left_fringe_width, right_fringe_width; 289 int left_fringe_width, right_fringe_width;
292 290
293#ifdef MULTI_KBOARD 291#ifdef MULTI_KBOARD
292 /* XXX Maybe this should be moved to struct display, too. */
294 /* A pointer to the kboard structure associated with this frame. 293 /* A pointer to the kboard structure associated with this frame.
295 For termcap frames, it will be the same as 294 For termcap frames, it will be the same as
296 output_data.tty->display_info->kboard. 295 display->display_info.tty->kboard.
297 For X frames, it will be the same as 296 For X frames, it will be the same as
298 output_data.x->display_info->kboard. */ 297 display->display_info.x->kboard. */
299 struct kboard *kboard; 298 struct kboard *kboard;
300#endif 299#endif
301 300
@@ -486,7 +485,7 @@ typedef struct frame *FRAME_PTR;
486#endif 485#endif
487 486
488/* Nonzero if frame F is still alive (not deleted). */ 487/* Nonzero if frame F is still alive (not deleted). */
489#define FRAME_LIVE_P(f) ((f)->output_data.nothing != 0) 488#define FRAME_LIVE_P(f) ((f)->display != 0)
490 489
491/* Nonzero if frame F is a minibuffer-only frame. */ 490/* Nonzero if frame F is a minibuffer-only frame. */
492#define FRAME_MINIBUF_ONLY_P(f) \ 491#define FRAME_MINIBUF_ONLY_P(f) \
diff --git a/src/indent.c b/src/indent.c
index 0eca2f3410e..1b3e5847510 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -30,7 +30,6 @@ Boston, MA 02111-1307, USA. */
30#include "keyboard.h" 30#include "keyboard.h"
31#include "frame.h" 31#include "frame.h"
32#include "window.h" 32#include "window.h"
33#include "systty.h" /* For emacs_tty in termchar.h */
34#include "termchar.h" 33#include "termchar.h"
35#include "termopts.h" 34#include "termopts.h"
36#include "disptab.h" 35#include "disptab.h"
diff --git a/src/keyboard.c b/src/keyboard.c
index df5c65c3341..ff62a07c25f 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -23,13 +23,12 @@ Boston, MA 02111-1307, USA. */
23#include <signal.h> 23#include <signal.h>
24#include <stdio.h> 24#include <stdio.h>
25#include "lisp.h" 25#include "lisp.h"
26#include "systty.h" /* This must be included befor termchar.h. */
27#include "termchar.h" 26#include "termchar.h"
28#include "termopts.h" 27#include "termopts.h"
28#include "frame.h"
29#include "termhooks.h" 29#include "termhooks.h"
30#include "macros.h" 30#include "macros.h"
31#include "keyboard.h" 31#include "keyboard.h"
32#include "frame.h"
33#include "window.h" 32#include "window.h"
34#include "commands.h" 33#include "commands.h"
35#include "buffer.h" 34#include "buffer.h"
@@ -2065,7 +2064,10 @@ void
2065start_polling () 2064start_polling ()
2066{ 2065{
2067#ifdef POLL_FOR_INPUT 2066#ifdef POLL_FOR_INPUT
2068 if (read_socket_hook && !interrupt_input) 2067 /* XXX This condition was (read_socket_hook && !interrupt_input),
2068 but read_socket_hook is not global anymore. Let's pretend that
2069 it's always set. */
2070 if (!interrupt_input)
2069 { 2071 {
2070 /* Turn alarm handling on unconditionally. It might have 2072 /* Turn alarm handling on unconditionally. It might have
2071 been turned off in process.c. */ 2073 been turned off in process.c. */
@@ -2099,7 +2101,10 @@ int
2099input_polling_used () 2101input_polling_used ()
2100{ 2102{
2101#ifdef POLL_FOR_INPUT 2103#ifdef POLL_FOR_INPUT
2102 return read_socket_hook && !interrupt_input; 2104 /* XXX This condition was (read_socket_hook && !interrupt_input),
2105 but read_socket_hook is not global anymore. Let's pretend that
2106 it's always set. */
2107 return !interrupt_input;
2103#else 2108#else
2104 return 0; 2109 return 0;
2105#endif 2110#endif
@@ -2111,7 +2116,10 @@ void
2111stop_polling () 2116stop_polling ()
2112{ 2117{
2113#ifdef POLL_FOR_INPUT 2118#ifdef POLL_FOR_INPUT
2114 if (read_socket_hook && !interrupt_input) 2119 /* XXX This condition was (read_socket_hook && !interrupt_input),
2120 but read_socket_hook is not global anymore. Let's pretend that
2121 it's always set. */
2122 if (!interrupt_input)
2115 ++poll_suppress_count; 2123 ++poll_suppress_count;
2116#endif 2124#endif
2117} 2125}
@@ -4081,7 +4089,8 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
4081 If there is no valid info, it does not store anything 4089 If there is no valid info, it does not store anything
4082 so x remains nil. */ 4090 so x remains nil. */
4083 x = Qnil; 4091 x = Qnil;
4084 (*mouse_position_hook) (&f, 0, &bar_window, &part, &x, &y, &time); 4092 if (f && FRAME_DISPLAY (f)->mouse_position_hook) /* XXX Can f or mouse_position_hook be NULL here? */
4093 (*FRAME_DISPLAY (f)->mouse_position_hook) (&f, 0, &bar_window, &part, &x, &y, &time);
4085 4094
4086 obj = Qnil; 4095 obj = Qnil;
4087 4096
@@ -6516,7 +6525,10 @@ gobble_input (expected)
6516 } 6525 }
6517 else 6526 else
6518#ifdef POLL_FOR_INPUT 6527#ifdef POLL_FOR_INPUT
6519 if (read_socket_hook && !interrupt_input && poll_suppress_count == 0) 6528 /* XXX This condition was (read_socket_hook && !interrupt_input),
6529 but read_socket_hook is not global anymore. Let's pretend that
6530 it's always set. */
6531 if (!interrupt_input && poll_suppress_count == 0)
6520 { 6532 {
6521 SIGMASKTYPE mask; 6533 SIGMASKTYPE mask;
6522 mask = sigblock (sigmask (SIGALRM)); 6534 mask = sigblock (sigmask (SIGALRM));
@@ -6600,11 +6612,21 @@ read_avail_input (expected)
6600 for (i = 0; i < KBD_BUFFER_SIZE; i++) 6612 for (i = 0; i < KBD_BUFFER_SIZE; i++)
6601 EVENT_INIT (buf[i]); 6613 EVENT_INIT (buf[i]);
6602 6614
6603 if (read_socket_hook) 6615 {
6604 /* No need for FIONREAD or fcntl; just say don't wait. */ 6616 struct display *d;
6605 nread = (*read_socket_hook) (buf, KBD_BUFFER_SIZE, expected);
6606 6617
6607 if (!nread && tty_list) 6618 for (d = display_list; d; d = d->next_display)
6619 {
6620 if (d->read_socket_hook)
6621 /* No need for FIONREAD or fcntl; just say don't wait. */
6622 nread = (*d->read_socket_hook) (buf, KBD_BUFFER_SIZE, expected);
6623
6624 if (nread > 0)
6625 break;
6626 }
6627 }
6628
6629 if (nread <= 0 && tty_list)
6608 { 6630 {
6609 /* Using KBD_BUFFER_SIZE - 1 here avoids reading more than 6631 /* Using KBD_BUFFER_SIZE - 1 here avoids reading more than
6610 the kbd_buffer can really hold. That may prevent loss 6632 the kbd_buffer can really hold. That may prevent loss
@@ -10426,6 +10448,11 @@ See also `current-input-mode'. */)
10426 (interrupt, flow, meta, quit) 10448 (interrupt, flow, meta, quit)
10427 Lisp_Object interrupt, flow, meta, quit; 10449 Lisp_Object interrupt, flow, meta, quit;
10428{ 10450{
10451 /* XXX This function needs to be revised for multi-device support.
10452 Currently it compiles fine, but its semantics are wrong. It sets
10453 global parameters (e.g. interrupt_input) based on only the
10454 current frame's device. */
10455
10429 if (!NILP (quit) 10456 if (!NILP (quit)
10430 && (!INTEGERP (quit) || XINT (quit) < 0 || XINT (quit) > 0400)) 10457 && (!INTEGERP (quit) || XINT (quit) < 0 || XINT (quit) > 0400))
10431 error ("set-input-mode: QUIT must be an ASCII character"); 10458 error ("set-input-mode: QUIT must be an ASCII character");
@@ -10442,7 +10469,7 @@ See also `current-input-mode'. */)
10442 10469
10443#ifdef SIGIO 10470#ifdef SIGIO
10444/* Note SIGIO has been undef'd if FIONREAD is missing. */ 10471/* Note SIGIO has been undef'd if FIONREAD is missing. */
10445 if (read_socket_hook) 10472 if (FRAME_DISPLAY (SELECTED_FRAME ())->read_socket_hook)
10446 { 10473 {
10447 /* When using X, don't give the user a real choice, 10474 /* When using X, don't give the user a real choice,
10448 because we haven't implemented the mechanisms to support it. */ 10475 because we haven't implemented the mechanisms to support it. */
diff --git a/src/keymap.c b/src/keymap.c
index 5f1f2a3f3a3..d03c84aa69d 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -27,6 +27,7 @@ Boston, MA 02111-1307, USA. */
27#include "buffer.h" 27#include "buffer.h"
28#include "charset.h" 28#include "charset.h"
29#include "keyboard.h" 29#include "keyboard.h"
30#include "frame.h"
30#include "termhooks.h" 31#include "termhooks.h"
31#include "blockinput.h" 32#include "blockinput.h"
32#include "puresize.h" 33#include "puresize.h"
diff --git a/src/lread.c b/src/lread.c
index 603c871c4df..fae47300bd6 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -33,6 +33,7 @@ Boston, MA 02111-1307, USA. */
33#include <epaths.h> 33#include <epaths.h>
34#include "commands.h" 34#include "commands.h"
35#include "keyboard.h" 35#include "keyboard.h"
36#include "frame.h"
36#include "termhooks.h" 37#include "termhooks.h"
37#include "coding.h" 38#include "coding.h"
38 39
diff --git a/src/print.c b/src/print.c
index 2560f5f3e26..3069f732829 100644
--- a/src/print.c
+++ b/src/print.c
@@ -30,7 +30,6 @@ Boston, MA 02111-1307, USA. */
30#include "window.h" 30#include "window.h"
31#include "process.h" 31#include "process.h"
32#include "dispextern.h" 32#include "dispextern.h"
33#include "systty.h" /* For emacs_tty in termchar.h */
34#include "termchar.h" 33#include "termchar.h"
35#include "intervals.h" 34#include "intervals.h"
36 35
diff --git a/src/process.c b/src/process.c
index 906497f14ed..70c3efa1dda 100644
--- a/src/process.c
+++ b/src/process.c
@@ -126,11 +126,11 @@ Boston, MA 02111-1307, USA. */
126#include "charset.h" 126#include "charset.h"
127#include "coding.h" 127#include "coding.h"
128#include "process.h" 128#include "process.h"
129#include "frame.h"
129#include "termhooks.h" 130#include "termhooks.h"
130#include "termopts.h" 131#include "termopts.h"
131#include "commands.h" 132#include "commands.h"
132#include "keyboard.h" 133#include "keyboard.h"
133#include "frame.h"
134#include "blockinput.h" 134#include "blockinput.h"
135#include "dispextern.h" 135#include "dispextern.h"
136#include "composite.h" 136#include "composite.h"
diff --git a/src/scroll.c b/src/scroll.c
index 915b60ab4c5..8f83851a2e0 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -23,7 +23,6 @@ Boston, MA 02111-1307, USA. */
23#include <stdio.h> 23#include <stdio.h>
24#include <string.h> 24#include <string.h>
25#include "lisp.h" 25#include "lisp.h"
26#include "systty.h" /* For emacs_tty in termchar.h */
27#include "termchar.h" 26#include "termchar.h"
28#include "dispextern.h" 27#include "dispextern.h"
29#include "keyboard.h" 28#include "keyboard.h"
diff --git a/src/sysdep.c b/src/sysdep.c
index a84a6d5c1fb..d5c72c52dde 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -272,11 +272,6 @@ discard_tty_input ()
272 if (noninteractive) 272 if (noninteractive)
273 return; 273 return;
274 274
275 /* Discarding input is not safe when the input could contain
276 replies from the X server. So don't do it. */
277 if (read_socket_hook)
278 return;
279
280#ifdef VMS 275#ifdef VMS
281 end_kbd_input (); 276 end_kbd_input ();
282 SYS$QIOW (0, fileno (TTY_INPUT (CURTTY())), IO$_READVBLK|IO$M_PURGE, input_iosb, 0, 0, 277 SYS$QIOW (0, fileno (TTY_INPUT (CURTTY())), IO$_READVBLK|IO$M_PURGE, input_iosb, 0, 0,
@@ -322,7 +317,7 @@ discard_tty_input ()
322void 317void
323stuff_char (char c) 318stuff_char (char c)
324{ 319{
325 if (read_socket_hook) 320 if (! FRAME_TERMCAP_P (SELECTED_FRAME ()))
326 return; 321 return;
327 322
328/* Should perhaps error if in batch mode */ 323/* Should perhaps error if in batch mode */
@@ -961,13 +956,17 @@ reset_sigio (fd)
961} 956}
962 957
963#ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ 958#ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */
964/* XXX Uhm, this FASYNC is not used anymore here. */ 959/* XXX Uhm, FASYNC is not used anymore here. */
965 960
966void 961void
967request_sigio () 962request_sigio ()
968{ 963{
964 /* XXX read_socket_hook is not global anymore. Is blocking SIGIO
965 bad under X? */
966#if 0
969 if (read_socket_hook) 967 if (read_socket_hook)
970 return; 968 return;
969#endif
971 970
972#ifdef SIGWINCH 971#ifdef SIGWINCH
973 sigunblock (sigmask (SIGWINCH)); 972 sigunblock (sigmask (SIGWINCH));
@@ -979,10 +978,14 @@ request_sigio ()
979 978
980void 979void
981unrequest_sigio (void) 980unrequest_sigio (void)
982{ 981{
982 /* XXX read_socket_hook is not global anymore. Is blocking SIGIO
983 bad under X? */
984#if 0
983 if (read_socket_hook) 985 if (read_socket_hook)
984 return; 986 return;
985 987#endif
988
986#ifdef SIGWINCH 989#ifdef SIGWINCH
987 sigblock (sigmask (SIGWINCH)); 990 sigblock (sigmask (SIGWINCH));
988#endif 991#endif
@@ -1388,15 +1391,18 @@ nil means don't delete them until `list-processes' is run. */);
1388#endif /* VMS */ 1391#endif /* VMS */
1389 1392
1390#ifdef BSD_PGRPS 1393#ifdef BSD_PGRPS
1394#if 0
1395 /* read_socket_hook is not global anymore. I think doing this
1396 unconditionally will not cause any problems. */
1391 if (! read_socket_hook && EQ (Vwindow_system, Qnil)) 1397 if (! read_socket_hook && EQ (Vwindow_system, Qnil))
1398#endif
1392 narrow_foreground_group (fileno (TTY_INPUT (tty_out))); 1399 narrow_foreground_group (fileno (TTY_INPUT (tty_out)));
1393#endif 1400#endif
1394 1401
1395#ifdef HAVE_WINDOW_SYSTEM 1402#ifdef HAVE_WINDOW_SYSTEM
1396 /* Emacs' window system on MSDOG uses the `internal terminal' and therefore 1403 /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
1397 needs the initialization code below. */ 1404 needs the initialization code below. */
1398 /* XXX This need to be revised for X+tty session support. */ 1405 if (tty_out->input != stdin || EQ (Vwindow_system, Qnil))
1399 if (tty_out->input != stdin || (!read_socket_hook && EQ (Vwindow_system, Qnil)))
1400#endif 1406#endif
1401 { 1407 {
1402 if (! tty_out->old_tty) 1408 if (! tty_out->old_tty)
@@ -1642,7 +1648,7 @@ nil means don't delete them until `list-processes' is run. */);
1642#ifndef F_SETOWN_BUG 1648#ifndef F_SETOWN_BUG
1643#ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */ 1649#ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */
1644 if (interrupt_input 1650 if (interrupt_input
1645 && ! read_socket_hook && EQ (Vwindow_system, Qnil)) 1651 && (tty_out->input != stdin || EQ (Vwindow_system, Qnil)))
1646 { 1652 {
1647 old_fcntl_owner[fileno (TTY_INPUT (tty_out))] = 1653 old_fcntl_owner[fileno (TTY_INPUT (tty_out))] =
1648 fcntl (fileno (TTY_INPUT (tty_out)), F_GETOWN, 0); 1654 fcntl (fileno (TTY_INPUT (tty_out)), F_GETOWN, 0);
diff --git a/src/term.c b/src/term.c
index 96fa9baddac..178ded7fc85 100644
--- a/src/term.c
+++ b/src/term.c
@@ -29,7 +29,6 @@ Boston, MA 02111-1307, USA. */
29#include <sys/file.h> 29#include <sys/file.h>
30 30
31#include "lisp.h" 31#include "lisp.h"
32#include "systty.h" /* For emacs_tty in termchar.h */
33#include "termchar.h" 32#include "termchar.h"
34#include "termopts.h" 33#include "termopts.h"
35#include "charset.h" 34#include "charset.h"
@@ -72,9 +71,9 @@ static void turn_off_face P_ ((struct frame *, int face_id));
72static void tty_show_cursor P_ ((struct tty_display_info *)); 71static void tty_show_cursor P_ ((struct tty_display_info *));
73static void tty_hide_cursor P_ ((struct tty_display_info *)); 72static void tty_hide_cursor P_ ((struct tty_display_info *));
74 73
75void delete_tty P_ ((struct tty_display_info *)); 74void delete_tty P_ ((struct display *));
76static void delete_tty_1 P_ ((struct tty_display_info *)); 75void create_tty_output P_ ((struct frame *));
77 76void delete_tty_output P_ ((struct frame *));
78 77
79#define OUTPUT(tty, a) \ 78#define OUTPUT(tty, a) \
80 emacs_tputs ((tty), a, \ 79 emacs_tputs ((tty), a, \
@@ -103,8 +102,10 @@ Lisp_Object Vring_bell_function;
103/* Functions to call after a tty was deleted. */ 102/* Functions to call after a tty was deleted. */
104Lisp_Object Vdelete_tty_after_functions; 103Lisp_Object Vdelete_tty_after_functions;
105 104
106/* Terminal characteristics that higher levels want to look at. */ 105/* Chain of all displays currently in use. */
106struct display *display_list;
107 107
108/* Chain of all tty device parameters. */
108struct tty_display_info *tty_list; 109struct tty_display_info *tty_list;
109 110
110/* Nonzero means no need to redraw the entire frame on resuming a 111/* Nonzero means no need to redraw the entire frame on resuming a
@@ -115,133 +116,6 @@ int no_redraw_on_reenter;
115 116
116Lisp_Object Qframe_tty_name, Qframe_tty_type; 117Lisp_Object Qframe_tty_name, Qframe_tty_type;
117 118
118/* Hook functions that you can set to snap out the functions in this file.
119 These are all extern'd in termhooks.h */
120
121void (*cursor_to_hook) P_ ((int, int));
122void (*raw_cursor_to_hook) P_ ((int, int));
123void (*clear_to_end_hook) P_ ((void));
124void (*clear_frame_hook) P_ ((void));
125void (*clear_end_of_line_hook) P_ ((int));
126
127void (*ins_del_lines_hook) P_ ((int, int));
128
129void (*delete_glyphs_hook) P_ ((int));
130
131void (*ring_bell_hook) P_ ((void));
132
133void (*reset_terminal_modes_hook) P_ ((void));
134void (*set_terminal_modes_hook) P_ ((void));
135void (*update_begin_hook) P_ ((struct frame *));
136void (*update_end_hook) P_ ((struct frame *));
137void (*set_terminal_window_hook) P_ ((int));
138void (*insert_glyphs_hook) P_ ((struct glyph *, int));
139void (*write_glyphs_hook) P_ ((struct glyph *, int));
140void (*delete_glyphs_hook) P_ ((int));
141
142int (*read_socket_hook) P_ ((struct input_event *, int, int));
143
144void (*frame_up_to_date_hook) P_ ((struct frame *));
145
146/* Return the current position of the mouse.
147
148 Set *f to the frame the mouse is in, or zero if the mouse is in no
149 Emacs frame. If it is set to zero, all the other arguments are
150 garbage.
151
152 If the motion started in a scroll bar, set *bar_window to the
153 scroll bar's window, *part to the part the mouse is currently over,
154 *x to the position of the mouse along the scroll bar, and *y to the
155 overall length of the scroll bar.
156
157 Otherwise, set *bar_window to Qnil, and *x and *y to the column and
158 row of the character cell the mouse is over.
159
160 Set *time to the time the mouse was at the returned position.
161
162 This should clear mouse_moved until the next motion
163 event arrives. */
164
165void (*mouse_position_hook) P_ ((FRAME_PTR *f, int insist,
166 Lisp_Object *bar_window,
167 enum scroll_bar_part *part,
168 Lisp_Object *x,
169 Lisp_Object *y,
170 unsigned long *time));
171
172/* When reading from a minibuffer in a different frame, Emacs wants
173 to shift the highlight from the selected frame to the mini-buffer's
174 frame; under X, this means it lies about where the focus is.
175 This hook tells the window system code to re-decide where to put
176 the highlight. */
177
178void (*frame_rehighlight_hook) P_ ((FRAME_PTR f));
179
180/* If we're displaying frames using a window system that can stack
181 frames on top of each other, this hook allows you to bring a frame
182 to the front, or bury it behind all the other windows. If this
183 hook is zero, that means the device we're displaying on doesn't
184 support overlapping frames, so there's no need to raise or lower
185 anything.
186
187 If RAISE is non-zero, F is brought to the front, before all other
188 windows. If RAISE is zero, F is sent to the back, behind all other
189 windows. */
190
191void (*frame_raise_lower_hook) P_ ((FRAME_PTR f, int raise));
192
193/* Set the vertical scroll bar for WINDOW to have its upper left corner
194 at (TOP, LEFT), and be LENGTH rows high. Set its handle to
195 indicate that we are displaying PORTION characters out of a total
196 of WHOLE characters, starting at POSITION. If WINDOW doesn't yet
197 have a scroll bar, create one for it. */
198
199void (*set_vertical_scroll_bar_hook)
200 P_ ((struct window *window,
201 int portion, int whole, int position));
202
203
204/* The following three hooks are used when we're doing a thorough
205 redisplay of the frame. We don't explicitly know which scroll bars
206 are going to be deleted, because keeping track of when windows go
207 away is a real pain - can you say set-window-configuration?
208 Instead, we just assert at the beginning of redisplay that *all*
209 scroll bars are to be removed, and then save scroll bars from the
210 fiery pit when we actually redisplay their window. */
211
212/* Arrange for all scroll bars on FRAME to be removed at the next call
213 to `*judge_scroll_bars_hook'. A scroll bar may be spared if
214 `*redeem_scroll_bar_hook' is applied to its window before the judgment.
215
216 This should be applied to each frame each time its window tree is
217 redisplayed, even if it is not displaying scroll bars at the moment;
218 if the HAS_SCROLL_BARS flag has just been turned off, only calling
219 this and the judge_scroll_bars_hook will get rid of them.
220
221 If non-zero, this hook should be safe to apply to any frame,
222 whether or not it can support scroll bars, and whether or not it is
223 currently displaying them. */
224
225void (*condemn_scroll_bars_hook) P_ ((FRAME_PTR frame));
226
227/* Unmark WINDOW's scroll bar for deletion in this judgement cycle.
228 Note that it's okay to redeem a scroll bar that is not condemned. */
229
230void (*redeem_scroll_bar_hook) P_ ((struct window *window));
231
232/* Remove all scroll bars on FRAME that haven't been saved since the
233 last call to `*condemn_scroll_bars_hook'.
234
235 This should be applied to each frame after each time its window
236 tree is redisplayed, even if it is not displaying scroll bars at the
237 moment; if the HAS_SCROLL_BARS flag has just been turned off, only
238 calling this and condemn_scroll_bars_hook will get rid of them.
239
240 If non-zero, this hook should be safe to apply to any frame,
241 whether or not it can support scroll bars, and whether or not it is
242 currently displaying them. */
243
244void (*judge_scroll_bars_hook) P_ ((FRAME_PTR FRAME));
245 119
246 120
247/* Meaning of bits in no_color_video. Each bit set means that the 121/* Meaning of bits in no_color_video. Each bit set means that the
@@ -270,10 +144,6 @@ int max_frame_cols;
270 144
271int max_frame_lines; 145int max_frame_lines;
272 146
273/* A template for tty display methods, with common values
274 preinitialized. */
275static struct display_method tty_display_method_template;
276
277/* Frame currently being redisplayed; 0 if not currently redisplaying. 147/* Frame currently being redisplayed; 0 if not currently redisplaying.
278 (Direct output does not count). */ 148 (Direct output does not count). */
279 149
@@ -323,8 +193,8 @@ ring_bell ()
323 193
324 Vring_bell_function = function; 194 Vring_bell_function = function;
325 } 195 }
326 else if (!FRAME_TERMCAP_P (f)) 196 else if (FRAME_DISPLAY (f)->ring_bell_hook)
327 (*ring_bell_hook) (); 197 (*FRAME_DISPLAY (f)->ring_bell_hook) ();
328 else { 198 else {
329 struct tty_display_info *tty = FRAME_TTY (f); 199 struct tty_display_info *tty = FRAME_TTY (f);
330 OUTPUT (tty, tty->TS_visible_bell && visible_bell ? tty->TS_visible_bell : tty->TS_bell); 200 OUTPUT (tty, tty->TS_visible_bell && visible_bell ? tty->TS_visible_bell : tty->TS_bell);
@@ -343,10 +213,10 @@ void
343set_terminal_modes () 213set_terminal_modes ()
344{ 214{
345 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 215 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
346 if (FRAME_TERMCAP_P (f)) 216 if (FRAME_DISPLAY (f)->set_terminal_modes_hook)
217 (*FRAME_DISPLAY (f)->set_terminal_modes_hook) ();
218 else
347 tty_set_terminal_modes (FRAME_TTY (f)); 219 tty_set_terminal_modes (FRAME_TTY (f));
348 else
349 (*set_terminal_modes_hook) ();
350} 220}
351 221
352void tty_reset_terminal_modes (struct tty_display_info *tty) 222void tty_reset_terminal_modes (struct tty_display_info *tty)
@@ -366,10 +236,10 @@ void
366reset_terminal_modes () 236reset_terminal_modes ()
367{ 237{
368 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 238 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
369 if (FRAME_TERMCAP_P (f)) 239 if (FRAME_DISPLAY (f)->reset_terminal_modes_hook)
240 (*FRAME_DISPLAY (f)->reset_terminal_modes_hook) ();
241 else
370 tty_reset_terminal_modes (FRAME_TTY (f)); 242 tty_reset_terminal_modes (FRAME_TTY (f));
371 else if (reset_terminal_modes_hook)
372 (*reset_terminal_modes_hook) ();
373} 243}
374 244
375void 245void
@@ -377,15 +247,17 @@ update_begin (f)
377 struct frame *f; 247 struct frame *f;
378{ 248{
379 updating_frame = f; 249 updating_frame = f;
380 if (!FRAME_TERMCAP_P (f)) 250 if (FRAME_DISPLAY (f)->update_begin_hook)
381 update_begin_hook (f); 251 (*FRAME_DISPLAY (f)->update_begin_hook) (f);
382} 252}
383 253
384void 254void
385update_end (f) 255update_end (f)
386 struct frame *f; 256 struct frame *f;
387{ 257{
388 if (FRAME_TERMCAP_P (f)) 258 if (FRAME_DISPLAY (f)->update_end_hook)
259 (*FRAME_DISPLAY (f)->update_end_hook) (f);
260 else if (FRAME_TERMCAP_P (f))
389 { 261 {
390 struct tty_display_info *tty = FRAME_TTY (f); 262 struct tty_display_info *tty = FRAME_TTY (f);
391 if (!XWINDOW (selected_window)->cursor_off_p) 263 if (!XWINDOW (selected_window)->cursor_off_p)
@@ -393,8 +265,6 @@ update_end (f)
393 turn_off_insert (tty); 265 turn_off_insert (tty);
394 background_highlight (tty); 266 background_highlight (tty);
395 } 267 }
396 else
397 update_end_hook (f);
398 268
399 updating_frame = NULL; 269 updating_frame = NULL;
400} 270}
@@ -404,15 +274,15 @@ set_terminal_window (size)
404 int size; 274 int size;
405{ 275{
406 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 276 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
407 if (FRAME_TERMCAP_P (f)) 277 if (FRAME_DISPLAY (f)->set_terminal_window_hook)
278 (*FRAME_DISPLAY (f)->set_terminal_window_hook) (size);
279 else if (FRAME_TERMCAP_P (f))
408 { 280 {
409 struct tty_display_info *tty = FRAME_TTY (f); 281 struct tty_display_info *tty = FRAME_TTY (f);
410 tty->specified_window = size ? size : FRAME_LINES (f); 282 tty->specified_window = size ? size : FRAME_LINES (f);
411 if (FRAME_SCROLL_REGION_OK (f)) 283 if (FRAME_SCROLL_REGION_OK (f))
412 set_scroll_region (0, tty->specified_window); 284 set_scroll_region (0, tty->specified_window);
413 } 285 }
414 else
415 set_terminal_window_hook (size);
416} 286}
417 287
418void 288void
@@ -545,9 +415,9 @@ cursor_to (vpos, hpos)
545 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 415 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
546 struct tty_display_info *tty; 416 struct tty_display_info *tty;
547 417
548 if (! FRAME_TERMCAP_P (f) && cursor_to_hook) 418 if (FRAME_DISPLAY (f)->cursor_to_hook)
549 { 419 {
550 (*cursor_to_hook) (vpos, hpos); 420 (*FRAME_DISPLAY (f)->cursor_to_hook) (vpos, hpos);
551 return; 421 return;
552 } 422 }
553 423
@@ -576,9 +446,9 @@ raw_cursor_to (row, col)
576{ 446{
577 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); 447 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame);
578 struct tty_display_info *tty; 448 struct tty_display_info *tty;
579 if (! FRAME_TERMCAP_P (f)) 449 if (FRAME_DISPLAY (f)->raw_cursor_to_hook)
580 { 450 {
581 (*raw_cursor_to_hook) (row, col); 451 (*FRAME_DISPLAY (f)->raw_cursor_to_hook) (row, col);
582 return; 452 return;
583 } 453 }
584 tty = FRAME_TTY (f); 454 tty = FRAME_TTY (f);
@@ -603,9 +473,9 @@ clear_to_end ()
603 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 473 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
604 struct tty_display_info *tty; 474 struct tty_display_info *tty;
605 475
606 if (clear_to_end_hook && ! FRAME_TERMCAP_P (f)) 476 if (FRAME_DISPLAY (f)->clear_to_end_hook)
607 { 477 {
608 (*clear_to_end_hook) (); 478 (*FRAME_DISPLAY (f)->clear_to_end_hook) ();
609 return; 479 return;
610 } 480 }
611 tty = FRAME_TTY (f); 481 tty = FRAME_TTY (f);
@@ -632,9 +502,9 @@ clear_frame ()
632 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 502 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
633 struct tty_display_info *tty; 503 struct tty_display_info *tty;
634 504
635 if (clear_frame_hook && ! FRAME_TERMCAP_P (f)) 505 if (FRAME_DISPLAY (f)->clear_frame_hook)
636 { 506 {
637 (*clear_frame_hook) (); 507 (*FRAME_DISPLAY (f)->clear_frame_hook) ();
638 return; 508 return;
639 } 509 }
640 tty = FRAME_TTY (f); 510 tty = FRAME_TTY (f);
@@ -663,9 +533,9 @@ clear_end_of_line (first_unused_hpos)
663 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 533 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
664 struct tty_display_info *tty; 534 struct tty_display_info *tty;
665 535
666 if (clear_end_of_line_hook && ! FRAME_TERMCAP_P (f)) 536 if (FRAME_DISPLAY (f)->clear_end_of_line_hook)
667 { 537 {
668 (*clear_end_of_line_hook) (first_unused_hpos); 538 (*FRAME_DISPLAY (f)->clear_end_of_line_hook) (first_unused_hpos);
669 return; 539 return;
670 } 540 }
671 541
@@ -828,9 +698,9 @@ write_glyphs (string, len)
828 unsigned char conversion_buffer[1024]; 698 unsigned char conversion_buffer[1024];
829 int conversion_buffer_size = sizeof conversion_buffer; 699 int conversion_buffer_size = sizeof conversion_buffer;
830 700
831 if (write_glyphs_hook && ! FRAME_TERMCAP_P (f)) 701 if (FRAME_DISPLAY (f)->write_glyphs_hook)
832 { 702 {
833 (*write_glyphs_hook) (string, len); 703 (*FRAME_DISPLAY (f)->write_glyphs_hook) (string, len);
834 return; 704 return;
835 } 705 }
836 706
@@ -935,9 +805,9 @@ insert_glyphs (start, len)
935 805
936 f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 806 f = (updating_frame ? updating_frame : XFRAME (selected_frame));
937 807
938 if (insert_glyphs_hook && ! FRAME_TERMCAP_P (f)) 808 if (FRAME_DISPLAY (f)->insert_glyphs_hook)
939 { 809 {
940 (*insert_glyphs_hook) (start, len); 810 (*FRAME_DISPLAY (f)->insert_glyphs_hook) (start, len);
941 return; 811 return;
942 } 812 }
943 813
@@ -1024,9 +894,9 @@ delete_glyphs (n)
1024 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 894 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
1025 struct tty_display_info *tty = FRAME_TTY (f); 895 struct tty_display_info *tty = FRAME_TTY (f);
1026 896
1027 if (delete_glyphs_hook && ! FRAME_TERMCAP_P (f)) 897 if (FRAME_DISPLAY (f)->delete_glyphs_hook)
1028 { 898 {
1029 (*delete_glyphs_hook) (n); 899 (*FRAME_DISPLAY (f)->delete_glyphs_hook) (n);
1030 return; 900 return;
1031 } 901 }
1032 902
@@ -1061,9 +931,9 @@ ins_del_lines (vpos, n)
1061 int vpos, n; 931 int vpos, n;
1062{ 932{
1063 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); 933 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
1064 if (ins_del_lines_hook && ! FRAME_TERMCAP_P (f)) 934 if (FRAME_DISPLAY (f)->ins_del_lines_hook)
1065 { 935 {
1066 (*ins_del_lines_hook) (vpos, n); 936 (*FRAME_DISPLAY (f)->ins_del_lines_hook) (vpos, n);
1067 return; 937 return;
1068 } 938 }
1069 else 939 else
@@ -1948,7 +1818,12 @@ DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p,
1948 (display) 1818 (display)
1949 Lisp_Object display; 1819 Lisp_Object display;
1950{ 1820{
1951 struct tty_display_info *tty = FRAME_TTY (SELECTED_FRAME ()); 1821 struct tty_display_info *tty;
1822
1823 if (! FRAMEP (display))
1824 return Qnil;
1825
1826 tty = FRAME_TTY (XFRAME (display));
1952 return tty->TN_max_colors > 0 ? Qt : Qnil; 1827 return tty->TN_max_colors > 0 ? Qt : Qnil;
1953} 1828}
1954 1829
@@ -1959,7 +1834,12 @@ DEFUN ("tty-display-color-cells", Ftty_display_color_cells,
1959 (display) 1834 (display)
1960 Lisp_Object display; 1835 Lisp_Object display;
1961{ 1836{
1962 struct tty_display_info *tty = FRAME_TTY (SELECTED_FRAME ()); 1837 struct tty_display_info *tty;
1838
1839 if (! FRAMEP (display))
1840 return Qnil;
1841
1842 tty = FRAME_TTY (XFRAME (display));
1963 return make_number (tty->TN_max_colors); 1843 return make_number (tty->TN_max_colors);
1964} 1844}
1965 1845
@@ -2102,17 +1982,18 @@ set_tty_color_mode (f, val)
2102 1982
2103 1983
2104 1984
2105struct tty_display_info * 1985static struct display *
2106get_named_tty (name) 1986get_named_tty_display (name)
2107 char *name; 1987 char *name;
2108{ 1988{
2109 struct tty_display_info *tty = tty_list; 1989 struct display *d;
2110 1990
2111 while (tty) { 1991 for (d = display_list; d; d = d->next_display) {
2112 if ((tty->name == 0 && name == 0) 1992 if (d->type == output_termcap
2113 || (name && tty->name && !strcmp (tty->name, name))) 1993 && ((d->display_info.tty->name == 0 && name == 0)
2114 return tty; 1994 || (name && d->display_info.tty->name
2115 tty = tty->next; 1995 && !strcmp (d->display_info.tty->name, name))))
1996 return d;
2116 }; 1997 };
2117 1998
2118 return 0; 1999 return 0;
@@ -2177,11 +2058,13 @@ DEFUN ("frame-tty-type", Fframe_tty_type, Sframe_tty_type, 0, 1, 0,
2177 Initialization 2058 Initialization
2178 ***********************************************************************/ 2059 ***********************************************************************/
2179 2060
2180struct tty_display_info * 2061struct display *
2181term_dummy_init (void) 2062initial_term_init (void)
2182{ 2063{
2183 if (initialized || tty_list) 2064 if (initialized || display_list || tty_list)
2184 error ("tty already initialized"); 2065 abort ();
2066
2067 display_list = create_display ();
2185 2068
2186 tty_list = xmalloc (sizeof (struct tty_display_info)); 2069 tty_list = xmalloc (sizeof (struct tty_display_info));
2187 bzero (tty_list, sizeof (struct tty_display_info)); 2070 bzero (tty_list, sizeof (struct tty_display_info));
@@ -2189,14 +2072,19 @@ term_dummy_init (void)
2189 tty_list->input = stdin; 2072 tty_list->input = stdin;
2190 tty_list->output = stdout; 2073 tty_list->output = stdout;
2191 tty_list->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); 2074 tty_list->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
2192 tty_list->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); 2075#ifdef MULTI_KBOARD
2193 tty_list->kboard = initial_kboard; 2076 tty_list->kboard = initial_kboard;
2194 return tty_list; 2077#endif
2078
2079 display_list->type = output_termcap;
2080 display_list->display_info.tty = tty_list;
2081
2082 return display_list;
2195} 2083}
2196 2084
2197 2085
2198struct tty_display_info * 2086struct display *
2199term_init (Lisp_Object frame, char *name, char *terminal_type) 2087term_init (char *name, char *terminal_type)
2200{ 2088{
2201 char *area; 2089 char *area;
2202 char **address = &area; 2090 char **address = &area;
@@ -2204,52 +2092,45 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
2204 int buffer_size = 4096; 2092 int buffer_size = 4096;
2205 register char *p; 2093 register char *p;
2206 int status; 2094 int status;
2207 struct frame *f = XFRAME (frame);
2208 struct tty_display_info *tty; 2095 struct tty_display_info *tty;
2096 struct display *display;
2209 2097
2210 tty = get_named_tty (name); 2098 display = get_named_tty_display (name);
2211 if (tty) 2099 if (display)
2212 { 2100 {
2101 tty = display->display_info.tty;
2102
2213 /* Return the previously initialized terminal, except if it is 2103 /* Return the previously initialized terminal, except if it is
2214 the dummy terminal created for the initial frame. */ 2104 the dummy terminal created for the initial frame. */
2215 if (tty->type) 2105 if (tty->type)
2216 return tty; 2106 return display;
2217 2107
2218 /* Free up temporary structures. */ 2108 /* Free up temporary structures. */
2219 if (tty->Wcm) 2109 if (tty->Wcm)
2220 xfree (tty->Wcm); 2110 xfree (tty->Wcm);
2221 if (tty->display_method)
2222 xfree (tty->display_method);
2223 if (tty->kboard != initial_kboard) 2111 if (tty->kboard != initial_kboard)
2224 abort (); 2112 abort ();
2225 tty->kboard = 0; 2113 tty->kboard = 0;
2226 } 2114 }
2227 else 2115 else
2228 { 2116 {
2117 display = create_display ();
2229 tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info)); 2118 tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info));
2230 bzero (tty, sizeof (struct tty_display_info)); 2119 bzero (tty, sizeof (struct tty_display_info));
2231 tty->next = tty_list; 2120 tty->next = tty_list;
2232 tty_list = tty; 2121 tty_list = tty;
2122
2123 display->type = output_termcap;
2124 display->display_info.tty = tty;
2233 } 2125 }
2234 2126
2235 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); 2127 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
2236 Wcm_clear (tty); 2128 Wcm_clear (tty);
2237 2129
2238 /* Each termcap frame has its own display method. */ 2130 display->rif = 0; /* ttys don't support window-based redisplay. */
2239 tty->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); 2131 display->delete_frame_hook = &delete_tty_output;
2240 bzero (tty->display_method, sizeof (struct display_method)); 2132 display->delete_display_hook = &delete_tty;
2241 2133
2242 /* Initialize the common members in the new display method with our
2243 predefined template. */
2244 *tty->display_method = tty_display_method_template;
2245 f->display_method = tty->display_method;
2246
2247 /* Make sure the frame is live; if an error happens, it must be
2248 deleted. */
2249 f->output_method = output_termcap;
2250 if (! f->output_data.tty)
2251 abort ();
2252 f->output_data.tty->display_info = tty;
2253 if (name) 2134 if (name)
2254 { 2135 {
2255 int fd; 2136 int fd;
@@ -2257,7 +2138,7 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
2257 fd = emacs_open (name, O_RDWR, 0); 2138 fd = emacs_open (name, O_RDWR, 0);
2258 if (fd < 0) 2139 if (fd < 0)
2259 { 2140 {
2260 delete_tty (tty); 2141 delete_tty (display);
2261 error ("Could not open file: %s", name); 2142 error ("Could not open file: %s", name);
2262 } 2143 }
2263 file = fdopen (fd, "w+"); 2144 file = fdopen (fd, "w+");
@@ -2283,29 +2164,29 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
2283 2164
2284 area = (char *) xmalloc (2044); 2165 area = (char *) xmalloc (2044);
2285 2166
2286 FrameRows (tty) = FRAME_LINES (f); 2167 FrameRows (tty) = FRAME_LINES (f); /* XXX */
2287 FrameCols (tty) = FRAME_COLS (f); 2168 FrameCols (tty) = FRAME_COLS (f); /* XXX */
2288 tty->specified_window = FRAME_LINES (f); 2169 tty->specified_window = FRAME_LINES (f); /* XXX */
2289 2170
2290 tty->display_method->delete_in_insert_mode = 1; 2171 tty->display->delete_in_insert_mode = 1;
2291 2172
2292 UseTabs (tty) = 0; 2173 UseTabs (tty) = 0;
2293 FRAME_SCROLL_REGION_OK (f) = 0; 2174 display->scroll_region_ok = 0;
2294 2175
2295 /* Seems to insert lines when it's not supposed to, messing 2176 /* Seems to insert lines when it's not supposed to, messing
2296 up the display. In doing a trace, it didn't seem to be 2177 up the display. In doing a trace, it didn't seem to be
2297 called much, so I don't think we're losing anything by 2178 called much, so I don't think we're losing anything by
2298 turning it off. */ 2179 turning it off. */
2299 FRAME_LINE_INS_DEL_OK (f) = 0; 2180 display->line_ins_del_ok = 0;
2300 FRAME_CHAR_INS_DEL_OK (f) = 1; 2181 display->char_ins_del_ok = 1;
2301 2182
2302 baud_rate = 19200; 2183 baud_rate = 19200;
2303 2184
2304 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; 2185 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; /* XXX */
2305 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; 2186 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; /* XXX */
2306 TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ 2187 TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */
2307 2188
2308 return tty; 2189 return display;
2309#else /* not WINDOWSNT */ 2190#else /* not WINDOWSNT */
2310 2191
2311 Wcm_clear (tty); 2192 Wcm_clear (tty);
@@ -2318,7 +2199,7 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
2318 if (name) 2199 if (name)
2319 { 2200 {
2320 xfree (buffer); 2201 xfree (buffer);
2321 delete_tty (tty); 2202 delete_tty (display);
2322 error ("Cannot open terminfo database file"); 2203 error ("Cannot open terminfo database file");
2323 } 2204 }
2324 else 2205 else
@@ -2327,7 +2208,7 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
2327 if (name) 2208 if (name)
2328 { 2209 {
2329 xfree (buffer); 2210 xfree (buffer);
2330 delete_tty (tty); 2211 delete_tty (display);
2331 error ("Cannot open termcap database file"); 2212 error ("Cannot open termcap database file");
2332 } 2213 }
2333 else 2214 else
@@ -2340,7 +2221,7 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
2340 if (name) 2221 if (name)
2341 { 2222 {
2342 xfree (buffer); 2223 xfree (buffer);
2343 delete_tty (tty); 2224 delete_tty (display);
2344 error ("Terminal type %s is not defined", terminal_type); 2225 error ("Terminal type %s is not defined", terminal_type);
2345 } 2226 }
2346 else 2227 else
@@ -2354,7 +2235,7 @@ to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
2354 if (name) 2235 if (name)
2355 { 2236 {
2356 xfree (buffer); 2237 xfree (buffer);
2357 delete_tty (tty); 2238 delete_tty (display);
2358 error ("Terminal type %s is not defined", terminal_type); 2239 error ("Terminal type %s is not defined", terminal_type);
2359 } 2240 }
2360 else 2241 else
@@ -2478,9 +2359,9 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2478 /* Since we make MagicWrap terminals look like AutoWrap, we need to have 2359 /* Since we make MagicWrap terminals look like AutoWrap, we need to have
2479 the former flag imply the latter. */ 2360 the former flag imply the latter. */
2480 AutoWrap (tty) = MagicWrap (tty) || tgetflag ("am"); 2361 AutoWrap (tty) = MagicWrap (tty) || tgetflag ("am");
2481 FRAME_MEMORY_BELOW_FRAME (f) = tgetflag ("db"); 2362 display->memory_below_frame = tgetflag ("db");
2482 tty->TF_hazeltine = tgetflag ("hz"); 2363 tty->TF_hazeltine = tgetflag ("hz");
2483 FRAME_MUST_WRITE_SPACES (f) = tgetflag ("in"); 2364 display->must_write_spaces = tgetflag ("in");
2484 tty->meta_key = tgetflag ("km") || tgetflag ("MT"); 2365 tty->meta_key = tgetflag ("km") || tgetflag ("MT");
2485 tty->TF_insmode_motion = tgetflag ("mi"); 2366 tty->TF_insmode_motion = tgetflag ("mi");
2486 tty->TF_standout_motion = tgetflag ("ms"); 2367 tty->TF_standout_motion = tgetflag ("ms");
@@ -2506,7 +2387,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2506 { 2387 {
2507 if (initialized) 2388 if (initialized)
2508 { 2389 {
2509 delete_tty (tty); 2390 delete_tty (display);
2510 error ("Screen size %dx%d is too small", 2391 error ("Screen size %dx%d is too small",
2511 FrameCols (tty), FrameRows (tty)); 2392 FrameCols (tty), FrameRows (tty));
2512 } 2393 }
@@ -2518,7 +2399,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2518 } 2399 }
2519 2400
2520#if 0 /* This is not used anywhere. */ 2401#if 0 /* This is not used anywhere. */
2521 tty->display_method->min_padding_speed = tgetnum ("pb"); 2402 tty->display->min_padding_speed = tgetnum ("pb");
2522#endif 2403#endif
2523 2404
2524 TabWidth (tty) = tgetnum ("tw"); 2405 TabWidth (tty) = tgetnum ("tw");
@@ -2596,7 +2477,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2596 2477
2597 if (!strcmp (terminal_type, "supdup")) 2478 if (!strcmp (terminal_type, "supdup"))
2598 { 2479 {
2599 FRAME_MEMORY_BELOW_FRAME (f) = 1; 2480 display->memory_below_frame = 1;
2600 tty->Wcm->cm_losewrap = 1; 2481 tty->Wcm->cm_losewrap = 1;
2601 } 2482 }
2602 if (!strncmp (terminal_type, "c10", 3) 2483 if (!strncmp (terminal_type, "c10", 3)
@@ -2623,7 +2504,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2623 tty->TS_set_window = "\033v%C %C %C %C "; 2504 tty->TS_set_window = "\033v%C %C %C %C ";
2624 } 2505 }
2625 /* Termcap entry often fails to have :in: flag */ 2506 /* Termcap entry often fails to have :in: flag */
2626 FRAME_MUST_WRITE_SPACES (f) = 1; 2507 display->must_write_spaces = 1;
2627 /* :ti string typically fails to have \E^G! in it */ 2508 /* :ti string typically fails to have \E^G! in it */
2628 /* This limits scope of insert-char to one line. */ 2509 /* This limits scope of insert-char to one line. */
2629 strcpy (area, tty->TS_termcap_modes); 2510 strcpy (area, tty->TS_termcap_modes);
@@ -2646,7 +2527,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2646 if (Wcm_init (tty) == -1) /* can't do cursor motion */ 2527 if (Wcm_init (tty) == -1) /* can't do cursor motion */
2647 if (name) 2528 if (name)
2648 { 2529 {
2649 delete_tty (tty); 2530 delete_tty (display);
2650 error ("Terminal type \"%s\" is not powerful enough to run Emacs", 2531 error ("Terminal type \"%s\" is not powerful enough to run Emacs",
2651 terminal_type); 2532 terminal_type);
2652 } 2533 }
@@ -2683,7 +2564,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2683 { 2564 {
2684 if (name) 2565 if (name)
2685 { 2566 {
2686 delete_tty (tty); 2567 delete_tty (display);
2687 error ("The frame size has not been specified"); 2568 error ("The frame size has not been specified");
2688 } 2569 }
2689 else 2570 else
@@ -2700,36 +2581,35 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2700 2581
2701 UseTabs (tty) = tabs_safe_p (fileno (TTY_INPUT (tty))) && TabWidth (tty) == 8; 2582 UseTabs (tty) = tabs_safe_p (fileno (TTY_INPUT (tty))) && TabWidth (tty) == 8;
2702 2583
2703 FRAME_SCROLL_REGION_OK (f) 2584 display->scroll_region_ok
2704 = (tty->Wcm->cm_abs 2585 = (tty->Wcm->cm_abs
2705 && (tty->TS_set_window || tty->TS_set_scroll_region || tty->TS_set_scroll_region_1)); 2586 && (tty->TS_set_window || tty->TS_set_scroll_region || tty->TS_set_scroll_region_1));
2706 2587
2707 FRAME_LINE_INS_DEL_OK (f) 2588 display->line_ins_del_ok
2708 = (((tty->TS_ins_line || tty->TS_ins_multi_lines) 2589 = (((tty->TS_ins_line || tty->TS_ins_multi_lines)
2709 && (tty->TS_del_line || tty->TS_del_multi_lines)) 2590 && (tty->TS_del_line || tty->TS_del_multi_lines))
2710 || (FRAME_SCROLL_REGION_OK (f) 2591 || (display->scroll_region_ok
2711 && tty->TS_fwd_scroll && tty->TS_rev_scroll)); 2592 && tty->TS_fwd_scroll && tty->TS_rev_scroll));
2712 2593
2713 FRAME_CHAR_INS_DEL_OK (f) 2594 display->char_ins_del_ok
2714 = ((tty->TS_ins_char || tty->TS_insert_mode 2595 = ((tty->TS_ins_char || tty->TS_insert_mode
2715 || tty->TS_pad_inserted_char || tty->TS_ins_multi_chars) 2596 || tty->TS_pad_inserted_char || tty->TS_ins_multi_chars)
2716 && (tty->TS_del_char || tty->TS_del_multi_chars)); 2597 && (tty->TS_del_char || tty->TS_del_multi_chars));
2717 2598
2718 FRAME_FAST_CLEAR_END_OF_LINE (f) = tty->TS_clr_line != 0; 2599 display->fast_clear_end_of_line = tty->TS_clr_line != 0;
2719 2600
2720 init_baud_rate (fileno (TTY_INPUT (tty))); 2601 init_baud_rate (fileno (TTY_INPUT (tty)));
2721 if (read_socket_hook) /* Baudrate is somewhat
2722 meaningless in this case */
2723 baud_rate = 9600;
2724 2602
2725 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; 2603 /* XXX This condition sounds bogus. */
2726 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; 2604 if (display->read_socket_hook) /* Baudrate is somewhat
2605 meaningless in this case */
2606 baud_rate = 9600;
2727 2607
2728#ifdef AIXHFT 2608#ifdef AIXHFT
2729 /* The HFT system on AIX doesn't optimize for scrolling, so it's 2609 /* The HFT system on AIX doesn't optimize for scrolling, so it's
2730 really ugly at times. */ 2610 really ugly at times. */
2731 FRAME_LINE_INS_DEL_OK (f) = 0; 2611 display->line_ins_del_ok = 0;
2732 FRAME_CHAR_INS_DEL_OK (f) = 0; 2612 display->char_ins_del_ok = 0;
2733#endif 2613#endif
2734 2614
2735#ifdef MULTI_KBOARD 2615#ifdef MULTI_KBOARD
@@ -2748,13 +2628,10 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2748 /* Don't do this. I think termcap may still need the buffer. */ 2628 /* Don't do this. I think termcap may still need the buffer. */
2749 /* xfree (buffer); */ 2629 /* xfree (buffer); */
2750 2630
2751 /* Set the top frame to the first frame on this display. */
2752 tty->top_frame = frame;
2753
2754 /* Init system terminal modes (RAW or CBREAK, etc.). */ 2631 /* Init system terminal modes (RAW or CBREAK, etc.). */
2755 init_sys_modes (tty); 2632 init_sys_modes (tty);
2756 2633
2757 return tty; 2634 return display;
2758#endif /* not WINDOWSNT */ 2635#endif /* not WINDOWSNT */
2759} 2636}
2760 2637
@@ -2781,7 +2658,7 @@ tty. The functions are run with one arg, the frame to be deleted. */)
2781 (tty) 2658 (tty)
2782 Lisp_Object tty; 2659 Lisp_Object tty;
2783{ 2660{
2784 struct tty_display_info *t; 2661 struct display *d;
2785 char *name = 0; 2662 char *name = 0;
2786 2663
2787 CHECK_STRING (tty); 2664 CHECK_STRING (tty);
@@ -2793,29 +2670,35 @@ tty. The functions are run with one arg, the frame to be deleted. */)
2793 name[SBYTES (tty)] = 0; 2670 name[SBYTES (tty)] = 0;
2794 } 2671 }
2795 2672
2796 t = get_named_tty (name); 2673 d = get_named_tty_display (name);
2797 2674
2798 if (! t) 2675 if (! d)
2799 error ("No such tty device: %s", name); 2676 error ("No such terminal device: %s", name);
2800 2677
2801 delete_tty (t); 2678 delete_tty (d);
2802} 2679}
2803 2680
2804static int deleting_tty = 0; 2681static int deleting_tty = 0;
2805 2682
2806void 2683void
2807delete_tty (struct tty_display_info *tty) 2684delete_tty (struct display *display)
2808{ 2685{
2686 struct tty_display_info *tty;
2809 Lisp_Object tail, frame; 2687 Lisp_Object tail, frame;
2810 char *tty_name; 2688 char *tty_name;
2811 2689
2812 if (deleting_tty) 2690 if (deleting_tty)
2813 /* We get a recursive call when we delete the last frame on this 2691 /* We get a recursive call when we delete the last frame on this
2814 tty. */ 2692 display. */
2815 return; 2693 return;
2816 2694
2817 deleting_tty = 1; 2695 deleting_tty = 1;
2818 2696
2697 if (display->type != output_termcap)
2698 abort ();
2699
2700 tty = display->display_info.tty;
2701
2819 if (tty == tty_list) 2702 if (tty == tty_list)
2820 tty_list = tty->next; 2703 tty_list = tty->next;
2821 else 2704 else
@@ -2842,6 +2725,8 @@ delete_tty (struct tty_display_info *tty)
2842 } 2725 }
2843 } 2726 }
2844 2727
2728 delete_display (display);
2729
2845 reset_sys_modes (tty); 2730 reset_sys_modes (tty);
2846 2731
2847 tty_name = tty->name; 2732 tty_name = tty->name;
@@ -2865,9 +2750,6 @@ delete_tty (struct tty_display_info *tty)
2865 if (tty->Wcm) 2750 if (tty->Wcm)
2866 xfree (tty->Wcm); 2751 xfree (tty->Wcm);
2867 2752
2868 if (tty->display_method)
2869 xfree (tty->display_method);
2870
2871#ifdef MULTI_KBOARD 2753#ifdef MULTI_KBOARD
2872 if (tty->kboard && --tty->kboard->reference_count > 0) 2754 if (tty->kboard && --tty->kboard->reference_count > 0)
2873 abort (); 2755 abort ();
@@ -2895,6 +2777,34 @@ delete_tty (struct tty_display_info *tty)
2895 } 2777 }
2896} 2778}
2897 2779
2780
2781
2782/* Initialize the tty-dependent part of frame F. The frame must
2783 already have its display initialized. */
2784void
2785create_tty_output (struct frame *f)
2786{
2787 if (! FRAME_TERMCAP_P (f))
2788 abort ();
2789
2790 struct tty_output *t = xmalloc (sizeof (struct tty_output));
2791 bzero (t, sizeof (struct tty_output));
2792
2793 t->display_info = FRAME_DISPLAY (f)->display_info.tty;
2794
2795 f->output_data.tty = t;
2796}
2797
2798/* Delete the tty-dependent part of frame F. */
2799void
2800delete_tty_output (struct frame *f)
2801{
2802 if (! FRAME_TERMCAP_P (f))
2803 abort ();
2804
2805 xfree (f->output_data.tty);
2806}
2807
2898 2808
2899 2809
2900 2810
@@ -2912,6 +2822,35 @@ mark_ttys ()
2912 } 2822 }
2913} 2823}
2914 2824
2825
2826
2827/* Create a new display object and add it to the display list. */
2828struct display *
2829create_display (void)
2830{
2831 struct display *dev = (struct display *) xmalloc (sizeof (struct display));
2832
2833 bzero (dev, sizeof (struct display));
2834 dev->next_display = display_list;
2835 display_list = dev;
2836
2837 return dev;
2838}
2839
2840/* Remove a display from the display list and free its memory. */
2841void
2842delete_display (struct display *dev)
2843{
2844 struct display **dp;
2845 for (dp = &display_list; *dp != dev; dp = &(*dp)->next_display)
2846 if (! *dp)
2847 abort ();
2848 *dp = dev->next_display;
2849
2850 bzero (dev, sizeof (struct display));
2851 xfree (dev);
2852}
2853
2915 2854
2916 2855
2917void 2856void
@@ -2951,11 +2890,6 @@ See `delete-tty'. */);
2951 2890
2952 Fprovide (intern ("multi-tty"), Qnil); 2891 Fprovide (intern ("multi-tty"), Qnil);
2953 2892
2954 /* Initialize the display method template. */
2955
2956 /* Termcap-based displays don't support window-based redisplay. */
2957 tty_display_method_template.rif = 0;
2958
2959} 2893}
2960 2894
2961 2895
diff --git a/src/termchar.h b/src/termchar.h
index 5b9082917fb..fe9cd4b27df 100644
--- a/src/termchar.h
+++ b/src/termchar.h
@@ -179,10 +179,6 @@ struct tty_display_info
179 /* Nonzero means use ^S/^Q for flow control. */ 179 /* Nonzero means use ^S/^Q for flow control. */
180 int flow_control; 180 int flow_control;
181 181
182 /* This is a copy of struct frame's display_method value; needed for
183 freeing up memory when deleting the tty. */
184 struct display_method *display_method;
185
186#ifdef MULTI_KBOARD 182#ifdef MULTI_KBOARD
187 /* The terminal's keyboard object. */ 183 /* The terminal's keyboard object. */
188 struct kboard *kboard; 184 struct kboard *kboard;
@@ -195,7 +191,7 @@ extern struct tty_display_info *tty_list;
195 191
196#define FRAME_TTY(f) \ 192#define FRAME_TTY(f) \
197 ((f)->output_method == output_termcap \ 193 ((f)->output_method == output_termcap \
198 ? (f)->output_data.tty->display_info \ 194 ? (f)->display->display_info.tty \
199 : (abort(), (struct tty_display_info *) 0)) 195 : (abort(), (struct tty_display_info *) 0))
200 196
201#define CURTTY() FRAME_TTY (SELECTED_FRAME()) 197#define CURTTY() FRAME_TTY (SELECTED_FRAME())
diff --git a/src/termhooks.h b/src/termhooks.h
index 35a8763425a..36a31ff4f6a 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -1,5 +1,4 @@
1/* Hooks by which low level terminal operations 1/* Parameters and display hooks for output devices
2 can be made to call other routines.
3 Copyright (C) 1985,86,93,94,2003 Free Software Foundation, Inc. 2 Copyright (C) 1985,86,93,94,2003 Free Software Foundation, Inc.
4 3
5This file is part of GNU Emacs. 4This file is part of GNU Emacs.
@@ -30,75 +29,6 @@ struct frame;
30#define P_(X) () 29#define P_(X) ()
31#endif 30#endif
32 31
33/* Device-local parameters. */
34struct display_method
35{
36 /* Terminal characteristics. */
37
38 int must_write_spaces; /* Nonzero means spaces in the text must
39 actually be output; can't just skip over
40 some columns to leave them blank. */
41 int fast_clear_end_of_line; /* Nonzero means terminal has a `ce' string */
42
43 int line_ins_del_ok; /* Terminal can insert and delete lines */
44 int char_ins_del_ok; /* Terminal can insert and delete chars */
45 int scroll_region_ok; /* Terminal supports setting the scroll
46 window */
47 int scroll_region_cost; /* Cost of setting the scroll window,
48 measured in characters. */
49 int memory_below_frame; /* Terminal remembers lines scrolled
50 off bottom */
51
52#if 0 /* These are not used anywhere. */
53 /* EMACS_INT baud_rate; */ /* Output speed in baud */
54 int min_padding_speed; /* Speed below which no padding necessary. */
55 int dont_calculate_costs; /* Nonzero means don't bother computing
56 various cost tables; we won't use them. */
57#endif
58
59 /* Window-based redisplay interface for this frame (0 for termcap
60 frames). */
61 struct redisplay_interface *rif;
62
63 /* XXX Display hooks will go here. */
64};
65
66#define FRAME_MUST_WRITE_SPACES(f) ((f)->display_method->must_write_spaces)
67#define FRAME_FAST_CLEAR_END_OF_LINE(f) ((f)->display_method->fast_clear_end_of_line)
68#define FRAME_LINE_INS_DEL_OK(f) ((f)->display_method->line_ins_del_ok)
69#define FRAME_CHAR_INS_DEL_OK(f) ((f)->display_method->char_ins_del_ok)
70#define FRAME_SCROLL_REGION_OK(f) ((f)->display_method->scroll_region_ok)
71#define FRAME_SCROLL_REGION_COST(f) ((f)->display_method->scroll_region_cost)
72#define FRAME_MEMORY_BELOW_FRAME(f) ((f)->display_method->memory_below_frame)
73
74#define FRAME_RIF(f) ((f)->display_method->rif)
75
76/* Text display hooks. */
77
78extern void (*cursor_to_hook) P_ ((int vpos, int hpos));
79extern void (*raw_cursor_to_hook) P_ ((int, int));
80
81extern void (*clear_to_end_hook) P_ ((void));
82extern void (*clear_frame_hook) P_ ((void));
83extern void (*clear_end_of_line_hook) P_ ((int));
84
85extern void (*ins_del_lines_hook) P_ ((int, int));
86
87extern void (*insert_glyphs_hook) P_ ((struct glyph *s, int n));
88extern void (*write_glyphs_hook) P_ ((struct glyph *s, int n));
89extern void (*delete_glyphs_hook) P_ ((int));
90
91extern void (*ring_bell_hook) P_ ((void));
92
93extern void (*reset_terminal_modes_hook) P_ ((void));
94extern void (*set_terminal_modes_hook) P_ ((void));
95extern void (*update_begin_hook) P_ ((struct frame *));
96extern void (*update_end_hook) P_ ((struct frame *));
97extern void (*set_terminal_window_hook) P_ ((int));
98
99
100
101/* Multi-frame and mouse support hooks. */
102 32
103enum scroll_bar_part { 33enum scroll_bar_part {
104 scroll_bar_above_handle, 34 scroll_bar_above_handle,
@@ -112,125 +42,6 @@ enum scroll_bar_part {
112 scroll_bar_move_ratio 42 scroll_bar_move_ratio
113}; 43};
114 44
115/* Return the current position of the mouse.
116
117 Set *f to the frame the mouse is in, or zero if the mouse is in no
118 Emacs frame. If it is set to zero, all the other arguments are
119 garbage.
120
121 If the motion started in a scroll bar, set *bar_window to the
122 scroll bar's window, *part to the part the mouse is currently over,
123 *x to the position of the mouse along the scroll bar, and *y to the
124 overall length of the scroll bar.
125
126 Otherwise, set *bar_window to Qnil, and *x and *y to the column and
127 row of the character cell the mouse is over.
128
129 Set *time to the time the mouse was at the returned position.
130
131 This should clear mouse_moved until the next motion
132 event arrives. */
133extern void (*mouse_position_hook) P_ ((struct frame **f, int,
134 Lisp_Object *bar_window,
135 enum scroll_bar_part *part,
136 Lisp_Object *x,
137 Lisp_Object *y,
138 unsigned long *time));
139
140/* The window system handling code should set this if the mouse has
141 moved since the last call to the mouse_position_hook. Calling that
142 hook should clear this. */
143extern int mouse_moved;
144
145/* When a frame's focus redirection is changed, this hook tells the
146 window system code to re-decide where to put the highlight. Under
147 X, this means that Emacs lies about where the focus is. */
148extern void (*frame_rehighlight_hook) P_ ((struct frame *));
149
150/* If we're displaying frames using a window system that can stack
151 frames on top of each other, this hook allows you to bring a frame
152 to the front, or bury it behind all the other windows. If this
153 hook is zero, that means the device we're displaying on doesn't
154 support overlapping frames, so there's no need to raise or lower
155 anything.
156
157 If RAISE is non-zero, F is brought to the front, before all other
158 windows. If RAISE is zero, F is sent to the back, behind all other
159 windows. */
160extern void (*frame_raise_lower_hook) P_ ((struct frame *f, int raise));
161
162
163/* Scroll bar hooks. */
164
165/* The representation of scroll bars is determined by the code which
166 implements them, except for one thing: they must be represented by
167 lisp objects. This allows us to place references to them in
168 Lisp_Windows without worrying about those references becoming
169 dangling references when the scroll bar is destroyed.
170
171 The window-system-independent portion of Emacs just refers to
172 scroll bars via their windows, and never looks inside the scroll bar
173 representation; it always uses hook functions to do all the
174 scroll bar manipulation it needs.
175
176 The `vertical_scroll_bar' field of a Lisp_Window refers to that
177 window's scroll bar, or is nil if the window doesn't have a
178 scroll bar.
179
180 The `scroll_bars' and `condemned_scroll_bars' fields of a Lisp_Frame
181 are free for use by the scroll bar implementation in any way it sees
182 fit. They are marked by the garbage collector. */
183
184
185/* Set the vertical scroll bar for WINDOW to have its upper left corner
186 at (TOP, LEFT), and be LENGTH rows high. Set its handle to
187 indicate that we are displaying PORTION characters out of a total
188 of WHOLE characters, starting at POSITION. If WINDOW doesn't yet
189 have a scroll bar, create one for it. */
190extern void (*set_vertical_scroll_bar_hook)
191 P_ ((struct window *window,
192 int portion, int whole, int position));
193
194
195/* The following three hooks are used when we're doing a thorough
196 redisplay of the frame. We don't explicitly know which scroll bars
197 are going to be deleted, because keeping track of when windows go
198 away is a real pain - can you say set-window-configuration?
199 Instead, we just assert at the beginning of redisplay that *all*
200 scroll bars are to be removed, and then save scroll bars from the
201 fiery pit when we actually redisplay their window. */
202
203/* Arrange for all scroll bars on FRAME to be removed at the next call
204 to `*judge_scroll_bars_hook'. A scroll bar may be spared if
205 `*redeem_scroll_bar_hook' is applied to its window before the judgement.
206
207 This should be applied to each frame each time its window tree is
208 redisplayed, even if it is not displaying scroll bars at the moment;
209 if the HAS_SCROLL_BARS flag has just been turned off, only calling
210 this and the judge_scroll_bars_hook will get rid of them.
211
212 If non-zero, this hook should be safe to apply to any frame,
213 whether or not it can support scroll bars, and whether or not it is
214 currently displaying them. */
215extern void (*condemn_scroll_bars_hook) P_ ((struct frame *frame));
216
217/* Unmark WINDOW's scroll bar for deletion in this judgement cycle.
218 Note that it's okay to redeem a scroll bar that is not condemned. */
219extern void (*redeem_scroll_bar_hook) P_ ((struct window *window));
220
221/* Remove all scroll bars on FRAME that haven't been saved since the
222 last call to `*condemn_scroll_bars_hook'.
223
224 This should be applied to each frame after each time its window
225 tree is redisplayed, even if it is not displaying scroll bars at the
226 moment; if the HAS_SCROLL_BARS flag has just been turned off, only
227 calling this and condemn_scroll_bars_hook will get rid of them.
228
229 If non-zero, this hook should be safe to apply to any frame,
230 whether or not it can support scroll bars, and whether or not it is
231 currently displaying them. */
232extern void (*judge_scroll_bars_hook) P_ ((struct frame *FRAME));
233
234 45
235/* Input queue declarations and hooks. */ 46/* Input queue declarations and hooks. */
236 47
@@ -413,13 +224,6 @@ struct input_event
413 224
414#define EVENT_INIT(event) bzero (&(event), sizeof (struct input_event)) 225#define EVENT_INIT(event) bzero (&(event), sizeof (struct input_event))
415 226
416/* Called to read input events. */
417extern int (*read_socket_hook) P_ ((struct input_event *, int, int));
418
419/* Called when a frame's display becomes entirely up to date. */
420extern void (*frame_up_to_date_hook) P_ ((struct frame *));
421
422
423/* Bits in the modifiers member of the input_event structure. 227/* Bits in the modifiers member of the input_event structure.
424 Note that reorder_modifiers assumes that the bits are in canonical 228 Note that reorder_modifiers assumes that the bits are in canonical
425 order. 229 order.
@@ -471,5 +275,258 @@ enum {
471 275
472#endif /* CONSP */ 276#endif /* CONSP */
473 277
278
279/* Display-local parameters. */
280struct display
281{
282 /* Chain of all displays. */
283 struct display *next_display;
284
285 /* The number of frames that are on this display. */
286 int reference_count;
287
288 /* The type of the display. */
289 enum output_method type;
290
291 /* Display-type dependent data shared amongst all frames on this display. */
292 union display_info
293 {
294 struct tty_display_info *tty; /* termchar.h */
295 struct x_display_info *x; /* xterm.h */
296 } display_info;
297
298
299 /* Terminal characteristics. */
300 /* XXX Are these really used on non-termcap displays? */
301
302 int must_write_spaces; /* Nonzero means spaces in the text must
303 actually be output; can't just skip over
304 some columns to leave them blank. */
305 int fast_clear_end_of_line; /* Nonzero means terminal has a `ce' string */
306
307 int line_ins_del_ok; /* Terminal can insert and delete lines */
308 int char_ins_del_ok; /* Terminal can insert and delete chars */
309 int scroll_region_ok; /* Terminal supports setting the scroll
310 window */
311 int scroll_region_cost; /* Cost of setting the scroll window,
312 measured in characters. */
313 int memory_below_frame; /* Terminal remembers lines scrolled
314 off bottom */
315
316#if 0 /* These are not used anywhere. */
317 /* EMACS_INT baud_rate; */ /* Output speed in baud */
318 int min_padding_speed; /* Speed below which no padding necessary. */
319 int dont_calculate_costs; /* Nonzero means don't bother computing
320 various cost tables; we won't use them. */
321#endif
322
323
324 /* Window-based redisplay interface for this device (0 for tty
325 devices). */
326 struct redisplay_interface *rif;
327
328 /* Frame-based redisplay interface. */
329
330 /* Text display hooks. */
331
332 void (*cursor_to_hook) P_ ((int vpos, int hpos));
333 void (*raw_cursor_to_hook) P_ ((int, int));
334
335 void (*clear_to_end_hook) P_ ((void));
336 void (*clear_frame_hook) P_ ((void));
337 void (*clear_end_of_line_hook) P_ ((int));
338
339 void (*ins_del_lines_hook) P_ ((int, int));
340
341 void (*insert_glyphs_hook) P_ ((struct glyph *s, int n));
342 void (*write_glyphs_hook) P_ ((struct glyph *s, int n));
343 void (*delete_glyphs_hook) P_ ((int));
344
345 void (*ring_bell_hook) P_ ((void));
346
347 void (*reset_terminal_modes_hook) P_ ((void));
348 void (*set_terminal_modes_hook) P_ ((void));
349 void (*update_begin_hook) P_ ((struct frame *));
350 void (*update_end_hook) P_ ((struct frame *));
351 void (*set_terminal_window_hook) P_ ((int));
352
353 /* Multi-frame and mouse support hooks. */
354
355 /* Return the current position of the mouse.
356
357 Set *f to the frame the mouse is in, or zero if the mouse is in no
358 Emacs frame. If it is set to zero, all the other arguments are
359 garbage.
360
361 If the motion started in a scroll bar, set *bar_window to the
362 scroll bar's window, *part to the part the mouse is currently over,
363 *x to the position of the mouse along the scroll bar, and *y to the
364 overall length of the scroll bar.
365
366 Otherwise, set *bar_window to Qnil, and *x and *y to the column and
367 row of the character cell the mouse is over.
368
369 Set *time to the time the mouse was at the returned position.
370
371 This should clear mouse_moved until the next motion
372 event arrives. */
373 void (*mouse_position_hook) P_ ((struct frame **f, int,
374 Lisp_Object *bar_window,
375 enum scroll_bar_part *part,
376 Lisp_Object *x,
377 Lisp_Object *y,
378 unsigned long *time));
379
380 /* The window system handling code should set this if the mouse has
381 moved since the last call to the mouse_position_hook. Calling that
382 hook should clear this. */
383 int mouse_moved;
384
385 /* When a frame's focus redirection is changed, this hook tells the
386 window system code to re-decide where to put the highlight. Under
387 X, this means that Emacs lies about where the focus is. */
388 void (*frame_rehighlight_hook) P_ ((struct frame *));
389
390 /* If we're displaying frames using a window system that can stack
391 frames on top of each other, this hook allows you to bring a frame
392 to the front, or bury it behind all the other windows. If this
393 hook is zero, that means the device we're displaying on doesn't
394 support overlapping frames, so there's no need to raise or lower
395 anything.
396
397 If RAISE is non-zero, F is brought to the front, before all other
398 windows. If RAISE is zero, F is sent to the back, behind all other
399 windows. */
400 void (*frame_raise_lower_hook) P_ ((struct frame *f, int raise));
401
402
403 /* Scroll bar hooks. */
404
405 /* The representation of scroll bars is determined by the code which
406 implements them, except for one thing: they must be represented by
407 lisp objects. This allows us to place references to them in
408 Lisp_Windows without worrying about those references becoming
409 dangling references when the scroll bar is destroyed.
410
411 The window-system-independent portion of Emacs just refers to
412 scroll bars via their windows, and never looks inside the scroll bar
413 representation; it always uses hook functions to do all the
414 scroll bar manipulation it needs.
415
416 The `vertical_scroll_bar' field of a Lisp_Window refers to that
417 window's scroll bar, or is nil if the window doesn't have a
418 scroll bar.
419
420 The `scroll_bars' and `condemned_scroll_bars' fields of a Lisp_Frame
421 are free for use by the scroll bar implementation in any way it sees
422 fit. They are marked by the garbage collector. */
423
424
425 /* Set the vertical scroll bar for WINDOW to have its upper left corner
426 at (TOP, LEFT), and be LENGTH rows high. Set its handle to
427 indicate that we are displaying PORTION characters out of a total
428 of WHOLE characters, starting at POSITION. If WINDOW doesn't yet
429 have a scroll bar, create one for it. */
430 void (*set_vertical_scroll_bar_hook) P_ ((struct window *window,
431 int portion, int whole,
432 int position));
433
434
435 /* The following three hooks are used when we're doing a thorough
436 redisplay of the frame. We don't explicitly know which scroll bars
437 are going to be deleted, because keeping track of when windows go
438 away is a real pain - can you say set-window-configuration?
439 Instead, we just assert at the beginning of redisplay that *all*
440 scroll bars are to be removed, and then save scroll bars from the
441 fiery pit when we actually redisplay their window. */
442
443 /* Arrange for all scroll bars on FRAME to be removed at the next call
444 to `*judge_scroll_bars_hook'. A scroll bar may be spared if
445 `*redeem_scroll_bar_hook' is applied to its window before the judgement.
446
447 This should be applied to each frame each time its window tree is
448 redisplayed, even if it is not displaying scroll bars at the moment;
449 if the HAS_SCROLL_BARS flag has just been turned off, only calling
450 this and the judge_scroll_bars_hook will get rid of them.
451
452 If non-zero, this hook should be safe to apply to any frame,
453 whether or not it can support scroll bars, and whether or not it is
454 currently displaying them. */
455 void (*condemn_scroll_bars_hook) P_ ((struct frame *frame));
456
457 /* Unmark WINDOW's scroll bar for deletion in this judgement cycle.
458 Note that it's okay to redeem a scroll bar that is not condemned. */
459 void (*redeem_scroll_bar_hook) P_ ((struct window *window));
460
461 /* Remove all scroll bars on FRAME that haven't been saved since the
462 last call to `*condemn_scroll_bars_hook'.
463
464 This should be applied to each frame after each time its window
465 tree is redisplayed, even if it is not displaying scroll bars at the
466 moment; if the HAS_SCROLL_BARS flag has just been turned off, only
467 calling this and condemn_scroll_bars_hook will get rid of them.
468
469 If non-zero, this hook should be safe to apply to any frame,
470 whether or not it can support scroll bars, and whether or not it is
471 currently displaying them. */
472 void (*judge_scroll_bars_hook) P_ ((struct frame *FRAME));
473
474
475 /* Called to read input events. */
476 int (*read_socket_hook) P_ ((struct input_event *, int, int));
477
478 /* Called when a frame's display becomes entirely up to date. */
479 void (*frame_up_to_date_hook) P_ ((struct frame *));
480
481
482 /* Called to delete the device-specific portions of a frame that is
483 on this display. */
484 void (*delete_frame_hook) P_ ((struct frame *));
485
486 /* Called after the last frame on this display is deleted.
487 If this is NULL, then the generic delete_frame() is called.
488
489 Fdelete_frame ensures that there are no live frames on the
490 display when it calls this hook. */
491 void (*delete_display_hook) P_ ((struct display *));
492
493};
494
495
496/* Chain of all displays currently in use. */
497extern struct display *display_list;
498
499#define FRAME_MUST_WRITE_SPACES(f) ((f)->display->must_write_spaces)
500#define FRAME_FAST_CLEAR_END_OF_LINE(f) ((f)->display->fast_clear_end_of_line)
501#define FRAME_LINE_INS_DEL_OK(f) ((f)->display->line_ins_del_ok)
502#define FRAME_CHAR_INS_DEL_OK(f) ((f)->display->char_ins_del_ok)
503#define FRAME_SCROLL_REGION_OK(f) ((f)->display->scroll_region_ok)
504#define FRAME_SCROLL_REGION_COST(f) ((f)->display->scroll_region_cost)
505#define FRAME_MEMORY_BELOW_FRAME(f) ((f)->display->memory_below_frame)
506
507#define FRAME_RIF(f) ((f)->display->rif)
508
509#define FRAME_DISPLAY(f) ((f)->display)
510
511/* FRAME_WINDOW_P tests whether the frame is a window, and is
512 defined to be the predicate for the window system being used. */
513
514#ifdef HAVE_X_WINDOWS
515#define FRAME_WINDOW_P(f) FRAME_X_P (f)
516#endif
517#ifdef HAVE_NTGUI
518#define FRAME_WINDOW_P(f) FRAME_W32_P (f)
519#endif
520#ifdef MAC_OS
521#define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
522#endif
523#ifndef FRAME_WINDOW_P
524#define FRAME_WINDOW_P(f) (0)
525#endif
526
527
528extern struct display *create_display P_ ((void));
529extern void delete_display P_ ((struct display *));
530
474/* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d 531/* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d
475 (do not change this comment) */ 532 (do not change this comment) */
diff --git a/src/window.c b/src/window.c
index 854fb712a2d..c4d896532b1 100644
--- a/src/window.c
+++ b/src/window.c
@@ -31,7 +31,6 @@ Boston, MA 02111-1307, USA. */
31#include "window.h" 31#include "window.h"
32#include "commands.h" 32#include "commands.h"
33#include "indent.h" 33#include "indent.h"
34#include "systty.h" /* For emacs_tty in termchar.h */
35#include "termchar.h" 34#include "termchar.h"
36#include "disptab.h" 35#include "disptab.h"
37#include "dispextern.h" 36#include "dispextern.h"
diff --git a/src/xdisp.c b/src/xdisp.c
index dcddeeb9037..65c914d65fa 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -173,7 +173,6 @@ Boston, MA 02111-1307, USA. */
173#include "keyboard.h" 173#include "keyboard.h"
174#include "frame.h" 174#include "frame.h"
175#include "window.h" 175#include "window.h"
176#include "systty.h" /* For emacs_tty in termchar.h */
177#include "termchar.h" 176#include "termchar.h"
178#include "dispextern.h" 177#include "dispextern.h"
179#include "buffer.h" 178#include "buffer.h"
@@ -6458,8 +6457,8 @@ message2_nolog (m, nbytes, multibyte)
6458 do_pending_window_change (0); 6457 do_pending_window_change (0);
6459 echo_area_display (1); 6458 echo_area_display (1);
6460 do_pending_window_change (0); 6459 do_pending_window_change (0);
6461 if (frame_up_to_date_hook != 0 && ! gc_in_progress) 6460 if (FRAME_DISPLAY (f)->frame_up_to_date_hook != 0 && ! gc_in_progress)
6462 (*frame_up_to_date_hook) (f); 6461 (*FRAME_DISPLAY (f)->frame_up_to_date_hook) (f);
6463 } 6462 }
6464} 6463}
6465 6464
@@ -6544,8 +6543,8 @@ message3_nolog (m, nbytes, multibyte)
6544 do_pending_window_change (0); 6543 do_pending_window_change (0);
6545 echo_area_display (1); 6544 echo_area_display (1);
6546 do_pending_window_change (0); 6545 do_pending_window_change (0);
6547 if (frame_up_to_date_hook != 0 && ! gc_in_progress) 6546 if (FRAME_DISPLAY (f)->frame_up_to_date_hook != 0 && ! gc_in_progress)
6548 (*frame_up_to_date_hook) (f); 6547 (*FRAME_DISPLAY (f)->frame_up_to_date_hook) (f);
6549 } 6548 }
6550} 6549}
6551 6550
@@ -7616,11 +7615,11 @@ echo_area_display (update_frame_p)
7616/* The terminal frame is used as the first Emacs frame on the Mac OS. */ 7615/* The terminal frame is used as the first Emacs frame on the Mac OS. */
7617#ifndef MAC_OS8 7616#ifndef MAC_OS8
7618#ifdef HAVE_WINDOW_SYSTEM 7617#ifdef HAVE_WINDOW_SYSTEM
7619 /* When Emacs starts, selected_frame may be a visible terminal 7618 /* When Emacs starts, selected_frame may be the initial terminal
7620 frame, even if we run under a window system. If we let this 7619 frame. If we let this through, a message would be displayed on
7621 through, a message would be displayed on the terminal. */ 7620 the terminal. */
7622 if (!FRAME_WINDOW_P (XFRAME (selected_frame)) 7621 if (FRAME_TERMCAP_P (XFRAME (selected_frame))
7623 && !NILP (Vwindow_system)) 7622 && FRAME_TTY (XFRAME (selected_frame))->type == NULL)
7624 return 0; 7623 return 0;
7625#endif /* HAVE_WINDOW_SYSTEM */ 7624#endif /* HAVE_WINDOW_SYSTEM */
7626#endif 7625#endif
@@ -10100,16 +10099,16 @@ redisplay_internal (preserve_echo_area)
10100 10099
10101 /* Mark all the scroll bars to be removed; we'll redeem 10100 /* Mark all the scroll bars to be removed; we'll redeem
10102 the ones we want when we redisplay their windows. */ 10101 the ones we want when we redisplay their windows. */
10103 if (condemn_scroll_bars_hook) 10102 if (FRAME_DISPLAY (f)->condemn_scroll_bars_hook)
10104 condemn_scroll_bars_hook (f); 10103 FRAME_DISPLAY (f)->condemn_scroll_bars_hook (f);
10105 10104
10106 if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f)) 10105 if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f))
10107 redisplay_windows (FRAME_ROOT_WINDOW (f)); 10106 redisplay_windows (FRAME_ROOT_WINDOW (f));
10108 10107
10109 /* Any scroll bars which redisplay_windows should have 10108 /* Any scroll bars which redisplay_windows should have
10110 nuked should now go away. */ 10109 nuked should now go away. */
10111 if (judge_scroll_bars_hook) 10110 if (FRAME_DISPLAY (f)->judge_scroll_bars_hook)
10112 judge_scroll_bars_hook (f); 10111 FRAME_DISPLAY (f)->judge_scroll_bars_hook (f);
10113 10112
10114 /* If fonts changed, display again. */ 10113 /* If fonts changed, display again. */
10115 /* ??? rms: I suspect it is a mistake to jump all the way 10114 /* ??? rms: I suspect it is a mistake to jump all the way
@@ -10161,8 +10160,8 @@ redisplay_internal (preserve_echo_area)
10161 { 10160 {
10162 struct frame *f = updated[i]; 10161 struct frame *f = updated[i];
10163 mark_window_display_accurate (f->root_window, 1); 10162 mark_window_display_accurate (f->root_window, 1);
10164 if (frame_up_to_date_hook) 10163 if (FRAME_DISPLAY (f)->frame_up_to_date_hook)
10165 frame_up_to_date_hook (f); 10164 FRAME_DISPLAY (f)->frame_up_to_date_hook (f);
10166 } 10165 }
10167 } 10166 }
10168 } 10167 }
@@ -10251,8 +10250,8 @@ redisplay_internal (preserve_echo_area)
10251 last_arrow_position = COERCE_MARKER (Voverlay_arrow_position); 10250 last_arrow_position = COERCE_MARKER (Voverlay_arrow_position);
10252 last_arrow_string = Voverlay_arrow_string; 10251 last_arrow_string = Voverlay_arrow_string;
10253 10252
10254 if (frame_up_to_date_hook != 0) 10253 if (FRAME_DISPLAY (sf)->frame_up_to_date_hook != 0)
10255 frame_up_to_date_hook (sf); 10254 FRAME_DISPLAY (sf)->frame_up_to_date_hook (sf);
10256 } 10255 }
10257 10256
10258 update_mode_lines = 0; 10257 update_mode_lines = 0;
@@ -11390,7 +11389,9 @@ set_vertical_scroll_bar (w)
11390 start = end = whole = 0; 11389 start = end = whole = 0;
11391 11390
11392 /* Indicate what this scroll bar ought to be displaying now. */ 11391 /* Indicate what this scroll bar ought to be displaying now. */
11393 set_vertical_scroll_bar_hook (w, end - start, whole, start); 11392 if (FRAME_DISPLAY (XFRAME (w->frame))->set_vertical_scroll_bar_hook)
11393 (*FRAME_DISPLAY (XFRAME (w->frame))->set_vertical_scroll_bar_hook)
11394 (w, end - start, whole, start);
11394} 11395}
11395 11396
11396/* Redisplay leaf window WINDOW. JUST_THIS_ONE_P non-zero means only 11397/* Redisplay leaf window WINDOW. JUST_THIS_ONE_P non-zero means only
@@ -12091,7 +12092,8 @@ redisplay_window (window, just_this_one_p)
12091 12092
12092 /* Note that we actually used the scroll bar attached to this 12093 /* Note that we actually used the scroll bar attached to this
12093 window, so it shouldn't be deleted at the end of redisplay. */ 12094 window, so it shouldn't be deleted at the end of redisplay. */
12094 redeem_scroll_bar_hook (w); 12095 if (FRAME_DISPLAY (f)->redeem_scroll_bar_hook)
12096 (*FRAME_DISPLAY (f)->redeem_scroll_bar_hook) (w);
12095 } 12097 }
12096 12098
12097 /* Restore current_buffer and value of point in it. */ 12099 /* Restore current_buffer and value of point in it. */
diff --git a/src/xfaces.c b/src/xfaces.c
index 9f51f118f3e..77a2663a2cb 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -200,6 +200,7 @@ Boston, MA 02111-1307, USA. */
200#include "charset.h" 200#include "charset.h"
201#include "keyboard.h" 201#include "keyboard.h"
202#include "frame.h" 202#include "frame.h"
203#include "termhooks.h"
203 204
204#ifdef HAVE_WINDOW_SYSTEM 205#ifdef HAVE_WINDOW_SYSTEM
205#include "fontset.h" 206#include "fontset.h"
@@ -5407,7 +5408,7 @@ substitution of a `dim' face for italic. */)
5407 /* See if the capabilities we selected above are supported, with the 5408 /* See if the capabilities we selected above are supported, with the
5408 given colors. */ 5409 given colors. */
5409 if (test_caps != 0 && 5410 if (test_caps != 0 &&
5410 ! tty_capable_p (FRAME_TTY (SELECTED_FRAME ()), test_caps, fg_tty_color.pixel, bg_tty_color.pixel)) 5411 ! tty_capable_p (FRAME_TTY (f), test_caps, fg_tty_color.pixel, bg_tty_color.pixel))
5411 return Qnil; 5412 return Qnil;
5412 5413
5413 5414
diff --git a/src/xfns.c b/src/xfns.c
index bfb4140f8d1..3a1c861686d 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -48,7 +48,6 @@ Boston, MA 02111-1307, USA. */
48#include "systime.h" 48#include "systime.h"
49#include "termhooks.h" 49#include "termhooks.h"
50#include "atimer.h" 50#include "atimer.h"
51#include "systty.h"
52#include "termchar.h" 51#include "termchar.h"
53 52
54#ifdef HAVE_X_WINDOWS 53#ifdef HAVE_X_WINDOWS
@@ -1762,10 +1761,10 @@ x_set_scroll_bar_foreground (f, value, oldval)
1762 if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f)) 1761 if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))
1763 { 1762 {
1764 /* Remove all scroll bars because they have wrong colors. */ 1763 /* Remove all scroll bars because they have wrong colors. */
1765 if (condemn_scroll_bars_hook) 1764 if (FRAME_DISPLAY (f)->condemn_scroll_bars_hook)
1766 (*condemn_scroll_bars_hook) (f); 1765 (*FRAME_DISPLAY (f)->condemn_scroll_bars_hook) (f);
1767 if (judge_scroll_bars_hook) 1766 if (FRAME_DISPLAY (f)->judge_scroll_bars_hook)
1768 (*judge_scroll_bars_hook) (f); 1767 (*FRAME_DISPLAY (f)->judge_scroll_bars_hook) (f);
1769 1768
1770 update_face_from_frame_parameter (f, Qscroll_bar_foreground, value); 1769 update_face_from_frame_parameter (f, Qscroll_bar_foreground, value);
1771 redraw_frame (f); 1770 redraw_frame (f);
@@ -1811,10 +1810,10 @@ x_set_scroll_bar_background (f, value, oldval)
1811 if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f)) 1810 if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))
1812 { 1811 {
1813 /* Remove all scroll bars because they have wrong colors. */ 1812 /* Remove all scroll bars because they have wrong colors. */
1814 if (condemn_scroll_bars_hook) 1813 if (FRAME_DISPLAY (f)->condemn_scroll_bars_hook)
1815 (*condemn_scroll_bars_hook) (f); 1814 (*FRAME_DISPLAY (f)->condemn_scroll_bars_hook) (f);
1816 if (judge_scroll_bars_hook) 1815 if (FRAME_DISPLAY (f)->judge_scroll_bars_hook)
1817 (*judge_scroll_bars_hook) (f); 1816 (*FRAME_DISPLAY (f)->judge_scroll_bars_hook) (f);
1818 1817
1819 update_face_from_frame_parameter (f, Qscroll_bar_background, value); 1818 update_face_from_frame_parameter (f, Qscroll_bar_background, value);
1820 redraw_frame (f); 1819 redraw_frame (f);
@@ -3245,7 +3244,9 @@ This function is an internal primitive--use `make-frame' instead. */)
3245 /* Note that X Windows does support scroll bars. */ 3244 /* Note that X Windows does support scroll bars. */
3246 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1; 3245 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
3247 3246
3248 f->display_method = &x_display_method; 3247 f->display = dpyinfo->frame_display;
3248 f->display->reference_count++;
3249
3249 f->output_method = output_x_window; 3250 f->output_method = output_x_window;
3250 f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output)); 3251 f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
3251 bzero (f->output_data.x, sizeof (struct x_output)); 3252 bzero (f->output_data.x, sizeof (struct x_output));
@@ -9981,7 +9982,8 @@ x_create_tip_frame (dpyinfo, parms, text)
9981 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; 9982 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
9982 record_unwind_protect (unwind_create_tip_frame, frame); 9983 record_unwind_protect (unwind_create_tip_frame, frame);
9983 9984
9984 f->display_method = &x_display_method; 9985 f->display = dpyinfo->frame_display;
9986 f->display->reference_count++;
9985 9987
9986 /* By setting the output method, we're essentially saying that 9988 /* By setting the output method, we're essentially saying that
9987 the frame is live, as per FRAME_LIVE_P. If we get a signal 9989 the frame is live, as per FRAME_LIVE_P. If we get a signal
diff --git a/src/xmenu.c b/src/xmenu.c
index 669d8177c15..7c3aa8002b1 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -39,10 +39,10 @@ Boston, MA 02111-1307, USA. */
39#include <stdio.h> 39#include <stdio.h>
40 40
41#include "lisp.h" 41#include "lisp.h"
42#include "termhooks.h"
43#include "keyboard.h" 42#include "keyboard.h"
44#include "keymap.h" 43#include "keymap.h"
45#include "frame.h" 44#include "frame.h"
45#include "termhooks.h"
46#include "window.h" 46#include "window.h"
47#include "blockinput.h" 47#include "blockinput.h"
48#include "buffer.h" 48#include "buffer.h"
diff --git a/src/xselect.c b/src/xselect.c
index 8eda4b78464..e1dbb4601dc 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -302,13 +302,20 @@ x_own_selection (selection_name, selection_value)
302 Lisp_Object selection_name, selection_value; 302 Lisp_Object selection_name, selection_value;
303{ 303{
304 struct frame *sf = SELECTED_FRAME (); 304 struct frame *sf = SELECTED_FRAME ();
305 Window selecting_window = FRAME_X_WINDOW (sf); 305 Window selecting_window;
306 Display *display = FRAME_X_DISPLAY (sf); 306 Display *display;
307 Time time = last_event_timestamp; 307 Time time = last_event_timestamp;
308 Atom selection_atom; 308 Atom selection_atom;
309 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (sf); 309 struct x_display_info *dpyinfo;
310 int count; 310 int count;
311 311
312 if (! FRAME_X_P (sf))
313 return;
314
315 selecting_window = FRAME_X_WINDOW (sf);
316 display = FRAME_X_DISPLAY (sf);
317 dpyinfo = FRAME_X_DISPLAY_INFO (sf);
318
312 CHECK_SYMBOL (selection_name); 319 CHECK_SYMBOL (selection_name);
313 selection_atom = symbol_to_x_atom (dpyinfo, display, selection_name); 320 selection_atom = symbol_to_x_atom (dpyinfo, display, selection_name);
314 321
@@ -572,7 +579,8 @@ some_frame_on_display (dpyinfo)
572 579
573 FOR_EACH_FRAME (list, frame) 580 FOR_EACH_FRAME (list, frame)
574 { 581 {
575 if (FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo) 582 if (FRAME_X_P (XFRAME (frame))
583 && FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo)
576 return frame; 584 return frame;
577 } 585 }
578 586
@@ -1219,17 +1227,26 @@ x_get_foreign_selection (selection_symbol, target_type)
1219 Lisp_Object selection_symbol, target_type; 1227 Lisp_Object selection_symbol, target_type;
1220{ 1228{
1221 struct frame *sf = SELECTED_FRAME (); 1229 struct frame *sf = SELECTED_FRAME ();
1222 Window requestor_window = FRAME_X_WINDOW (sf); 1230 Window requestor_window;
1223 Display *display = FRAME_X_DISPLAY (sf); 1231 Display *display;
1224 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (sf); 1232 struct x_display_info *dpyinfo;
1225 Time requestor_time = last_event_timestamp; 1233 Time requestor_time = last_event_timestamp;
1226 Atom target_property = dpyinfo->Xatom_EMACS_TMP; 1234 Atom target_property;
1227 Atom selection_atom = symbol_to_x_atom (dpyinfo, display, selection_symbol); 1235 Atom selection_atom;
1228 Atom type_atom; 1236 Atom type_atom;
1229 int secs, usecs; 1237 int secs, usecs;
1230 int count; 1238 int count;
1231 Lisp_Object frame; 1239 Lisp_Object frame;
1232 1240
1241 if (! FRAME_X_P (sf))
1242 return Qnil;
1243
1244 requestor_window = FRAME_X_WINDOW (sf);
1245 display = FRAME_X_DISPLAY (sf);
1246 dpyinfo = FRAME_X_DISPLAY_INFO (sf);
1247 target_property = dpyinfo->Xatom_EMACS_TMP;
1248 selection_atom = symbol_to_x_atom (dpyinfo, display, selection_symbol);
1249
1233 if (CONSP (target_type)) 1250 if (CONSP (target_type))
1234 type_atom = symbol_to_x_atom (dpyinfo, display, XCAR (target_type)); 1251 type_atom = symbol_to_x_atom (dpyinfo, display, XCAR (target_type));
1235 else 1252 else
@@ -1989,6 +2006,9 @@ Disowning it means there is no such selection. */)
1989 struct frame *sf = SELECTED_FRAME (); 2006 struct frame *sf = SELECTED_FRAME ();
1990 2007
1991 check_x (); 2008 check_x ();
2009 if (! FRAME_X_P (sf))
2010 return Qnil;
2011
1992 display = FRAME_X_DISPLAY (sf); 2012 display = FRAME_X_DISPLAY (sf);
1993 dpyinfo = FRAME_X_DISPLAY_INFO (sf); 2013 dpyinfo = FRAME_X_DISPLAY_INFO (sf);
1994 CHECK_SYMBOL (selection); 2014 CHECK_SYMBOL (selection);
@@ -2152,6 +2172,10 @@ DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal,
2152 struct frame *sf = SELECTED_FRAME (); 2172 struct frame *sf = SELECTED_FRAME ();
2153 2173
2154 check_x (); 2174 check_x ();
2175
2176 if (! FRAME_X_P (sf))
2177 return Qnil;
2178
2155 display = FRAME_X_DISPLAY (sf); 2179 display = FRAME_X_DISPLAY (sf);
2156 dpyinfo = FRAME_X_DISPLAY_INFO (sf); 2180 dpyinfo = FRAME_X_DISPLAY_INFO (sf);
2157 window = RootWindow (display, 0); /* Cut buffers are on screen 0 */ 2181 window = RootWindow (display, 0); /* Cut buffers are on screen 0 */
@@ -2193,6 +2217,10 @@ DEFUN ("x-store-cut-buffer-internal", Fx_store_cut_buffer_internal,
2193 struct frame *sf = SELECTED_FRAME (); 2217 struct frame *sf = SELECTED_FRAME ();
2194 2218
2195 check_x (); 2219 check_x ();
2220
2221 if (! FRAME_X_P (sf))
2222 return Qnil;
2223
2196 display = FRAME_X_DISPLAY (sf); 2224 display = FRAME_X_DISPLAY (sf);
2197 window = RootWindow (display, 0); /* Cut buffers are on screen 0 */ 2225 window = RootWindow (display, 0); /* Cut buffers are on screen 0 */
2198 2226
@@ -2249,8 +2277,12 @@ Positive means shift the values forward, negative means backward. */)
2249 Atom props[8]; 2277 Atom props[8];
2250 Display *display; 2278 Display *display;
2251 struct frame *sf = SELECTED_FRAME (); 2279 struct frame *sf = SELECTED_FRAME ();
2252 2280
2253 check_x (); 2281 check_x ();
2282
2283 if (! FRAME_X_P (sf))
2284 return Qnil;
2285
2254 display = FRAME_X_DISPLAY (sf); 2286 display = FRAME_X_DISPLAY (sf);
2255 window = RootWindow (display, 0); /* Cut buffers are on screen 0 */ 2287 window = RootWindow (display, 0); /* Cut buffers are on screen 0 */
2256 CHECK_NUMBER (n); 2288 CHECK_NUMBER (n);
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 091d21327ac..88ee0a78188 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -48,6 +48,7 @@ Boston, MA 02111-1307, USA. */
48#include "systime.h" 48#include "systime.h"
49#include "sysselect.h" 49#include "sysselect.h"
50#include "lisp.h" 50#include "lisp.h"
51#include "frame.h"
51#include "termhooks.h" 52#include "termhooks.h"
52#include "termopts.h" 53#include "termopts.h"
53#include "xterm.h" 54#include "xterm.h"
diff --git a/src/xterm.c b/src/xterm.c
index b850139de4c..fcb431a472c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -54,7 +54,6 @@ Boston, MA 02111-1307, USA. */
54#include <sys/ioctl.h> 54#include <sys/ioctl.h>
55#endif /* ! defined (BSD_SYSTEM) */ 55#endif /* ! defined (BSD_SYSTEM) */
56 56
57#include "systty.h"
58#include "systime.h" 57#include "systime.h"
59 58
60#ifndef INCLUDED_FCNTL 59#ifndef INCLUDED_FCNTL
@@ -184,10 +183,6 @@ static Lisp_Object last_window;
184 183
185int x_use_underline_position_properties; 184int x_use_underline_position_properties;
186 185
187/* Generic display parameters for X displays. */
188
189struct display_method x_display_method;
190
191/* This is a chain of structures for all the X displays currently in 186/* This is a chain of structures for all the X displays currently in
192 use. */ 187 use. */
193 188
@@ -329,6 +324,8 @@ void x_raise_frame P_ ((struct frame *));
329void x_set_window_size P_ ((struct frame *, int, int, int)); 324void x_set_window_size P_ ((struct frame *, int, int, int));
330void x_wm_set_window_state P_ ((struct frame *, int)); 325void x_wm_set_window_state P_ ((struct frame *, int));
331void x_wm_set_icon_pixmap P_ ((struct frame *, int)); 326void x_wm_set_icon_pixmap P_ ((struct frame *, int));
327struct display *x_create_frame_display P_ ((struct x_display_info *));
328void x_delete_frame_display P_ ((struct display *));
332void x_initialize P_ ((void)); 329void x_initialize P_ ((void));
333static void x_font_min_bounds P_ ((XFontStruct *, int *, int *)); 330static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
334static int x_compute_min_glyph_bounds P_ ((struct frame *)); 331static int x_compute_min_glyph_bounds P_ ((struct frame *));
@@ -10232,6 +10229,7 @@ x_term_init (display_name, xrm_option, resource_name)
10232{ 10229{
10233 int connection; 10230 int connection;
10234 Display *dpy; 10231 Display *dpy;
10232 struct display *display;
10235 struct x_display_info *dpyinfo; 10233 struct x_display_info *dpyinfo;
10236 XrmDatabase xrdb; 10234 XrmDatabase xrdb;
10237 10235
@@ -10366,6 +10364,8 @@ x_term_init (display_name, xrm_option, resource_name)
10366 dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info)); 10364 dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info));
10367 bzero (dpyinfo, sizeof *dpyinfo); 10365 bzero (dpyinfo, sizeof *dpyinfo);
10368 10366
10367 display = x_create_frame_display (dpyinfo);
10368
10369#ifdef MULTI_KBOARD 10369#ifdef MULTI_KBOARD
10370 { 10370 {
10371 struct x_display_info *share; 10371 struct x_display_info *share;
@@ -10716,7 +10716,18 @@ x_delete_display (dpyinfo)
10716 struct x_display_info *dpyinfo; 10716 struct x_display_info *dpyinfo;
10717{ 10717{
10718 int i; 10718 int i;
10719 10719
10720 {
10721 /* Delete the generic struct display for this X display. */
10722 struct display *d;
10723 for (d = display_list; d; d = d->next_display)
10724 if (d->type == output_x_window && d->display_info.x != dpyinfo)
10725 {
10726 delete_display (d);
10727 break;
10728 }
10729 }
10730
10720 delete_keyboard_wait_descriptor (dpyinfo->connection); 10731 delete_keyboard_wait_descriptor (dpyinfo->connection);
10721 10732
10722 /* Discard this display from x_display_name_list and x_display_list. 10733 /* Discard this display from x_display_name_list and x_display_list.
@@ -10846,35 +10857,63 @@ static struct redisplay_interface x_redisplay_interface =
10846 x_shift_glyphs_for_insert 10857 x_shift_glyphs_for_insert
10847 }; 10858 };
10848 10859
10860
10861/* This function is called when the last frame on a display is deleted. */
10862void
10863x_delete_frame_display (struct display *display)
10864{
10865 /* We don't do anything, the connection to the X server must remain
10866 open. */
10867}
10868
10869
10870struct display *
10871x_create_frame_display (struct x_display_info *dpyinfo)
10872{
10873 struct display *display;
10874
10875 display = create_display ();
10876
10877 display->type = output_x_window;
10878 display->display_info.x = dpyinfo;
10879 dpyinfo->frame_display = display;
10880
10881 display->clear_frame_hook = x_clear_frame;
10882 display->ins_del_lines_hook = x_ins_del_lines;
10883 display->delete_glyphs_hook = x_delete_glyphs;
10884 display->ring_bell_hook = XTring_bell;
10885 display->reset_terminal_modes_hook = XTreset_terminal_modes;
10886 display->set_terminal_modes_hook = XTset_terminal_modes;
10887 display->update_begin_hook = x_update_begin;
10888 display->update_end_hook = x_update_end;
10889 display->set_terminal_window_hook = XTset_terminal_window;
10890 display->read_socket_hook = XTread_socket;
10891 display->frame_up_to_date_hook = XTframe_up_to_date;
10892 display->mouse_position_hook = XTmouse_position;
10893 display->frame_rehighlight_hook = XTframe_rehighlight;
10894 display->frame_raise_lower_hook = XTframe_raise_lower;
10895 display->set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar;
10896 display->condemn_scroll_bars_hook = XTcondemn_scroll_bars;
10897 display->redeem_scroll_bar_hook = XTredeem_scroll_bar;
10898 display->judge_scroll_bars_hook = XTjudge_scroll_bars;
10899
10900 display->delete_frame_hook = x_destroy_window;
10901 display->delete_display_hook = x_delete_frame_display;
10902
10903 display->rif = &x_redisplay_interface;
10904 display->scroll_region_ok = 1; /* We'll scroll partial frames. */
10905 display->char_ins_del_ok = 1;
10906 display->line_ins_del_ok = 1; /* We'll just blt 'em. */
10907 display->fast_clear_end_of_line = 1; /* X does this well. */
10908 display->memory_below_frame = 0; /* We don't remember what scrolls
10909 off the bottom. */
10910
10911 return display;
10912}
10913
10849void 10914void
10850x_initialize () 10915x_initialize ()
10851{ 10916{
10852 clear_frame_hook = x_clear_frame;
10853 ins_del_lines_hook = x_ins_del_lines;
10854 delete_glyphs_hook = x_delete_glyphs;
10855 ring_bell_hook = XTring_bell;
10856 reset_terminal_modes_hook = XTreset_terminal_modes;
10857 set_terminal_modes_hook = XTset_terminal_modes;
10858 update_begin_hook = x_update_begin;
10859 update_end_hook = x_update_end;
10860 set_terminal_window_hook = XTset_terminal_window;
10861 read_socket_hook = XTread_socket;
10862 frame_up_to_date_hook = XTframe_up_to_date;
10863 mouse_position_hook = XTmouse_position;
10864 frame_rehighlight_hook = XTframe_rehighlight;
10865 frame_raise_lower_hook = XTframe_raise_lower;
10866 set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar;
10867 condemn_scroll_bars_hook = XTcondemn_scroll_bars;
10868 redeem_scroll_bar_hook = XTredeem_scroll_bar;
10869 judge_scroll_bars_hook = XTjudge_scroll_bars;
10870
10871 x_display_method.rif = &x_redisplay_interface;
10872 x_display_method.scroll_region_ok = 1; /* We'll scroll partial frames. */
10873 x_display_method.char_ins_del_ok = 1;
10874 x_display_method.line_ins_del_ok = 1; /* We'll just blt 'em. */
10875 x_display_method.fast_clear_end_of_line = 1; /* X does this well. */
10876 x_display_method.memory_below_frame = 0; /* We don't remember what scrolls off the
10877 bottom. */
10878 baud_rate = 19200; 10917 baud_rate = 19200;
10879 10918
10880 x_noop_count = 0; 10919 x_noop_count = 0;
diff --git a/src/xterm.h b/src/xterm.h
index 3f629a7695a..8eb8604ae75 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -134,9 +134,6 @@ struct x_bitmap_record
134 int height, width, depth; 134 int height, width, depth;
135}; 135};
136 136
137/* Generic parameters for X displays. */
138extern struct display_method x_display_method;
139
140/* For each X display, we have a structure that records 137/* For each X display, we have a structure that records
141 information about it. */ 138 information about it. */
142 139
@@ -385,6 +382,9 @@ struct x_display_info
385 X_WMTYPE_A, 382 X_WMTYPE_A,
386 X_WMTYPE_B 383 X_WMTYPE_B
387 } wm_type; 384 } wm_type;
385
386 /* The generic display parameters corresponding to this X display. */
387 struct display *frame_display;
388}; 388};
389 389
390#ifdef HAVE_X_I18N 390#ifdef HAVE_X_I18N