Mercurial > hg > xemacs-beta
comparison src/frame.c @ 367:a4f53d9b3154 r21-1-13
Import from CVS: tag r21-1-13
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:01:07 +0200 |
parents | 7c94d56991e1 |
children | cc15677e0335 |
comparison
equal
deleted
inserted
replaced
366:83d76f480a59 | 367:a4f53d9b3154 |
---|---|
1004 | 1004 |
1005 return 1; | 1005 return 1; |
1006 } | 1006 } |
1007 | 1007 |
1008 int | 1008 int |
1009 device_matches_console_spec (Lisp_Object frame, Lisp_Object device, | 1009 device_matches_console_spec (Lisp_Object device, Lisp_Object console) |
1010 Lisp_Object console) | |
1011 { | 1010 { |
1012 if (EQ (console, Qwindow_system)) | 1011 if (EQ (console, Qwindow_system)) |
1013 return DEVICE_WIN_P (XDEVICE (device)); | 1012 return DEVICE_WIN_P (XDEVICE (device)); |
1014 if (NILP (console)) | |
1015 console = (DEVICE_CONSOLE (XDEVICE (FRAME_DEVICE (XFRAME (frame))))); | |
1016 if (DEVICEP (console)) | 1013 if (DEVICEP (console)) |
1017 return EQ (device, console); | 1014 return EQ (device, console); |
1018 if (CONSOLEP (console)) | 1015 if (CONSOLEP (console)) |
1019 return EQ (DEVICE_CONSOLE (XDEVICE (device)), console); | 1016 return EQ (DEVICE_CONSOLE (XDEVICE (device)), console); |
1020 if (valid_console_type_p (console)) | 1017 if (valid_console_type_p (console)) |
1024 | 1021 |
1025 /* Return the next frame in the frame list after FRAME. | 1022 /* Return the next frame in the frame list after FRAME. |
1026 FRAMETYPE and CONSOLE control which frames and devices | 1023 FRAMETYPE and CONSOLE control which frames and devices |
1027 are considered; see `next-frame'. */ | 1024 are considered; see `next-frame'. */ |
1028 | 1025 |
1029 static Lisp_Object | 1026 Lisp_Object |
1030 next_frame_internal (Lisp_Object frame, Lisp_Object frametype, | 1027 next_frame (Lisp_Object frame, Lisp_Object frametype, Lisp_Object console) |
1031 Lisp_Object console, int called_from_delete_device) | 1028 { |
1032 { | 1029 Lisp_Object first = Qnil; |
1030 Lisp_Object devcons, concons; | |
1033 int passed = 0; | 1031 int passed = 0; |
1034 int started_over = 0; | 1032 |
1035 | |
1036 /* If this frame is dead, it won't be in frame_list, and we'll loop | |
1037 forever. Forestall that. */ | |
1038 CHECK_LIVE_FRAME (frame); | 1033 CHECK_LIVE_FRAME (frame); |
1039 | |
1040 while (1) | |
1041 { | |
1042 Lisp_Object devcons, concons; | |
1043 | 1034 |
1044 DEVICE_LOOP_NO_BREAK (devcons, concons) | 1035 DEVICE_LOOP_NO_BREAK (devcons, concons) |
1045 { | 1036 { |
1046 Lisp_Object device = XCAR (devcons); | 1037 Lisp_Object device = XCAR (devcons); |
1047 Lisp_Object frmcons; | 1038 Lisp_Object frmcons; |
1048 | 1039 |
1049 if (!device_matches_console_spec (frame, device, console)) | 1040 if (!device_matches_console_spec (device, console)) |
1041 { | |
1042 if (EQ (device, FRAME_DEVICE (XFRAME (frame)))) | |
1043 passed = 1; | |
1050 continue; | 1044 continue; |
1045 } | |
1051 | 1046 |
1052 DEVICE_FRAME_LOOP (frmcons, XDEVICE (device)) | 1047 DEVICE_FRAME_LOOP (frmcons, XDEVICE (device)) |
1053 { | 1048 { |
1054 Lisp_Object f = XCAR (frmcons); | 1049 Lisp_Object f = XCAR (frmcons); |
1050 | |
1055 if (passed) | 1051 if (passed) |
1056 { | 1052 { |
1057 /* #### Doing this here is bad and is now | |
1058 unnecessary. The real bug was that f->iconified | |
1059 was never, ever updated unless a user explicitly | |
1060 called frame-iconified-p. That has now been | |
1061 fixed. With this change removed all of the other | |
1062 changes made to support this routine having the | |
1063 called_from_delete_device arg could be removed. | |
1064 But it is too close to release to do that now. */ | |
1065 #if 0 | |
1066 /* Make sure the visibility and iconified flags are | |
1067 up-to-date unless we're being deleted. */ | |
1068 if (!called_from_delete_device) | |
1069 { | |
1070 Fframe_iconified_p (f); | |
1071 Fframe_visible_p (f); | |
1072 } | |
1073 #endif | |
1074 | |
1075 /* Decide whether this frame is eligible to be returned. */ | |
1076 | |
1077 /* If we've looped all the way around without finding any | |
1078 eligible frames, return the original frame. */ | |
1079 if (EQ (f, frame)) | |
1080 return f; | |
1081 | |
1082 if (frame_matches_frametype (f, frametype)) | 1053 if (frame_matches_frametype (f, frametype)) |
1083 return f; | 1054 return f; |
1084 } | 1055 } |
1085 | 1056 else |
1057 { | |
1086 if (EQ (frame, f)) | 1058 if (EQ (frame, f)) |
1087 passed++; | 1059 { |
1060 passed = 1; | |
1088 } | 1061 } |
1062 else | |
1063 { | |
1064 if (NILP (first) && frame_matches_frametype (f, frametype)) | |
1065 first = f; | |
1066 } | |
1089 } | 1067 } |
1090 /* We hit the end of the list, and need to start over again. */ | 1068 } |
1091 if (started_over) | 1069 } |
1092 return Qnil; | 1070 |
1093 started_over++; | 1071 if (NILP (first)) |
1094 } | 1072 /* We went through the whole frame list without finding a single |
1095 } | 1073 acceptable frame. Return the original frame. */ |
1096 | 1074 return frame; |
1097 Lisp_Object | 1075 else |
1098 next_frame (Lisp_Object frame, Lisp_Object frametype, Lisp_Object console) | 1076 /* There were no acceptable frames in the list after FRAME; otherwise, |
1099 { | 1077 we would have returned directly from the loop. Since FIRST is the last |
1100 return next_frame_internal (frame, frametype, console, 0); | 1078 acceptable frame in the list, return it. */ |
1079 return first; | |
1101 } | 1080 } |
1102 | 1081 |
1103 /* Return the previous frame in the frame list before FRAME. | 1082 /* Return the previous frame in the frame list before FRAME. |
1104 FRAMETYPE and CONSOLE control which frames and devices | 1083 FRAMETYPE and CONSOLE control which frames and devices |
1105 are considered; see `next-frame'. */ | 1084 are considered; see `next-frame'. */ |
1106 | 1085 |
1107 Lisp_Object | 1086 Lisp_Object |
1108 prev_frame (Lisp_Object frame, Lisp_Object frametype, Lisp_Object console) | 1087 previous_frame (Lisp_Object frame, Lisp_Object frametype, Lisp_Object console) |
1109 { | 1088 { |
1110 Lisp_Object devcons, concons; | 1089 Lisp_Object devcons, concons; |
1111 Lisp_Object prev; | 1090 Lisp_Object last = Qnil; |
1112 | 1091 |
1113 /* If this frame is dead, it won't be in frame_list, and we'll loop | |
1114 forever. Forestall that. */ | |
1115 CHECK_LIVE_FRAME (frame); | 1092 CHECK_LIVE_FRAME (frame); |
1116 | 1093 |
1117 prev = Qnil; | |
1118 DEVICE_LOOP_NO_BREAK (devcons, concons) | 1094 DEVICE_LOOP_NO_BREAK (devcons, concons) |
1119 { | 1095 { |
1120 Lisp_Object device = XCAR (devcons); | 1096 Lisp_Object device = XCAR (devcons); |
1121 Lisp_Object frmcons; | 1097 Lisp_Object frmcons; |
1122 | 1098 |
1123 if (!device_matches_console_spec (frame, device, console)) | 1099 if (!device_matches_console_spec (device, console)) |
1100 { | |
1101 if (EQ (device, FRAME_DEVICE (XFRAME (frame))) | |
1102 && !NILP (last)) | |
1103 return last; | |
1124 continue; | 1104 continue; |
1105 } | |
1125 | 1106 |
1126 DEVICE_FRAME_LOOP (frmcons, XDEVICE (device)) | 1107 DEVICE_FRAME_LOOP (frmcons, XDEVICE (device)) |
1127 { | 1108 { |
1128 Lisp_Object f = XCAR (frmcons); | 1109 Lisp_Object f = XCAR (frmcons); |
1129 | 1110 |
1130 if (EQ (frame, f) && !NILP (prev)) | 1111 if (EQ (frame, f)) |
1131 return prev; | 1112 { |
1132 | 1113 if (!NILP (last)) |
1133 /* Decide whether this frame is eligible to be returned, | 1114 return last; |
1134 according to frametype. */ | 1115 } |
1135 | 1116 else |
1117 { | |
1136 if (frame_matches_frametype (f, frametype)) | 1118 if (frame_matches_frametype (f, frametype)) |
1137 prev = f; | 1119 last = f; |
1138 | |
1139 } | 1120 } |
1140 } | 1121 } |
1141 | 1122 } |
1142 /* We've scanned the entire list. */ | 1123 |
1143 if (NILP (prev)) | 1124 if (NILP (last)) |
1144 /* We went through the whole frame list without finding a single | 1125 /* We went through the whole frame list without finding a single |
1145 acceptable frame. Return the original frame. */ | 1126 acceptable frame. Return the original frame. */ |
1146 return frame; | 1127 return frame; |
1147 else | 1128 else |
1148 /* There were no acceptable frames in the list before FRAME; otherwise, | 1129 /* There were no acceptable frames in the list before FRAME; otherwise, |
1149 we would have returned directly from the loop. Since PREV is the last | 1130 we would have returned directly from the loop. Since LAST is the last |
1150 acceptable frame in the list, return it. */ | 1131 acceptable frame in the list, return it. */ |
1151 return prev; | 1132 return last; |
1152 } | 1133 } |
1153 | 1134 |
1154 DEFUN ("next-frame", Fnext_frame, 0, 3, 0, /* | 1135 DEFUN ("next-frame", Fnext_frame, 0, 3, 0, /* |
1155 Return the next frame of the right type in the frame list after FRAME. | 1136 Return the next frame of the right type in the frame list after FRAME. |
1156 FRAMETYPE controls which frames are eligible to be returned; all | 1137 FRAMETYPE controls which frames are eligible to be returned; all |
1211 */ | 1192 */ |
1212 (frame, frametype, console)) | 1193 (frame, frametype, console)) |
1213 { | 1194 { |
1214 XSETFRAME (frame, decode_frame (frame)); | 1195 XSETFRAME (frame, decode_frame (frame)); |
1215 | 1196 |
1216 return prev_frame (frame, frametype, console); | 1197 return previous_frame (frame, frametype, console); |
1217 } | 1198 } |
1218 | 1199 |
1219 /* Return any frame for which PREDICATE is non-zero, or return Qnil | 1200 /* Return any frame for which PREDICATE is non-zero, or return Qnil |
1220 if there aren't any. */ | 1201 if there aren't any. */ |
1221 | 1202 |
1243 /* Return 1 if it is ok to delete frame F; | 1224 /* Return 1 if it is ok to delete frame F; |
1244 0 if all frames aside from F are invisible. | 1225 0 if all frames aside from F are invisible. |
1245 (Exception: if F is a stream frame, it's OK to delete if | 1226 (Exception: if F is a stream frame, it's OK to delete if |
1246 any other frames exist.) */ | 1227 any other frames exist.) */ |
1247 | 1228 |
1248 static int | 1229 int |
1249 other_visible_frames_internal (struct frame *f, int called_from_delete_device) | 1230 other_visible_frames (struct frame *f) |
1250 { | 1231 { |
1251 Lisp_Object frame; | 1232 Lisp_Object frame; |
1252 | 1233 |
1253 XSETFRAME (frame, f); | 1234 XSETFRAME (frame, f); |
1254 if (FRAME_STREAM_P (f)) | 1235 if (FRAME_STREAM_P (f)) |
1255 return !EQ (frame, next_frame_internal (frame, Qt, Qt, | 1236 return !EQ (frame, next_frame (frame, Qt, Qt)); |
1256 called_from_delete_device)); | 1237 return !EQ (frame, next_frame (frame, Qvisible_iconic_nomini, Qt)); |
1257 return !EQ (frame, next_frame_internal (frame, Qvisible_iconic_nomini, Qt, | |
1258 called_from_delete_device)); | |
1259 } | |
1260 | |
1261 int | |
1262 other_visible_frames (struct frame *f) | |
1263 { | |
1264 return other_visible_frames_internal (f, 0); | |
1265 } | 1238 } |
1266 | 1239 |
1267 /* Delete frame F. | 1240 /* Delete frame F. |
1268 | 1241 |
1269 If FORCE is non-zero, allow deletion of the only frame. | 1242 If FORCE is non-zero, allow deletion of the only frame. |
1320 only frame. However, this would let people shoot themselves by | 1293 only frame. However, this would let people shoot themselves by |
1321 deleting all frames which were either visible or iconified and thus | 1294 deleting all frames which were either visible or iconified and thus |
1322 losing any way of communicating with the still running XEmacs process. | 1295 losing any way of communicating with the still running XEmacs process. |
1323 So we put it back. */ | 1296 So we put it back. */ |
1324 if (!force && !allow_deletion_of_last_visible_frame && | 1297 if (!force && !allow_deletion_of_last_visible_frame && |
1325 !other_visible_frames_internal (f, called_from_delete_device)) | 1298 !other_visible_frames (f)) |
1326 error ("Attempt to delete the sole visible or iconified frame"); | 1299 error ("Attempt to delete the sole visible or iconified frame"); |
1327 | 1300 |
1328 /* Does this frame have a minibuffer, and is it the surrogate | 1301 /* Does this frame have a minibuffer, and is it the surrogate |
1329 minibuffer for any other frame? */ | 1302 minibuffer for any other frame? */ |
1330 if (FRAME_HAS_MINIBUF_P (f)) | 1303 if (FRAME_HAS_MINIBUF_P (f)) |
1446 Otherwise, find another visible frame; if none, just take any frame. | 1419 Otherwise, find another visible frame; if none, just take any frame. |
1447 First try the same device, then the same console. */ | 1420 First try the same device, then the same console. */ |
1448 | 1421 |
1449 next = DEVMETH_OR_GIVEN (d, get_frame_parent, (f), Qnil); | 1422 next = DEVMETH_OR_GIVEN (d, get_frame_parent, (f), Qnil); |
1450 if (NILP (next) || EQ (next, frame) || ! FRAME_LIVE_P (XFRAME (next))) | 1423 if (NILP (next) || EQ (next, frame) || ! FRAME_LIVE_P (XFRAME (next))) |
1451 next = next_frame_internal (frame, Qvisible, device, | 1424 next = next_frame (frame, Qvisible, device); |
1452 called_from_delete_device); | |
1453 if (NILP (next) || EQ (next, frame)) | 1425 if (NILP (next) || EQ (next, frame)) |
1454 next = next_frame_internal (frame, Qvisible, console, | 1426 next = next_frame (frame, Qvisible, console); |
1455 called_from_delete_device); | |
1456 if (NILP (next) || EQ (next, frame)) | 1427 if (NILP (next) || EQ (next, frame)) |
1457 next = next_frame_internal (frame, Qvisible, Qt, | 1428 next = next_frame (frame, Qvisible, Qt); |
1458 called_from_delete_device); | |
1459 if (NILP (next) || EQ (next, frame)) | 1429 if (NILP (next) || EQ (next, frame)) |
1460 next = next_frame_internal (frame, Qt, device, | 1430 next = next_frame (frame, Qt, device); |
1461 called_from_delete_device); | |
1462 if (NILP (next) || EQ (next, frame)) | 1431 if (NILP (next) || EQ (next, frame)) |
1463 next = next_frame_internal (frame, Qt, console, | 1432 next = next_frame (frame, Qt, console); |
1464 called_from_delete_device); | |
1465 if (NILP (next) || EQ (next, frame)) | 1433 if (NILP (next) || EQ (next, frame)) |
1466 next = next_frame_internal (frame, Qt, Qt, called_from_delete_device); | 1434 next = next_frame (frame, Qt, Qt); |
1467 | 1435 |
1468 /* if we haven't found another frame at this point | 1436 /* if we haven't found another frame at this point |
1469 then there aren't any. */ | 1437 then there aren't any. */ |
1470 if (NILP (next) || EQ (next, frame)) | 1438 if (NILP (next) || EQ (next, frame)) |
1471 ; | 1439 ; |
1483 * device then we still need to change DEVICE_SELECTED_FRAME(d) | 1451 * device then we still need to change DEVICE_SELECTED_FRAME(d) |
1484 * to a live frame, if there are any left on this device. | 1452 * to a live frame, if there are any left on this device. |
1485 */ | 1453 */ |
1486 if (!EQ (device, FRAME_DEVICE(XFRAME(next)))) | 1454 if (!EQ (device, FRAME_DEVICE(XFRAME(next)))) |
1487 { | 1455 { |
1488 Lisp_Object next_f = | 1456 Lisp_Object next_f = next_frame (frame, Qt, device); |
1489 next_frame_internal (frame, Qt, device, | |
1490 called_from_delete_device); | |
1491 if (NILP (next_f) || EQ (next_f, frame)) | 1457 if (NILP (next_f) || EQ (next_f, frame)) |
1492 ; | 1458 ; |
1493 else | 1459 else |
1494 set_device_selected_frame (d, next_f); | 1460 set_device_selected_frame (d, next_f); |
1495 } | 1461 } |