+/* Return geometric attributes of FRAME. According to the value of
+ ATTRIBUTES return the outer edges of FRAME (Qouter_edges), the inner
+ edges of FRAME, the root window edges of frame (Qroot_edges). Any
+ other value means to return the geometry as returned by
+ Fx_frame_geometry. */
+static Lisp_Object
+frame_geometry (Lisp_Object frame, Lisp_Object attribute)
+{
+ struct frame *f = decode_live_frame (frame);
+ Lisp_Object fullscreen_symbol = Fframe_parameter (frame, Qfullscreen);
+ bool fullscreen = (EQ (fullscreen_symbol, Qfullboth)
+ || EQ (fullscreen_symbol, Qfullscreen));
+ int border = fullscreen ? 0 : f->border_width;
+ int title_height = fullscreen ? 0 : FRAME_NS_TITLEBAR_HEIGHT (f);
+ int native_width = FRAME_PIXEL_WIDTH (f);
+ int native_height = FRAME_PIXEL_HEIGHT (f);
+ int outer_width = native_width + 2 * border;
+ int outer_height = native_height + 2 * border + title_height;
+ int native_left = f->left_pos + border;
+ int native_top = f->top_pos + border + title_height;
+ int native_right = f->left_pos + outer_width - border;
+ int native_bottom = f->top_pos + outer_height - border;
+ int internal_border_width = FRAME_INTERNAL_BORDER_WIDTH (f);
+ int tool_bar_height = FRAME_TOOLBAR_HEIGHT (f);
+ int tool_bar_width = (tool_bar_height
+ ? outer_width - 2 * internal_border_width
+ : 0);
+
+ /* Construct list. */
+ if (EQ (attribute, Qouter_edges))
+ return list4 (make_number (f->left_pos), make_number (f->top_pos),
+ make_number (f->left_pos + outer_width),
+ make_number (f->top_pos + outer_height));
+ 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 (native_left + internal_border_width),
+ make_number (native_top
+ + tool_bar_height
+ + internal_border_width),
+ make_number (native_right - internal_border_width),
+ make_number (native_bottom - internal_border_width));
+ else
+ return
+ listn (CONSTYPE_HEAP, 10,
+ Fcons (Qouter_position,
+ Fcons (make_number (f->left_pos),
+ make_number (f->top_pos))),
+ Fcons (Qouter_size,
+ Fcons (make_number (outer_width),
+ make_number (outer_height))),
+ Fcons (Qexternal_border_size,
+ (fullscreen
+ ? Fcons (make_number (0), make_number (0))
+ : Fcons (make_number (border), make_number (border)))),
+ Fcons (Qtitle_bar_size,
+ Fcons (make_number (0), make_number (title_height))),
+ Fcons (Qmenu_bar_external, Qnil),
+ Fcons (Qmenu_bar_size, Fcons (make_number (0), make_number (0))),
+ Fcons (Qtool_bar_external,
+ FRAME_EXTERNAL_TOOL_BAR (f) ? 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 ("ns-frame-geometry", Fns_frame_geometry, Sns_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