On graphical systems, the position of a normal top-level frame is specified as the absolute position of its outer frame (see Frame Geometry). The position of a child frame (see Child Frames) is specified via pixel offsets of its outer edges relative to the native position of its parent frame.
You can access or change the position of a frame using the frame parameters
top (see Position Parameters). Here are two additional functions for working with the positions of an existing, visible frame. For both functions, the argument
frame must denote a live frame and defaults to the selected frame.
function frame-position \&optional frame
For a normal, non-child frame this function returns a cons of the pixel coordinates of its outer position (see Frame Layout) with respect to the origin
(0, 0) of its display. For a child frame (see Child Frames) this function returns the pixel coordinates of its outer position with respect to an origin
(0, 0) at the native position of
Negative values never indicate an offset from the right or bottom edge of
frame’s display or parent frame. Rather, they mean that
frame’s outer position is on the left and/or above the origin of its display or the native position of its parent frame. This usually means that
frame is only partially visible (or completely invisible). However, on systems where the display’s origin does not coincide with its top-left corner, the frame may be visible on a secondary monitor.
On a text terminal frame both values are zero.
function set-frame-position frame x y
This function sets the outer frame position of
frame to (
y). The latter arguments specify pixels and normally count from the origin at the position (0, 0) of
frame’s display. For child frames, they count from the native position of
frame’s parent frame.
Negative parameter values position the right edge of the outer frame by
-x pixels left from the right edge of the screen (or the parent frame’s native rectangle) and the bottom edge by
-y pixels up from the bottom edge of the screen (or the parent frame’s native rectangle).
Note that negative values do not permit to align the right or bottom edge of
frame exactly at the right or bottom edge of its display or parent frame. Neither do they allow to specify a position that does not lie within the edges of the display or parent frame. The frame parameters
top (see Position Parameters) allow to do that, but may still fail to provide good results for the initial or a new frame.
This function has no effect on text terminal frames.
This hook specifies the functions that are run when an Emacs frame is moved (assigned a new position) by the window-system or window manager. The functions are run with one argument, the frame that moved. For a child frame (see Child Frames), the functions are run only when the position of the frame changes in relation to that of its parent frame.