aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2012-11-06 17:26:20 +0400
committerDmitry Antipov2012-11-06 17:26:20 +0400
commitd9f07150fc320156377a172fd4a5ec23f13a15c0 (patch)
treed6f3d226cc337756df27d3c828e64d5b9e816132 /src
parent8e6a67b7fa719b0527bb66377d6b72c3c4e84142 (diff)
downloademacs-d9f07150fc320156377a172fd4a5ec23f13a15c0.tar.gz
emacs-d9f07150fc320156377a172fd4a5ec23f13a15c0.zip
Widely used frame validity and checking functions.
* frame.h (decode_live_frame, decode_any_frame): Add prototypes. * frame.c (decode_live_frame, decode_any_frame): New functions. (delete_frame, Fredirect_frame_focus, Fframe_parameters) (Fframe_parameter, Fframe_char_height, Fframe_char_width) (Fframe_pixel_height, Fframe_pixel_width, Ftool_bar_pixel_width) (Fframe_pointer_visible_p): Use decode_any_frame. (Fmake_frame_visible, Fmake_frame_invisible, Ficonify_frame) (Fraise_frame, Flower_frame, Fmodify_frame_parameters) (Fset_frame_height, Fset_frame_width): Use decode_live_frame. (Fframe_focus): Likewise. Allow zero number of arguments. Adjust docstring. (frame_buffer_list, frame_buffer_predicate): Remove. * lisp.h (frame_buffer_predicate): Remove prototype. * buffer.c (Fother_buffer): Use decode_any_frame. * xdisp.c (Ftool_bar_lines_needed): Likewise. * xfaces.c (Fcolor_gray_p, Fcolor_supported_p): Likewise. * font.c (Ffont_face_attributes, Ffont_family_list, Fopen_font) (Fclose_font, Ffont_info): Use decode_live_frame. * fontset.c (check_fontset_name): Likewise. * terminal.c (Fframe_terminal): Likewise. * w32fns.c (check_x_frame): Likewise. * window.c (Fminibuffer_window, Fwindow_at) (Fcurrent_window_configuration): Likewise. (Frun_window_configuration_change_hook, Fwindow_resize_apply): Likewise. Allow zero number of arguments. Adjust docstring. * dispnew.c (Fredraw_frame): Likewise. * xfaces.c (frame_or_selected_frame): Remove. (Fx_list_fonts, Finternal_get_lisp_face_attribute, Fface_font) (Finternal_lisp_face_equal_p, Finternal_lisp_face_empty_p) (Fframe_face_alist): Use decode_live_frame. * xfns.c (check_x_frame): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog35
-rw-r--r--src/buffer.c12
-rw-r--r--src/dispnew.c10
-rw-r--r--src/font.c40
-rw-r--r--src/fontset.c9
-rw-r--r--src/frame.c235
-rw-r--r--src/frame.h2
-rw-r--r--src/lisp.h1
-rw-r--r--src/terminal.c9
-rw-r--r--src/w32fns.c6
-rw-r--r--src/window.c46
-rw-r--r--src/xdisp.c11
-rw-r--r--src/xfaces.c98
-rw-r--r--src/xfns.c6
14 files changed, 172 insertions, 348 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1daeb7bc0b6..0a277a0d67b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,40 @@
12012-11-06 Dmitry Antipov <dmantipov@yandex.ru> 12012-11-06 Dmitry Antipov <dmantipov@yandex.ru>
2 2
3 Widely used frame validity and checking functions.
4 * frame.h (decode_live_frame, decode_any_frame): Add prototypes.
5 * frame.c (decode_live_frame, decode_any_frame): New functions.
6 (delete_frame, Fredirect_frame_focus, Fframe_parameters)
7 (Fframe_parameter, Fframe_char_height, Fframe_char_width)
8 (Fframe_pixel_height, Fframe_pixel_width, Ftool_bar_pixel_width)
9 (Fframe_pointer_visible_p): Use decode_any_frame.
10 (Fmake_frame_visible, Fmake_frame_invisible, Ficonify_frame)
11 (Fraise_frame, Flower_frame, Fmodify_frame_parameters)
12 (Fset_frame_height, Fset_frame_width): Use decode_live_frame.
13 (Fframe_focus): Likewise. Allow zero number of arguments.
14 Adjust docstring.
15 (frame_buffer_list, frame_buffer_predicate): Remove.
16 * lisp.h (frame_buffer_predicate): Remove prototype.
17 * buffer.c (Fother_buffer): Use decode_any_frame.
18 * xdisp.c (Ftool_bar_lines_needed): Likewise.
19 * xfaces.c (Fcolor_gray_p, Fcolor_supported_p): Likewise.
20 * font.c (Ffont_face_attributes, Ffont_family_list, Fopen_font)
21 (Fclose_font, Ffont_info): Use decode_live_frame.
22 * fontset.c (check_fontset_name): Likewise.
23 * terminal.c (Fframe_terminal): Likewise.
24 * w32fns.c (check_x_frame): Likewise.
25 * window.c (Fminibuffer_window, Fwindow_at)
26 (Fcurrent_window_configuration): Likewise.
27 (Frun_window_configuration_change_hook, Fwindow_resize_apply):
28 Likewise. Allow zero number of arguments. Adjust docstring.
29 * dispnew.c (Fredraw_frame): Likewise.
30 * xfaces.c (frame_or_selected_frame): Remove.
31 (Fx_list_fonts, Finternal_get_lisp_face_attribute, Fface_font)
32 (Finternal_lisp_face_equal_p, Finternal_lisp_face_empty_p)
33 (Fframe_face_alist): Use decode_live_frame.
34 * xfns.c (check_x_frame): Likewise.
35
362012-11-06 Dmitry Antipov <dmantipov@yandex.ru>
37
3 * window.c (quad): New function. 38 * window.c (quad): New function.
4 (Fwindow_edges, Fwindow_pixel_edges, Fwindow_inside_edges) 39 (Fwindow_edges, Fwindow_pixel_edges, Fwindow_inside_edges)
5 (Fwindow_absolute_pixel_edges, Fwindow_inside_absolute_pixel_edges) 40 (Fwindow_absolute_pixel_edges, Fwindow_inside_absolute_pixel_edges)
diff --git a/src/buffer.c b/src/buffer.c
index 347f27edc3a..24286610570 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1543,17 +1543,11 @@ list first, followed by the list of all buffers. If no other buffer
1543exists, return the buffer `*scratch*' (creating it if necessary). */) 1543exists, return the buffer `*scratch*' (creating it if necessary). */)
1544 (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame) 1544 (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame)
1545{ 1545{
1546 Lisp_Object tail, buf, pred; 1546 struct frame *f = decode_any_frame (frame);
1547 Lisp_Object notsogood = Qnil; 1547 Lisp_Object tail = f->buffer_list, pred = f->buffer_predicate;
1548 Lisp_Object buf, notsogood = Qnil;
1548 1549
1549 if (NILP (frame))
1550 frame = selected_frame;
1551
1552 CHECK_FRAME (frame);
1553
1554 pred = frame_buffer_predicate (frame);
1555 /* Consider buffers that have been seen in the frame first. */ 1550 /* Consider buffers that have been seen in the frame first. */
1556 tail = XFRAME (frame)->buffer_list;
1557 for (; CONSP (tail); tail = XCDR (tail)) 1551 for (; CONSP (tail); tail = XCDR (tail))
1558 { 1552 {
1559 buf = XCAR (tail); 1553 buf = XCAR (tail);
diff --git a/src/dispnew.c b/src/dispnew.c
index 907259a3e94..4758f4ad76f 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3071,14 +3071,12 @@ window_to_frame_hpos (struct window *w, int hpos)
3071 Redrawing Frames 3071 Redrawing Frames
3072 **********************************************************************/ 3072 **********************************************************************/
3073 3073
3074DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0, 3074DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 0, 1, 0,
3075 doc: /* Clear frame FRAME and output again what is supposed to appear on it. */) 3075 doc: /* Clear frame FRAME and output again what is supposed to appear on it.
3076If FRAME is omitted or nil, the selected frame is used. */)
3076 (Lisp_Object frame) 3077 (Lisp_Object frame)
3077{ 3078{
3078 struct frame *f; 3079 struct frame *f = decode_live_frame (frame);
3079
3080 CHECK_LIVE_FRAME (frame);
3081 f = XFRAME (frame);
3082 3080
3083 /* Ignore redraw requests, if frame has no glyphs yet. 3081 /* Ignore redraw requests, if frame has no glyphs yet.
3084 (Implementation note: It still has to be checked why we are 3082 (Implementation note: It still has to be checked why we are
diff --git a/src/font.c b/src/font.c
index e960f9b3d13..41dbfd7a757 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3993,16 +3993,11 @@ The optional argument FRAME specifies the frame that the face attributes
3993are to be displayed on. If omitted, the selected frame is used. */) 3993are to be displayed on. If omitted, the selected frame is used. */)
3994 (Lisp_Object font, Lisp_Object frame) 3994 (Lisp_Object font, Lisp_Object frame)
3995{ 3995{
3996 struct frame *f; 3996 struct frame *f = decode_live_frame (frame);
3997 Lisp_Object plist[10]; 3997 Lisp_Object plist[10];
3998 Lisp_Object val; 3998 Lisp_Object val;
3999 int n = 0; 3999 int n = 0;
4000 4000
4001 if (NILP (frame))
4002 frame = selected_frame;
4003 CHECK_LIVE_FRAME (frame);
4004 f = XFRAME (frame);
4005
4006 if (STRINGP (font)) 4001 if (STRINGP (font))
4007 { 4002 {
4008 int fontset = fs_query_fontset (font, 0); 4003 int fontset = fs_query_fontset (font, 0);
@@ -4152,18 +4147,15 @@ how close they are to PREFER. */)
4152 4147
4153DEFUN ("font-family-list", Ffont_family_list, Sfont_family_list, 0, 1, 0, 4148DEFUN ("font-family-list", Ffont_family_list, Sfont_family_list, 0, 1, 0,
4154 doc: /* List available font families on the current frame. 4149 doc: /* List available font families on the current frame.
4155Optional argument FRAME, if non-nil, specifies the target frame. */) 4150If FRAME is omitted or nil, the selected frame is used. */)
4156 (Lisp_Object frame) 4151 (Lisp_Object frame)
4157{ 4152{
4158 FRAME_PTR f; 4153 struct frame *f = decode_live_frame (frame);
4159 struct font_driver_list *driver_list; 4154 struct font_driver_list *driver_list;
4160 Lisp_Object list; 4155 Lisp_Object list = Qnil;
4156
4157 XSETFRAME (frame, f);
4161 4158
4162 if (NILP (frame))
4163 frame = selected_frame;
4164 CHECK_LIVE_FRAME (frame);
4165 f = XFRAME (frame);
4166 list = Qnil;
4167 for (driver_list = f->font_driver_list; driver_list; 4159 for (driver_list = f->font_driver_list; driver_list;
4168 driver_list = driver_list->next) 4160 driver_list = driver_list->next)
4169 if (driver_list->driver->list_family) 4161 if (driver_list->driver->list_family)
@@ -4531,11 +4523,9 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
4531 (Lisp_Object font_entity, Lisp_Object size, Lisp_Object frame) 4523 (Lisp_Object font_entity, Lisp_Object size, Lisp_Object frame)
4532{ 4524{
4533 EMACS_INT isize; 4525 EMACS_INT isize;
4526 struct frame *f = decode_live_frame (frame);
4534 4527
4535 CHECK_FONT_ENTITY (font_entity); 4528 CHECK_FONT_ENTITY (font_entity);
4536 if (NILP (frame))
4537 frame = selected_frame;
4538 CHECK_LIVE_FRAME (frame);
4539 4529
4540 if (NILP (size)) 4530 if (NILP (size))
4541 isize = XINT (AREF (font_entity, FONT_SIZE_INDEX)); 4531 isize = XINT (AREF (font_entity, FONT_SIZE_INDEX));
@@ -4543,7 +4533,7 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
4543 { 4533 {
4544 CHECK_NUMBER_OR_FLOAT (size); 4534 CHECK_NUMBER_OR_FLOAT (size);
4545 if (FLOATP (size)) 4535 if (FLOATP (size))
4546 isize = POINT_TO_PIXEL (XFLOAT_DATA (size), XFRAME (frame)->resy); 4536 isize = POINT_TO_PIXEL (XFLOAT_DATA (size), f->resy);
4547 else 4537 else
4548 isize = XINT (size); 4538 isize = XINT (size);
4549 if (! (INT_MIN <= isize && isize <= INT_MAX)) 4539 if (! (INT_MIN <= isize && isize <= INT_MAX))
@@ -4551,7 +4541,7 @@ DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
4551 if (isize == 0) 4541 if (isize == 0)
4552 isize = 120; 4542 isize = 120;
4553 } 4543 }
4554 return font_open_entity (XFRAME (frame), font_entity, isize); 4544 return font_open_entity (f, font_entity, isize);
4555} 4545}
4556 4546
4557DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0, 4547DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0,
@@ -4559,10 +4549,7 @@ DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0,
4559 (Lisp_Object font_object, Lisp_Object frame) 4549 (Lisp_Object font_object, Lisp_Object frame)
4560{ 4550{
4561 CHECK_FONT_OBJECT (font_object); 4551 CHECK_FONT_OBJECT (font_object);
4562 if (NILP (frame)) 4552 font_close_object (decode_live_frame (frame), font_object);
4563 frame = selected_frame;
4564 CHECK_LIVE_FRAME (frame);
4565 font_close_object (XFRAME (frame), font_object);
4566 return Qnil; 4553 return Qnil;
4567} 4554}
4568 4555
@@ -4847,7 +4834,7 @@ where
4847If the named font is not yet loaded, return nil. */) 4834If the named font is not yet loaded, return nil. */)
4848 (Lisp_Object name, Lisp_Object frame) 4835 (Lisp_Object name, Lisp_Object frame)
4849{ 4836{
4850 FRAME_PTR f; 4837 struct frame *f;
4851 struct font *font; 4838 struct font *font;
4852 Lisp_Object info; 4839 Lisp_Object info;
4853 Lisp_Object font_object; 4840 Lisp_Object font_object;
@@ -4856,10 +4843,7 @@ If the named font is not yet loaded, return nil. */)
4856 4843
4857 if (! FONTP (name)) 4844 if (! FONTP (name))
4858 CHECK_STRING (name); 4845 CHECK_STRING (name);
4859 if (NILP (frame)) 4846 f = decode_live_frame (frame);
4860 frame = selected_frame;
4861 CHECK_LIVE_FRAME (frame);
4862 f = XFRAME (frame);
4863 4847
4864 if (STRINGP (name)) 4848 if (STRINGP (name))
4865 { 4849 {
diff --git a/src/fontset.c b/src/fontset.c
index da745b31ca1..b76a216bac2 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1326,17 +1326,14 @@ static Lisp_Object
1326check_fontset_name (Lisp_Object name, Lisp_Object *frame) 1326check_fontset_name (Lisp_Object name, Lisp_Object *frame)
1327{ 1327{
1328 int id; 1328 int id;
1329 struct frame *f = decode_live_frame (*frame);
1329 1330
1330 if (NILP (*frame)) 1331 XSETFRAME (*frame, f);
1331 *frame = selected_frame;
1332 CHECK_LIVE_FRAME (*frame);
1333 1332
1334 if (EQ (name, Qt)) 1333 if (EQ (name, Qt))
1335 return Vdefault_fontset; 1334 return Vdefault_fontset;
1336 if (NILP (name)) 1335 if (NILP (name))
1337 { 1336 id = FRAME_FONTSET (f);
1338 id = FRAME_FONTSET (XFRAME (*frame));
1339 }
1340 else 1337 else
1341 { 1338 {
1342 CHECK_STRING (name); 1339 CHECK_STRING (name);
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)
131 f->minibuffer_window = val; 131 f->minibuffer_window = val;
132} 132}
133 133
134 134struct frame *
135decode_live_frame (register Lisp_Object frame)
136{
137 if (NILP (frame))
138 frame = selected_frame;
139 CHECK_LIVE_FRAME (frame);
140 return XFRAME (frame);
141}
142
143struct frame *
144decode_any_frame (register Lisp_Object frame)
145{
146 if (NILP (frame))
147 frame = selected_frame;
148 CHECK_FRAME (frame);
149 return XFRAME (frame);
150}
151
135static void 152static void
136set_menu_bar_lines_1 (Lisp_Object window, int n) 153set_menu_bar_lines_1 (Lisp_Object window, int n)
137{ 154{
@@ -1118,23 +1135,12 @@ other_visible_frames (FRAME_PTR f)
1118Lisp_Object 1135Lisp_Object
1119delete_frame (Lisp_Object frame, Lisp_Object force) 1136delete_frame (Lisp_Object frame, Lisp_Object force)
1120{ 1137{
1121 struct frame *f; 1138 struct frame *f = decode_any_frame (frame);
1122 struct frame *sf = SELECTED_FRAME (); 1139 struct frame *sf = SELECTED_FRAME ();
1123 struct kboard *kb; 1140 struct kboard *kb;
1124 1141
1125 int minibuffer_selected, is_tooltip_frame; 1142 int minibuffer_selected, is_tooltip_frame;
1126 1143
1127 if (EQ (frame, Qnil))
1128 {
1129 f = sf;
1130 XSETFRAME (frame, f);
1131 }
1132 else
1133 {
1134 CHECK_FRAME (frame);
1135 f = XFRAME (frame);
1136 }
1137
1138 if (! FRAME_LIVE_P (f)) 1144 if (! FRAME_LIVE_P (f))
1139 return Qnil; 1145 return Qnil;
1140 1146
@@ -1146,9 +1152,11 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1146 if (NILP (XCDR (Vframe_list)) && !EQ (force, Qnoelisp)) 1152 if (NILP (XCDR (Vframe_list)) && !EQ (force, Qnoelisp))
1147 error ("Attempt to delete the only frame"); 1153 error ("Attempt to delete the only frame");
1148 1154
1155 XSETFRAME (frame, f);
1156
1149 /* Does this frame have a minibuffer, and is it the surrogate 1157 /* Does this frame have a minibuffer, and is it the surrogate
1150 minibuffer for any other frame? */ 1158 minibuffer for any other frame? */
1151 if (FRAME_HAS_MINIBUF_P (XFRAME (frame))) 1159 if (FRAME_HAS_MINIBUF_P (f))
1152 { 1160 {
1153 Lisp_Object frames; 1161 Lisp_Object frames;
1154 1162
@@ -1663,25 +1671,23 @@ DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
1663If omitted, FRAME defaults to the currently selected frame. */) 1671If omitted, FRAME defaults to the currently selected frame. */)
1664 (Lisp_Object frame) 1672 (Lisp_Object frame)
1665{ 1673{
1666 if (NILP (frame)) 1674 struct frame *f = decode_live_frame (frame);
1667 frame = selected_frame;
1668
1669 CHECK_LIVE_FRAME (frame);
1670 1675
1671 /* I think this should be done with a hook. */ 1676 /* I think this should be done with a hook. */
1672#ifdef HAVE_WINDOW_SYSTEM 1677#ifdef HAVE_WINDOW_SYSTEM
1673 if (FRAME_WINDOW_P (XFRAME (frame))) 1678 if (FRAME_WINDOW_P (f))
1674 { 1679 {
1675 FRAME_SAMPLE_VISIBILITY (XFRAME (frame)); 1680 FRAME_SAMPLE_VISIBILITY (f);
1676 x_make_frame_visible (XFRAME (frame)); 1681 x_make_frame_visible (f);
1677 } 1682 }
1678#endif 1683#endif
1679 1684
1680 make_frame_visible_1 (XFRAME (frame)->root_window); 1685 make_frame_visible_1 (f->root_window);
1681 1686
1682 /* Make menu bar update for the Buffers and Frames menus. */ 1687 /* Make menu bar update for the Buffers and Frames menus. */
1683 windows_or_buffers_changed++; 1688 windows_or_buffers_changed++;
1684 1689
1690 XSETFRAME (frame, f);
1685 return frame; 1691 return frame;
1686} 1692}
1687 1693
@@ -1722,16 +1728,13 @@ always considered visible, whether or not they are currently being
1722displayed in the terminal. */) 1728displayed in the terminal. */)
1723 (Lisp_Object frame, Lisp_Object force) 1729 (Lisp_Object frame, Lisp_Object force)
1724{ 1730{
1725 if (NILP (frame)) 1731 struct frame *f = decode_live_frame (frame);
1726 frame = selected_frame;
1727 1732
1728 CHECK_LIVE_FRAME (frame); 1733 if (NILP (force) && !other_visible_frames (f))
1729
1730 if (NILP (force) && !other_visible_frames (XFRAME (frame)))
1731 error ("Attempt to make invisible the sole visible or iconified frame"); 1734 error ("Attempt to make invisible the sole visible or iconified frame");
1732 1735
1733 /* Don't allow minibuf_window to remain on a deleted frame. */ 1736 /* Don't allow minibuf_window to remain on a deleted frame. */
1734 if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window)) 1737 if (EQ (f->minibuffer_window, minibuf_window))
1735 { 1738 {
1736 struct frame *sf = XFRAME (selected_frame); 1739 struct frame *sf = XFRAME (selected_frame);
1737 /* Use set_window_buffer instead of Fset_window_buffer (see 1740 /* Use set_window_buffer instead of Fset_window_buffer (see
@@ -1743,8 +1746,8 @@ displayed in the terminal. */)
1743 1746
1744 /* I think this should be done with a hook. */ 1747 /* I think this should be done with a hook. */
1745#ifdef HAVE_WINDOW_SYSTEM 1748#ifdef HAVE_WINDOW_SYSTEM
1746 if (FRAME_WINDOW_P (XFRAME (frame))) 1749 if (FRAME_WINDOW_P (f))
1747 x_make_frame_invisible (XFRAME (frame)); 1750 x_make_frame_invisible (f);
1748#endif 1751#endif
1749 1752
1750 /* Make menu bar update for the Buffers and Frames menus. */ 1753 /* Make menu bar update for the Buffers and Frames menus. */
@@ -1759,19 +1762,10 @@ DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame,
1759If omitted, FRAME defaults to the currently selected frame. */) 1762If omitted, FRAME defaults to the currently selected frame. */)
1760 (Lisp_Object frame) 1763 (Lisp_Object frame)
1761{ 1764{
1762 if (NILP (frame)) 1765 struct frame *f = decode_live_frame (frame);
1763 frame = selected_frame;
1764
1765 CHECK_LIVE_FRAME (frame);
1766
1767#if 0 /* This isn't logically necessary, and it can do GC. */
1768 /* Don't let the frame remain selected. */
1769 if (EQ (frame, selected_frame))
1770 Fhandle_switch_frame (next_frame (frame, Qt));
1771#endif
1772 1766
1773 /* Don't allow minibuf_window to remain on an iconified frame. */ 1767 /* Don't allow minibuf_window to remain on an iconified frame. */
1774 if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window)) 1768 if (EQ (f->minibuffer_window, minibuf_window))
1775 { 1769 {
1776 struct frame *sf = XFRAME (selected_frame); 1770 struct frame *sf = XFRAME (selected_frame);
1777 /* Use set_window_buffer instead of Fset_window_buffer (see 1771 /* Use set_window_buffer instead of Fset_window_buffer (see
@@ -1783,8 +1777,8 @@ If omitted, FRAME defaults to the currently selected frame. */)
1783 1777
1784 /* I think this should be done with a hook. */ 1778 /* I think this should be done with a hook. */
1785#ifdef HAVE_WINDOW_SYSTEM 1779#ifdef HAVE_WINDOW_SYSTEM
1786 if (FRAME_WINDOW_P (XFRAME (frame))) 1780 if (FRAME_WINDOW_P (f))
1787 x_iconify_frame (XFRAME (frame)); 1781 x_iconify_frame (f);
1788#endif 1782#endif
1789 1783
1790 /* Make menu bar update for the Buffers and Frames menus. */ 1784 /* 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
1848doesn't support multiple overlapping frames, this function selects FRAME. */) 1842doesn't support multiple overlapping frames, this function selects FRAME. */)
1849 (Lisp_Object frame) 1843 (Lisp_Object frame)
1850{ 1844{
1851 struct frame *f; 1845 struct frame *f = decode_live_frame (frame);
1852 if (NILP (frame))
1853 frame = selected_frame;
1854 1846
1855 CHECK_LIVE_FRAME (frame); 1847 XSETFRAME (frame, f);
1856
1857 f = XFRAME (frame);
1858 1848
1859 if (FRAME_TERMCAP_P (f)) 1849 if (FRAME_TERMCAP_P (f))
1860 /* On a text terminal select FRAME. */ 1850 /* On a text terminal select FRAME. */
@@ -1877,14 +1867,7 @@ If Emacs is displaying on an ordinary terminal or some other device which
1877doesn't support multiple overlapping frames, this function does nothing. */) 1867doesn't support multiple overlapping frames, this function does nothing. */)
1878 (Lisp_Object frame) 1868 (Lisp_Object frame)
1879{ 1869{
1880 struct frame *f; 1870 struct frame *f = decode_live_frame (frame);
1881
1882 if (NILP (frame))
1883 frame = selected_frame;
1884
1885 CHECK_LIVE_FRAME (frame);
1886
1887 f = XFRAME (frame);
1888 1871
1889 if (FRAME_TERMINAL (f)->frame_raise_lower_hook) 1872 if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
1890 (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0); 1873 (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0);
@@ -1920,18 +1903,14 @@ is affected by `select-frame', while the latter is not.
1920The redirection lasts until `redirect-frame-focus' is called to change it. */) 1903The redirection lasts until `redirect-frame-focus' is called to change it. */)
1921 (Lisp_Object frame, Lisp_Object focus_frame) 1904 (Lisp_Object frame, Lisp_Object focus_frame)
1922{ 1905{
1923 struct frame *f;
1924
1925 /* Note that we don't check for a live frame here. It's reasonable 1906 /* Note that we don't check for a live frame here. It's reasonable
1926 to redirect the focus of a frame you're about to delete, if you 1907 to redirect the focus of a frame you're about to delete, if you
1927 know what other frame should receive those keystrokes. */ 1908 know what other frame should receive those keystrokes. */
1928 CHECK_FRAME (frame); 1909 struct frame *f = decode_any_frame (frame);
1929 1910
1930 if (! NILP (focus_frame)) 1911 if (! NILP (focus_frame))
1931 CHECK_LIVE_FRAME (focus_frame); 1912 CHECK_LIVE_FRAME (focus_frame);
1932 1913
1933 f = XFRAME (frame);
1934
1935 fset_focus_frame (f, focus_frame); 1914 fset_focus_frame (f, focus_frame);
1936 1915
1937 if (FRAME_TERMINAL (f)->frame_rehighlight_hook) 1916 if (FRAME_TERMINAL (f)->frame_rehighlight_hook)
@@ -1941,15 +1920,14 @@ The redirection lasts until `redirect-frame-focus' is called to change it. */)
1941} 1920}
1942 1921
1943 1922
1944DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0, 1923DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 0, 1, 0,
1945 doc: /* Return the frame to which FRAME's keystrokes are currently being sent. 1924 doc: /* Return the frame to which FRAME's keystrokes are currently being sent.
1946This returns nil if FRAME's focus is not redirected. 1925If FRAME is omitted or nil, the selected frame is used.
1926Return nil if FRAME's focus is not redirected.
1947See `redirect-frame-focus'. */) 1927See `redirect-frame-focus'. */)
1948 (Lisp_Object frame) 1928 (Lisp_Object frame)
1949{ 1929{
1950 CHECK_LIVE_FRAME (frame); 1930 return FRAME_FOCUS_FRAME (decode_live_frame (frame));
1951
1952 return FRAME_FOCUS_FRAME (XFRAME (frame));
1953} 1931}
1954 1932
1955 1933
@@ -1972,22 +1950,6 @@ get_frame_param (register struct frame *frame, Lisp_Object prop)
1972} 1950}
1973#endif 1951#endif
1974 1952
1975/* Return the buffer-predicate of the selected frame. */
1976
1977Lisp_Object
1978frame_buffer_predicate (Lisp_Object frame)
1979{
1980 return XFRAME (frame)->buffer_predicate;
1981}
1982
1983/* Return the buffer-list of the selected frame. */
1984
1985static Lisp_Object
1986frame_buffer_list (Lisp_Object frame)
1987{
1988 return XFRAME (frame)->buffer_list;
1989}
1990
1991/* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */ 1953/* Discard BUFFER from the buffer-list and buried-buffer-list of each frame. */
1992 1954
1993void 1955void
@@ -2166,20 +2128,14 @@ DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0,
2166 doc: /* Return the parameters-alist of frame FRAME. 2128 doc: /* Return the parameters-alist of frame FRAME.
2167It is a list of elements of the form (PARM . VALUE), where PARM is a symbol. 2129It is a list of elements of the form (PARM . VALUE), where PARM is a symbol.
2168The meaningful PARMs depend on the kind of frame. 2130The meaningful PARMs depend on the kind of frame.
2169If FRAME is omitted, return information on the currently selected frame. */) 2131If FRAME is omitted or nil, return information on the currently selected frame. */)
2170 (Lisp_Object frame) 2132 (Lisp_Object frame)
2171{ 2133{
2172 Lisp_Object alist; 2134 Lisp_Object alist;
2173 FRAME_PTR f; 2135 struct frame *f = decode_any_frame (frame);
2174 int height, width; 2136 int height, width;
2175 struct gcpro gcpro1; 2137 struct gcpro gcpro1;
2176 2138
2177 if (NILP (frame))
2178 frame = selected_frame;
2179
2180 CHECK_FRAME (frame);
2181 f = XFRAME (frame);
2182
2183 if (!FRAME_LIVE_P (f)) 2139 if (!FRAME_LIVE_P (f))
2184 return Qnil; 2140 return Qnil;
2185 2141
@@ -2240,9 +2196,8 @@ If FRAME is omitted, return information on the currently selected frame. */)
2240 : FRAME_MINIBUF_ONLY_P (f) ? Qonly 2196 : FRAME_MINIBUF_ONLY_P (f) ? Qonly
2241 : FRAME_MINIBUF_WINDOW (f))); 2197 : FRAME_MINIBUF_WINDOW (f)));
2242 store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil)); 2198 store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil));
2243 store_in_alist (&alist, Qbuffer_list, frame_buffer_list (frame)); 2199 store_in_alist (&alist, Qbuffer_list, f->buffer_list);
2244 store_in_alist (&alist, Qburied_buffer_list, 2200 store_in_alist (&alist, Qburied_buffer_list, f->buried_buffer_list);
2245 XFRAME (frame)->buried_buffer_list);
2246 2201
2247 /* I think this should be done with a hook. */ 2202 /* I think this should be done with a hook. */
2248#ifdef HAVE_WINDOW_SYSTEM 2203#ifdef HAVE_WINDOW_SYSTEM
@@ -2267,17 +2222,12 @@ DEFUN ("frame-parameter", Fframe_parameter, Sframe_parameter, 2, 2, 0,
2267If FRAME is nil, describe the currently selected frame. */) 2222If FRAME is nil, describe the currently selected frame. */)
2268 (Lisp_Object frame, Lisp_Object parameter) 2223 (Lisp_Object frame, Lisp_Object parameter)
2269{ 2224{
2270 struct frame *f; 2225 struct frame *f = decode_any_frame (frame);
2271 Lisp_Object value; 2226 Lisp_Object value = Qnil;
2272 2227
2273 if (NILP (frame))
2274 frame = selected_frame;
2275 else
2276 CHECK_FRAME (frame);
2277 CHECK_SYMBOL (parameter); 2228 CHECK_SYMBOL (parameter);
2278 2229
2279 f = XFRAME (frame); 2230 XSETFRAME (frame, f);
2280 value = Qnil;
2281 2231
2282 if (FRAME_LIVE_P (f)) 2232 if (FRAME_LIVE_P (f))
2283 { 2233 {
@@ -2357,14 +2307,9 @@ Note that this functionality is obsolete as of Emacs 22.2, and its
2357use is not recommended. Explicitly check for a frame-parameter instead. */) 2307use is not recommended. Explicitly check for a frame-parameter instead. */)
2358 (Lisp_Object frame, Lisp_Object alist) 2308 (Lisp_Object frame, Lisp_Object alist)
2359{ 2309{
2360 FRAME_PTR f; 2310 struct frame *f = decode_live_frame (frame);
2361 register Lisp_Object tail, prop, val; 2311 register Lisp_Object tail, prop, val;
2362 2312
2363 if (EQ (frame, Qnil))
2364 frame = selected_frame;
2365 CHECK_LIVE_FRAME (frame);
2366 f = XFRAME (frame);
2367
2368 /* I think this should be done with a hook. */ 2313 /* I think this should be done with a hook. */
2369#ifdef HAVE_WINDOW_SYSTEM 2314#ifdef HAVE_WINDOW_SYSTEM
2370 if (FRAME_WINDOW_P (f)) 2315 if (FRAME_WINDOW_P (f))
@@ -2419,18 +2364,13 @@ use is not recommended. Explicitly check for a frame-parameter instead. */)
2419DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height, 2364DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
2420 0, 1, 0, 2365 0, 1, 0,
2421 doc: /* Height in pixels of a line in the font in frame FRAME. 2366 doc: /* Height in pixels of a line in the font in frame FRAME.
2422If FRAME is omitted, the selected frame is used. 2367If FRAME is omitted or nil, the selected frame is used.
2423For a terminal frame, the value is always 1. */) 2368For a terminal frame, the value is always 1. */)
2424 (Lisp_Object frame) 2369 (Lisp_Object frame)
2425{ 2370{
2426 struct frame *f;
2427
2428 if (NILP (frame))
2429 frame = selected_frame;
2430 CHECK_FRAME (frame);
2431 f = XFRAME (frame);
2432
2433#ifdef HAVE_WINDOW_SYSTEM 2371#ifdef HAVE_WINDOW_SYSTEM
2372 struct frame *f = decode_any_frame (frame);
2373
2434 if (FRAME_WINDOW_P (f)) 2374 if (FRAME_WINDOW_P (f))
2435 return make_number (x_char_height (f)); 2375 return make_number (x_char_height (f));
2436 else 2376 else
@@ -2442,19 +2382,14 @@ For a terminal frame, the value is always 1. */)
2442DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width, 2382DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
2443 0, 1, 0, 2383 0, 1, 0,
2444 doc: /* Width in pixels of characters in the font in frame FRAME. 2384 doc: /* Width in pixels of characters in the font in frame FRAME.
2445If FRAME is omitted, the selected frame is used. 2385If FRAME is omitted or nil, the selected frame is used.
2446On a graphical screen, the width is the standard width of the default font. 2386On a graphical screen, the width is the standard width of the default font.
2447For a terminal screen, the value is always 1. */) 2387For a terminal screen, the value is always 1. */)
2448 (Lisp_Object frame) 2388 (Lisp_Object frame)
2449{ 2389{
2450 struct frame *f;
2451
2452 if (NILP (frame))
2453 frame = selected_frame;
2454 CHECK_FRAME (frame);
2455 f = XFRAME (frame);
2456
2457#ifdef HAVE_WINDOW_SYSTEM 2390#ifdef HAVE_WINDOW_SYSTEM
2391 struct frame *f = decode_any_frame (frame);
2392
2458 if (FRAME_WINDOW_P (f)) 2393 if (FRAME_WINDOW_P (f))
2459 return make_number (x_char_width (f)); 2394 return make_number (x_char_width (f));
2460 else 2395 else
@@ -2465,7 +2400,7 @@ For a terminal screen, the value is always 1. */)
2465DEFUN ("frame-pixel-height", Fframe_pixel_height, 2400DEFUN ("frame-pixel-height", Fframe_pixel_height,
2466 Sframe_pixel_height, 0, 1, 0, 2401 Sframe_pixel_height, 0, 1, 0,
2467 doc: /* Return a FRAME's height in pixels. 2402 doc: /* Return a FRAME's height in pixels.
2468If FRAME is omitted, the selected frame is used. The exact value 2403If FRAME is omitted or nil, the selected frame is used. The exact value
2469of the result depends on the window-system and toolkit in use: 2404of the result depends on the window-system and toolkit in use:
2470 2405
2471In the Gtk+ version of Emacs, it includes only any window (including 2406In 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
2480to `frame-height'). */) 2415to `frame-height'). */)
2481 (Lisp_Object frame) 2416 (Lisp_Object frame)
2482{ 2417{
2483 struct frame *f; 2418 struct frame *f = decode_any_frame (frame);
2484
2485 if (NILP (frame))
2486 frame = selected_frame;
2487 CHECK_FRAME (frame);
2488 f = XFRAME (frame);
2489 2419
2490#ifdef HAVE_WINDOW_SYSTEM 2420#ifdef HAVE_WINDOW_SYSTEM
2491 if (FRAME_WINDOW_P (f)) 2421 if (FRAME_WINDOW_P (f))
@@ -2499,15 +2429,10 @@ DEFUN ("frame-pixel-width", Fframe_pixel_width,
2499 Sframe_pixel_width, 0, 1, 0, 2429 Sframe_pixel_width, 0, 1, 0,
2500 doc: /* Return FRAME's width in pixels. 2430 doc: /* Return FRAME's width in pixels.
2501For a terminal frame, the result really gives the width in characters. 2431For a terminal frame, the result really gives the width in characters.
2502If FRAME is omitted, the selected frame is used. */) 2432If FRAME is omitted or nil, the selected frame is used. */)
2503 (Lisp_Object frame) 2433 (Lisp_Object frame)
2504{ 2434{
2505 struct frame *f; 2435 struct frame *f = decode_any_frame (frame);
2506
2507 if (NILP (frame))
2508 frame = selected_frame;
2509 CHECK_FRAME (frame);
2510 f = XFRAME (frame);
2511 2436
2512#ifdef HAVE_WINDOW_SYSTEM 2437#ifdef HAVE_WINDOW_SYSTEM
2513 if (FRAME_WINDOW_P (f)) 2438 if (FRAME_WINDOW_P (f))
@@ -2521,17 +2446,15 @@ DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width,
2521 Stool_bar_pixel_width, 0, 1, 0, 2446 Stool_bar_pixel_width, 0, 1, 0,
2522 doc: /* Return width in pixels of FRAME's tool bar. 2447 doc: /* Return width in pixels of FRAME's tool bar.
2523The result is greater than zero only when the tool bar is on the left 2448The result is greater than zero only when the tool bar is on the left
2524or right side of FRAME. If FRAME is omitted, the selected frame is 2449or right side of FRAME. If FRAME is omitted or nil, the selected frame
2525used. */) 2450is used. */)
2526 (Lisp_Object frame) 2451 (Lisp_Object frame)
2527{ 2452{
2528 if (NILP (frame))
2529 frame = selected_frame;
2530 CHECK_FRAME (frame);
2531
2532#ifdef FRAME_TOOLBAR_WIDTH 2453#ifdef FRAME_TOOLBAR_WIDTH
2533 if (FRAME_WINDOW_P (XFRAME (frame))) 2454 struct frame *f = decode_any_frame (frame);
2534 return make_number (FRAME_TOOLBAR_WIDTH (XFRAME (frame))); 2455
2456 if (FRAME_WINDOW_P (f))
2457 return make_number (FRAME_TOOLBAR_WIDTH (f));
2535#endif 2458#endif
2536 return make_number (0); 2459 return make_number (0);
2537} 2460}
@@ -2542,13 +2465,9 @@ Optional third arg non-nil means that redisplay should use LINES lines
2542but that the idea of the actual height of the frame should not be changed. */) 2465but that the idea of the actual height of the frame should not be changed. */)
2543 (Lisp_Object frame, Lisp_Object lines, Lisp_Object pretend) 2466 (Lisp_Object frame, Lisp_Object lines, Lisp_Object pretend)
2544{ 2467{
2545 register struct frame *f; 2468 register struct frame *f = decode_live_frame (frame);
2546 2469
2547 CHECK_TYPE_RANGED_INTEGER (int, lines); 2470 CHECK_TYPE_RANGED_INTEGER (int, lines);
2548 if (NILP (frame))
2549 frame = selected_frame;
2550 CHECK_LIVE_FRAME (frame);
2551 f = XFRAME (frame);
2552 2471
2553 /* I think this should be done with a hook. */ 2472 /* I think this should be done with a hook. */
2554#ifdef HAVE_WINDOW_SYSTEM 2473#ifdef HAVE_WINDOW_SYSTEM
@@ -2570,12 +2489,9 @@ Optional third arg non-nil means that redisplay should use COLS columns
2570but that the idea of the actual width of the frame should not be changed. */) 2489but that the idea of the actual width of the frame should not be changed. */)
2571 (Lisp_Object frame, Lisp_Object cols, Lisp_Object pretend) 2490 (Lisp_Object frame, Lisp_Object cols, Lisp_Object pretend)
2572{ 2491{
2573 register struct frame *f; 2492 register struct frame *f = decode_live_frame (frame);
2493
2574 CHECK_TYPE_RANGED_INTEGER (int, cols); 2494 CHECK_TYPE_RANGED_INTEGER (int, cols);
2575 if (NILP (frame))
2576 frame = selected_frame;
2577 CHECK_LIVE_FRAME (frame);
2578 f = XFRAME (frame);
2579 2495
2580 /* I think this should be done with a hook. */ 2496 /* I think this should be done with a hook. */
2581#ifdef HAVE_WINDOW_SYSTEM 2497#ifdef HAVE_WINDOW_SYSTEM
@@ -4292,12 +4208,7 @@ Otherwise it returns nil. FRAME omitted or nil means the
4292selected frame. This is useful when `make-pointer-invisible' is set. */) 4208selected frame. This is useful when `make-pointer-invisible' is set. */)
4293 (Lisp_Object frame) 4209 (Lisp_Object frame)
4294{ 4210{
4295 if (NILP (frame)) 4211 return decode_any_frame (frame)->pointer_invisible ? Qnil : Qt;
4296 frame = selected_frame;
4297
4298 CHECK_FRAME (frame);
4299
4300 return (XFRAME (frame)->pointer_invisible ? Qnil : Qt);
4301} 4212}
4302 4213
4303 4214
diff --git a/src/frame.h b/src/frame.h
index eea618df797..1dc3ebbaf13 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -943,6 +943,8 @@ extern Lisp_Object Qnoelisp;
943extern struct frame *last_nonminibuf_frame; 943extern struct frame *last_nonminibuf_frame;
944 944
945extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object); 945extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
946extern struct frame *decode_live_frame (Lisp_Object);
947extern struct frame *decode_any_frame (Lisp_Object);
946extern struct frame *make_initial_frame (void); 948extern struct frame *make_initial_frame (void);
947extern struct frame *make_frame (int); 949extern struct frame *make_frame (int);
948#ifdef HAVE_WINDOW_SYSTEM 950#ifdef HAVE_WINDOW_SYSTEM
diff --git a/src/lisp.h b/src/lisp.h
index e9f47f4ed27..1a76a502ca0 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3298,7 +3298,6 @@ extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object);
3298#if HAVE_NS 3298#if HAVE_NS
3299extern Lisp_Object get_frame_param (struct frame *, Lisp_Object); 3299extern Lisp_Object get_frame_param (struct frame *, Lisp_Object);
3300#endif 3300#endif
3301extern Lisp_Object frame_buffer_predicate (Lisp_Object);
3302extern void frames_discard_buffer (Lisp_Object); 3301extern void frames_discard_buffer (Lisp_Object);
3303extern void syms_of_frame (void); 3302extern void syms_of_frame (void);
3304 3303
diff --git a/src/terminal.c b/src/terminal.c
index 2c0c60e7345..854ca61f19c 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -360,14 +360,7 @@ If FRAME is nil, the selected frame is used.
360The terminal device is represented by its integer identifier. */) 360The terminal device is represented by its integer identifier. */)
361 (Lisp_Object frame) 361 (Lisp_Object frame)
362{ 362{
363 struct terminal *t; 363 struct terminal *t = FRAME_TERMINAL (decode_live_frame (frame));
364
365 if (NILP (frame))
366 frame = selected_frame;
367
368 CHECK_LIVE_FRAME (frame);
369
370 t = FRAME_TERMINAL (XFRAME (frame));
371 364
372 if (!t) 365 if (!t)
373 return Qnil; 366 return Qnil;
diff --git a/src/w32fns.c b/src/w32fns.c
index 18e29ecaaf5..24760054523 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -264,12 +264,8 @@ have_menus_p (void)
264FRAME_PTR 264FRAME_PTR
265check_x_frame (Lisp_Object frame) 265check_x_frame (Lisp_Object frame)
266{ 266{
267 FRAME_PTR f; 267 struct frame *f = decode_live_frame (frame);
268 268
269 if (NILP (frame))
270 frame = selected_frame;
271 CHECK_LIVE_FRAME (frame);
272 f = XFRAME (frame);
273 if (! FRAME_W32_P (f)) 269 if (! FRAME_W32_P (f))
274 error ("Non-W32 frame used"); 270 error ("Non-W32 frame used");
275 return f; 271 return f;
diff --git a/src/window.c b/src/window.c
index 75a8d42d8d1..c32234b5fcd 100644
--- a/src/window.c
+++ b/src/window.c
@@ -340,10 +340,7 @@ DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0,
340If FRAME is omitted or nil, it defaults to the selected frame. */) 340If FRAME is omitted or nil, it defaults to the selected frame. */)
341 (Lisp_Object frame) 341 (Lisp_Object frame)
342{ 342{
343 if (NILP (frame)) 343 return FRAME_MINIBUF_WINDOW (decode_live_frame (frame));
344 frame = selected_frame;
345 CHECK_LIVE_FRAME (frame);
346 return FRAME_MINIBUF_WINDOW (XFRAME (frame));
347} 344}
348 345
349DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, 346DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p,
@@ -1371,12 +1368,7 @@ The top left corner of the frame is considered to be row 0,
1371column 0. */) 1368column 0. */)
1372 (Lisp_Object x, Lisp_Object y, Lisp_Object frame) 1369 (Lisp_Object x, Lisp_Object y, Lisp_Object frame)
1373{ 1370{
1374 struct frame *f; 1371 struct frame *f = decode_live_frame (frame);
1375
1376 if (NILP (frame))
1377 frame = selected_frame;
1378 CHECK_LIVE_FRAME (frame);
1379 f = XFRAME (frame);
1380 1372
1381 /* Check that arguments are integers or floats. */ 1373 /* Check that arguments are integers or floats. */
1382 CHECK_NUMBER_OR_FLOAT (x); 1374 CHECK_NUMBER_OR_FLOAT (x);
@@ -3109,12 +3101,12 @@ run_window_configuration_change_hook (struct frame *f)
3109} 3101}
3110 3102
3111DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook, 3103DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook,
3112 Srun_window_configuration_change_hook, 1, 1, 0, 3104 Srun_window_configuration_change_hook, 0, 1, 0,
3113 doc: /* Run `window-configuration-change-hook' for FRAME. */) 3105 doc: /* Run `window-configuration-change-hook' for FRAME.
3106If FRAME is omitted or nil, it defaults to the selected frame. */)
3114 (Lisp_Object frame) 3107 (Lisp_Object frame)
3115{ 3108{
3116 CHECK_LIVE_FRAME (frame); 3109 run_window_configuration_change_hook (decode_live_frame (frame));
3117 run_window_configuration_change_hook (XFRAME (frame));
3118 return Qnil; 3110 return Qnil;
3119} 3111}
3120 3112
@@ -3641,10 +3633,12 @@ window_resize_apply (struct window *w, int horflag)
3641} 3633}
3642 3634
3643 3635
3644DEFUN ("window-resize-apply", Fwindow_resize_apply, Swindow_resize_apply, 1, 2, 0, 3636DEFUN ("window-resize-apply", Fwindow_resize_apply, Swindow_resize_apply, 0, 2, 0,
3645 doc: /* Apply requested size values for window-tree of FRAME. 3637 doc: /* Apply requested size values for window-tree of FRAME.
3646Optional argument HORIZONTAL omitted or nil means apply requested height 3638If FRAME is omitted or nil, it defaults to the selected frame.
3647values. HORIZONTAL non-nil means apply requested width values. 3639
3640Optional argument HORIZONTAL omitted or nil means apply requested
3641height values. HORIZONTAL non-nil means apply requested width values.
3648 3642
3649This function checks whether the requested values sum up to a valid 3643This function checks whether the requested values sum up to a valid
3650window layout, recursively assigns the new sizes of all child windows 3644window layout, recursively assigns the new sizes of all child windows
@@ -3655,17 +3649,10 @@ Note: This function does not check any of `window-fixed-size-p',
3655be applied on the Elisp level. */) 3649be applied on the Elisp level. */)
3656 (Lisp_Object frame, Lisp_Object horizontal) 3650 (Lisp_Object frame, Lisp_Object horizontal)
3657{ 3651{
3658 struct frame *f; 3652 struct frame *f = decode_live_frame (frame);
3659 struct window *r; 3653 struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f));
3660 int horflag = !NILP (horizontal); 3654 int horflag = !NILP (horizontal);
3661 3655
3662 if (NILP (frame))
3663 frame = selected_frame;
3664 CHECK_LIVE_FRAME (frame);
3665
3666 f = XFRAME (frame);
3667 r = XWINDOW (FRAME_ROOT_WINDOW (f));
3668
3669 if (!window_resize_check (r, horflag) 3656 if (!window_resize_check (r, horflag)
3670 || ! EQ (r->new_total, 3657 || ! EQ (r->new_total,
3671 (horflag ? r->total_cols : r->total_lines))) 3658 (horflag ? r->total_cols : r->total_lines)))
@@ -6148,12 +6135,7 @@ saved by this function. */)
6148 register int n_windows; 6135 register int n_windows;
6149 register struct save_window_data *data; 6136 register struct save_window_data *data;
6150 register int i; 6137 register int i;
6151 FRAME_PTR f; 6138 struct frame *f = decode_live_frame (frame);
6152
6153 if (NILP (frame))
6154 frame = selected_frame;
6155 CHECK_LIVE_FRAME (frame);
6156 f = XFRAME (frame);
6157 6139
6158 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f))); 6140 n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
6159 data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols, 6141 data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols,
diff --git a/src/xdisp.c b/src/xdisp.c
index 1ff7819f34d..c01f5deab83 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -11916,19 +11916,14 @@ tool_bar_lines_needed (struct frame *f, int *n_rows)
11916 11916
11917DEFUN ("tool-bar-lines-needed", Ftool_bar_lines_needed, Stool_bar_lines_needed, 11917DEFUN ("tool-bar-lines-needed", Ftool_bar_lines_needed, Stool_bar_lines_needed,
11918 0, 1, 0, 11918 0, 1, 0,
11919 doc: /* Return the number of lines occupied by the tool bar of FRAME. */) 11919 doc: /* Return the number of lines occupied by the tool bar of FRAME.
11920If FRAME is nil or omitted, use the selected frame. */)
11920 (Lisp_Object frame) 11921 (Lisp_Object frame)
11921{ 11922{
11922 struct frame *f; 11923 struct frame *f = decode_any_frame (frame);
11923 struct window *w; 11924 struct window *w;
11924 int nlines = 0; 11925 int nlines = 0;
11925 11926
11926 if (NILP (frame))
11927 frame = selected_frame;
11928 else
11929 CHECK_FRAME (frame);
11930 f = XFRAME (frame);
11931
11932 if (WINDOWP (f->tool_bar_window) 11927 if (WINDOWP (f->tool_bar_window)
11933 && (w = XWINDOW (f->tool_bar_window), 11928 && (w = XWINDOW (f->tool_bar_window),
11934 WINDOW_TOTAL_LINES (w) > 0)) 11929 WINDOW_TOTAL_LINES (w) > 0))
diff --git a/src/xfaces.c b/src/xfaces.c
index 221387c4b6d..41c618612ac 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -669,23 +669,6 @@ x_free_gc (struct frame *f, GC gc)
669} 669}
670#endif /* HAVE_NS */ 670#endif /* HAVE_NS */
671 671
672/* If FRAME is nil, return a pointer to the selected frame.
673 Otherwise, check that FRAME is a live frame, and return a pointer
674 to it. NPARAM is the parameter number of FRAME, for
675 CHECK_LIVE_FRAME. This is here because it's a frequent pattern in
676 Lisp function definitions. */
677
678static struct frame *
679frame_or_selected_frame (Lisp_Object frame, int nparam)
680{
681 if (NILP (frame))
682 frame = selected_frame;
683
684 CHECK_LIVE_FRAME (frame);
685 return XFRAME (frame);
686}
687
688
689/*********************************************************************** 672/***********************************************************************
690 Frames and faces 673 Frames and faces
691 ***********************************************************************/ 674 ***********************************************************************/
@@ -1204,15 +1187,9 @@ FRAME specifies the frame and thus the display for interpreting COLOR.
1204If FRAME is nil or omitted, use the selected frame. */) 1187If FRAME is nil or omitted, use the selected frame. */)
1205 (Lisp_Object color, Lisp_Object frame) 1188 (Lisp_Object color, Lisp_Object frame)
1206{ 1189{
1207 struct frame *f;
1208
1209 CHECK_STRING (color); 1190 CHECK_STRING (color);
1210 if (NILP (frame)) 1191 return (face_color_gray_p (decode_any_frame (frame), SSDATA (color))
1211 frame = selected_frame; 1192 ? Qt : Qnil);
1212 else
1213 CHECK_FRAME (frame);
1214 f = XFRAME (frame);
1215 return face_color_gray_p (f, SSDATA (color)) ? Qt : Qnil;
1216} 1193}
1217 1194
1218 1195
@@ -1225,17 +1202,10 @@ If FRAME is nil or omitted, use the selected frame.
1225COLOR must be a valid color name. */) 1202COLOR must be a valid color name. */)
1226 (Lisp_Object color, Lisp_Object frame, Lisp_Object background_p) 1203 (Lisp_Object color, Lisp_Object frame, Lisp_Object background_p)
1227{ 1204{
1228 struct frame *f;
1229
1230 CHECK_STRING (color); 1205 CHECK_STRING (color);
1231 if (NILP (frame)) 1206 return (face_color_supported_p (decode_any_frame (frame),
1232 frame = selected_frame; 1207 SSDATA (color), !NILP (background_p))
1233 else 1208 ? Qt : Qnil);
1234 CHECK_FRAME (frame);
1235 f = XFRAME (frame);
1236 if (face_color_supported_p (f, SSDATA (color), !NILP (background_p)))
1237 return Qt;
1238 return Qnil;
1239} 1209}
1240 1210
1241 1211
@@ -1683,9 +1653,7 @@ the WIDTH times as wide as FACE on FRAME. */)
1683 1653
1684 /* We can't simply call check_x_frame because this function may be 1654 /* We can't simply call check_x_frame because this function may be
1685 called before any frame is created. */ 1655 called before any frame is created. */
1686 if (NILP (frame)) 1656 f = decode_live_frame (frame);
1687 frame = selected_frame;
1688 f = frame_or_selected_frame (frame, 2);
1689 if (! FRAME_WINDOW_P (f)) 1657 if (! FRAME_WINDOW_P (f))
1690 { 1658 {
1691 /* Perhaps we have not yet created any frame. */ 1659 /* Perhaps we have not yet created any frame. */
@@ -1693,6 +1661,8 @@ the WIDTH times as wide as FACE on FRAME. */)
1693 frame = Qnil; 1661 frame = Qnil;
1694 face = Qnil; 1662 face = Qnil;
1695 } 1663 }
1664 else
1665 XSETFRAME (frame, f);
1696 1666
1697 /* Determine the width standard for comparison with the fonts we find. */ 1667 /* Determine the width standard for comparison with the fonts we find. */
1698 1668
@@ -3679,21 +3649,12 @@ frame. If FRAME is t, report on the defaults for face SYMBOL (for new
3679frames). If FRAME is omitted or nil, use the selected frame. */) 3649frames). If FRAME is omitted or nil, use the selected frame. */)
3680 (Lisp_Object symbol, Lisp_Object keyword, Lisp_Object frame) 3650 (Lisp_Object symbol, Lisp_Object keyword, Lisp_Object frame)
3681{ 3651{
3682 Lisp_Object lface, value = Qnil; 3652 struct frame *f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
3653 Lisp_Object lface = lface_from_face_name (f, symbol, 1), value = Qnil;
3683 3654
3684 CHECK_SYMBOL (symbol); 3655 CHECK_SYMBOL (symbol);
3685 CHECK_SYMBOL (keyword); 3656 CHECK_SYMBOL (keyword);
3686 3657
3687 if (EQ (frame, Qt))
3688 lface = lface_from_face_name (NULL, symbol, 1);
3689 else
3690 {
3691 if (NILP (frame))
3692 frame = selected_frame;
3693 CHECK_LIVE_FRAME (frame);
3694 lface = lface_from_face_name (XFRAME (frame), symbol, 1);
3695 }
3696
3697 if (EQ (keyword, QCfamily)) 3658 if (EQ (keyword, QCfamily))
3698 value = LFACE_FAMILY (lface); 3659 value = LFACE_FAMILY (lface);
3699 else if (EQ (keyword, QCfoundry)) 3660 else if (EQ (keyword, QCfoundry))
@@ -3876,7 +3837,7 @@ return the font name used for CHARACTER. */)
3876 } 3837 }
3877 else 3838 else
3878 { 3839 {
3879 struct frame *f = frame_or_selected_frame (frame, 1); 3840 struct frame *f = decode_live_frame (frame);
3880 int face_id = lookup_named_face (f, face, 1); 3841 int face_id = lookup_named_face (f, face, 1);
3881 struct face *fface = FACE_FROM_ID (f, face_id); 3842 struct face *fface = FACE_FROM_ID (f, face_id);
3882 3843
@@ -3963,14 +3924,11 @@ If FRAME is omitted or nil, use the selected frame. */)
3963 struct frame *f; 3924 struct frame *f;
3964 Lisp_Object lface1, lface2; 3925 Lisp_Object lface1, lface2;
3965 3926
3966 if (EQ (frame, Qt)) 3927 /* Don't use check_x_frame here because this function is called
3967 f = NULL; 3928 before X frames exist. At that time, if FRAME is nil,
3968 else 3929 selected_frame will be used which is the frame dumped with
3969 /* Don't use check_x_frame here because this function is called 3930 Emacs. That frame is not an X frame. */
3970 before X frames exist. At that time, if FRAME is nil, 3931 f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
3971 selected_frame will be used which is the frame dumped with
3972 Emacs. That frame is not an X frame. */
3973 f = frame_or_selected_frame (frame, 2);
3974 3932
3975 lface1 = lface_from_face_name (f, face1, 1); 3933 lface1 = lface_from_face_name (f, face1, 1);
3976 lface2 = lface_from_face_name (f, face2, 1); 3934 lface2 = lface_from_face_name (f, face2, 1);
@@ -3988,20 +3946,10 @@ If FRAME is t, report on the defaults for face FACE (for new frames).
3988If FRAME is omitted or nil, use the selected frame. */) 3946If FRAME is omitted or nil, use the selected frame. */)
3989 (Lisp_Object face, Lisp_Object frame) 3947 (Lisp_Object face, Lisp_Object frame)
3990{ 3948{
3991 struct frame *f; 3949 struct frame *f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
3992 Lisp_Object lface; 3950 Lisp_Object lface = lface_from_face_name (f, face, 1);
3993 int i; 3951 int i;
3994 3952
3995 if (NILP (frame))
3996 frame = selected_frame;
3997 CHECK_LIVE_FRAME (frame);
3998 f = XFRAME (frame);
3999
4000 if (EQ (frame, Qt))
4001 lface = lface_from_face_name (NULL, face, 1);
4002 else
4003 lface = lface_from_face_name (f, face, 1);
4004
4005 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) 3953 for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
4006 if (!UNSPECIFIEDP (AREF (lface, i))) 3954 if (!UNSPECIFIEDP (AREF (lface, i)))
4007 break; 3955 break;
@@ -4016,8 +3964,7 @@ DEFUN ("frame-face-alist", Fframe_face_alist, Sframe_face_alist,
4016For internal use only. */) 3964For internal use only. */)
4017 (Lisp_Object frame) 3965 (Lisp_Object frame)
4018{ 3966{
4019 struct frame *f = frame_or_selected_frame (frame, 0); 3967 return decode_live_frame (frame)->face_alist;
4020 return f->face_alist;
4021} 3968}
4022 3969
4023 3970
@@ -4205,14 +4152,9 @@ or lists of the form (RED GREEN BLUE).
4205If FRAME is unspecified or nil, the current frame is used. */) 4152If FRAME is unspecified or nil, the current frame is used. */)
4206 (Lisp_Object color1, Lisp_Object color2, Lisp_Object frame) 4153 (Lisp_Object color1, Lisp_Object color2, Lisp_Object frame)
4207{ 4154{
4208 struct frame *f; 4155 struct frame *f = decode_live_frame (frame);
4209 XColor cdef1, cdef2; 4156 XColor cdef1, cdef2;
4210 4157
4211 if (NILP (frame))
4212 frame = selected_frame;
4213 CHECK_LIVE_FRAME (frame);
4214 f = XFRAME (frame);
4215
4216 if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1)) 4158 if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1))
4217 && !(STRINGP (color1) && defined_color (f, SSDATA (color1), &cdef1, 0))) 4159 && !(STRINGP (color1) && defined_color (f, SSDATA (color1), &cdef1, 0)))
4218 signal_error ("Invalid color", color1); 4160 signal_error ("Invalid color", color1);
diff --git a/src/xfns.c b/src/xfns.c
index aca227385bf..9c99902b93d 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -164,12 +164,8 @@ have_menus_p (void)
164FRAME_PTR 164FRAME_PTR
165check_x_frame (Lisp_Object frame) 165check_x_frame (Lisp_Object frame)
166{ 166{
167 FRAME_PTR f; 167 struct frame *f = decode_live_frame (frame);
168 168
169 if (NILP (frame))
170 frame = selected_frame;
171 CHECK_LIVE_FRAME (frame);
172 f = XFRAME (frame);
173 if (! FRAME_X_P (f)) 169 if (! FRAME_X_P (f))
174 error ("Non-X frame used"); 170 error ("Non-X frame used");
175 return f; 171 return f;