(CFLAGS): Exclude ${CFLAGS} from singlequotes.
[bpt/emacs.git] / src / xterm.h
CommitLineData
3f930d20 1/* Definitions and headers for communication with X protocol.
4e027793 2 Copyright (C) 1989, 1993 Free Software Foundation, Inc.
3f930d20
JB
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
4e027793 8the Free Software Foundation; either version 2, or (at your option)
3f930d20
JB
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the 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
0be31d57
RS
31#ifdef USE_X_TOOLKIT
32#include <X11/StringDefs.h>
33#include <X11/IntrinsicP.h> /* CoreP.h needs this */
34#include <X11/CoreP.h> /* foul, but we need this to use our own
35 window inside a widget instead of one
36 that Xt creates... */
37#include <X11/StringDefs.h>
0be31d57
RS
38#endif
39
3f930d20
JB
40/* Define a queue for X-events. One such queue is used for mouse clicks.
41 Another is used for expose events. */
42
43#define EVENT_BUFFER_SIZE 64
44
3f930d20
JB
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
ef15f270 52
d2729198
JB
53/* 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
55 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
57 the most recent flag first:
58
59 #ifdef HAVE_X11R5
60 ...
61 #elif HAVE_X11R4
62 ...
63 #elif HAVE_X11
64 ...
65 #endif
66
67 If you ever find yourself writing a "#ifdef HAVE_FOO" clause that
68 looks a lot like another one, consider moving the text into a macro
69 whose definition is configuration-dependent, but whose usage is
70 universal - like the stuff in systime.h.
71
72 It turns out that we can auto-detect whether we're being compiled
ef15f270
JB
73 with X11R3 or X11R4 by looking for the flag macros for R4 structure
74 members that R3 doesn't have. */
75#ifdef PBaseSize
3fe53836
RS
76/* AIX 3.1's X is somewhere between X11R3 and X11R4. It has
77 PBaseSize, but not XWithdrawWindow, XSetWMName, XSetWMNormalHints,
48508a3a
FP
78 XSetWMIconName.
79 AIX 3.2 is at least X11R4. */
80#if (!defined AIX) || (defined AIX3_2)
ef15f270
JB
81#define HAVE_X11R4
82#endif
3fe53836 83#endif
ef15f270 84
6bde6341
JB
85#ifdef XlibSpecificationRelease
86#if XlibSpecificationRelease >= 5
87#define HAVE_X11R5
88#endif
89#endif
90
3f930d20
JB
91#define PIX_TYPE unsigned long
92#define XDISPLAY x_current_display,
93#define XFlushQueue() XFlush(x_current_display)
94#define BLACK_PIX_DEFAULT BlackPixel (x_current_display, \
95 XDefaultScreen (x_current_display))
96#define WHITE_PIX_DEFAULT WhitePixel (x_current_display, \
97 XDefaultScreen (x_current_display))
98#define DISPLAY_SCREEN_ARG x_current_display, \
99 XDefaultScreen (x_current_display)
100#define DISPLAY_CELLS DisplayCells (x_current_display, XDefaultScreen (x_current_display))
bbe42033 101#define ROOT_WINDOW RootWindow (x_current_display, DefaultScreen (x_current_display))
3f930d20
JB
102#define FONT_TYPE XFontStruct
103#define Color XColor
104
105#define XExposeRegionEvent XExposeEvent
546714cf
KH
106#define Bitmap Pixmap /* In X11, Bitmaps are a kind of
107 Pixmap. */
3f930d20
JB
108#define WINDOWINFO_TYPE XWindowAttributes
109#define XGetWindowInfo(w, i) XGetWindowAttributes (x_current_display, \
110 (w), (i))
111#define XGetFont(f) XLoadQueryFont (x_current_display, (f))
112#define XLoseFont(f) XFreeFont (x_current_display, (f))
113#define XStuffPending() XPending (x_current_display)
114#define XClear(w) XClearWindow (x_current_display, (w))
115#define XWarpMousePointer(w,x,y) XWarpPointer (x_current_display, None, w, \
116 0,0,0,0, x, y)
117#define XHandleError XSetErrorHandler
118#define XHandleIOError XSetIOErrorHandler
119
120#define XChangeWindowSize(w,x,y) XResizeWindow(x_current_display,w,x,y)
121
122#define FONT_WIDTH(f) ((f)->max_bounds.width)
123#define FONT_HEIGHT(f) ((f)->ascent + (f)->descent)
124#define FONT_BASE(f) ((f)->ascent)
125
3f930d20 126/* The mask of events that text windows always want to receive. This
8828b393
JB
127 does not include mouse movement events. It is used when the window
128 is created (in x_window) and when we ask/unask for mouse movement
129 events (in XTmouse_tracking_enable).
130
131 We do include ButtonReleases in this set because elisp isn't always
132 fast enough to catch them when it wants them, and they're rare
133 enough that they don't use much processor time. */
3f930d20
JB
134
135#define STANDARD_EVENT_SET \
136 (KeyPressMask \
137 | ExposureMask \
138 | ButtonPressMask \
8828b393
JB
139 | ButtonReleaseMask \
140 | PointerMotionMask \
141 | PointerMotionHintMask \
3f930d20
JB
142 | StructureNotifyMask \
143 | FocusChangeMask \
144 | LeaveWindowMask \
145 | EnterWindowMask \
146 | VisibilityChangeMask)
147
148#else /* X10 */
149
150#define ConnectionNumber(dpy) dpyno()
151#define PIX_TYPE int
152#define XDISPLAY
153#define XFlushQueue() XFlush()
154#define BLACK_PIX_DEFAULT BlackPixel
155#define WHITE_PIX_DEFAULT WhitePixel
156#define DISPLAY_SCREEN_ARG
157#define DISPLAY_CELLS DisplayCells ()
158#define ROOT_WINDOW RootWindow
159#define XFree free
160#define FONT_TYPE FontInfo
161
162#define WINDOWINFO_TYPE WindowInfo
163#define XGetWindowInfo(w, i) XQueryWindow ((w), (i))
164#define XGetFont(f) XOpenFont ((f))
165#define XLoseFont(f) XCloseFont ((f))
166#define XStuffPending() XPending ()
167#define XWarpMousePointer(w,x,y) XWarpMouse (w,x,y)
168#define XHandleError XErrorHandler
169#define XHandleIOError XIOErrorHandler
170
171#define FONT_WIDTH(f) ((f)->width)
172#define FONT_HEIGHT(f) ((f)->height)
173#define FONT_BASE(f) ((f)->base)
174
175#define XChangeWindowSize(w,x,y) XChangeWindow(w,x,y)
176
177#endif /* X10 */
178
179struct event_queue
180 {
181 int rindex; /* Index at which to fetch next. */
182 int windex; /* Index at which to store next. */
183 XEvent xrep[EVENT_BUFFER_SIZE];
184 };
185
186/* Queue for mouse clicks. */
187extern struct event_queue x_mouse_queue;
188
3f930d20
JB
189/* This is the X connection that we are using. */
190
191extern Display *x_current_display;
192
3868b9ec
KH
193/* This checks to make sure we have a display. */
194extern void check_x ();
195
f676886a 196extern struct frame *x_window_to_frame ();
3f930d20 197
0be31d57
RS
198#ifdef USE_X_TOOLKIT
199extern struct frame *x_any_window_to_frame ();
200#endif
201
f676886a
JB
202/* The frame (if any) which has the X window that has keyboard focus.
203 Zero if none. This is examined by Ffocus_frame in xfns.c */
3f930d20 204
f802f8e0 205extern struct frame *x_focus_frame;
3f930d20
JB
206
207#ifdef HAVE_X11
208/* Variables associated with the X display screen this emacs is using. */
209
210/* How many screens this X display has. */
259c5af9 211extern int x_screen_count;
3f930d20
JB
212
213/* The vendor supporting this X server. */
214extern Lisp_Object Vx_vendor;
215
216/* The vendor's release number for this X server. */
259c5af9 217extern int x_release;
3f930d20
JB
218
219/* Height of this X screen in pixels. */
259c5af9 220extern int x_screen_height;
3f930d20
JB
221
222/* Height of this X screen in millimeters. */
259c5af9 223extern int x_screen_height_mm;
3f930d20
JB
224
225/* Width of this X screen in pixels. */
259c5af9 226extern int x_screen_width;
3f930d20
JB
227
228/* Width of this X screen in millimeters. */
259c5af9 229extern int x_screen_width_mm;
3f930d20
JB
230
231/* Does this X screen do backing store? */
232extern Lisp_Object Vx_backing_store;
233
234/* Does this X screen do save-unders? */
259c5af9 235extern int x_save_under;
3f930d20
JB
236
237/* Number of planes for this screen. */
259c5af9 238extern int x_screen_planes;
3f930d20
JB
239
240/* X Visual type of this screen. */
241extern Lisp_Object Vx_screen_visual;
242
243#endif /* HAVE_X11 */
244\f
245enum text_cursor_kinds {
246 filled_box_cursor, hollow_box_cursor, bar_cursor
247};
248
f676886a 249/* Each X frame object points to its own struct x_display object
3f930d20
JB
250 in the display.x field. The x_display structure contains all
251 the information that is specific to X windows. */
252
253struct x_display
254{
255 /* Position of the X window (x and y offsets in root window). */
256 int left_pos;
257 int top_pos;
258
259 /* Border width of the X window as known by the X window system. */
260 int border_width;
261
262 /* Size of the X window in pixels. */
263 int pixel_height, pixel_width;
264
2ba6876c
RS
265 /* Height of a line, in pixels. */
266 int line_height;
267
3f930d20 268#ifdef HAVE_X11
f676886a 269 /* The tiled border used when the mouse is out of the frame. */
3f930d20
JB
270 Pixmap border_tile;
271
272 /* Here are the Graphics Contexts for the default font. */
273 GC normal_gc; /* Normal video */
274 GC reverse_gc; /* Reverse video */
275 GC cursor_gc; /* cursor drawing */
276#endif /* HAVE_X11 */
277
278 /* Width of the internal border. This is a line of background color
f676886a 279 just inside the window's border. When the frame is selected,
3f930d20
JB
280 a highlighting is displayed inside the internal border. */
281 int internal_border_width;
282
f676886a
JB
283 /* The X window used for this frame.
284 May be zero while the frame object is being created
3f930d20
JB
285 and the X window has not yet been created. */
286 Window window_desc;
287
288 /* The X window used for the bitmap icon;
289 or 0 if we don't have a bitmap icon. */
290 Window icon_desc;
291
292 /* The X window that is the parent of this X window.
293 Usually but not always RootWindow. */
294 Window parent_desc;
295
0be31d57
RS
296#ifdef USE_X_TOOLKIT
297 /* The widget of this screen. This is the window of a "shell" widget. */
298 Widget widget;
299 /* The XmPanedWindows... */
300 Widget column_widget;
301 /* The widget of the edit portion of this screen; the window in
302 "window_desc" is inside of this. */
303 Widget edit_widget;
304
305 Widget menubar_widget;
306#endif
307
3f930d20
JB
308 /* 1 for bitmap icon, 0 for text icon. */
309 int icon_bitmap_flag;
310
311 FONT_TYPE *font;
312
313 /* Pixel values used for various purposes.
314 border_pixel may be -1 meaning use a gray tile. */
315 PIX_TYPE background_pixel;
316 PIX_TYPE foreground_pixel;
317 PIX_TYPE cursor_pixel;
318 PIX_TYPE border_pixel;
319 PIX_TYPE mouse_pixel;
67710a63 320 PIX_TYPE cursor_foreground_pixel;
3f930d20 321
3f930d20
JB
322 /* Descriptor for the cursor in use for this window. */
323#ifdef HAVE_X11
324 Cursor text_cursor;
325 Cursor nontext_cursor;
326 Cursor modeline_cursor;
6bfbdaeb 327 Cursor cross_cursor;
3f930d20
JB
328#else
329 Cursor cursor;
330#endif
331
332 /* The name that was associated with the icon, the last time
333 it was refreshed. Usually the same as the name of the
f676886a 334 buffer in the currently selected window in the frame */
3f930d20
JB
335 char *icon_label;
336
337 /* Flag to set when the X window needs to be completely repainted. */
338 int needs_exposure;
339
dbc4e1c1
JB
340 /* What kind of text cursor is drawn in this window right now?
341 (If there is no cursor (phys_cursor_x < 0), then this means nothing.) */
342 enum text_cursor_kinds current_cursor;
343
344 /* What kind of text cursor should we draw in the future?
345 This should always be filled_box_cursor or bar_cursor. */
346 enum text_cursor_kinds desired_cursor;
ef15f270
JB
347
348 /* These are the current window manager hints. It seems that
349 XSetWMHints, when presented with an unset bit in the `flags'
350 member of the hints structure, does not leave the corresponding
351 attribute unchanged; rather, it resets that attribute to its
352 default value. For example, unless you set the `icon_pixmap'
353 field and the `IconPixmapHint' bit, XSetWMHints will forget what
354 your icon pixmap was. This is rather troublesome, since some of
355 the members (for example, `input' and `icon_pixmap') want to stay
356 the same throughout the execution of Emacs. So, we keep this
357 structure around, just leaving values in it and adding new bits
358 to the mask as we go. */
359 XWMHints wm_hints;
c8e3cbe0 360
c8e3cbe0 361 /* The size of the extra width currently allotted for vertical
a3c87d4e
JB
362 scroll bars, in pixels. */
363 int vertical_scroll_bar_extra;
13bd51a5 364
28f72798
JB
365 /* Table of parameter faces for this frame. Any X resources (pixel
366 values, fonts) referred to here have been allocated explicitly
367 for this face, and should be freed if we change the face. */
368 struct face **param_faces;
369 int n_param_faces;
370
371 /* Table of computed faces for this frame. These are the faces
372 whose indexes go into the upper bits of a glyph, computed by
373 combining the parameter faces specified by overlays, text
374 properties, and what have you. The X resources mentioned here
375 are all shared with parameter faces. */
376 struct face **computed_faces;
377 int n_computed_faces; /* How many are valid */
378 int size_computed_faces; /* How many are allocated */
3f930d20 379};
d2729198 380
28f72798
JB
381/* Get at the computed faces of an X window frame. */
382#define FRAME_PARAM_FACES(f) ((f)->display.x->param_faces)
383#define FRAME_N_PARAM_FACES(f) ((f)->display.x->n_param_faces)
384#define FRAME_DEFAULT_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[0])
385#define FRAME_MODE_LINE_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[1])
386
387#define FRAME_COMPUTED_FACES(f) ((f)->display.x->computed_faces)
388#define FRAME_N_COMPUTED_FACES(f) ((f)->display.x->n_computed_faces)
389#define FRAME_SIZE_COMPUTED_FACES(f) ((f)->display.x->size_computed_faces)
390#define FRAME_DEFAULT_FACE(f) ((f)->display.x->computed_faces[0])
391#define FRAME_MODE_LINE_FACE(f) ((f)->display.x->computed_faces[1])
13bd51a5 392
d2729198
JB
393/* Return the window associated with the frame F. */
394#define FRAME_X_WINDOW(f) ((f)->display.x->window_desc)
395
dbc4e1c1
JB
396/* These two really ought to be called FRAME_PIXEL_{WIDTH,HEIGHT}. */
397#define PIXEL_WIDTH(f) ((f)->display.x->pixel_width)
398#define PIXEL_HEIGHT(f) ((f)->display.x->pixel_height)
399
400#define FRAME_DESIRED_CURSOR(f) ((f)->display.x->desired_cursor)
401
3f930d20 402\f
13bd51a5 403/* When X windows are used, a glyph may be a 16 bit unsigned datum.
3f930d20
JB
404 The high order byte is the face number and is used as an index
405 in the face table. A face is a font plus:
406 1) the unhighlighted foreground color,
407 2) the unhighlighted background color.
408 For highlighting, the two colors are exchanged.
13bd51a5 409 Face number 0 is unused. The low order byte of a glyph gives
3f930d20
JB
410 the character within the font. All fonts are assumed to be
411 fixed width, and to have the same height and width. */
412
413#ifdef HAVE_X11
3f930d20 414
9d46c2e6 415/* Face declared in dispextern.h */
3f930d20
JB
416
417#else /* X10 */
418
419struct face
420{
421 FONT_TYPE *font; /* Font info for specified font. */
422 int fg; /* Unhighlighted foreground. */
423 int bg; /* Unhighlighted background. */
424};
425#endif /* X10 */
426
427#define MAX_FACES_AND_GLYPHS 256
428extern struct face *x_face_table[];
c8e3cbe0
JB
429
430\f
a3c87d4e 431/* X-specific scroll bar stuff. */
c8e3cbe0 432
a3c87d4e 433/* We represent scroll bars as lisp vectors. This allows us to place
4e027793 434 references to them in windows without worrying about whether we'll
a3c87d4e 435 end up with windows referring to dead scroll bars; the garbage
4e027793
JB
436 collector will free it when its time comes.
437
a3c87d4e 438 We use struct scroll_bar as a template for accessing fields of the
4e027793
JB
439 vector. */
440
a3c87d4e 441struct scroll_bar {
c8e3cbe0 442
4e027793
JB
443 /* These fields are shared by all vectors. */
444 int size_from_Lisp_Vector_struct;
445 struct Lisp_Vector *next_from_Lisp_Vector_struct;
446
a3c87d4e 447 /* The window we're a scroll bar for. */
4e027793 448 Lisp_Object window;
c8e3cbe0 449
a3c87d4e 450 /* The next and previous in the chain of scroll bars in this frame. */
4e027793 451 Lisp_Object next, prev;
c8e3cbe0 452
a3c87d4e 453 /* The X window representing this scroll bar. Since this is a full
4e027793
JB
454 32-bit quantity, we store it split into two 32-bit values. */
455 Lisp_Object x_window_low, x_window_high;
c8e3cbe0 456
a3c87d4e 457 /* The position and size of the scroll bar in pixels, relative to the
c8e3cbe0 458 frame. */
4e027793 459 Lisp_Object top, left, width, height;
c8e3cbe0 460
4e027793
JB
461 /* The starting and ending positions of the handle, relative to the
462 handle area (i.e. zero is the top position, not
a3c87d4e 463 SCROLL_BAR_TOP_BORDER). If they're equal, that means the handle
4e027793 464 hasn't been drawn yet.
c8e3cbe0 465
4e027793
JB
466 These are not actually the locations where the beginning and end
467 are drawn; in order to keep handles from becoming invisible when
468 editing large files, we establish a minimum height by always
a3c87d4e 469 drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
4e027793
JB
470 where they would be normally; the bottom and top are in a
471 different co-ordinate system. */
472 Lisp_Object start, end;
c8e3cbe0 473
a3c87d4e 474 /* If the scroll bar handle is currently being dragged by the user,
c8e3cbe0
JB
475 this is the number of pixels from the top of the handle to the
476 place where the user grabbed it. If the handle isn't currently
4e027793
JB
477 being dragged, this is Qnil. */
478 Lisp_Object dragging;
c8e3cbe0
JB
479};
480
a3c87d4e
JB
481/* The number of elements a vector holding a struct scroll_bar needs. */
482#define SCROLL_BAR_VEC_SIZE \
483 ((sizeof (struct scroll_bar) - sizeof (int) - sizeof (struct Lisp_Vector *)) \
4e027793
JB
484 / sizeof (Lisp_Object))
485
a3c87d4e
JB
486/* Turning a lisp vector value into a pointer to a struct scroll_bar. */
487#define XSCROLL_BAR(vec) ((struct scroll_bar *) XPNTR (vec))
4e027793
JB
488
489
490/* Building a 32-bit C integer from two 16-bit lisp integers. */
a3c87d4e 491#define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low))
4e027793
JB
492
493/* Setting two lisp integers to the low and high words of a 32-bit C int. */
a3c87d4e 494#define SCROLL_BAR_UNPACK(low, high, int32) \
4e027793
JB
495 (XSET ((low), Lisp_Int, (int32) & 0xffff), \
496 XSET ((high), Lisp_Int, ((int32) >> 16) & 0xffff))
497
498
a3c87d4e
JB
499/* Extract the X window id of the scroll bar from a struct scroll_bar. */
500#define SCROLL_BAR_X_WINDOW(ptr) \
501 ((Window) SCROLL_BAR_PACK ((ptr)->x_window_low, (ptr)->x_window_high))
4e027793 502
a3c87d4e
JB
503/* Store a window id in a struct scroll_bar. */
504#define SET_SCROLL_BAR_X_WINDOW(ptr, id) \
505 (SCROLL_BAR_UNPACK ((ptr)->x_window_low, (ptr)->x_window_high, (int) id))
4e027793
JB
506
507
a3c87d4e
JB
508/* Return the outside pixel width for a vertical scroll bar on frame F. */
509#define VERTICAL_SCROLL_BAR_PIXEL_WIDTH(f) (2*FONT_WIDTH ((f)->display.x->font))
c8e3cbe0 510
a3c87d4e 511/* Return the outside pixel height for a vertical scroll bar HEIGHT
c8e3cbe0 512 rows high on frame F. */
a3c87d4e 513#define VERTICAL_SCROLL_BAR_PIXEL_HEIGHT(f, height) \
2ba6876c 514 ((height) * (f)->display.x->line_height)
c8e3cbe0 515
a3c87d4e 516/* Return the inside width of a vertical scroll bar, given the outside
4e027793 517 width. */
a3c87d4e
JB
518#define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(width) \
519 ((width) - VERTICAL_SCROLL_BAR_LEFT_BORDER - VERTICAL_SCROLL_BAR_RIGHT_BORDER)
c8e3cbe0 520
4e027793
JB
521/* Return the length of the rectangle within which the top of the
522 handle must stay. This isn't equivalent to the inside height,
a3c87d4e 523 because the scroll bar handle has a minimum height.
4e027793 524
a3c87d4e
JB
525 This is the real range of motion for the scroll bar, so when we're
526 scaling buffer positions to scroll bar positions, we use this, not
527 VERTICAL_SCROLL_BAR_INSIDE_HEIGHT. */
528#define VERTICAL_SCROLL_BAR_TOP_RANGE(height) \
529 (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (height) - VERTICAL_SCROLL_BAR_MIN_HANDLE)
4e027793 530
a3c87d4e
JB
531/* Return the inside height of vertical scroll bar, given the outside
532 height. See VERTICAL_SCROLL_BAR_TOP_RANGE too. */
533#define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(height) \
534 ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER - VERTICAL_SCROLL_BAR_BOTTOM_BORDER)
4e027793
JB
535
536
a3c87d4e 537/* Border widths for scroll bars.
4e027793 538
a3c87d4e 539 Scroll bar windows don't have any X borders; their border width is
4e027793
JB
540 set to zero, and we redraw borders ourselves. This makes the code
541 a bit cleaner, since we don't have to convert between outside width
542 (used when relating to the rest of the screen) and inside width
a3c87d4e 543 (used when sizing and drawing the scroll bar window itself).
4e027793 544
eb8c3be9 545 The handle moves up and down/back and forth in a rectangle inset
a3c87d4e
JB
546 from the edges of the scroll bar. These are widths by which we
547 inset the handle boundaries from the scroll bar edges. */
548#define VERTICAL_SCROLL_BAR_LEFT_BORDER (2)
d68eb3a2 549#define VERTICAL_SCROLL_BAR_RIGHT_BORDER (2)
a3c87d4e
JB
550#define VERTICAL_SCROLL_BAR_TOP_BORDER (2)
551#define VERTICAL_SCROLL_BAR_BOTTOM_BORDER (2)
4e027793 552
a3c87d4e
JB
553/* Minimum lengths for scroll bar handles, in pixels. */
554#define VERTICAL_SCROLL_BAR_MIN_HANDLE (5)
c8e3cbe0
JB
555
556\f
557/* Manipulating pixel sizes and character sizes.
558 Knowledge of which factors affect the overall size of the window should
559 be hidden in these macros, if that's possible.
560
4e027793
JB
561/* Return the upper/left pixel position of the character cell on frame F
562 at ROW/COL. */
563#define CHAR_TO_PIXEL_ROW(f, row) \
564 ((f)->display.x->internal_border_width \
2ba6876c 565 + (row) * (f)->display.x->line_height)
4e027793
JB
566#define CHAR_TO_PIXEL_COL(f, col) \
567 ((f)->display.x->internal_border_width \
568 + (col) * FONT_WIDTH ((f)->display.x->font))
569
570/* Return the pixel width/height of frame F if it has
571 WIDTH columns/HEIGHT rows. */
c8e3cbe0 572#define CHAR_TO_PIXEL_WIDTH(f, width) \
4e027793 573 (CHAR_TO_PIXEL_COL (f, width) \
a3c87d4e 574 + (f)->display.x->vertical_scroll_bar_extra \
4e027793 575 + (f)->display.x->internal_border_width)
c8e3cbe0 576#define CHAR_TO_PIXEL_HEIGHT(f, height) \
4e027793
JB
577 (CHAR_TO_PIXEL_ROW (f, height) \
578 + (f)->display.x->internal_border_width)
c8e3cbe0 579
c8e3cbe0 580
4e027793
JB
581/* Return the row/column (zero-based) of the character cell containing
582 the pixel on FRAME at ROW/COL. */
cecfe612 583#define PIXEL_TO_CHAR_ROW(f, row) \
4e027793 584 (((row) - (f)->display.x->internal_border_width) \
2ba6876c 585 / (f)->display.x->line_height)
cecfe612 586#define PIXEL_TO_CHAR_COL(f, col) \
4e027793
JB
587 (((col) - (f)->display.x->internal_border_width) \
588 / FONT_WIDTH ((f)->display.x->font))
c8e3cbe0 589
4e027793
JB
590/* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
591 frame F? */
592#define PIXEL_TO_CHAR_WIDTH(f, width) \
593 (PIXEL_TO_CHAR_COL (f, ((width) \
594 - (f)->display.x->internal_border_width \
a3c87d4e 595 - (f)->display.x->vertical_scroll_bar_extra)))
4e027793
JB
596#define PIXEL_TO_CHAR_HEIGHT(f, height) \
597 (PIXEL_TO_CHAR_ROW (f, ((height) \
598 - (f)->display.x->internal_border_width)))
c352056c
RS
599\f
600/* If a struct input_event has a kind which is selection_request_event
601 or selection_clear_event, then its contents are really described
602 by this structure. */
603
604/* For an event of kind selection_request_event,
605 this structure really describes the contents. */
606struct selection_input_event
607{
608 int kind;
609 Display *display;
610 Window requestor;
611 Atom selection, target, property;
612 Time time;
613};
614
615#define SELECTION_EVENT_DISPLAY(eventp) \
616 (((struct selection_input_event *) (eventp))->display)
617#define SELECTION_EVENT_REQUESTOR(eventp) \
618 (((struct selection_input_event *) (eventp))->requestor)
619#define SELECTION_EVENT_SELECTION(eventp) \
620 (((struct selection_input_event *) (eventp))->selection)
621#define SELECTION_EVENT_TARGET(eventp) \
622 (((struct selection_input_event *) (eventp))->target)
623#define SELECTION_EVENT_PROPERTY(eventp) \
624 (((struct selection_input_event *) (eventp))->property)
625#define SELECTION_EVENT_TIME(eventp) \
626 (((struct selection_input_event *) (eventp))->time)
bf489d26
JB
627
628\f
629/* Interface to the face code functions. */
630
28f72798
JB
631/* Create the first two computed faces for a frame -- the ones that
632 have GC's. */
bf489d26
JB
633extern void init_frame_faces (/* FRAME_PTR */);
634
635/* Free the resources for the faces associated with a frame. */
636extern void free_frame_faces (/* FRAME_PTR */);
637
28f72798 638/* Given a computed face, find or make an equivalent display face
bf489d26
JB
639 in face_vector, and return a pointer to it. */
640extern struct face *intern_face (/* FRAME_PTR, struct face * */);
641
642/* Given a frame and a face name, return the face's ID number, or
643 zero if it isn't a recognized face name. */
644extern int face_name_id_number (/* FRAME_PTR, Lisp_Object */);
645
646/* Return non-zero if FONT1 and FONT2 have the same size bounding box.
647 We assume that they're both character-cell fonts. */
648extern int same_size_fonts (/* XFontStruct *, XFontStruct * */);
649
650/* Recompute the GC's for the default and modeline faces.
651 We call this after changing frame parameters on which those GC's
652 depend. */
653extern void recompute_basic_faces (/* FRAME_PTR */);
654
28f72798
JB
655/* Return the face ID associated with a buffer position POS. Store
656 into *ENDPTR the next position at which a different face is
657 needed. This does not take account of glyphs that specify their
658 own face codes. F is the frame in use for display, and W is a
659 window displaying the current buffer.
bf489d26
JB
660
661 REGION_BEG, REGION_END delimit the region, so it can be highlighted. */
662extern int compute_char_face (/* FRAME_PTR frame,
663 struct window *w,
664 int pos,
665 int region_beg, int region_end,
666 int *endptr */);
667/* Return the face ID to use to display a special glyph which selects
668 FACE_CODE as the face ID, assuming that ordinarily the face would
669 be BASIC_FACE. F is the frame. */
670extern int compute_glyph_face (/* FRAME_PTR, int */);