diff options
Diffstat (limited to 'src/frame.c')
-rw-r--r-- | src/frame.c | 235 |
1 files changed, 73 insertions, 162 deletions
diff --git a/src/frame.c b/src/frame.c index 1d375380d56..52be8be270e 100644 --- a/src/frame.c +++ b/src/frame.c @@ -131,7 +131,24 @@ fset_minibuffer_window (struct frame *f, Lisp_Object val) f->minibuffer_window = val; } - +struct frame * +decode_live_frame (register Lisp_Object frame) +{ + if (NILP (frame)) + frame = selected_frame; + CHECK_LIVE_FRAME (frame); + return XFRAME (frame); +} + +struct frame * +decode_any_frame (register Lisp_Object frame) +{ + if (NILP (frame)) + frame = selected_frame; + CHECK_FRAME (frame); + return XFRAME (frame); +} + static void set_menu_bar_lines_1 (Lisp_Object window, int n) { @@ -1118,23 +1135,12 @@ other_visible_frames (FRAME_PTR f) Lisp_Object delete_frame (Lisp_Object frame, Lisp_Object force) { - struct frame *f; + struct frame *f = decode_any_frame (frame); struct frame *sf = SELECTED_FRAME (); struct kboard *kb; int minibuffer_selected, is_tooltip_frame; - if (EQ (frame, Qnil)) - { - f = sf; - XSETFRAME (frame, f); - } - else - { - CHECK_FRAME (frame); - f = XFRAME (frame); - } - if (! FRAME_LIVE_P (f)) return Qnil; @@ -1146,9 +1152,11 @@ delete_frame (Lisp_Object frame, Lisp_Object force) if (NILP (XCDR (Vframe_list)) && !EQ (force, Qnoelisp)) error ("Attempt to delete the only frame"); + XSETFRAME (frame, f); + /* Does this frame have a minibuffer, and is it the surrogate minibuffer for any other frame? */ - if (FRAME_HAS_MINIBUF_P (XFRAME (frame))) + if (FRAME_HAS_MINIBUF_P (f)) { Lisp_Object frames; @@ -1663,25 +1671,23 @@ DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible, If omitted, FRAME defaults to the currently selected frame. */) (Lisp_Object frame) { - if (NILP (frame)) - frame = selected_frame; - - CHECK_LIVE_FRAME (frame); + struct frame *f = decode_live_frame (frame); /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM - if (FRAME_WINDOW_P (XFRAME (frame))) + if (FRAME_WINDOW_P (f)) { - FRAME_SAMPLE_VISIBILITY (XFRAME (frame)); - x_make_frame_visible (XFRAME (frame)); + FRAME_SAMPLE_VISIBILITY (f); + x_make_frame_visible (f); } #endif - make_frame_visible_1 (XFRAME (frame)->root_window); + make_frame_visible_1 (f->root_window); /* Make menu bar update for the Buffers and Frames menus. */ windows_or_buffers_changed++; + XSETFRAME (frame, f); return frame; } @@ -1722,16 +1728,13 @@ always considered visible, whether or not they are currently being displayed in the terminal. */) (Lisp_Object frame, Lisp_Object force) { - if (NILP (frame)) - frame = selected_frame; + struct frame *f = decode_live_frame (frame); - CHECK_LIVE_FRAME (frame); - - if (NILP (force) && !other_visible_frames (XFRAME (frame))) + if (NILP (force) && !other_visible_frames (f)) error ("Attempt to make invisible the sole visible or iconified frame"); /* Don't allow minibuf_window to remain on a deleted frame. */ - if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window)) + if (EQ (f->minibuffer_window, minibuf_window)) { struct frame *sf = XFRAME (selected_frame); /* Use set_window_buffer instead of Fset_window_buffer (see @@ -1743,8 +1746,8 @@ displayed in the terminal. */) /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM - if (FRAME_WINDOW_P (XFRAME (frame))) - x_make_frame_invisible (XFRAME (frame)); + if (FRAME_WINDOW_P (f)) + x_make_frame_invisible (f); #endif /* Make menu bar update for the Buffers and Frames menus. */ @@ -1759,19 +1762,10 @@ DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame, If omitted, FRAME defaults to the currently selected frame. */) (Lisp_Object frame) { - if (NILP (frame)) - frame = selected_frame; - - CHECK_LIVE_FRAME (frame); - -#if 0 /* This isn't logically necessary, and it can do GC. */ - /* Don't let the frame remain selected. */ - if (EQ (frame, selected_frame)) - Fhandle_switch_frame (next_frame (frame, Qt)); -#endif + struct frame *f = decode_live_frame (frame); /* Don't allow minibuf_window to remain on an iconified frame. */ - if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window)) + if (EQ (f->minibuffer_window, minibuf_window)) { struct frame *sf = XFRAME (selected_frame); /* Use set_window_buffer instead of Fset_window_buffer (see @@ -1783,8 +1777,8 @@ If omitted, FRAME defaults to the currently selected frame. */) /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM - if (FRAME_WINDOW_P (XFRAME (frame))) - x_iconify_frame (XFRAME (frame)); + if (FRAME_WINDOW_P (f)) + x_iconify_frame (f); #endif /* Make menu bar update for the Buffers and Frames menus. */ @@ -1848,13 +1842,9 @@ If Emacs is displaying on an ordinary terminal or some other device which doesn't support multiple overlapping frames, this function selects FRAME. */) (Lisp_Object frame) { - struct frame *f; - if (NILP (frame)) - frame = selected_frame; + struct frame *f = decode_live_frame (frame); - CHECK_LIVE_FRAME (frame); - - f = XFRAME (frame); + XSETFRAME (frame, f); if (FRAME_TERMCAP_P (f)) /* On a text terminal select FRAME. */ @@ -1877,14 +1867,7 @@ If Emacs is displaying on an ordinary terminal or some other device which doesn't support multiple overlapping frames, this function does nothing. */) (Lisp_Object frame) { - struct frame *f; - - if (NILP (frame)) - frame = selected_frame; - - CHECK_LIVE_FRAME (frame); - - f = XFRAME (frame); + struct frame *f = decode_live_frame (frame); if (FRAME_TERMINAL (f)->frame_raise_lower_hook) (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0); @@ -1920,18 +1903,14 @@ is affected by `select-frame', while the latter is not. The redirection lasts until `redirect-frame-focus' is called to change it. */) (Lisp_Object frame, Lisp_Object focus_frame) { - struct frame *f; - /* Note that we don't check for a live frame here. It's reasonable to redirect the focus of a frame you're about to delete, if you know what other frame should receive those keystrokes. */ - CHECK_FRAME (frame); + struct frame *f = decode_any_frame (frame); if (! NILP (focus_frame)) CHECK_LIVE_FRAME (focus_frame); - f = XFRAME (frame); - fset_focus_frame (f, focus_frame); if (FRAME_TERMINAL (f)->frame_rehighlight_hook) @@ -1941,15 +1920,14 @@ The redirection lasts until `redirect-frame-focus' is called to change it. */) } -DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0, +DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 0, 1, 0, doc: /* Return the frame to which FRAME's keystrokes are currently being sent. -This returns nil if FRAME's focus is not redirected. +If FRAME is omitted or nil, the selected frame is used. +Return nil if FRAME's focus is not redirected. See `redirect-frame-focus'. */) (Lisp_Object frame) { - CHECK_LIVE_FRAME (frame); - - return FRAME_FOCUS_FRAME (XFRAME (frame)); + return FRAME_FOCUS_FRAME (decode_live_frame (frame)); } @@ -1972,22 +1950,6 @@ get_frame_param (register struct frame *frame, Lisp_Object prop) } #endif -/* Return the buffer-predicate of the selected frame. */ - -Lisp_Object -frame_buffer_predicate (Lisp_Object frame) -{ - return XFRAME (frame)->buffer_predicate; -} - -/* Return the buffer-list of the selected frame. */ - -static Lisp_Object -frame_buffer_list (Lisp_Object frame) -{ - return XFRAME (frame)->buffer_list; -} - /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */ void @@ -2166,20 +2128,14 @@ DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0, doc: /* Return the parameters-alist of frame FRAME. It is a list of elements of the form (PARM . VALUE), where PARM is a symbol. The meaningful PARMs depend on the kind of frame. -If FRAME is omitted, return information on the currently selected frame. */) +If FRAME is omitted or nil, return information on the currently selected frame. */) (Lisp_Object frame) { Lisp_Object alist; - FRAME_PTR f; + struct frame *f = decode_any_frame (frame); int height, width; struct gcpro gcpro1; - if (NILP (frame)) - frame = selected_frame; - - CHECK_FRAME (frame); - f = XFRAME (frame); - if (!FRAME_LIVE_P (f)) return Qnil; @@ -2240,9 +2196,8 @@ If FRAME is omitted, return information on the currently selected frame. */) : FRAME_MINIBUF_ONLY_P (f) ? Qonly : FRAME_MINIBUF_WINDOW (f))); store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil)); - store_in_alist (&alist, Qbuffer_list, frame_buffer_list (frame)); - store_in_alist (&alist, Qburied_buffer_list, - XFRAME (frame)->buried_buffer_list); + store_in_alist (&alist, Qbuffer_list, f->buffer_list); + store_in_alist (&alist, Qburied_buffer_list, f->buried_buffer_list); /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM @@ -2267,17 +2222,12 @@ DEFUN ("frame-parameter", Fframe_parameter, Sframe_parameter, 2, 2, 0, If FRAME is nil, describe the currently selected frame. */) (Lisp_Object frame, Lisp_Object parameter) { - struct frame *f; - Lisp_Object value; + struct frame *f = decode_any_frame (frame); + Lisp_Object value = Qnil; - if (NILP (frame)) - frame = selected_frame; - else - CHECK_FRAME (frame); CHECK_SYMBOL (parameter); - f = XFRAME (frame); - value = Qnil; + XSETFRAME (frame, f); if (FRAME_LIVE_P (f)) { @@ -2357,14 +2307,9 @@ Note that this functionality is obsolete as of Emacs 22.2, and its use is not recommended. Explicitly check for a frame-parameter instead. */) (Lisp_Object frame, Lisp_Object alist) { - FRAME_PTR f; + struct frame *f = decode_live_frame (frame); register Lisp_Object tail, prop, val; - if (EQ (frame, Qnil)) - frame = selected_frame; - CHECK_LIVE_FRAME (frame); - f = XFRAME (frame); - /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f)) @@ -2419,18 +2364,13 @@ use is not recommended. Explicitly check for a frame-parameter instead. */) DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height, 0, 1, 0, doc: /* Height in pixels of a line in the font in frame FRAME. -If FRAME is omitted, the selected frame is used. +If FRAME is omitted or nil, the selected frame is used. For a terminal frame, the value is always 1. */) (Lisp_Object frame) { - struct frame *f; - - if (NILP (frame)) - frame = selected_frame; - CHECK_FRAME (frame); - f = XFRAME (frame); - #ifdef HAVE_WINDOW_SYSTEM + struct frame *f = decode_any_frame (frame); + if (FRAME_WINDOW_P (f)) return make_number (x_char_height (f)); else @@ -2442,19 +2382,14 @@ For a terminal frame, the value is always 1. */) DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width, 0, 1, 0, doc: /* Width in pixels of characters in the font in frame FRAME. -If FRAME is omitted, the selected frame is used. +If FRAME is omitted or nil, the selected frame is used. On a graphical screen, the width is the standard width of the default font. For a terminal screen, the value is always 1. */) (Lisp_Object frame) { - struct frame *f; - - if (NILP (frame)) - frame = selected_frame; - CHECK_FRAME (frame); - f = XFRAME (frame); - #ifdef HAVE_WINDOW_SYSTEM + struct frame *f = decode_any_frame (frame); + if (FRAME_WINDOW_P (f)) return make_number (x_char_width (f)); else @@ -2465,7 +2400,7 @@ For a terminal screen, the value is always 1. */) DEFUN ("frame-pixel-height", Fframe_pixel_height, Sframe_pixel_height, 0, 1, 0, doc: /* Return a FRAME's height in pixels. -If FRAME is omitted, the selected frame is used. The exact value +If FRAME is omitted or nil, the selected frame is used. The exact value of the result depends on the window-system and toolkit in use: In the Gtk+ version of Emacs, it includes only any window (including @@ -2480,12 +2415,7 @@ result is really in characters rather than pixels (i.e., is identical to `frame-height'). */) (Lisp_Object frame) { - struct frame *f; - - if (NILP (frame)) - frame = selected_frame; - CHECK_FRAME (frame); - f = XFRAME (frame); + struct frame *f = decode_any_frame (frame); #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f)) @@ -2499,15 +2429,10 @@ DEFUN ("frame-pixel-width", Fframe_pixel_width, Sframe_pixel_width, 0, 1, 0, doc: /* Return FRAME's width in pixels. For a terminal frame, the result really gives the width in characters. -If FRAME is omitted, the selected frame is used. */) +If FRAME is omitted or nil, the selected frame is used. */) (Lisp_Object frame) { - struct frame *f; - - if (NILP (frame)) - frame = selected_frame; - CHECK_FRAME (frame); - f = XFRAME (frame); + struct frame *f = decode_any_frame (frame); #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f)) @@ -2521,17 +2446,15 @@ DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width, Stool_bar_pixel_width, 0, 1, 0, doc: /* Return width in pixels of FRAME's tool bar. The result is greater than zero only when the tool bar is on the left -or right side of FRAME. If FRAME is omitted, the selected frame is -used. */) +or right side of FRAME. If FRAME is omitted or nil, the selected frame +is used. */) (Lisp_Object frame) { - if (NILP (frame)) - frame = selected_frame; - CHECK_FRAME (frame); - #ifdef FRAME_TOOLBAR_WIDTH - if (FRAME_WINDOW_P (XFRAME (frame))) - return make_number (FRAME_TOOLBAR_WIDTH (XFRAME (frame))); + struct frame *f = decode_any_frame (frame); + + if (FRAME_WINDOW_P (f)) + return make_number (FRAME_TOOLBAR_WIDTH (f)); #endif return make_number (0); } @@ -2542,13 +2465,9 @@ Optional third arg non-nil means that redisplay should use LINES lines but that the idea of the actual height of the frame should not be changed. */) (Lisp_Object frame, Lisp_Object lines, Lisp_Object pretend) { - register struct frame *f; + register struct frame *f = decode_live_frame (frame); CHECK_TYPE_RANGED_INTEGER (int, lines); - if (NILP (frame)) - frame = selected_frame; - CHECK_LIVE_FRAME (frame); - f = XFRAME (frame); /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM @@ -2570,12 +2489,9 @@ Optional third arg non-nil means that redisplay should use COLS columns but that the idea of the actual width of the frame should not be changed. */) (Lisp_Object frame, Lisp_Object cols, Lisp_Object pretend) { - register struct frame *f; + register struct frame *f = decode_live_frame (frame); + CHECK_TYPE_RANGED_INTEGER (int, cols); - if (NILP (frame)) - frame = selected_frame; - CHECK_LIVE_FRAME (frame); - f = XFRAME (frame); /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM @@ -4292,12 +4208,7 @@ Otherwise it returns nil. FRAME omitted or nil means the selected frame. This is useful when `make-pointer-invisible' is set. */) (Lisp_Object frame) { - if (NILP (frame)) - frame = selected_frame; - - CHECK_FRAME (frame); - - return (XFRAME (frame)->pointer_invisible ? Qnil : Qt); + return decode_any_frame (frame)->pointer_invisible ? Qnil : Qt; } |