Commit 56f2de10 authored by Martin Rudalics's avatar Martin Rudalics
Browse files

* frame.c (delete_frame): New function derived from

Fdelete_frame to handle Qnoelisp value for FORCE argument.
Delete last frame iff FORCE equals Qnoelisp.  (Bug#1450)
(Fdelete_frame): Call delete_frame.  Remove line from doc-string
saying that FORCE non-nil doesn't run `delete-frame-functions'.
* frame.h: Extern delete_frame.
* window.c (window_loop):
* terminal.c (delete_terminal):
* xterm.c (x_connection_closed):
* xfns.c (Fx_hide_tip):
* w32fns.c (Fx_hide_tip): Call delete_frame instead of
Fdelete_frame.
parent caf857eb
2008-12-22 Martin Rudalics <rudalics@gmx.at>
* frame.c (delete_frame): New function derived from
Fdelete_frame to handle Qnoelisp value for FORCE argument.
Delete last frame iff FORCE equals Qnoelisp. (Bug#1450)
(Fdelete_frame): Call delete_frame. Remove line from doc-string
saying that FORCE non-nil doesn't run `delete-frame-functions'.
* frame.h: Extern delete_frame.
* window.c (window_loop):
* terminal.c (delete_terminal):
* xterm.c (x_connection_closed):
* xfns.c (Fx_hide_tip):
* w32fns.c (Fx_hide_tip): Call delete_frame instead of
Fdelete_frame.
2008-12-21 Jason Rumney <jasonr@gnu.org> 2008-12-21 Jason Rumney <jasonr@gnu.org>
   
* w32uniscribe.c (uniscribe_encode_char): Return FONT_INVALID_CHAR * w32uniscribe.c (uniscribe_encode_char): Return FONT_INVALID_CHAR
......
...@@ -1322,20 +1322,13 @@ delete_frame_handler (Lisp_Object arg) ...@@ -1322,20 +1322,13 @@ delete_frame_handler (Lisp_Object arg)
extern Lisp_Object Qrun_hook_with_args; extern Lisp_Object Qrun_hook_with_args;
DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "", /* Delete FRAME. When FORCE equals Qnoelisp, delete FRAME
doc: /* Delete FRAME, permanently eliminating it from use. unconditionally. x_connection_closed and delete_terminal use
If omitted, FRAME defaults to the selected frame. this. Any other value of FORCE implements the semantics
A frame may not be deleted if its minibuffer is used by other frames. described for Fdelete_frame. */
Normally, you may not delete a frame if all other frames are invisible, Lisp_Object
but if the second optional argument FORCE is non-nil, you may do so. delete_frame (frame, force)
register Lisp_Object frame, force;
This function runs `delete-frame-functions' before actually deleting the
frame, unless the frame is a tooltip.
The functions are run with one arg, the frame to be deleted.
But FORCE inhibits this too. */)
/* FORCE is non-nil when handling a disconnected terminal. */
(frame, force)
Lisp_Object frame, force;
{ {
struct frame *f; struct frame *f;
struct frame *sf = SELECTED_FRAME (); struct frame *sf = SELECTED_FRAME ();
...@@ -1360,12 +1353,10 @@ But FORCE inhibits this too. */) ...@@ -1360,12 +1353,10 @@ But FORCE inhibits this too. */)
if (NILP (force) && !other_visible_frames (f)) if (NILP (force) && !other_visible_frames (f))
error ("Attempt to delete the sole visible or iconified frame"); error ("Attempt to delete the sole visible or iconified frame");
#if 0 /* x_connection_closed must have set FORCE to `noelisp' in order
/* This is a nice idea, but x_connection_closed needs to be able
to delete the last frame, if it is gone. */ to delete the last frame, if it is gone. */
if (NILP (XCDR (Vframe_list))) if (NILP (XCDR (Vframe_list)) && !EQ (force, Qnoelisp))
error ("Attempt to delete the only frame"); error ("Attempt to delete the only frame");
#endif
/* Does this frame have a minibuffer, and is it the surrogate /* Does this frame have a minibuffer, and is it the surrogate
minibuffer for any other frame? */ minibuffer for any other frame? */
...@@ -1385,19 +1376,20 @@ But FORCE inhibits this too. */) ...@@ -1385,19 +1376,20 @@ But FORCE inhibits this too. */)
WINDOW_FRAME (XWINDOW WINDOW_FRAME (XWINDOW
(FRAME_MINIBUF_WINDOW (XFRAME (this)))))) (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
{ {
/* If we MUST delete this frame, delete the other first. */ /* If we MUST delete this frame, delete the other first.
if (!NILP (force)) But do this only if FORCE equals `noelisp'. */
Fdelete_frame (this, force); if (EQ (force, Qnoelisp))
delete_frame (this, Qnoelisp);
else else
error ("Attempt to delete a surrogate minibuffer frame"); error ("Attempt to delete a surrogate minibuffer frame");
} }
} }
} }
/* Run `delete-frame-functions' /* Run `delete-frame-functions' unless FORCE is `noelisp' or
unless FORCE is `noelisp' or frame is a tooltip. frame is a tooltip. FORCE is set to `noelisp' when handling
FORCE is set to `noelisp' when handling a disconnect from the terminal, a disconnect from the terminal, so we don't dare call Lisp
so we don't dare call Lisp code. */ code. */
if (NILP (Vrun_hooks) || !NILP (Fframe_parameter (frame, intern ("tooltip")))) if (NILP (Vrun_hooks) || !NILP (Fframe_parameter (frame, intern ("tooltip"))))
; ;
if (EQ (force, Qnoelisp)) if (EQ (force, Qnoelisp))
...@@ -1641,6 +1633,24 @@ But FORCE inhibits this too. */) ...@@ -1641,6 +1633,24 @@ But FORCE inhibits this too. */)
return Qnil; return Qnil;
} }
DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "",
doc: /* Delete FRAME, permanently eliminating it from use.
FRAME defaults to the selected frame.
A frame may not be deleted if its minibuffer is used by other frames.
Normally, you may not delete a frame if all other frames are invisible,
but if the second optional argument FORCE is non-nil, you may do so.
This function runs `delete-frame-functions' before actually
deleting the frame, unless the frame is a tooltip.
The functions are run with one argument, the frame to be deleted. */)
(frame, force)
Lisp_Object frame, force;
{
return delete_frame (frame, !NILP (force) ? Qt : Qnil);
}
/* Return mouse position in character cell units. */ /* Return mouse position in character cell units. */
......
...@@ -1115,6 +1115,7 @@ extern Lisp_Object display_x_get_resource (Display_Info *, ...@@ -1115,6 +1115,7 @@ extern Lisp_Object display_x_get_resource (Display_Info *,
Lisp_Object component, Lisp_Object component,
Lisp_Object subclass); Lisp_Object subclass);
extern Lisp_Object delete_frame P_ ((Lisp_Object, Lisp_Object));
#endif /* HAVE_WINDOW_SYSTEM */ #endif /* HAVE_WINDOW_SYSTEM */
......
...@@ -256,7 +256,7 @@ delete_terminal (struct terminal *terminal) ...@@ -256,7 +256,7 @@ delete_terminal (struct terminal *terminal)
struct terminal **tp; struct terminal **tp;
Lisp_Object tail, frame; Lisp_Object tail, frame;
/* Protect against recursive calls. Fdelete_frame calls the /* Protect against recursive calls. delete_frame calls the
delete_terminal_hook when we delete our last frame. */ delete_terminal_hook when we delete our last frame. */
if (!terminal->name) if (!terminal->name)
return; return;
...@@ -269,8 +269,8 @@ delete_terminal (struct terminal *terminal) ...@@ -269,8 +269,8 @@ delete_terminal (struct terminal *terminal)
struct frame *f = XFRAME (frame); struct frame *f = XFRAME (frame);
if (FRAME_LIVE_P (f) && f->terminal == terminal) if (FRAME_LIVE_P (f) && f->terminal == terminal)
{ {
/* Maybe this should pass Qnoelisp rather than Qt? */ /* Pass Qnoelisp rather than Qt. */
Fdelete_frame (frame, Qt); delete_frame (frame, Qnoelisp);
} }
} }
...@@ -283,7 +283,7 @@ delete_terminal (struct terminal *terminal) ...@@ -283,7 +283,7 @@ delete_terminal (struct terminal *terminal)
terminal->keyboard_coding = NULL; terminal->keyboard_coding = NULL;
xfree (terminal->terminal_coding); xfree (terminal->terminal_coding);
terminal->terminal_coding = NULL; terminal->terminal_coding = NULL;
if (terminal->kboard && --terminal->kboard->reference_count == 0) if (terminal->kboard && --terminal->kboard->reference_count == 0)
{ {
delete_kboard (terminal->kboard); delete_kboard (terminal->kboard);
...@@ -315,7 +315,7 @@ but if the second argument FORCE is non-nil, you may do so. */) ...@@ -315,7 +315,7 @@ but if the second argument FORCE is non-nil, you may do so. */)
struct terminal *p = terminal_list; struct terminal *p = terminal_list;
while (p && (p == t || !TERMINAL_ACTIVE_P (p))) while (p && (p == t || !TERMINAL_ACTIVE_P (p)))
p = p->next_terminal; p = p->next_terminal;
if (!p) if (!p)
error ("Attempt to delete the sole active display terminal"); error ("Attempt to delete the sole active display terminal");
} }
...@@ -376,7 +376,7 @@ possible return values. */) ...@@ -376,7 +376,7 @@ possible return values. */)
Lisp_Object object; Lisp_Object object;
{ {
struct terminal *t; struct terminal *t;
t = get_terminal (object, 0); t = get_terminal (object, 0);
if (!t) if (!t)
......
...@@ -5944,7 +5944,7 @@ Value is t if tooltip was open, nil otherwise. */) ...@@ -5944,7 +5944,7 @@ Value is t if tooltip was open, nil otherwise. */)
if (FRAMEP (frame)) if (FRAMEP (frame))
{ {
Fdelete_frame (frame, Qnil); delete_frame (frame, Qnil);
deleted = Qt; deleted = Qt;
} }
......
...@@ -2273,7 +2273,7 @@ window_loop (type, obj, mini, frames) ...@@ -2273,7 +2273,7 @@ window_loop (type, obj, mini, frames)
windows = XCDR (windows); windows = XCDR (windows);
/* Now we can safely delete the frame. */ /* Now we can safely delete the frame. */
Fdelete_frame (w->frame, Qnil); delete_frame (w->frame, Qnil);
} }
else if (NILP (w->parent)) else if (NILP (w->parent))
{ {
...@@ -2334,7 +2334,7 @@ window_loop (type, obj, mini, frames) ...@@ -2334,7 +2334,7 @@ window_loop (type, obj, mini, frames)
windows = XCDR (windows); windows = XCDR (windows);
/* Now we can safely delete the frame. */ /* Now we can safely delete the frame. */
Fdelete_frame (w->frame, Qnil); delete_frame (w->frame, Qnil);
} }
else if (!NILP (w->dedicated) && !NILP (w->parent)) else if (!NILP (w->dedicated) && !NILP (w->parent))
{ {
...@@ -6909,7 +6909,7 @@ foreach_window (f, fn, user_data) ...@@ -6909,7 +6909,7 @@ foreach_window (f, fn, user_data)
int (* fn) P_ ((struct window *, void *)); int (* fn) P_ ((struct window *, void *));
void *user_data; void *user_data;
{ {
/* Fdelete_frame may set FRAME_ROOT_WINDOW (f) to Qnil. */ /* delete_frame may set FRAME_ROOT_WINDOW (f) to Qnil. */
if (WINDOWP (FRAME_ROOT_WINDOW (f))) if (WINDOWP (FRAME_ROOT_WINDOW (f)))
foreach_window_1 (XWINDOW (FRAME_ROOT_WINDOW (f)), fn, user_data); foreach_window_1 (XWINDOW (FRAME_ROOT_WINDOW (f)), fn, user_data);
} }
......
...@@ -5248,7 +5248,7 @@ Value is t if tooltip was open, nil otherwise. */) ...@@ -5248,7 +5248,7 @@ Value is t if tooltip was open, nil otherwise. */)
if (FRAMEP (frame)) if (FRAMEP (frame))
{ {
Fdelete_frame (frame, Qnil); delete_frame (frame, Qnil);
deleted = Qt; deleted = Qt;
#ifdef USE_LUCID #ifdef USE_LUCID
......
...@@ -4017,7 +4017,7 @@ x_window_to_scroll_bar (display, window_id) ...@@ -4017,7 +4017,7 @@ x_window_to_scroll_bar (display, window_id)
if (! FRAME_X_P (XFRAME (frame))) if (! FRAME_X_P (XFRAME (frame)))
continue; continue;
/* Scan this frame's scroll bar list for a scroll bar with the /* Scan this frame's scroll bar list for a scroll bar with the
right window ID. */ right window ID. */
condemned = FRAME_CONDEMNED_SCROLL_BARS (XFRAME (frame)); condemned = FRAME_CONDEMNED_SCROLL_BARS (XFRAME (frame));
...@@ -6467,7 +6467,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) ...@@ -6467,7 +6467,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
inev.ie.code = XFASTINT (c); inev.ie.code = XFASTINT (c);
goto done_keysym; goto done_keysym;
} }
/* Random non-modifier sorts of keysyms. */ /* Random non-modifier sorts of keysyms. */
if (((keysym >= XK_BackSpace && keysym <= XK_Escape) if (((keysym >= XK_BackSpace && keysym <= XK_Escape)
|| keysym == XK_Delete || keysym == XK_Delete
...@@ -7172,7 +7172,7 @@ XTread_socket (terminal, expected, hold_quit) ...@@ -7172,7 +7172,7 @@ XTread_socket (terminal, expected, hold_quit)
XTread_socket_fake_io_error = 0; XTread_socket_fake_io_error = 0;
x_io_error_quitter (terminal->display_info.x->display); x_io_error_quitter (terminal->display_info.x->display);
} }
#if 0 /* This loop is a noop now. */ #if 0 /* This loop is a noop now. */
/* Find the display we are supposed to read input for. /* Find the display we are supposed to read input for.
It's the one communicating on descriptor SD. */ It's the one communicating on descriptor SD. */
...@@ -7871,7 +7871,7 @@ x_connection_closed (dpy, error_message) ...@@ -7871,7 +7871,7 @@ x_connection_closed (dpy, error_message)
dpyinfo->reference_count++; dpyinfo->reference_count++;
dpyinfo->terminal->reference_count++; dpyinfo->terminal->reference_count++;
} }
/* First delete frames whose mini-buffers are on frames /* First delete frames whose mini-buffers are on frames
that are on the dead display. */ that are on the dead display. */
FOR_EACH_FRAME (tail, frame) FOR_EACH_FRAME (tail, frame)
...@@ -7883,7 +7883,7 @@ x_connection_closed (dpy, error_message) ...@@ -7883,7 +7883,7 @@ x_connection_closed (dpy, error_message)
&& FRAME_X_P (XFRAME (minibuf_frame)) && FRAME_X_P (XFRAME (minibuf_frame))
&& ! EQ (frame, minibuf_frame) && ! EQ (frame, minibuf_frame)
&& FRAME_X_DISPLAY_INFO (XFRAME (minibuf_frame)) == dpyinfo) && FRAME_X_DISPLAY_INFO (XFRAME (minibuf_frame)) == dpyinfo)
Fdelete_frame (frame, Qnoelisp); delete_frame (frame, Qnoelisp);
} }
/* Now delete all remaining frames on the dead display. /* Now delete all remaining frames on the dead display.
...@@ -7893,10 +7893,10 @@ x_connection_closed (dpy, error_message) ...@@ -7893,10 +7893,10 @@ x_connection_closed (dpy, error_message)
if (FRAME_X_P (XFRAME (frame)) if (FRAME_X_P (XFRAME (frame))
&& FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo) && FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo)
{ {
/* Set this to t so that Fdelete_frame won't get confused /* Set this to t so that delete_frame won't get confused
trying to find a replacement. */ trying to find a replacement. */
FRAME_KBOARD (XFRAME (frame))->Vdefault_minibuffer_frame = Qt; FRAME_KBOARD (XFRAME (frame))->Vdefault_minibuffer_frame = Qt;
Fdelete_frame (frame, Qnoelisp); delete_frame (frame, Qnoelisp);
} }
/* We have to close the display to inform Xt that it doesn't /* We have to close the display to inform Xt that it doesn't
...@@ -10170,7 +10170,7 @@ x_term_init (display_name, xrm_option, resource_name) ...@@ -10170,7 +10170,7 @@ x_term_init (display_name, xrm_option, resource_name)
terminal->name = (char *) xmalloc (SBYTES (display_name) + 1); terminal->name = (char *) xmalloc (SBYTES (display_name) + 1);
strncpy (terminal->name, SDATA (display_name), SBYTES (display_name)); strncpy (terminal->name, SDATA (display_name), SBYTES (display_name));
terminal->name[SBYTES (display_name)] = 0; terminal->name[SBYTES (display_name)] = 0;
#if 0 #if 0
XSetAfterFunction (x_current_display, x_trace_wire); XSetAfterFunction (x_current_display, x_trace_wire);
#endif /* ! 0 */ #endif /* ! 0 */
...@@ -10622,7 +10622,7 @@ x_delete_terminal (struct terminal *terminal) ...@@ -10622,7 +10622,7 @@ x_delete_terminal (struct terminal *terminal)
struct x_display_info *dpyinfo = terminal->display_info.x; struct x_display_info *dpyinfo = terminal->display_info.x;
int i; int i;
/* Protect against recursive calls. Fdelete_frame in /* Protect against recursive calls. delete_frame in
delete_terminal calls us back when it deletes our last frame. */ delete_terminal calls us back when it deletes our last frame. */
if (!terminal->name) if (!terminal->name)
return; return;
...@@ -10664,7 +10664,7 @@ static struct terminal * ...@@ -10664,7 +10664,7 @@ static struct terminal *
x_create_terminal (struct x_display_info *dpyinfo) x_create_terminal (struct x_display_info *dpyinfo)
{ {
struct terminal *terminal; struct terminal *terminal;
terminal = create_terminal (); terminal = create_terminal ();
terminal->type = output_x_window; terminal->type = output_x_window;
...@@ -10672,7 +10672,7 @@ x_create_terminal (struct x_display_info *dpyinfo) ...@@ -10672,7 +10672,7 @@ x_create_terminal (struct x_display_info *dpyinfo)
dpyinfo->terminal = terminal; dpyinfo->terminal = terminal;
/* kboard is initialized in x_term_init. */ /* kboard is initialized in x_term_init. */
terminal->clear_frame_hook = x_clear_frame; terminal->clear_frame_hook = x_clear_frame;
terminal->ins_del_lines_hook = x_ins_del_lines; terminal->ins_del_lines_hook = x_ins_del_lines;
terminal->delete_glyphs_hook = x_delete_glyphs; terminal->delete_glyphs_hook = x_delete_glyphs;
...@@ -10695,7 +10695,7 @@ x_create_terminal (struct x_display_info *dpyinfo) ...@@ -10695,7 +10695,7 @@ x_create_terminal (struct x_display_info *dpyinfo)
terminal->delete_frame_hook = x_destroy_window; terminal->delete_frame_hook = x_destroy_window;
terminal->delete_terminal_hook = x_delete_terminal; terminal->delete_terminal_hook = x_delete_terminal;
terminal->rif = &x_redisplay_interface; terminal->rif = &x_redisplay_interface;
terminal->scroll_region_ok = 1; /* We'll scroll partial frames. */ terminal->scroll_region_ok = 1; /* We'll scroll partial frames. */
terminal->char_ins_del_ok = 1; terminal->char_ins_del_ok = 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment