GTK window, how to get window decoration sizes?

Viewed 2030

I am looking for an equivalent of AdjustWindowRect function that allows to get widths/heights of window caption and borders.

Do we have this functionality in GTK 3 at all? Seems like not. I've looked through all gtk_window_xxx, gtk_widget_xxx and gdk_window_xxx* functions...

Update:

In principle I am able to determine window-chrome/decoration dimensions as a delta of gdk_window_get_frame_extents() and gtk_widget_get_allocation() / gdk_window_get_origin() but

  1. it works only after window appeared on the screen. I need it before that - to calculate initial window position.
  2. it is really a hack.
4 Answers

Unfortunately situation with GTK is even worse than just problem of getting decorations.

The first:

gtk_window_move(window, x, y) sets border frame position of the window.

And gtk_window_resize(window, w, h) sets client dimensions of the window.

And there is absolutely no way in GTK API to set border frame size programmatically and explicitly. And so there is no way to set window frame position/size of decorated windows.

On Windows and MacOS, using their APIs, that is easy to do, and reliably. But on GTK they only have this:

gtk_window_move(): Begs the window manager to move 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.

Related