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