Commit c29a51df authored by Martin Rudalics's avatar Martin Rudalics

Rewrite and add frame geometry related functions.

* src/frame.c (Fframe_position): New function.
(Fset_frame_position): Rename parameters and rewrite doc-string.
(syms_of_frame): Remove Qframe_position, Qframe_outer_size,
Qtitle_height and Qframe_inner_size.  Add Qouter_edges,
Qouter_position, Qouter_size, Qnative_edges, Qinner_edges,
Qtitle_bar_size.
* src/nsfns.m (frame_geometry): New function.
(Fx_frame_geometry): Call frame_geometry.
(Fx_frame_edges): New function.
* src/w32fns.c (C_CHILDREN_TITLEBAR, TITLEBAR_INFO)
(GetTitleBarInfo_Proc): Define these so we can use the
GetTitleBarInfo API.
(Fw32_frame_menu_bar_size, Fw32_frame_rect): Remove.
(Fx_frame_geometry): Rewrite.
(Fx_frame_edges, Fx_mouse_absolute_pixel_position)
(Fx_set_mouse_absolute_pixel_position): New functions.
* src/xfns.c (frame_geometry): New function.
(Fx_frame_geometry): Call frame_geometry.
(Fx_frame_edges, Fx_mouse_absolute_pixel_position)
(Fx_set_mouse_absolute_pixel_position): New functions.
parent ab759c22
......@@ -2977,24 +2977,40 @@ font height. */)
return Qnil;
}
DEFUN ("frame-position", Fframe_position,
Sframe_position, 0, 1, 0,
doc: /* Return top left corner of FRAME in pixels.
FRAME must be a live frame and defaults to the selected one. The return
value is a cons (x, y) of the coordinates of the top left corner of
FRAME's outer frame, in pixels relative to an origin (0, 0) of FRAME's
display. */)
(Lisp_Object frame)
{
register struct frame *f = decode_live_frame (frame);
return Fcons (make_number (f->left_pos), make_number (f->top_pos));
}
DEFUN ("set-frame-position", Fset_frame_position,
Sset_frame_position, 3, 3, 0,
doc: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET.
If FRAME is nil, the selected frame is used. XOFFSET and YOFFSET are
actually the position of the upper left corner of the frame. Negative
values for XOFFSET or YOFFSET are interpreted relative to the rightmost
or bottommost possible position (that stays within the screen). */)
(Lisp_Object frame, Lisp_Object xoffset, Lisp_Object yoffset)
doc: /* Set position of FRAME to (X, Y).
FRAME must be a live frame and defaults to the selected one. X and Y,
if positive, specify the coordinate of the left and top edge of FRAME's
outer frame in pixels relative to an origin (0, 0) of FRAME's display.
If any of X or Y is negative, it specifies the coordinates of the right
or bottom edge of the outer frame of FRAME relative to the right or
bottom edge of FRAME's display. */)
(Lisp_Object frame, Lisp_Object x, Lisp_Object y)
{
register struct frame *f = decode_live_frame (frame);
CHECK_TYPE_RANGED_INTEGER (int, xoffset);
CHECK_TYPE_RANGED_INTEGER (int, yoffset);
CHECK_TYPE_RANGED_INTEGER (int, x);
CHECK_TYPE_RANGED_INTEGER (int, y);
/* I think this should be done with a hook. */
#ifdef HAVE_WINDOW_SYSTEM
if (FRAME_WINDOW_P (f))
x_set_offset (f, XINT (xoffset), XINT (yoffset), 1);
x_set_offset (f, XINT (x), XINT (y), 1);
#endif
return Qt;
......@@ -4890,15 +4906,17 @@ syms_of_frame (void)
DEFSYM (Qframes, "frames");
DEFSYM (Qsource, "source");
DEFSYM (Qframe_position, "frame-position");
DEFSYM (Qframe_outer_size, "frame-outer-size");
DEFSYM (Qouter_edges, "outer-edges");
DEFSYM (Qouter_position, "outer-position");
DEFSYM (Qouter_size, "outer-size");
DEFSYM (Qnative_edges, "native-edges");
DEFSYM (Qinner_edges, "inner-edges");
DEFSYM (Qexternal_border_size, "external-border-size");
DEFSYM (Qtitle_height, "title-height");
DEFSYM (Qtitle_bar_size, "title-bar-size");
DEFSYM (Qmenu_bar_external, "menu-bar-external");
DEFSYM (Qmenu_bar_size, "menu-bar-size");
DEFSYM (Qtool_bar_external, "tool-bar-external");
DEFSYM (Qtool_bar_size, "tool-bar-size");
DEFSYM (Qframe_inner_size, "frame-inner-size");
/* The following are used for frame_size_history. */
DEFSYM (Qadjust_frame_size_1, "adjust-frame-size-1");
DEFSYM (Qadjust_frame_size_2, "adjust-frame-size-2");
......@@ -5263,6 +5281,7 @@ in a more readable form. */);
defsubr (&Sset_frame_height);
defsubr (&Sset_frame_width);
defsubr (&Sset_frame_size);
defsubr (&Sframe_position);
defsubr (&Sset_frame_position);
defsubr (&Sframe_pointer_visible_p);
......
......@@ -2836,91 +2836,142 @@ with offset DY added (default is -10).
return Qt;
}
DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0,
doc: /* Return geometric attributes of frame FRAME.
/* 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)));
}
FRAME must be a live frame and defaults to the selected one.
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.
The return value is an association list containing the following
elements (all size 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.
- `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.
`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.
- `border' is a cons of the horizontal and vertical width of FRAME's
external borders.
`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-height' is the height of the title bar of FRAME.
`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 t means the menu bar is external (not
`menu-bar-external', if non-nil, means the menu bar is external (never
included in the inner edges of FRAME).
- `menu-bar-size' is a cons of the width and height of the menu bar of
`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
`tool-bar-external', if non-nil, means the tool bar is external (never
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-position' tells on which side the tool bar on FRAME is and can
be one of `left', `top', `right' or `bottom'. If this is nil, FRAME
has no tool bar.
- `tool-bar-size' is a cons of the width and height of the tool bar of
`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. */)
`internal-border-width' is the width of the internal border of
FRAME. */)
(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, title, outer_width, outer_height;
int tool_bar_height, tool_bar_width;
// Always 0 on NS.
int menu_bar_height = 0;
int menu_bar_width = 0;
if (FRAME_INITIAL_P (f) || !FRAME_NS_P (f))
return Qnil;
return frame_geometry (frame, Qnil);
}
DEFUN ("x-frame-edges", Fx_frame_edges, Sx_frame_edges, 0, 2, 0,
doc: /* Return edge coordinates of FRAME.
FRAME must be a live frame and defaults to the selected one. The return
value is a list of the form (LEFT, TOP, RIGHT, BOTTOM). All values are
in pixels relative to the origin - the position (0, 0) - of FRAME's
display.
border = f->border_width;
title = FRAME_NS_TITLEBAR_HEIGHT (f);
outer_width = FRAME_PIXEL_WIDTH (f) + 2 * border;
outer_height = FRAME_PIXEL_HEIGHT (f) + 2 * border;
tool_bar_height = FRAME_TOOLBAR_HEIGHT (f);
tool_bar_width = tool_bar_height > 0
? outer_width - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)
: 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))));
If optional argument TYPE is the symbol `outer-edges', return the outer
edges of FRAME. The outer edges comprise the decorations of the window
manager (like the title bar or external borders) as well as any external
menu or tool bar of FRAME. If optional argument TYPE is the symbol
`native-edges' or nil, return the native edges of FRAME. The native
edges exclude the decorations of the window manager and any external
menu or tool bar of FRAME. If TYPE is the symbol `inner-edges', return
the inner edges of FRAME. These edges exclude title bar, any borders,
menu bar or tool bar of FRAME. */)
(Lisp_Object frame, Lisp_Object type)
{
return frame_geometry (frame, ((EQ (type, Qouter_edges)
|| EQ (type, Qinner_edges))
? type
: Qnative_edges));
}
/* ==========================================================================
......@@ -3106,6 +3157,7 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename
defsubr (&Sx_display_pixel_height);
defsubr (&Sns_display_monitor_attributes_list);
defsubr (&Sx_frame_geometry);
defsubr (&Sx_frame_edges);
defsubr (&Sx_display_mm_width);
defsubr (&Sx_display_mm_height);
defsubr (&Sx_display_screens);
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment