+ }
+ else
+ tem = Fassq (param, Vdefault_frame_alist);
+
+ /* If it wasn't specified in ALIST or the Lisp-level defaults,
+ look in the X resources. */
+ if (EQ (tem, Qnil))
+ {
+ if (attribute)
+ {
+ tem = display_x_get_resource (dpyinfo,
+ build_string (attribute),
+ build_string (class),
+ Qnil, Qnil);
+
+ if (NILP (tem))
+ return Qunbound;
+
+ switch (type)
+ {
+ case RES_TYPE_NUMBER:
+ return make_number (atoi (SDATA (tem)));
+
+ case RES_TYPE_FLOAT:
+ return make_float (atof (SDATA (tem)));
+
+ case RES_TYPE_BOOLEAN:
+ tem = Fdowncase (tem);
+ if (!strcmp (SDATA (tem), "on")
+ || !strcmp (SDATA (tem), "true"))
+ return Qt;
+ else
+ return Qnil;
+
+ case RES_TYPE_STRING:
+ return tem;
+
+ case RES_TYPE_SYMBOL:
+ /* As a special case, we map the values `true' and `on'
+ to Qt, and `false' and `off' to Qnil. */
+ {
+ Lisp_Object lower;
+ lower = Fdowncase (tem);
+ if (!strcmp (SDATA (lower), "on")
+ || !strcmp (SDATA (lower), "true"))
+ return Qt;
+ else if (!strcmp (SDATA (lower), "off")
+ || !strcmp (SDATA (lower), "false"))
+ return Qnil;
+ else
+ return Fintern (tem, Qnil);
+ }
+
+ default:
+ abort ();
+ }
+ }
+ else
+ return Qunbound;
+ }
+ return Fcdr (tem);
+}
+
+Lisp_Object
+x_frame_get_arg (f, alist, param, attribute, class, type)
+ struct frame *f;
+ Lisp_Object alist, param;
+ char *attribute;
+ char *class;
+ enum resource_types type;
+{
+ return x_get_arg (FRAME_X_DISPLAY_INFO (f),
+ alist, param, attribute, class, type);
+}
+
+/* Like x_frame_get_arg, but also record the value in f->param_alist. */
+
+Lisp_Object
+x_frame_get_and_record_arg (f, alist, param, attribute, class, type)
+ struct frame *f;
+ Lisp_Object alist, param;
+ char *attribute;
+ char *class;
+ enum resource_types type;
+{
+ Lisp_Object value;
+
+ value = x_get_arg (FRAME_X_DISPLAY_INFO (f), alist, param,
+ attribute, class, type);
+ if (! NILP (value) && ! EQ (value, Qunbound))
+ store_frame_param (f, param, value);
+
+ return value;
+}
+
+
+/* Record in frame F the specified or default value according to ALIST
+ of the parameter named PROP (a Lisp symbol).
+ If no value is specified for PROP, look for an X default for XPROP
+ on the frame named NAME.
+ If that is not found either, use the value DEFLT. */
+
+Lisp_Object
+x_default_parameter (f, alist, prop, deflt, xprop, xclass, type)
+ struct frame *f;
+ Lisp_Object alist;
+ Lisp_Object prop;
+ Lisp_Object deflt;
+ char *xprop;
+ char *xclass;
+ enum resource_types type;
+{
+ Lisp_Object tem;
+
+ tem = x_frame_get_arg (f, alist, prop, xprop, xclass, type);
+ if (EQ (tem, Qunbound))
+ tem = deflt;
+ x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil));
+ return tem;
+}
+
+
+
+\f
+DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0,
+ doc: /* Parse an X-style geometry string STRING.
+Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
+The properties returned may include `top', `left', `height', and `width'.
+The value of `left' or `top' may be an integer,
+or a list (+ N) meaning N pixels relative to top/left corner,
+or a list (- N) meaning -N pixels relative to bottom/right corner. */)
+ (string)
+ Lisp_Object string;
+{
+ int geometry, x, y;
+ unsigned int width, height;
+ Lisp_Object result;
+
+ CHECK_STRING (string);
+
+ geometry = XParseGeometry ((char *) SDATA (string),
+ &x, &y, &width, &height);
+
+#if 0
+ if (!!(geometry & XValue) != !!(geometry & YValue))
+ error ("Must specify both x and y position, or neither");
+#endif
+
+ result = Qnil;
+ if (geometry & XValue)
+ {
+ Lisp_Object element;
+
+ if (x >= 0 && (geometry & XNegative))
+ element = Fcons (Qleft, Fcons (Qminus, Fcons (make_number (-x), Qnil)));
+ else if (x < 0 && ! (geometry & XNegative))
+ element = Fcons (Qleft, Fcons (Qplus, Fcons (make_number (x), Qnil)));
+ else
+ element = Fcons (Qleft, make_number (x));
+ result = Fcons (element, result);
+ }
+
+ if (geometry & YValue)
+ {
+ Lisp_Object element;
+
+ if (y >= 0 && (geometry & YNegative))
+ element = Fcons (Qtop, Fcons (Qminus, Fcons (make_number (-y), Qnil)));
+ else if (y < 0 && ! (geometry & YNegative))
+ element = Fcons (Qtop, Fcons (Qplus, Fcons (make_number (y), Qnil)));
+ else
+ element = Fcons (Qtop, make_number (y));
+ result = Fcons (element, result);
+ }
+
+ if (geometry & WidthValue)
+ result = Fcons (Fcons (Qwidth, make_number (width)), result);
+ if (geometry & HeightValue)
+ result = Fcons (Fcons (Qheight, make_number (height)), result);
+
+ return result;
+}
+
+/* Calculate the desired size and position of frame F.
+ Return the flags saying which aspects were specified.
+
+ Also set the win_gravity and size_hint_flags of F.
+
+ Adjust height for toolbar if TOOLBAR_P is 1.
+
+ This function does not make the coordinates positive. */
+
+#define DEFAULT_ROWS 40
+#define DEFAULT_COLS 80
+
+int
+x_figure_window_size (f, parms, toolbar_p)
+ struct frame *f;
+ Lisp_Object parms;
+ int toolbar_p;
+{
+ register Lisp_Object tem0, tem1, tem2;
+ long window_prompting = 0;
+ Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+
+ /* Default values if we fall through.
+ Actually, if that happens we should get
+ window manager prompting. */
+ SET_FRAME_COLS (f, DEFAULT_COLS);
+ FRAME_LINES (f) = DEFAULT_ROWS;
+ /* Window managers expect that if program-specified
+ positions are not (0,0), they're intentional, not defaults. */
+ f->top_pos = 0;
+ f->left_pos = 0;
+
+ /* Ensure that old new_text_cols and new_text_lines will not override the
+ values set here. */
+ /* ++KFS: This was specific to W32, but seems ok for all platforms */
+ f->new_text_cols = f->new_text_lines = 0;
+
+ tem0 = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
+ tem1 = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
+ tem2 = x_get_arg (dpyinfo, parms, Quser_size, 0, 0, RES_TYPE_NUMBER);
+ if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
+ {
+ if (!EQ (tem0, Qunbound))
+ {
+ CHECK_NUMBER (tem0);
+ FRAME_LINES (f) = XINT (tem0);
+ }
+ if (!EQ (tem1, Qunbound))
+ {
+ CHECK_NUMBER (tem1);
+ SET_FRAME_COLS (f, XINT (tem1));
+ }
+ if (!NILP (tem2) && !EQ (tem2, Qunbound))
+ window_prompting |= USSize;
+ else
+ window_prompting |= PSize;
+ }
+
+ f->scroll_bar_actual_width
+ = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
+
+ /* This used to be done _before_ calling x_figure_window_size, but
+ since the height is reset here, this was really a no-op. I
+ assume that moving it here does what Gerd intended (although he
+ no longer can remember what that was... ++KFS, 2003-03-25. */
+
+ /* Add the tool-bar height to the initial frame height so that the
+ user gets a text display area of the size he specified with -g or
+ via .Xdefaults. Later changes of the tool-bar height don't
+ change the frame size. This is done so that users can create
+ tall Emacs frames without having to guess how tall the tool-bar
+ will get. */
+ if (toolbar_p && FRAME_TOOL_BAR_LINES (f))
+ {
+ int margin, relief, bar_height;
+
+ relief = (tool_bar_button_relief >= 0
+ ? tool_bar_button_relief
+ : DEFAULT_TOOL_BAR_BUTTON_RELIEF);
+
+ if (INTEGERP (Vtool_bar_button_margin)
+ && XINT (Vtool_bar_button_margin) > 0)
+ margin = XFASTINT (Vtool_bar_button_margin);
+ else if (CONSP (Vtool_bar_button_margin)
+ && INTEGERP (XCDR (Vtool_bar_button_margin))
+ && XINT (XCDR (Vtool_bar_button_margin)) > 0)
+ margin = XFASTINT (XCDR (Vtool_bar_button_margin));
+ else
+ margin = 0;
+
+ bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;
+ FRAME_LINES (f) += (bar_height + FRAME_LINE_HEIGHT (f) - 1) / FRAME_LINE_HEIGHT (f);
+ }
+
+ compute_fringe_widths (f, 0);
+
+ FRAME_PIXEL_WIDTH (f) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, FRAME_COLS (f));
+ FRAME_PIXEL_HEIGHT (f) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, FRAME_LINES (f));
+
+ tem0 = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
+ tem1 = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
+ tem2 = x_get_arg (dpyinfo, parms, Quser_position, 0, 0, RES_TYPE_NUMBER);
+ if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
+ {
+ if (EQ (tem0, Qminus))
+ {
+ f->top_pos = 0;
+ window_prompting |= YNegative;
+ }
+ else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)
+ && CONSP (XCDR (tem0))
+ && INTEGERP (XCAR (XCDR (tem0))))
+ {
+ f->top_pos = - XINT (XCAR (XCDR (tem0)));
+ window_prompting |= YNegative;
+ }
+ else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)
+ && CONSP (XCDR (tem0))
+ && INTEGERP (XCAR (XCDR (tem0))))
+ {
+ f->top_pos = XINT (XCAR (XCDR (tem0)));
+ }
+ else if (EQ (tem0, Qunbound))
+ f->top_pos = 0;
+ else
+ {
+ CHECK_NUMBER (tem0);
+ f->top_pos = XINT (tem0);
+ if (f->top_pos < 0)
+ window_prompting |= YNegative;
+ }
+
+ if (EQ (tem1, Qminus))
+ {
+ f->left_pos = 0;
+ window_prompting |= XNegative;
+ }
+ else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)
+ && CONSP (XCDR (tem1))
+ && INTEGERP (XCAR (XCDR (tem1))))
+ {
+ f->left_pos = - XINT (XCAR (XCDR (tem1)));
+ window_prompting |= XNegative;
+ }
+ else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)
+ && CONSP (XCDR (tem1))
+ && INTEGERP (XCAR (XCDR (tem1))))
+ {
+ f->left_pos = XINT (XCAR (XCDR (tem1)));
+ }
+ else if (EQ (tem1, Qunbound))
+ f->left_pos = 0;
+ else
+ {
+ CHECK_NUMBER (tem1);
+ f->left_pos = XINT (tem1);
+ if (f->left_pos < 0)
+ window_prompting |= XNegative;
+ }
+
+ if (!NILP (tem2) && ! EQ (tem2, Qunbound))
+ window_prompting |= USPosition;
+ else
+ window_prompting |= PPosition;
+ }
+
+ if (f->want_fullscreen != FULLSCREEN_NONE)
+ {
+ int left, top;
+ int width, height;
+
+ /* It takes both for some WM:s to place it where we want */
+ window_prompting = USPosition | PPosition;
+ x_fullscreen_adjust (f, &width, &height, &top, &left);
+ FRAME_COLS (f) = width;
+ FRAME_LINES (f) = height;
+ FRAME_PIXEL_WIDTH (f) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, width);
+ FRAME_PIXEL_HEIGHT (f) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, height);
+ f->left_pos = left;
+ f->top_pos = top;
+ }
+
+ if (window_prompting & XNegative)
+ {
+ if (window_prompting & YNegative)
+ f->win_gravity = SouthEastGravity;
+ else
+ f->win_gravity = NorthEastGravity;
+ }
+ else
+ {
+ if (window_prompting & YNegative)
+ f->win_gravity = SouthWestGravity;
+ else
+ f->win_gravity = NorthWestGravity;
+ }
+
+ f->size_hint_flags = window_prompting;
+
+ return window_prompting;