Package: gtk

Function gtk-window-move

Lambda List

gtk-window-move (window x y)

Arguments

window -- a gtk-window widget
x -- an integer with the x coordinate to move the window to
y -- an integer with the y coordinate to move the window to

Details

Asks the window manager to move the window to the given position. Window managers are free to ignore this. Most window managers ignore requests for initial window positions, instead using a user-defined placement algorithm, and honor requests after the window has already been shown.

Note: The position is the position of the gravity-determined reference point for the window. The gravity determines two things: first, the location of the reference point in root window coordinates, and second, which point on the window is positioned at the reference point.

By default the gravity is the :north-west value of the gdk-gravity enumeration, so the reference point is simply the x, y supplied to the gtk-window-move function. The top-left corner of the window decorations, aka window frame or border, will be placed at x, y. Therefore, to position a window at the top left of the screen, you want to use the default gravity, which is :north-west, and move the window to 0,0.

To position a window at the bottom right corner of the screen, you would set the :south-east value, which means that the reference point is at x + the window width and y + the window height, and the bottom-right corner of the window border will be placed at that reference point. So, to place a window in the bottom right corner you would first set gravity to south east, then write:
(gtk-window-move window
                 (- (gdk-screen-width) window-width)
                 (- (gdk-screen-height) window-height))  
Note that this example does not take multi-head scenarios into account.

The Extended Window Manager Hints specification has a table of gravities in the "Implementation Notes" section. The gtk-window-position documentation may also be relevant.
 

See also

2021-9-12