Function: frame-parameters

frame-parameters is a function defined in frame.c.

Signature

(frame-parameters &optional FRAME)

Documentation

Return the parameters-alist of frame FRAME.

It is a list of elements of the form (PARM . VALUE), where PARM is a symbol. The meaningful PARMs depend on the kind of frame. If FRAME is omitted or nil, return information on the currently selected frame.

Source Code

// Defined in /usr/src/emacs/src/frame.c
{
  Lisp_Object alist;
  struct frame *f = decode_any_frame (frame);
  int height, width;

  if (!FRAME_LIVE_P (f))
    return Qnil;

  alist = Fcopy_alist (f->param_alist);

  if (!FRAME_WINDOW_P (f))
    {
      Lisp_Object elt;

      /* 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 (CONSP (elt) && STRINGP (XCDR (elt)))
	{
	  elt = frame_unspecified_color (f, XCDR (elt));
	  if (!NILP (elt))
	    store_in_alist (&alist, Qforeground_color, elt);
	}
      else
	store_in_alist (&alist, Qforeground_color,
			tty_color_name (f, FRAME_FOREGROUND_PIXEL (f)));
      elt = Fassq (Qbackground_color, alist);
      if (CONSP (elt) && STRINGP (XCDR (elt)))
	{
	  elt = frame_unspecified_color (f, XCDR (elt));
	  if (!NILP (elt))
	    store_in_alist (&alist, Qbackground_color, elt);
	}
      else
	store_in_alist (&alist, Qbackground_color,
			tty_color_name (f, FRAME_BACKGROUND_PIXEL (f)));
      store_in_alist (&alist, Qfont,
		      build_string (FRAME_MSDOS_P (f)
				    ? "ms-dos"
				    : FRAME_W32_P (f) ? "w32term"
				    :"tty"));
    }

  store_in_alist (&alist, Qname, f->name);
  /* It's questionable whether here we should report the value of
     f->new_height (and f->new_width below) but we've done that in the
     past, so let's keep it.  Note that a value of -1 for either of
     these means that no new size was requested.

     But check f->new_size before to make sure that f->new_height and
     f->new_width are not ones requested by adjust_frame_size.  */
  height = ((f->new_size_p && f->new_height >= 0)
	    ? f->new_height / FRAME_LINE_HEIGHT (f)
	    : FRAME_LINES (f));
  store_in_alist (&alist, Qheight, make_fixnum (height));
  width = ((f->new_size_p && f->new_width >= 0)
	   ? f->new_width / FRAME_COLUMN_WIDTH (f)
	   : FRAME_COLS(f));
  store_in_alist (&alist, Qwidth, make_fixnum (width));

  store_in_alist (&alist, Qmodeline, FRAME_WANTS_MODELINE_P (f) ? Qt : Qnil);
  store_in_alist (&alist, Qunsplittable, FRAME_NO_SPLIT_P (f) ? Qt : Qnil);
  store_in_alist (&alist, Qbuffer_list, f->buffer_list);
  store_in_alist (&alist, Qburied_buffer_list, f->buried_buffer_list);

  /* I think this should be done with a hook.  */
#ifdef HAVE_WINDOW_SYSTEM
  if (FRAME_WINDOW_P (f))
    gui_report_frame_params (f, &alist);
  else
#endif
    {
      /* This ought to be correct in f->param_alist for an X frame.  */
      Lisp_Object lines;

      XSETFASTINT (lines, FRAME_MENU_BAR_LINES (f));
      store_in_alist (&alist, Qmenu_bar_lines, lines);
      XSETFASTINT (lines, FRAME_TAB_BAR_LINES (f));
      store_in_alist (&alist, Qtab_bar_lines, lines);
    }

  return alist;
}