Mercurial > emacs
comparison src/frame.c @ 5925:806e876cacb4
(Fset_frame_height, Fset_frame_width, Fset_frame_size):
Pass CHANGE_GRAVITY arg to x_set_window_size.
(other_visible_frames): New function; code taken from Fdelete_frame.
(Fdelete_frame): Use it.
(Fmake_frame_invisible): Use it. New arg FORCE.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 12 Feb 1994 02:37:17 +0000 |
parents | e8d95be8bc19 |
children | 650c0f231d17 |
comparison
equal
deleted
inserted
replaced
5924:d81345ecac1a | 5925:806e876cacb4 |
---|---|
616 CHECK_LIVE_FRAME (frame, 0); | 616 CHECK_LIVE_FRAME (frame, 0); |
617 | 617 |
618 return prev_frame (frame, miniframe); | 618 return prev_frame (frame, miniframe); |
619 } | 619 } |
620 | 620 |
621 /* Return 1 if it is ok to delete frame F; | |
622 0 if all frames aside from F are invisible. | |
623 (Exception: if F is the terminal frame, and we are using X, return 1.) */ | |
624 | |
625 static int | |
626 other_visible_frames (f) | |
627 FRAME_PTR f; | |
628 { | |
629 /* We know the selected frame is visible, | |
630 so if F is some other frame, it can't be the sole visible one. */ | |
631 if (f == selected_frame) | |
632 { | |
633 Lisp_Object frames; | |
634 int count = 0; | |
635 | |
636 for (frames = Vframe_list; | |
637 CONSP (frames); | |
638 frames = XCONS (frames)->cdr) | |
639 { | |
640 Lisp_Object this = XCONS (frames)->car; | |
641 | |
642 /* Verify that the frame's window still exists | |
643 and we can still talk to it. And note any recent change | |
644 in visibility. */ | |
645 #ifdef HAVE_X_WINDOWS | |
646 if (FRAME_X_P (XFRAME (this))) | |
647 { | |
648 x_sync (this); | |
649 FRAME_SAMPLE_VISIBILITY (XFRAME (this)); | |
650 } | |
651 #endif | |
652 | |
653 if (FRAME_VISIBLE_P (XFRAME (this)) | |
654 || FRAME_ICONIFIED_P (XFRAME (this)) | |
655 /* Allow deleting the terminal frame when at least | |
656 one X frame exists! */ | |
657 || (FRAME_X_P (XFRAME (this)) && !FRAME_X_P (f))) | |
658 count++; | |
659 } | |
660 return count > 1; | |
661 } | |
662 return 1; | |
663 } | |
664 | |
621 DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "", | 665 DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "", |
622 "Delete FRAME, permanently eliminating it from use.\n\ | 666 "Delete FRAME, permanently eliminating it from use.\n\ |
623 If omitted, FRAME defaults to the selected frame.\n\ | 667 If omitted, FRAME defaults to the selected frame.\n\ |
624 A frame may not be deleted if its minibuffer is used by other frames.\n\ | 668 A frame may not be deleted if its minibuffer is used by other frames.\n\ |
625 Normally, you may not delete a frame if all other frames are invisible,\n\ | 669 Normally, you may not delete a frame if all other frames are invisible,\n\ |
641 } | 685 } |
642 | 686 |
643 if (! FRAME_LIVE_P (f)) | 687 if (! FRAME_LIVE_P (f)) |
644 return Qnil; | 688 return Qnil; |
645 | 689 |
646 /* If all other frames are invisible, refuse to delete. | 690 if (NILP (force) && !other_visible_frames (f)) |
647 (Exception: allow deleting the terminal frame when using X.) */ | 691 error ("Attempt to delete the sole visible or iconified frame"); |
648 if (f == selected_frame && NILP (force)) | |
649 { | |
650 Lisp_Object frames; | |
651 int count = 0; | |
652 | |
653 for (frames = Vframe_list; | |
654 CONSP (frames); | |
655 frames = XCONS (frames)->cdr) | |
656 { | |
657 Lisp_Object this = XCONS (frames)->car; | |
658 | |
659 #ifdef HAVE_X_WINDOWS | |
660 if (FRAME_X_P (XFRAME (this))) | |
661 { | |
662 x_sync (this); | |
663 FRAME_SAMPLE_VISIBILITY (XFRAME (this)); | |
664 } | |
665 #endif | |
666 | |
667 if (FRAME_VISIBLE_P (XFRAME (this)) | |
668 || FRAME_ICONIFIED_P (XFRAME (this)) | |
669 /* Allow deleting the terminal frame when at least | |
670 one X frame exists! */ | |
671 || (FRAME_X_P (XFRAME (this)) && !FRAME_X_P (f))) | |
672 count++; | |
673 } | |
674 if (count == 1) | |
675 error ("Attempt to delete the only frame"); | |
676 } | |
677 | 692 |
678 /* Does this frame have a minibuffer, and is it the surrogate | 693 /* Does this frame have a minibuffer, and is it the surrogate |
679 minibuffer for any other frame? */ | 694 minibuffer for any other frame? */ |
680 if (FRAME_HAS_MINIBUF_P (XFRAME (frame))) | 695 if (FRAME_HAS_MINIBUF_P (XFRAME (frame))) |
681 { | 696 { |
869 | 884 |
870 return frame; | 885 return frame; |
871 } | 886 } |
872 | 887 |
873 DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible, | 888 DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible, |
874 0, 1, "", | 889 0, 2, "", |
875 "Make the frame FRAME invisible (assuming it is an X-window).\n\ | 890 "Make the frame FRAME invisible (assuming it is an X-window).\n\ |
876 If omitted, FRAME defaults to the currently selected frame.") | 891 If omitted, FRAME defaults to the currently selected frame.\n\ |
877 (frame) | 892 Normally you may not make FRAME invisible if all other frames are invisible,\n\ |
878 Lisp_Object frame; | 893 but if the second optional argument FORCE is non-nil, you may do so.") |
894 (frame, force) | |
895 Lisp_Object frame, force; | |
879 { | 896 { |
880 if (NILP (frame)) | 897 if (NILP (frame)) |
881 XSET (frame, Lisp_Frame, selected_frame); | 898 XSET (frame, Lisp_Frame, selected_frame); |
882 | 899 |
883 CHECK_LIVE_FRAME (frame, 0); | 900 CHECK_LIVE_FRAME (frame, 0); |
901 | |
902 if (NILP (force) && !other_visible_frames (XFRAME (frame))) | |
903 error ("Attempt to make invisible the sole visible or iconified frame"); | |
884 | 904 |
885 /* Don't let the frame remain selected. */ | 905 /* Don't let the frame remain selected. */ |
886 if (XFRAME (frame) == selected_frame) | 906 if (XFRAME (frame) == selected_frame) |
887 Fhandle_switch_frame (next_frame (frame, Qt), Qnil); | 907 Fhandle_switch_frame (next_frame (frame, Qt), Qnil); |
888 | 908 |
1343 /* I think this should be done with a hook. */ | 1363 /* I think this should be done with a hook. */ |
1344 #ifdef HAVE_X_WINDOWS | 1364 #ifdef HAVE_X_WINDOWS |
1345 if (FRAME_X_P (f)) | 1365 if (FRAME_X_P (f)) |
1346 { | 1366 { |
1347 if (XINT (rows) != f->width) | 1367 if (XINT (rows) != f->width) |
1348 x_set_window_size (f, f->width, XINT (rows)); | 1368 x_set_window_size (f, 1, f->width, XINT (rows)); |
1349 } | 1369 } |
1350 else | 1370 else |
1351 #endif | 1371 #endif |
1352 change_frame_size (f, XINT (rows), 0, !NILP (pretend), 0); | 1372 change_frame_size (f, XINT (rows), 0, !NILP (pretend), 0); |
1353 return Qnil; | 1373 return Qnil; |
1373 /* I think this should be done with a hook. */ | 1393 /* I think this should be done with a hook. */ |
1374 #ifdef HAVE_X_WINDOWS | 1394 #ifdef HAVE_X_WINDOWS |
1375 if (FRAME_X_P (f)) | 1395 if (FRAME_X_P (f)) |
1376 { | 1396 { |
1377 if (XINT (cols) != f->width) | 1397 if (XINT (cols) != f->width) |
1378 x_set_window_size (f, XINT (cols), f->height); | 1398 x_set_window_size (f, 1, XINT (cols), f->height); |
1379 } | 1399 } |
1380 else | 1400 else |
1381 #endif | 1401 #endif |
1382 change_frame_size (f, 0, XINT (cols), !NILP (pretend), 0); | 1402 change_frame_size (f, 0, XINT (cols), !NILP (pretend), 0); |
1383 return Qnil; | 1403 return Qnil; |
1399 /* I think this should be done with a hook. */ | 1419 /* I think this should be done with a hook. */ |
1400 #ifdef HAVE_X_WINDOWS | 1420 #ifdef HAVE_X_WINDOWS |
1401 if (FRAME_X_P (f)) | 1421 if (FRAME_X_P (f)) |
1402 { | 1422 { |
1403 if (XINT (rows) != f->height || XINT (cols) != f->width) | 1423 if (XINT (rows) != f->height || XINT (cols) != f->width) |
1404 x_set_window_size (f, XINT (cols), XINT (rows)); | 1424 x_set_window_size (f, 1, XINT (cols), XINT (rows)); |
1405 } | 1425 } |
1406 else | 1426 else |
1407 #endif | 1427 #endif |
1408 change_frame_size (f, XINT (rows), XINT (cols), 0, 0); | 1428 change_frame_size (f, XINT (rows), XINT (cols), 0, 0); |
1409 | 1429 |