XEmacs 21.2.29 "Hestia".
[chise/xemacs-chise.git.1] / src / frame.h
1 /* Define frame-object for XEmacs.
2    Copyright (C) 1988, 1992, 1993, 1994 Free Software Foundation, Inc.
3
4 This file is part of XEmacs.
5
6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
10
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING.  If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 /* Synched up with: FSF 19.30. */
22
23 #ifndef INCLUDED_frame_h_
24 #define INCLUDED_frame_h_
25
26 #ifdef HAVE_SCROLLBARS
27 #include "scrollbar.h"
28 #endif
29
30 #ifdef HAVE_TOOLBARS
31 #include "toolbar.h"
32 #endif
33
34 #include "device.h"
35 #include "glyphs.h"
36 #include "redisplay.h"
37
38 #define FRAME_TYPE_NAME(f) ((f)->framemeths->name)
39 #define FRAME_TYPE(f) ((f)->framemeths->symbol)
40
41 /******** Accessing / calling a frame method *********/
42
43 #define HAS_FRAMEMETH_P(f, m) HAS_CONTYPE_METH_P ((f)->framemeths, m)
44 #define FRAMEMETH(f, m, args) CONTYPE_METH ((f)->framemeths, m, args)
45 #define MAYBE_FRAMEMETH(f, m, args) \
46   MAYBE_CONTYPE_METH ((f)->framemeths, m, args)
47 #define FRAMEMETH_OR_GIVEN(f, m, args, given) \
48   CONTYPE_METH_OR_GIVEN((f)->framemeths, m, args, given)
49
50 struct frame
51 {
52   struct lcrecord_header header;
53
54   /* Methods for this frame's console.  This can also be retrieved
55      through frame->device->console, but it's faster this way. */
56   struct console_methods *framemeths;
57
58   /* Size of text only area of this frame, excluding scrollbars,
59      toolbars and end of line glyphs. The size can be in characters
60      or pixels, depending on units in which window system resizes
61      its windows */
62   int height, width;
63
64   /* New height and width for pending size change, in the same units
65      as above. 0 if no change pending.  */
66   int new_height, new_width;
67
68   /* Size of text-only are of the frame, in default font characters.
69      This may be inaccurate due to rounding error */
70   int char_height, char_width;
71
72   /* Size of the whole frame, including scrollbars, toolbars and end
73      of line glyphs, in pixels */
74   int pixheight, pixwidth;
75
76 #ifdef HAVE_TTY
77   /* The count of frame number.  This applies to TTY frames only. */
78   int order_count;
79 #endif
80
81   /* Current page number for a printer frame. */
82   int page_number;
83
84   /* Width of the internal border.  This is a line of background color
85      just inside the window's border.  It is normally only non-zero on
86      X frames, but we put it here to avoid introducing window system
87      dependencies. */
88   int internal_border_width;
89
90   /* This frame's root window mirror.  This structure exactly mirrors
91      the frame's window structure but contains only pointers to the
92      display structures. */
93   struct window_mirror *root_mirror;
94
95   int modiff;
96
97   /* subwindow cache elements for this frame */
98   subwindow_cachel_dynarr *subwindow_cachels;
99
100   struct expose_ignore* subwindow_exposures;
101   struct expose_ignore* subwindow_exposures_tail;
102
103 #ifdef HAVE_SCROLLBARS
104   /* frame-local scrollbar information.  See scrollbar.c. */
105   int scrollbar_y_offset;
106
107   /* cache of created scrollbars */
108   struct scrollbar_instance *sb_vcache;
109   struct scrollbar_instance *sb_hcache;
110 #endif
111
112 #ifdef HAVE_TOOLBARS
113   /* Size of toolbars as seen by redisplay. This is used to determine
114      whether to re-layout windows by a call to change_frame_size early
115      in redisplay_frame. */
116   unsigned int current_toolbar_size[4];
117 #endif
118
119   /* Dynamic array of display lines for gutters */
120   display_line_dynarr *current_display_lines;
121   display_line_dynarr *desired_display_lines;
122
123   /* A structure of auxiliary data specific to the device type.
124      struct x_frame is used for X window frames; defined in console-x.h */
125   void *frame_data;
126
127 #define FRAME_SLOT_DECLARATION
128 #define MARKED_SLOT(x) Lisp_Object x
129 #include "frameslots.h"
130
131     /* Nonzero if frame is currently displayed.
132        Mutually exclusive with iconified
133        JV: This now a tristate flag:
134 Value : Emacs meaning                           :f-v-p : X meaning
135 0     : not displayed                           : nil  : unmapped
136 >0    : user can access it,needs repainting     : t    : mapped and visible
137 <0    : user can access it,needs no repainting  : hidden :mapped and invisible
138      where f-v-p is the return value of frame-visible-p */
139   int visible;
140
141   /* one-bit flags: */
142
143   /* Are we finished initializing? */
144   unsigned int init_finished :1;
145
146   /* Is frame marked for deletion?  This is used in XSetErrorHandler().  */
147   unsigned int being_deleted :1;
148
149   /* Nonzero if this frame has been destroyed. */
150   unsigned int dead :1;
151
152   /* Nonzero if last attempt at redisplay on this frame was preempted.  */
153   unsigned int display_preempted :1;
154
155   /* Nonzero if window is currently iconified.
156      This and visible are mutually exclusive.  */
157   unsigned int iconified :1;
158
159   /* Nonzero if this frame should be cleared and then redrawn.
160      Setting this will also effectively set frame_changed. */
161   unsigned int clear :1;
162
163   /* True if frame actually has a  minibuffer window on it.
164      0 if using a minibuffer window that isn't on this frame.  */
165   unsigned int has_minibuffer :1;
166
167   /* True if frame's root window can't be split.  */
168   unsigned int no_split :1;
169
170   unsigned int top_toolbar_was_visible :1;
171   unsigned int bottom_toolbar_was_visible :1;
172   unsigned int left_toolbar_was_visible :1;
173   unsigned int right_toolbar_was_visible :1;
174   /* gutter visibility */
175   unsigned int top_gutter_was_visible :1;
176   unsigned int bottom_gutter_was_visible :1;
177   unsigned int left_gutter_was_visible :1;
178   unsigned int right_gutter_was_visible :1;
179
180   /* redisplay flags */
181   unsigned int buffers_changed :1;
182   unsigned int clip_changed :1;
183   unsigned int extents_changed :1;
184   unsigned int faces_changed :1;
185   unsigned int frame_changed :1;
186   unsigned int subwindows_changed :1;
187   unsigned int subwindows_state_changed :1;
188   unsigned int glyphs_changed :1;
189   unsigned int icon_changed :1;
190   unsigned int menubar_changed :1;
191   unsigned int modeline_changed :1;
192   unsigned int point_changed :1;
193   unsigned int size_changed :1;
194   unsigned int toolbar_changed :1;
195   unsigned int gutter_changed :1;
196   unsigned int windows_changed :1;
197   unsigned int windows_structure_changed :1;
198   unsigned int window_face_cache_reset :1;      /* used by expose handler */
199   unsigned int echo_area_garbaged :1;   /* used by Fredisplay_echo_area */
200   unsigned int size_slipped :1;
201
202   unsigned int size_change_pending :1;
203   unsigned int mirror_dirty :1;
204
205   /* flag indicating if any window on this frame is displaying a subwindow */
206   unsigned int subwindows_being_displayed :1;
207 };
208
209 EXFUN (Fdelete_frame, 2);
210 EXFUN (Fframe_iconified_p, 1);
211 EXFUN (Fframe_name, 1);
212 EXFUN (Fframe_property, 3);
213 EXFUN (Fmake_frame, 2);
214 EXFUN (Fmake_frame_visible, 1);
215 EXFUN (Fraise_frame, 1);
216 EXFUN (Fselect_frame, 1);
217 EXFUN (Fset_frame_pointer, 2);
218 EXFUN (Fset_frame_position, 3);
219 EXFUN (Fset_frame_properties, 2);
220 EXFUN (Fset_frame_size, 4);
221
222 extern Lisp_Object Qbackground_toolbar_color, Qbell_volume, Qborder_color;
223 extern Lisp_Object Qborder_width, Qbottom_toolbar_shadow_color;
224 extern Lisp_Object Qbottom_toolbar_shadow_pixmap, Qdelete_frame;
225 extern Lisp_Object Qdeselect_frame_hook, Qdrag_and_drop_functions, Qgc_pointer;
226 extern Lisp_Object Qiconic, Qinitially_unmapped, Qinter_line_space;
227 extern Lisp_Object Qinternal_border_width, Qinvisible, Qmap_frame_hook;
228 extern Lisp_Object Qminibuffer, Qmodeline_pointer, Qmouse_enter_frame_hook;
229 extern Lisp_Object Qmouse_leave_frame_hook, Qpointer_background;
230 extern Lisp_Object Qpointer_color, Qpopup, Qscrollbar_placement;
231 extern Lisp_Object Qselect_frame_hook, Qspace_pointer;
232 extern Lisp_Object Qsynchronize_minibuffers, Qtext_pointer;
233 extern Lisp_Object Qtoolbar_shadow_thickness, Qtop_toolbar_shadow_color;
234 extern Lisp_Object Qtop_toolbar_shadow_pixmap, Qunmap_frame_hook;
235 extern Lisp_Object Qunsplittable, Quse_backing_store, Qvisible, Qvisual_bell;
236 extern Lisp_Object Vframe_icon_title_format, Vframe_title_format;
237 extern Lisp_Object Vmouse_motion_handler;
238
239
240 DECLARE_LRECORD (frame, struct frame);
241 #define XFRAME(x) XRECORD (x, frame, struct frame)
242 #define XSETFRAME(x, p) XSETRECORD (x, p, frame)
243 #define FRAMEP(x) RECORDP (x, frame)
244 #define CHECK_FRAME(x) CHECK_RECORD (x, frame)
245 #define CONCHECK_FRAME(x) CONCHECK_RECORD (x, frame)
246
247 #define CHECK_LIVE_FRAME(x) do {                        \
248   CHECK_FRAME (x);                                      \
249   if (! FRAME_LIVE_P (XFRAME (x)))                      \
250     dead_wrong_type_argument (Qframe_live_p, (x));      \
251 } while (0)
252 #define CONCHECK_LIVE_FRAME(x) do {                     \
253   CONCHECK_FRAME (x);                                   \
254   if (! FRAME_LIVE_P (XFRAME (x)))                      \
255     x = wrong_type_argument (Qframe_live_p, (x));       \
256 } while (0)
257
258 #define FRAME_TYPE_P(f, type)   EQ (FRAME_TYPE (f), Q##type)
259
260 #ifdef ERROR_CHECK_TYPECHECK
261 INLINE struct frame *
262 error_check_frame_type (struct frame * f, Lisp_Object sym);
263 INLINE struct frame *
264 error_check_frame_type (struct frame * f, Lisp_Object sym)
265 {
266   assert (EQ (FRAME_TYPE (f), sym));
267   return f;
268 }
269 # define FRAME_TYPE_DATA(f, type)                       \
270  ((struct type##_frame *) error_check_frame_type (f, Q##type)->frame_data)
271 #else
272 # define FRAME_TYPE_DATA(f, type)                       \
273   ((struct type##_frame *) (f)->frame_data)
274 #endif
275
276 #define CHECK_FRAME_TYPE(x, type)                       \
277   do {                                                  \
278     CHECK_FRAME (x);                                    \
279     if (!FRAME_TYPE_P (XFRAME (x), type))               \
280       dead_wrong_type_argument                          \
281         (type##_console_methods->predicate_symbol, x);  \
282   } while (0)
283 #define CONCHECK_FRAME_TYPE(x, type)                    \
284   do {                                                  \
285     CONCHECK_FRAME (x);                                 \
286     if (!FRAME_TYPE_P (XFRAME (x), type))               \
287       x = wrong_type_argument                           \
288         (type##_console_methods->predicate_symbol, x);  \
289   } while (0)
290
291 #define FRAME_DISPLAY_P(frm)                            \
292   (DEVICE_DISPLAY_P (XDEVICE (FRAME_DEVICE (frm))))
293
294 #define CHECK_DISPLAY_FRAME(frm)                        \
295   do {                                                  \
296     CHECK_FRAME (frm);                                  \
297     CHECK_LIVE_FRAME (frm);                             \
298     CHECK_DISPLAY_DEVICE (FRAME_DEVICE (XFRAME (frm))); \
299   } while (0)
300
301 #define CONCHECK_DISPLAY_FRAME(frm)                     \
302   do {                                                  \
303     CONCHECK_FRAME (frm);                               \
304     CONCHECK_LIVE_FRAME (frm);                          \
305     CONCHECK_DISPLAY_DEVICE (FRAME_DEVICE (XFRAME (frm))); \
306   } while (0)
307
308 #define FRAME_PRINTER_P(frm)                            \
309   (DEVICE_PRINTER_P (XDEVICE (FRAME_DEVICE (frm))))
310
311 #define CHECK_PRINTER_FRAME(frm)                        \
312   do {                                                  \
313     CHECK_FRAME (frm);                                  \
314     CHECK_LIVE_FRAME (frm);                             \
315     CHECK_PRINTER_DEVICE (FRAME_DEVICE (XFRAME (frm))); \
316   } while (0)
317
318 #define CONCHECK_PRINTER_FRAME(frm)                     \
319   do {                                                  \
320     CONCHECK_FRAME (frm);                               \
321     CONCHECK_LIVE_FRAME (frm);                          \
322     CONCHECK_PRINTER_DEVICE (FRAME_DEVICE (XFRAME (frm))); \
323   } while (0)
324
325 /* #### These should be in the frame-*.h files but there are
326    too many places where the abstraction is broken.  Need to
327    fix. */
328
329 #define FRAME_X_P(frm) CONSOLE_TYPESYM_X_P (FRAME_TYPE (frm))
330 #define CHECK_X_FRAME(z) CHECK_FRAME_TYPE (z, x)
331 #define CONCHECK_X_FRAME(z) CONCHECK_FRAME_TYPE (z, x)
332
333 #define FRAME_TTY_P(frm) CONSOLE_TYPESYM_TTY_P (FRAME_TYPE (frm))
334 #define CHECK_TTY_FRAME(z) CHECK_FRAME_TYPE (z, tty)
335 #define CONCHECK_TTY_FRAME(z) CONCHECK_FRAME_TYPE (z, tty)
336
337 #define FRAME_STREAM_P(frm) CONSOLE_TYPESYM_STREAM_P (FRAME_TYPE (frm))
338 #define CHECK_STREAM_FRAME(z) CHECK_FRAME_TYPE (z, stream)
339 #define CONCHECK_STREAM_FRAME(z) CONCHECK_FRAME_TYPE (z, stream)
340
341 #define FRAME_WIN_P(frm) CONSOLE_TYPESYM_WIN_P (FRAME_TYPE (frm))
342
343 extern int frame_changed;
344
345 #define MARK_FRAME_FACES_CHANGED(f) do {                \
346   struct frame *mffc_f = (f);                           \
347   mffc_f->faces_changed = 1;                            \
348   mffc_f->modiff++;                                     \
349   if (!NILP (mffc_f->device))                           \
350     {                                                   \
351       struct device *mffc_d = XDEVICE (mffc_f->device); \
352       MARK_DEVICE_FACES_CHANGED (mffc_d);               \
353     }                                                   \
354   else                                                  \
355     faces_changed = 1;                                  \
356 } while (0)
357
358 #define MARK_FRAME_GLYPHS_CHANGED(f) do {               \
359   struct frame *mfgc_f = (f);                           \
360   mfgc_f->glyphs_changed = 1;                           \
361   mfgc_f->modiff++;                                     \
362   if (!NILP (mfgc_f->device))                           \
363     {                                                   \
364       struct device *mfgc_d = XDEVICE (mfgc_f->device); \
365       MARK_DEVICE_GLYPHS_CHANGED (mfgc_d);              \
366     }                                                   \
367   else                                                  \
368     glyphs_changed = 1;                                 \
369 } while (0)
370
371 #define MARK_FRAME_SUBWINDOWS_CHANGED(f) do {           \
372   struct frame *mfgc_f = (f);                           \
373   mfgc_f->subwindows_changed = 1;                       \
374   mfgc_f->modiff++;                                     \
375   if (!NILP (mfgc_f->device))                           \
376     {                                                   \
377       struct device *mfgc_d = XDEVICE (mfgc_f->device); \
378       MARK_DEVICE_SUBWINDOWS_CHANGED (mfgc_d);          \
379     }                                                   \
380   else                                                  \
381     subwindows_changed = 1;                             \
382 } while (0)
383
384 #define MARK_FRAME_SUBWINDOWS_STATE_CHANGED(f) do {     \
385   struct frame *mfgc_f = (f);                           \
386   mfgc_f->subwindows_state_changed = 1;                 \
387   mfgc_f->modiff++;                                     \
388   if (!NILP (mfgc_f->device))                           \
389     {                                                   \
390       struct device *mfgc_d = XDEVICE (mfgc_f->device); \
391       MARK_DEVICE_SUBWINDOWS_STATE_CHANGED (mfgc_d);    \
392     }                                                   \
393   else                                                  \
394     subwindows_state_changed = 1;                       \
395 } while (0)
396
397 #define MARK_FRAME_TOOLBARS_CHANGED(f) do {             \
398   struct frame *mftc_f = (f);                           \
399   mftc_f->toolbar_changed = 1;                          \
400   mftc_f->modiff++;                                     \
401   if (!NILP (mftc_f->device))                           \
402     {                                                   \
403       struct device *mftc_d = XDEVICE (mftc_f->device); \
404       MARK_DEVICE_TOOLBARS_CHANGED (mftc_d);            \
405     }                                                   \
406   else                                                  \
407     toolbar_changed = 1;                                \
408 } while (0)
409
410 #define MARK_FRAME_GUTTERS_CHANGED(f) do {              \
411   struct frame *mftc_f = (f);                           \
412   mftc_f->gutter_changed = 1;                           \
413   mftc_f->modiff++;                                     \
414   if (!NILP (mftc_f->device))                           \
415     {                                                   \
416       struct device *mftc_d = XDEVICE (mftc_f->device); \
417       MARK_DEVICE_GUTTERS_CHANGED (mftc_d);             \
418     }                                                   \
419   else                                                  \
420     gutter_changed = 1;                                 \
421 } while (0)
422
423 #define MARK_FRAME_SIZE_CHANGED(f) do {                 \
424   struct frame *mfsc_f = (f);                           \
425   mfsc_f->size_changed = 1;                             \
426   mfsc_f->size_change_pending = 1;                      \
427   mfsc_f->modiff++;                                     \
428   if (!NILP (mfsc_f->device))                           \
429     {                                                   \
430       struct device *mfsc_d = XDEVICE (mfsc_f->device); \
431       MARK_DEVICE_SIZE_CHANGED (mfsc_d);                \
432     }                                                   \
433   else                                                  \
434     size_changed = 1;                                   \
435 } while (0)
436
437 #define MARK_FRAME_CHANGED(f) do {                      \
438   struct frame *mfc_f = (f);                            \
439   mfc_f->frame_changed = 1;                             \
440   mfc_f->modiff++;                                      \
441   if (!NILP (mfc_f->device))                            \
442     {                                                   \
443       struct device *mfc_d = XDEVICE (mfc_f->device);   \
444       MARK_DEVICE_FRAME_CHANGED (mfc_d);                \
445     }                                                   \
446   else                                                  \
447     frame_changed = 1;                                  \
448 } while (0)
449
450 #define MARK_FRAME_WINDOWS_CHANGED(f) do {              \
451   struct frame *mfwc_f = (f);                           \
452   mfwc_f->windows_changed = 1;                          \
453   mfwc_f->modiff++;                                     \
454   if (!NILP (mfwc_f->device))                           \
455     {                                                   \
456       struct device *mfwc_d = XDEVICE (mfwc_f->device); \
457       MARK_DEVICE_WINDOWS_CHANGED (mfwc_d);             \
458     }                                                   \
459   else                                                  \
460     windows_changed = 1;                                \
461 } while (0)
462
463 #define MARK_FRAME_WINDOWS_STRUCTURE_CHANGED(f) do {    \
464   struct frame *fwsc_f = (f);                           \
465   fwsc_f->windows_structure_changed = 1;                \
466   fwsc_f->modiff++;                                     \
467   if (!NILP (fwsc_f->device))                           \
468     {                                                   \
469       struct device *fwsc_d = XDEVICE (fwsc_f->device); \
470       MARK_DEVICE_WINDOWS_STRUCTURE_CHANGED (fwsc_d);   \
471     }                                                   \
472   else                                                  \
473     windows_structure_changed = 1;                      \
474   invalidate_vertical_divider_cache_in_frame (fwsc_f);  \
475 } while (0)
476
477 #define MARK_FRAME_SIZE_SLIPPED(f) do {                 \
478   struct frame *fwsc_f = (f);                           \
479   fwsc_f->size_slipped = 1;                             \
480   fwsc_f->modiff++;                                     \
481   if (!NILP (fwsc_f->device))                           \
482     {                                                   \
483       struct device *fwsc_d = XDEVICE (fwsc_f->device); \
484       MARK_DEVICE_FRAME_CHANGED (fwsc_d);               \
485     }                                                   \
486   else                                                  \
487     frame_changed = 1;                                  \
488 } while (0)
489
490 #define CLEAR_FRAME_SIZE_SLIPPED(f) do {                \
491   struct frame *fwsc_f = (f);                           \
492   fwsc_f->size_slipped = 0;                             \
493 } while (0)
494
495 #define SET_FRAME_CLEAR(f) MARK_FRAME_CHANGED (f); (f)->clear = 1
496 #define FRAME_DEVICE(f) ((f)->device)
497 #define FRAME_CONSOLE(f) DEVICE_CONSOLE (XDEVICE (FRAME_DEVICE (f)))
498 #define FRAME_LIVE_P(f) (!(f)->dead)
499
500 #define FRAME_MINIBUF_ONLY_P(f) \
501   EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
502 #define FRAME_HAS_MINIBUF_P(f)  ((f)->has_minibuffer)
503 #define FRAME_HEIGHT(f)         ((f)->height)
504 #define FRAME_WIDTH(f)          ((f)->width)
505 #define FRAME_CHARHEIGHT(f)     ((f)->char_height)
506 #define FRAME_CHARWIDTH(f)      ((f)->char_width)
507 #define FRAME_PIXHEIGHT(f)      ((f)->pixheight)
508 #define FRAME_PIXWIDTH(f)       ((f)->pixwidth)
509 #define FRAME_PAGENUMBER(f)     ((f)->page_number + 0)
510 #define FRAME_SET_PAGENUMBER(f,x) (f)->page_number = (x);
511 #ifdef HAVE_SCROLLBARS
512 #define FRAME_SCROLLBAR_WIDTH(f)                \
513   (NILP ((f)->vertical_scrollbar_visible_p) ?   \
514     0 : XINT ((f)->scrollbar_width))
515 #define FRAME_SCROLLBAR_HEIGHT(f)               \
516   (NILP ((f)->horizontal_scrollbar_visible_p) ? \
517     0 : XINT ((f)->scrollbar_height))
518 #else
519 #define FRAME_SCROLLBAR_WIDTH(f) 0
520 #define FRAME_SCROLLBAR_HEIGHT(f) 0
521 #endif
522
523 #define FW_FRAME(obj)                                   \
524    (WINDOWP (obj) ? WINDOW_FRAME (XWINDOW (obj))        \
525     : (FRAMEP  (obj) ? obj                              \
526        : Qnil))
527
528 #define FRAME_NEW_HEIGHT(f) ((f)->new_height)
529 #define FRAME_NEW_WIDTH(f) ((f)->new_width)
530 #define FRAME_CURSOR_X(f) ((f)->cursor_x)
531 #define FRAME_CURSOR_Y(f) ((f)->cursor_y)
532 #define FRAME_VISIBLE_P(f) ((f)->visible)
533 #define FRAME_REPAINT_P(f) ((f)->visible>0)
534 #define FRAME_NO_SPLIT_P(f) ((f)->no_split)
535 #define FRAME_ICONIFIED_P(f) ((f)->iconified)
536 #define FRAME_FOCUS_FRAME(f) ((f)->focus_frame)
537 #define FRAME_MINIBUF_WINDOW(f) ((f)->minibuffer_window)
538 #define FRAME_ROOT_WINDOW(f) ((f)->root_window)
539 /* Catch people attempting to set this. */
540 #define FRAME_SELECTED_WINDOW(f) NON_LVALUE ((f)->selected_window)
541 #define FRAME_LAST_NONMINIBUF_WINDOW(f) \
542   NON_LVALUE ((f)->last_nonminibuf_window)
543 #define FRAME_SB_VCACHE(f) ((f)->sb_vcache)
544 #define FRAME_SB_HCACHE(f) ((f)->sb_hcache)
545 #define FRAME_SUBWINDOW_CACHE(f) ((f)->subwindow_cachels)
546
547 #if 0 /* FSFmacs */
548
549 #define FRAME_VISIBLE_P(f) ((f)->visible != 0)
550 #define FRAME_SET_VISIBLE(f,p) \
551   ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
552
553 /* Emacs's redisplay code could become confused if a frame's
554    visibility changes at arbitrary times.  For example, if a frame is
555    visible while the desired glyphs are being built, but becomes
556    invisible before they are updated, then some rows of the
557    desired_glyphs will be left marked as enabled after redisplay is
558    complete, which should never happen.  The next time the frame
559    becomes visible, redisplay will probably barf.
560
561    Currently, there are no similar situations involving iconified, but
562    the principle is the same.
563
564    So instead of having asynchronous input handlers directly set and
565    clear the frame's visibility and iconification flags, they just set
566    the async_visible and async_iconified flags; the redisplay code
567    calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
568    which sets visible and iconified from their asynchronous
569    counterparts.
570
571    Synchronous code must use the FRAME_SET_VISIBLE macro.
572
573    Also, if a frame used to be invisible, but has just become visible,
574    it must be marked as garbaged, since redisplay hasn't been keeping
575    up its contents.  */
576 #define FRAME_SAMPLE_VISIBILITY(f) \
577   (((f)->async_visible && ! (f)->visible) ? SET_FRAME_GARBAGED (f) : 0, \
578    (f)->visible = (f)->async_visible, \
579    (f)->iconified = (f)->async_iconified)
580
581 #endif /* FSFmacs */
582
583 #define FRAME_BORDER_WIDTH(f) ((f)->internal_border_width)
584 #define FRAME_BORDER_HEIGHT(f) ((f)->internal_border_width)
585
586 /* This returns the frame-local value; that tells you what you should
587    use when computing the frame size.  It is *not* the actual toolbar
588    size because that depends on the selected window.  Use the macros
589    below for that.
590 */
591
592 #ifdef HAVE_TOOLBARS
593 #define FRAME_RAW_THEORETICAL_TOOLBAR_VISIBLE(f, pos) \
594   (!NILP((f)->toolbar_buttons[pos]) && !NILP ((f)->toolbar_visible_p[pos]))
595 #define FRAME_RAW_THEORETICAL_TOOLBAR_SIZE(f, pos) \
596   (!NILP ((f)->toolbar_buttons[pos]) && INTP((f)->toolbar_size[pos]) ? \
597    (XINT ((f)->toolbar_size[pos])) : 0)
598 #define FRAME_RAW_THEORETICAL_TOOLBAR_BORDER_WIDTH(f, pos) \
599   (!NILP ((f)->toolbar_buttons[pos]) && INTP((f)->toolbar_border_width[pos]) ? \
600    (XINT ((f)->toolbar_border_width[pos])) : 0)
601 #else
602 #define FRAME_RAW_THEORETICAL_TOOLBAR_VISIBLE(f, pos) 0
603 #define FRAME_RAW_THEORETICAL_TOOLBAR_SIZE(f, pos) 0
604 #define FRAME_RAW_THEORETICAL_TOOLBAR_BORDER_WIDTH(f, pos) 0
605 #endif
606
607 #define FRAME_THEORETICAL_TOOLBAR_SIZE(f, pos)          \
608   (FRAME_RAW_THEORETICAL_TOOLBAR_VISIBLE (f, pos)       \
609    ? FRAME_RAW_THEORETICAL_TOOLBAR_SIZE (f, pos)        \
610    : 0)
611
612 #define FRAME_THEORETICAL_TOP_TOOLBAR_HEIGHT(f) \
613   FRAME_THEORETICAL_TOOLBAR_SIZE (f, TOP_TOOLBAR)
614 #define FRAME_THEORETICAL_BOTTOM_TOOLBAR_HEIGHT(f) \
615   FRAME_THEORETICAL_TOOLBAR_SIZE (f, BOTTOM_TOOLBAR)
616 #define FRAME_THEORETICAL_LEFT_TOOLBAR_WIDTH(f) \
617   FRAME_THEORETICAL_TOOLBAR_SIZE (f, LEFT_TOOLBAR)
618 #define FRAME_THEORETICAL_RIGHT_TOOLBAR_WIDTH(f) \
619   FRAME_THEORETICAL_TOOLBAR_SIZE (f, RIGHT_TOOLBAR)
620
621 #define FRAME_THEORETICAL_TOOLBAR_BORDER_WIDTH(f, pos)          \
622   (FRAME_RAW_THEORETICAL_TOOLBAR_VISIBLE (f, pos)               \
623    ? FRAME_RAW_THEORETICAL_TOOLBAR_BORDER_WIDTH (f, pos)        \
624    : 0)
625
626 #define FRAME_THEORETICAL_TOP_TOOLBAR_BORDER_WIDTH(f) \
627   FRAME_THEORETICAL_TOOLBAR_BORDER_WIDTH (f, TOP_TOOLBAR)
628 #define FRAME_THEORETICAL_BOTTOM_TOOLBAR_BORDER_WIDTH(f) \
629   FRAME_THEORETICAL_TOOLBAR_BORDER_WIDTH (f, BOTTOM_TOOLBAR)
630 #define FRAME_THEORETICAL_LEFT_TOOLBAR_BORDER_WIDTH(f) \
631   FRAME_THEORETICAL_TOOLBAR_BORDER_WIDTH (f, LEFT_TOOLBAR)
632 #define FRAME_THEORETICAL_RIGHT_TOOLBAR_BORDER_WIDTH(f) \
633   FRAME_THEORETICAL_TOOLBAR_BORDER_WIDTH (f, RIGHT_TOOLBAR)
634
635 /* This returns the window-local value rather than the frame-local value;
636    that tells you about what's actually visible rather than what should
637    be used when computing the frame size. */
638
639 #ifdef HAVE_TOOLBARS
640 #define FRAME_RAW_REAL_TOOLBAR_VISIBLE(f, pos) \
641   (HAS_DEVMETH_P (XDEVICE (FRAME_DEVICE (f)), initialize_frame_toolbars) \
642    && !NILP (XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->toolbar_visible_p[pos]))
643 #define FRAME_RAW_REAL_TOOLBAR_BORDER_WIDTH(f, pos) \
644      ((INTP (XWINDOW \
645              (FRAME_LAST_NONMINIBUF_WINDOW (f))->toolbar_border_width[pos])) ? \
646       (XINT (XWINDOW \
647              (FRAME_LAST_NONMINIBUF_WINDOW (f))->toolbar_border_width[pos])) \
648       : 0)
649 #define FRAME_RAW_REAL_TOOLBAR_SIZE(f, pos) \
650      ((INTP (XWINDOW \
651              (FRAME_LAST_NONMINIBUF_WINDOW (f))->toolbar_size[pos])) ? \
652       (XINT (XWINDOW \
653              (FRAME_LAST_NONMINIBUF_WINDOW (f))->toolbar_size[pos])) : 0)
654 #define FRAME_REAL_TOOLBAR(f, pos) \
655   (XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->toolbar[pos])
656 #else
657 #define FRAME_RAW_REAL_TOOLBAR_VISIBLE(f, pos) 0
658 #define FRAME_RAW_REAL_TOOLBAR_BORDER_WIDTH(f, pos) 0
659 #define FRAME_RAW_REAL_TOOLBAR_SIZE(f, pos) 0
660 #define FRAME_REAL_TOOLBAR(f, pos) Qnil
661 #endif
662
663 /* Note to Chuck
664    Note to Chuck
665    Note to Chuck:
666
667    The former definitions of FRAME_REAL_FOO_TOOLBAR_VISIBLE
668    looked at the toolbar data to see what was there.  The
669    current ones look at the current values of the specifiers.
670    This is a semantic change; the former definition returned
671    what was *actually* there right at the moment, while the
672    current one returns what *ought* to be there once redisplay
673    has run to completion.  I think this new definition is more
674    correct in almost all circumstances and is much less likely
675    to lead to strange race conditions.  I'm not completely
676    sure that there aren't some places in the redisplay code
677    that use these macros and expect the former semantics, so
678    if you encounter some odd toolbar behavior, you might want
679    to look into this. --ben */
680
681 #define FRAME_REAL_TOOLBAR_VISIBLE(f, pos)              \
682   ((!NILP (FRAME_REAL_TOOLBAR (f, pos))                 \
683   && FRAME_RAW_REAL_TOOLBAR_SIZE (f, pos) > 0)          \
684    ? FRAME_RAW_REAL_TOOLBAR_VISIBLE (f, pos)            \
685    : 0)
686 #define FRAME_REAL_TOOLBAR_SIZE(f, pos)                 \
687   ((!NILP (FRAME_REAL_TOOLBAR (f, pos))                 \
688   && FRAME_RAW_REAL_TOOLBAR_VISIBLE (f, pos))           \
689    ? FRAME_RAW_REAL_TOOLBAR_SIZE (f, pos)               \
690    : 0)
691 #define FRAME_REAL_TOOLBAR_BORDER_WIDTH(f, pos)         \
692   ((!NILP (FRAME_REAL_TOOLBAR (f, pos))                 \
693   && FRAME_RAW_REAL_TOOLBAR_VISIBLE (f, pos))           \
694    ? FRAME_RAW_REAL_TOOLBAR_BORDER_WIDTH (f, pos)       \
695    : 0)
696
697 #define FRAME_REAL_TOP_TOOLBAR_HEIGHT(f) \
698   FRAME_REAL_TOOLBAR_SIZE (f, TOP_TOOLBAR)
699 #define FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT(f) \
700   FRAME_REAL_TOOLBAR_SIZE (f, BOTTOM_TOOLBAR)
701 #define FRAME_REAL_LEFT_TOOLBAR_WIDTH(f) \
702   FRAME_REAL_TOOLBAR_SIZE (f, LEFT_TOOLBAR)
703 #define FRAME_REAL_RIGHT_TOOLBAR_WIDTH(f) \
704   FRAME_REAL_TOOLBAR_SIZE (f, RIGHT_TOOLBAR)
705
706 #define FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH(f) \
707   FRAME_REAL_TOOLBAR_BORDER_WIDTH (f, TOP_TOOLBAR)
708 #define FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH(f) \
709   FRAME_REAL_TOOLBAR_BORDER_WIDTH (f, BOTTOM_TOOLBAR)
710 #define FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH(f) \
711   FRAME_REAL_TOOLBAR_BORDER_WIDTH (f, LEFT_TOOLBAR)
712 #define FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH(f) \
713   FRAME_REAL_TOOLBAR_BORDER_WIDTH (f, RIGHT_TOOLBAR)
714
715 #define FRAME_REAL_TOP_TOOLBAR_VISIBLE(f) \
716   FRAME_REAL_TOOLBAR_VISIBLE (f, TOP_TOOLBAR)
717 #define FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE(f) \
718   FRAME_REAL_TOOLBAR_VISIBLE (f, BOTTOM_TOOLBAR)
719 #define FRAME_REAL_LEFT_TOOLBAR_VISIBLE(f) \
720   FRAME_REAL_TOOLBAR_VISIBLE (f, LEFT_TOOLBAR)
721 #define FRAME_REAL_RIGHT_TOOLBAR_VISIBLE(f) \
722   FRAME_REAL_TOOLBAR_VISIBLE (f, RIGHT_TOOLBAR)
723
724 #define FRAME_TOP_BORDER_START(f)                               \
725   (FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) +                          \
726    2 * FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f))
727 #define FRAME_TOP_BORDER_END(f)                                 \
728   (FRAME_TOP_BORDER_START (f) + FRAME_BORDER_HEIGHT (f))
729
730 #define FRAME_BOTTOM_BORDER_START(f)                            \
731   (FRAME_PIXHEIGHT (f) - FRAME_BORDER_HEIGHT (f) -              \
732    FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) -                       \
733    2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f))
734 #define FRAME_BOTTOM_BORDER_END(f)                              \
735   (FRAME_PIXHEIGHT (f) - FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) - \
736    2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f))
737
738 #define FRAME_LEFT_BORDER_START(f)                              \
739   (FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) +                          \
740    2 * FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f))
741 #define FRAME_LEFT_BORDER_END(f)                                \
742   (FRAME_LEFT_BORDER_START (f) + FRAME_BORDER_WIDTH (f))
743
744 #define FRAME_RIGHT_BORDER_START(f)                             \
745   (FRAME_PIXWIDTH (f) - FRAME_BORDER_WIDTH (f) -                \
746    FRAME_REAL_RIGHT_TOOLBAR_WIDTH(f) -                          \
747    2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH (f))
748 #define FRAME_RIGHT_BORDER_END(f)                               \
749   (FRAME_PIXWIDTH (f) - FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) -    \
750    2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH(f))
751
752 /* Equivalent in FSF Emacs:
753
754    FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
755    `for' loop which iterates over the elements of Vframe_list.  The
756    loop will set FRAME_VAR, a Lisp_Object, to each frame in
757    Vframe_list in succession and execute the statement.  LIST_VAR
758    should be a Lisp_Object too; it is used to iterate through the
759    Vframe_list.
760    */
761
762 /* NO_BREAK means that "break" doesn't do what you think it does!
763    Use goto instead.  "continue" is OK, though. */
764 #define FRAME_LOOP_NO_BREAK(frmcons, devcons, concons)          \
765   DEVICE_LOOP_NO_BREAK (devcons, concons)                       \
766     DEVICE_FRAME_LOOP (frmcons, XDEVICE (XCAR (devcons)))
767
768 void update_frame_title (struct frame *f);
769 Lisp_Object next_frame (Lisp_Object f, Lisp_Object frametype,
770                         Lisp_Object console);
771 Lisp_Object prev_frame (Lisp_Object f, Lisp_Object frametype,
772                         Lisp_Object console);
773 void pixel_to_char_size (struct frame *f, int pixel_width, int pixel_height,
774                          int *char_width, int *char_height);
775 void char_to_pixel_size (struct frame *f, int char_width, int char_height,
776                          int *pixel_width, int *pixel_height);
777 void round_size_to_char (struct frame *f, int in_width, int in_height,
778                          int *out_width, int *out_height);
779 void pixel_to_real_char_size (struct frame *f, int pixel_width, int pixel_height,
780                          int *char_width, int *char_height);
781 void char_to_real_pixel_size (struct frame *f, int char_width, int char_height,
782                          int *pixel_width, int *pixel_height);
783 void round_size_to_real_char (struct frame *f, int in_width, int in_height,
784                               int *out_width, int *out_height);
785 void change_frame_size (struct frame *frame,
786                         int newlength, int newwidth,
787                         int delay);
788 void adjust_frame_size (struct frame *frame);
789 void frame_size_slipped (Lisp_Object specifier, struct frame *f,
790                          Lisp_Object oldval);
791 void hold_frame_size_changes (void);
792 void unhold_one_frame_size_changes (struct frame *f);
793 void unhold_frame_size_changes (void);
794 void select_frame_1 (Lisp_Object frame);
795 void select_frame_2 (Lisp_Object frame);
796 struct frame *selected_frame (void);
797 struct frame *device_selected_frame (struct device *d);
798 struct frame *decode_frame (Lisp_Object frame);
799 struct frame *decode_frame_or_selected (Lisp_Object cdf);
800 Lisp_Object make_frame (struct frame *f);
801 int other_visible_frames (struct frame *f);
802 void delete_frame_internal (struct frame *f, int force,
803                             int called_from_delete_device,
804                             int from_io_error);
805 void io_error_delete_frame (Lisp_Object frame);
806 Lisp_Object find_some_frame (int (*predicate) (Lisp_Object, void *),
807                              void *closure);
808 int device_matches_console_spec (Lisp_Object frame, Lisp_Object device,
809                                  Lisp_Object console);
810 Lisp_Object frame_first_window (struct frame *f);
811 int show_gc_cursor (struct frame *f, Lisp_Object cursor);
812 void set_frame_selected_window (struct frame *f, Lisp_Object window);
813 int is_surrogate_for_selected_frame (struct frame *f);
814 void update_frame_icon (struct frame *f);
815 void invalidate_vertical_divider_cache_in_frame (struct frame *f);
816
817 void init_frame (void);
818
819 #endif /* INCLUDED_frame_h_ */