comparison src/xterm.h @ 9655:93ccc7bbae8a

(struct x_display_info): Struct renamed from x_screen. (x_display): x_screen field renamed to display_info. (FRAME_X_DISPLAY): Use new name. (FRAME_X_DISPLAY_INFO): Likewise; also renamed from FRAME_X_SCREEN. (struct x_display_info): New fields *_mod_mask, icon_bitmap_id, connection, xrdb, Xatom..., grabbed, height, width, screen, visual, n_planes. (x_display_list): New variable. (FRAME_X_SCREEN): New macro. (WHITE_PIX_DEFAULT, BLACK_PIX_DEFAULT): Take arg f. (EMACS_CLASS): Macro moved here. (XExposeRegionEvent): Unused macro deleted. (XGetWindowInfo, XGetFont, XLoseFont): Unused macros deleted. (MINWIDTH, MINHEIGHT, MAXWIDTH, MAXHEIGHT): Unused macros deleted. (MAX_FACES_AND_GLYPHS, Bitmap): Unused macros deleted. (struct event_queue): Structure deleted (was unused). (EVENT_BUFFER_SIZE): Macro deleted. (XClear): Macro deleted. Callers use XClearWindow. (XWarpMousePointer): Macro deleted. Callers use XWarpPointer. (XStuffPending): Macro deleted. Callers use XPending. (XHandleError, XHandleIOError): Macros deleted. Callers use XSet...ErrorHandler. (XChangeWindowSize): Macro deleted. Callers use XResizeWindow. (Color): Macro deleted; replaced with XColor. (FONT_TYPE): Macro deleted; replaced with XFontStruct. (PIX_TYPE): Macro deleted; replaced with unsigned long. (ROOT_WINDOW): Macro deleted. (struct x_display_info): New field root_window. All uses changed. (XDISPLAY): Macro deleted. (XFlushQueue): Macro deleted. All callers changed. (DISPLAY_SCREEN_ARG): Maco deleted. (DISPLAY_CELLS): Macro deleted. (WINDOWINFO_TYPE): Macro deleted.
author Richard M. Stallman <rms@gnu.org>
date Sat, 22 Oct 1994 04:39:30 +0000
parents b0cf6d689f7a
children f4fa600e345f
comparison
equal deleted inserted replaced
9654:41681efe1086 9655:93ccc7bbae8a
35 window inside a widget instead of one 35 window inside a widget instead of one
36 that Xt creates... */ 36 that Xt creates... */
37 #include <X11/StringDefs.h> 37 #include <X11/StringDefs.h>
38 #endif 38 #endif
39 39
40 /* Define a queue for X-events. One such queue is used for mouse clicks. 40 /* The class of this X application. */
41 Another is used for expose events. */ 41 #define EMACS_CLASS "Emacs"
42 42
43 #define EVENT_BUFFER_SIZE 64 43 /* Bookkeeping to distinguish X versions. */
44
45 /* Max and Min sizes in character columns. */
46 #define MINWIDTH 10
47 #define MINHEIGHT 10
48 #define MAXWIDTH 300
49 #define MAXHEIGHT 80
50
51 #ifdef HAVE_X11
52 44
53 /* HAVE_X11R4 is defined if we have the features of X11R4. It should 45 /* HAVE_X11R4 is defined if we have the features of X11R4. It should
54 be defined when we're using X11R5, since X11R5 has the features of 46 be defined when we're using X11R5, since X11R5 has the features of
55 X11R4. If, in the future, we find we need more of these flags 47 X11R4. If, in the future, we find we need more of these flags
56 (HAVE_X11R5, for example), code should always be written to test 48 (HAVE_X11R5, for example), code should always be written to test
88 /* In case someone has X11R5 on AIX 3.1, 80 /* In case someone has X11R5 on AIX 3.1,
89 make sure HAVE_X11R4 is defined as well as HAVE_X11R5. */ 81 make sure HAVE_X11R4 is defined as well as HAVE_X11R5. */
90 #define HAVE_X11R4 82 #define HAVE_X11R4
91 #endif 83 #endif
92 #endif 84 #endif
93 85
94 #define PIX_TYPE unsigned long 86 #define BLACK_PIX_DEFAULT(f) BlackPixel (FRAME_X_DISPLAY (f), \
95 #define XDISPLAY x_current_display, 87 XScreenNumberOfScreen (FRAME_X_SCREEN (f)))
96 #define XFlushQueue() XFlush(x_current_display) 88 #define WHITE_PIX_DEFAULT(f) WhitePixel (FRAME_X_DISPLAY (f), \
97 #define BLACK_PIX_DEFAULT BlackPixel (x_current_display, \ 89 XScreenNumberOfScreen (FRAME_X_SCREEN (f)))
98 XDefaultScreen (x_current_display))
99 #define WHITE_PIX_DEFAULT WhitePixel (x_current_display, \
100 XDefaultScreen (x_current_display))
101 #define DISPLAY_SCREEN_ARG x_current_display, \
102 XDefaultScreen (x_current_display)
103 #define DISPLAY_CELLS DisplayCells (x_current_display, XDefaultScreen (x_current_display))
104 #define ROOT_WINDOW RootWindow (x_current_display, DefaultScreen (x_current_display))
105 #define FONT_TYPE XFontStruct
106 #define Color XColor
107
108 #define XExposeRegionEvent XExposeEvent
109 #define Bitmap Pixmap /* In X11, Bitmaps are a kind of
110 Pixmap. */
111 #define WINDOWINFO_TYPE XWindowAttributes
112 #define XGetWindowInfo(w, i) XGetWindowAttributes (x_current_display, \
113 (w), (i))
114 #define XGetFont(f) XLoadQueryFont (x_current_display, (f))
115 #define XLoseFont(f) XFreeFont (x_current_display, (f))
116 #define XStuffPending() XPending (x_current_display)
117 #define XClear(w) XClearWindow (x_current_display, (w))
118 #define XWarpMousePointer(w,x,y) XWarpPointer (x_current_display, None, w, \
119 0,0,0,0, x, y)
120 #define XHandleError XSetErrorHandler
121 #define XHandleIOError XSetIOErrorHandler
122
123 #define XChangeWindowSize(w,x,y) XResizeWindow(x_current_display,w,x,y)
124 90
125 #define FONT_WIDTH(f) ((f)->max_bounds.width) 91 #define FONT_WIDTH(f) ((f)->max_bounds.width)
126 #define FONT_HEIGHT(f) ((f)->ascent + (f)->descent) 92 #define FONT_HEIGHT(f) ((f)->ascent + (f)->descent)
127 #define FONT_BASE(f) ((f)->ascent) 93 #define FONT_BASE(f) ((f)->ascent)
128 94
95 #define CHECK_X_FRAME(f, frame) \
96 if (NILP (frame)) \
97 f = selected_frame; \
98 else \
99 { \
100 CHECK_LIVE_FRAME (frame, 0); \
101 f = XFRAME (frame); \
102 } \
103 if (! FRAME_X_P (f))
104
105
106
129 /* The mask of events that text windows always want to receive. This 107 /* The mask of events that text windows always want to receive. This
130 does not include mouse movement events. It is used when the window 108 does not include mouse movement events. It is used when the window
131 is created (in x_window) and when we ask/unask for mouse movement 109 is created (in x_window) and and in selection processing.
132 events (in XTmouse_tracking_enable). 110
133 111 We do include ButtonReleases in this set because Emacs isn't always
134 We do include ButtonReleases in this set because elisp isn't always
135 fast enough to catch them when it wants them, and they're rare 112 fast enough to catch them when it wants them, and they're rare
136 enough that they don't use much processor time. */ 113 enough that they don't use much processor time. */
137 114
138 #define STANDARD_EVENT_SET \ 115 #define STANDARD_EVENT_SET \
139 (KeyPressMask \ 116 (KeyPressMask \
146 | FocusChangeMask \ 123 | FocusChangeMask \
147 | LeaveWindowMask \ 124 | LeaveWindowMask \
148 | EnterWindowMask \ 125 | EnterWindowMask \
149 | VisibilityChangeMask) 126 | VisibilityChangeMask)
150 127
151 #else /* X10 */
152
153 #define ConnectionNumber(dpy) dpyno()
154 #define PIX_TYPE int
155 #define XDISPLAY
156 #define XFlushQueue() XFlush()
157 #define BLACK_PIX_DEFAULT BlackPixel
158 #define WHITE_PIX_DEFAULT WhitePixel
159 #define DISPLAY_SCREEN_ARG
160 #define DISPLAY_CELLS DisplayCells ()
161 #define ROOT_WINDOW RootWindow
162 #define XFree free
163 #define FONT_TYPE FontInfo
164
165 #define WINDOWINFO_TYPE WindowInfo
166 #define XGetWindowInfo(w, i) XQueryWindow ((w), (i))
167 #define XGetFont(f) XOpenFont ((f))
168 #define XLoseFont(f) XCloseFont ((f))
169 #define XStuffPending() XPending ()
170 #define XWarpMousePointer(w,x,y) XWarpMouse (w,x,y)
171 #define XHandleError XErrorHandler
172 #define XHandleIOError XIOErrorHandler
173
174 #define FONT_WIDTH(f) ((f)->width)
175 #define FONT_HEIGHT(f) ((f)->height)
176 #define FONT_BASE(f) ((f)->base)
177
178 #define XChangeWindowSize(w,x,y) XChangeWindow(w,x,y)
179
180 #endif /* X10 */
181
182 struct event_queue
183 {
184 int rindex; /* Index at which to fetch next. */
185 int windex; /* Index at which to store next. */
186 XEvent xrep[EVENT_BUFFER_SIZE];
187 };
188
189 /* Queue for mouse clicks. */
190 extern struct event_queue x_mouse_queue;
191
192 /* This is the X connection that we are using. */
193
194 extern Display *x_current_display;
195
196 /* This checks to make sure we have a display. */ 128 /* This checks to make sure we have a display. */
197 extern void check_x (); 129 extern void check_x ();
198 130
199 extern struct frame *x_window_to_frame (); 131 extern struct frame *x_window_to_frame ();
200 132
206 /* The frame (if any) which has the X window that has keyboard focus. 138 /* The frame (if any) which has the X window that has keyboard focus.
207 Zero if none. This is examined by Ffocus_frame in xfns.c */ 139 Zero if none. This is examined by Ffocus_frame in xfns.c */
208 140
209 extern struct frame *x_focus_frame; 141 extern struct frame *x_focus_frame;
210 142
211 #ifdef HAVE_X11 143 extern Visual *select_visual ();
212 /* Variables associated with the X display screen this emacs is using. */
213
214 /* How many screens this X display has. */
215 extern int x_screen_count;
216
217 /* The vendor supporting this X server. */
218 extern Lisp_Object Vx_vendor;
219
220 /* The vendor's release number for this X server. */
221 extern int x_release;
222
223 /* Height of this X screen in pixels. */
224 extern int x_screen_height;
225
226 /* Height of this X screen in millimeters. */
227 extern int x_screen_height_mm;
228
229 /* Width of this X screen in pixels. */
230 extern int x_screen_width;
231
232 /* Width of this X screen in millimeters. */
233 extern int x_screen_width_mm;
234
235 /* Does this X screen do backing store? */
236 extern Lisp_Object Vx_backing_store;
237
238 /* Does this X screen do save-unders? */
239 extern int x_save_under;
240
241 /* Number of planes for this screen. */
242 extern int x_screen_planes;
243
244 /* X Visual type of this screen. */
245 extern Lisp_Object Vx_screen_visual;
246
247 /* Mask of which mouse buttons are currently held down. */
248 extern unsigned int x_mouse_grabbed;
249
250 #endif /* HAVE_X11 */
251 144
252 enum text_cursor_kinds { 145 enum text_cursor_kinds {
253 filled_box_cursor, hollow_box_cursor, bar_cursor 146 filled_box_cursor, hollow_box_cursor, bar_cursor
254 }; 147 };
255 148
256 /* For each X display, we have a structure that records 149 /* For each X display, we have a structure that records
257 information about it. */ 150 information about it. */
258 151
259 struct x_screen 152 struct x_display_info
260 { 153 {
261 /* Chain of all x_display structures. */ 154 /* Chain of all x_display structures. */
262 struct x_display *next; 155 struct x_display_info *next;
156 /* Connection number (normally a file descriptor number). */
157 int connection;
263 /* This says how to access this display in Xlib. */ 158 /* This says how to access this display in Xlib. */
264 Display *x_display_value; 159 Display *display;
265 /* This records previous values returned by x-list-fonts. */ 160 /* This records previous values returned by x-list-fonts. */
266 Lisp_Object font_list_cache; 161 Lisp_Object font_list_cache;
267 /* The name of this display. */ 162 /* The name of this display. */
268 Lisp_Object name; 163 Lisp_Object name;
269 /* Number of frames that are on this display. */ 164 /* Number of frames that are on this display. */
270 int reference_count; 165 int reference_count;
166 /* The Screen this connection is connected to. */
167 Screen *screen;
168 /* The Visual being used for this display. */
169 Visual *visual;
170 /* Number of panes on this screen. */
171 int n_planes;
172 /* Dimensions of this screen. */
173 int height, width;
174 /* Mask of things that cause the mouse to be grabbed. */
175 int grabbed;
176 /* Emacs bitmap-id of the default icon bitmap for this frame.
177 Or -1 if none has been allocated yet. */
178 int icon_bitmap_id;
179 /* The root window of this screen. */
180 Window root_window;
181
182 /* X Resource data base */
183 XrmDatabase xrdb;
184
185 /* Which modifier keys are on which modifier bits?
186
187 With each keystroke, X returns eight bits indicating which modifier
188 keys were held down when the key was pressed. The interpretation
189 of the top five modifier bits depends on what keys are attached
190 to them. If the Meta_L and Meta_R keysyms are on mod5, then mod5
191 is the meta bit.
192
193 meta_mod_mask is a mask containing the bits used for the meta key.
194 It may have more than one bit set, if more than one modifier bit
195 has meta keys on it. Basically, if EVENT is a KeyPress event,
196 the meta key is pressed if (EVENT.state & meta_mod_mask) != 0.
197
198 shift_lock_mask is LockMask if the XK_Shift_Lock keysym is on the
199 lock modifier bit, or zero otherwise. Non-alphabetic keys should
200 only be affected by the lock modifier bit if XK_Shift_Lock is in
201 use; XK_Caps_Lock should only affect alphabetic keys. With this
202 arrangement, the lock modifier should shift the character if
203 (EVENT.state & shift_lock_mask) != 0. */
204 int meta_mod_mask, shift_lock_mask;
205
206 /* These are like meta_mod_mask, but for different modifiers. */
207 int alt_mod_mask, super_mod_mask, hyper_mod_mask;
208
209 /* Communication with window managers. */
210 Atom Xatom_wm_protocols;
211 /* Kinds of protocol things we may receive. */
212 Atom Xatom_wm_take_focus;
213 Atom Xatom_wm_save_yourself;
214 Atom Xatom_wm_delete_window;
215 /* Atom for indicating window state to the window manager. */
216 Atom Xatom_wm_change_state;
217 /* Other WM communication */
218 Atom Xatom_wm_configure_denied; /* When our config request is denied */
219 Atom Xatom_wm_window_moved; /* When the WM moves us. */
220 /* EditRes protocol */
221 Atom Xatom_editres;
222
223 /* More atoms, which are selection types. */
224 Atom Xatom_CLIPBOARD, Xatom_TIMESTAMP, Xatom_TEXT, Xatom_DELETE,
225 Xatom_MULTIPLE, Xatom_INCR, Xatom_EMACS_TMP, Xatom_TARGETS, Xatom_NULL,
226 Xatom_ATOM_PAIR;
271 }; 227 };
228
229 /* This is a chain of structures for all the X displays currently in use. */
230 extern struct x_display_info *x_display_list;
231
232 extern struct x_display_info *x_display_info_for_display ();
233 extern struct x_display_info *x_display_info_for_name ();
234
235 extern struct x_display_info *x_term_init ();
272 236
273 /* Each X frame object points to its own struct x_display object 237 /* Each X frame object points to its own struct x_display object
274 in the display.x field. The x_display structure contains all 238 in the display.x field. The x_display structure contains all
275 the information that is specific to X windows. */ 239 the information that is specific to X windows. */
276 240
331 295
332 /* If >=0, a bitmap index. The indicated bitmap is used for the 296 /* If >=0, a bitmap index. The indicated bitmap is used for the
333 icon. */ 297 icon. */
334 int icon_bitmap; 298 int icon_bitmap;
335 299
336 FONT_TYPE *font; 300 XFontStruct *font;
337 301
338 /* Pixel values used for various purposes. 302 /* Pixel values used for various purposes.
339 border_pixel may be -1 meaning use a gray tile. */ 303 border_pixel may be -1 meaning use a gray tile. */
340 PIX_TYPE background_pixel; 304 unsigned long background_pixel;
341 PIX_TYPE foreground_pixel; 305 unsigned long foreground_pixel;
342 PIX_TYPE cursor_pixel; 306 unsigned long cursor_pixel;
343 PIX_TYPE border_pixel; 307 unsigned long border_pixel;
344 PIX_TYPE mouse_pixel; 308 unsigned long mouse_pixel;
345 PIX_TYPE cursor_foreground_pixel; 309 unsigned long cursor_foreground_pixel;
346 310
347 /* Descriptor for the cursor in use for this window. */ 311 /* Descriptor for the cursor in use for this window. */
348 #ifdef HAVE_X11 312 #ifdef HAVE_X11
349 Cursor text_cursor; 313 Cursor text_cursor;
350 Cursor nontext_cursor; 314 Cursor nontext_cursor;
407 371
408 /* The geometry flags for this window. */ 372 /* The geometry flags for this window. */
409 int size_hint_flags; 373 int size_hint_flags;
410 374
411 /* This is the Emacs structure for the X display this frame is on. */ 375 /* This is the Emacs structure for the X display this frame is on. */
412 struct x_screen *x_screen; 376 struct x_display_info *display_info;
413 }; 377 };
414 378
415 /* Get at the computed faces of an X window frame. */ 379 /* Get at the computed faces of an X window frame. */
416 #define FRAME_PARAM_FACES(f) ((f)->display.x->param_faces) 380 #define FRAME_PARAM_FACES(f) ((f)->display.x->param_faces)
417 #define FRAME_N_PARAM_FACES(f) ((f)->display.x->n_param_faces) 381 #define FRAME_N_PARAM_FACES(f) ((f)->display.x->n_param_faces)
429 393
430 #define FRAME_FOREGROUND_PIXEL(f) ((f)->display.x->foreground_pixel) 394 #define FRAME_FOREGROUND_PIXEL(f) ((f)->display.x->foreground_pixel)
431 #define FRAME_BACKGROUND_PIXEL(f) ((f)->display.x->background_pixel) 395 #define FRAME_BACKGROUND_PIXEL(f) ((f)->display.x->background_pixel)
432 #define FRAME_FONT(f) ((f)->display.x->font) 396 #define FRAME_FONT(f) ((f)->display.x->font)
433 397
434 #define FRAME_X_SCREEN(f) ((f)->display.x->x_screen) 398 /* This gives the x_display_info structure for the display F is on. */
399 #define FRAME_X_DISPLAY_INFO(f) ((f)->display.x->display_info)
435 400
436 /* This is the `Display *' which frame F is on. */ 401 /* This is the `Display *' which frame F is on. */
437 #define FRAME_X_DISPLAY(f) ((f)->display.x->x_screen->x_display_value) 402 #define FRAME_X_DISPLAY(f) (FRAME_X_DISPLAY_INFO (f)->display)
403
404 /* This is the `Screen *' which frame F is on. */
405 #define FRAME_X_SCREEN(f) (FRAME_X_DISPLAY_INFO (f)->screen)
438 406
439 /* These two really ought to be called FRAME_PIXEL_{WIDTH,HEIGHT}. */ 407 /* These two really ought to be called FRAME_PIXEL_{WIDTH,HEIGHT}. */
440 #define PIXEL_WIDTH(f) ((f)->display.x->pixel_width) 408 #define PIXEL_WIDTH(f) ((f)->display.x->pixel_width)
441 #define PIXEL_HEIGHT(f) ((f)->display.x->pixel_height) 409 #define PIXEL_HEIGHT(f) ((f)->display.x->pixel_height)
442 410
443 #define FRAME_DESIRED_CURSOR(f) ((f)->display.x->desired_cursor) 411 #define FRAME_DESIRED_CURSOR(f) ((f)->display.x->desired_cursor)
444
445
446 /* When X windows are used, a glyph may be a 16 bit unsigned datum.
447 The high order byte is the face number and is used as an index
448 in the face table. A face is a font plus:
449 1) the unhighlighted foreground color,
450 2) the unhighlighted background color.
451 For highlighting, the two colors are exchanged.
452 Face number 0 is unused. The low order byte of a glyph gives
453 the character within the font. All fonts are assumed to be
454 fixed width, and to have the same height and width. */
455
456 #ifdef HAVE_X11
457
458 /* Face declared in dispextern.h */
459
460 #else /* X10 */
461
462 struct face
463 {
464 FONT_TYPE *font; /* Font info for specified font. */
465 int fg; /* Unhighlighted foreground. */
466 int bg; /* Unhighlighted background. */
467 };
468 #endif /* X10 */
469
470 #define MAX_FACES_AND_GLYPHS 256
471 extern struct face *x_face_table[];
472 412
473 413
474 /* X-specific scroll bar stuff. */ 414 /* X-specific scroll bar stuff. */
475 415
476 /* We represent scroll bars as lisp vectors. This allows us to place 416 /* We represent scroll bars as lisp vectors. This allows us to place