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