getWindowStateAsString() window size is wrong on Linux

This problem has existed for years, it isn’t new. Did a git pull to get the most recent, which I believe is v6.1.6.

When I call getWindowStateAsString() to store my application’s window state, and then use restoreWindowStateFromString(), the Window’s height is reduced by 37 pixels every time. I think this because JUCE is not correctly measuring or taking into account the native titlebar height; all my applications use setUsingNativeTitleBar(true).

My window inherits from DocumentWindow. In the constructor, I have this:

setUsingNativeTitleBar(true);
setResizable(true, false);
setDropShadowEnabled(true);
...
restoreWindowStateFromString(cfg().getValue("StartupWnd"));

In the destructor, I have this:

cfg().setValue("StartupWnd", getWindowStateAsString());

Then if I open and close the application multiple times and print out the values saved to the configuration file, I see this:

stephane@2004-dev ~/s/D/build (master)> grep StartupWnd ~/.DarkMark/DarkMark.cfg
<VALUE name="StartupWnd" val="536 210 951 639 frame 37 0 0 0"/>
stephane@2004-dev ~/s/D/build (master)> grep StartupWnd ~/.DarkMark/DarkMark.cfg
<VALUE name="StartupWnd" val="536 210 951 602 frame 37 0 0 0"/>
stephane@2004-dev ~/s/D/build (master)> grep StartupWnd ~/.DarkMark/DarkMark.cfg
<VALUE name="StartupWnd" val="536 210 951 565 frame 37 0 0 0"/>
stephane@2004-dev ~/s/D/build (master)> grep StartupWnd ~/.DarkMark/DarkMark.cfg
<VALUE name="StartupWnd" val="536 210 951 528 frame 37 0 0 0"/>

Note how the 4th value gets reduced by exactly 37 pixels every time the application saves the state.

It is suspicious that the 6th word is “37”, and the window size is reduced by 37 pixels each time. Not sure what this “frame” is supposed to be doing.

For me that problem was solved few months ago.

I did a quick test with my dummy example and it seems to work fine there (develop branch).

I just check – I’m on “develop”:

stephane@2004-dev ~/s/JUCE (develop)> git branch -a
* develop
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/accessibility
  remotes/origin/develop
  remotes/origin/juce6
  remotes/origin/juce7
  remotes/origin/master

stephane@2004-dev ~/s/JUCE (develop)> git log -1
commit b0a8bc0ce2a9241c05f47c3a2b9b6b37e8f70513 (HEAD -> develop, origin/develop)
Author: Tom Poole <tom@juce.com>
Date:   Tue Apr 26 11:38:19 2022 +0100

    VST3: Fix a compiler warning in the VST3 SDK

Me too on Ubuntu 20.04 also.

jojo@jojo-T430:~/JUCE$ git branch
* develop
  master
jojo@jojo-T430:~/JUCE$ git log
commit b0a8bc0ce2a9241c05f47c3a2b9b6b37e8f70513 (HEAD -> develop, origin/develop)
Author: Tom Poole <tom@juce.com>
Date:   Tue Apr 26 11:38:19 2022 +0100

    VST3: Fix a compiler warning in the VST3 SDK

Weird. The Drift app i did to reproduce the bug works fine for me.

I just checked out the juce7 branch (last commit was a few hours ago by Tom Poole) but the error still happens for me on that branch as well. Window shrinks by exactly 37 pixels each time the API is used to save/restore the window.

stephane@2004-dev ~/s/JUCE (juce7)> git log -1
commit 9c6ce98a546e62c747e5703e3a7458d4ed3ea302 (HEAD -> juce7, origin/juce7)
Author: Tom Poole <tom@juce.com>
Date:   Tue Apr 26 16:32:15 2022 +0100

    macOS: Fix an unguarded availability warning
stephane@2004-dev ~/s/JUCE (juce7)> grep StartupWnd ~/.DarkMark/DarkMark.cfg
  <VALUE name="StartupWnd" val="536 210 951 682 frame 37 0 0 0"/>
stephane@2004-dev ~/s/JUCE (juce7)> grep StartupWnd ~/.DarkMark/DarkMark.cfg
  <VALUE name="StartupWnd" val="536 210 951 608 frame 37 0 0 0"/>
stephane@2004-dev ~/s/JUCE (juce7)> grep StartupWnd ~/.DarkMark/DarkMark.cfg
  <VALUE name="StartupWnd" val="536 210 951 571 frame 37 0 0 0"/>
stephane@2004-dev ~/s/JUCE (juce7)> grep StartupWnd ~/.DarkMark/DarkMark.cfg
  <VALUE name="StartupWnd" val="536 210 951 534 frame 37 0 0 0"/>

What Linux distribution are you testing on, and what window manager are you using?

Ubuntu 20.04. The usual desktop version of Ubuntu.