Properly setting window size taking decorations into account

The application being worked on is a cross platform terminal emulator which uses the native Mac widgets on Mac and Gtk4 on Linux. The author wants to be able to set the window size in rows * columns. If we calculate the display area based on the row * columns and pass that in as a window size request it winds up being off by a few rows due to client side decorations being part of the window’s size.

What is needed is a way to get the size of the window minus the decorations early in window creation, preferably before it’s displayed, so that we can set it appropriately. If I realize the window without displaying it is this info available?

Think the other way around:
Set the size of your display area with “set_size_request()” according to your rows*columns config, then let the window draw its borders around.

You can set the “resizable” flag of the window to “false” if you want it to stick to the contents size.

Thanks, sounds decidedly simpler.

That works, but I’m unable to resize the window smaller than that afterwards. Any other solution come to mind?

Ah, you wanted to be able to resize?

Then a simple trick can be to remove the size request with set_size_request(-1, -1) after the window got realized (after a timeout or in idle).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.