Commit df9b29ed authored by Martin Rudalics's avatar Martin Rudalics
Browse files

Sanitize frame geometry related functions

* src/nsfns.m (Fx_frame_geometry): Rename to Fns_frame_geometry.
(Fx_frame_edges): Rename to Fns_frame_edges.
* src/w32fns.c (Fx_frame_geometry): Rename to Fw32_frame_geometry.
(Fx_frame_edges): Rename to Fw32_frame_edges.
(Fx_mouse_absolute_pixel_position): Rename to
Fw32_mouse_absolute_pixel_position.
(Fx_set_mouse_absolute_pixel_position): Rename to
Fw32_set_mouse_absolute_pixel_position.
* lisp/frame.el (x-frame-geometry, w32-frame-geometry)
(ns-frame-geometry, x-frame-edges, w32-frame-edges)
(ns-frame-edges, w32-mouse-absolute-pixel-position)
(x-mouse-absolute-pixel-position)
(w32-set-mouse-absolute-pixel-position)
(x-set-mouse-absolute-pixel-position): Declare.
(frame-geometry, mouse-absolute-pixel-position)
(set-mouse-absolute-pixel-position): New functions.
(frame-edges): Rewrite in terms of x-/w32-/ns-frame-edges.
parent 092e17b1
......@@ -1312,6 +1312,80 @@ live frame and defaults to the selected one."
(setq vertical default-frame-scroll-bars))
(cons vertical (and horizontal 'bottom))))
(declare-function x-frame-geometry "xfns.c" (&optional frame))
(declare-function w32-frame-geometry "w32fns.c" (&optional frame))
(declare-function ns-frame-geometry "nsfns.m" (&optional frame))
(defun frame-geometry (&optional frame)
"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
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 non-nil, means the tool bar is external (never
included in the inner edges of FRAME).
`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
FRAME.
`internal-border-width' is the width of the internal border of
FRAME."
(let* ((frame (window-normalize-frame frame))
(frame-type (framep-on-display frame)))
(cond
((eq frame-type 'x)
(x-frame-geometry frame))
((eq frame-type 'w32)
(w32-frame-geometry frame))
((eq frame-type 'ns)
(ns-frame-geometry frame))
(t
(list
'(outer-position 0 . 0)
(cons 'outer-size (cons (frame-width frame) (frame-height frame)))
'(external-border-size 0 . 0)
'(title-bar-size 0 . 0)
'(menu-bar-external . nil)
(let ((menu-bar-lines (frame-parameter frame 'menu-bar-lines)))
(cons 'menu-bar-size
(if menu-bar-lines
(cons (frame-width frame) 1)
1 0)))
'(tool-bar-external . nil)
'(tool-bar-position . nil)
'(tool-bar-size 0 . 0)
(cons 'internal-border-width
(frame-parameter frame 'internal-border-width)))))))
(declare-function x-frame-edges "xfns.c" (&optional frame type))
(declare-function w32-frame-edges "w32fns.c" (&optional frame type))
(declare-function ns-frame-edges "nsfns.m" (&optional frame type))
(defun frame-edges (&optional frame type)
"Return coordinates of FRAME's edges.
FRAME must be a live frame and defaults to the selected one. The
......@@ -1325,10 +1399,48 @@ Optional argument TYPE specifies the type of the edges. TYPE
`native-edges' (or nil) means to return the native edges of
FRAME. TYPE `inner-edges' means to return the inner edges of
FRAME."
(let ((frame (window-normalize-frame frame)))
(if (display-graphic-p (frame-parameter nil 'display))
(x-frame-edges frame (or type 'native-edges))
(list 0 0 (frame-width frame) (frame-height frame)))))
(let* ((frame (window-normalize-frame frame))
(frame-type (framep-on-display frame)))
(cond
((eq frame-type 'x)
(x-frame-edges frame type))
((eq frame-type 'w32)
(w32-frame-edges frame type))
((eq frame-type 'ns)
(ns-frame-edges frame type))
(t
(list 0 0 (frame-width frame) (frame-height frame))))))
(declare-function w32-mouse-absolute-pixel-position "w32fns.c")
(declare-function x-mouse-absolute-pixel-position "xfns.c")
(defun mouse-absolute-pixel-position ()
"Return absolute position of mouse cursor in pixels.
The position is returned as a cons cell (X . Y) of the
coordinates of the mouse cursor position in pixels relative to a
position (0, 0) of the selected frame's terminal."
(let ((frame-type (framep-on-display)))
(cond
((eq frame-type 'x)
(x-mouse-absolute-pixel-position))
((eq frame-type 'w32)
(w32-mouse-absolute-pixel-position))
(t
(cons 0 0)))))
(declare-function w32-set-mouse-absolute-pixel-position "w32fns.c" (x y))
(declare-function x-set-mouse-absolute-pixel-position "xfns.c" (x y))
(defun set-mouse-absolute-pixel-position (x y)
"Move mouse pointer to absolute pixel position (X, Y).
The coordinates X and Y are interpreted in pixels relative to a
position (0, 0) of the selected frame's terminal."
(let ((frame-type (framep-on-display)))
(cond
((eq frame-type 'x)
(x-set-mouse-absolute-pixel-position x y))
((eq frame-type 'w32)
(w32-set-mouse-absolute-pixel-position x y)))))
(defun frame-monitor-attributes (&optional frame)
"Return the attributes of the physical monitor dominating FRAME.
......
......@@ -2906,7 +2906,7 @@ ATTRIBUTES return the outer edges of FRAME (Qouter_edges), the inner
make_number (internal_border_width)));
}
DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0,
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
......@@ -2950,7 +2950,7 @@ ATTRIBUTES return the outer edges of FRAME (Qouter_edges), the inner
return frame_geometry (frame, Qnil);
}
DEFUN ("x-frame-edges", Fx_frame_edges, Sx_frame_edges, 0, 2, 0,
DEFUN ("ns-frame-edges", Fns_frame_edges, Sns_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
......@@ -3156,8 +3156,8 @@ - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename
defsubr (&Sx_display_pixel_width);
defsubr (&Sx_display_pixel_height);
defsubr (&Sns_display_monitor_attributes_list);
defsubr (&Sx_frame_geometry);
defsubr (&Sx_frame_edges);
defsubr (&Sns_frame_geometry);
defsubr (&Sns_frame_edges);
defsubr (&Sx_display_mm_width);
defsubr (&Sx_display_mm_height);
defsubr (&Sx_display_screens);
......
......@@ -8002,7 +8002,7 @@ This is a direct interface to the Windows API FindWindow function. */)
return Qt;
}
DEFUN ("x-frame-geometry", Fx_frame_geometry, Sx_frame_geometry, 0, 1, 0,
DEFUN ("w32-frame-geometry", Fw32_frame_geometry, Sw32_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
......@@ -8138,7 +8138,7 @@ and width values are in pixels.
make_number (internal_border_width)));
}
DEFUN ("x-frame-edges", Fx_frame_edges, Sx_frame_edges, 0, 2, 0,
DEFUN ("w32-frame-edges", Fw32_frame_edges, Sw32_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
......@@ -8213,8 +8213,8 @@ menu bar or tool bar of FRAME. */)
}
}
DEFUN ("x-mouse-absolute-pixel-position", Fx_mouse_absolute_pixel_position,
Sx_mouse_absolute_pixel_position, 0, 0, 0,
DEFUN ("w32-mouse-absolute-pixel-position", Fw32_mouse_absolute_pixel_position,
Sw32_mouse_absolute_pixel_position, 0, 0, 0,
doc: /* Return absolute position of mouse cursor in pixels.
The position is returned as a cons cell (X . Y) of the coordinates of
the mouse cursor position in pixels relative to a position (0, 0) of the
......@@ -8230,8 +8230,8 @@ selected frame's display. */)
return Fcons (make_number (pt.x), make_number (pt.y));
}
DEFUN ("x-set-mouse-absolute-pixel-position", Fx_set_mouse_absolute_pixel_position,
Sx_set_mouse_absolute_pixel_position, 2, 2, 0,
DEFUN ("w32-set-mouse-absolute-pixel-position", Fw32_set_mouse_absolute_pixel_position,
Sw32_set_mouse_absolute_pixel_position, 2, 2, 0,
doc: /* Move mouse pointer to absolute pixel position (X, Y).
The coordinates X and Y are interpreted in pixels relative to a position
(0, 0) of the selected frame's display. */)
......@@ -9280,10 +9280,10 @@ This variable has effect only on Windows Vista and later. */);
defsubr (&Sx_open_connection);
defsubr (&Sx_close_connection);
defsubr (&Sx_display_list);
defsubr (&Sx_frame_geometry);
defsubr (&Sx_frame_edges);
defsubr (&Sx_mouse_absolute_pixel_position);
defsubr (&Sx_set_mouse_absolute_pixel_position);
defsubr (&Sw32_frame_geometry);
defsubr (&Sw32_frame_edges);
defsubr (&Sw32_mouse_absolute_pixel_position);
defsubr (&Sw32_set_mouse_absolute_pixel_position);
defsubr (&Sx_synchronize);
/* W32 specific functions */
......
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