(enum fringe_bitmap_type): Define here.
[bpt/emacs.git] / src / xterm.h
index d5b01ae..3c8bee6 100644 (file)
@@ -30,11 +30,25 @@ Boston, MA 02111-1307, USA.  */
 #include <X11/StringDefs.h>
 #include <X11/IntrinsicP.h>    /* CoreP.h needs this */
 #include <X11/CoreP.h>         /* foul, but we need this to use our own
-                                  window inside a widget instead of one 
+                                  window inside a widget instead of one
                                   that Xt creates... */
 #include <X11/StringDefs.h>
+
+typedef Widget xt_or_gtk_widget;
 #endif
 
+#ifdef USE_GTK
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+
+/* Some definitions to reduce conditionals.  */
+typedef GtkWidget *xt_or_gtk_widget;
+#define XtParent(x) (gtk_widget_get_parent (x))
+#undef XSync
+#define XSync(d, b) gdk_window_process_all_updates ()
+
+#endif /* USE_GTK */
+
 /* The class of this X application.  */
 #define EMACS_CLASS "Emacs"
 \f
@@ -65,7 +79,7 @@ Boston, MA 02111-1307, USA.  */
 #ifdef PBaseSize
 /* AIX 3.1's X is somewhere between X11R3 and X11R4.  It has
    PBaseSize, but not XWithdrawWindow, XSetWMName, XSetWMNormalHints,
-   XSetWMIconName.  
+   XSetWMIconName.
    AIX 3.2 is at least X11R4.  */
 #if (!defined AIX) || (defined AIX3_2)
 #define HAVE_X11R4
@@ -107,15 +121,6 @@ Boston, MA 02111-1307, USA.  */
    | EnterWindowMask           \
    | VisibilityChangeMask)
 
-enum text_cursor_kinds
-{
-  NO_CURSOR = -1,
-  FILLED_BOX_CURSOR,
-  HOLLOW_BOX_CURSOR,
-  BAR_CURSOR,
-  HBAR_CURSOR
-};
-
 /* Structure recording X pixmap and reference count.
    If REFCOUNT is 0 then this record is free to be reused.  */
 
@@ -135,51 +140,51 @@ struct x_display_info
 {
   /* Chain of all x_display_info structures.  */
   struct x_display_info *next;
-  
+
   /* Connection number (normally a file descriptor number).  */
   int connection;
-  
+
   /* This says how to access this display in Xlib.  */
   Display *display;
-  
+
   /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
      The same cons cell also appears in x_display_name_list.  */
   Lisp_Object name_list_element;
-  
+
   /* Number of frames that are on this display.  */
   int reference_count;
-  
+
   /* The Screen this connection is connected to.  */
   Screen *screen;
 
   /* Dots per inch of the screen.  */
   double resx, resy;
-  
+
   /* The Visual being used for this display.  */
   Visual *visual;
 
   /* The colormap being used.  */
   Colormap cmap;
-  
+
   /* Number of panes on this screen.  */
   int n_planes;
-  
+
   /* Dimensions of this screen.  */
   int height, width;
-  
+
   /* Mask of things that cause the mouse to be grabbed.  */
   int grabbed;
-  
+
   /* Emacs bitmap-id of the default icon bitmap for this frame.
      Or -1 if none has been allocated yet.  */
   int icon_bitmap_id;
-  
+
   /* The root window of this screen.  */
   Window root_window;
-  
+
   /* The cursor to use for vertical scroll bars.  */
   Cursor vertical_scroll_bar_cursor;
-  
+
   /* X Resource data base */
   XrmDatabase xrdb;
 
@@ -271,25 +276,25 @@ struct x_display_info
 
   /* Communication with window managers.  */
   Atom Xatom_wm_protocols;
-  
+
   /* Kinds of protocol things we may receive.  */
   Atom Xatom_wm_take_focus;
   Atom Xatom_wm_save_yourself;
   Atom Xatom_wm_delete_window;
-  
+
   /* Atom for indicating window state to the window manager.  */
   Atom Xatom_wm_change_state;
-  
+
   /* Other WM communication */
   Atom Xatom_wm_configure_denied; /* When our config request is denied */
   Atom Xatom_wm_window_moved;     /* When the WM moves us.  */
-  
+
   /* EditRes protocol */
   Atom Xatom_editres;
 
   /* More atoms, which are selection types.  */
   Atom Xatom_CLIPBOARD, Xatom_TIMESTAMP, Xatom_TEXT, Xatom_DELETE,
-  Xatom_COMPOUND_TEXT,
+  Xatom_COMPOUND_TEXT, Xatom_UTF8_STRING,
   Xatom_MULTIPLE, Xatom_INCR, Xatom_EMACS_TMP, Xatom_TARGETS, Xatom_NULL,
   Xatom_ATOM_PAIR;
 
@@ -357,7 +362,7 @@ extern void check_x P_ ((void));
 
 extern struct frame *x_window_to_frame P_ ((struct x_display_info *, int));
 
-#ifdef USE_X_TOOLKIT
+#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
 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));
@@ -412,6 +417,10 @@ struct x_output
      if the menubar is turned off.  */
   int menubar_height;
 
+  /* Height of tool bar widget, in pixels.
+     Zero if not using an external tool bar.  */
+  int toolbar_height;
+
   /* Height of a line, in pixels.  */
   int line_height;
 
@@ -455,6 +464,26 @@ struct x_output
   Widget menubar_widget;
 #endif
 
+#ifdef USE_GTK
+  /* The widget of this screen.  This is the window of a top widget.  */
+  GtkWidget *widget;
+  /* The widget of the edit portion of this screen; the window in
+     "window_desc" is inside of this.  */
+  GtkWidget *edit_widget;
+  /* The widget used for laying out widgets vertically.  */
+  GtkWidget *vbox_widget;
+  /* The menubar in this frame.  */
+  GtkWidget *menubar_widget;
+  /* The tool bar in this frame  */
+  GtkWidget *toolbar_widget;
+  /* The handle box that makes the tool bar detachable.  */
+  GtkWidget *handlebox_widget;
+
+  /* The last size hints set.  */
+  GdkGeometry size_hints;
+  long hint_flags;
+#endif
+
   /* If >=0, a bitmap index.  The indicated bitmap is used for the
      icon. */
   int icon_bitmap;
@@ -481,7 +510,7 @@ struct x_output
   /* Foreground color for scroll bars.  A value of -1 means use the
      default (black for non-toolkit scroll bars).  */
   unsigned long scroll_bar_foreground_pixel;
-  
+
   /* Background color for scroll bars.  A value of -1 means use the
      default (background color of the frame for non-toolkit scroll
      bars).  */
@@ -503,24 +532,13 @@ struct x_output
   /* Window whose cursor is hourglass_cursor.  This window is temporarily
      mapped to display an hourglass cursor.  */
   Window hourglass_window;
-  
+
   /* Non-zero means hourglass cursor is currently displayed.  */
   unsigned hourglass_p : 1;
 
   /* Flag to set when the X window needs to be completely repainted.  */
   int needs_exposure;
 
-  /* What kind of text cursor is drawn in this window right now?
-     (If there is no cursor (phys_cursor_x < 0), then this means nothing.)  */
-  enum text_cursor_kinds current_cursor;
-
-  /* What kind of text cursor should we draw in the future?
-     This should always be filled_box_cursor or bar_cursor.  */
-  enum text_cursor_kinds desired_cursor;
-
-  /* Width of bar cursor (if we are using that).  */
-  int cursor_width;
-
   /* These are the current window manager hints.  It seems that
      XSetWMHints, when presented with an unset bit in the `flags'
      member of the hints structure, does not leave the corresponding
@@ -613,7 +631,7 @@ struct x_output
   /* As x_pixels_diff, but to FRAME_OUTER_WINDOW.  For some reason the
      two might differ by a pixel, depending on WM */
   int x_pixels_outer_diff;
-  
+
   /* As y_pixels_diff, but to FRAME_OUTER_WINDOW.  In the toolkit version,
      these may differ because this does not take into account possible
      menubar.  y_pixels_diff is with menubar height included */
@@ -639,7 +657,7 @@ enum
 enum
 {
   /* Values for focus_state, used as bit mask.
-     EXPLICIT means if we received a FocusIn for the frame and know it has
+     EXPLICIT means we received a FocusIn for the frame and know it has
      the focus.  IMPLICIT means we recevied an EnterNotify and the frame
      may have the focus if no window manager is running.
      FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
@@ -658,13 +676,28 @@ enum
                                XtWindow ((f)->output_data.x->widget) :  \
                                FRAME_X_WINDOW (f))
 #else
+#ifdef USE_GTK
+#define GTK_WIDGET_TO_X_WIN(w) \
+  ((w) && (w)->window ? GDK_WINDOW_XWINDOW ((w)->window) : 0)
+
+#define FRAME_GTK_OUTER_WIDGET(f) ((f)->output_data.x->widget)
+#define FRAME_GTK_WIDGET(f) ((f)->output_data.x->edit_widget)
+#define FRAME_OUTER_WINDOW(f)                                   \
+       (FRAME_GTK_OUTER_WIDGET (f) ?                            \
+        GTK_WIDGET_TO_X_WIN (FRAME_GTK_OUTER_WIDGET (f)) :      \
+         FRAME_X_WINDOW (f))
+
+#else /* !USE_GTK */
 #define FRAME_OUTER_WINDOW(f) (FRAME_X_WINDOW (f))
+#endif /* !USE_GTK */
 #endif
 
+
 #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_TOOLBAR_HEIGHT(f) ((f)->output_data.x->toolbar_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
@@ -694,7 +727,15 @@ enum
 #define PIXEL_WIDTH(f) ((f)->output_data.x->pixel_width)
 #define PIXEL_HEIGHT(f) ((f)->output_data.x->pixel_height)
 
-#define FRAME_DESIRED_CURSOR(f) ((f)->output_data.x->desired_cursor)
+/* The difference in pixels between the top left corner of the
+   Emacs window (including possible window manager decorations)
+   and FRAME_X_WINDOW (f).  */
+#define FRAME_OUTER_TO_INNER_DIFF_X(f) \
+     ((f)->output_data.x->x_pixels_outer_diff)
+#define FRAME_OUTER_TO_INNER_DIFF_Y(f)          \
+     ((f)->output_data.x->y_pixels_outer_diff   \
+      + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f))
+
 
 #define FRAME_XIC(f) ((f)->output_data.x->xic)
 #define FRAME_X_XIM(f) (FRAME_X_DISPLAY_INFO (f)->xim)
@@ -839,7 +880,7 @@ struct scroll_bar
 
 /* Return the length of the rectangle within which the top of the
    handle must stay.  This isn't equivalent to the inside height,
-   because the scroll bar handle has a minimum height.  
+   because the scroll bar handle has a minimum height.
 
    This is the real range of motion for the scroll bar, so when we're
    scaling buffer positions to scroll bar positions, we use this, not
@@ -902,7 +943,7 @@ struct scroll_bar
    + (f)->output_data.x->internal_border_width)
 
 
-/* Return the row/column (zero-based) of the character cell containing 
+/* Return the row/column (zero-based) of the character cell containing
    the pixel on FRAME at ROW/COL.  */
 #define PIXEL_TO_CHAR_ROW(f, row) \
   (((row) - (f)->output_data.x->internal_border_width) \
@@ -1051,6 +1092,7 @@ extern void x_clear_area P_ ((Display *, Window, int, int, int, int, int));
 extern void x_fullscreen_adjust P_ ((struct frame *f, int *, int *,
                                      int *, int *));
 
+extern int x_dispatch_event P_ ((XEvent *, Display *));
 
 /* Defined in xselect.c */
 
@@ -1091,7 +1133,6 @@ 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 *));