(read_char): When an event from unread-command-events
[bpt/emacs.git] / src / xterm.h
index 3960649..a1f0e38 100644 (file)
@@ -1,5 +1,6 @@
 /* Definitions and headers for communication with X protocol.
-   Copyright (C) 1989, 1993, 1994, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1989, 1993, 1994, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -77,8 +78,7 @@ Boston, MA 02111-1307, USA.  */
 #define HAVE_X11R4
 #endif
 
-#ifdef HAVE_X11R5
-#define HAVE_X_I18N
+#ifdef HAVE_X_I18N
 #include <X11/Xlocale.h>
 #endif
 \f
@@ -107,19 +107,6 @@ Boston, MA 02111-1307, USA.  */
    | EnterWindowMask           \
    | VisibilityChangeMask)
 
-/* This checks to make sure we have a display.  */
-extern void check_x ();
-
-extern struct frame *x_window_to_frame ();
-
-#ifdef USE_X_TOOLKIT
-extern struct frame *x_any_window_to_frame ();
-extern struct frame *x_non_menubar_window_to_frame ();
-extern struct frame *x_top_window_to_frame ();
-#endif
-
-extern Visual *select_visual ();
-
 enum text_cursor_kinds
 {
   NO_CURSOR = -1,
@@ -169,6 +156,9 @@ struct x_display_info
   
   /* The Visual being used for this display.  */
   Visual *visual;
+
+  /* THe colormap being used.  */
+  Colormap cmap;
   
   /* Number of panes on this screen.  */
   int n_planes;
@@ -344,8 +334,30 @@ struct x_display_info
 
   /* Cache of images.  */
   struct image_cache *image_cache;
+
+#ifdef HAVE_X_I18N
+  /* XIM (X Input method).  */
+  XIM xim;
+  XIMStyles *xim_styles;
+#endif
+
+  /* If non-null, a cache of the colors in the color map.  Don't
+     use this directly, call x_color_cells instead.  */
+  XColor *color_cells;
+  int ncolor_cells;
 };
 
+/* This checks to make sure we have a display.  */
+extern void check_x P_ ((void));
+
+extern struct frame *x_window_to_frame P_ ((struct x_display_info *, int));
+
+#ifdef USE_X_TOOLKIT
+extern struct frame *x_any_window_to_frame P_ ((struct x_display_info *, int));
+extern struct frame *x_non_menubar_window_to_frame P_ ((struct x_display_info *, int));
+extern struct frame *x_top_window_to_frame P_ ((struct x_display_info *, int));
+#endif
+
 /* This is a chain of structures for all the X displays currently in use.  */
 extern struct x_display_info *x_display_list;
 
@@ -361,15 +373,17 @@ extern Lisp_Object Vx_pixel_size_width_font_regexp;
 /* A flag to control how to display unibyte 8-bit character.  */
 extern int unibyte_display_via_language_environment;
 
-struct x_display_info *x_display_info_for_display P_ ((Display *));
-struct x_display_info *x_display_info_for_name ();
+extern struct x_display_info *x_display_info_for_display P_ ((Display *));
+extern struct x_display_info *x_display_info_for_name P_ ((Lisp_Object));
 
-extern struct x_display_info *x_term_init ();
+extern struct x_display_info *x_term_init P_ ((Lisp_Object, char *, char *));
 
 extern Lisp_Object x_list_fonts P_ ((struct frame *, Lisp_Object, int, int));
-
-extern struct font_info *x_get_font_info(), *x_load_font (), *x_query_font ();
-extern void x_find_ccl_program();
+extern void select_visual P_ ((struct x_display_info *));
+extern struct font_info *x_get_font_info P_ ((struct frame *f, int));
+extern struct font_info *x_load_font P_ ((struct frame *, char *, int));
+extern struct font_info *x_query_font P_ ((struct frame *, char *));
+extern void x_find_ccl_program P_ ((struct font_info *));
 \f
 /* Each X frame object points to its own struct x_output object
    in the output_data.x field.  The x_output structure contains
@@ -443,8 +457,8 @@ struct x_output
   /* Default ASCII font of this frame.  */
   XFontStruct *font;
 
-  /* The baseline position of the default ASCII font.  */
-  int font_baseline;
+  /* The baseline offset of the default ASCII font.  */
+  int baseline_offset;
 
   /* If a fontset is specified for this frame instead of font, this
      value contains an ID of the fontset, else -1.  */
@@ -474,6 +488,7 @@ struct x_output
   Cursor modeline_cursor;
   Cursor cross_cursor;
   Cursor busy_cursor;
+  Cursor horizontal_drag_cursor;
 
   /* Window whose cursor is busy_cursor.  This window is temporarily
      mapped to display a busy-cursor.  */
@@ -547,10 +562,10 @@ struct x_output
   char has_been_visible;
 
 #ifdef HAVE_X_I18N
-  /* Input method. */
-  XIM xim;
   /* Input context (currently, this means Compose key handler setup).  */
   XIC xic;
+  XIMStyle xic_style;
+  XFontSet xic_xfs;
 #endif
 
   /* Relief GCs, colors etc.  */
@@ -577,11 +592,10 @@ struct x_output
 #define FRAME_OUTER_WINDOW(f) (FRAME_X_WINDOW (f))
 #endif
 
-#define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.x->foreground_pixel)
-#define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel)
 #define FRAME_FONT(f) ((f)->output_data.x->font)
 #define FRAME_FONTSET(f) ((f)->output_data.x->fontset)
 #define FRAME_INTERNAL_BORDER_WIDTH(f) ((f)->output_data.x->internal_border_width)
+#define FRAME_MENUBAR_HEIGHT(f) ((f)->output_data.x->menubar_height)
 #define FRAME_LINE_HEIGHT(f) ((f)->output_data.x->line_height)
 
 /* Width of the default font of frame F.  Must be defined by each
@@ -597,6 +611,12 @@ struct x_output
 /* This is the `Screen *' which frame F is on.  */
 #define FRAME_X_SCREEN(f) (FRAME_X_DISPLAY_INFO (f)->screen)
 
+/* This is the Visual which frame F is on.  */
+#define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual
+
+/* This is the Colormap which frame F uses.  */
+#define FRAME_X_COLORMAP(f) FRAME_X_DISPLAY_INFO (f)->cmap
+
 /* This is the 'font_info *' which frame F has.  */
 #define FRAME_X_FONT_TABLE(f) (FRAME_X_DISPLAY_INFO (f)->font_table)
 
@@ -606,8 +626,11 @@ struct x_output
 
 #define FRAME_DESIRED_CURSOR(f) ((f)->output_data.x->desired_cursor)
 
-#define FRAME_XIM(f) ((f)->output_data.x->xim)
 #define FRAME_XIC(f) ((f)->output_data.x->xic)
+#define FRAME_X_XIM(f) (FRAME_X_DISPLAY_INFO (f)->xim)
+#define FRAME_X_XIM_STYLES(f) (FRAME_X_DISPLAY_INFO (f)->xim_styles)
+#define FRAME_XIC_STYLE(f) ((f)->output_data.x->xic_style)
+#define FRAME_XIC_FONTSET(f) ((f)->output_data.x->xic_xfs)
 
 /* Value is the smallest width of any character in any font on frame F.  */
 
@@ -669,8 +692,8 @@ struct x_output
    We use struct scroll_bar as a template for accessing fields of the
    vector.  */
 
-struct scroll_bar {
-
+struct scroll_bar
+{
   /* These fields are shared by all vectors.  */
   EMACS_INT size_from_Lisp_Vector_struct;
   struct Lisp_Vector *next_from_Lisp_Vector_struct;
@@ -685,9 +708,6 @@ struct scroll_bar {
      32-bit quantity, we store it split into two 32-bit values.  */
   Lisp_Object x_window_low, x_window_high;
 
-  /* Same as above for the widget.  */
-  Lisp_Object x_widget_low, x_widget_high;
-
   /* The position and size of the scroll bar in pixels, relative to the
      frame.  */
   Lisp_Object top, left, width, height;
@@ -739,13 +759,20 @@ struct scroll_bar {
 #define SET_SCROLL_BAR_X_WINDOW(ptr, id) \
   (SCROLL_BAR_UNPACK ((ptr)->x_window_low, (ptr)->x_window_high, (int) id))
 
-/* Extract the X widget of the scroll bar from a struct scroll_bar.  */
-#define SCROLL_BAR_X_WIDGET(ptr) \
-  ((Widget) SCROLL_BAR_PACK ((ptr)->x_widget_low, (ptr)->x_widget_high))
+/* Extract the X widget of the scroll bar from a struct scroll_bar.
+   XtWindowToWidget should be fast enough since Xt uses a hash table
+   to map windows to widgets.  */
+
+#define SCROLL_BAR_X_WIDGET(dpy, ptr) \
+  XtWindowToWidget (dpy, SCROLL_BAR_X_WINDOW (ptr))
 
 /* Store a widget id in a struct scroll_bar.  */
-#define SET_SCROLL_BAR_X_WIDGET(ptr, w) \
-  (SCROLL_BAR_UNPACK ((ptr)->x_widget_low, (ptr)->x_widget_high, (int) w))
+
+#define SET_SCROLL_BAR_X_WIDGET(ptr, w)                \
+  do {                                         \
+    Window window = XtWindow (w);              \
+    SET_SCROLL_BAR_X_WINDOW (ptr, window);     \
+} while (0)
 
 
 /* Return the inside width of a vertical scroll bar, given the outside
@@ -793,7 +820,7 @@ struct scroll_bar {
 
 /* Trimming off a few pixels from each side prevents
    text from glomming up against the scroll bar */
-#define VERTICAL_SCROLL_BAR_WIDTH_TRIM (2)
+#define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
 
 \f
 /* Manipulating pixel sizes and character sizes.
@@ -880,6 +907,8 @@ struct window;
 struct glyph_matrix;
 struct frame;
 struct input_event;
+struct face;
+struct image;
 
 /* From xselect.c.  */
 
@@ -888,24 +917,14 @@ void x_handle_property_notify P_ ((XPropertyEvent *));
 
 /* From xfns.c.  */
 
-void x_real_positions P_ ((struct frame *, int *, int *));
-void x_destroy_bitmap P_ ((struct frame *, int));
-int x_create_bitmap_from_file P_ ((struct frame *, Lisp_Object));
-int x_create_bitmap_from_data P_ ((struct frame *, char *, unsigned,
-                                  unsigned));
-void x_reference_bitmap P_ ((struct frame *, int));
-void x_sync P_ ((struct frame *));
-int x_bitmap_pixmap P_ ((struct frame *, int));
-void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
-int x_bitmap_height P_ ((struct frame *, int));
-int x_bitmap_width P_ ((struct frame *, int));
-int defined_color P_ ((struct frame *, char *, XColor *, int));
 Lisp_Object display_x_get_resource P_ ((struct x_display_info *,
                                        Lisp_Object, Lisp_Object,
                                        Lisp_Object, Lisp_Object));
 struct frame *check_x_frame P_ ((Lisp_Object));
 EXFUN (Fx_display_color_p, 1);
 EXFUN (Fx_display_grayscale_p, 1);
+int image_ascent P_ ((struct image *, struct face *));
+extern void x_free_gcs P_ ((struct frame *));
 
 /* From xrdb.c.  */
 
@@ -928,7 +947,7 @@ int x_text_icon P_ ((struct frame *, char *));
 int x_bitmap_icon P_ ((struct frame *, Lisp_Object));
 void x_set_window_size P_ ((struct frame *, int, int, int));
 void x_wm_set_window_state P_ ((struct frame *, int));
-int x_alloc_nearest_color P_ ((Display *, Screen *, Colormap, XColor *));
+int x_alloc_nearest_color P_ ((struct frame *, Colormap, XColor *));
 
 extern void pixel_to_glyph_coords P_ ((struct frame *, int, int,
                                       int *, int *, XRectangle *, int));
@@ -958,6 +977,7 @@ extern void x_lower_frame P_ ((struct frame *));
 extern void x_make_frame_visible P_ ((struct frame *));
 extern void x_make_frame_invisible P_ ((struct frame *));
 extern void x_iconify_frame P_ ((struct frame *));
+extern void x_free_frame_resources P_ ((struct frame *));
 extern void x_destroy_window P_ ((struct frame *));
 extern void x_wm_set_size_hint P_ ((struct frame *, long, int));
 extern void x_wm_set_window_state P_ ((struct frame *, int));
@@ -965,8 +985,15 @@ extern void x_wm_set_icon_pixmap P_ ((struct frame *, int));
 extern void x_wm_set_icon_position P_ ((struct frame *, int, int));
 extern void x_delete_display P_ ((struct x_display_info *));
 extern void x_initialize P_ ((void));
-void x_display_cursor P_ ((struct window *, int, int, int, int, int));
-void x_update_cursor P_ ((struct frame *, int));
+extern void x_display_cursor P_ ((struct window *, int, int, int, int, int));
+extern void x_update_cursor P_ ((struct frame *, int));
+extern unsigned long x_copy_color P_ ((struct frame *, unsigned long));
+#ifdef USE_X_TOOLKIT
+extern XtAppContext Xt_app_con;
+#endif
+extern void x_query_colors P_ ((struct frame *f, XColor *, int));
+extern void x_query_color P_ ((struct frame *f, XColor *));
+extern void x_clear_area P_ ((Display *, Window, int, int, int, int, int));
 
 /* Defined in xselect.c */
 
@@ -993,13 +1020,26 @@ extern void x_report_frame_params P_ ((struct frame *, Lisp_Object *));
 extern int defined_color P_ ((struct frame *, char *, XColor *, int));
 extern void x_set_border_pixel P_ ((struct frame *, int));
 extern void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
+extern unsigned char * x_encode_text P_ ((Lisp_Object, Lisp_Object,
+                                         int *, int *));
 extern void x_implicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
+extern void create_frame_xic P_ ((struct frame *));
+extern void destroy_frame_xic P_ ((struct frame *));
+extern void xic_set_preeditarea P_ ((struct window *, int, int));
+extern void xic_set_statusarea P_ ((struct frame *));
+extern void xic_set_xfontset P_ ((struct frame *, char *));
 extern int x_pixel_width P_ ((struct frame *));
 extern int x_pixel_height P_ ((struct frame *));
 extern int x_char_width P_ ((struct frame *));
 extern int x_char_height P_ ((struct frame *));
 extern int x_screen_planes P_ ((struct frame *));
 extern void x_sync P_ ((struct frame *));
+extern enum text_cursor_kinds x_specified_cursor_type P_ ((Lisp_Object, int *));
+extern int x_defined_color P_ ((struct frame *, char *, XColor *, int));
+#ifdef HAVE_X_I18N
+extern void free_frame_xic P_ ((struct frame *));
+#endif
+extern void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
 
 /* Defined in xfaces.c */