/* Generic frame functions.
- Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000 Free Software Foundation.
+ Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001
+ Free Software Foundation.
This file is part of GNU Emacs.
#ifdef WINDOWSNT
#include "w32term.h"
#endif
+#ifdef macintosh
+#include "macterm.h"
+#endif
#include "buffer.h"
/* These help us bind and responding to switch-frame events. */
#include "commands.h"
#include "dosfns.h"
#endif
-#ifdef macintosh
-extern struct mac_output *NewMacWindow ();
-extern void DisposeMacWindow (struct mac_output *);
-#endif
-
-/* Evaluate this expression to rebuild the section of syms_of_frame
- that initializes and staticpros the symbols declared below. Note
- that Emacs 18 has a bug that keeps C-x C-e from being able to
- evaluate this expression.
-
-(progn
- ;; Accumulate a list of the symbols we want to initialize from the
- ;; declarations at the top of the file.
- (goto-char (point-min))
- (search-forward "/\*&&& symbols declared here &&&*\/\n")
- (let (symbol-list)
- (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
- (setq symbol-list
- (cons (buffer-substring (match-beginning 1) (match-end 1))
- symbol-list))
- (forward-line 1))
- (setq symbol-list (nreverse symbol-list))
- ;; Delete the section of syms_of_... where we initialize the symbols.
- (search-forward "\n /\*&&& init symbols here &&&*\/\n")
- (let ((start (point)))
- (while (looking-at "^ Q")
- (forward-line 2))
- (kill-region start (point)))
- ;; Write a new symbol initialization section.
- (while symbol-list
- (insert (format " %s = intern (\"" (car symbol-list)))
- (let ((start (point)))
- (insert (substring (car symbol-list) 1))
- (subst-char-in-region start (point) ?_ ?-))
- (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
- (setq symbol-list (cdr symbol-list)))))
- */
-
-/*&&& symbols declared here &&&*/
Lisp_Object Qframep;
Lisp_Object Qframe_live_p;
Lisp_Object Qheight;
Lisp_Object Qtitle;
Lisp_Object Qdisplay_type;
Lisp_Object Qbackground_mode;
+Lisp_Object Qinhibit_default_face_x_resources;
Lisp_Object Vterminal_frame;
Lisp_Object Vdefault_frame_alist;
Lisp_Object Vmouse_position_function;
-
-static void
-syms_of_frame_1 ()
-{
- /*&&& init symbols here &&&*/
- Qframep = intern ("framep");
- staticpro (&Qframep);
- Qframe_live_p = intern ("frame-live-p");
- staticpro (&Qframe_live_p);
- Qheight = intern ("height");
- staticpro (&Qheight);
- Qicon = intern ("icon");
- staticpro (&Qicon);
- Qminibuffer = intern ("minibuffer");
- staticpro (&Qminibuffer);
- Qmodeline = intern ("modeline");
- staticpro (&Qmodeline);
- Qname = intern ("name");
- staticpro (&Qname);
- Qonly = intern ("only");
- staticpro (&Qonly);
- Qunsplittable = intern ("unsplittable");
- staticpro (&Qunsplittable);
- Qmenu_bar_lines = intern ("menu-bar-lines");
- staticpro (&Qmenu_bar_lines);
- Qtool_bar_lines = intern ("tool-bar-lines");
- staticpro (&Qtool_bar_lines);
- Qwidth = intern ("width");
- staticpro (&Qwidth);
- Qx = intern ("x");
- staticpro (&Qx);
- Qw32 = intern ("w32");
- staticpro (&Qw32);
- Qpc = intern ("pc");
- staticpro (&Qpc);
- Qmac = intern ("mac");
- staticpro (&Qmac);
- Qvisible = intern ("visible");
- staticpro (&Qvisible);
- Qbuffer_predicate = intern ("buffer-predicate");
- staticpro (&Qbuffer_predicate);
- Qbuffer_list = intern ("buffer-list");
- staticpro (&Qbuffer_list);
- Qtitle = intern ("title");
- staticpro (&Qtitle);
- Qdisplay_type = intern ("display-type");
- staticpro (&Qdisplay_type);
- Qbackground_mode = intern ("background-mode");
- staticpro (&Qbackground_mode);
-
- DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
- "Alist of default values for frame creation.\n\
-These may be set in your init file, like this:\n\
- (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))\n\
-These override values given in window system configuration data,\n\
- including X Windows' defaults database.\n\
-For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
-For values specific to the separate minibuffer frame, see\n\
- `minibuffer-frame-alist'.\n\
-The `menu-bar-lines' element of the list controls whether new frames\n\
- have menu bars; `menu-bar-mode' works by altering this element.");
- Vdefault_frame_alist = Qnil;
-}
\f
static void
set_menu_bar_lines_1 (window, n)
register struct frame *f;
register Lisp_Object root_window;
register Lisp_Object mini_window;
- register struct Lisp_Vector *vec;
- int i;
-
- vec = allocate_vectorlike ((EMACS_INT) VECSIZE (struct frame));
- for (i = 0; i < VECSIZE (struct frame); i++)
- XSETFASTINT (vec->contents[i], 0);
- vec->size = VECSIZE (struct frame);
- f = (struct frame *)vec;
+
+ f = allocate_frame ();
XSETFRAME (frame, f);
f->desired_matrix = 0;
f->title = Qnil;
f->menu_bar_window = Qnil;
f->tool_bar_window = Qnil;
- f->desired_tool_bar_items = f->current_tool_bar_items = Qnil;
+ f->tool_bar_items = Qnil;
f->desired_tool_bar_string = f->current_tool_bar_string = Qnil;
- f->n_desired_tool_bar_items = f->n_current_tool_bar_items = 0;
+ f->n_tool_bar_items = 0;
root_window = make_window ();
if (mini_p)
else
f->output_method = output_termcap;
#else
+#ifdef WINDOWSNT
+ f->output_method = output_termcap;
+ f->output_data.x = &tty_display;
+#else
#ifdef macintosh
- f->output_data.mac = NewMacWindow(f);
- f->output_data.mac->background_pixel = 0xffffff;
- f->output_data.mac->foreground_pixel = 0;
- f->output_data.mac->n_param_faces = 0;
- f->output_data.mac->n_computed_faces = 0;
- f->output_data.mac->size_computed_faces = 0;
- f->output_method = output_mac;
- f->auto_raise = 1;
- f->auto_lower = 1;
- init_frame_faces (f);
-#else /* !macintosh */
+ make_mac_terminal_frame (f);
+#else
f->output_data.x = &tty_display;
-#endif /* !macintosh */
+#endif /* macintosh */
+#endif /* WINDOWSNT */
#endif /* MSDOS */
-#ifndef macintosh
if (!noninteractive)
init_frame_faces (f);
-#endif
+
return f;
}
XCDR (XCAR (tem)) = Fcopy_sequence (XCDR (XCAR (tem)));
return frame;
}
+
\f
+/* Perform the switch to frame FRAME.
+
+ If FRAME is a switch-frame event `(switch-frame FRAME1)', use
+ FRAME1 as frame.
+
+ If TRACK is non-zero and the frame that currently has the focus
+ redirects its focus to the selected frame, redirect that focused
+ frame's focus to FRAME instead.
+
+ FOR_DELETION non-zero means that the selected frame is being
+ deleted, which includes the possibility that the frame's display
+ is dead. */
+
Lisp_Object
-do_switch_frame (frame, no_enter, track)
- Lisp_Object frame, no_enter;
- int track;
+do_switch_frame (frame, track, for_deletion)
+ Lisp_Object frame;
+ int track, for_deletion;
{
struct frame *sf = SELECTED_FRAME ();
#else /* ! 0 */
/* Instead, apply it only to the frame we're pointing to. */
#ifdef HAVE_WINDOW_SYSTEM
- if (track && (FRAME_WINDOW_P (XFRAME (frame))))
+ if (track && FRAME_WINDOW_P (XFRAME (frame)))
{
Lisp_Object focus, xfocus;
#endif /* HAVE_X_WINDOWS */
#endif /* ! 0 */
+ if (!for_deletion && FRAME_HAS_MINIBUF_P (sf))
+ resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1);
+
selected_frame = frame;
if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame)))
last_nonminibuf_frame = XFRAME (selected_frame);
(frame, no_enter)
Lisp_Object frame, no_enter;
{
- return do_switch_frame (frame, no_enter, 1);
+ return do_switch_frame (frame, 1, 0);
}
/* Preserve prefix arg that the command loop just cleared. */
current_kboard->Vprefix_arg = Vcurrent_prefix_arg;
call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
- return do_switch_frame (event, no_enter, 0);
+ return do_switch_frame (event, 0, 0);
}
DEFUN ("ignore-event", Fignore_event, Signore_event, 0, 0, "",
"Return a list of all frames.")
()
{
- return Fcopy_sequence (Vframe_list);
+ Lisp_Object frames;
+ frames = Fcopy_sequence (Vframe_list);
+#ifdef HAVE_WINDOW_SYSTEM
+ if (FRAMEP (tip_frame))
+ frames = Fdelq (tip_frame, frames);
+#endif
+ return frames;
}
/* Return the next frame in the frame list after FRAME.
If omitted, FRAME defaults to the selected frame.\n\
A frame may not be deleted if its minibuffer is used by other frames.\n\
Normally, you may not delete a frame if all other frames are invisible,\n\
-but if the second optional argument FORCE is non-nil, you may do so.")
+but if the second optional argument FORCE is non-nil, you may do so.\n\
+\n\
+This function runs `delete-frame-hook' before actually deleting the\n\
+frame. The hook is called with one argument FRAME.")
(frame, force)
Lisp_Object frame, force;
{
if (! FRAME_LIVE_P (f))
return Qnil;
- if (NILP (force) && !other_visible_frames (f))
+ if (NILP (force) && !other_visible_frames (f)
+#ifdef macintosh
+ /* Terminal frame deleted before any other visible frames are
+ created. */
+ && strcmp (XSTRING (f->name)->data, "F1") != 0
+#endif
+ )
error ("Attempt to delete the sole visible or iconified frame");
#if 0
}
}
+ /* Run `delete-frame-hook'. */
+ if (!NILP (Vrun_hooks))
+ {
+ Lisp_Object args[2];
+ args[0] = intern ("delete-frame-hook");
+ args[1] = frame;
+ Frun_hook_with_args (2, args);
+ }
+
minibuffer_selected = EQ (minibuf_window, selected_window);
/* Don't let the frame remain selected. */
}
}
- do_switch_frame (frame1, Qnil, 0);
+ do_switch_frame (frame1, 0, 1);
sf = SELECTED_FRAME ();
}
x_destroy_window (f);
#endif
-/* Done by x_destroy_window above already */
-#if 0
-#ifdef macintosh
- if (FRAME_MAC_P (f))
- DisposeMacWindow (f->output_data.mac);
-#endif
-#endif
-
f->output_data.nothing = 0;
/* If we've deleted the last_nonminibuf_frame, then try to find
If Emacs is running on a mouseless terminal or hasn't been programmed\n\
to read the mouse position, it returns the selected frame for FRAME\n\
and nil for X and Y.\n\
-Runs the abnormal hook `mouse-position-function' with the normal return\n\
-value as argument.")
+If `mouse-position-function' is non-nil, `mouse-position' calls it,\n\
+passing the normal return value to that function as an argument,\n\
+and returns whatever that function returns.")
()
{
FRAME_PTR f;
#if 0 /* This isn't logically necessary, and it can do GC. */
/* Don't let the frame remain selected. */
if (EQ (frame, selected_frame))
- do_switch_frame (next_frame (frame, Qt), Qnil, 0)
+ do_switch_frame (next_frame (frame, Qt), 0, 0)
#endif
/* Don't allow minibuf_window to remain on a deleted frame. */
int height, width;
struct gcpro gcpro1;
- if (EQ (frame, Qnil))
+ if (NILP (frame))
frame = selected_frame;
CHECK_FRAME (frame, 0);
{
int fg = FRAME_FOREGROUND_PIXEL (f);
int bg = FRAME_BACKGROUND_PIXEL (f);
+ Lisp_Object elt;
- store_in_alist (&alist, intern ("foreground-color"),
- tty_color_name (f, fg));
- store_in_alist (&alist, intern ("background-color"),
- tty_color_name (f, bg));
+ /* If the frame's parameter alist says the colors are
+ unspecified and reversed, take the frame's background pixel
+ for foreground and vice versa. */
+ elt = Fassq (Qforeground_color, alist);
+ if (!NILP (elt) && CONSP (elt) && STRINGP (XCDR (elt)))
+ {
+ if (strncmp (XSTRING (XCDR (elt))->data,
+ unspecified_bg,
+ XSTRING (XCDR (elt))->size) == 0)
+ store_in_alist (&alist, Qforeground_color, tty_color_name (f, bg));
+ else if (strncmp (XSTRING (XCDR (elt))->data,
+ unspecified_fg,
+ XSTRING (XCDR (elt))->size) == 0)
+ store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
+ }
+ else
+ store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
+ elt = Fassq (Qbackground_color, alist);
+ if (!NILP (elt) && CONSP (elt) && STRINGP (XCDR (elt)))
+ {
+ if (strncmp (XSTRING (XCDR (elt))->data,
+ unspecified_fg,
+ XSTRING (XCDR (elt))->size) == 0)
+ store_in_alist (&alist, Qbackground_color, tty_color_name (f, fg));
+ else if (strncmp (XSTRING (XCDR (elt))->data,
+ unspecified_bg,
+ XSTRING (XCDR (elt))->size) == 0)
+ store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
+ }
+ else
+ store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
store_in_alist (&alist, intern ("font"),
build_string (FRAME_MSDOS_P (f)
? "ms-dos"
- : FRAME_W32_P (f) ? "w32term" : "tty"));
+ : FRAME_W32_P (f) ? "w32term"
+ :"tty"));
}
store_in_alist (&alist, Qname, f->name);
height = (FRAME_NEW_HEIGHT (f) ? FRAME_NEW_HEIGHT (f) : FRAME_HEIGHT (f));
: FRAME_MINIBUF_ONLY_P (f) ? Qonly
: FRAME_MINIBUF_WINDOW (f)));
store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil));
- store_in_alist (&alist, Qbuffer_list,
- frame_buffer_list (selected_frame));
+ store_in_alist (&alist, Qbuffer_list, frame_buffer_list (frame));
/* I think this should be done with a hook. */
#ifdef HAVE_WINDOW_SYSTEM
{
value = Fassq (parameter, f->param_alist);
if (CONSP (value))
- value = XCDR (value);
+ {
+ value = XCDR (value);
+ /* Fframe_parameters puts the actual fg/bg color names,
+ even if f->param_alist says otherwise. This is
+ important when param_alist's notion of colors is
+ "unspecified". We need to do the same here. */
+ if (STRINGP (value) && !FRAME_WINDOW_P (f))
+ {
+ char *color_name;
+ EMACS_INT csz;
+
+ if (EQ (parameter, Qbackground_color))
+ {
+ color_name = XSTRING (value)->data;
+ csz = XSTRING (value)->size;
+ if (strncmp (color_name, unspecified_bg, csz) == 0)
+ value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f));
+ else if (strncmp (color_name, unspecified_fg, csz) == 0)
+ value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f));
+ }
+ else if (EQ (parameter, Qforeground_color))
+ {
+ color_name = XSTRING (value)->data;
+ csz = XSTRING (value)->size;
+ if (strncmp (color_name, unspecified_fg, csz) == 0)
+ value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f));
+ else if (strncmp (color_name, unspecified_bg, csz) == 0)
+ value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f));
+ }
+ }
+ }
else if (EQ (parameter, Qdisplay_type)
|| EQ (parameter, Qbackground_mode))
/* Avoid consing in frequent cases. */
DEFUN ("modify-frame-parameters", Fmodify_frame_parameters,
Smodify_frame_parameters, 2, 2, 0,
"Modify the parameters of frame FRAME according to ALIST.\n\
+If FRAME is nil, it defaults to the selected frame.\n\
ALIST is an alist of parameters to change and their new values.\n\
Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.\n\
The meaningful PARMs depend on the kind of frame.\n\
{
FRAME_PTR f;
register Lisp_Object tail, prop, val;
+ int count = BINDING_STACK_SIZE ();
+
+ /* Bind this to t to inhibit initialization of the default face from
+ X resources in face-set-after-frame-default. If we don't inhibit
+ this, modifying the `font' frame parameter, for example, while
+ there is a `default.attributeFont' X resource, won't work,
+ because `default's font is reset to the value of the X resource
+ and that resets the `font' frame parameter. */
+ specbind (Qinhibit_default_face_x_resources, Qt);
if (EQ (frame, Qnil))
frame = selected_frame;
IT_set_frame_parameters (f, alist);
else
#endif
-#ifdef macintosh
- if (FRAME_MAC_P (f))
- mac_set_frame_parameters (f, alist);
- else
-#endif
{
int length = XINT (Flength (alist));
}
}
- return Qnil;
+ return unbind_to (count, Qnil);
}
\f
DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
void
syms_of_frame ()
{
- syms_of_frame_1 ();
+ Qframep = intern ("framep");
+ staticpro (&Qframep);
+ Qframe_live_p = intern ("frame-live-p");
+ staticpro (&Qframe_live_p);
+ Qheight = intern ("height");
+ staticpro (&Qheight);
+ Qicon = intern ("icon");
+ staticpro (&Qicon);
+ Qminibuffer = intern ("minibuffer");
+ staticpro (&Qminibuffer);
+ Qmodeline = intern ("modeline");
+ staticpro (&Qmodeline);
+ Qname = intern ("name");
+ staticpro (&Qname);
+ Qonly = intern ("only");
+ staticpro (&Qonly);
+ Qunsplittable = intern ("unsplittable");
+ staticpro (&Qunsplittable);
+ Qmenu_bar_lines = intern ("menu-bar-lines");
+ staticpro (&Qmenu_bar_lines);
+ Qtool_bar_lines = intern ("tool-bar-lines");
+ staticpro (&Qtool_bar_lines);
+ Qwidth = intern ("width");
+ staticpro (&Qwidth);
+ Qx = intern ("x");
+ staticpro (&Qx);
+ Qw32 = intern ("w32");
+ staticpro (&Qw32);
+ Qpc = intern ("pc");
+ staticpro (&Qpc);
+ Qmac = intern ("mac");
+ staticpro (&Qmac);
+ Qvisible = intern ("visible");
+ staticpro (&Qvisible);
+ Qbuffer_predicate = intern ("buffer-predicate");
+ staticpro (&Qbuffer_predicate);
+ Qbuffer_list = intern ("buffer-list");
+ staticpro (&Qbuffer_list);
+ Qtitle = intern ("title");
+ staticpro (&Qtitle);
+ Qdisplay_type = intern ("display-type");
+ staticpro (&Qdisplay_type);
+ Qbackground_mode = intern ("background-mode");
+ staticpro (&Qbackground_mode);
- staticpro (&Vframe_list);
+ DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
+ "Alist of default values for frame creation.\n\
+These may be set in your init file, like this:\n\
+ (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))\n\
+These override values given in window system configuration data,\n\
+ including X Windows' defaults database.\n\
+For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
+For values specific to the separate minibuffer frame, see\n\
+ `minibuffer-frame-alist'.\n\
+The `menu-bar-lines' element of the list controls whether new frames\n\
+ have menu bars; `menu-bar-mode' works by altering this element.");
+ Vdefault_frame_alist = Qnil;
+
+ Qinhibit_default_face_x_resources
+ = intern ("inhibit-default-face-x-resources");
+ staticpro (&Qinhibit_default_face_x_resources);
DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
"The initial frame-object, which represents Emacs's stdout.");
Vemacs_iconified = Qnil;
DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function,
- "If non-nil, function applied to the normal result of `mouse-position'.\n\
-This abnormal hook exists for the benefit of packages like XTerm-mouse\n\
+ "If non-nil, function to transform normal value of `mouse-position'.\n\
+`mouse-position' calls this function, passing its usual return value as\n\
+argument, and returns whatever this function returns.\n\
+This abnormal hook exists for the benefit of packages like `xt-mouse.el'\n\
which need to do mouse handling at the Lisp level.");
Vmouse_position_function = Qnil;
current set of frames, or where the minibuffer is currently being\n\
displayed.");
+ staticpro (&Vframe_list);
+
defsubr (&Sactive_minibuffer_window);
defsubr (&Sframep);
defsubr (&Sframe_live_p);