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