aboutsummaryrefslogtreecommitdiffstats
path: root/src/frame.c
diff options
context:
space:
mode:
authorDmitry Antipov2012-11-12 08:00:55 +0400
committerDmitry Antipov2012-11-12 08:00:55 +0400
commit5b04e9f9ac3212f0eb88c853dd21dd63a8bdbee2 (patch)
treed9449b2bda744e962e336625f60c5c004e5c721e /src/frame.c
parent31f47fbaead299941c22a133ed7e2928c7b1273e (diff)
downloademacs-5b04e9f9ac3212f0eb88c853dd21dd63a8bdbee2.tar.gz
emacs-5b04e9f9ac3212f0eb88c853dd21dd63a8bdbee2.zip
Simplify by using FOR_EACH_FRAME here and there.
* frame.c (next_frame, prev_frame, other_visible_frames) (delete_frame, visible-frame-list): Use FOR_EACH_FRAME. * w32term.c (x_window_to_scroll_bar): Likewise. * window.c (window_list): Likewise. * xdisp.c (x_consider_frame_title): Likewise. * xfaces.c ( Fdisplay_supports_face_attributes_p): Likewise. * xfns.c (x_window_to_frame, x_any_window_to_frame) (x_menubar_window_to_frame, x_top_window_to_frame): Likewise. * xmenu.c (menubar_id_to_frame): Likewise. * xselect.c (frame_for_x_selection): Likewise. * xterm.c (x_frame_of_widget, x_window_to_scroll_bar) (x_window_to_menu_bar): Likewise. * w32fns.c (x_window_to_frame): Likewise. Adjust comment.
Diffstat (limited to 'src/frame.c')
-rw-r--r--src/frame.c108
1 files changed, 27 insertions, 81 deletions
diff --git a/src/frame.c b/src/frame.c
index 52be8be270e..d580bf7f148 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -906,7 +906,7 @@ DEFUN ("frame-list", Fframe_list, Sframe_list,
906static Lisp_Object 906static Lisp_Object
907next_frame (Lisp_Object frame, Lisp_Object minibuf) 907next_frame (Lisp_Object frame, Lisp_Object minibuf)
908{ 908{
909 Lisp_Object tail; 909 Lisp_Object f, tail;
910 int passed = 0; 910 int passed = 0;
911 911
912 /* There must always be at least one frame in Vframe_list. */ 912 /* There must always be at least one frame in Vframe_list. */
@@ -918,12 +918,8 @@ next_frame (Lisp_Object frame, Lisp_Object minibuf)
918 CHECK_LIVE_FRAME (frame); 918 CHECK_LIVE_FRAME (frame);
919 919
920 while (1) 920 while (1)
921 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) 921 FOR_EACH_FRAME (tail, f)
922 { 922 {
923 Lisp_Object f;
924
925 f = XCAR (tail);
926
927 if (passed 923 if (passed
928 && ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame)) 924 && ((!FRAME_TERMCAP_P (XFRAME (f)) && !FRAME_TERMCAP_P (XFRAME (frame))
929 && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) 925 && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame)))
@@ -984,22 +980,13 @@ next_frame (Lisp_Object frame, Lisp_Object minibuf)
984static Lisp_Object 980static Lisp_Object
985prev_frame (Lisp_Object frame, Lisp_Object minibuf) 981prev_frame (Lisp_Object frame, Lisp_Object minibuf)
986{ 982{
987 Lisp_Object tail; 983 Lisp_Object f, tail, prev = Qnil;
988 Lisp_Object prev;
989 984
990 /* There must always be at least one frame in Vframe_list. */ 985 /* There must always be at least one frame in Vframe_list. */
991 if (! CONSP (Vframe_list)) 986 eassert (CONSP (Vframe_list));
992 emacs_abort ();
993 987
994 prev = Qnil; 988 FOR_EACH_FRAME (tail, f)
995 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
996 { 989 {
997 Lisp_Object f;
998
999 f = XCAR (tail);
1000 if (!FRAMEP (f))
1001 emacs_abort ();
1002
1003 if (EQ (frame, f) && !NILP (prev)) 990 if (EQ (frame, f) && !NILP (prev))
1004 return prev; 991 return prev;
1005 992
@@ -1100,11 +1087,10 @@ Otherwise, include all frames. */)
1100static int 1087static int
1101other_visible_frames (FRAME_PTR f) 1088other_visible_frames (FRAME_PTR f)
1102{ 1089{
1103 Lisp_Object frames; 1090 Lisp_Object frames, this;
1104 1091
1105 for (frames = Vframe_list; CONSP (frames); frames = XCDR (frames)) 1092 FOR_EACH_FRAME (frames, this)
1106 { 1093 {
1107 Lisp_Object this = XCAR (frames);
1108 if (f == XFRAME (this)) 1094 if (f == XFRAME (this))
1109 continue; 1095 continue;
1110 1096
@@ -1158,15 +1144,10 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1158 minibuffer for any other frame? */ 1144 minibuffer for any other frame? */
1159 if (FRAME_HAS_MINIBUF_P (f)) 1145 if (FRAME_HAS_MINIBUF_P (f))
1160 { 1146 {
1161 Lisp_Object frames; 1147 Lisp_Object frames, this;
1162 1148
1163 for (frames = Vframe_list; 1149 FOR_EACH_FRAME (frames, this)
1164 CONSP (frames);
1165 frames = XCDR (frames))
1166 { 1150 {
1167 Lisp_Object this;
1168 this = XCAR (frames);
1169
1170 if (! EQ (this, frame) 1151 if (! EQ (this, frame)
1171 && EQ (frame, 1152 && EQ (frame,
1172 WINDOW_FRAME (XWINDOW 1153 WINDOW_FRAME (XWINDOW
@@ -1359,15 +1340,13 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1359 another one. */ 1340 another one. */
1360 if (f == last_nonminibuf_frame) 1341 if (f == last_nonminibuf_frame)
1361 { 1342 {
1362 Lisp_Object frames; 1343 Lisp_Object frames, this;
1363 1344
1364 last_nonminibuf_frame = 0; 1345 last_nonminibuf_frame = 0;
1365 1346
1366 for (frames = Vframe_list; 1347 FOR_EACH_FRAME (frames, this)
1367 CONSP (frames);
1368 frames = XCDR (frames))
1369 { 1348 {
1370 f = XFRAME (XCAR (frames)); 1349 f = XFRAME (this);
1371 if (!FRAME_MINIBUF_ONLY_P (f)) 1350 if (!FRAME_MINIBUF_ONLY_P (f))
1372 { 1351 {
1373 last_nonminibuf_frame = f; 1352 last_nonminibuf_frame = f;
@@ -1380,27 +1359,13 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1380 single-kboard state if we're in it for this kboard. */ 1359 single-kboard state if we're in it for this kboard. */
1381 if (kb != NULL) 1360 if (kb != NULL)
1382 { 1361 {
1383 Lisp_Object frames; 1362 Lisp_Object frames, this;
1384 /* Some frame we found on the same kboard, or nil if there are none. */ 1363 /* Some frame we found on the same kboard, or nil if there are none. */
1385 Lisp_Object frame_on_same_kboard; 1364 Lisp_Object frame_on_same_kboard = Qnil;
1386
1387 frame_on_same_kboard = Qnil;
1388
1389 for (frames = Vframe_list;
1390 CONSP (frames);
1391 frames = XCDR (frames))
1392 {
1393 Lisp_Object this;
1394 struct frame *f1;
1395
1396 this = XCAR (frames);
1397 if (!FRAMEP (this))
1398 emacs_abort ();
1399 f1 = XFRAME (this);
1400 1365
1401 if (kb == FRAME_KBOARD (f1)) 1366 FOR_EACH_FRAME (frames, this)
1402 frame_on_same_kboard = this; 1367 if (kb == FRAME_KBOARD (XFRAME (this)))
1403 } 1368 frame_on_same_kboard = this;
1404 1369
1405 if (NILP (frame_on_same_kboard)) 1370 if (NILP (frame_on_same_kboard))
1406 not_single_kboard_state (kb); 1371 not_single_kboard_state (kb);
@@ -1412,27 +1377,16 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1412 frames with other windows. */ 1377 frames with other windows. */
1413 if (kb != NULL && EQ (frame, KVAR (kb, Vdefault_minibuffer_frame))) 1378 if (kb != NULL && EQ (frame, KVAR (kb, Vdefault_minibuffer_frame)))
1414 { 1379 {
1415 Lisp_Object frames; 1380 Lisp_Object frames, this;
1416 1381
1417 /* The last frame we saw with a minibuffer, minibuffer-only or not. */ 1382 /* The last frame we saw with a minibuffer, minibuffer-only or not. */
1418 Lisp_Object frame_with_minibuf; 1383 Lisp_Object frame_with_minibuf = Qnil;
1419 /* Some frame we found on the same kboard, or nil if there are none. */ 1384 /* Some frame we found on the same kboard, or nil if there are none. */
1420 Lisp_Object frame_on_same_kboard; 1385 Lisp_Object frame_on_same_kboard = Qnil;
1421 1386
1422 frame_on_same_kboard = Qnil; 1387 FOR_EACH_FRAME (frames, this)
1423 frame_with_minibuf = Qnil;
1424
1425 for (frames = Vframe_list;
1426 CONSP (frames);
1427 frames = XCDR (frames))
1428 { 1388 {
1429 Lisp_Object this; 1389 struct frame *f1 = XFRAME (this);
1430 struct frame *f1;
1431
1432 this = XCAR (frames);
1433 if (!FRAMEP (this))
1434 emacs_abort ();
1435 f1 = XFRAME (this);
1436 1390
1437 /* Consider only frames on the same kboard 1391 /* Consider only frames on the same kboard
1438 and only those with minibuffers. */ 1392 and only those with minibuffers. */
@@ -1816,20 +1770,12 @@ DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
1816 doc: /* Return a list of all frames now \"visible\" (being updated). */) 1770 doc: /* Return a list of all frames now \"visible\" (being updated). */)
1817 (void) 1771 (void)
1818{ 1772{
1819 Lisp_Object tail, frame; 1773 Lisp_Object tail, frame, value = Qnil;
1820 struct frame *f; 1774
1821 Lisp_Object value; 1775 FOR_EACH_FRAME (tail, frame)
1776 if (FRAME_VISIBLE_P (XFRAME (frame)))
1777 value = Fcons (frame, value);
1822 1778
1823 value = Qnil;
1824 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
1825 {
1826 frame = XCAR (tail);
1827 if (!FRAMEP (frame))
1828 continue;
1829 f = XFRAME (frame);
1830 if (FRAME_VISIBLE_P (f))
1831 value = Fcons (frame, value);
1832 }
1833 return value; 1779 return value;
1834} 1780}
1835 1781