Implement x-frame-geometry for NS.

* src/nsfns.m (Fx_frame_geometry): New function.
(syms_of_nsfns): Defsubr Sx_frame_geometry.
This commit is contained in:
Jan D
2015-02-22 17:24:32 +01:00
parent 32af8a39c4
commit 9f5a24a6fd
2 changed files with 87 additions and 0 deletions

View File

@@ -1,3 +1,8 @@
2015-02-22 Jan Djärv <jan.h.d@swipnet.se>
* nsfns.m (Fx_frame_geometry): New function.
(syms_of_nsfns): Defsubr Sx_frame_geometry.
2015-02-22 Paul Eggert <eggert@cs.ucla.edu>
Spelling fixes

View File

@@ -2806,6 +2806,87 @@ Value is t if tooltip was open, nil otherwise. */)
return Qt;
}
DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0,
doc: /* Return geometric attributes of frame FRAME.
FRAME must be a live frame and defaults to the selected one.
The return value is an association list containing the following
elements (all size values are in pixels).
- `frame-outer-size' is a cons of the outer width and height of FRAME.
The outer size include the title bar and the external borders as well
as any menu and/or tool bar of frame.
- `border' is a cons of the horizontal and vertical width of FRAME's
external borders.
- `title-bar-height' is the height of the title bar of FRAME.
- `menu-bar-external' if `t' means the menu bar is external (not
included in the inner edges of FRAME).
- `menu-bar-size' is a cons of the width and height of the menu bar of
FRAME.
- `tool-bar-external' if `t' means the tool bar is external (not
included in the inner edges of FRAME).
- `tool-bar-side' tells tells on which side the tool bar on FRAME is and
can be one of `left', `top', `right' or `bottom'.
- `tool-bar-size' is a cons of the width and height of the tool bar of
FRAME.
- `frame-inner-size' is a cons of the inner width and height of FRAME.
This excludes FRAME's title bar and external border as well as any
external menu and/or tool bar. */)
(Lisp_Object frame)
{
struct frame *f = decode_live_frame (frame);
int inner_width = FRAME_PIXEL_WIDTH (f);
int inner_height = FRAME_PIXEL_HEIGHT (f);
Lisp_Object fullscreen = Fframe_parameter (frame, Qfullscreen);
int border = f->border_width;
int title = FRAME_NS_TITLEBAR_HEIGHT (f);
int outer_width = FRAME_PIXEL_WIDTH (f) + 2 * border;
int outer_height = FRAME_PIXEL_HEIGHT (f) + 2 * border;
int tool_bar_height = FRAME_TOOLBAR_HEIGHT (f);
int tool_bar_width = tool_bar_height > 0
? outer_width - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)
: 0;
// Always 0 on NS.
int menu_bar_height = 0;
int menu_bar_width = 0;
return
listn (CONSTYPE_HEAP, 10,
Fcons (Qframe_position,
Fcons (make_number (f->left_pos), make_number (f->top_pos))),
Fcons (Qframe_outer_size,
Fcons (make_number (outer_width), make_number (outer_height))),
Fcons (Qexternal_border_size,
((EQ (fullscreen, Qfullboth) || EQ (fullscreen, Qfullscreen))
? Fcons (make_number (0), make_number (0))
: Fcons (make_number (border), make_number (border)))),
Fcons (Qtitle_height,
((EQ (fullscreen, Qfullboth) || EQ (fullscreen, Qfullscreen))
? make_number (0)
: make_number (title))),
Fcons (Qmenu_bar_external, FRAME_EXTERNAL_MENU_BAR (f) ? Qt : Qnil),
Fcons (Qmenu_bar_size,
Fcons (make_number (menu_bar_width),
make_number (menu_bar_height))),
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 (Qframe_inner_size,
Fcons (make_number (inner_width),
make_number (inner_height))));
}
/* ==========================================================================
@@ -2989,6 +3070,7 @@ be used as the image of the icon representing the frame. */);
defsubr (&Sx_display_pixel_width);
defsubr (&Sx_display_pixel_height);
defsubr (&Sns_display_monitor_attributes_list);
defsubr (&Sx_frame_geometry);
defsubr (&Sx_display_mm_width);
defsubr (&Sx_display_mm_height);
defsubr (&Sx_display_screens);