comparison src/xterm.h @ 259:470231fe99be

Initial revision
author Jim Blandy <jimb@redhat.com>
date Fri, 10 May 1991 13:43:14 +0000
parents
children 17ca8766781a
comparison
equal deleted inserted replaced
258:1e0bc00dca7a 259:470231fe99be
1 /* Definitions and headers for communication with X protocol.
2 Copyright (C) 1989 Free Software Foundation, Inc.
3
4 This file is part of GNU Emacs.
5
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.
10
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.
15
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. */
19
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 */
30
31 /* Define a queue for X-events. One such queue is used for mouse clicks.
32 Another is used for expose events. */
33
34 #define EVENT_BUFFER_SIZE 64
35
36 #define RES_CLASS "emacs"
37
38 /* Max and Min sizes in character columns. */
39 #define MINWIDTH 10
40 #define MINHEIGHT 10
41 #define MAXWIDTH 300
42 #define MAXHEIGHT 80
43
44 #ifdef HAVE_X11
45 #define PIX_TYPE unsigned long
46 #define XDISPLAY x_current_display,
47 #define XFlushQueue() XFlush(x_current_display)
48 #define BLACK_PIX_DEFAULT BlackPixel (x_current_display, \
49 XDefaultScreen (x_current_display))
50 #define WHITE_PIX_DEFAULT WhitePixel (x_current_display, \
51 XDefaultScreen (x_current_display))
52 #define DISPLAY_SCREEN_ARG x_current_display, \
53 XDefaultScreen (x_current_display)
54 #define DISPLAY_CELLS DisplayCells (x_current_display, XDefaultScreen (x_current_display))
55 #define ROOT_WINDOW RootWindow (x_current_display, XDefaultScreen (x_current_display))
56 #define FONT_TYPE XFontStruct
57 #define Color XColor
58
59 #define XExposeRegionEvent XExposeEvent
60 #define Bitmap Pixmap /* In X11, Bitmaps are are kind of
61 Pixmap. */
62 #define WINDOWINFO_TYPE XWindowAttributes
63 #define XGetWindowInfo(w, i) XGetWindowAttributes (x_current_display, \
64 (w), (i))
65 #define XGetFont(f) XLoadQueryFont (x_current_display, (f))
66 #define XLoseFont(f) XFreeFont (x_current_display, (f))
67 #define XStuffPending() XPending (x_current_display)
68 #define XClear(w) XClearWindow (x_current_display, (w))
69 #define XWarpMousePointer(w,x,y) XWarpPointer (x_current_display, None, w, \
70 0,0,0,0, x, y)
71 #define XHandleError XSetErrorHandler
72 #define XHandleIOError XSetIOErrorHandler
73
74 #define XChangeWindowSize(w,x,y) XResizeWindow(x_current_display,w,x,y)
75
76 #define FONT_WIDTH(f) ((f)->max_bounds.width)
77 #define FONT_HEIGHT(f) ((f)->ascent + (f)->descent)
78 #define FONT_BASE(f) ((f)->ascent)
79
80 /* GC values used for drawing non-standard (other face) text. */
81 extern XGCValues face_gc_values;
82
83 /* The mask of events that text windows always want to receive. This
84 does not include mouse movement events or button release events.
85 It is used when the window is created (in x_window) and when we
86 ask/unask for mouse movement events (in XTmouse_tracking_enable).
87 */
88
89 #define STANDARD_EVENT_SET \
90 (KeyPressMask \
91 | ExposureMask \
92 | ButtonPressMask \
93 | StructureNotifyMask \
94 | FocusChangeMask \
95 | LeaveWindowMask \
96 | EnterWindowMask \
97 | VisibilityChangeMask)
98
99 #else /* X10 */
100
101 #define ConnectionNumber(dpy) dpyno()
102 #define PIX_TYPE int
103 #define XDISPLAY
104 #define XFlushQueue() XFlush()
105 #define BLACK_PIX_DEFAULT BlackPixel
106 #define WHITE_PIX_DEFAULT WhitePixel
107 #define DISPLAY_SCREEN_ARG
108 #define DISPLAY_CELLS DisplayCells ()
109 #define ROOT_WINDOW RootWindow
110 #define XFree free
111 #define FONT_TYPE FontInfo
112
113 #define WINDOWINFO_TYPE WindowInfo
114 #define XGetWindowInfo(w, i) XQueryWindow ((w), (i))
115 #define XGetFont(f) XOpenFont ((f))
116 #define XLoseFont(f) XCloseFont ((f))
117 #define XStuffPending() XPending ()
118 #define XWarpMousePointer(w,x,y) XWarpMouse (w,x,y)
119 #define XHandleError XErrorHandler
120 #define XHandleIOError XIOErrorHandler
121
122 #define FONT_WIDTH(f) ((f)->width)
123 #define FONT_HEIGHT(f) ((f)->height)
124 #define FONT_BASE(f) ((f)->base)
125
126 #define XChangeWindowSize(w,x,y) XChangeWindow(w,x,y)
127
128 #endif /* X10 */
129
130 struct event_queue
131 {
132 int rindex; /* Index at which to fetch next. */
133 int windex; /* Index at which to store next. */
134 XEvent xrep[EVENT_BUFFER_SIZE];
135 };
136
137 /* Queue for mouse clicks. */
138 extern struct event_queue x_mouse_queue;
139
140 /* Mechanism for interlocking between main program level
141 and input interrupt level. */
142
143 /* Nonzero during a critical section. At such a time, an input interrupt
144 does nothing but set `x_pending_input'. */
145 extern int x_input_blocked;
146
147 /* Nonzero means an input interrupt has arrived
148 during the current critical section. */
149 extern int x_pending_input;
150
151 #ifndef sigmask
152 #define sigmask(no) (1L << ((no) - 1))
153 #endif
154
155 /* Begin critical section. */
156 #define BLOCK_INPUT (x_input_blocked++)
157
158 /* End critical section. */
159 #define UNBLOCK_INPUT (x_input_blocked--, (x_input_blocked < 0 ? abort () : 0))
160
161 #define TOTALLY_UNBLOCK_INPUT (x_input_blocked = 0)
162 #define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT
163
164 /* This is the X connection that we are using. */
165
166 extern Display *x_current_display;
167
168 extern struct screen *x_window_to_screen ();
169
170 /* The screen (if any) which has the X window that has keyboard focus.
171 Zero if none. This is examined by Ffocus_screen in xfns.c */
172
173 struct screen *x_focus_screen;
174
175 #ifdef HAVE_X11
176 /* Variables associated with the X display screen this emacs is using. */
177
178 /* How many screens this X display has. */
179 extern Lisp_Object x_screen_count;
180
181 /* The vendor supporting this X server. */
182 extern Lisp_Object Vx_vendor;
183
184 /* The vendor's release number for this X server. */
185 extern Lisp_Object x_release;
186
187 /* Height of this X screen in pixels. */
188 extern Lisp_Object x_screen_height;
189
190 /* Height of this X screen in millimeters. */
191 extern Lisp_Object x_screen_height_mm;
192
193 /* Width of this X screen in pixels. */
194 extern Lisp_Object x_screen_width;
195
196 /* Width of this X screen in millimeters. */
197 extern Lisp_Object x_screen_width_mm;
198
199 /* Does this X screen do backing store? */
200 extern Lisp_Object Vx_backing_store;
201
202 /* Does this X screen do save-unders? */
203 extern Lisp_Object x_save_under;
204
205 /* Number of planes for this screen. */
206 extern Lisp_Object x_screen_planes;
207
208 /* X Visual type of this screen. */
209 extern Lisp_Object Vx_screen_visual;
210
211 #endif /* HAVE_X11 */
212
213 enum text_cursor_kinds {
214 filled_box_cursor, hollow_box_cursor, bar_cursor
215 };
216
217 #define PIXEL_WIDTH(s) ((s)->display.x->pixel_width)
218 #define PIXEL_HEIGHT(s) ((s)->display.x->pixel_height)
219
220 /* Each X screen object points to its own struct x_display object
221 in the display.x field. The x_display structure contains all
222 the information that is specific to X windows. */
223
224 struct x_display
225 {
226 /* Position of the X window (x and y offsets in root window). */
227 int left_pos;
228 int top_pos;
229
230 /* Border width of the X window as known by the X window system. */
231 int border_width;
232
233 /* Size of the X window in pixels. */
234 int pixel_height, pixel_width;
235
236 #ifdef HAVE_X11
237 /* The tiled border used when the mouse is out of the screen. */
238 Pixmap border_tile;
239
240 /* Here are the Graphics Contexts for the default font. */
241 GC normal_gc; /* Normal video */
242 GC reverse_gc; /* Reverse video */
243 GC cursor_gc; /* cursor drawing */
244 #endif /* HAVE_X11 */
245
246 /* Width of the internal border. This is a line of background color
247 just inside the window's border. When the screen is selected,
248 a highlighting is displayed inside the internal border. */
249 int internal_border_width;
250
251 /* The X window used for this screen.
252 May be zero while the screen object is being created
253 and the X window has not yet been created. */
254 Window window_desc;
255
256 /* The X window used for the bitmap icon;
257 or 0 if we don't have a bitmap icon. */
258 Window icon_desc;
259
260 /* The X window that is the parent of this X window.
261 Usually but not always RootWindow. */
262 Window parent_desc;
263
264 /* 1 for bitmap icon, 0 for text icon. */
265 int icon_bitmap_flag;
266
267 FONT_TYPE *font;
268
269 /* Pixel values used for various purposes.
270 border_pixel may be -1 meaning use a gray tile. */
271 PIX_TYPE background_pixel;
272 PIX_TYPE foreground_pixel;
273 PIX_TYPE cursor_pixel;
274 PIX_TYPE border_pixel;
275 PIX_TYPE mouse_pixel;
276
277 /* Windows for scrollbars */
278 Window v_scrollbar;
279 Window v_thumbup;
280 Window v_thumbdown;
281 Window v_slider;
282
283 Window h_scrollbar;
284 Window h_thumbleft;
285 Window h_thumbright;
286 Window h_slider;
287
288 /* Scrollbar info */
289
290 int v_scrollbar_width;
291 int h_scrollbar_height;
292
293 /* Descriptor for the cursor in use for this window. */
294 #ifdef HAVE_X11
295 Cursor text_cursor;
296 Cursor nontext_cursor;
297 Cursor modeline_cursor;
298 #else
299 Cursor cursor;
300 #endif
301
302 /* The name that was associated with the icon, the last time
303 it was refreshed. Usually the same as the name of the
304 buffer in the currently selected window in the screen */
305 char *icon_label;
306
307 /* Flag to set when the X window needs to be completely repainted. */
308 int needs_exposure;
309
310 /* What kind of text cursor is drawn in this window right now? (If
311 there is no cursor (phys_cursor_x < 0), then this means nothing. */
312 enum text_cursor_kinds text_cursor_kind;
313 };
314
315 /* When X windows are used, a glyf may be a 16 bit unsigned datum.
316 The high order byte is the face number and is used as an index
317 in the face table. A face is a font plus:
318 1) the unhighlighted foreground color,
319 2) the unhighlighted background color.
320 For highlighting, the two colors are exchanged.
321 Face number 0 is unused. The low order byte of a glyf gives
322 the character within the font. All fonts are assumed to be
323 fixed width, and to have the same height and width. */
324
325 #ifdef HAVE_X11
326 /* Table of GC's used for this screen. */
327 GC *gc_table;
328
329 /* How many GCs are in the table. */
330 int gcs_in_use;
331
332 struct face
333 {
334 GC face_gc;
335 unsigned int foreground;
336 unsigned int background;
337 Pixmap stipple;
338 XFontStruct *font;
339 };
340
341 #else /* X10 */
342
343 struct face
344 {
345 FONT_TYPE *font; /* Font info for specified font. */
346 int fg; /* Unhighlighted foreground. */
347 int bg; /* Unhighlighted background. */
348 };
349 #endif /* X10 */
350
351 #define MAX_FACES_AND_GLYPHS 256
352 extern struct face *x_face_table[];