comparison src/window.c @ 8263:bae811318a57

(Fdisplay_buffer): Cope with unsplittable frames and dedicated windows.
author Richard M. Stallman <rms@gnu.org>
date Sat, 16 Jul 1994 20:18:53 +0000
parents b743577d12c2
children 30755be9badb
comparison
equal deleted inserted replaced
8262:676fd590cc41 8263:bae811318a57
1311 } 1311 }
1312 1312
1313 DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 1, 0, 1313 DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 1, 0,
1314 "Return the window least recently selected or used for display.\n\ 1314 "Return the window least recently selected or used for display.\n\
1315 If optional argument FRAME is `visible', search all visible frames.\n\ 1315 If optional argument FRAME is `visible', search all visible frames.\n\
1316 If FRAME is 0, search all visible and iconified frames.\n\
1316 If FRAME is t, search all frames.\n\ 1317 If FRAME is t, search all frames.\n\
1317 If FRAME is nil, search only the selected frame.\n\ 1318 If FRAME is nil, search only the selected frame.\n\
1318 If FRAME is a frame, search only that frame.") 1319 If FRAME is a frame, search only that frame.")
1319 (frame) 1320 (frame)
1320 Lisp_Object frame; 1321 Lisp_Object frame;
1329 } 1330 }
1330 1331
1331 DEFUN ("get-largest-window", Fget_largest_window, Sget_largest_window, 0, 1, 0, 1332 DEFUN ("get-largest-window", Fget_largest_window, Sget_largest_window, 0, 1, 0,
1332 "Return the largest window in area.\n\ 1333 "Return the largest window in area.\n\
1333 If optional argument FRAME is `visible', search all visible frames.\n\ 1334 If optional argument FRAME is `visible', search all visible frames.\n\
1335 If FRAME is 0, search all visible and iconified frames.\n\
1334 If FRAME is t, search all frames.\n\ 1336 If FRAME is t, search all frames.\n\
1335 If FRAME is nil, search only the selected frame.\n\ 1337 If FRAME is nil, search only the selected frame.\n\
1336 If FRAME is a frame, search only that frame.") 1338 If FRAME is a frame, search only that frame.")
1337 (frame) 1339 (frame)
1338 Lisp_Object frame; 1340 Lisp_Object frame;
1804 #endif /* MULTI_FRAME */ 1806 #endif /* MULTI_FRAME */
1805 1807
1806 if (pop_up_windows 1808 if (pop_up_windows
1807 #ifdef MULTI_FRAME 1809 #ifdef MULTI_FRAME
1808 || FRAME_MINIBUF_ONLY_P (selected_frame) 1810 || FRAME_MINIBUF_ONLY_P (selected_frame)
1811 /* If the current frame is a special display frame,
1812 don't try to reuse its windows. */
1813 || !NILP (XWINDOW (FRAME_ROOT_WINDOW (selected_frame))->dedicated)
1809 #endif 1814 #endif
1810 ) 1815 )
1811 { 1816 {
1812 Lisp_Object frames; 1817 Lisp_Object frames;
1813 1818
1818 #endif 1823 #endif
1819 /* Don't try to create a window if would get an error */ 1824 /* Don't try to create a window if would get an error */
1820 if (split_height_threshold < window_min_height << 1) 1825 if (split_height_threshold < window_min_height << 1)
1821 split_height_threshold = window_min_height << 1; 1826 split_height_threshold = window_min_height << 1;
1822 1827
1823 window = Fget_largest_window (frames); 1828 /* Note that both Fget_largest_window and Fget_lru_window
1824 1829 ignore minibuffers and dedicated windows.
1830 This means they can return nil. */
1831
1832 /* If the frame we would try to split cannot be split,
1833 try other frames. */
1834 if (FRAME_NO_SPLIT_P (NILP (frames) ? selected_frame
1835 : last_nonminibuf_frame))
1836 {
1837 /* Try visible frames first. */
1838 window = Fget_largest_window (Qvisible);
1839 /* If that didn't work, try iconified frames. */
1840 if (NILP (window))
1841 window = Fget_largest_window (make_number (0));
1842 if (NILP (window))
1843 window = Fget_largest_window (Qt);
1844 }
1845 else
1846 window = Fget_largest_window (frames);
1847
1848 /* If we got a tall enough full-width window, split it. */
1825 if (!NILP (window) 1849 if (!NILP (window)
1826 && window_height (window) >= split_height_threshold 1850 && window_height (window) >= split_height_threshold
1827 && (XFASTINT (XWINDOW (window)->width) 1851 && (XFASTINT (XWINDOW (window)->width)
1828 == FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (window)))))) 1852 == FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (window))))))
1829 window = Fsplit_window (window, Qnil, Qnil); 1853 window = Fsplit_window (window, Qnil, Qnil);
1830 else 1854 else
1831 { 1855 {
1832 window = Fget_lru_window (frames); 1856 window = Fget_lru_window (frames);
1833 if ((EQ (window, selected_window) 1857 /* If the LRU window is selected, and big enough, split it. */
1834 || EQ (XWINDOW (window)->parent, Qnil)) 1858 if (!NILP (window)
1859 && (EQ (window, selected_window)
1860 || EQ (XWINDOW (window)->parent, Qnil))
1835 && window_height (window) >= window_min_height << 1) 1861 && window_height (window) >= window_min_height << 1)
1836 window = Fsplit_window (window, Qnil, Qnil); 1862 window = Fsplit_window (window, Qnil, Qnil);
1863 #ifdef MULTI_FRAME
1864 /* If Fget_lru_window returned nil, try other approaches. */
1865 /* Try visible frames first. */
1866 if (NILP (window))
1867 window = Fget_largest_window (Qvisible);
1868 /* If that didn't work, try iconified frames. */
1869 if (NILP (window))
1870 window = Fget_largest_window (make_number (0));
1871 /* Try invisible frames. */
1872 if (NILP (window))
1873 window = Fget_largest_window (Qt);
1874 /* As a last resort, make a new frame. */
1875 if (NILP (window))
1876 window = Fframe_selected_window (call0 (Vpop_up_frame_function));
1877 #else
1878 /* As a last resort, use a non minibuffer window. */
1879 if (NILP (window))
1880 window = Fframe_first_window (Fselected_frame ());
1881 #endif
1837 } 1882 }
1838 } 1883 }
1839 else 1884 else
1840 window = Fget_lru_window (Qnil); 1885 window = Fget_lru_window (Qnil);
1841 1886