]> code.delx.au - gnu-emacs/blob - src/frame.h
Merged from miles@gnu.org--gnu-2005 (patch 469)
[gnu-emacs] / src / frame.h
1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993, 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
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
8 the Free Software Foundation; either version 2, or (at your option)
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, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
21 /* Don't multiply include: dispextern.h includes macterm.h which
22 includes frame.h some emacs source includes both dispextern.h and
23 frame.h */
24
25 #ifndef EMACS_FRAME_H
26 #define EMACS_FRAME_H
27
28 \f
29 /* Miscellanea. */
30
31 /* Nonzero means there is at least one garbaged frame. */
32 extern int frame_garbaged;
33
34 /* Nonzero means FRAME_MESSAGE_BUF (selected_frame) is being used by
35 print. */
36
37 extern int message_buf_print;
38
39 \f
40 /* The structure representing a frame. */
41
42 enum output_method
43 {
44 output_initial,
45 output_termcap,
46 output_x_window,
47 output_msdos_raw,
48 output_w32,
49 output_mac
50 };
51
52 enum vertical_scroll_bar_type
53 {
54 vertical_scroll_bar_none,
55 vertical_scroll_bar_left,
56 vertical_scroll_bar_right
57 };
58
59 enum text_cursor_kinds
60 {
61 DEFAULT_CURSOR = -2,
62 NO_CURSOR = -1,
63 FILLED_BOX_CURSOR,
64 HOLLOW_BOX_CURSOR,
65 BAR_CURSOR,
66 HBAR_CURSOR
67 };
68
69 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
70 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
71
72 struct display;
73
74 struct frame
75 {
76 EMACS_INT size;
77 struct Lisp_Vector *next;
78
79 /* All Lisp_Object components must come first.
80 Only EMACS_INT values can be intermixed with them.
81 That ensures they are all aligned normally. */
82
83 /* Name of this frame: a Lisp string. It is used for looking up resources,
84 as well as for the title in some cases. */
85 Lisp_Object name;
86
87 /* The name to use for the icon, the last time
88 it was refreshed. nil means not explicitly specified. */
89 Lisp_Object icon_name;
90
91 /* This is the frame title specified explicitly, if any.
92 Usually it is nil. */
93 Lisp_Object title;
94
95 /* The frame which should receive keystrokes that occur in this
96 frame, or nil if they should go to the frame itself. This is
97 usually nil, but if the frame is minibufferless, we can use this
98 to redirect keystrokes to a surrogate minibuffer frame when
99 needed.
100
101 Note that a value of nil is different than having the field point
102 to the frame itself. Whenever the Fselect_frame function is used
103 to shift from one frame to the other, any redirections to the
104 original frame are shifted to the newly selected frame; if
105 focus_frame is nil, Fselect_frame will leave it alone. */
106 Lisp_Object focus_frame;
107
108 /* This frame's root window. Every frame has one.
109 If the frame has only a minibuffer window, this is it.
110 Otherwise, if the frame has a minibuffer window, this is its sibling. */
111 Lisp_Object root_window;
112
113 /* This frame's selected window.
114 Each frame has its own window hierarchy
115 and one of the windows in it is selected within the frame.
116 The selected window of the selected frame is Emacs's selected window. */
117 Lisp_Object selected_window;
118
119 /* This frame's minibuffer window.
120 Most frames have their own minibuffer windows,
121 but only the selected frame's minibuffer window
122 can actually appear to exist. */
123 Lisp_Object minibuffer_window;
124
125 /* Parameter alist of this frame.
126 These are the parameters specified when creating the frame
127 or modified with modify-frame-parameters. */
128 Lisp_Object param_alist;
129
130 /* List of scroll bars on this frame.
131 Actually, we don't specify exactly what is stored here at all; the
132 scroll bar implementation code can use it to store anything it likes.
133 This field is marked by the garbage collector. It is here
134 instead of in the `display' structure so that the garbage
135 collector doesn't need to look inside the window-system-dependent
136 structure. */
137 Lisp_Object scroll_bars;
138 Lisp_Object condemned_scroll_bars;
139
140 /* Vector describing the items to display in the menu bar.
141 Each item has four elements in this vector.
142 They are KEY, STRING, SUBMAP, and HPOS.
143 (HPOS is not used in when the X toolkit is in use.)
144 There are four additional elements of nil at the end, to terminate. */
145 Lisp_Object menu_bar_items;
146
147 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
148 Lisp_Object face_alist;
149
150 /* A vector that records the entire structure of this frame's menu bar.
151 For the format of the data, see extensive comments in xmenu.c.
152 Only the X toolkit version uses this. */
153 Lisp_Object menu_bar_vector;
154 /* Number of elements in the vector that have meaningful data. */
155 EMACS_INT menu_bar_items_used;
156
157 /* Predicate for selecting buffers for other-buffer. */
158 Lisp_Object buffer_predicate;
159
160 /* List of buffers viewed in this frame, for other-buffer. */
161 Lisp_Object buffer_list;
162
163 /* A dummy window used to display menu bars under X when no X
164 toolkit support is available. */
165 Lisp_Object menu_bar_window;
166
167 /* A window used to display the tool-bar of a frame. */
168 Lisp_Object tool_bar_window;
169
170 /* Desired and current tool-bar items. */
171 Lisp_Object tool_bar_items;
172
173 /* Desired and current contents displayed in tool_bar_window. */
174 Lisp_Object desired_tool_bar_string, current_tool_bar_string;
175
176 /* beyond here, there should be no more Lisp_Object components. */
177
178 /* Cache of realized faces. */
179 struct face_cache *face_cache;
180
181 /* A buffer to hold the frame's name. We can't use the Lisp
182 string's pointer (`name', above) because it might get relocated. */
183 char *namebuf;
184
185 /* Glyph pool and matrix. */
186 struct glyph_pool *current_pool;
187 struct glyph_pool *desired_pool;
188 struct glyph_matrix *desired_matrix;
189 struct glyph_matrix *current_matrix;
190
191 /* 1 means that glyphs on this frame have been initialized so it can
192 be used for output. */
193 unsigned glyphs_initialized_p : 1;
194
195 #if defined (USE_GTK)
196 /* Nonzero means using a tool bar that comes from the toolkit. */
197 int external_tool_bar;
198 #endif
199
200 /* Margin at the top of the frame. Used to display the tool-bar. */
201 int tool_bar_lines;
202
203 int n_tool_bar_items;
204
205 /* A buffer for decode_mode_line. */
206 char *decode_mode_spec_buffer;
207
208 /* See do_line_insertion_deletion_costs for info on these arrays. */
209 /* Cost of inserting 1 line on this frame */
210 int *insert_line_cost;
211 /* Cost of deleting 1 line on this frame */
212 int *delete_line_cost;
213 /* Cost of inserting n lines on this frame */
214 int *insert_n_lines_cost;
215 /* Cost of deleting n lines on this frame */
216 int *delete_n_lines_cost;
217
218 /* Size of this frame, excluding fringes, scroll bars etc.,
219 in units of canonical characters. */
220 EMACS_INT text_lines, text_cols;
221
222 /* Total size of this frame (i.e. its native window), in units of
223 canonical characters. */
224 EMACS_INT total_lines, total_cols;
225
226 /* New text height and width for pending size change.
227 0 if no change pending. */
228 int new_text_lines, new_text_cols;
229
230 /* Pixel position of the frame window (x and y offsets in root window). */
231 int left_pos, top_pos;
232
233 /* Size of the frame window in pixels. */
234 int pixel_height, pixel_width;
235
236 /* These many pixels are the difference between the outer window (i.e. the
237 left and top of the window manager decoration) and FRAME_X_WINDOW. */
238 int x_pixels_diff, y_pixels_diff;
239
240 /* This is the gravity value for the specified window position. */
241 int win_gravity;
242
243 /* The geometry flags for this window. */
244 int size_hint_flags;
245
246 /* Border width of the frame window as known by the (X) window system. */
247 int border_width;
248
249 /* Width of the internal border. This is a line of background color
250 just inside the window's border. When the frame is selected,
251 a highlighting is displayed inside the internal border. */
252 int internal_border_width;
253
254 /* Canonical X unit. Width of default font, in pixels. */
255 int column_width;
256
257 /* Widht of space glyph of default font, in pixels. */
258 int space_width;
259
260 /* Canonical Y unit. Height of a line, in pixels. */
261 int line_height;
262
263 /* The output method says how the contents of this frame are
264 displayed. It could be using termcap, or using an X window.
265 This must be the same as the display->type. */
266 enum output_method output_method;
267
268 /* The display that this frame uses. If this is NULL, then the
269 frame is deleted. */
270 struct display *display;
271
272 /* Display-dependent, frame-local auxiliary data used for displaying
273 the contents. When the frame is deleted, this data is deleted as
274 well. */
275 union output_data
276 {
277 struct tty_output *tty; /* termchar.h */
278 struct x_output *x; /* xterm.h */
279 struct w32_output *w32; /* w32term.h */
280 struct mac_output *mac; /* macterm.h */
281 EMACS_INT nothing;
282 }
283 output_data;
284
285 /* Total width of fringes reserved for drawing truncation bitmaps,
286 continuation bitmaps and alike. The width is in canonical char
287 units of the frame. This must currently be the case because window
288 sizes aren't pixel values. If it weren't the case, we wouldn't be
289 able to split windows horizontally nicely. */
290 int fringe_cols;
291
292 /* The extra width (in pixels) currently allotted for fringes. */
293 int left_fringe_width, right_fringe_width;
294
295 /* See FULLSCREEN_ enum below */
296 int want_fullscreen;
297
298 /* Number of lines of menu bar. */
299 int menu_bar_lines;
300
301 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
302 || defined (USE_GTK)
303 /* Nonzero means using a menu bar that comes from the X toolkit. */
304 int external_menu_bar;
305 #endif
306
307 /* Nonzero if last attempt at redisplay on this frame was preempted. */
308 char display_preempted;
309
310 /* visible is nonzero if the frame is currently displayed; we check
311 it to see if we should bother updating the frame's contents.
312 DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
313
314 Note that, since invisible frames aren't updated, whenever a
315 frame becomes visible again, it must be marked as garbaged. The
316 FRAME_SAMPLE_VISIBILITY macro takes care of this.
317
318 On ttys and on Windows NT/9X, to avoid wasting effort updating
319 visible frames that are actually completely obscured by other
320 windows on the display, we bend the meaning of visible slightly:
321 if greater than 1, then the frame is obscured - we still consider
322 it to be "visible" as seen from lisp, but we don't bother
323 updating it. We must take care to garbage the frame when it
324 ceaces to be obscured though.
325
326 iconified is nonzero if the frame is currently iconified.
327
328 Asynchronous input handlers should NOT change these directly;
329 instead, they should change async_visible or async_iconified, and
330 let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified
331 at the next redisplay.
332
333 These should probably be considered read-only by everyone except
334 FRAME_SAMPLE_VISIBILITY.
335
336 These two are mutually exclusive. They might both be zero, if the
337 frame has been made invisible without an icon. */
338 char visible, iconified;
339
340 /* Asynchronous input handlers change these, and
341 FRAME_SAMPLE_VISIBILITY copies them into visible and iconified.
342 See FRAME_SAMPLE_VISIBILITY, below. */
343 volatile char async_visible, async_iconified;
344
345 /* Nonzero if this frame should be redrawn. */
346 volatile char garbaged;
347
348 /* True if frame actually has a minibuffer window on it.
349 0 if using a minibuffer window that isn't on this frame. */
350 char has_minibuffer;
351
352 /* 0 means, if this frame has just one window,
353 show no modeline for that window. */
354 char wants_modeline;
355
356 /* Non-zero if the hardware device this frame is displaying on can
357 support scroll bars. */
358 char can_have_scroll_bars;
359
360 /* If can_have_scroll_bars is non-zero, this is non-zero if we should
361 actually display them on this frame. */
362 enum vertical_scroll_bar_type vertical_scroll_bar_type;
363
364 /* What kind of text cursor should we draw in the future?
365 This should always be filled_box_cursor or bar_cursor. */
366 enum text_cursor_kinds desired_cursor;
367
368 /* Width of bar cursor (if we are using that). */
369 int cursor_width;
370
371 /* What kind of text cursor should we draw when the cursor blinks off?
372 This can be filled_box_cursor or bar_cursor or no_cursor. */
373 enum text_cursor_kinds blink_off_cursor;
374
375 /* Width of bar cursor (if we are using that) for blink-off state. */
376 int blink_off_cursor_width;
377
378 /* Non-0 means raise this frame to the top of the heap when selected. */
379 char auto_raise;
380
381 /* Non-0 means lower this frame to the bottom of the stack when left. */
382 char auto_lower;
383
384 /* True if frame's root window can't be split. */
385 char no_split;
386
387 /* If this is set, then Emacs won't change the frame name to indicate
388 the current buffer, etcetera. If the user explicitly sets the frame
389 name, this gets set. If the user sets the name to Qnil, this is
390 cleared. */
391 char explicit_name;
392
393 /* Nonzero if size of some window on this frame has changed. */
394 char window_sizes_changed;
395
396 /* Storage for messages to this frame. */
397 char *message_buf;
398
399 /* Nonnegative if current redisplay should not do scroll computation
400 for lines beyond a certain vpos. This is the vpos. */
401 int scroll_bottom_vpos;
402
403 /* Configured width of the scroll bar, in pixels and in characters.
404 config_scroll_bar_cols tracks config_scroll_bar_width if the
405 latter is positive; a zero value in config_scroll_bar_width means
406 to compute the actual width on the fly, using config_scroll_bar_cols
407 and the current font width. */
408 int config_scroll_bar_width;
409 int config_scroll_bar_cols;
410
411 /* The size of the extra width currently allotted for vertical
412 scroll bars in this frame, in pixels. */
413 int scroll_bar_actual_width;
414
415 /* The baud rate that was used to calculate costs for this frame. */
416 int cost_calculation_baud_rate;
417
418 /* Nonzero if the mouse has moved on this display
419 since the last time we checked. */
420 char mouse_moved;
421
422 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
423 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
424 frame parameter. 0 means don't do gamma correction. */
425 double gamma;
426
427 /* Additional space to put between text lines on this frame. */
428 int extra_line_spacing;
429
430 /* Set to non-zero in change_frame_size when size of frame changed
431 Clear the frame in clear_garbaged_frames if set. */
432 unsigned resized_p : 1;
433
434 /* Set to non-zero in when we want for force a flush_display in
435 update_frame, usually after resizing the frame. */
436 unsigned force_flush_display_p : 1;
437
438 /* All display backends seem to need these two pixel values. */
439 unsigned long background_pixel;
440 unsigned long foreground_pixel;
441
442 /* Set to non-zero if the default face for the frame has been
443 realized. Reset to zero whenever the default face changes.
444 Used to see the difference between a font change and face change. */
445 unsigned default_face_done_p : 1;
446 };
447
448 #ifdef MULTI_KBOARD
449 #define FRAME_KBOARD(f) ((f)->display->kboard)
450 #else
451 #define FRAME_KBOARD(f) (&the_only_kboard)
452 #endif
453
454 typedef struct frame *FRAME_PTR;
455
456 #define XFRAME(p) (eassert (GC_FRAMEP(p)),(struct frame *) XPNTR (p))
457 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
458
459 /* Given a window, return its frame as a Lisp_Object. */
460 #define WINDOW_FRAME(w) (w)->frame
461
462 /* Test a frame for particular kinds of display methods. */
463 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
464 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
465 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
466 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
467 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
468 #define FRAME_MAC_P(f) ((f)->output_method == output_mac)
469
470 /* FRAME_WINDOW_P tests whether the frame is a window, and is
471 defined to be the predicate for the window system being used. */
472
473 #ifdef HAVE_X_WINDOWS
474 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
475 #endif
476 #ifdef HAVE_NTGUI
477 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
478 #endif
479 #ifdef MAC_OS
480 #define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
481 #endif
482 #ifndef FRAME_WINDOW_P
483 #define FRAME_WINDOW_P(f) (0)
484 #endif
485
486 /* Nonzero if frame F is still alive (not deleted). */
487 #define FRAME_LIVE_P(f) ((f)->display != 0)
488
489 /* Nonzero if frame F is a minibuffer-only frame. */
490 #define FRAME_MINIBUF_ONLY_P(f) \
491 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
492
493 /* Nonzero if frame F contains a minibuffer window.
494 (If this is 0, F must use some other minibuffer window.) */
495 #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
496
497 /* Pixel height of frame F, including non-toolkit menu bar and
498 non-toolkit tool bar lines. */
499 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
500
501 /* Pixel width of frame F. */
502 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
503
504 /* Height of frame F, measured in canonical lines, including
505 non-toolkit menu bar and non-toolkit tool bar lines. */
506 #define FRAME_LINES(f) (f)->text_lines
507
508 /* Width of frame F, measured in canonical character columns,
509 not including scroll bars if any. */
510 #define FRAME_COLS(f) (f)->text_cols
511
512 /* Number of lines of frame F used for menu bar.
513 This is relevant on terminal frames and on
514 X Windows when not using the X toolkit.
515 These lines are counted in FRAME_LINES. */
516 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
517
518 /* Nonzero if this frame should display a tool bar
519 in a way that does not use any text lines. */
520 #if defined (USE_GTK)
521 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
522 #else
523 #define FRAME_EXTERNAL_TOOL_BAR(f) 0
524 #endif
525
526 /* Number of lines of frame F used for the tool-bar. */
527
528 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
529
530
531 /* Lines above the top-most window in frame F. */
532
533 #define FRAME_TOP_MARGIN(F) \
534 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
535
536 /* Nonzero if this frame should display a menu bar
537 in a way that does not use any text lines. */
538 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
539 || defined (USE_GTK)
540 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
541 #else
542 #define FRAME_EXTERNAL_MENU_BAR(f) 0
543 #endif
544 #define FRAME_VISIBLE_P(f) ((f)->visible != 0)
545
546 /* Nonzero if frame F is currently visible but hidden. */
547 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
548
549 /* Nonzero if frame F is currently iconified. */
550 #define FRAME_ICONIFIED_P(f) (f)->iconified
551
552 #define FRAME_SET_VISIBLE(f,p) \
553 ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
554 #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
555 #define FRAME_GARBAGED_P(f) (f)->garbaged
556
557 /* Nonzero means do not allow splitting this frame's window. */
558 #define FRAME_NO_SPLIT_P(f) (f)->no_split
559
560 /* Not really implemented. */
561 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
562
563 /* Nonzero if a size change has been requested for frame F
564 but not yet really put into effect. This can be true temporarily
565 when an X event comes in at a bad time. */
566 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
567
568 /* The minibuffer window of frame F, if it has one; otherwise nil. */
569 #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
570
571 /* The root window of the window tree of frame F. */
572 #define FRAME_ROOT_WINDOW(f) (f)->root_window
573
574 /* The currently selected window of the window tree of frame F. */
575 #define FRAME_SELECTED_WINDOW(f) (f)->selected_window
576
577 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
578 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
579 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
580 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
581 #define FRAME_MESSAGE_BUF(f) (f)->message_buf
582 #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
583 #define FRAME_FOCUS_FRAME(f) (f)->focus_frame
584
585 /* Nonzero if frame F supports scroll bars.
586 If this is zero, then it is impossible to enable scroll bars
587 on frame F. */
588 #define FRAME_CAN_HAVE_SCROLL_BARS(f) ((f)->can_have_scroll_bars)
589
590 /* This frame slot says whether scroll bars are currently enabled for frame F,
591 and which side they are on. */
592 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
593 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
594 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
595 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
596 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
597 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
598 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
599
600 /* Width that a scroll bar in frame F should have, if there is one.
601 Measured in pixels.
602 If scroll bars are turned off, this is still nonzero. */
603 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
604
605 /* Width that a scroll bar in frame F should have, if there is one.
606 Measured in columns (characters).
607 If scroll bars are turned off, this is still nonzero. */
608 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
609
610 /* Width of a scroll bar in frame F, measured in columns (characters),
611 but only if scroll bars are on the left. If scroll bars are on
612 the right in this frame, or there are no scroll bars, value is 0. */
613
614 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
615 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
616 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
617 : 0)
618
619 /* Width of a left scroll bar in frame F, measured in pixels */
620
621 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
622 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
623 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
624 : 0)
625
626 /* Width of a scroll bar in frame F, measured in columns (characters),
627 but only if scroll bars are on the right. If scroll bars are on
628 the left in this frame, or there are no scroll bars, value is 0. */
629
630 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
631 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
632 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
633 : 0)
634
635 /* Width of a right scroll bar area in frame F, measured in pixels */
636
637 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
638 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
639 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
640 : 0)
641
642 /* Actual width of a scroll bar in frame F, measured in columns. */
643
644 #define FRAME_SCROLL_BAR_COLS(f) \
645 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
646 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
647 : 0)
648
649 /* Actual width of a scroll bar area in frame F, measured in pixels. */
650
651 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
652 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
653 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
654 : 0)
655
656 /* Total width of frame F, in columns (characters),
657 including the width used by scroll bars if any. */
658
659 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
660
661 /* Set the width of frame F to VAL.
662 VAL is the width of a full-frame window,
663 not including scroll bars and fringes. */
664
665 #define SET_FRAME_COLS(f, val) \
666 (FRAME_COLS (f) = (val), \
667 (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f)))
668
669 /* Given a value WIDTH for frame F's nominal width,
670 return the value that FRAME_TOTAL_COLS should have. */
671
672 #define FRAME_TOTAL_COLS_ARG(f, width) \
673 ((width) \
674 + FRAME_SCROLL_BAR_COLS (f) \
675 + FRAME_FRINGE_COLS (f))
676
677 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
678
679 #define FRAME_CURSOR_X_LIMIT(f) \
680 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
681
682 /* Nonzero if frame F has scroll bars. */
683
684 #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
685
686 #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
687 #define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items)
688 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
689
690 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
691 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
692 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
693 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
694
695 /* Return a pointer to the face cache of frame F. */
696
697 #define FRAME_FACE_CACHE(F) (F)->face_cache
698
699 /* Return the size of message_buf of the frame F. We multiply the
700 width of the frame by 4 because multi-byte form may require at most
701 4-byte for a character. */
702
703 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
704
705 /* Emacs's redisplay code could become confused if a frame's
706 visibility changes at arbitrary times. For example, if a frame is
707 visible while the desired glyphs are being built, but becomes
708 invisible before they are updated, then some rows of the
709 desired_glyphs will be left marked as enabled after redisplay is
710 complete, which should never happen. The next time the frame
711 becomes visible, redisplay will probably barf.
712
713 Currently, there are no similar situations involving iconified, but
714 the principle is the same.
715
716 So instead of having asynchronous input handlers directly set and
717 clear the frame's visibility and iconification flags, they just set
718 the async_visible and async_iconified flags; the redisplay code
719 calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
720 which sets visible and iconified from their asynchronous
721 counterparts.
722
723 Synchronous code must use the FRAME_SET_VISIBLE macro.
724
725 Also, if a frame used to be invisible, but has just become visible,
726 it must be marked as garbaged, since redisplay hasn't been keeping
727 up its contents.
728
729 Note that a tty frame is visible if and only if it is the topmost
730 frame. */
731
732 #define FRAME_SAMPLE_VISIBILITY(f) \
733 (((f)->async_visible && (f)->visible != (f)->async_visible) ? \
734 SET_FRAME_GARBAGED (f) : 0, \
735 (f)->visible = (f)->async_visible, \
736 (f)->iconified = (f)->async_iconified)
737
738 #define CHECK_FRAME(x) \
739 do { \
740 if (! FRAMEP (x)) \
741 x = wrong_type_argument (Qframep, (x)); \
742 } while (0)
743
744 #define CHECK_LIVE_FRAME(x) \
745 do { \
746 if (! FRAMEP (x) \
747 || ! FRAME_LIVE_P (XFRAME (x))) \
748 x = wrong_type_argument (Qframe_live_p, (x)); \
749 } while (0)
750
751 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
752 `for' loop which iterates over the elements of Vframe_list. The
753 loop will set FRAME_VAR, a Lisp_Object, to each frame in
754 Vframe_list in succession and execute the statement. LIST_VAR
755 should be a Lisp_Object too; it is used to iterate through the
756 Vframe_list.
757
758 This macro is a holdover from a time when multiple frames weren't always
759 supported. An alternate definition of the macro would expand to
760 something which executes the statement once. */
761
762 #define FOR_EACH_FRAME(list_var, frame_var) \
763 for ((list_var) = Vframe_list; \
764 (CONSP (list_var) \
765 && (frame_var = XCAR (list_var), 1)); \
766 list_var = XCDR (list_var))
767
768
769 extern Lisp_Object Qframep, Qframe_live_p;
770 extern Lisp_Object Qtty, Qtty_type;
771 extern Lisp_Object Qdisplay_id, Qdisplay_live_p;
772
773 extern struct frame *last_nonminibuf_frame;
774
775 extern struct frame *make_initial_frame P_ ((void));
776 extern struct frame *make_terminal_frame P_ ((struct display *));
777 extern struct frame *make_frame P_ ((int));
778 #ifdef HAVE_WINDOW_SYSTEM
779 extern struct frame *make_minibuffer_frame P_ ((void));
780 extern struct frame *make_frame_without_minibuffer P_ ((Lisp_Object,
781 struct kboard *,
782 Lisp_Object));
783 #endif /* HAVE_WINDOW_SYSTEM */
784 extern int other_visible_frames P_ ((struct frame *));
785
786 extern Lisp_Object Vframe_list;
787 extern Lisp_Object Vdefault_frame_alist;
788
789 extern Lisp_Object Vterminal_frame;
790
791 extern Lisp_Object Vmouse_highlight;
792 \f
793 /* The currently selected frame. */
794
795 extern Lisp_Object selected_frame;
796
797 /* Value is a pointer to the selected frame. If the selected frame
798 isn't live, abort. */
799
800 #define SELECTED_FRAME() \
801 ((FRAMEP (selected_frame) \
802 && FRAME_LIVE_P (XFRAME (selected_frame))) \
803 ? XFRAME (selected_frame) \
804 : (abort (), (struct frame *) 0))
805
806 \f
807 /***********************************************************************
808 Display-related Macros
809 ***********************************************************************/
810
811 /* Canonical y-unit on frame F.
812 This value currently equals the line height of the frame (which is
813 the height of the default font of F). */
814
815 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
816
817 /* Canonical x-unit on frame F.
818 This value currently equals the average width of the default font of F. */
819
820 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
821
822 /* Space glyph width of the default font of frame F. */
823
824 #define FRAME_SPACE_WIDTH(F) ((F)->space_width)
825
826
827 /* Pixel width of areas used to display truncation marks, continuation
828 marks, overlay arrows. This is 0 for terminal frames. */
829
830 #ifdef HAVE_WINDOW_SYSTEM
831
832 /* Total width of fringes reserved for drawing truncation bitmaps,
833 continuation bitmaps and alike. The width is in canonical char
834 units of the frame. This must currently be the case because window
835 sizes aren't pixel values. If it weren't the case, we wouldn't be
836 able to split windows horizontally nicely. */
837
838 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
839
840 /* Pixel-width of the left and right fringe. */
841
842 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
843 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
844
845 /* Total width of fringes in pixels. */
846
847 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
848 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
849
850
851 /* Pixel-width of internal border lines */
852
853 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
854
855 #else /* not HAVE_WINDOW_SYSTEM */
856
857 #define FRAME_FRINGE_COLS(F) 0
858 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
859 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
860 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
861 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
862
863 #endif /* not HAVE_WINDOW_SYSTEM */
864
865
866
867 \f
868 /***********************************************************************
869 Conversion between canonical units and pixels
870 ***********************************************************************/
871
872 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
873 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
874 represented as Lisp numbers, i.e. integers or floats. */
875
876 /* Convert canonical value X to pixels. F is the frame whose
877 canonical char width is to be used. X must be a Lisp integer or
878 float. Value is a C integer. */
879
880 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
881 (INTEGERP (X) \
882 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
883 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
884
885 /* Convert canonical value Y to pixels. F is the frame whose
886 canonical character height is to be used. X must be a Lisp integer
887 or float. Value is a C integer. */
888
889 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
890 (INTEGERP (Y) \
891 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
892 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
893
894 /* Convert pixel-value X to canonical units. F is the frame whose
895 canonical character width is to be used. X is a C integer. Result
896 is a Lisp float if X is not a multiple of the canon width,
897 otherwise it's a Lisp integer. */
898
899 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
900 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
901 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
902 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
903
904 /* Convert pixel-value Y to canonical units. F is the frame whose
905 canonical character height is to be used. Y is a C integer.
906 Result is a Lisp float if Y is not a multiple of the canon width,
907 otherwise it's a Lisp integer. */
908
909 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
910 ((Y) % FRAME_LINE_HEIGHT (F) \
911 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
912 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
913
914
915 \f
916 /* Manipulating pixel sizes and character sizes.
917 Knowledge of which factors affect the overall size of the window should
918 be hidden in these macros, if that's possible.
919
920 Return the upper/left pixel position of the character cell on frame F
921 at ROW/COL. */
922
923 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
924 (FRAME_INTERNAL_BORDER_WIDTH (f) \
925 + (row) * FRAME_LINE_HEIGHT (f))
926
927 #define FRAME_COL_TO_PIXEL_X(f, col) \
928 (FRAME_INTERNAL_BORDER_WIDTH (f) \
929 + (col) * FRAME_COLUMN_WIDTH (f))
930
931 /* Return the pixel width/height of frame F if it has
932 COLS columns/LINES rows. */
933
934 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
935 (FRAME_COL_TO_PIXEL_X (f, cols) \
936 + (f)->scroll_bar_actual_width \
937 + FRAME_TOTAL_FRINGE_WIDTH (f) \
938 + FRAME_INTERNAL_BORDER_WIDTH (f))
939
940 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
941 (FRAME_LINE_TO_PIXEL_Y (f, lines) \
942 + FRAME_INTERNAL_BORDER_WIDTH (f))
943
944
945 /* Return the row/column (zero-based) of the character cell containing
946 the pixel on FRAME at Y/X. */
947
948 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
949 (((y) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
950 / FRAME_LINE_HEIGHT (f))
951
952 #define FRAME_PIXEL_X_TO_COL(f, x) \
953 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
954 / FRAME_COLUMN_WIDTH (f))
955
956 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
957 frame F? */
958
959 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
960 (FRAME_PIXEL_X_TO_COL (f, ((width) \
961 - FRAME_INTERNAL_BORDER_WIDTH (f) \
962 - FRAME_TOTAL_FRINGE_WIDTH (f) \
963 - (f)->scroll_bar_actual_width)))
964
965 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
966 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
967 - FRAME_INTERNAL_BORDER_WIDTH (f))))
968
969
970 /***********************************************************************
971 Frame Parameters
972 ***********************************************************************/
973
974 extern Lisp_Object Qauto_raise, Qauto_lower;
975 extern Lisp_Object Qborder_color, Qborder_width;
976 extern Lisp_Object Qbuffer_predicate, Qbuffer_list;
977 extern Lisp_Object Qcursor_color, Qcursor_type;
978 extern Lisp_Object Qfont;
979 extern Lisp_Object Qbackground_color, Qforeground_color;
980 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
981 extern Lisp_Object Qinternal_border_width;
982 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
983 extern Lisp_Object Qmouse_color;
984 extern Lisp_Object Qname, Qtitle;
985 extern Lisp_Object Qparent_id;
986 extern Lisp_Object Qunsplittable, Qvisibility;
987 extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
988 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
989 extern Lisp_Object Qscreen_gamma;
990 extern Lisp_Object Qline_spacing;
991 extern Lisp_Object Qwait_for_wm;
992 extern Lisp_Object Qfullscreen;
993
994 extern Lisp_Object Qleft_fringe, Qright_fringe;
995 extern Lisp_Object Qheight, Qwidth;
996 extern Lisp_Object Qminibuffer, Qmodeline;
997 extern Lisp_Object Qonly;
998 extern Lisp_Object Qx, Qw32, Qmac, Qpc;
999 extern Lisp_Object Qvisible;
1000 extern Lisp_Object Qdisplay_type;
1001 extern Lisp_Object Qbackground_mode;
1002
1003 extern Lisp_Object Qx_resource_name;
1004
1005 extern Lisp_Object Qleft, Qright, Qtop, Qbox;
1006 extern Lisp_Object Qdisplay;
1007
1008 extern Lisp_Object Qwindow_system;
1009
1010 #ifdef HAVE_WINDOW_SYSTEM
1011
1012 /* The class of this X application. */
1013 #define EMACS_CLASS "Emacs"
1014
1015 enum
1016 {
1017 /* Values used as a bit mask, BOTH == WIDTH | HEIGHT. */
1018 FULLSCREEN_NONE = 0,
1019 FULLSCREEN_WIDTH = 1,
1020 FULLSCREEN_HEIGHT = 2,
1021 FULLSCREEN_BOTH = 3,
1022 FULLSCREEN_WAIT = 4,
1023 };
1024
1025
1026 /* These are in xterm.c, w32term.c, etc. */
1027
1028 extern void x_set_scroll_bar_default_width P_ ((struct frame *));
1029 extern void x_set_offset P_ ((struct frame *, int, int, int));
1030 extern void x_wm_set_icon_position P_ ((struct frame *, int, int));
1031
1032 extern Lisp_Object x_new_font P_ ((struct frame *, char *));
1033 extern Lisp_Object x_new_fontset P_ ((struct frame *, char *));
1034
1035
1036 /* These are in frame.c */
1037
1038 extern Lisp_Object Vx_resource_name;
1039 extern Lisp_Object Vx_resource_class;
1040
1041
1042 extern Lisp_Object Qface_set_after_frame_default;
1043
1044 extern void x_fullscreen_adjust P_ ((struct frame *f, int *, int *,
1045 int *, int *));
1046
1047 extern void x_set_frame_parameters P_ ((struct frame *, Lisp_Object));
1048 extern void x_report_frame_params P_ ((struct frame *, Lisp_Object *));
1049
1050 extern void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object));
1051 extern void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object));
1052 extern void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object));
1053 extern void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object));
1054 extern void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1055 extern void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1056 extern void x_set_internal_border_width P_ ((struct frame *, Lisp_Object,
1057 Lisp_Object));
1058 extern void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object));
1059 extern void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object));
1060 extern void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object));
1061 extern void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object));
1062 extern void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object,
1063 Lisp_Object));
1064 extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object,
1065 Lisp_Object));
1066
1067 extern Lisp_Object x_icon_type P_ ((struct frame *));
1068
1069 extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int));
1070
1071
1072 extern void validate_x_resource_name P_ ((void));
1073
1074 #endif /* HAVE_WINDOW_SYSTEM */
1075
1076 #endif /* not EMACS_FRAME_H */
1077
1078 /* arch-tag: 0df048ee-e6bf-4f48-bd56-e3cd055dd8c4
1079 (do not change this comment) */