view src/blockinput.h @ 97657:24f1cb4150ef

Include frame.h before termhooks.h. (mouse_on, mouse_off, mouse_moveto, mouse_init) (msdos_set_cursor_shape, IT_set_face, IT_write_glyphs) (show_mouse_face, IT_clear_end_of_line, IT_clear_screen) (IT_clear_to_end, IT_cursor_to, IT_display_cursor, IT_cmgoto) (IT_set_terminal_modes, IT_reset_terminal_modes) (IT_set_frame_parameters): Use tty->termscript instead of a global variable termscript. (IT_write_glyphs): Use tty->terminal->terminal_coding instead of a global variable terminal_coding. Don't refer to Vnonascii_translation_table. (internal_terminal_init): Set Vwindow_system in current_kboard. Don't use TTY_CHAR_INS_DEL_OK. Set Vinitial_window_system. Announce date and time of session start, if termscript is open. Don't zero out the_only_display_info (it is done in term.c:init_tty). Open termscript only of not already open. Log "SCREEN SAVED" here, instead of IT_set_terminal_modes. Init mouse here instead of dos_ttraw. Don't initialize display if this is an initial tty. Don't set FRAME_FONT. (Vwindow_system_version): Bump to 23. (dos_ttraw): Accept a TTY argument; all callers fixed. If mouse is available, set up mouse_position_hook. (dos_ttraw, IT_set_terminal_modes): If called with initial terminal, do nothing. (IT_set_frame_parameters): Handle the Qtty_type frame parameter by calling internal_terminal_init. (dos_set_window_size, show_mouse_face) (clear_mouse_face, IT_note_mode_line_highlight) (IT_note_mouse_highlight, IT_update_begin, IT_frame_up_to_date) (dos_rawgetc): Use tty_display_info instead of x_display_info. (initialize_msdos_display): New function. (IT_cursor_to, IT_clear_to_end, IT_clear_screen) (IT_clear_end_of_line, IT_insert_glyphs, IT_write_glyphs) (IT_delete_glyphs, IT_ring_bell, IT_reset_terminal_modes) (IT_set_terminal_modes, IT_set_terminal_window, IT_update_begin): Accept additional argument: a pointer to a frame. All callers changed. (request_sigio, unrequest_sigio): Don't define, now defined on sysdep.c. (IT_write_glyphs): Rewrite to use encode_terminal_code.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 23 Aug 2008 16:54:45 +0000
parents d45acf0c8d23
children e038c1a8307c
line wrap: on
line source

/* blockinput.h - interface to blocking complicated interrupt-driven input.
   Copyright (C) 1989, 1993, 2001, 2002, 2003, 2004,
                 2005, 2006, 2007, 2008  Free Software Foundation, Inc.

This file is part of GNU Emacs.

GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */

#ifndef EMACS_BLOCKINPUT_H
#define EMACS_BLOCKINPUT_H

#include "atimer.h"

/* When Emacs is using signal-driven input, the processing of those
   input signals can get pretty hairy.  For example, when Emacs is
   running under X windows, handling an input signal can entail
   retrieving events from the X event queue, or making other X calls.

   If an input signal occurs while Emacs is in the midst of some
   non-reentrant code, and the signal processing invokes that same
   code, we lose.  For example, malloc and the Xlib functions aren't
   usually re-entrant, and both are used by the X input signal handler
   - if we try to process an input signal in the midst of executing
   any of these functions, we'll lose.

   To avoid this, we make the following requirements:

   * Everyone must evaluate BLOCK_INPUT before entering these functions,
   and then call UNBLOCK_INPUT after performing them.  Calls
   BLOCK_INPUT and UNBLOCK_INPUT may be nested.

   * Any complicated interrupt handling code should test
   interrupt_input_blocked, and put off its work until later.

   * If the interrupt handling code wishes, it may set
   interrupt_input_pending to a non-zero value.  If that flag is set
   when input becomes unblocked, UNBLOCK_INPUT will send a new SIGIO.  */

extern volatile int interrupt_input_blocked;

/* Nonzero means an input interrupt has arrived
   during the current critical section.  */
extern int interrupt_input_pending;


/* Non-zero means asynchronous timers should be run when input is
   unblocked.  */

extern int pending_atimers;

#if defined HAVE_NS && !defined COCOA_EXPERIMENTAL_CTRL_G
/* NS does not use interrupt-driven input processing (yet), so this is
   unneeded and moreover was causing problems. */
#define BLOCK_INPUT
#define UNBLOCK_INPUT
#define TOTALLY_UNBLOCK_INPUT
#define UNBLOCK_INPUT_TO(LEVEL)

#else

/* Begin critical section. */
#define BLOCK_INPUT (interrupt_input_blocked++)

/* End critical section.

   If doing signal-driven input, and a signal came in when input was
   blocked, reinvoke the signal handler now to deal with it.

   We used to have two possible definitions of this macro - one for
   when SIGIO was #defined, and one for when it wasn't; when SIGIO
   wasn't #defined, we wouldn't bother to check if we should re-invoke
   the signal handler.  But that doesn't work very well; some of the
   files which use this macro don't #include the right files to get
   SIGIO.

   So, we always test interrupt_input_pending now; that's not too
   expensive, and it'll never get set if we don't need to resignal.  */

#define UNBLOCK_INPUT 				\
  do						\
    {						\
      --interrupt_input_blocked;		\
      if (interrupt_input_blocked == 0)		\
	{					\
	  if (interrupt_input_pending)		\
	    reinvoke_input_signal ();		\
	  if (pending_atimers)			\
	    do_pending_atimers ();		\
	}					\
      else if (interrupt_input_blocked < 0)	\
	abort ();				\
    }						\
  while (0)

/* Undo any number of BLOCK_INPUT calls,
   and also reinvoke any pending signal.  */

#define TOTALLY_UNBLOCK_INPUT			\
  do if (interrupt_input_blocked != 0)		\
    {						\
      interrupt_input_blocked = 1;		\
      UNBLOCK_INPUT;				\
    }						\
  while (0)

/* Undo any number of BLOCK_INPUT calls down to level LEVEL,
   and also (if the level is now 0) reinvoke any pending signal.  */

#define UNBLOCK_INPUT_TO(LEVEL)				\
  do							\
    {							\
      interrupt_input_blocked = (LEVEL) + 1;		\
      UNBLOCK_INPUT;					\
    }							\
  while (0)

#endif	/* defined HAVE_NS && !defined COCOA_EXPERIMENTAL_CTRL_G */

#define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT

/* In critical section ? */
#define INPUT_BLOCKED_P (interrupt_input_blocked > 0)

/* Defined in keyboard.c */
/* Don't use a prototype here; it causes trouble in some files.  */
extern void reinvoke_input_signal ();

#endif /* EMACS_BLOCKINPUT_H */

/* arch-tag: 51a9ec86-945a-4966-8f04-2d1341250e03
   (do not change this comment) */