| Extracted from Pike v7.8 release 700 at 2013-06-08.

[Top]
GTK2
GTK2.Window

# Method GTK2.Window()->get_position()

Method get_position

  `mapping get_position()`

Description

  This function returns the position you need to pass to move() to keep this window in its current position. This means that the meaning of the returned value varies with window gravity.

  If you haven't changed the window gravity, its gravity will be GDK2.GRAVITY_NORTH_WEST. This means that get_position() gets the position of the top-left corner of the window manager frame for the window. move() sets the position of this same top-left corner.

  get_position() is not 100% reliable because X does not specify a way to obtain the geometry of the decorations placed on a window by the window manager. Thus GTK+ is using a "best guess" that works with most window managers.

  Moreover, nearly all window managers are historically broken with respect to their handling of window gravity. So moving a window to its current position as returned by get_position() tends to result in moving the window slightly. Window managers are slowly getting better over time.

  If a window has gravity GDK2.GRAVITY_STATIC the window manager frame is not relevant, and thus get_position() will always produc accurate results. However you can't use static gravity to do things like place a window in a corner of the screen, because static gravity ignores the window manager decorations.

  If you are saving and restoring your application's window positions, you should know that it's impossible for applications to do this without getting it somewhat wrong because applications do not have sufficient knowledge of window manager state.