comparison src/window.c @ 1325:f03e559aac3e

* window.c (struct save_window_data): Save the currently selected frame, too. (Fset_window_configuration): Restore the frame's selected window using Fselect_window, and then restore the selected frame using Fselect_frame. (Fcurrent_window_configuration): Record the currently selected frame. Update docstring to describe the information now recorded. * window.c (Fset_window_configuration): Clean up the way we save and restore the frame's size. * window.c (struct save_window_data): Add a member called focus_frame, to save and restore the screen's focus frame. (Fset_window_configuration): Redirect the frame's focus as indicated in the window configuration. (Fcurrent_window_configuration): Record the frame's current focus.
author Jim Blandy <jimb@redhat.com>
date Sat, 03 Oct 1992 05:42:42 +0000
parents 5c66007ecabb
children 709532b86646
comparison
equal deleted inserted replaced
1324:44215417cf6e 1325:f03e559aac3e
2294 struct save_window_data 2294 struct save_window_data
2295 { 2295 {
2296 int size_from_Lisp_Vector_struct; 2296 int size_from_Lisp_Vector_struct;
2297 struct Lisp_Vector *next_from_Lisp_Vector_struct; 2297 struct Lisp_Vector *next_from_Lisp_Vector_struct;
2298 Lisp_Object frame_width, frame_height; 2298 Lisp_Object frame_width, frame_height;
2299 Lisp_Object selected_frame;
2299 Lisp_Object current_window; 2300 Lisp_Object current_window;
2300 Lisp_Object current_buffer; 2301 Lisp_Object current_buffer;
2301 Lisp_Object minibuf_scroll_window; 2302 Lisp_Object minibuf_scroll_window;
2302 Lisp_Object root_window; 2303 Lisp_Object root_window;
2304 Lisp_Object focus_frame;
2303 /* A vector, interpreted as a struct saved_window */ 2305 /* A vector, interpreted as a struct saved_window */
2304 Lisp_Object saved_windows; 2306 Lisp_Object saved_windows;
2305 }; 2307 };
2306 #define SAVE_WINDOW_DATA_SIZE 7 /* Arg to Fmake_vector */ 2308 #define SAVE_WINDOW_DATA_SIZE 7 /* Arg to Fmake_vector */
2307 2309
2351 register Lisp_Object tem; 2353 register Lisp_Object tem;
2352 Lisp_Object new_current_buffer; 2354 Lisp_Object new_current_buffer;
2353 int k; 2355 int k;
2354 FRAME_PTR f; 2356 FRAME_PTR f;
2355 2357
2356 /* Save screen height here so we can go back to it at the end. */ 2358 /* If the frame has been resized since this window configuration was
2359 made, we change the frame to the size specified in the
2360 configuration, restore the configuration, and then resize it
2361 back. We keep track of the prevailing height in these variables. */
2357 int previous_frame_height; 2362 int previous_frame_height;
2358 int previous_frame_width; 2363 int previous_frame_width;
2359 int frame_size_change;
2360 2364
2361 while (XTYPE (configuration) != Lisp_Window_Configuration) 2365 while (XTYPE (configuration) != Lisp_Window_Configuration)
2362 { 2366 {
2363 configuration = wrong_type_argument (intern ("window-configuration-p"), 2367 configuration = wrong_type_argument (intern ("window-configuration-p"),
2364 configuration); 2368 configuration);
2367 data = (struct save_window_data *) XVECTOR (configuration); 2371 data = (struct save_window_data *) XVECTOR (configuration);
2368 saved_windows = XVECTOR (data->saved_windows); 2372 saved_windows = XVECTOR (data->saved_windows);
2369 2373
2370 f = XFRAME (XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame); 2374 f = XFRAME (XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame);
2371 2375
2372 if (XFASTINT (data->frame_height) != FRAME_HEIGHT (f) 2376 previous_frame_height = FRAME_HEIGHT (f);
2373 || XFASTINT (data->frame_width) != FRAME_WIDTH (f)) 2377 previous_frame_width = FRAME_WIDTH (f);
2374 { 2378 if (XFASTINT (data->frame_height) != previous_frame_height
2375 previous_frame_height = FRAME_HEIGHT (f); 2379 || XFASTINT (data->frame_width) != previous_frame_width)
2376 previous_frame_width = FRAME_WIDTH (f); 2380 change_frame_size (f, data->frame_height, data->frame_width, 0, 0);
2377 frame_size_change = 1;
2378
2379 change_frame_size (f, data->frame_height, data->frame_width, 0, 0);
2380 }
2381 else
2382 frame_size_change = 0;
2383 2381
2384 windows_or_buffers_changed++; 2382 windows_or_buffers_changed++;
2385 new_current_buffer = data->current_buffer; 2383 new_current_buffer = data->current_buffer;
2386 if (NILP (XBUFFER (new_current_buffer)->name)) 2384 if (NILP (XBUFFER (new_current_buffer)->name))
2387 new_current_buffer = Qnil; 2385 new_current_buffer = Qnil;
2389 /* Kludge Alert! 2387 /* Kludge Alert!
2390 Mark all windows now on frame as "deleted". 2388 Mark all windows now on frame as "deleted".
2391 Restoring the new configuration "undeletes" any that are in it. 2389 Restoring the new configuration "undeletes" any that are in it.
2392 2390
2393 Save their current buffers in their height fields, since we may 2391 Save their current buffers in their height fields, since we may
2394 need it later, if the buffer saved in the configuration is now 2392 need it later, if a buffer saved in the configuration is now
2395 dead. */ 2393 dead. */
2396 delete_all_subwindows (XWINDOW (FRAME_ROOT_WINDOW (f))); 2394 delete_all_subwindows (XWINDOW (FRAME_ROOT_WINDOW (f)));
2397 2395
2398 for (k = 0; k < saved_windows->size; k++) 2396 for (k = 0; k < saved_windows->size; k++)
2399 { 2397 {
2454 set_marker_restricted (w->start, Fmarker_position (p->start), w->buffer); 2452 set_marker_restricted (w->start, Fmarker_position (p->start), w->buffer);
2455 set_marker_restricted (w->pointm, Fmarker_position (p->pointm), w->buffer); 2453 set_marker_restricted (w->pointm, Fmarker_position (p->pointm), w->buffer);
2456 Fset_marker (XBUFFER (w->buffer)->mark, 2454 Fset_marker (XBUFFER (w->buffer)->mark,
2457 Fmarker_position (p->mark), w->buffer); 2455 Fmarker_position (p->mark), w->buffer);
2458 2456
2457 /* As documented in Fcurrent_window_configuration, don't
2458 save the location of point in the buffer which was current
2459 when the window configuration was recorded. */
2459 if (!EQ (p->buffer, new_current_buffer) && 2460 if (!EQ (p->buffer, new_current_buffer) &&
2460 XBUFFER (p->buffer) == current_buffer) 2461 XBUFFER (p->buffer) == current_buffer)
2461 Fgoto_char (w->pointm); 2462 Fgoto_char (w->pointm);
2462 } 2463 }
2463 else if (NILP (XBUFFER (w->buffer)->name)) 2464 else if (NILP (XBUFFER (w->buffer)->name))
2484 } 2485 }
2485 } 2486 }
2486 } 2487 }
2487 2488
2488 FRAME_ROOT_WINDOW (f) = data->root_window; 2489 FRAME_ROOT_WINDOW (f) = data->root_window;
2489 /* We also need to restore the frame's selected window; that's taken 2490 Fselect_window (data->current_window);
2490 care of below, either by calling Fselect_window, or by explicit 2491
2491 assignment. */ 2492 /* Fselect_window will have made f the selected frame, so we
2493 reselect the proper frame here. Fselect_frame will change the
2494 selected window too, but that doesn't make the call to
2495 Fselect_window above totally superfluous; it still sets f's
2496 selected window. */
2497 Fselect_frame (d->selected_frame);
2498
2499 if (!NILP (new_current_buffer))
2500 Fset_buffer (new_current_buffer);
2501
2502 #ifdef MULTI_FRAME
2503 {
2504 Lisp_Object frame;
2505
2506 XSET (frame, Lisp_Frame, f);
2507 Fredirect_frame_focus (frame, data->focus_frame);
2508 }
2509 #endif
2492 2510
2493 #if 0 /* I don't understand why this is needed, and it causes 2511 #if 0 /* I don't understand why this is needed, and it causes
2494 problems when the frame's old selected window has been 2512 problems when the frame's old selected window has been
2495 deleted. */ 2513 deleted. */
2496 #ifdef MULTI_FRAME 2514 #ifdef MULTI_FRAME
2498 Fselect_frame (WINDOW_FRAME (XWINDOW (data->root_window)), Qnil); 2516 Fselect_frame (WINDOW_FRAME (XWINDOW (data->root_window)), Qnil);
2499 #endif 2517 #endif
2500 #endif 2518 #endif
2501 2519
2502 /* Set the screen height to the value it had before this function. */ 2520 /* Set the screen height to the value it had before this function. */
2503 if (frame_size_change) 2521 if (previous_frame_height != FRAME_HEIGHT (f)
2522 || previous_frame_width != FRAME_WIDTH (f))
2504 change_frame_size (f, previous_frame_height, previous_frame_width, 0, 0); 2523 change_frame_size (f, previous_frame_height, previous_frame_width, 0, 0);
2505
2506 if (f == selected_frame)
2507 {
2508 Fselect_window (data->current_window);
2509 if (!NILP (new_current_buffer))
2510 Fset_buffer (new_current_buffer);
2511 else
2512 Fset_buffer (XWINDOW (selected_window)->buffer);
2513 }
2514 else
2515 FRAME_SELECTED_WINDOW (f) = data->current_window;
2516 2524
2517 Vminibuf_scroll_window = data->minibuf_scroll_window; 2525 Vminibuf_scroll_window = data->minibuf_scroll_window;
2518 return (Qnil); 2526 return (Qnil);
2519 } 2527 }
2520 2528
2625 "Return an object representing the current window configuration of FRAME.\n\ 2633 "Return an object representing the current window configuration of FRAME.\n\
2626 If FRAME is nil or omitted, use the selected frame.\n\ 2634 If FRAME is nil or omitted, use the selected frame.\n\
2627 This describes the number of windows, their sizes and current buffers,\n\ 2635 This describes the number of windows, their sizes and current buffers,\n\
2628 and for each displayed buffer, where display starts, and the positions of\n\ 2636 and for each displayed buffer, where display starts, and the positions of\n\
2629 point and mark. An exception is made for point in the current buffer:\n\ 2637 point and mark. An exception is made for point in the current buffer:\n\
2630 its value is -not- saved.") 2638 its value is -not- saved.\n\
2639 This also records the currently selected frame, and FRAME's focus\n\
2640 redirection (see `redirect-frame-focus').")
2631 (frame) 2641 (frame)
2632 Lisp_Object frame; 2642 Lisp_Object frame;
2633 { 2643 {
2634 register Lisp_Object tem; 2644 register Lisp_Object tem;
2635 register int n_windows; 2645 register int n_windows;
2649 data = (struct save_window_data *) 2659 data = (struct save_window_data *)
2650 XVECTOR (Fmake_vector (make_number (SAVE_WINDOW_DATA_SIZE), 2660 XVECTOR (Fmake_vector (make_number (SAVE_WINDOW_DATA_SIZE),
2651 Qnil)); 2661 Qnil));
2652 XFASTINT (data->frame_width) = FRAME_WIDTH (f); 2662 XFASTINT (data->frame_width) = FRAME_WIDTH (f);
2653 XFASTINT (data->frame_height) = FRAME_HEIGHT (f); 2663 XFASTINT (data->frame_height) = FRAME_HEIGHT (f);
2664 XSET (data->selected_frame, Lisp_Frame, selected_frame);
2654 data->current_window = FRAME_SELECTED_WINDOW (f); 2665 data->current_window = FRAME_SELECTED_WINDOW (f);
2655 XSET (data->current_buffer, Lisp_Buffer, current_buffer); 2666 XSET (data->current_buffer, Lisp_Buffer, current_buffer);
2656 data->minibuf_scroll_window = Vminibuf_scroll_window; 2667 data->minibuf_scroll_window = Vminibuf_scroll_window;
2657 data->root_window = FRAME_ROOT_WINDOW (f); 2668 data->root_window = FRAME_ROOT_WINDOW (f);
2669 data->focus_frame = FRAME_FOCUS_FRAME (f);
2658 tem = Fmake_vector (make_number (n_windows), Qnil); 2670 tem = Fmake_vector (make_number (n_windows), Qnil);
2659 data->saved_windows = tem; 2671 data->saved_windows = tem;
2660 for (i = 0; i < n_windows; i++) 2672 for (i = 0; i < n_windows; i++)
2661 XVECTOR (tem)->contents[i] 2673 XVECTOR (tem)->contents[i]
2662 = Fmake_vector (make_number (SAVED_WINDOW_VECTOR_SIZE), Qnil); 2674 = Fmake_vector (make_number (SAVED_WINDOW_VECTOR_SIZE), Qnil);