+#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
+ menu_bar_external = true;
+ menu_bar_height = FRAME_MENUBAR_HEIGHT (f);
+ native_top += menu_bar_height;
+ inner_top += menu_bar_height;
+#else
+ menu_bar_height = FRAME_MENU_BAR_HEIGHT (f);
+ inner_top += menu_bar_height;
+#endif
+ menu_bar_width = menu_bar_height ? native_width : 0;
+
+#if defined (USE_GTK)
+ tool_bar_external = true;
+ if (EQ (FRAME_TOOL_BAR_POSITION (f), Qleft))
+ {
+ tool_bar_width = FRAME_TOOLBAR_WIDTH (f);
+ native_left += tool_bar_width;
+ inner_left += tool_bar_width;
+ tool_bar_height
+ = tool_bar_width ? native_height - menu_bar_height : 0;
+ }
+ else if (EQ (FRAME_TOOL_BAR_POSITION (f), Qtop))
+ {
+ tool_bar_height = FRAME_TOOLBAR_HEIGHT (f);
+ native_top += tool_bar_height;
+ inner_top += tool_bar_height;
+ tool_bar_width = tool_bar_height ? native_width : 0;
+ }
+ else if (EQ (FRAME_TOOL_BAR_POSITION (f), Qright))
+ {
+ tool_bar_width = FRAME_TOOLBAR_WIDTH (f);
+ native_right -= tool_bar_width;
+ inner_right -= tool_bar_width;
+ tool_bar_height
+ = tool_bar_width ? native_height - menu_bar_height : 0;
+ }
+ else
+ {
+ tool_bar_height = FRAME_TOOLBAR_HEIGHT (f);
+ native_bottom -= tool_bar_height;
+ inner_bottom -= tool_bar_height;
+ tool_bar_width = tool_bar_height ? native_width : 0;
+ }
+#else
+ tool_bar_height = FRAME_TOOL_BAR_HEIGHT (f);
+ tool_bar_width = tool_bar_height ? native_width : 0;
+ inner_top += tool_bar_height;
+#endif
+
+ /* Construct list. */
+ if (EQ (attribute, Qouter_edges))
+ return list4 (make_number (outer_left), make_number (outer_top),
+ make_number (outer_right), make_number (outer_bottom));
+ else if (EQ (attribute, Qnative_edges))
+ return list4 (make_number (native_left), make_number (native_top),
+ make_number (native_right), make_number (native_bottom));
+ else if (EQ (attribute, Qinner_edges))
+ return list4 (make_number (inner_left), make_number (inner_top),
+ make_number (inner_right), make_number (inner_bottom));
+ else
+ return
+ listn (CONSTYPE_HEAP, 10,
+ Fcons (Qouter_position,
+ Fcons (make_number (outer_left),
+ make_number (outer_top))),
+ Fcons (Qouter_size,
+ Fcons (make_number (outer_right - outer_left),
+ make_number (outer_bottom - outer_top))),
+ /* Approximate. */
+ Fcons (Qexternal_border_size,
+ Fcons (make_number (right_off),
+ make_number (bottom_off))),
+ /* Approximate. */
+ Fcons (Qtitle_bar_size,
+ Fcons (make_number (0),
+ make_number (top_off - bottom_off))),
+ Fcons (Qmenu_bar_external, menu_bar_external ? Qt : Qnil),
+ Fcons (Qmenu_bar_size,
+ Fcons (make_number (menu_bar_width),
+ make_number (menu_bar_height))),
+ Fcons (Qtool_bar_external, tool_bar_external ? Qt : Qnil),
+ Fcons (Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f)),
+ Fcons (Qtool_bar_size,
+ Fcons (make_number (tool_bar_width),
+ make_number (tool_bar_height))),
+ Fcons (Qinternal_border_width,
+ make_number (internal_border_width)));
+}
+
+DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0,
+ doc: /* Return geometric attributes of FRAME.
+FRAME must be a live frame and defaults to the selected one. The return
+value is an association list of the attributes listed below. All height
+and width values are in pixels.
+
+`outer-position' is a cons of the outer left and top edges of FRAME
+ relative to the origin - the position (0, 0) - of FRAME's display.
+
+`outer-size' is a cons of the outer width and height of FRAME. The
+ outer size includes the title bar and the external borders as well as
+ any menu and/or tool bar of frame.
+
+`external-border-size' is a cons of the horizontal and vertical width of
+ FRAME's external borders as supplied by the window manager.
+
+`title-bar-size' is a cons of the width and height of the title bar of
+ FRAME as supplied by the window manager. If both of them are zero,
+ FRAME has no title bar. If only the width is zero, Emacs was not
+ able to retrieve the width information.
+
+`menu-bar-external', if non-nil, means the menu bar is external (never