aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorRichard M. Stallman2002-01-08 05:41:37 +0000
committerRichard M. Stallman2002-01-08 05:41:37 +0000
commit192c3131345ac1f3445dd4bbdb46156ed4d6e122 (patch)
treee167e3e1b2f081f5ee90a024903fd5d7fa2d69e7 /src/window.c
parent50a07e18565cc4dd7162908197ac71e85c1781d7 (diff)
downloademacs-192c3131345ac1f3445dd4bbdb46156ed4d6e122.tar.gz
emacs-192c3131345ac1f3445dd4bbdb46156ed4d6e122.zip
(delete_window): Rewrite the code for changing the
selected window to handle the case where WINDOW is not a leaf.
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c55
1 files changed, 38 insertions, 17 deletions
diff --git a/src/window.c b/src/window.c
index 0e5af1f0790..e3914f8f97a 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1214,34 +1214,49 @@ delete_window (window)
1214 1214
1215 /* Are we trying to delete any frame's selected window? */ 1215 /* Are we trying to delete any frame's selected window? */
1216 { 1216 {
1217 Lisp_Object pwindow; 1217 Lisp_Object swindow, pwindow;
1218 1218
1219 /* See if the frame's selected window is either WINDOW 1219 /* See if the frame's selected window is either WINDOW
1220 or any subwindow of it, by finding all that window's parents 1220 or any subwindow of it, by finding all that window's parents
1221 and comparing each one with WINDOW. */ 1221 and comparing each one with WINDOW. */
1222 pwindow = FRAME_SELECTED_WINDOW (f); 1222 swindow = FRAME_SELECTED_WINDOW (f);
1223 1223
1224 while (!NILP (pwindow)) 1224 while (1)
1225 { 1225 {
1226 if (EQ (window, pwindow)) 1226 pwindow = swindow;
1227 while (!NILP (pwindow))
1228 {
1229 if (EQ (window, pwindow))
1230 break;
1231 pwindow = XWINDOW (pwindow)->parent;
1232 }
1233
1234 /* If the window being deleted is not a parent of SWINDOW,
1235 then SWINDOW is ok as the new selected window. */
1236 if (!EQ (window, pwindow))
1227 break; 1237 break;
1228 pwindow = XWINDOW (pwindow)->parent; 1238 /* Otherwise, try another window for SWINDOW. */
1239 swindow = Fnext_window (swindow, Qlambda, Qnil);;
1240
1241 /* If we get back to the frame's selected window,
1242 it means there was no acceptable alternative,
1243 so we cannot delete. */
1244 if (EQ (swindow, FRAME_SELECTED_WINDOW (f)))
1245 error ("Cannot delete window");
1229 } 1246 }
1230 1247
1231 if (EQ (window, pwindow)) 1248 /* If we need to change SWINDOW, do it. */
1249 if (! EQ (swindow, FRAME_SELECTED_WINDOW (f)))
1232 { 1250 {
1233 Lisp_Object alternative;
1234 alternative = Fnext_window (window, Qlambda, Qnil);
1235
1236 /* If we're about to delete the selected window on the 1251 /* If we're about to delete the selected window on the
1237 selected frame, then we should use Fselect_window to select 1252 selected frame, then we should use Fselect_window to select
1238 the new window. On the other hand, if we're about to 1253 the new window. On the other hand, if we're about to
1239 delete the selected window on any other frame, we shouldn't do 1254 delete the selected window on any other frame, we shouldn't do
1240 anything but set the frame's selected_window slot. */ 1255 anything but set the frame's selected_window slot. */
1241 if (EQ (window, selected_window)) 1256 if (EQ (FRAME_SELECTED_WINDOW (f), selected_window))
1242 Fselect_window (alternative); 1257 Fselect_window (swindow);
1243 else 1258 else
1244 FRAME_SELECTED_WINDOW (f) = alternative; 1259 FRAME_SELECTED_WINDOW (f) = swindow;
1245 } 1260 }
1246 } 1261 }
1247 1262
@@ -2372,7 +2387,10 @@ window_min_size (w, width_p, ignore_fixed_p, fixed)
2372 WINDOW's width. Resize WINDOW's children, if any, so that they 2387 WINDOW's width. Resize WINDOW's children, if any, so that they
2373 keep their proportionate size relative to WINDOW. Propagate 2388 keep their proportionate size relative to WINDOW. Propagate
2374 WINDOW's top or left edge position to children. Delete windows 2389 WINDOW's top or left edge position to children. Delete windows
2375 that become too small unless NODELETE_P is non-zero. */ 2390 that become too small unless NODELETE_P is non-zero.
2391
2392 If NODELETE_P is 2, that means we do delete windows that are
2393 too small, even if they were too small before! */
2376 2394
2377static void 2395static void
2378size_window (window, size, width_p, nodelete_p) 2396size_window (window, size, width_p, nodelete_p)
@@ -2384,6 +2402,9 @@ size_window (window, size, width_p, nodelete_p)
2384 Lisp_Object child, *forward, *sideward; 2402 Lisp_Object child, *forward, *sideward;
2385 int old_size, min_size; 2403 int old_size, min_size;
2386 2404
2405 if (nodelete_p == 2)
2406 nodelete_p = 0;
2407
2387 check_min_window_sizes (); 2408 check_min_window_sizes ();
2388 size = max (0, size); 2409 size = max (0, size);
2389 2410
@@ -2400,12 +2421,12 @@ size_window (window, size, width_p, nodelete_p)
2400 old_size = XINT (w->height); 2421 old_size = XINT (w->height);
2401 min_size = window_min_height; 2422 min_size = window_min_height;
2402 } 2423 }
2403 2424
2404 if (old_size < min_size) 2425 if (old_size < min_size && nodelete_p != 2)
2405 w->too_small_ok = Qt; 2426 w->too_small_ok = Qt;
2406 2427
2407 /* Maybe delete WINDOW if it's too small. */ 2428 /* Maybe delete WINDOW if it's too small. */
2408 if (!nodelete_p && !NILP (w->parent)) 2429 if (nodelete_p != 1 && !NILP (w->parent))
2409 { 2430 {
2410 if (!MINI_WINDOW_P (w) && !NILP (w->too_small_ok)) 2431 if (!MINI_WINDOW_P (w) && !NILP (w->too_small_ok))
2411 min_size = width_p ? MIN_SAFE_WINDOW_WIDTH : MIN_SAFE_WINDOW_HEIGHT; 2432 min_size = width_p ? MIN_SAFE_WINDOW_WIDTH : MIN_SAFE_WINDOW_HEIGHT;
@@ -2531,7 +2552,7 @@ size_window (window, size, width_p, nodelete_p)
2531 int child_size; 2552 int child_size;
2532 c = XWINDOW (child); 2553 c = XWINDOW (child);
2533 child_size = width_p ? XINT (c->width) : XINT (c->height); 2554 child_size = width_p ? XINT (c->width) : XINT (c->height);
2534 size_window (child, child_size, width_p, 0); 2555 size_window (child, child_size, width_p, 2);
2535 } 2556 }
2536 } 2557 }
2537} 2558}