(make-doctor-variables): Eliminate `observation-list' also.
[emacs.git] / src / xterm.h
blob9edca4025e4d26f3c90d8b76a34f53d0842bf627
1 /* Definitions and headers for communication with X protocol.
2 Copyright (C) 1989, 1993, 1994 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 2, 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, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
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>
28 #ifdef USE_X_TOOLKIT
29 #include <X11/StringDefs.h>
30 #include <X11/IntrinsicP.h> /* CoreP.h needs this */
31 #include <X11/CoreP.h> /* foul, but we need this to use our own
32 window inside a widget instead of one
33 that Xt creates... */
34 #include <X11/StringDefs.h>
35 #endif
37 /* The class of this X application. */
38 #define EMACS_CLASS "Emacs"
40 /* Bookkeeping to distinguish X versions. */
42 /* HAVE_X11R4 is defined if we have the features of X11R4. It should
43 be defined when we're using X11R5, since X11R5 has the features of
44 X11R4. If, in the future, we find we need more of these flags
45 (HAVE_X11R5, for example), code should always be written to test
46 the most recent flag first:
48 #ifdef HAVE_X11R5
49 ...
50 #elif HAVE_X11R4
51 ...
52 #elif HAVE_X11
53 ...
54 #endif
56 If you ever find yourself writing a "#ifdef HAVE_FOO" clause that
57 looks a lot like another one, consider moving the text into a macro
58 whose definition is configuration-dependent, but whose usage is
59 universal - like the stuff in systime.h.
61 It turns out that we can auto-detect whether we're being compiled
62 with X11R3 or X11R4 by looking for the flag macros for R4 structure
63 members that R3 doesn't have. */
64 #ifdef PBaseSize
65 /* AIX 3.1's X is somewhere between X11R3 and X11R4. It has
66 PBaseSize, but not XWithdrawWindow, XSetWMName, XSetWMNormalHints,
67 XSetWMIconName.
68 AIX 3.2 is at least X11R4. */
69 #if (!defined AIX) || (defined AIX3_2)
70 #define HAVE_X11R4
71 #endif
72 #endif
74 #ifdef HAVE_X11R5
75 /* In case someone has X11R5 on AIX 3.1,
76 make sure HAVE_X11R4 is defined as well as HAVE_X11R5. */
77 #define HAVE_X11R4
78 #endif
80 #ifdef HAVE_X11R5
81 #define HAVE_X_I18N
82 #include <X11/Xlocale.h>
83 #endif
85 #define BLACK_PIX_DEFAULT(f) BlackPixel (FRAME_X_DISPLAY (f), \
86 XScreenNumberOfScreen (FRAME_X_SCREEN (f)))
87 #define WHITE_PIX_DEFAULT(f) WhitePixel (FRAME_X_DISPLAY (f), \
88 XScreenNumberOfScreen (FRAME_X_SCREEN (f)))
90 #define FONT_WIDTH(f) ((f)->max_bounds.width)
91 #define FONT_HEIGHT(f) ((f)->ascent + (f)->descent)
92 #define FONT_BASE(f) ((f)->ascent)
94 /* The mask of events that text windows always want to receive. This
95 includes mouse movement events, since handling the mouse-font text property
96 means that we must track mouse motion all the time. */
98 #define STANDARD_EVENT_SET \
99 (KeyPressMask \
100 | ExposureMask \
101 | ButtonPressMask \
102 | ButtonReleaseMask \
103 | PointerMotionMask \
104 | StructureNotifyMask \
105 | FocusChangeMask \
106 | LeaveWindowMask \
107 | EnterWindowMask \
108 | VisibilityChangeMask)
110 /* This checks to make sure we have a display. */
111 extern void check_x ();
113 extern struct frame *x_window_to_frame ();
115 #ifdef USE_X_TOOLKIT
116 extern struct frame *x_any_window_to_frame ();
117 extern struct frame *x_non_menubar_window_to_frame ();
118 extern struct frame *x_top_window_to_frame ();
119 #endif
121 extern Visual *select_visual ();
123 enum text_cursor_kinds {
124 filled_box_cursor, hollow_box_cursor, bar_cursor
127 /* This data type is used for the font_table field
128 of struct x_display_info. */
130 struct font_info
132 XFontStruct *font;
133 char *name;
134 char *full_name;
137 /* Structure recording X pixmap and reference count.
138 If REFCOUNT is 0 then this record is free to be reused. */
140 struct x_bitmap_record
142 Pixmap pixmap;
143 char *file;
144 int refcount;
145 /* Record some info about this pixmap. */
146 int height, width, depth;
149 /* For each X display, we have a structure that records
150 information about it. */
152 struct x_display_info
154 /* Chain of all x_display_info structures. */
155 struct x_display_info *next;
156 /* Connection number (normally a file descriptor number). */
157 int connection;
158 /* This says how to access this display in Xlib. */
159 Display *display;
160 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
161 The same cons cell also appears in x_display_name_list. */
162 Lisp_Object name_list_element;
163 /* Number of frames that are on this display. */
164 int reference_count;
165 /* The Screen this connection is connected to. */
166 Screen *screen;
167 /* The Visual being used for this display. */
168 Visual *visual;
169 /* Number of panes on this screen. */
170 int n_planes;
171 /* Dimensions of this screen. */
172 int height, width;
173 /* Mask of things that cause the mouse to be grabbed. */
174 int grabbed;
175 /* Emacs bitmap-id of the default icon bitmap for this frame.
176 Or -1 if none has been allocated yet. */
177 int icon_bitmap_id;
178 /* The root window of this screen. */
179 Window root_window;
180 /* The cursor to use for vertical scroll bars. */
181 Cursor vertical_scroll_bar_cursor;
182 /* X Resource data base */
183 XrmDatabase xrdb;
185 /* A table of all the fonts we have already loaded. */
186 struct font_info *font_table;
188 /* The current capacity of x_font_table. */
189 int font_table_size;
191 /* Reusable Graphics Context for drawing a cursor in a non-default face. */
192 GC scratch_cursor_gc;
194 /* These variables describe the range of text currently shown
195 in its mouse-face, together with the window they apply to.
196 As long as the mouse stays within this range, we need not
197 redraw anything on its account. */
198 int mouse_face_beg_row, mouse_face_beg_col;
199 int mouse_face_end_row, mouse_face_end_col;
200 int mouse_face_past_end;
201 Lisp_Object mouse_face_window;
202 int mouse_face_face_id;
204 /* 1 if a mouse motion event came and we didn't handle it right away because
205 gc was in progress. */
206 int mouse_face_deferred_gc;
208 /* FRAME and X, Y position of mouse when last checked for
209 highlighting. X and Y can be negative or out of range for the frame. */
210 struct frame *mouse_face_mouse_frame;
211 int mouse_face_mouse_x, mouse_face_mouse_y;
213 /* Nonzero means defer mouse-motion highlighting. */
214 int mouse_face_defer;
216 char *x_id_name;
218 /* The number of fonts actually stored in x_font_table.
219 font_table[n] is used and valid iff 0 <= n < n_fonts.
220 0 <= n_fonts <= font_table_size. */
221 int n_fonts;
223 /* Pointer to bitmap records. */
224 struct x_bitmap_record *bitmaps;
226 /* Allocated size of bitmaps field. */
227 int bitmaps_size;
229 /* Last used bitmap index. */
230 int bitmaps_last;
232 /* Which modifier keys are on which modifier bits?
234 With each keystroke, X returns eight bits indicating which modifier
235 keys were held down when the key was pressed. The interpretation
236 of the top five modifier bits depends on what keys are attached
237 to them. If the Meta_L and Meta_R keysyms are on mod5, then mod5
238 is the meta bit.
240 meta_mod_mask is a mask containing the bits used for the meta key.
241 It may have more than one bit set, if more than one modifier bit
242 has meta keys on it. Basically, if EVENT is a KeyPress event,
243 the meta key is pressed if (EVENT.state & meta_mod_mask) != 0.
245 shift_lock_mask is LockMask if the XK_Shift_Lock keysym is on the
246 lock modifier bit, or zero otherwise. Non-alphabetic keys should
247 only be affected by the lock modifier bit if XK_Shift_Lock is in
248 use; XK_Caps_Lock should only affect alphabetic keys. With this
249 arrangement, the lock modifier should shift the character if
250 (EVENT.state & shift_lock_mask) != 0. */
251 int meta_mod_mask, shift_lock_mask;
253 /* These are like meta_mod_mask, but for different modifiers. */
254 int alt_mod_mask, super_mod_mask, hyper_mod_mask;
256 /* Communication with window managers. */
257 Atom Xatom_wm_protocols;
258 /* Kinds of protocol things we may receive. */
259 Atom Xatom_wm_take_focus;
260 Atom Xatom_wm_save_yourself;
261 Atom Xatom_wm_delete_window;
262 /* Atom for indicating window state to the window manager. */
263 Atom Xatom_wm_change_state;
264 /* Other WM communication */
265 Atom Xatom_wm_configure_denied; /* When our config request is denied */
266 Atom Xatom_wm_window_moved; /* When the WM moves us. */
267 /* EditRes protocol */
268 Atom Xatom_editres;
270 /* More atoms, which are selection types. */
271 Atom Xatom_CLIPBOARD, Xatom_TIMESTAMP, Xatom_TEXT, Xatom_DELETE,
272 Xatom_MULTIPLE, Xatom_INCR, Xatom_EMACS_TMP, Xatom_TARGETS, Xatom_NULL,
273 Xatom_ATOM_PAIR;
274 #ifdef MULTI_KBOARD
275 struct kboard *kboard;
276 #endif
277 int cut_buffers_initialized; /* Whether we're sure they all exist */
279 /* The frame (if any) which has the X window that has keyboard focus.
280 Zero if none. This is examined by Ffocus_frame in xfns.c. Note
281 that a mere EnterNotify event can set this; if you need to know the
282 last frame specified in a FocusIn or FocusOut event, use
283 x_focus_event_frame. */
284 struct frame *x_focus_frame;
286 /* The last frame mentioned in a FocusIn or FocusOut event. This is
287 separate from x_focus_frame, because whether or not LeaveNotify
288 events cause us to lose focus depends on whether or not we have
289 received a FocusIn event for it. */
290 struct frame *x_focus_event_frame;
292 /* The frame which currently has the visual highlight, and should get
293 keyboard input (other sorts of input have the frame encoded in the
294 event). It points to the X focus frame's selected window's
295 frame. It differs from x_focus_frame when we're using a global
296 minibuffer. */
297 struct frame *x_highlight_frame;
300 /* This is a chain of structures for all the X displays currently in use. */
301 extern struct x_display_info *x_display_list;
303 /* This is a list of cons cells, each of the form (NAME . FONT-LIST-CACHE),
304 one for each element of x_display_list and in the same order.
305 NAME is the name of the frame.
306 FONT-LIST-CACHE records previous values returned by x-list-fonts. */
307 extern Lisp_Object x_display_name_list;
309 extern struct x_display_info *x_display_info_for_display ();
310 extern struct x_display_info *x_display_info_for_name ();
312 extern struct x_display_info *x_term_init ();
314 /* Each X frame object points to its own struct x_output object
315 in the output_data.x field. The x_output structure contains
316 the information that is specific to X windows. */
318 struct x_output
320 /* Position of the X window (x and y offsets in root window). */
321 int left_pos;
322 int top_pos;
324 /* Border width of the X window as known by the X window system. */
325 int border_width;
327 /* Size of the X window in pixels. */
328 int pixel_height, pixel_width;
330 /* Height of menu bar widget, in pixels.
331 Zero if not using the X toolkit.
332 When using the toolkit, this value is not meaningful
333 if the menubar is turned off. */
334 int menubar_height;
336 /* Height of a line, in pixels. */
337 int line_height;
339 /* The tiled border used when the mouse is out of the frame. */
340 Pixmap border_tile;
342 /* Here are the Graphics Contexts for the default font. */
343 GC normal_gc; /* Normal video */
344 GC reverse_gc; /* Reverse video */
345 GC cursor_gc; /* cursor drawing */
347 /* Width of the internal border. This is a line of background color
348 just inside the window's border. When the frame is selected,
349 a highlighting is displayed inside the internal border. */
350 int internal_border_width;
352 /* The X window used for this frame.
353 May be zero while the frame object is being created
354 and the X window has not yet been created. */
355 Window window_desc;
357 /* The X window used for the bitmap icon;
358 or 0 if we don't have a bitmap icon. */
359 Window icon_desc;
361 /* The X window that is the parent of this X window.
362 Usually this is a window that was made by the window manager,
363 but it can be the root window, and it can be explicitly specified
364 (see the explicit_parent field, below). */
365 Window parent_desc;
367 #ifdef USE_X_TOOLKIT
368 /* The widget of this screen. This is the window of a "shell" widget. */
369 Widget widget;
370 /* The XmPanedWindows... */
371 Widget column_widget;
372 /* The widget of the edit portion of this screen; the window in
373 "window_desc" is inside of this. */
374 Widget edit_widget;
376 Widget menubar_widget;
377 #endif
379 /* If >=0, a bitmap index. The indicated bitmap is used for the
380 icon. */
381 int icon_bitmap;
383 XFontStruct *font;
385 /* Pixel values used for various purposes.
386 border_pixel may be -1 meaning use a gray tile. */
387 unsigned long background_pixel;
388 unsigned long foreground_pixel;
389 unsigned long cursor_pixel;
390 unsigned long border_pixel;
391 unsigned long mouse_pixel;
392 unsigned long cursor_foreground_pixel;
394 /* Descriptor for the cursor in use for this window. */
395 Cursor text_cursor;
396 Cursor nontext_cursor;
397 Cursor modeline_cursor;
398 Cursor cross_cursor;
400 /* Flag to set when the X window needs to be completely repainted. */
401 int needs_exposure;
403 /* What kind of text cursor is drawn in this window right now?
404 (If there is no cursor (phys_cursor_x < 0), then this means nothing.) */
405 enum text_cursor_kinds current_cursor;
407 /* What kind of text cursor should we draw in the future?
408 This should always be filled_box_cursor or bar_cursor. */
409 enum text_cursor_kinds desired_cursor;
411 /* Width of bar cursor (if we are using that). */
412 int cursor_width;
414 /* These are the current window manager hints. It seems that
415 XSetWMHints, when presented with an unset bit in the `flags'
416 member of the hints structure, does not leave the corresponding
417 attribute unchanged; rather, it resets that attribute to its
418 default value. For example, unless you set the `icon_pixmap'
419 field and the `IconPixmapHint' bit, XSetWMHints will forget what
420 your icon pixmap was. This is rather troublesome, since some of
421 the members (for example, `input' and `icon_pixmap') want to stay
422 the same throughout the execution of Emacs. So, we keep this
423 structure around, just leaving values in it and adding new bits
424 to the mask as we go. */
425 XWMHints wm_hints;
427 /* The size of the extra width currently allotted for vertical
428 scroll bars, in pixels. */
429 int vertical_scroll_bar_extra;
431 /* Table of parameter faces for this frame. Any X resources (pixel
432 values, fonts) referred to here have been allocated explicitly
433 for this face, and should be freed if we change the face. */
434 struct face **param_faces;
435 int n_param_faces;
437 /* Table of computed faces for this frame. These are the faces
438 whose indexes go into the upper bits of a glyph, computed by
439 combining the parameter faces specified by overlays, text
440 properties, and what have you. The X resources mentioned here
441 are all shared with parameter faces. */
442 struct face **computed_faces;
443 int n_computed_faces; /* How many are valid */
444 int size_computed_faces; /* How many are allocated */
446 /* This is the gravity value for the specified window position. */
447 int win_gravity;
449 /* The geometry flags for this window. */
450 int size_hint_flags;
452 /* This is the Emacs structure for the X display this frame is on. */
453 struct x_display_info *display_info;
455 /* This is a button event that wants to activate the menubar.
456 We save it here until the command loop gets to think about it. */
457 XEvent *saved_menu_event;
459 /* This is the widget id used for this frame's menubar in lwlib. */
460 #ifdef USE_X_TOOLKIT
461 int id;
462 #endif
464 /* Nonzero means our parent is another application's window
465 and was explicitly specified. */
466 char explicit_parent;
468 /* Nonzero means tried already to make this frame visible. */
469 char asked_for_visible;
471 #ifdef HAVE_X_I18N
472 /* Input method. */
473 XIM xim;
474 /* Input context (currently, this means Compose key handler setup). */
475 XIC xic;
476 #endif
479 /* Get at the computed faces of an X window frame. */
480 #define FRAME_PARAM_FACES(f) ((f)->output_data.x->param_faces)
481 #define FRAME_N_PARAM_FACES(f) ((f)->output_data.x->n_param_faces)
482 #define FRAME_DEFAULT_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[0])
483 #define FRAME_MODE_LINE_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[1])
485 #define FRAME_COMPUTED_FACES(f) ((f)->output_data.x->computed_faces)
486 #define FRAME_N_COMPUTED_FACES(f) ((f)->output_data.x->n_computed_faces)
487 #define FRAME_SIZE_COMPUTED_FACES(f) ((f)->output_data.x->size_computed_faces)
488 #define FRAME_DEFAULT_FACE(f) ((f)->output_data.x->computed_faces[0])
489 #define FRAME_MODE_LINE_FACE(f) ((f)->output_data.x->computed_faces[1])
491 /* Return the window associated with the frame F. */
492 #define FRAME_X_WINDOW(f) ((f)->output_data.x->window_desc)
494 #define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.x->foreground_pixel)
495 #define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel)
496 #define FRAME_FONT(f) ((f)->output_data.x->font)
497 #define FRAME_INTERNAL_BORDER_WIDTH(f) ((f)->output_data.x->internal_border_width)
498 #define FRAME_LINE_HEIGHT(f) ((f)->output_data.x->line_height)
500 /* This gives the x_display_info structure for the display F is on. */
501 #define FRAME_X_DISPLAY_INFO(f) ((f)->output_data.x->display_info)
503 /* This is the `Display *' which frame F is on. */
504 #define FRAME_X_DISPLAY(f) (FRAME_X_DISPLAY_INFO (f)->display)
506 /* This is the `Screen *' which frame F is on. */
507 #define FRAME_X_SCREEN(f) (FRAME_X_DISPLAY_INFO (f)->screen)
509 /* These two really ought to be called FRAME_PIXEL_{WIDTH,HEIGHT}. */
510 #define PIXEL_WIDTH(f) ((f)->output_data.x->pixel_width)
511 #define PIXEL_HEIGHT(f) ((f)->output_data.x->pixel_height)
513 #define FRAME_DESIRED_CURSOR(f) ((f)->output_data.x->desired_cursor)
515 #define FRAME_XIM(f) ((f)->output_data.x->xim)
516 #define FRAME_XIC(f) ((f)->output_data.x->xic)
518 /* X-specific scroll bar stuff. */
520 /* We represent scroll bars as lisp vectors. This allows us to place
521 references to them in windows without worrying about whether we'll
522 end up with windows referring to dead scroll bars; the garbage
523 collector will free it when its time comes.
525 We use struct scroll_bar as a template for accessing fields of the
526 vector. */
528 struct scroll_bar {
530 /* These fields are shared by all vectors. */
531 EMACS_INT size_from_Lisp_Vector_struct;
532 struct Lisp_Vector *next_from_Lisp_Vector_struct;
534 /* The window we're a scroll bar for. */
535 Lisp_Object window;
537 /* The next and previous in the chain of scroll bars in this frame. */
538 Lisp_Object next, prev;
540 /* The X window representing this scroll bar. Since this is a full
541 32-bit quantity, we store it split into two 32-bit values. */
542 Lisp_Object x_window_low, x_window_high;
544 /* The position and size of the scroll bar in pixels, relative to the
545 frame. */
546 Lisp_Object top, left, width, height;
548 /* The starting and ending positions of the handle, relative to the
549 handle area (i.e. zero is the top position, not
550 SCROLL_BAR_TOP_BORDER). If they're equal, that means the handle
551 hasn't been drawn yet.
553 These are not actually the locations where the beginning and end
554 are drawn; in order to keep handles from becoming invisible when
555 editing large files, we establish a minimum height by always
556 drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
557 where they would be normally; the bottom and top are in a
558 different co-ordinate system. */
559 Lisp_Object start, end;
561 /* If the scroll bar handle is currently being dragged by the user,
562 this is the number of pixels from the top of the handle to the
563 place where the user grabbed it. If the handle isn't currently
564 being dragged, this is Qnil. */
565 Lisp_Object dragging;
568 /* The number of elements a vector holding a struct scroll_bar needs. */
569 #define SCROLL_BAR_VEC_SIZE \
570 ((sizeof (struct scroll_bar) \
571 - sizeof (EMACS_INT) - sizeof (struct Lisp_Vector *)) \
572 / sizeof (Lisp_Object))
574 /* Turning a lisp vector value into a pointer to a struct scroll_bar. */
575 #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
578 /* Building a 32-bit C integer from two 16-bit lisp integers. */
579 #define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low))
581 /* Setting two lisp integers to the low and high words of a 32-bit C int. */
582 #define SCROLL_BAR_UNPACK(low, high, int32) \
583 (XSETINT ((low), (int32) & 0xffff), \
584 XSETINT ((high), ((int32) >> 16) & 0xffff))
587 /* Extract the X window id of the scroll bar from a struct scroll_bar. */
588 #define SCROLL_BAR_X_WINDOW(ptr) \
589 ((Window) SCROLL_BAR_PACK ((ptr)->x_window_low, (ptr)->x_window_high))
591 /* Store a window id in a struct scroll_bar. */
592 #define SET_SCROLL_BAR_X_WINDOW(ptr, id) \
593 (SCROLL_BAR_UNPACK ((ptr)->x_window_low, (ptr)->x_window_high, (int) id))
596 /* Return the outside pixel height for a vertical scroll bar HEIGHT
597 rows high on frame F. */
598 #define VERTICAL_SCROLL_BAR_PIXEL_HEIGHT(f, height) \
599 ((height) * (f)->output_data.x->line_height)
601 /* Return the inside width of a vertical scroll bar, given the outside
602 width. */
603 #define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(width) \
604 ((width) - VERTICAL_SCROLL_BAR_LEFT_BORDER - VERTICAL_SCROLL_BAR_RIGHT_BORDER)
606 /* Return the length of the rectangle within which the top of the
607 handle must stay. This isn't equivalent to the inside height,
608 because the scroll bar handle has a minimum height.
610 This is the real range of motion for the scroll bar, so when we're
611 scaling buffer positions to scroll bar positions, we use this, not
612 VERTICAL_SCROLL_BAR_INSIDE_HEIGHT. */
613 #define VERTICAL_SCROLL_BAR_TOP_RANGE(height) \
614 (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (height) - VERTICAL_SCROLL_BAR_MIN_HANDLE)
616 /* Return the inside height of vertical scroll bar, given the outside
617 height. See VERTICAL_SCROLL_BAR_TOP_RANGE too. */
618 #define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(height) \
619 ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER - VERTICAL_SCROLL_BAR_BOTTOM_BORDER)
622 /* Border widths for scroll bars.
624 Scroll bar windows don't have any X borders; their border width is
625 set to zero, and we redraw borders ourselves. This makes the code
626 a bit cleaner, since we don't have to convert between outside width
627 (used when relating to the rest of the screen) and inside width
628 (used when sizing and drawing the scroll bar window itself).
630 The handle moves up and down/back and forth in a rectangle inset
631 from the edges of the scroll bar. These are widths by which we
632 inset the handle boundaries from the scroll bar edges. */
633 #define VERTICAL_SCROLL_BAR_LEFT_BORDER (2)
634 #define VERTICAL_SCROLL_BAR_RIGHT_BORDER (2)
635 #define VERTICAL_SCROLL_BAR_TOP_BORDER (2)
636 #define VERTICAL_SCROLL_BAR_BOTTOM_BORDER (2)
638 /* Minimum lengths for scroll bar handles, in pixels. */
639 #define VERTICAL_SCROLL_BAR_MIN_HANDLE (5)
642 /* Manipulating pixel sizes and character sizes.
643 Knowledge of which factors affect the overall size of the window should
644 be hidden in these macros, if that's possible.
646 Return the upper/left pixel position of the character cell on frame F
647 at ROW/COL. */
648 #define CHAR_TO_PIXEL_ROW(f, row) \
649 ((f)->output_data.x->internal_border_width \
650 + (row) * (f)->output_data.x->line_height)
651 #define CHAR_TO_PIXEL_COL(f, col) \
652 ((f)->output_data.x->internal_border_width \
653 + (col) * FONT_WIDTH ((f)->output_data.x->font))
655 /* Return the pixel width/height of frame F if it has
656 WIDTH columns/HEIGHT rows. */
657 #define CHAR_TO_PIXEL_WIDTH(f, width) \
658 (CHAR_TO_PIXEL_COL (f, width) \
659 + (f)->output_data.x->vertical_scroll_bar_extra \
660 + (f)->output_data.x->internal_border_width)
661 #define CHAR_TO_PIXEL_HEIGHT(f, height) \
662 (CHAR_TO_PIXEL_ROW (f, height) \
663 + (f)->output_data.x->internal_border_width)
666 /* Return the row/column (zero-based) of the character cell containing
667 the pixel on FRAME at ROW/COL. */
668 #define PIXEL_TO_CHAR_ROW(f, row) \
669 (((row) - (f)->output_data.x->internal_border_width) \
670 / (f)->output_data.x->line_height)
671 #define PIXEL_TO_CHAR_COL(f, col) \
672 (((col) - (f)->output_data.x->internal_border_width) \
673 / FONT_WIDTH ((f)->output_data.x->font))
675 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
676 frame F? */
677 #define PIXEL_TO_CHAR_WIDTH(f, width) \
678 (PIXEL_TO_CHAR_COL (f, ((width) \
679 - (f)->output_data.x->internal_border_width \
680 - (f)->output_data.x->vertical_scroll_bar_extra)))
681 #define PIXEL_TO_CHAR_HEIGHT(f, height) \
682 (PIXEL_TO_CHAR_ROW (f, ((height) \
683 - (f)->output_data.x->internal_border_width)))
685 /* If a struct input_event has a kind which is selection_request_event
686 or selection_clear_event, then its contents are really described
687 by this structure. */
689 /* For an event of kind selection_request_event,
690 this structure really describes the contents.
691 **Don't make this struct longer!**
692 If it overlaps the frame_or_window field of struct input_event,
693 that will cause GC to crash. */
694 struct selection_input_event
696 int kind;
697 Display *display;
698 /* We spell it with an "o" here because X does. */
699 Window requestor;
700 Atom selection, target, property;
701 Time time;
704 #define SELECTION_EVENT_DISPLAY(eventp) \
705 (((struct selection_input_event *) (eventp))->display)
706 /* We spell it with an "o" here because X does. */
707 #define SELECTION_EVENT_REQUESTOR(eventp) \
708 (((struct selection_input_event *) (eventp))->requestor)
709 #define SELECTION_EVENT_SELECTION(eventp) \
710 (((struct selection_input_event *) (eventp))->selection)
711 #define SELECTION_EVENT_TARGET(eventp) \
712 (((struct selection_input_event *) (eventp))->target)
713 #define SELECTION_EVENT_PROPERTY(eventp) \
714 (((struct selection_input_event *) (eventp))->property)
715 #define SELECTION_EVENT_TIME(eventp) \
716 (((struct selection_input_event *) (eventp))->time)
719 /* Interface to the face code functions. */
721 /* Create the first two computed faces for a frame -- the ones that
722 have GC's. */
723 extern void init_frame_faces (/* FRAME_PTR */);
725 /* Free the resources for the faces associated with a frame. */
726 extern void free_frame_faces (/* FRAME_PTR */);
728 /* Given a computed face, find or make an equivalent display face
729 in face_vector, and return a pointer to it. */
730 extern struct face *intern_face (/* FRAME_PTR, struct face * */);
732 /* Given a frame and a face name, return the face's ID number, or
733 zero if it isn't a recognized face name. */
734 extern int face_name_id_number (/* FRAME_PTR, Lisp_Object */);
736 /* Return non-zero if FONT1 and FONT2 have the same size bounding box.
737 We assume that they're both character-cell fonts. */
738 extern int same_size_fonts (/* XFontStruct *, XFontStruct * */);
740 /* Recompute the GC's for the default and modeline faces.
741 We call this after changing frame parameters on which those GC's
742 depend. */
743 extern void recompute_basic_faces (/* FRAME_PTR */);
745 /* Return the face ID associated with a buffer position POS. Store
746 into *ENDPTR the next position at which a different face is
747 needed. This does not take account of glyphs that specify their
748 own face codes. F is the frame in use for display, and W is a
749 window displaying the current buffer.
751 REGION_BEG, REGION_END delimit the region, so it can be highlighted. */
752 extern int compute_char_face (/* FRAME_PTR frame,
753 struct window *w,
754 int pos,
755 int region_beg, int region_end,
756 int *endptr */);
757 /* Return the face ID to use to display a special glyph which selects
758 FACE_CODE as the face ID, assuming that ordinarily the face would
759 be BASIC_FACE. F is the frame. */
760 extern int compute_glyph_face (/* FRAME_PTR, int */);