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