
1: /* Define frame-object for GNU Emacs. 2: Copyright (C) 1993, 1994, 1999, 2000, 2001, 2002, 2003, 2004, 3: 2005, 2006, 2007 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: ^L 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: ^L 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 unsigned long 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: struct frame 97: { 98: EMACS_INT size; 99: struct Lisp_Vector *next; 100: 101: /* All Lisp_Object components must come first. 102: Only EMACS_INT values can be intermixed with them. 103: That ensures they are all aligned normally. */ 104: 105: /* Name of this frame: a Lisp string. It is used for looking up resources, 106: as well as for the title in some cases. */ 107: Lisp_Object name; 108: 109: /* The name to use for the icon, the last time 110: it was refreshed. nil means not explicitly specified. */ 111: Lisp_Object icon_name; 112: 113: /* This is the frame title specified explicitly, if any. 114: Usually it is nil. */ 115: Lisp_Object title; 116: 117: /* The frame which should receive keystrokes that occur in this 118: frame, or nil if they should go to the frame itself. This is 119: usually nil, but if the frame is minibufferless, we can use this 120: to redirect keystrokes to a surrogate minibuffer frame when 121: needed. 122: 123: Note that a value of nil is different than having the field point 124: to the frame itself. Whenever the Fselect_frame function is used 125: to shift from one frame to the other, any redirections to the 126: original frame are shifted to the newly selected frame; if 127: focus_frame is nil, Fselect_frame will leave it alone. */ 128: Lisp_Object focus_frame; 129: 130: /* This frame's root window. Every frame has one. 131: If the frame has only a minibuffer window, this is it. 132: Otherwise, if the frame has a minibuffer window, this is its sibling. */ 133: Lisp_Object root_window; 134: 135: /* This frame's selected window. 136: Each frame has its own window hierarchy 137: and one of the windows in it is selected within the frame. 138: The selected window of the selected frame is Emacs's selected window. */ 139: Lisp_Object selected_window; 140: 141: /* This frame's minibuffer window. 142: Most frames have their own minibuffer windows, 143: but only the selected frame's minibuffer window 144: can actually appear to exist. */ 145: Lisp_Object minibuffer_window; 146: 147: /* Parameter alist of this frame. 148: These are the parameters specified when creating the frame 149: or modified with modify-frame-parameters. */ 150: Lisp_Object param_alist; 151: 152: /* List of scroll bars on this frame. 153: Actually, we don't specify exactly what is stored here at all; the 154: scroll bar implementation code can use it to store anything it likes. 155: This field is marked by the garbage collector. It is here 156: instead of in the `display' structure so that the garbage 157: collector doesn't need to look inside the window-system-dependent 158: structure. */ 159: Lisp_Object scroll_bars; 160: Lisp_Object condemned_scroll_bars; 161: 162: /* Vector describing the items to display in the menu bar. 163: Each item has four elements in this vector. 164: They are KEY, STRING, SUBMAP, and HPOS. 165: (HPOS is not used in when the X toolkit is in use.) 166: There are four additional elements of nil at the end, to terminate. */ 167: Lisp_Object menu_bar_items; 168: 169: /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */ 170: Lisp_Object face_alist; 171: 172: /* A vector that records the entire structure of this frame's menu bar. 173: For the format of the data, see extensive comments in xmenu.c. 174: Only the X toolkit version uses this. */ 175: Lisp_Object menu_bar_vector; 176: /* Number of elements in the vector that have meaningful data. */ 177: EMACS_INT menu_bar_items_used; 178: 179: /* Predicate for selecting buffers for other-buffer. */ 180: Lisp_Object buffer_predicate; 181: 182: /* List of buffers viewed in this frame, for other-buffer. */ 183: Lisp_Object buffer_list; 184: 185: /* A dummy window used to display menu bars under X when no X 186: toolkit support is available. */ 187: Lisp_Object menu_bar_window; 188: 189: /* A window used to display the tool-bar of a frame. */ 190: Lisp_Object tool_bar_window; 191: 192: /* Desired and current tool-bar items. */ 193: Lisp_Object tool_bar_items; 194: 195: /* Desired and current contents displayed in tool_bar_window. */ 196: Lisp_Object desired_tool_bar_string, current_tool_bar_string; 197: 198: /* beyond here, there should be no more Lisp_Object components. */ 199: 200: /* Cache of realized faces. */ 201: struct face_cache *face_cache; 202: 203: /* A buffer to hold the frame's name. We can't use the Lisp 204: string's pointer (`name', above) because it might get relocated. */ 205: char *namebuf; 206: 207: /* Glyph pool and matrix. */ 208: struct glyph_pool *current_pool; 209: struct glyph_pool *desired_pool; 210: struct glyph_matrix *desired_matrix; 211: struct glyph_matrix *current_matrix; 212: 213: /* 1 means that glyphs on this frame have been initialized so it can 214: be used for output. */ 215: unsigned glyphs_initialized_p : 1; 216: 217: #if defined (USE_GTK) 218: /* Nonzero means using a tool bar that comes from the toolkit. */ 219: int external_tool_bar; 220: #endif 221: 222: /* Margin at the top of the frame. Used to display the tool-bar. */ 223: int tool_bar_lines; 224: 225: int n_tool_bar_rows; 226: int n_tool_bar_items; 227: 228: /* A buffer for decode_mode_line. */ 229: char *decode_mode_spec_buffer; 230: 231: /* See do_line_insertion_deletion_costs for info on these arrays. */ 232: /* Cost of inserting 1 line on this frame */ 233: int *insert_line_cost; 234: /* Cost of deleting 1 line on this frame */ 235: int *delete_line_cost; 236: /* Cost of inserting n lines on this frame */ 237: int *insert_n_lines_cost; 238: /* Cost of deleting n lines on this frame */ 239: int *delete_n_lines_cost; 240: 241: /* Size of this frame, excluding fringes, scroll bars etc., 242: in units of canonical characters. */ 243: EMACS_INT text_lines, text_cols; 244: 245: /* Total size of this frame (i.e. its native window), in units of 246: canonical characters. */ 247: EMACS_INT total_lines, total_cols; 248: 249: /* New text height and width for pending size change. 250: 0 if no change pending. */ 251: int new_text_lines, new_text_cols; 252: 253: /* Pixel position of the frame window (x and y offsets in root window). */ 254: int left_pos, top_pos; 255: 256: /* Size of the frame window in pixels. */ 257: int pixel_height, pixel_width; 258: 259: /* These many pixels are the difference between the outer window (i.e. the 260: left and top of the window manager decoration) and FRAME_X_WINDOW. */ 261: int x_pixels_diff, y_pixels_diff; 262: 263: /* This is the gravity value for the specified window position. */ 264: int win_gravity; 265: 266: /* The geometry flags for this window. */ 267: int size_hint_flags; 268: 269: /* Border width of the frame window as known by the (X) window system. */ 270: int border_width; 271: 272: /* Width of the internal border. This is a line of background color 273: just inside the window's border. When the frame is selected, 274: a highlighting is displayed inside the internal border. */ 275: int internal_border_width; 276: 277: /* Canonical X unit. Width of default font, in pixels. */ 278: int column_width; 279: 280: /* Widht of space glyph of default font, in pixels. */ 281: int space_width; 282: 283: /* Canonical Y unit. Height of a line, in pixels. */ 284: int line_height; 285: 286: /* The output method says how the contents of this frame 287: are displayed. It could be using termcap, or using an X window. */ 288: enum output_method output_method; 289: 290: /* A structure of auxiliary data used for displaying the contents. 291: struct x_output is used for X window frames; 292: it is defined in xterm.h. 293: struct w32_output is used for W32 window frames; 294: it is defined in w32term.h. */ 295: union output_data 296: { 297: struct x_output *x; 298: struct w32_output *w32; 299: struct mac_output *mac; 300: EMACS_INT nothing; 301: } 302: output_data; 303: 304: /* Total width of fringes reserved for drawing truncation bitmaps, 305: continuation bitmaps and alike. The width is in canonical char 306: units of the frame. This must currently be the case because window 307: sizes aren't pixel values. If it weren't the case, we wouldn't be 308: able to split windows horizontally nicely. */ 309: int fringe_cols; 310: 311: /* The extra width (in pixels) currently allotted for fringes. */ 312: int left_fringe_width, right_fringe_width; 313: 314: #ifdef MULTI_KBOARD 315: /* A pointer to the kboard structure associated with this frame. 316: For termcap frames, this points to initial_kboard. For X frames, 317: it will be the same as display.x->display_info->kboard. */ 318: struct kboard *kboard; 319: #endif 320: 321: /* See FULLSCREEN_ enum below */ 322: int want_fullscreen; 323: 324: /* Number of lines of menu bar. */ 325: int menu_bar_lines; 326: 327: #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \ 328: || defined (USE_GTK) 329: /* Nonzero means using a menu bar that comes from the X toolkit. */ 330: int external_menu_bar; 331: #endif 332: 333: /* Nonzero if last attempt at redisplay on this frame was preempted. */ 334: char display_preempted; 335: 336: /* visible is nonzero if the frame is currently displayed; we check 337: it to see if we should bother updating the frame's contents. 338: DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE. 339: 340: Note that, since invisible frames aren't updated, whenever a 341: frame becomes visible again, it must be marked as garbaged. The 342: FRAME_SAMPLE_VISIBILITY macro takes care of this. 343: 344: On Windows NT/9X, to avoid wasting effort updating visible frames 345: that are actually completely obscured by other windows on the 346: display, we bend the meaning of visible slightly: if greater than 347: 1, then the frame is obscured - we still consider it to be 348: "visible" as seen from lisp, but we don't bother updating it. We 349: must take care to garbage the frame when it ceaces to be obscured 350: though. Note that these semantics are only used on NT/9X. 351: 352: iconified is nonzero if the frame is currently iconified. 353: 354: Asynchronous input handlers should NOT change these directly; 355: instead, they should change async_visible or async_iconified, and 356: let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified 357: at the next redisplay. 358: 359: These should probably be considered read-only by everyone except 360: FRAME_SAMPLE_VISIBILITY. 361: 362: These two are mutually exclusive. They might both be zero, if the 363: frame has been made invisible without an icon. */ 364: char visible, iconified; 365: 366: /* Asynchronous input handlers change these, and 367: FRAME_SAMPLE_VISIBILITY copies them into visible and iconified. 368: See FRAME_SAMPLE_VISIBILITY, below. */ 369: volatile char async_visible, async_iconified; 370: 371: /* Nonzero if this frame should be redrawn. */ 372: volatile char garbaged; 373: 374: /* True if frame actually has a minibuffer window on it. 375: 0 if using a minibuffer window that isn't on this frame. */ 376: char has_minibuffer; 377: 378: /* 0 means, if this frame has just one window, 379: show no modeline for that window. */ 380: char wants_modeline; 381: 382: /* Non-zero if the hardware device this frame is displaying on can 383: support scroll bars. */ 384: char can_have_scroll_bars; 385: 386: /* If can_have_scroll_bars is non-zero, this is non-zero if we should 387: actually display them on this frame. */ 388: enum vertical_scroll_bar_type vertical_scroll_bar_type; 389: 390: /* What kind of text cursor should we draw in the future? 391: This should always be filled_box_cursor or bar_cursor. */ 392: enum text_cursor_kinds desired_cursor; 393: 394: /* Width of bar cursor (if we are using that). */ 395: int cursor_width; 396: 397: /* What kind of text cursor should we draw when the cursor blinks off? 398: This can be filled_box_cursor or bar_cursor or no_cursor. */ 399: enum text_cursor_kinds blink_off_cursor; 400: 401: /* Width of bar cursor (if we are using that) for blink-off state. */ 402: int blink_off_cursor_width; 403: 404: /* Non-0 means raise this frame to the top of the heap when selected. */ 405: char auto_raise; 406: 407: /* Non-0 means lower this frame to the bottom of the stack when left. */ 408: char auto_lower; 409: 410: /* True if frame's root window can't be split. */ 411: char no_split; 412: 413: /* If this is set, then Emacs won't change the frame name to indicate 414: the current buffer, etcetera. If the user explicitly sets the frame 415: name, this gets set. If the user sets the name to Qnil, this is 416: cleared. */ 417: char explicit_name; 418: 419: /* Nonzero if size of some window on this frame has changed. */ 420: char window_sizes_changed; 421: 422: /* Storage for messages to this frame. */ 423: char *message_buf; 424: 425: /* Nonnegative if current redisplay should not do scroll computation 426: for lines beyond a certain vpos. This is the vpos. */ 427: int scroll_bottom_vpos; 428: 429: /* Configured width of the scroll bar, in pixels and in characters. 430: config_scroll_bar_cols tracks config_scroll_bar_width if the 431: latter is positive; a zero value in config_scroll_bar_width means 432: to compute the actual width on the fly, using config_scroll_bar_cols 433: and the current font width. */ 434: int config_scroll_bar_width; 435: int config_scroll_bar_cols; 436: 437: /* The size of the extra width currently allotted for vertical 438: scroll bars in this frame, in pixels. */ 439: int scroll_bar_actual_width; 440: 441: /* The baud rate that was used to calculate costs for this frame. */ 442: int cost_calculation_baud_rate; 443: 444: /* Nonzero if the mouse has moved on this display 445: since the last time we checked. */ 446: char mouse_moved; 447: 448: /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA * 449: SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a 450: frame parameter. 0 means don't do gamma correction. */ 451: double gamma; 452: 453: /* Additional space to put between text lines on this frame. */ 454: int extra_line_spacing; 455: 456: /* Set to non-zero in change_frame_size when size of frame changed 457: Clear the frame in clear_garbaged_frames if set. */ 458: unsigned resized_p : 1; 459: 460: /* Set to non-zero in when we want for force a flush_display in 461: update_frame, usually after resizing the frame. */ 462: unsigned force_flush_display_p : 1; 463: 464: /* Set to non-zero if the default face for the frame has been 465: realized. Reset to zero whenever the default face changes. 466: Used to see the difference between a font change and face change. */ 467: unsigned default_face_done_p : 1; 468: 469: /* Set to non-zero if this frame has already been hscrolled during 470: current redisplay. */ 471: unsigned already_hscrolled_p : 1; 472: 473: /* Set to non-zero when current redisplay has updated frame. */ 474: unsigned updated_p : 1; 475: 476: /* Set to non-zero to minimize tool-bar height even when 477: auto-resize-tool-bar is set to grow-only. */ 478: unsigned minimize_tool_bar_window_p : 1; 479: }; 480: 481: #ifdef MULTI_KBOARD 482: #define FRAME_KBOARD(f) ((f)->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 (GC_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_TERMCAP_P(f) ((f)->output_method == output_termcap) 497: #define FRAME_X_P(f) ((f)->output_method == output_x_window) 498: #define FRAME_W32_P(f) ((f)->output_method == output_w32) 499: #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw) 500: #define FRAME_MAC_P(f) ((f)->output_method == output_mac) 501: 502: /* FRAME_WINDOW_P tests whether the frame is a window, and is 503: defined to be the predicate for the window system being used. */ 504: 505: #ifdef HAVE_X_WINDOWS 506: #define FRAME_WINDOW_P(f) FRAME_X_P (f) 507: #endif 508: #ifdef HAVE_NTGUI 509: #define FRAME_WINDOW_P(f) FRAME_W32_P (f) 510: #endif 511: #ifdef MAC_OS 512: #define FRAME_WINDOW_P(f) FRAME_MAC_P (f) 513: #endif 514: #ifndef FRAME_WINDOW_P 515: #define FRAME_WINDOW_P(f) (0) 516: #endif 517: 518: /* Nonzero if frame F is still alive (not deleted). */ 519: #define FRAME_LIVE_P(f) ((f)->output_data.nothing != 0) 520: 521: /* Nonzero if frame F is a minibuffer-only frame. */ 522: #define FRAME_MINIBUF_ONLY_P(f) \ 523: EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f)) 524: 525: /* Nonzero if frame F contains a minibuffer window. 526: (If this is 0, F must use some other minibuffer window.) */ 527: #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer) 528: 529: /* Pixel height of frame F, including non-toolkit menu bar and 530: non-toolkit tool bar lines. */ 531: #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height) 532: 533: /* Pixel width of frame F. */ 534: #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width) 535: 536: /* Height of frame F, measured in canonical lines, including 537: non-toolkit menu bar and non-toolkit tool bar lines. */ 538: #define FRAME_LINES(f) (f)->text_lines 539: 540: /* Width of frame F, measured in canonical character columns, 541: not including scroll bars if any. */ 542: #define FRAME_COLS(f) (f)->text_cols 543: 544: /* Number of lines of frame F used for menu bar. 545: This is relevant on terminal frames and on 546: X Windows when not using the X toolkit. 547: These lines are counted in FRAME_LINES. */ 548: #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines 549: 550: /* Nonzero if this frame should display a tool bar 551: in a way that does not use any text lines. */ 552: #if defined (USE_GTK) 553: #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar 554: #else 555: #define FRAME_EXTERNAL_TOOL_BAR(f) 0 556: #endif 557: 558: /* Number of lines of frame F used for the tool-bar. */ 559: 560: #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines 561: 562: 563: /* Lines above the top-most window in frame F. */ 564: 565: #define FRAME_TOP_MARGIN(F) \ 566: (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F)) 567: 568: /* Nonzero if this frame should display a menu bar 569: in a way that does not use any text lines. */ 570: #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \ 571: || defined (USE_GTK) 572: #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar 573: #else 574: #define FRAME_EXTERNAL_MENU_BAR(f) 0 575: #endif 576: #define FRAME_VISIBLE_P(f) ((f)->visible != 0) 577: 578: /* Nonzero if frame F is currently visible but hidden. */ 579: #define FRAME_OBSCURED_P(f) ((f)->visible > 1) 580: 581: /* Nonzero if frame F is currently iconified. */ 582: #define FRAME_ICONIFIED_P(f) (f)->iconified 583: 584: #define FRAME_SET_VISIBLE(f,p) \ 585: ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f)) 586: #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1) 587: #define FRAME_GARBAGED_P(f) (f)->garbaged 588: 589: /* Nonzero means do not allow splitting this frame's window. */ 590: #define FRAME_NO_SPLIT_P(f) (f)->no_split 591: 592: /* Not really implemented. */ 593: #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline 594: 595: /* Nonzero if a size change has been requested for frame F 596: but not yet really put into effect. This can be true temporarily 597: when an X event comes in at a bad time. */ 598: #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed 599: 600: /* The minibuffer window of frame F, if it has one; otherwise nil. */ 601: #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window 602: 603: /* The root window of the window tree of frame F. */ 604: #define FRAME_ROOT_WINDOW(f) (f)->root_window 605: 606: /* The currently selected window of the window tree of frame F. */ 607: #define FRAME_SELECTED_WINDOW(f) (f)->selected_window 608: 609: #define FRAME_INSERT_COST(f) (f)->insert_line_cost 610: #define FRAME_DELETE_COST(f) (f)->delete_line_cost 611: #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost 612: #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost 613: #define FRAME_MESSAGE_BUF(f) (f)->message_buf 614: #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos 615: #define FRAME_FOCUS_FRAME(f) (f)->focus_frame 616: 617: /* Nonzero if frame F sup