annotate src/blockinput.h @ 82990:2ecd1f669db9

Fixed X support, preliminary support for X-tty combo sessions. lib-src/emacsclient.c (copy_from_to, pty_conversation): Re-added SIGIO hack. (Sigh.) lisp/frame.el (make-frame-on-tty): Use make-terminal-frame, not make-frame. src/dispnew.c (line_hash_code, line_draw_cost): Updated to use the new display_method parameters. (Fredraw_frame): fflush the tty only if f is a termcap frame. (direct_output_for_insert): Updated to use the new display_method parameters. fflush the tty only if f is a termcap frame. (direct_output_forward_char, update_frame_1, scrolling): Ditto. (update_frame_line, Fding, bitch_at_user): Ditto. (Fsend_string_to_terminal): Fail if current frame is not on a tty. (init_display): Frame size change is safe here. src/frame.c (Vterminal_frame): Restored previously deleted variable. (syms_of_frame): Initialize it. (make_terminal_frame): Copy the frame's display_method from tty_display_info. (Fmake_terminal_frame): Enable simultaneous X and tty frames (buggy). (Fredirect_frame_focus): Don't call frame_rehighlight_hook if frame is on a termcap device. src/frame.h (struct frame): Renamed display to display_method. (Vterminal_frame): Re-added declaration. src/keyboard.c (flow_control): Moved to struct tty_display_info. (read_avail_input): Check ttys even if there is a read_socket_hook. (Fset_input_mode): Call reset_sys_modes/init_sys_modes and set flow_control or meta_key only when the frame is a termcap frame. (Fcurrent_input_mode): Handle flow_control and meta_key right on non-termcap frames. src/scroll.c (calculate_scrolling, calculate_direct_scrolling): Update to use the new display_method parameters. (scrolling_1, scroll_cost): Ditto. src/sysdep.c (init_sys_modes, reset_sys_modes): Always set the terminal parameters if tty_out->input is not stdin. Updated to the new location of flow_control. (hft_init): Moved HFT init code to term_init, as it needs the frame. src/term.c (tty_display_method_template): New variable. (update_begin): Added rif hack. (set_terminal_window, ins_del_lines, term_init): Updated to use the new display_method parameters. (insert_glyphs, ins_del_lines): Only call insert_glyphs_hook if the current frame is not on a tty. (calculate_costs): Don't calculate costs if not on a tty. (term_dummy_init): Fixed tty->output initialization. Preallocate Wcm and display_method. (term_init): Allocate & initialize display_method. Blindly fixed WINDOWSNT-specific parts. Added HFT-specific initialization exception from hft_init. (delete_tty): Only delete termcap frames. Free() the display_method. src/termchar.h (struct tty_display_info): Moved high-level terminal characteristics to struct display_method. Added flow_control and display_method members. src/termhooks.h (struct display_method): New struct (renamed from struct device). Added accessor macros. src/window.c (init_window_once): Initialize Vterminal_frame. src/xdisp.c (init_iterator, expose_frame): Added rif hack. (try_window_id): Updated to use the new display_method parameters. src/xfaces.c (realize_basic_faces): Don't call x_update_menu_appearance if the frame is a tty frame. src/xfns.c (Fx_create_frame): Added rif hack. Initialize display_method. (x_create_tip_frame): Initialize display_method. src/xterm.c (x_display_method): New variable. (x_flush, x_frame_of_widget, XTmouse_position): Ignore non-X frames. (x_window_to_scroll_bar, x_window_to_menu_bar): Ditto. (xim_destroy_callback, xim_instantiate_callback): Ditto. (frame_highlight, frame_unhighlight): Added rif hack. (x_initialize): Don't initialize rif. Do initialize x_display_method. src/xterm.h (x_display_method): New declaration. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-30
author Karoly Lorentey <lorentey@elte.hu>
date Fri, 02 Jan 2004 01:15:26 +0000
parents 695cf19ef79e
children 0e26a0be1ee5 375f2633d815
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2437
diff changeset
1 /* blockinput.h - interface to blocking complicated interrupt-driven input.
2437
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 Copyright (C) 1989, 1993 Free Software Foundation, Inc.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 2721
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 2721
diff changeset
19 Boston, MA 02111-1307, USA. */
2437
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
29926
5a1dca465b50 Protect against multiple inclusion. Include
Dave Love <fx@gnu.org>
parents: 27426
diff changeset
21 #ifndef EMACS_BLOCKINPUT_H
5a1dca465b50 Protect against multiple inclusion. Include
Dave Love <fx@gnu.org>
parents: 27426
diff changeset
22 #define EMACS_BLOCKINPUT_H
5a1dca465b50 Protect against multiple inclusion. Include
Dave Love <fx@gnu.org>
parents: 27426
diff changeset
23
5a1dca465b50 Protect against multiple inclusion. Include
Dave Love <fx@gnu.org>
parents: 27426
diff changeset
24 #include "atimer.h"
2437
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 /* When Emacs is using signal-driven input, the processing of those
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 input signals can get pretty hairy. For example, when Emacs is
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 running under X windows, handling an input signal can entail
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 retrieving events from the X event queue, or making other X calls.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 If an input signal occurs while Emacs is in the midst of some
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 non-reentrant code, and the signal processing invokes that same
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 code, we lose. For example, malloc and the Xlib functions aren't
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 usually re-entrant, and both are used by the X input signal handler
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 - if we try to process an input signal in the midst of executing
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 any of these functions, we'll lose.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 To avoid this, we make the following requirements:
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 * Everyone must evaluate BLOCK_INPUT before entering these functions,
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 and then call UNBLOCK_INPUT after performing them. Calls
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 BLOCK_INPUT and UNBLOCK_INPUT may be nested.
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 * Any complicated interrupt handling code should test
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 29926
diff changeset
45 interrupt_input_blocked, and put off its work until later.
2437
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 * If the interrupt handling code wishes, it may set
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 interrupt_input_pending to a non-zero value. If that flag is set
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 when input becomes unblocked, UNBLOCK_INPUT will send a new SIGIO. */
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50
2479
6d011b24f6fe (interrupt_input_blocked): Make this signed int.
Richard M. Stallman <rms@gnu.org>
parents: 2477
diff changeset
51 extern int interrupt_input_blocked;
2437
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 /* Nonzero means an input interrupt has arrived
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 during the current critical section. */
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 extern int interrupt_input_pending;
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56
27426
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
57
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
58 /* Non-zero means asynchronous timers should be run when input is
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
59 unblocked. */
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
60
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
61 extern int pending_atimers;
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
62
2437
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 /* Begin critical section. */
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 #define BLOCK_INPUT (interrupt_input_blocked++)
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65
2721
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
66 /* End critical section.
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
67
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
68 If doing signal-driven input, and a signal came in when input was
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
69 blocked, reinvoke the signal handler now to deal with it.
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
70
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
71 We used to have two possible definitions of this macro - one for
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
72 when SIGIO was #defined, and one for when it wasn't; when SIGIO
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
73 wasn't #defined, we wouldn't bother to check if we should re-invoke
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
74 the signal handler. But that doesn't work very well; some of the
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
75 files which use this macro don't #include the right files to get
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
76 SIGIO.
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
77
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
78 So, we always test interrupt_input_pending now; that's not too
ca5cb6cafc40 * blockinput.h (UNBLOCK_INPUT): We cannot assume that SIGIO is
Jim Blandy <jimb@redhat.com>
parents: 2479
diff changeset
79 expensive, and it'll never get set if we don't need to resignal. */
27426
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
80
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
81 #define UNBLOCK_INPUT \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
82 do \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
83 { \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
84 --interrupt_input_blocked; \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
85 if (interrupt_input_blocked == 0) \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
86 { \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
87 if (interrupt_input_pending) \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
88 reinvoke_input_signal (); \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
89 if (pending_atimers) \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
90 do_pending_atimers (); \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
91 } \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
92 else if (interrupt_input_blocked < 0) \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
93 abort (); \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
94 } \
e28edb0e4233 (pending_atimers): Add extern declaration.
Gerd Moellmann <gerd@gnu.org>
parents: 21796
diff changeset
95 while (0)
2437
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 #define TOTALLY_UNBLOCK_INPUT (interrupt_input_blocked = 0)
290a7be0d392 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 #define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT
21515
fb4c986db0e2 Add more prototypes.
Andreas Schwab <schwab@suse.de>
parents: 14186
diff changeset
99
fb4c986db0e2 Add more prototypes.
Andreas Schwab <schwab@suse.de>
parents: 14186
diff changeset
100 /* Defined in keyboard.c */
21796
f7ca88e90856 (reinvoke_input_signal): Don't use prototype decl.
Richard M. Stallman <rms@gnu.org>
parents: 21515
diff changeset
101 /* Don't use a prototype here; it causes trouble in some files. */
f7ca88e90856 (reinvoke_input_signal): Don't use prototype decl.
Richard M. Stallman <rms@gnu.org>
parents: 21515
diff changeset
102 extern void reinvoke_input_signal ();
29926
5a1dca465b50 Protect against multiple inclusion. Include
Dave Love <fx@gnu.org>
parents: 27426
diff changeset
103
5a1dca465b50 Protect against multiple inclusion. Include
Dave Love <fx@gnu.org>
parents: 27426
diff changeset
104 #endif /* EMACS_BLOCKINPUT_H */
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
105
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
106 /* arch-tag: 51a9ec86-945a-4966-8f04-2d1341250e03
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
107 (do not change this comment) */