aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/window.c282
1 files changed, 147 insertions, 135 deletions
diff --git a/src/window.c b/src/window.c
index 94bae9506b8..df8bd81bb4b 100644
--- a/src/window.c
+++ b/src/window.c
@@ -34,7 +34,7 @@ Lisp_Object Qwindowp, Qlive_window_p;
34Lisp_Object Fnext_window (), Fdelete_window (), Fselect_window (); 34Lisp_Object Fnext_window (), Fdelete_window (), Fselect_window ();
35Lisp_Object Fset_window_buffer (), Fsplit_window (), Frecenter (); 35Lisp_Object Fset_window_buffer (), Fsplit_window (), Frecenter ();
36 36
37static void delete_all_subwindows (); 37void delete_all_subwindows ();
38static struct window *decode_window(); 38static struct window *decode_window();
39 39
40/* This is the window in which the terminal's cursor should 40/* This is the window in which the terminal's cursor should
@@ -2394,22 +2394,12 @@ by `current-window-configuration' (which see).")
2394 (configuration) 2394 (configuration)
2395 Lisp_Object configuration; 2395 Lisp_Object configuration;
2396{ 2396{
2397 register struct window *w;
2398 register struct save_window_data *data; 2397 register struct save_window_data *data;
2399 struct Lisp_Vector *saved_windows; 2398 struct Lisp_Vector *saved_windows;
2400 register struct saved_window *p;
2401 register Lisp_Object tem;
2402 Lisp_Object new_current_buffer; 2399 Lisp_Object new_current_buffer;
2403 int k; 2400 Lisp_Object frame;
2404 FRAME_PTR f; 2401 FRAME_PTR f;
2405 2402
2406 /* If the frame has been resized since this window configuration was
2407 made, we change the frame to the size specified in the
2408 configuration, restore the configuration, and then resize it
2409 back. We keep track of the prevailing height in these variables. */
2410 int previous_frame_height;
2411 int previous_frame_width;
2412
2413 while (XTYPE (configuration) != Lisp_Window_Configuration) 2403 while (XTYPE (configuration) != Lisp_Window_Configuration)
2414 { 2404 {
2415 configuration = wrong_type_argument (intern ("window-configuration-p"), 2405 configuration = wrong_type_argument (intern ("window-configuration-p"),
@@ -2419,123 +2409,167 @@ by `current-window-configuration' (which see).")
2419 data = (struct save_window_data *) XVECTOR (configuration); 2409 data = (struct save_window_data *) XVECTOR (configuration);
2420 saved_windows = XVECTOR (data->saved_windows); 2410 saved_windows = XVECTOR (data->saved_windows);
2421 2411
2422 f = XFRAME (XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame);
2423
2424 previous_frame_height = FRAME_HEIGHT (f);
2425 previous_frame_width = FRAME_WIDTH (f);
2426 if (XFASTINT (data->frame_height) != previous_frame_height
2427 || XFASTINT (data->frame_width) != previous_frame_width)
2428 change_frame_size (f, data->frame_height, data->frame_width, 0, 0);
2429
2430 windows_or_buffers_changed++;
2431 new_current_buffer = data->current_buffer; 2412 new_current_buffer = data->current_buffer;
2432 if (NILP (XBUFFER (new_current_buffer)->name)) 2413 if (NILP (XBUFFER (new_current_buffer)->name))
2433 new_current_buffer = Qnil; 2414 new_current_buffer = Qnil;
2434 2415
2435 /* Kludge Alert! 2416 frame = XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame;
2436 Mark all windows now on frame as "deleted". 2417 f = XFRAME (frame);
2437 Restoring the new configuration "undeletes" any that are in it.
2438
2439 Save their current buffers in their height fields, since we may
2440 need it later, if a buffer saved in the configuration is now
2441 dead. */
2442 delete_all_subwindows (XWINDOW (FRAME_ROOT_WINDOW (f)));
2443 2418
2444 for (k = 0; k < saved_windows->size; k++) 2419 /* If f is a dead frame, don't bother rebuilding its window tree.
2420 However, there is other stuff we should still try to do below. */
2421 if (FRAME_LIVE_P (f))
2445 { 2422 {
2446 p = SAVED_WINDOW_N (saved_windows, k); 2423 register struct window *w;
2447 w = XWINDOW (p->window); 2424 register struct saved_window *p;
2448 w->next = Qnil; 2425 int k;
2426
2427 /* If the frame has been resized since this window configuration was
2428 made, we change the frame to the size specified in the
2429 configuration, restore the configuration, and then resize it
2430 back. We keep track of the prevailing height in these variables. */
2431 int previous_frame_height = FRAME_HEIGHT (f);
2432 int previous_frame_width = FRAME_WIDTH (f);
2433
2434 if (XFASTINT (data->frame_height) != previous_frame_height
2435 || XFASTINT (data->frame_width) != previous_frame_width)
2436 change_frame_size (f, data->frame_height, data->frame_width, 0, 0);
2437
2438 windows_or_buffers_changed++;
2439
2440 /* Kludge Alert!
2441 Mark all windows now on frame as "deleted".
2442 Restoring the new configuration "undeletes" any that are in it.
2443
2444 Save their current buffers in their height fields, since we may
2445 need it later, if a buffer saved in the configuration is now
2446 dead. */
2447 delete_all_subwindows (XWINDOW (FRAME_ROOT_WINDOW (f)));
2448
2449 for (k = 0; k < saved_windows->size; k++)
2450 {
2451 p = SAVED_WINDOW_N (saved_windows, k);
2452 w = XWINDOW (p->window);
2453 w->next = Qnil;
2449 2454
2450 if (!NILP (p->parent)) 2455 if (!NILP (p->parent))
2451 w->parent = SAVED_WINDOW_N (saved_windows, XFASTINT (p->parent))->window; 2456 w->parent = SAVED_WINDOW_N (saved_windows,
2452 else 2457 XFASTINT (p->parent))->window;
2453 w->parent = Qnil; 2458 else
2459 w->parent = Qnil;
2454 2460
2455 if (!NILP (p->prev)) 2461 if (!NILP (p->prev))
2456 {
2457 w->prev = SAVED_WINDOW_N (saved_windows, XFASTINT (p->prev))->window;
2458 XWINDOW (w->prev)->next = p->window;
2459 }
2460 else
2461 {
2462 w->prev = Qnil;
2463 if (!NILP (w->parent))
2464 { 2462 {
2465 if (EQ (p->width, XWINDOW (w->parent)->width)) 2463 w->prev = SAVED_WINDOW_N (saved_windows,
2464 XFASTINT (p->prev))->window;
2465 XWINDOW (w->prev)->next = p->window;
2466 }
2467 else
2468 {
2469 w->prev = Qnil;
2470 if (!NILP (w->parent))
2466 { 2471 {
2467 XWINDOW (w->parent)->vchild = p->window; 2472 if (EQ (p->width, XWINDOW (w->parent)->width))
2468 XWINDOW (w->parent)->hchild = Qnil; 2473 {
2474 XWINDOW (w->parent)->vchild = p->window;
2475 XWINDOW (w->parent)->hchild = Qnil;
2476 }
2477 else
2478 {
2479 XWINDOW (w->parent)->hchild = p->window;
2480 XWINDOW (w->parent)->vchild = Qnil;
2481 }
2482 }
2483 }
2484
2485 /* If we squirreled away the buffer in the window's height,
2486 restore it now. */
2487 if (XTYPE (w->height) == Lisp_Buffer)
2488 w->buffer = w->height;
2489 w->left = p->left;
2490 w->top = p->top;
2491 w->width = p->width;
2492 w->height = p->height;
2493 w->hscroll = p->hscroll;
2494 w->display_table = p->display_table;
2495 XFASTINT (w->last_modified) = 0;
2496
2497 /* Reinstall the saved buffer and pointers into it. */
2498 if (NILP (p->buffer))
2499 w->buffer = p->buffer;
2500 else
2501 {
2502 if (!NILP (XBUFFER (p->buffer)->name))
2503 /* If saved buffer is alive, install it. */
2504 {
2505 w->buffer = p->buffer;
2506 w->start_at_line_beg = p->start_at_line_beg;
2507 set_marker_restricted (w->start,
2508 Fmarker_position (p->start),
2509 w->buffer);
2510 set_marker_restricted (w->pointm,
2511 Fmarker_position (p->pointm),
2512 w->buffer);
2513 Fset_marker (XBUFFER (w->buffer)->mark,
2514 Fmarker_position (p->mark), w->buffer);
2515
2516 /* As documented in Fcurrent_window_configuration, don't
2517 save the location of point in the buffer which was current
2518 when the window configuration was recorded. */
2519 if (!EQ (p->buffer, new_current_buffer) &&
2520 XBUFFER (p->buffer) == current_buffer)
2521 Fgoto_char (w->pointm);
2522 }
2523 else if (NILP (XBUFFER (w->buffer)->name))
2524 /* Else if window's old buffer is dead too, get a live one. */
2525 {
2526 w->buffer = Fcdr (Fcar (Vbuffer_alist));
2527 /* This will set the markers to beginning of visible
2528 range. */
2529 set_marker_restricted (w->start, make_number (0), w->buffer);
2530 set_marker_restricted (w->pointm, make_number (0),w->buffer);
2531 w->start_at_line_beg = Qt;
2469 } 2532 }
2470 else 2533 else
2534 /* Keeping window's old buffer; make sure the markers
2535 are real. Else if window's old buffer is dead too,
2536 get a live one. */
2471 { 2537 {
2472 XWINDOW (w->parent)->hchild = p->window; 2538 /* Set window markers at start of visible range. */
2473 XWINDOW (w->parent)->vchild = Qnil; 2539 if (XMARKER (w->start)->buffer == 0)
2540 set_marker_restricted (w->start, make_number (0),
2541 w->buffer);
2542 if (XMARKER (w->pointm)->buffer == 0)
2543 set_marker_restricted (w->pointm,
2544 (make_number
2545 (BUF_PT (XBUFFER (w->buffer)))),
2546 w->buffer);
2547 w->start_at_line_beg = Qt;
2474 } 2548 }
2475 } 2549 }
2476 } 2550 }
2477 2551
2478 /* If we squirreled away the buffer in the window's height, 2552 FRAME_ROOT_WINDOW (f) = data->root_window;
2479 restore it now. */ 2553 Fselect_window (data->current_window);
2480 if (XTYPE (w->height) == Lisp_Buffer)
2481 w->buffer = w->height;
2482 w->left = p->left;
2483 w->top = p->top;
2484 w->width = p->width;
2485 w->height = p->height;
2486 w->hscroll = p->hscroll;
2487 w->display_table = p->display_table;
2488 XFASTINT (w->last_modified) = 0;
2489 2554
2490 /* Reinstall the saved buffer and pointers into it. */ 2555#ifdef MULTI_FRAME
2491 if (NILP (p->buffer)) 2556 Fredirect_frame_focus (frame, data->focus_frame);
2492 w->buffer = p->buffer; 2557#endif
2493 else
2494 {
2495 if (!NILP (XBUFFER (p->buffer)->name))
2496 /* If saved buffer is alive, install it. */
2497 {
2498 w->buffer = p->buffer;
2499 w->start_at_line_beg = p->start_at_line_beg;
2500 set_marker_restricted (w->start, Fmarker_position (p->start), w->buffer);
2501 set_marker_restricted (w->pointm, Fmarker_position (p->pointm), w->buffer);
2502 Fset_marker (XBUFFER (w->buffer)->mark,
2503 Fmarker_position (p->mark), w->buffer);
2504
2505 /* As documented in Fcurrent_window_configuration, don't
2506 save the location of point in the buffer which was current
2507 when the window configuration was recorded. */
2508 if (!EQ (p->buffer, new_current_buffer) &&
2509 XBUFFER (p->buffer) == current_buffer)
2510 Fgoto_char (w->pointm);
2511 }
2512 else if (NILP (XBUFFER (w->buffer)->name))
2513 /* Else if window's old buffer is dead too, get a live one. */
2514 {
2515 w->buffer = Fcdr (Fcar (Vbuffer_alist));
2516 /* This will set the markers to beginning of visible range. */
2517 set_marker_restricted (w->start, make_number (0), w->buffer);
2518 set_marker_restricted (w->pointm, make_number (0), w->buffer);
2519 w->start_at_line_beg = Qt;
2520 }
2521 else
2522 /* Keeping window's old buffer; make sure the markers are real. */
2523 /* Else if window's old buffer is dead too, get a live one. */
2524 {
2525 /* Set window markers at start of visible range. */
2526 if (XMARKER (w->start)->buffer == 0)
2527 set_marker_restricted (w->start, make_number (0), w->buffer);
2528 if (XMARKER (w->pointm)->buffer == 0)
2529 set_marker_restricted (w->pointm,
2530 make_number (BUF_PT (XBUFFER (w->buffer))),
2531 w->buffer);
2532 w->start_at_line_beg = Qt;
2533 }
2534 }
2535 }
2536 2558
2537 FRAME_ROOT_WINDOW (f) = data->root_window; 2559#if 0 /* I don't understand why this is needed, and it causes problems
2538 Fselect_window (data->current_window); 2560 when the frame's old selected window has been deleted. */
2561#ifdef MULTI_FRAME
2562 if (f != selected_frame && ! FRAME_TERMCAP_P (f))
2563 Fselect_frame (WINDOW_FRAME (XWINDOW (data->root_window)), Qnil);
2564#endif
2565#endif
2566
2567 /* Set the screen height to the value it had before this function. */
2568 if (previous_frame_height != FRAME_HEIGHT (f)
2569 || previous_frame_width != FRAME_WIDTH (f))
2570 change_frame_size (f, previous_frame_height, previous_frame_width,
2571 0, 0);
2572 }
2539 2573
2540#ifdef MULTI_FRAME 2574#ifdef MULTI_FRAME
2541 /* Fselect_window will have made f the selected frame, so we 2575 /* Fselect_window will have made f the selected frame, so we
@@ -2543,35 +2577,13 @@ by `current-window-configuration' (which see).")
2543 selected window too, but that doesn't make the call to 2577 selected window too, but that doesn't make the call to
2544 Fselect_window above totally superfluous; it still sets f's 2578 Fselect_window above totally superfluous; it still sets f's
2545 selected window. */ 2579 selected window. */
2546 Fselect_frame (data->selected_frame); 2580 if (FRAME_LIVE_P (XFRAME (data->selected_frame)))
2581 Fselect_frame (data->selected_frame);
2547#endif 2582#endif
2548 2583
2549 if (!NILP (new_current_buffer)) 2584 if (!NILP (new_current_buffer))
2550 Fset_buffer (new_current_buffer); 2585 Fset_buffer (new_current_buffer);
2551 2586
2552#ifdef MULTI_FRAME
2553 {
2554 Lisp_Object frame;
2555
2556 XSET (frame, Lisp_Frame, f);
2557 Fredirect_frame_focus (frame, data->focus_frame);
2558 }
2559#endif
2560
2561#if 0 /* I don't understand why this is needed, and it causes
2562 problems when the frame's old selected window has been
2563 deleted. */
2564#ifdef MULTI_FRAME
2565 if (f != selected_frame && ! FRAME_TERMCAP_P (f))
2566 Fselect_frame (WINDOW_FRAME (XWINDOW (data->root_window)), Qnil);
2567#endif
2568#endif
2569
2570 /* Set the screen height to the value it had before this function. */
2571 if (previous_frame_height != FRAME_HEIGHT (f)
2572 || previous_frame_width != FRAME_WIDTH (f))
2573 change_frame_size (f, previous_frame_height, previous_frame_width, 0, 0);
2574
2575 Vminibuf_scroll_window = data->minibuf_scroll_window; 2587 Vminibuf_scroll_window = data->minibuf_scroll_window;
2576 return (Qnil); 2588 return (Qnil);
2577} 2589}
@@ -2579,7 +2591,7 @@ by `current-window-configuration' (which see).")
2579/* Mark all windows now on frame as deleted 2591/* Mark all windows now on frame as deleted
2580 by setting their buffers to nil. */ 2592 by setting their buffers to nil. */
2581 2593
2582static void 2594void
2583delete_all_subwindows (w) 2595delete_all_subwindows (w)
2584 register struct window *w; 2596 register struct window *w;
2585{ 2597{