aboutsummaryrefslogtreecommitdiffstats
path: root/src/frame.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/frame.c')
-rw-r--r--src/frame.c132
1 files changed, 80 insertions, 52 deletions
diff --git a/src/frame.c b/src/frame.c
index 14fc15c4717..d11a6b8fee9 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -185,7 +185,6 @@ set_menu_bar_lines_1 (Lisp_Object window, int n)
185{ 185{
186 struct window *w = XWINDOW (window); 186 struct window *w = XWINDOW (window);
187 187
188 w->last_modified = 0;
189 w->top_line += n; 188 w->top_line += n;
190 w->total_lines -= n; 189 w->total_lines -= n;
191 190
@@ -693,24 +692,16 @@ affects all frames on the same terminal device. */)
693 ? FRAME_TTY (XFRAME (selected_frame))->name 692 ? FRAME_TTY (XFRAME (selected_frame))->name
694 : NULL)); 693 : NULL));
695 if (!NILP (tty)) 694 if (!NILP (tty))
696 { 695 name = xlispstrdupa (tty);
697 name = alloca (SBYTES (tty) + 1);
698 memcpy (name, SSDATA (tty), SBYTES (tty));
699 name[SBYTES (tty)] = 0;
700 }
701 696
702 tty_type = get_future_frame_param 697 tty_type = get_future_frame_param
703 (Qtty_type, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame)) 698 (Qtty_type, parms, (FRAME_TERMCAP_P (XFRAME (selected_frame))
704 ? FRAME_TTY (XFRAME (selected_frame))->type 699 ? FRAME_TTY (XFRAME (selected_frame))->type
705 : NULL)); 700 : NULL));
706 if (!NILP (tty_type)) 701 if (!NILP (tty_type))
707 { 702 type = xlispstrdupa (tty_type);
708 type = alloca (SBYTES (tty_type) + 1);
709 memcpy (type, SSDATA (tty_type), SBYTES (tty_type));
710 type[SBYTES (tty_type)] = 0;
711 }
712 703
713 t = init_tty (name, type, 0); /* Errors are not fatal. */ 704 t = init_tty (name, type, 0); /* Errors are not fatal. */
714 } 705 }
715 706
716 f = make_terminal_frame (t); 707 f = make_terminal_frame (t);
@@ -726,7 +717,7 @@ affects all frames on the same terminal device. */)
726 XSETFRAME (frame, f); 717 XSETFRAME (frame, f);
727 718
728 store_in_alist (&parms, Qtty_type, build_string (t->display_info.tty->type)); 719 store_in_alist (&parms, Qtty_type, build_string (t->display_info.tty->type));
729 store_in_alist (&parms, Qtty, 720 store_in_alist (&parms, Qtty,
730 (t->display_info.tty->name 721 (t->display_info.tty->name
731 ? build_string (t->display_info.tty->name) 722 ? build_string (t->display_info.tty->name)
732 : Qnil)); 723 : Qnil));
@@ -1087,6 +1078,19 @@ Otherwise, include all frames. */)
1087 CHECK_LIVE_FRAME (frame); 1078 CHECK_LIVE_FRAME (frame);
1088 return prev_frame (frame, miniframe); 1079 return prev_frame (frame, miniframe);
1089} 1080}
1081
1082DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame,
1083 Slast_nonminibuf_frame, 0, 0, 0,
1084 doc: /* Return last non-minibuffer frame selected. */)
1085 (void)
1086{
1087 Lisp_Object frame = Qnil;
1088
1089 if (last_nonminibuf_frame)
1090 XSETFRAME (frame, last_nonminibuf_frame);
1091
1092 return frame;
1093}
1090 1094
1091/* Return 1 if it is ok to delete frame F; 1095/* Return 1 if it is ok to delete frame F;
1092 0 if all frames aside from F are invisible. 1096 0 if all frames aside from F are invisible.
@@ -1119,6 +1123,50 @@ other_visible_frames (struct frame *f)
1119 return 0; 1123 return 0;
1120} 1124}
1121 1125
1126/* Make sure that minibuf_window doesn't refer to FRAME's minibuffer
1127 window. Preferably use the selected frame's minibuffer window
1128 instead. If the selected frame doesn't have one, get some other
1129 frame's minibuffer window. SELECT non-zero means select the new
1130 minibuffer window. */
1131static void
1132check_minibuf_window (Lisp_Object frame, int select)
1133{
1134 struct frame *f = decode_live_frame (frame);
1135
1136 if (WINDOWP (minibuf_window) && EQ (f->minibuffer_window, minibuf_window))
1137 {
1138 Lisp_Object frames, this, window = make_number (0);
1139
1140 if (!EQ (frame, selected_frame)
1141 && FRAME_HAS_MINIBUF_P (XFRAME (selected_frame)))
1142 window = FRAME_MINIBUF_WINDOW (XFRAME (selected_frame));
1143 else
1144 FOR_EACH_FRAME (frames, this)
1145 {
1146 if (!EQ (this, frame) && FRAME_HAS_MINIBUF_P (XFRAME (this)))
1147 {
1148 window = FRAME_MINIBUF_WINDOW (XFRAME (this));
1149 break;
1150 }
1151 }
1152
1153 /* Don't abort if no window was found (Bug#15247). */
1154 if (WINDOWP (window))
1155 {
1156 /* Use set_window_buffer instead of Fset_window_buffer (see
1157 discussion of bug#11984, bug#12025, bug#12026). */
1158 set_window_buffer (window, XWINDOW (minibuf_window)->contents, 0, 0);
1159 minibuf_window = window;
1160
1161 /* SELECT non-zero usually means that FRAME's minibuffer
1162 window was selected; select the new one. */
1163 if (select)
1164 Fselect_window (minibuf_window, Qnil);
1165 }
1166 }
1167}
1168
1169
1122/* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME 1170/* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
1123 unconditionally. x_connection_closed and delete_terminal use 1171 unconditionally. x_connection_closed and delete_terminal use
1124 this. Any other value of FORCE implements the semantics 1172 this. Any other value of FORCE implements the semantics
@@ -1206,10 +1254,18 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1206 /* Don't let the frame remain selected. */ 1254 /* Don't let the frame remain selected. */
1207 if (f == sf) 1255 if (f == sf)
1208 { 1256 {
1209 Lisp_Object tail, frame1; 1257 Lisp_Object tail;
1210 1258 Lisp_Object frame1 = Qnil;
1211 /* Look for another visible frame on the same terminal. */ 1259
1212 frame1 = next_frame (frame, Qvisible); 1260 /* Look for another visible frame on the same terminal.
1261 Do not call next_frame here because it may loop forever.
1262 See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15025. */
1263 FOR_EACH_FRAME (tail, frame1)
1264 if (!EQ (frame, frame1)
1265 && (FRAME_TERMINAL (XFRAME (frame))
1266 == FRAME_TERMINAL (XFRAME (frame1)))
1267 && FRAME_VISIBLE_P (XFRAME (frame1)))
1268 break;
1213 1269
1214 /* If there is none, find *some* other frame. */ 1270 /* If there is none, find *some* other frame. */
1215 if (NILP (frame1) || EQ (frame1, frame)) 1271 if (NILP (frame1) || EQ (frame1, frame))
@@ -1245,19 +1301,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1245 } 1301 }
1246 1302
1247 /* Don't allow minibuf_window to remain on a deleted frame. */ 1303 /* Don't allow minibuf_window to remain on a deleted frame. */
1248 if (EQ (f->minibuffer_window, minibuf_window)) 1304 check_minibuf_window (frame, minibuffer_selected);
1249 {
1250 /* Use set_window_buffer instead of Fset_window_buffer (see
1251 discussion of bug#11984, bug#12025, bug#12026). */
1252 set_window_buffer (sf->minibuffer_window,
1253 XWINDOW (minibuf_window)->contents, 0, 0);
1254 minibuf_window = sf->minibuffer_window;
1255
1256 /* If the dying minibuffer window was selected,
1257 select the new one. */
1258 if (minibuffer_selected)
1259 Fselect_window (minibuf_window, Qnil);
1260 }
1261 1305
1262 /* Don't let echo_area_window to remain on a deleted frame. */ 1306 /* Don't let echo_area_window to remain on a deleted frame. */
1263 if (EQ (f->minibuffer_window, echo_area_window)) 1307 if (EQ (f->minibuffer_window, echo_area_window))
@@ -1684,16 +1728,8 @@ displayed in the terminal. */)
1684 if (NILP (force) && !other_visible_frames (f)) 1728 if (NILP (force) && !other_visible_frames (f))
1685 error ("Attempt to make invisible the sole visible or iconified frame"); 1729 error ("Attempt to make invisible the sole visible or iconified frame");
1686 1730
1687 /* Don't allow minibuf_window to remain on a deleted frame. */ 1731 /* Don't allow minibuf_window to remain on an invisible frame. */
1688 if (EQ (f->minibuffer_window, minibuf_window)) 1732 check_minibuf_window (frame, EQ (minibuf_window, selected_window));
1689 {
1690 struct frame *sf = XFRAME (selected_frame);
1691 /* Use set_window_buffer instead of Fset_window_buffer (see
1692 discussion of bug#11984, bug#12025, bug#12026). */
1693 set_window_buffer (sf->minibuffer_window,
1694 XWINDOW (minibuf_window)->contents, 0, 0);
1695 minibuf_window = sf->minibuffer_window;
1696 }
1697 1733
1698 /* I think this should be done with a hook. */ 1734 /* I think this should be done with a hook. */
1699#ifdef HAVE_WINDOW_SYSTEM 1735#ifdef HAVE_WINDOW_SYSTEM
@@ -1716,15 +1752,7 @@ If omitted, FRAME defaults to the currently selected frame. */)
1716 struct frame *f = decode_live_frame (frame); 1752 struct frame *f = decode_live_frame (frame);
1717 1753
1718 /* Don't allow minibuf_window to remain on an iconified frame. */ 1754 /* Don't allow minibuf_window to remain on an iconified frame. */
1719 if (EQ (f->minibuffer_window, minibuf_window)) 1755 check_minibuf_window (frame, EQ (minibuf_window, selected_window));
1720 {
1721 struct frame *sf = XFRAME (selected_frame);
1722 /* Use set_window_buffer instead of Fset_window_buffer (see
1723 discussion of bug#11984, bug#12025, bug#12026). */
1724 set_window_buffer (sf->minibuffer_window,
1725 XWINDOW (minibuf_window)->contents, 0, 0);
1726 minibuf_window = sf->minibuffer_window;
1727 }
1728 1756
1729 /* I think this should be done with a hook. */ 1757 /* I think this should be done with a hook. */
1730#ifdef HAVE_WINDOW_SYSTEM 1758#ifdef HAVE_WINDOW_SYSTEM
@@ -3545,7 +3573,7 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Li
3545 3573
3546 value = x_get_string_resource (rdb, name_key, class_key); 3574 value = x_get_string_resource (rdb, name_key, class_key);
3547 3575
3548 if (value != (char *) 0 && *value) 3576 if (value && *value)
3549 return build_string (value); 3577 return build_string (value);
3550 else 3578 else
3551 return Qnil; 3579 return Qnil;
@@ -4204,8 +4232,7 @@ make_monitor_attribute_list (struct MonitorInfo *monitors,
4204 mi->work.width, mi->work.height); 4232 mi->work.width, mi->work.height);
4205 geometry = list4i (mi->geom.x, mi->geom.y, 4233 geometry = list4i (mi->geom.x, mi->geom.y,
4206 mi->geom.width, mi->geom.height); 4234 mi->geom.width, mi->geom.height);
4207 attributes = Fcons (Fcons (Qsource, 4235 attributes = Fcons (Fcons (Qsource, build_string (source)),
4208 make_string (source, strlen (source))),
4209 attributes); 4236 attributes);
4210 attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)), 4237 attributes = Fcons (Fcons (Qframes, AREF (monitor_frames, i)),
4211 attributes); 4238 attributes);
@@ -4478,6 +4505,7 @@ automatically. See also `mouse-autoselect-window'. */);
4478 defsubr (&Sframe_list); 4505 defsubr (&Sframe_list);
4479 defsubr (&Snext_frame); 4506 defsubr (&Snext_frame);
4480 defsubr (&Sprevious_frame); 4507 defsubr (&Sprevious_frame);
4508 defsubr (&Slast_nonminibuf_frame);
4481 defsubr (&Sdelete_frame); 4509 defsubr (&Sdelete_frame);
4482 defsubr (&Smouse_position); 4510 defsubr (&Smouse_position);
4483 defsubr (&Smouse_pixel_position); 4511 defsubr (&Smouse_pixel_position);