aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChong Yidong2012-06-19 14:49:50 +0800
committerChong Yidong2012-06-19 14:49:50 +0800
commitc6bf30222430f41fbb696e296f0f63f465eefc35 (patch)
tree257eb724e088a7e5e321170ce078cc0e3efc5f6e /src
parent4e2cc2f31f8e516901bc3cacf98def678cd45dc9 (diff)
downloademacs-c6bf30222430f41fbb696e296f0f63f465eefc35.tar.gz
emacs-c6bf30222430f41fbb696e296f0f63f465eefc35.zip
Preserve tty top-frames under various window-changing operations.
* subr.el (with-selected-window): Preserve the selected window's terminal's top-frame. * window.el (save-selected-window): Likewise. * frame.c (delete_frame): When selecting a frame on a different text terminal, do not alter the terminal's top-frame. * term.c (Ftty_top_frame): New function. * xdisp.c (format_mode_line_unwind_data): Record the target frame's selected window and its terminal's top-frame. (unwind_format_mode_line): Restore them. (x_consider_frame_title, display_mode_line, Fformat_mode_line): Callers changed. (x_consider_frame_title): Do not condition on HAVE_WINDOW_SYSTEM, since tty frames can be explicitly named. (prepare_menu_bars): Likewise. Fixes: debbugs:4702
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog16
-rw-r--r--src/frame.c36
-rw-r--r--src/term.c22
-rw-r--r--src/xdisp.c62
4 files changed, 98 insertions, 38 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index df9fcb9dd87..16fcbb07522 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,19 @@
12012-06-19 Chong Yidong <cyd@gnu.org>
2
3 * frame.c (delete_frame): When selecting a frame on a different
4 text terminal, do not alter the terminal's top-frame.
5
6 * xdisp.c (format_mode_line_unwind_data): Record the target
7 frame's selected window and its terminal's top-frame.
8 (unwind_format_mode_line): Restore them.
9 (x_consider_frame_title, display_mode_line, Fformat_mode_line):
10 Callers changed.
11 (x_consider_frame_title): Do not condition on HAVE_WINDOW_SYSTEM,
12 since tty frames can be explicitly named.
13 (prepare_menu_bars): Likewise.
14
15 * term.c (Ftty_top_frame): New function.
16
12012-06-18 Paul Eggert <eggert@cs.ucla.edu> 172012-06-18 Paul Eggert <eggert@cs.ucla.edu>
2 18
3 Port byte-code-meter to modern targets. 19 Port byte-code-meter to modern targets.
diff --git a/src/frame.c b/src/frame.c
index 39d26ded5a6..fc52b07923d 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -630,8 +630,8 @@ DEFUN ("make-terminal-frame", Fmake_terminal_frame, Smake_terminal_frame,
630 doc: /* Create an additional terminal frame, possibly on another terminal. 630 doc: /* Create an additional terminal frame, possibly on another terminal.
631This function takes one argument, an alist specifying frame parameters. 631This function takes one argument, an alist specifying frame parameters.
632 632
633You can create multiple frames on a single text-only terminal, but 633You can create multiple frames on a single text terminal, but only one
634only one of them (the selected terminal frame) is actually displayed. 634of them (the selected terminal frame) is actually displayed.
635 635
636In practice, generally you don't need to specify any parameters, 636In practice, generally you don't need to specify any parameters,
637except when you want to create a new frame on another terminal. 637except when you want to create a new frame on another terminal.
@@ -865,8 +865,8 @@ something to select a different frame, or until the next time
865this function is called. If you are using a window system, the 865this function is called. If you are using a window system, the
866previously selected frame may be restored as the selected frame 866previously selected frame may be restored as the selected frame
867when returning to the command loop, because it still may have 867when returning to the command loop, because it still may have
868the window system's input focus. On a text-only terminal, the 868the window system's input focus. On a text terminal, the next
869next redisplay will display FRAME. 869redisplay will display FRAME.
870 870
871This function returns FRAME, or nil if FRAME has been deleted. */) 871This function returns FRAME, or nil if FRAME has been deleted. */)
872 (Lisp_Object frame, Lisp_Object norecord) 872 (Lisp_Object frame, Lisp_Object norecord)
@@ -1254,7 +1254,17 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1254 FOR_EACH_FRAME (tail, frame1) 1254 FOR_EACH_FRAME (tail, frame1)
1255 { 1255 {
1256 if (! EQ (frame, frame1) && FRAME_LIVE_P (XFRAME (frame1))) 1256 if (! EQ (frame, frame1) && FRAME_LIVE_P (XFRAME (frame1)))
1257 break; 1257 {
1258 /* Do not change a text terminal's top-frame. */
1259 struct frame *f1 = XFRAME (frame1);
1260 if (FRAME_TERMCAP_P (f1) || FRAME_MSDOS_P (f1))
1261 {
1262 Lisp_Object top_frame = FRAME_TTY (f1)->top_frame;
1263 if (!EQ (top_frame, frame))
1264 frame1 = top_frame;
1265 }
1266 break;
1267 }
1258 } 1268 }
1259 } 1269 }
1260#ifdef NS_IMPL_COCOA 1270#ifdef NS_IMPL_COCOA
@@ -1730,8 +1740,8 @@ usually not displayed at all, even in a window system's \"taskbar\".
1730Normally you may not make FRAME invisible if all other frames are invisible, 1740Normally you may not make FRAME invisible if all other frames are invisible,
1731but if the second optional argument FORCE is non-nil, you may do so. 1741but if the second optional argument FORCE is non-nil, you may do so.
1732 1742
1733This function has no effect on text-only terminal frames. Such frames 1743This function has no effect on text terminal frames. Such frames are
1734are always considered visible, whether or not they are currently being 1744always considered visible, whether or not they are currently being
1735displayed in the terminal. */) 1745displayed in the terminal. */)
1736 (Lisp_Object frame, Lisp_Object force) 1746 (Lisp_Object frame, Lisp_Object force)
1737{ 1747{
@@ -1743,12 +1753,6 @@ displayed in the terminal. */)
1743 if (NILP (force) && !other_visible_frames (XFRAME (frame))) 1753 if (NILP (force) && !other_visible_frames (XFRAME (frame)))
1744 error ("Attempt to make invisible the sole visible or iconified frame"); 1754 error ("Attempt to make invisible the sole visible or iconified frame");
1745 1755
1746#if 0 /* This isn't logically necessary, and it can do GC. */
1747 /* Don't let the frame remain selected. */
1748 if (EQ (frame, selected_frame))
1749 do_switch_frame (next_frame (frame, Qt), 0, 0, Qnil)
1750#endif
1751
1752 /* Don't allow minibuf_window to remain on a deleted frame. */ 1756 /* Don't allow minibuf_window to remain on a deleted frame. */
1753 if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window)) 1757 if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
1754 { 1758 {
@@ -1816,7 +1820,7 @@ Return nil if FRAME was made invisible, via `make-frame-invisible'.
1816On graphical displays, invisible frames are not updated and are 1820On graphical displays, invisible frames are not updated and are
1817usually not displayed at all, even in a window system's \"taskbar\". 1821usually not displayed at all, even in a window system's \"taskbar\".
1818 1822
1819If FRAME is a text-only terminal frame, this always returns t. 1823If FRAME is a text terminal frame, this always returns t.
1820Such frames are always considered visible, whether or not they are 1824Such frames are always considered visible, whether or not they are
1821currently being displayed on the terminal. */) 1825currently being displayed on the terminal. */)
1822 (Lisp_Object frame) 1826 (Lisp_Object frame)
@@ -1872,7 +1876,7 @@ doesn't support multiple overlapping frames, this function selects FRAME. */)
1872 f = XFRAME (frame); 1876 f = XFRAME (frame);
1873 1877
1874 if (FRAME_TERMCAP_P (f)) 1878 if (FRAME_TERMCAP_P (f))
1875 /* On a text-only terminal select FRAME. */ 1879 /* On a text terminal select FRAME. */
1876 Fselect_frame (frame, Qnil); 1880 Fselect_frame (frame, Qnil);
1877 else 1881 else
1878 /* Do like the documentation says. */ 1882 /* Do like the documentation says. */
@@ -2493,7 +2497,7 @@ not the menu bar).
2493In a graphical version with no toolkit, it includes both the tool bar 2497In a graphical version with no toolkit, it includes both the tool bar
2494and menu bar. 2498and menu bar.
2495 2499
2496For a text-only terminal, it includes the menu bar. In this case, the 2500For a text terminal, it includes the menu bar. In this case, the
2497result is really in characters rather than pixels (i.e., is identical 2501result is really in characters rather than pixels (i.e., is identical
2498to `frame-height'). */) 2502to `frame-height'). */)
2499 (Lisp_Object frame) 2503 (Lisp_Object frame)
diff --git a/src/term.c b/src/term.c
index 3a41552c02e..5f807181199 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2132,7 +2132,7 @@ DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p,
2132 2132
2133TERMINAL can be a terminal object, a frame, or nil (meaning the 2133TERMINAL can be a terminal object, a frame, or nil (meaning the
2134selected frame's terminal). This function always returns nil if 2134selected frame's terminal). This function always returns nil if
2135TERMINAL does not refer to a text-only terminal. */) 2135TERMINAL does not refer to a text terminal. */)
2136 (Lisp_Object terminal) 2136 (Lisp_Object terminal)
2137{ 2137{
2138 struct terminal *t = get_tty_terminal (terminal, 0); 2138 struct terminal *t = get_tty_terminal (terminal, 0);
@@ -2149,7 +2149,7 @@ DEFUN ("tty-display-color-cells", Ftty_display_color_cells,
2149 2149
2150TERMINAL can be a terminal object, a frame, or nil (meaning the 2150TERMINAL can be a terminal object, a frame, or nil (meaning the
2151selected frame's terminal). This function always returns 0 if 2151selected frame's terminal). This function always returns 0 if
2152TERMINAL does not refer to a text-only terminal. */) 2152TERMINAL does not refer to a text terminal. */)
2153 (Lisp_Object terminal) 2153 (Lisp_Object terminal)
2154{ 2154{
2155 struct terminal *t = get_tty_terminal (terminal, 0); 2155 struct terminal *t = get_tty_terminal (terminal, 0);
@@ -2371,7 +2371,7 @@ no effect if used on a non-tty terminal.
2371 2371
2372TERMINAL can be a terminal object, a frame or nil (meaning the 2372TERMINAL can be a terminal object, a frame or nil (meaning the
2373selected frame's terminal). This function always returns nil if 2373selected frame's terminal). This function always returns nil if
2374TERMINAL does not refer to a text-only terminal. */) 2374TERMINAL does not refer to a text terminal. */)
2375 (Lisp_Object terminal) 2375 (Lisp_Object terminal)
2376{ 2376{
2377 struct terminal *t = get_terminal (terminal, 1); 2377 struct terminal *t = get_terminal (terminal, 1);
@@ -2381,6 +2381,21 @@ TERMINAL does not refer to a text-only terminal. */)
2381 return Qnil; 2381 return Qnil;
2382} 2382}
2383 2383
2384DEFUN ("tty-top-frame", Ftty_top_frame, Stty_top_frame, 0, 1, 0,
2385 doc: /* Return the topmost terminal frame on TERMINAL.
2386TERMINAL can be a terminal object, a frame or nil (meaning the
2387selected frame's terminal). This function returns nil if TERMINAL
2388does not refer to a text terminal. Otherwise, it returns the
2389top-most frame on the text terminal. */)
2390 (Lisp_Object terminal)
2391{
2392 struct terminal *t = get_terminal (terminal, 1);
2393
2394 if (t->type == output_termcap)
2395 return t->display_info.tty->top_frame;
2396 return Qnil;
2397}
2398
2384 2399
2385 2400
2386DEFUN ("suspend-tty", Fsuspend_tty, Ssuspend_tty, 0, 1, 0, 2401DEFUN ("suspend-tty", Fsuspend_tty, Ssuspend_tty, 0, 1, 0,
@@ -3638,6 +3653,7 @@ bigger, or it may make it blink, or it may do nothing at all. */);
3638 defsubr (&Stty_no_underline); 3653 defsubr (&Stty_no_underline);
3639 defsubr (&Stty_type); 3654 defsubr (&Stty_type);
3640 defsubr (&Scontrolling_tty_p); 3655 defsubr (&Scontrolling_tty_p);
3656 defsubr (&Stty_top_frame);
3641 defsubr (&Ssuspend_tty); 3657 defsubr (&Ssuspend_tty);
3642 defsubr (&Sresume_tty); 3658 defsubr (&Sresume_tty);
3643#ifdef HAVE_GPM 3659#ifdef HAVE_GPM
diff --git a/src/xdisp.c b/src/xdisp.c
index f371346589b..dafd22a3fb3 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -8356,9 +8356,9 @@ move_it_in_display_line_to (struct it *it,
8356 /* On graphical terminals, newlines may 8356 /* On graphical terminals, newlines may
8357 "overflow" into the fringe if 8357 "overflow" into the fringe if
8358 overflow-newline-into-fringe is non-nil. 8358 overflow-newline-into-fringe is non-nil.
8359 On text-only terminals, newlines may 8359 On text terminals, newlines may overflow
8360 overflow into the last glyph on the 8360 into the last glyph on the display
8361 display line.*/ 8361 line.*/
8362 if (!FRAME_WINDOW_P (it->f) 8362 if (!FRAME_WINDOW_P (it->f)
8363 || IT_OVERFLOW_NEWLINE_INTO_FRINGE (it)) 8363 || IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
8364 { 8364 {
@@ -10821,7 +10821,8 @@ static Lisp_Object mode_line_string_face_prop;
10821static Lisp_Object Vmode_line_unwind_vector; 10821static Lisp_Object Vmode_line_unwind_vector;
10822 10822
10823static Lisp_Object 10823static Lisp_Object
10824format_mode_line_unwind_data (struct buffer *obuf, 10824format_mode_line_unwind_data (struct frame *target_frame,
10825 struct buffer *obuf,
10825 Lisp_Object owin, 10826 Lisp_Object owin,
10826 int save_proptrans) 10827 int save_proptrans)
10827{ 10828{
@@ -10833,7 +10834,7 @@ format_mode_line_unwind_data (struct buffer *obuf,
10833 Vmode_line_unwind_vector = Qnil; 10834 Vmode_line_unwind_vector = Qnil;
10834 10835
10835 if (NILP (vector)) 10836 if (NILP (vector))
10836 vector = Fmake_vector (make_number (8), Qnil); 10837 vector = Fmake_vector (make_number (10), Qnil);
10837 10838
10838 ASET (vector, 0, make_number (mode_line_target)); 10839 ASET (vector, 0, make_number (mode_line_target));
10839 ASET (vector, 1, make_number (MODE_LINE_NOPROP_LEN (0))); 10840 ASET (vector, 1, make_number (MODE_LINE_NOPROP_LEN (0)));
@@ -10848,6 +10849,15 @@ format_mode_line_unwind_data (struct buffer *obuf,
10848 tmp = Qnil; 10849 tmp = Qnil;
10849 ASET (vector, 6, tmp); 10850 ASET (vector, 6, tmp);
10850 ASET (vector, 7, owin); 10851 ASET (vector, 7, owin);
10852 if (target_frame)
10853 {
10854 /* Similarly to `with-selected-window', if the operation selects
10855 a window on another frame, we must restore that frame's
10856 selected window, and (for a tty) the top-frame. */
10857 ASET (vector, 8, target_frame->selected_window);
10858 if (FRAME_TERMCAP_P (target_frame))
10859 ASET (vector, 9, FRAME_TTY (target_frame)->top_frame);
10860 }
10851 10861
10852 return vector; 10862 return vector;
10853} 10863}
@@ -10855,6 +10865,10 @@ format_mode_line_unwind_data (struct buffer *obuf,
10855static Lisp_Object 10865static Lisp_Object
10856unwind_format_mode_line (Lisp_Object vector) 10866unwind_format_mode_line (Lisp_Object vector)
10857{ 10867{
10868 Lisp_Object old_window = AREF (vector, 7);
10869 Lisp_Object target_frame_window = AREF (vector, 8);
10870 Lisp_Object old_top_frame = AREF (vector, 9);
10871
10858 mode_line_target = XINT (AREF (vector, 0)); 10872 mode_line_target = XINT (AREF (vector, 0));
10859 mode_line_noprop_ptr = mode_line_noprop_buf + XINT (AREF (vector, 1)); 10873 mode_line_noprop_ptr = mode_line_noprop_buf + XINT (AREF (vector, 1));
10860 mode_line_string_list = AREF (vector, 2); 10874 mode_line_string_list = AREF (vector, 2);
@@ -10863,9 +10877,26 @@ unwind_format_mode_line (Lisp_Object vector)
10863 mode_line_string_face = AREF (vector, 4); 10877 mode_line_string_face = AREF (vector, 4);
10864 mode_line_string_face_prop = AREF (vector, 5); 10878 mode_line_string_face_prop = AREF (vector, 5);
10865 10879
10866 if (!NILP (AREF (vector, 7))) 10880 /* Select window before buffer, since it may change the buffer. */
10867 /* Select window before buffer, since it may change the buffer. */ 10881 if (!NILP (old_window))
10868 Fselect_window (AREF (vector, 7), Qt); 10882 {
10883 /* If the operation that we are unwinding had selected a window
10884 on a different frame, reset its frame-selected-window. For a
10885 text terminal, reset its top-frame if necessary. */
10886 if (!NILP (target_frame_window))
10887 {
10888 Lisp_Object frame
10889 = WINDOW_FRAME (XWINDOW (target_frame_window));
10890
10891 if (!EQ (frame, WINDOW_FRAME (XWINDOW (old_window))))
10892 Fselect_window (target_frame_window, Qt);
10893
10894 if (!NILP (old_top_frame) && !EQ (old_top_frame, frame))
10895 Fselect_frame (old_top_frame, Qt);
10896 }
10897
10898 Fselect_window (old_window, Qt);
10899 }
10869 10900
10870 if (!NILP (AREF (vector, 6))) 10901 if (!NILP (AREF (vector, 6)))
10871 { 10902 {
@@ -10936,8 +10967,6 @@ store_mode_line_noprop (const char *string, int field_width, int precision)
10936 Frame Titles 10967 Frame Titles
10937 ***********************************************************************/ 10968 ***********************************************************************/
10938 10969
10939#ifdef HAVE_WINDOW_SYSTEM
10940
10941/* Set the title of FRAME, if it has changed. The title format is 10970/* Set the title of FRAME, if it has changed. The title format is
10942 Vicon_title_format if FRAME is iconified, otherwise it is 10971 Vicon_title_format if FRAME is iconified, otherwise it is
10943 frame_title_format. */ 10972 frame_title_format. */
@@ -10981,7 +11010,7 @@ x_consider_frame_title (Lisp_Object frame)
10981 mode_line_noprop_buf; then display the title. */ 11010 mode_line_noprop_buf; then display the title. */
10982 record_unwind_protect (unwind_format_mode_line, 11011 record_unwind_protect (unwind_format_mode_line,
10983 format_mode_line_unwind_data 11012 format_mode_line_unwind_data
10984 (current_buffer, selected_window, 0)); 11013 (f, current_buffer, selected_window, 0));
10985 11014
10986 Fselect_window (f->selected_window, Qt); 11015 Fselect_window (f->selected_window, Qt);
10987 set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->buffer)); 11016 set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->buffer));
@@ -11008,10 +11037,6 @@ x_consider_frame_title (Lisp_Object frame)
11008 } 11037 }
11009} 11038}
11010 11039
11011#endif /* not HAVE_WINDOW_SYSTEM */
11012
11013
11014
11015 11040
11016/*********************************************************************** 11041/***********************************************************************
11017 Menu Bars 11042 Menu Bars
@@ -11038,7 +11063,6 @@ prepare_menu_bars (void)
11038 /* Update all frame titles based on their buffer names, etc. We do 11063 /* Update all frame titles based on their buffer names, etc. We do
11039 this before the menu bars so that the buffer-menu will show the 11064 this before the menu bars so that the buffer-menu will show the
11040 up-to-date frame titles. */ 11065 up-to-date frame titles. */
11041#ifdef HAVE_WINDOW_SYSTEM
11042 if (windows_or_buffers_changed || update_mode_lines) 11066 if (windows_or_buffers_changed || update_mode_lines)
11043 { 11067 {
11044 Lisp_Object tail, frame; 11068 Lisp_Object tail, frame;
@@ -11051,7 +11075,6 @@ prepare_menu_bars (void)
11051 x_consider_frame_title (frame); 11075 x_consider_frame_title (frame);
11052 } 11076 }
11053 } 11077 }
11054#endif /* HAVE_WINDOW_SYSTEM */
11055 11078
11056 /* Update the menu bar item lists, if appropriate. This has to be 11079 /* Update the menu bar item lists, if appropriate. This has to be
11057 done before any actual redisplay or generation of display lines. */ 11080 done before any actual redisplay or generation of display lines. */
@@ -20125,7 +20148,7 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format)
20125 it.paragraph_embedding = L2R; 20148 it.paragraph_embedding = L2R;
20126 20149
20127 record_unwind_protect (unwind_format_mode_line, 20150 record_unwind_protect (unwind_format_mode_line,
20128 format_mode_line_unwind_data (NULL, Qnil, 0)); 20151 format_mode_line_unwind_data (NULL, NULL, Qnil, 0));
20129 20152
20130 mode_line_target = MODE_LINE_DISPLAY; 20153 mode_line_target = MODE_LINE_DISPLAY;
20131 20154
@@ -20826,7 +20849,8 @@ are the selected window and the WINDOW's buffer). */)
20826 and set that to nil so that we don't alter the outer value. */ 20849 and set that to nil so that we don't alter the outer value. */
20827 record_unwind_protect (unwind_format_mode_line, 20850 record_unwind_protect (unwind_format_mode_line,
20828 format_mode_line_unwind_data 20851 format_mode_line_unwind_data
20829 (old_buffer, selected_window, 1)); 20852 (XFRAME (WINDOW_FRAME (XWINDOW (window))),
20853 old_buffer, selected_window, 1));
20830 mode_line_proptrans_alist = Qnil; 20854 mode_line_proptrans_alist = Qnil;
20831 20855
20832 Fselect_window (window, Qt); 20856 Fselect_window (window, Qt);