Mercurial > emacs
annotate src/xterm.h @ 1407:0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
`nruns' and 'face_list' removed. Handle new element `max_ascent'.
(free_frame_glyphs): Don't free nonexistent elements `nruns' and
`face_list'; do free `max_ascent' element.
(make_frame_glyphs): Don't allocate nonexistent elements `nruns'
and `face_list'; do allocate `max_ascent' element.
(update_frame): Replaced use of macro LINE_HEIGHT with element
frame element `pix_height'.
| author | Joseph Arceneaux <jla@gnu.org> |
|---|---|
| date | Wed, 14 Oct 1992 21:30:21 +0000 |
| parents | 353663d81b11 |
| children | b8e32247c590 |
| rev | line source |
|---|---|
| 259 | 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 /* Max and Min sizes in character columns. */ | |
| 37 #define MINWIDTH 10 | |
| 38 #define MINHEIGHT 10 | |
| 39 #define MAXWIDTH 300 | |
| 40 #define MAXHEIGHT 80 | |
| 41 | |
| 42 #ifdef HAVE_X11 | |
| 999 | 43 |
| 1040 | 44 /* HAVE_X11R4 is defined if we have the features of X11R4. It should |
| 45 be defined when we're using X11R5, since X11R5 has the features of | |
| 46 X11R4. If, in the future, we find we need more of these flags | |
| 47 (HAVE_X11R5, for example), code should always be written to test | |
| 48 the most recent flag first: | |
| 49 | |
| 50 #ifdef HAVE_X11R5 | |
| 51 ... | |
| 52 #elif HAVE_X11R4 | |
| 53 ... | |
| 54 #elif HAVE_X11 | |
| 55 ... | |
| 56 #endif | |
| 57 | |
| 58 If you ever find yourself writing a "#ifdef HAVE_FOO" clause that | |
| 59 looks a lot like another one, consider moving the text into a macro | |
| 60 whose definition is configuration-dependent, but whose usage is | |
| 61 universal - like the stuff in systime.h. | |
| 62 | |
| 63 It turns out that we can auto-detect whether we're being compiled | |
| 999 | 64 with X11R3 or X11R4 by looking for the flag macros for R4 structure |
| 65 members that R3 doesn't have. */ | |
| 66 #ifdef PBaseSize | |
| 67 #define HAVE_X11R4 | |
| 68 #endif | |
| 69 | |
| 259 | 70 #define PIX_TYPE unsigned long |
| 71 #define XDISPLAY x_current_display, | |
| 72 #define XFlushQueue() XFlush(x_current_display) | |
| 73 #define BLACK_PIX_DEFAULT BlackPixel (x_current_display, \ | |
| 74 XDefaultScreen (x_current_display)) | |
| 75 #define WHITE_PIX_DEFAULT WhitePixel (x_current_display, \ | |
| 76 XDefaultScreen (x_current_display)) | |
| 77 #define DISPLAY_SCREEN_ARG x_current_display, \ | |
| 78 XDefaultScreen (x_current_display) | |
| 79 #define DISPLAY_CELLS DisplayCells (x_current_display, XDefaultScreen (x_current_display)) | |
|
1258
353663d81b11
* xterm.h (ROOT_WINDOW): Use the DefaultScreen macro, not the
Jim Blandy <jimb@redhat.com>
parents:
1040
diff
changeset
|
80 #define ROOT_WINDOW RootWindow (x_current_display, DefaultScreen (x_current_display)) |
| 259 | 81 #define FONT_TYPE XFontStruct |
| 82 #define Color XColor | |
| 83 | |
| 84 #define XExposeRegionEvent XExposeEvent | |
| 85 #define Bitmap Pixmap /* In X11, Bitmaps are are kind of | |
| 86 Pixmap. */ | |
| 87 #define WINDOWINFO_TYPE XWindowAttributes | |
| 88 #define XGetWindowInfo(w, i) XGetWindowAttributes (x_current_display, \ | |
| 89 (w), (i)) | |
| 90 #define XGetFont(f) XLoadQueryFont (x_current_display, (f)) | |
| 91 #define XLoseFont(f) XFreeFont (x_current_display, (f)) | |
| 92 #define XStuffPending() XPending (x_current_display) | |
| 93 #define XClear(w) XClearWindow (x_current_display, (w)) | |
| 94 #define XWarpMousePointer(w,x,y) XWarpPointer (x_current_display, None, w, \ | |
| 95 0,0,0,0, x, y) | |
| 96 #define XHandleError XSetErrorHandler | |
| 97 #define XHandleIOError XSetIOErrorHandler | |
| 98 | |
| 99 #define XChangeWindowSize(w,x,y) XResizeWindow(x_current_display,w,x,y) | |
| 100 | |
| 101 #define FONT_WIDTH(f) ((f)->max_bounds.width) | |
| 102 #define FONT_HEIGHT(f) ((f)->ascent + (f)->descent) | |
| 103 #define FONT_BASE(f) ((f)->ascent) | |
| 104 | |
| 105 /* GC values used for drawing non-standard (other face) text. */ | |
| 106 extern XGCValues face_gc_values; | |
| 107 | |
| 108 /* The mask of events that text windows always want to receive. This | |
| 424 | 109 does not include mouse movement events. It is used when the window |
| 110 is created (in x_window) and when we ask/unask for mouse movement | |
| 111 events (in XTmouse_tracking_enable). | |
| 112 | |
| 113 We do include ButtonReleases in this set because elisp isn't always | |
| 114 fast enough to catch them when it wants them, and they're rare | |
| 115 enough that they don't use much processor time. */ | |
| 259 | 116 |
| 117 #define STANDARD_EVENT_SET \ | |
| 118 (KeyPressMask \ | |
| 119 | ExposureMask \ | |
| 120 | ButtonPressMask \ | |
| 424 | 121 | ButtonReleaseMask \ |
| 122 | PointerMotionMask \ | |
| 123 | PointerMotionHintMask \ | |
| 259 | 124 | StructureNotifyMask \ |
| 125 | FocusChangeMask \ | |
| 126 | LeaveWindowMask \ | |
| 127 | EnterWindowMask \ | |
| 128 | VisibilityChangeMask) | |
| 129 | |
| 130 #else /* X10 */ | |
| 131 | |
| 132 #define ConnectionNumber(dpy) dpyno() | |
| 133 #define PIX_TYPE int | |
| 134 #define XDISPLAY | |
| 135 #define XFlushQueue() XFlush() | |
| 136 #define BLACK_PIX_DEFAULT BlackPixel | |
| 137 #define WHITE_PIX_DEFAULT WhitePixel | |
| 138 #define DISPLAY_SCREEN_ARG | |
| 139 #define DISPLAY_CELLS DisplayCells () | |
| 140 #define ROOT_WINDOW RootWindow | |
| 141 #define XFree free | |
| 142 #define FONT_TYPE FontInfo | |
| 143 | |
| 144 #define WINDOWINFO_TYPE WindowInfo | |
| 145 #define XGetWindowInfo(w, i) XQueryWindow ((w), (i)) | |
| 146 #define XGetFont(f) XOpenFont ((f)) | |
| 147 #define XLoseFont(f) XCloseFont ((f)) | |
| 148 #define XStuffPending() XPending () | |
| 149 #define XWarpMousePointer(w,x,y) XWarpMouse (w,x,y) | |
| 150 #define XHandleError XErrorHandler | |
| 151 #define XHandleIOError XIOErrorHandler | |
| 152 | |
| 153 #define FONT_WIDTH(f) ((f)->width) | |
| 154 #define FONT_HEIGHT(f) ((f)->height) | |
| 155 #define FONT_BASE(f) ((f)->base) | |
| 156 | |
| 157 #define XChangeWindowSize(w,x,y) XChangeWindow(w,x,y) | |
| 158 | |
| 159 #endif /* X10 */ | |
| 160 | |
| 161 struct event_queue | |
| 162 { | |
| 163 int rindex; /* Index at which to fetch next. */ | |
| 164 int windex; /* Index at which to store next. */ | |
| 165 XEvent xrep[EVENT_BUFFER_SIZE]; | |
| 166 }; | |
| 167 | |
| 168 /* Queue for mouse clicks. */ | |
| 169 extern struct event_queue x_mouse_queue; | |
| 170 | |
| 171 /* Mechanism for interlocking between main program level | |
| 172 and input interrupt level. */ | |
| 173 | |
| 174 /* Nonzero during a critical section. At such a time, an input interrupt | |
| 175 does nothing but set `x_pending_input'. */ | |
| 176 extern int x_input_blocked; | |
| 177 | |
| 178 /* Nonzero means an input interrupt has arrived | |
| 179 during the current critical section. */ | |
| 180 extern int x_pending_input; | |
| 181 | |
| 182 /* Begin critical section. */ | |
| 183 #define BLOCK_INPUT (x_input_blocked++) | |
| 184 | |
| 185 /* End critical section. */ | |
| 485 | 186 #define UNBLOCK_INPUT \ |
| 187 (x_input_blocked--, (x_input_blocked < 0 ? (abort (), 0) : 0)) | |
| 259 | 188 |
| 189 #define TOTALLY_UNBLOCK_INPUT (x_input_blocked = 0) | |
| 190 #define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT | |
| 191 | |
| 192 /* This is the X connection that we are using. */ | |
| 193 | |
| 194 extern Display *x_current_display; | |
| 195 | |
| 771 | 196 extern struct frame *x_window_to_frame (); |
| 259 | 197 |
| 771 | 198 /* The frame (if any) which has the X window that has keyboard focus. |
| 199 Zero if none. This is examined by Ffocus_frame in xfns.c */ | |
| 259 | 200 |
| 771 | 201 struct frame *x_focus_frame; |
| 259 | 202 |
| 203 #ifdef HAVE_X11 | |
| 204 /* Variables associated with the X display screen this emacs is using. */ | |
| 205 | |
| 206 /* How many screens this X display has. */ | |
| 207 extern Lisp_Object x_screen_count; | |
| 208 | |
| 209 /* The vendor supporting this X server. */ | |
| 210 extern Lisp_Object Vx_vendor; | |
| 211 | |
| 212 /* The vendor's release number for this X server. */ | |
| 213 extern Lisp_Object x_release; | |
| 214 | |
| 215 /* Height of this X screen in pixels. */ | |
| 216 extern Lisp_Object x_screen_height; | |
| 217 | |
| 218 /* Height of this X screen in millimeters. */ | |
| 219 extern Lisp_Object x_screen_height_mm; | |
| 220 | |
| 221 /* Width of this X screen in pixels. */ | |
| 222 extern Lisp_Object x_screen_width; | |
| 223 | |
| 224 /* Width of this X screen in millimeters. */ | |
| 225 extern Lisp_Object x_screen_width_mm; | |
| 226 | |
| 227 /* Does this X screen do backing store? */ | |
| 228 extern Lisp_Object Vx_backing_store; | |
| 229 | |
| 230 /* Does this X screen do save-unders? */ | |
| 231 extern Lisp_Object x_save_under; | |
| 232 | |
| 233 /* Number of planes for this screen. */ | |
| 234 extern Lisp_Object x_screen_planes; | |
| 235 | |
| 236 /* X Visual type of this screen. */ | |
| 237 extern Lisp_Object Vx_screen_visual; | |
| 238 | |
| 239 #endif /* HAVE_X11 */ | |
| 240 | |
| 241 enum text_cursor_kinds { | |
| 242 filled_box_cursor, hollow_box_cursor, bar_cursor | |
| 243 }; | |
| 244 | |
| 245 #define PIXEL_WIDTH(s) ((s)->display.x->pixel_width) | |
| 246 #define PIXEL_HEIGHT(s) ((s)->display.x->pixel_height) | |
| 247 | |
| 771 | 248 /* Each X frame object points to its own struct x_display object |
| 259 | 249 in the display.x field. The x_display structure contains all |
| 250 the information that is specific to X windows. */ | |
| 251 | |
| 252 struct x_display | |
| 253 { | |
| 254 /* Position of the X window (x and y offsets in root window). */ | |
| 255 int left_pos; | |
| 256 int top_pos; | |
| 257 | |
| 258 /* Border width of the X window as known by the X window system. */ | |
| 259 int border_width; | |
| 260 | |
| 261 /* Size of the X window in pixels. */ | |
| 262 int pixel_height, pixel_width; | |
| 263 | |
| 264 #ifdef HAVE_X11 | |
| 771 | 265 /* The tiled border used when the mouse is out of the frame. */ |
| 259 | 266 Pixmap border_tile; |
| 267 | |
| 268 /* Here are the Graphics Contexts for the default font. */ | |
| 269 GC normal_gc; /* Normal video */ | |
| 270 GC reverse_gc; /* Reverse video */ | |
| 271 GC cursor_gc; /* cursor drawing */ | |
| 272 #endif /* HAVE_X11 */ | |
| 273 | |
| 274 /* Width of the internal border. This is a line of background color | |
| 771 | 275 just inside the window's border. When the frame is selected, |
| 259 | 276 a highlighting is displayed inside the internal border. */ |
| 277 int internal_border_width; | |
| 278 | |
| 771 | 279 /* The X window used for this frame. |
| 280 May be zero while the frame object is being created | |
| 259 | 281 and the X window has not yet been created. */ |
| 282 Window window_desc; | |
| 283 | |
| 284 /* The X window used for the bitmap icon; | |
| 285 or 0 if we don't have a bitmap icon. */ | |
| 286 Window icon_desc; | |
| 287 | |
| 288 /* The X window that is the parent of this X window. | |
| 289 Usually but not always RootWindow. */ | |
| 290 Window parent_desc; | |
| 291 | |
| 292 /* 1 for bitmap icon, 0 for text icon. */ | |
| 293 int icon_bitmap_flag; | |
| 294 | |
| 295 FONT_TYPE *font; | |
| 296 | |
| 297 /* Pixel values used for various purposes. | |
| 298 border_pixel may be -1 meaning use a gray tile. */ | |
| 299 PIX_TYPE background_pixel; | |
| 300 PIX_TYPE foreground_pixel; | |
| 301 PIX_TYPE cursor_pixel; | |
| 302 PIX_TYPE border_pixel; | |
| 303 PIX_TYPE mouse_pixel; | |
| 304 | |
| 305 /* Windows for scrollbars */ | |
| 306 Window v_scrollbar; | |
| 307 Window v_thumbup; | |
| 308 Window v_thumbdown; | |
| 309 Window v_slider; | |
| 310 | |
| 311 Window h_scrollbar; | |
| 312 Window h_thumbleft; | |
| 313 Window h_thumbright; | |
| 314 Window h_slider; | |
| 315 | |
| 316 /* Scrollbar info */ | |
| 317 | |
| 318 int v_scrollbar_width; | |
| 319 int h_scrollbar_height; | |
| 320 | |
| 321 /* Descriptor for the cursor in use for this window. */ | |
| 322 #ifdef HAVE_X11 | |
| 323 Cursor text_cursor; | |
| 324 Cursor nontext_cursor; | |
| 325 Cursor modeline_cursor; | |
| 326 #else | |
| 327 Cursor cursor; | |
| 328 #endif | |
| 329 | |
| 330 /* The name that was associated with the icon, the last time | |
| 331 it was refreshed. Usually the same as the name of the | |
| 771 | 332 buffer in the currently selected window in the frame */ |
| 259 | 333 char *icon_label; |
| 334 | |
| 335 /* Flag to set when the X window needs to be completely repainted. */ | |
| 336 int needs_exposure; | |
| 337 | |
| 338 /* What kind of text cursor is drawn in this window right now? (If | |
| 339 there is no cursor (phys_cursor_x < 0), then this means nothing. */ | |
| 340 enum text_cursor_kinds text_cursor_kind; | |
| 999 | 341 |
| 342 /* These are the current window manager hints. It seems that | |
| 343 XSetWMHints, when presented with an unset bit in the `flags' | |
| 344 member of the hints structure, does not leave the corresponding | |
| 345 attribute unchanged; rather, it resets that attribute to its | |
| 346 default value. For example, unless you set the `icon_pixmap' | |
| 347 field and the `IconPixmapHint' bit, XSetWMHints will forget what | |
| 348 your icon pixmap was. This is rather troublesome, since some of | |
| 349 the members (for example, `input' and `icon_pixmap') want to stay | |
| 350 the same throughout the execution of Emacs. So, we keep this | |
| 351 structure around, just leaving values in it and adding new bits | |
| 352 to the mask as we go. */ | |
| 353 XWMHints wm_hints; | |
| 259 | 354 }; |
| 1040 | 355 |
| 356 /* Return the window associated with the frame F. */ | |
| 357 #define FRAME_X_WINDOW(f) ((f)->display.x->window_desc) | |
| 358 | |
| 259 | 359 |
| 360 /* When X windows are used, a glyf may be a 16 bit unsigned datum. | |
| 361 The high order byte is the face number and is used as an index | |
| 362 in the face table. A face is a font plus: | |
| 363 1) the unhighlighted foreground color, | |
| 364 2) the unhighlighted background color. | |
| 365 For highlighting, the two colors are exchanged. | |
| 366 Face number 0 is unused. The low order byte of a glyf gives | |
| 367 the character within the font. All fonts are assumed to be | |
| 368 fixed width, and to have the same height and width. */ | |
| 369 | |
| 370 #ifdef HAVE_X11 | |
| 771 | 371 /* Table of GC's used for this frame. */ |
| 259 | 372 GC *gc_table; |
| 373 | |
| 374 /* How many GCs are in the table. */ | |
| 375 int gcs_in_use; | |
| 376 | |
| 377 struct face | |
| 378 { | |
| 379 GC face_gc; | |
| 380 unsigned int foreground; | |
| 381 unsigned int background; | |
| 382 Pixmap stipple; | |
| 383 XFontStruct *font; | |
| 384 }; | |
| 385 | |
| 386 #else /* X10 */ | |
| 387 | |
| 388 struct face | |
| 389 { | |
| 390 FONT_TYPE *font; /* Font info for specified font. */ | |
| 391 int fg; /* Unhighlighted foreground. */ | |
| 392 int bg; /* Unhighlighted background. */ | |
| 393 }; | |
| 394 #endif /* X10 */ | |
| 395 | |
| 396 #define MAX_FACES_AND_GLYPHS 256 | |
| 397 extern struct face *x_face_table[]; |
