*** empty log message ***
[emacs.git] / src / xterm.h
blobbdce1c5aeb2e5bb6248edf0e8e7f887f25b01d13
1 /* Definitions and headers for communication with X protocol.
2 Copyright (C) 1989 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
9 any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 #ifdef HAVE_X11
21 #include <X11/Xlib.h>
22 #include <X11/cursorfont.h>
23 #include <X11/Xutil.h>
24 #include <X11/keysym.h>
25 #include <X11/Xatom.h>
26 #include <X11/Xresource.h>
27 #else
28 #include <X/Xlib.h>
29 #endif /* HAVE_X11 */
31 /* Define a queue for X-events. One such queue is used for mouse clicks.
32 Another is used for expose events. */
34 #define EVENT_BUFFER_SIZE 64
36 /* Max and Min sizes in character columns. */
37 #define MINWIDTH 10
38 #define MINHEIGHT 10
39 #define MAXWIDTH 300
40 #define MAXHEIGHT 80
42 #ifdef HAVE_X11
43 #define PIX_TYPE unsigned long
44 #define XDISPLAY x_current_display,
45 #define XFlushQueue() XFlush(x_current_display)
46 #define BLACK_PIX_DEFAULT BlackPixel (x_current_display, \
47 XDefaultScreen (x_current_display))
48 #define WHITE_PIX_DEFAULT WhitePixel (x_current_display, \
49 XDefaultScreen (x_current_display))
50 #define DISPLAY_SCREEN_ARG x_current_display, \
51 XDefaultScreen (x_current_display)
52 #define DISPLAY_CELLS DisplayCells (x_current_display, XDefaultScreen (x_current_display))
53 #define ROOT_WINDOW RootWindow (x_current_display, XDefaultScreen (x_current_display))
54 #define FONT_TYPE XFontStruct
55 #define Color XColor
57 #define XExposeRegionEvent XExposeEvent
58 #define Bitmap Pixmap /* In X11, Bitmaps are are kind of
59 Pixmap. */
60 #define WINDOWINFO_TYPE XWindowAttributes
61 #define XGetWindowInfo(w, i) XGetWindowAttributes (x_current_display, \
62 (w), (i))
63 #define XGetFont(f) XLoadQueryFont (x_current_display, (f))
64 #define XLoseFont(f) XFreeFont (x_current_display, (f))
65 #define XStuffPending() XPending (x_current_display)
66 #define XClear(w) XClearWindow (x_current_display, (w))
67 #define XWarpMousePointer(w,x,y) XWarpPointer (x_current_display, None, w, \
68 0,0,0,0, x, y)
69 #define XHandleError XSetErrorHandler
70 #define XHandleIOError XSetIOErrorHandler
72 #define XChangeWindowSize(w,x,y) XResizeWindow(x_current_display,w,x,y)
74 #define FONT_WIDTH(f) ((f)->max_bounds.width)
75 #define FONT_HEIGHT(f) ((f)->ascent + (f)->descent)
76 #define FONT_BASE(f) ((f)->ascent)
78 /* GC values used for drawing non-standard (other face) text. */
79 extern XGCValues face_gc_values;
81 /* The mask of events that text windows always want to receive. This
82 does not include mouse movement events. It is used when the window
83 is created (in x_window) and when we ask/unask for mouse movement
84 events (in XTmouse_tracking_enable).
86 We do include ButtonReleases in this set because elisp isn't always
87 fast enough to catch them when it wants them, and they're rare
88 enough that they don't use much processor time. */
90 #define STANDARD_EVENT_SET \
91 (KeyPressMask \
92 | ExposureMask \
93 | ButtonPressMask \
94 | ButtonReleaseMask \
95 | PointerMotionMask \
96 | PointerMotionHintMask \
97 | StructureNotifyMask \
98 | FocusChangeMask \
99 | LeaveWindowMask \
100 | EnterWindowMask \
101 | VisibilityChangeMask)
103 #else /* X10 */
105 #define ConnectionNumber(dpy) dpyno()
106 #define PIX_TYPE int
107 #define XDISPLAY
108 #define XFlushQueue() XFlush()
109 #define BLACK_PIX_DEFAULT BlackPixel
110 #define WHITE_PIX_DEFAULT WhitePixel
111 #define DISPLAY_SCREEN_ARG
112 #define DISPLAY_CELLS DisplayCells ()
113 #define ROOT_WINDOW RootWindow
114 #define XFree free
115 #define FONT_TYPE FontInfo
117 #define WINDOWINFO_TYPE WindowInfo
118 #define XGetWindowInfo(w, i) XQueryWindow ((w), (i))
119 #define XGetFont(f) XOpenFont ((f))
120 #define XLoseFont(f) XCloseFont ((f))
121 #define XStuffPending() XPending ()
122 #define XWarpMousePointer(w,x,y) XWarpMouse (w,x,y)
123 #define XHandleError XErrorHandler
124 #define XHandleIOError XIOErrorHandler
126 #define FONT_WIDTH(f) ((f)->width)
127 #define FONT_HEIGHT(f) ((f)->height)
128 #define FONT_BASE(f) ((f)->base)
130 #define XChangeWindowSize(w,x,y) XChangeWindow(w,x,y)
132 #endif /* X10 */
134 struct event_queue
136 int rindex; /* Index at which to fetch next. */
137 int windex; /* Index at which to store next. */
138 XEvent xrep[EVENT_BUFFER_SIZE];
141 /* Queue for mouse clicks. */
142 extern struct event_queue x_mouse_queue;
144 /* Mechanism for interlocking between main program level
145 and input interrupt level. */
147 /* Nonzero during a critical section. At such a time, an input interrupt
148 does nothing but set `x_pending_input'. */
149 extern int x_input_blocked;
151 /* Nonzero means an input interrupt has arrived
152 during the current critical section. */
153 extern int x_pending_input;
155 /* Begin critical section. */
156 #define BLOCK_INPUT (x_input_blocked++)
158 /* End critical section. */
159 #define UNBLOCK_INPUT \
160 (x_input_blocked--, (x_input_blocked < 0 ? (abort (), 0) : 0))
162 #define TOTALLY_UNBLOCK_INPUT (x_input_blocked = 0)
163 #define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT
165 /* This is the X connection that we are using. */
167 extern Display *x_current_display;
169 extern struct frame *x_window_to_frame ();
171 /* The frame (if any) which has the X window that has keyboard focus.
172 Zero if none. This is examined by Ffocus_frame in xfns.c */
174 struct frame *x_focus_frame;
176 #ifdef HAVE_X11
177 /* Variables associated with the X display screen this emacs is using. */
179 /* How many screens this X display has. */
180 extern Lisp_Object x_screen_count;
182 /* The vendor supporting this X server. */
183 extern Lisp_Object Vx_vendor;
185 /* The vendor's release number for this X server. */
186 extern Lisp_Object x_release;
188 /* Height of this X screen in pixels. */
189 extern Lisp_Object x_screen_height;
191 /* Height of this X screen in millimeters. */
192 extern Lisp_Object x_screen_height_mm;
194 /* Width of this X screen in pixels. */
195 extern Lisp_Object x_screen_width;
197 /* Width of this X screen in millimeters. */
198 extern Lisp_Object x_screen_width_mm;
200 /* Does this X screen do backing store? */
201 extern Lisp_Object Vx_backing_store;
203 /* Does this X screen do save-unders? */
204 extern Lisp_Object x_save_under;
206 /* Number of planes for this screen. */
207 extern Lisp_Object x_screen_planes;
209 /* X Visual type of this screen. */
210 extern Lisp_Object Vx_screen_visual;
212 #endif /* HAVE_X11 */
214 enum text_cursor_kinds {
215 filled_box_cursor, hollow_box_cursor, bar_cursor
218 #define PIXEL_WIDTH(s) ((s)->display.x->pixel_width)
219 #define PIXEL_HEIGHT(s) ((s)->display.x->pixel_height)
221 /* Each X frame object points to its own struct x_display object
222 in the display.x field. The x_display structure contains all
223 the information that is specific to X windows. */
225 struct x_display
227 /* Position of the X window (x and y offsets in root window). */
228 int left_pos;
229 int top_pos;
231 /* Border width of the X window as known by the X window system. */
232 int border_width;
234 /* Size of the X window in pixels. */
235 int pixel_height, pixel_width;
237 #ifdef HAVE_X11
238 /* The tiled border used when the mouse is out of the frame. */
239 Pixmap border_tile;
241 /* Here are the Graphics Contexts for the default font. */
242 GC normal_gc; /* Normal video */
243 GC reverse_gc; /* Reverse video */
244 GC cursor_gc; /* cursor drawing */
245 #endif /* HAVE_X11 */
247 /* Width of the internal border. This is a line of background color
248 just inside the window's border. When the frame is selected,
249 a highlighting is displayed inside the internal border. */
250 int internal_border_width;
252 /* The X window used for this frame.
253 May be zero while the frame object is being created
254 and the X window has not yet been created. */
255 Window window_desc;
257 /* The X window used for the bitmap icon;
258 or 0 if we don't have a bitmap icon. */
259 Window icon_desc;
261 /* The X window that is the parent of this X window.
262 Usually but not always RootWindow. */
263 Window parent_desc;
265 /* 1 for bitmap icon, 0 for text icon. */
266 int icon_bitmap_flag;
268 FONT_TYPE *font;
270 /* Pixel values used for various purposes.
271 border_pixel may be -1 meaning use a gray tile. */
272 PIX_TYPE background_pixel;
273 PIX_TYPE foreground_pixel;
274 PIX_TYPE cursor_pixel;
275 PIX_TYPE border_pixel;
276 PIX_TYPE mouse_pixel;
278 /* Windows for scrollbars */
279 Window v_scrollbar;
280 Window v_thumbup;
281 Window v_thumbdown;
282 Window v_slider;
284 Window h_scrollbar;
285 Window h_thumbleft;
286 Window h_thumbright;
287 Window h_slider;
289 /* Scrollbar info */
291 int v_scrollbar_width;
292 int h_scrollbar_height;
294 /* Descriptor for the cursor in use for this window. */
295 #ifdef HAVE_X11
296 Cursor text_cursor;
297 Cursor nontext_cursor;
298 Cursor modeline_cursor;
299 #else
300 Cursor cursor;
301 #endif
303 /* The name that was associated with the icon, the last time
304 it was refreshed. Usually the same as the name of the
305 buffer in the currently selected window in the frame */
306 char *icon_label;
308 /* Flag to set when the X window needs to be completely repainted. */
309 int needs_exposure;
311 /* What kind of text cursor is drawn in this window right now? (If
312 there is no cursor (phys_cursor_x < 0), then this means nothing. */
313 enum text_cursor_kinds text_cursor_kind;
316 /* When X windows are used, a glyf may be a 16 bit unsigned datum.
317 The high order byte is the face number and is used as an index
318 in the face table. A face is a font plus:
319 1) the unhighlighted foreground color,
320 2) the unhighlighted background color.
321 For highlighting, the two colors are exchanged.
322 Face number 0 is unused. The low order byte of a glyf gives
323 the character within the font. All fonts are assumed to be
324 fixed width, and to have the same height and width. */
326 #ifdef HAVE_X11
327 /* Table of GC's used for this frame. */
328 GC *gc_table;
330 /* How many GCs are in the table. */
331 int gcs_in_use;
333 struct face
335 GC face_gc;
336 unsigned int foreground;
337 unsigned int background;
338 Pixmap stipple;
339 XFontStruct *font;
342 #else /* X10 */
344 struct face
346 FONT_TYPE *font; /* Font info for specified font. */
347 int fg; /* Unhighlighted foreground. */
348 int bg; /* Unhighlighted background. */
350 #endif /* X10 */
352 #define MAX_FACES_AND_GLYPHS 256
353 extern struct face *x_face_table[];