Getting the title bar height in a windows/osx app

This should work on Linux, however, it may not work immediately (synchronously) after making a window visible. The window borders are communicated by the window manager setting the _NET_FRAME_EXTENTS property on the window, which must happen after the window has been created. For example, if I add the following to the constructor of the DemoRunner’s MainAppWindow then I see the expected frame size values:

Timer::callAfterDelay (2000, [this]
{
    DBG (getPeer()->getFrameSize().getTop());
    DBG (getPeer()->getFrameSize().getBottom());
});

If I omit the callAfterDelay and print the values directly inside the constructor, then both values are reported as 0.

It looks like at the moment we only update the frame extents when the window bounds change. We could probably improve this a bit by listening for changes to the FRAME_EXTENTS property and updating the border size as soon as the property is changed. I’ll make that change shortly.

Even once I’ve made the change above, the frame extents will not be available in the window’s constructor on Linux. If keeping track of the border size is important in your project, I’d recommend querying it as late as possible.

1 Like