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