diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 17 | ||||
| -rw-r--r-- | src/frame.c | 108 | ||||
| -rw-r--r-- | src/w32fns.c | 7 | ||||
| -rw-r--r-- | src/w32term.c | 11 | ||||
| -rw-r--r-- | src/window.c | 6 | ||||
| -rw-r--r-- | src/xdisp.c | 6 | ||||
| -rw-r--r-- | src/xfaces.c | 15 | ||||
| -rw-r--r-- | src/xfns.c | 38 | ||||
| -rw-r--r-- | src/xmenu.c | 5 | ||||
| -rw-r--r-- | src/xselect.c | 21 | ||||
| -rw-r--r-- | src/xterm.c | 51 |
11 files changed, 106 insertions, 179 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 3c0e5e4e2b5..e35e307c4ee 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,20 @@ | |||
| 1 | 2012-11-12 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Simplify by using FOR_EACH_FRAME here and there. | ||
| 4 | * frame.c (next_frame, prev_frame, other_visible_frames) | ||
| 5 | (delete_frame, visible-frame-list): Use FOR_EACH_FRAME. | ||
| 6 | * w32term.c (x_window_to_scroll_bar): Likewise. | ||
| 7 | * window.c (window_list): Likewise. | ||
| 8 | * xdisp.c (x_consider_frame_title): Likewise. | ||
| 9 | * xfaces.c ( Fdisplay_supports_face_attributes_p): Likewise. | ||
| 10 | * xfns.c (x_window_to_frame, x_any_window_to_frame) | ||
| 11 | (x_menubar_window_to_frame, x_top_window_to_frame): Likewise. | ||
| 12 | * xmenu.c (menubar_id_to_frame): Likewise. | ||
| 13 | * xselect.c (frame_for_x_selection): Likewise. | ||
| 14 | * xterm.c (x_frame_of_widget, x_window_to_scroll_bar) | ||
| 15 | (x_window_to_menu_bar): Likewise. | ||
| 16 | * w32fns.c (x_window_to_frame): Likewise. Adjust comment. | ||
| 17 | |||
| 1 | 2012-11-12 Paul Eggert <eggert@cs.ucla.edu> | 18 | 2012-11-12 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 19 | ||
| 3 | * data.c (Qdefalias_fset_function): Now static. | 20 | * data.c (Qdefalias_fset_function): Now static. |
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, | |||
| 906 | static Lisp_Object | 906 | static Lisp_Object |
| 907 | next_frame (Lisp_Object frame, Lisp_Object minibuf) | 907 | next_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) | |||
| 984 | static Lisp_Object | 980 | static Lisp_Object |
| 985 | prev_frame (Lisp_Object frame, Lisp_Object minibuf) | 981 | prev_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. */) | |||
| 1100 | static int | 1087 | static int |
| 1101 | other_visible_frames (FRAME_PTR f) | 1088 | other_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 | ||
diff --git a/src/w32fns.c b/src/w32fns.c index bb2abfe0807..ed5625e802c 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -304,19 +304,14 @@ check_x_display_info (Lisp_Object frame) | |||
| 304 | /* Return the Emacs frame-object corresponding to an w32 window. | 304 | /* Return the Emacs frame-object corresponding to an w32 window. |
| 305 | It could be the frame's main window or an icon window. */ | 305 | It could be the frame's main window or an icon window. */ |
| 306 | 306 | ||
| 307 | /* This function can be called during GC, so use GC_xxx type test macros. */ | ||
| 308 | |||
| 309 | struct frame * | 307 | struct frame * |
| 310 | x_window_to_frame (struct w32_display_info *dpyinfo, HWND wdesc) | 308 | x_window_to_frame (struct w32_display_info *dpyinfo, HWND wdesc) |
| 311 | { | 309 | { |
| 312 | Lisp_Object tail, frame; | 310 | Lisp_Object tail, frame; |
| 313 | struct frame *f; | 311 | struct frame *f; |
| 314 | 312 | ||
| 315 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 313 | FOR_EACH_FRAME (tail, frame) |
| 316 | { | 314 | { |
| 317 | frame = XCAR (tail); | ||
| 318 | if (!FRAMEP (frame)) | ||
| 319 | continue; | ||
| 320 | f = XFRAME (frame); | 315 | f = XFRAME (frame); |
| 321 | if (!FRAME_W32_P (f) || FRAME_W32_DISPLAY_INFO (f) != dpyinfo) | 316 | if (!FRAME_W32_P (f) || FRAME_W32_DISPLAY_INFO (f) != dpyinfo) |
| 322 | continue; | 317 | continue; |
diff --git a/src/w32term.c b/src/w32term.c index b14a46bc01a..032912c27f4 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -3437,16 +3437,11 @@ w32_handle_tool_bar_click (struct frame *f, struct input_event *button_event) | |||
| 3437 | static struct scroll_bar * | 3437 | static struct scroll_bar * |
| 3438 | x_window_to_scroll_bar (Window window_id) | 3438 | x_window_to_scroll_bar (Window window_id) |
| 3439 | { | 3439 | { |
| 3440 | Lisp_Object tail; | 3440 | Lisp_Object tail, frame; |
| 3441 | 3441 | ||
| 3442 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 3442 | FOR_EACH_FRAME (tail, frame) |
| 3443 | { | 3443 | { |
| 3444 | Lisp_Object frame, bar, condemned; | 3444 | Lisp_Object bar, condemned; |
| 3445 | |||
| 3446 | frame = XCAR (tail); | ||
| 3447 | /* All elements of Vframe_list should be frames. */ | ||
| 3448 | if (! FRAMEP (frame)) | ||
| 3449 | emacs_abort (); | ||
| 3450 | 3445 | ||
| 3451 | /* Scan this frame's scroll bar list for a scroll bar with the | 3446 | /* Scan this frame's scroll bar list for a scroll bar with the |
| 3452 | right window ID. */ | 3447 | right window ID. */ |
diff --git a/src/window.c b/src/window.c index 09ee20e4b86..9f3474fcd53 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -2133,10 +2133,10 @@ window_list (void) | |||
| 2133 | { | 2133 | { |
| 2134 | if (!CONSP (Vwindow_list)) | 2134 | if (!CONSP (Vwindow_list)) |
| 2135 | { | 2135 | { |
| 2136 | Lisp_Object tail; | 2136 | Lisp_Object tail, frame; |
| 2137 | 2137 | ||
| 2138 | Vwindow_list = Qnil; | 2138 | Vwindow_list = Qnil; |
| 2139 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 2139 | FOR_EACH_FRAME (tail, frame) |
| 2140 | { | 2140 | { |
| 2141 | Lisp_Object args[2]; | 2141 | Lisp_Object args[2]; |
| 2142 | 2142 | ||
| @@ -2144,7 +2144,7 @@ window_list (void) | |||
| 2144 | new windows at the front of args[1], which means we | 2144 | new windows at the front of args[1], which means we |
| 2145 | have to reverse this list at the end. */ | 2145 | have to reverse this list at the end. */ |
| 2146 | args[1] = Qnil; | 2146 | args[1] = Qnil; |
| 2147 | foreach_window (XFRAME (XCAR (tail)), add_window_to_list, &args[1]); | 2147 | foreach_window (XFRAME (frame), add_window_to_list, &args[1]); |
| 2148 | args[0] = Vwindow_list; | 2148 | args[0] = Vwindow_list; |
| 2149 | args[1] = Fnreverse (args[1]); | 2149 | args[1] = Fnreverse (args[1]); |
| 2150 | Vwindow_list = Fnconc (2, args); | 2150 | Vwindow_list = Fnconc (2, args); |
diff --git a/src/xdisp.c b/src/xdisp.c index 968c23c0944..5bda3347fe8 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -11096,17 +11096,15 @@ x_consider_frame_title (Lisp_Object frame) | |||
| 11096 | || f->explicit_name) | 11096 | || f->explicit_name) |
| 11097 | { | 11097 | { |
| 11098 | /* Do we have more than one visible frame on this X display? */ | 11098 | /* Do we have more than one visible frame on this X display? */ |
| 11099 | Lisp_Object tail; | 11099 | Lisp_Object tail, other_frame, fmt; |
| 11100 | Lisp_Object fmt; | ||
| 11101 | ptrdiff_t title_start; | 11100 | ptrdiff_t title_start; |
| 11102 | char *title; | 11101 | char *title; |
| 11103 | ptrdiff_t len; | 11102 | ptrdiff_t len; |
| 11104 | struct it it; | 11103 | struct it it; |
| 11105 | ptrdiff_t count = SPECPDL_INDEX (); | 11104 | ptrdiff_t count = SPECPDL_INDEX (); |
| 11106 | 11105 | ||
| 11107 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 11106 | FOR_EACH_FRAME (tail, other_frame) |
| 11108 | { | 11107 | { |
| 11109 | Lisp_Object other_frame = XCAR (tail); | ||
| 11110 | struct frame *tf = XFRAME (other_frame); | 11108 | struct frame *tf = XFRAME (other_frame); |
| 11111 | 11109 | ||
| 11112 | if (tf != f | 11110 | if (tf != f |
diff --git a/src/xfaces.c b/src/xfaces.c index eb19622435d..daf329791c1 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -5012,17 +5012,14 @@ face for italic. */) | |||
| 5012 | else | 5012 | else |
| 5013 | { | 5013 | { |
| 5014 | /* Find any frame on DISPLAY. */ | 5014 | /* Find any frame on DISPLAY. */ |
| 5015 | Lisp_Object fl_tail; | 5015 | Lisp_Object tail; |
| 5016 | 5016 | ||
| 5017 | frame = Qnil; | 5017 | frame = Qnil; |
| 5018 | for (fl_tail = Vframe_list; CONSP (fl_tail); fl_tail = XCDR (fl_tail)) | 5018 | FOR_EACH_FRAME (tail, frame) |
| 5019 | { | 5019 | if (!NILP (Fequal (Fcdr (Fassq (Qdisplay, |
| 5020 | frame = XCAR (fl_tail); | 5020 | XFRAME (frame)->param_alist)), |
| 5021 | if (!NILP (Fequal (Fcdr (Fassq (Qdisplay, | 5021 | display))) |
| 5022 | XFRAME (frame)->param_alist)), | 5022 | break; |
| 5023 | display))) | ||
| 5024 | break; | ||
| 5025 | } | ||
| 5026 | } | 5023 | } |
| 5027 | 5024 | ||
| 5028 | CHECK_LIVE_FRAME (frame); | 5025 | CHECK_LIVE_FRAME (frame); |
diff --git a/src/xfns.c b/src/xfns.c index 82e218479c8..1f98e9fc8c7 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -224,13 +224,11 @@ x_window_to_frame (struct x_display_info *dpyinfo, int wdesc) | |||
| 224 | Lisp_Object tail, frame; | 224 | Lisp_Object tail, frame; |
| 225 | struct frame *f; | 225 | struct frame *f; |
| 226 | 226 | ||
| 227 | if (wdesc == None) return 0; | 227 | if (wdesc == None) |
| 228 | return NULL; | ||
| 228 | 229 | ||
| 229 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 230 | FOR_EACH_FRAME (tail, frame) |
| 230 | { | 231 | { |
| 231 | frame = XCAR (tail); | ||
| 232 | if (!FRAMEP (frame)) | ||
| 233 | continue; | ||
| 234 | f = XFRAME (frame); | 232 | f = XFRAME (frame); |
| 235 | if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) | 233 | if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) |
| 236 | continue; | 234 | continue; |
| @@ -270,18 +268,16 @@ struct frame * | |||
| 270 | x_any_window_to_frame (struct x_display_info *dpyinfo, int wdesc) | 268 | x_any_window_to_frame (struct x_display_info *dpyinfo, int wdesc) |
| 271 | { | 269 | { |
| 272 | Lisp_Object tail, frame; | 270 | Lisp_Object tail, frame; |
| 273 | struct frame *f, *found; | 271 | struct frame *f, *found = NULL; |
| 274 | struct x_output *x; | 272 | struct x_output *x; |
| 275 | 273 | ||
| 276 | if (wdesc == None) return NULL; | 274 | if (wdesc == None) |
| 275 | return NULL; | ||
| 277 | 276 | ||
| 278 | found = NULL; | 277 | FOR_EACH_FRAME (tail, frame) |
| 279 | for (tail = Vframe_list; CONSP (tail) && !found; tail = XCDR (tail)) | ||
| 280 | { | 278 | { |
| 281 | frame = XCAR (tail); | 279 | if (found) |
| 282 | if (!FRAMEP (frame)) | 280 | break; |
| 283 | continue; | ||
| 284 | |||
| 285 | f = XFRAME (frame); | 281 | f = XFRAME (frame); |
| 286 | if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo) | 282 | if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo) |
| 287 | { | 283 | { |
| @@ -325,13 +321,11 @@ x_menubar_window_to_frame (struct x_display_info *dpyinfo, XEvent *event) | |||
| 325 | struct frame *f; | 321 | struct frame *f; |
| 326 | struct x_output *x; | 322 | struct x_output *x; |
| 327 | 323 | ||
| 328 | if (wdesc == None) return 0; | 324 | if (wdesc == None) |
| 325 | return NULL; | ||
| 329 | 326 | ||
| 330 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 327 | FOR_EACH_FRAME (tail, frame) |
| 331 | { | 328 | { |
| 332 | frame = XCAR (tail); | ||
| 333 | if (!FRAMEP (frame)) | ||
| 334 | continue; | ||
| 335 | f = XFRAME (frame); | 329 | f = XFRAME (frame); |
| 336 | if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) | 330 | if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) |
| 337 | continue; | 331 | continue; |
| @@ -359,13 +353,11 @@ x_top_window_to_frame (struct x_display_info *dpyinfo, int wdesc) | |||
| 359 | struct frame *f; | 353 | struct frame *f; |
| 360 | struct x_output *x; | 354 | struct x_output *x; |
| 361 | 355 | ||
| 362 | if (wdesc == None) return 0; | 356 | if (wdesc == None) |
| 357 | return NULL; | ||
| 363 | 358 | ||
| 364 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 359 | FOR_EACH_FRAME (tail, frame) |
| 365 | { | 360 | { |
| 366 | frame = XCAR (tail); | ||
| 367 | if (!FRAMEP (frame)) | ||
| 368 | continue; | ||
| 369 | f = XFRAME (frame); | 361 | f = XFRAME (frame); |
| 370 | if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) | 362 | if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) |
| 371 | continue; | 363 | continue; |
diff --git a/src/xmenu.c b/src/xmenu.c index 01d932cf8d8..b585df2125b 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -132,11 +132,8 @@ menubar_id_to_frame (LWLIB_ID id) | |||
| 132 | Lisp_Object tail, frame; | 132 | Lisp_Object tail, frame; |
| 133 | FRAME_PTR f; | 133 | FRAME_PTR f; |
| 134 | 134 | ||
| 135 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 135 | FOR_EACH_FRAME (tail, frame) |
| 136 | { | 136 | { |
| 137 | frame = XCAR (tail); | ||
| 138 | if (!FRAMEP (frame)) | ||
| 139 | continue; | ||
| 140 | f = XFRAME (frame); | 137 | f = XFRAME (frame); |
| 141 | if (!FRAME_WINDOW_P (f)) | 138 | if (!FRAME_WINDOW_P (f)) |
| 142 | continue; | 139 | continue; |
diff --git a/src/xselect.c b/src/xselect.c index de9386bd7d9..64c64fa0c76 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -1940,7 +1940,7 @@ x_handle_selection_notify (XSelectionEvent *event) | |||
| 1940 | static struct frame * | 1940 | static struct frame * |
| 1941 | frame_for_x_selection (Lisp_Object object) | 1941 | frame_for_x_selection (Lisp_Object object) |
| 1942 | { | 1942 | { |
| 1943 | Lisp_Object tail; | 1943 | Lisp_Object tail, frame; |
| 1944 | struct frame *f; | 1944 | struct frame *f; |
| 1945 | 1945 | ||
| 1946 | if (NILP (object)) | 1946 | if (NILP (object)) |
| @@ -1949,9 +1949,9 @@ frame_for_x_selection (Lisp_Object object) | |||
| 1949 | if (FRAME_X_P (f) && FRAME_LIVE_P (f)) | 1949 | if (FRAME_X_P (f) && FRAME_LIVE_P (f)) |
| 1950 | return f; | 1950 | return f; |
| 1951 | 1951 | ||
| 1952 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 1952 | FOR_EACH_FRAME (tail, frame) |
| 1953 | { | 1953 | { |
| 1954 | f = XFRAME (XCAR (tail)); | 1954 | f = XFRAME (frame); |
| 1955 | if (FRAME_X_P (f) && FRAME_LIVE_P (f)) | 1955 | if (FRAME_X_P (f) && FRAME_LIVE_P (f)) |
| 1956 | return f; | 1956 | return f; |
| 1957 | } | 1957 | } |
| @@ -1959,15 +1959,14 @@ frame_for_x_selection (Lisp_Object object) | |||
| 1959 | else if (TERMINALP (object)) | 1959 | else if (TERMINALP (object)) |
| 1960 | { | 1960 | { |
| 1961 | struct terminal *t = get_terminal (object, 1); | 1961 | struct terminal *t = get_terminal (object, 1); |
| 1962 | |||
| 1962 | if (t->type == output_x_window) | 1963 | if (t->type == output_x_window) |
| 1963 | { | 1964 | FOR_EACH_FRAME (tail, frame) |
| 1964 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 1965 | { |
| 1965 | { | 1966 | f = XFRAME (frame); |
| 1966 | f = XFRAME (XCAR (tail)); | 1967 | if (FRAME_LIVE_P (f) && f->terminal == t) |
| 1967 | if (FRAME_LIVE_P (f) && f->terminal == t) | 1968 | return f; |
| 1968 | return f; | 1969 | } |
| 1969 | } | ||
| 1970 | } | ||
| 1971 | } | 1970 | } |
| 1972 | else if (FRAMEP (object)) | 1971 | else if (FRAMEP (object)) |
| 1973 | { | 1972 | { |
diff --git a/src/xterm.c b/src/xterm.c index f89fbabaecc..463d82b4ee2 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -1438,7 +1438,7 @@ static struct frame * | |||
| 1438 | x_frame_of_widget (Widget widget) | 1438 | x_frame_of_widget (Widget widget) |
| 1439 | { | 1439 | { |
| 1440 | struct x_display_info *dpyinfo; | 1440 | struct x_display_info *dpyinfo; |
| 1441 | Lisp_Object tail; | 1441 | Lisp_Object tail, frame; |
| 1442 | struct frame *f; | 1442 | struct frame *f; |
| 1443 | 1443 | ||
| 1444 | dpyinfo = x_display_info_for_display (XtDisplay (widget)); | 1444 | dpyinfo = x_display_info_for_display (XtDisplay (widget)); |
| @@ -1452,15 +1452,15 @@ x_frame_of_widget (Widget widget) | |||
| 1452 | 1452 | ||
| 1453 | /* Look for a frame with that top-level widget. Allocate the color | 1453 | /* Look for a frame with that top-level widget. Allocate the color |
| 1454 | on that frame to get the right gamma correction value. */ | 1454 | on that frame to get the right gamma correction value. */ |
| 1455 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 1455 | FOR_EACH_FRAME (tail, frame) |
| 1456 | if (FRAMEP (XCAR (tail)) | 1456 | { |
| 1457 | && (f = XFRAME (XCAR (tail)), | 1457 | f = XFRAME (frame); |
| 1458 | (FRAME_X_P (f) | 1458 | if (FRAME_X_P (f) |
| 1459 | && f->output_data.nothing != 1 | 1459 | && f->output_data.nothing != 1 |
| 1460 | && FRAME_X_DISPLAY_INFO (f) == dpyinfo)) | 1460 | && FRAME_X_DISPLAY_INFO (f) == dpyinfo |
| 1461 | && f->output_data.x->widget == widget) | 1461 | && f->output_data.x->widget == widget) |
| 1462 | return f; | 1462 | return f; |
| 1463 | 1463 | } | |
| 1464 | emacs_abort (); | 1464 | emacs_abort (); |
| 1465 | } | 1465 | } |
| 1466 | 1466 | ||
| @@ -4098,20 +4098,15 @@ XTmouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window, | |||
| 4098 | static struct scroll_bar * | 4098 | static struct scroll_bar * |
| 4099 | x_window_to_scroll_bar (Display *display, Window window_id) | 4099 | x_window_to_scroll_bar (Display *display, Window window_id) |
| 4100 | { | 4100 | { |
| 4101 | Lisp_Object tail; | 4101 | Lisp_Object tail, frame; |
| 4102 | 4102 | ||
| 4103 | #if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS) | 4103 | #if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS) |
| 4104 | window_id = (Window) xg_get_scroll_id_for_window (display, window_id); | 4104 | window_id = (Window) xg_get_scroll_id_for_window (display, window_id); |
| 4105 | #endif /* USE_GTK && USE_TOOLKIT_SCROLL_BARS */ | 4105 | #endif /* USE_GTK && USE_TOOLKIT_SCROLL_BARS */ |
| 4106 | 4106 | ||
| 4107 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 4107 | FOR_EACH_FRAME (tail, frame) |
| 4108 | { | 4108 | { |
| 4109 | Lisp_Object frame, bar, condemned; | 4109 | Lisp_Object bar, condemned; |
| 4110 | |||
| 4111 | frame = XCAR (tail); | ||
| 4112 | /* All elements of Vframe_list should be frames. */ | ||
| 4113 | if (! FRAMEP (frame)) | ||
| 4114 | emacs_abort (); | ||
| 4115 | 4110 | ||
| 4116 | if (! FRAME_X_P (XFRAME (frame))) | 4111 | if (! FRAME_X_P (XFRAME (frame))) |
| 4117 | continue; | 4112 | continue; |
| @@ -4143,20 +4138,16 @@ x_window_to_scroll_bar (Display *display, Window window_id) | |||
| 4143 | static Widget | 4138 | static Widget |
| 4144 | x_window_to_menu_bar (Window window) | 4139 | x_window_to_menu_bar (Window window) |
| 4145 | { | 4140 | { |
| 4146 | Lisp_Object tail; | 4141 | Lisp_Object tail, frame; |
| 4147 | 4142 | ||
| 4148 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) | 4143 | FOR_EACH_FRAME (tail, frame) |
| 4149 | { | 4144 | if (FRAME_X_P (XFRAME (frame))) |
| 4150 | if (FRAME_X_P (XFRAME (XCAR (tail)))) | 4145 | { |
| 4151 | { | 4146 | Widget menu_bar = XFRAME (frame)->output_data.x->menubar_widget; |
| 4152 | Lisp_Object frame = XCAR (tail); | ||
| 4153 | Widget menu_bar = XFRAME (frame)->output_data.x->menubar_widget; | ||
| 4154 | |||
| 4155 | if (menu_bar && xlwmenu_window_p (menu_bar, window)) | ||
| 4156 | return menu_bar; | ||
| 4157 | } | ||
| 4158 | } | ||
| 4159 | 4147 | ||
| 4148 | if (menu_bar && xlwmenu_window_p (menu_bar, window)) | ||
| 4149 | return menu_bar; | ||
| 4150 | } | ||
| 4160 | return NULL; | 4151 | return NULL; |
| 4161 | } | 4152 | } |
| 4162 | 4153 | ||