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