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