Hi Jules,
Sometimes on startup, my app ends with a 1x1 window instead of its correct dimension (500x500). This happens with native border, or without it. The occurence of the bug is highly dependent on the timing of X11 events and the interaction with the WManager so I have had a hard time catching it in a debugger. Here is what happens:
- The top-level window component is created, its addToDesktop param is true so it gets added to the desktop, with its default size that is 1x1
- LinuxComponentPeer::setBounds(1,1) is called by addToDesktop
- later in the code, its real size is set, and LinuxComponentPeer::setBounds(500,500) gets called
both calls to setBounds will resize the window. The windowmanager will be notified, will perform the resize, and will send a ConfigureNotify event back to us. In general , juce only receives the ConfigureNotify for the the 500x500 resize, and none for the first resize. But sometimes, it first receives ConfigureNotify for the 1x1 resize, and then you have a sequence of calls inside the handler for ConfigureNotify that leads to a new call to setBounds(1,1) , with the following stack trace:
#3 0x082e9009 in juce::LinuxComponentPeer::setBounds (this=0x1352c5e0, x=26, y=0, w=2, h=22, isNowFullScreen=false) at juce/juce_amalgamated.cpp:249404
#4 0x08283219 in juce::LinuxComponentPeer::setSize (this=0x1352c5e0, w=2, h=22) at juce/juce_amalgamated.cpp:249397
#5 0x082e94c2 in juce::Component::setBounds (this=0x1352c4d8, x=26, y=0, w=2, h=22) at juce/juce_amalgamated.cpp:36161
#6 0x082eb534 in juce::Component::setSize (this=0x1352c4d8, w=2, h=22) at juce/juce_amalgamated.cpp:36212
#7 0x082eb5c9 in juce::ResizableWindow::childBoundsChanged (this=0x1352c4d8, child=0x1355e9c8) at juce/juce_amalgamated.cpp:71830
#8 0x082e8b39 in juce::Component::sendMovedResizedMessages (this=0x1355e9c8, wasMoved=false, wasResized=true) at juce/juce_amalgamated.cpp:36189
#9 0x082e94dd in juce::Component::setBounds (this=0x1355e9c8, x=1, y=21, w=0, h=0) at juce/juce_amalgamated.cpp:36165
#10 0x08340997 in juce::Component::setBoundsInset (this=0x1355e9c8, borders=@0xbf847300) at juce/juce_amalgamated.cpp:36270
#11 0x08340b67 in juce::ResizableWindow::resized (this=0x1352c4d8) at juce/juce_amalgamated.cpp:71810
#12 0x08340b95 in juce::DocumentWindow::resized (this=0x1352c4d8) at juce/juce_amalgamated.cpp:71503
#13 0x08340d13 in juce::DialogWindow::resized (this=0x1352c4d8) at juce/juce_amalgamated.cpp:71272
#14 0x082e8aa7 in juce::Component::sendMovedResizedMessages (this=0x1352c4d8, wasMoved=true, wasResized=true) at juce/juce_amalgamated.cpp:36178
#15 0x082e8d80 in juce::ComponentPeer::handleMovedOrResized (this=0x1352c5e0) at juce/juce_amalgamated.cpp:71043
#16 0x08345deb in juce::LinuxComponentPeer::handleWindowMessage (this=0x1352c5e0, event=0xbf8476e0) at juce/juce_amalgamated.cpp:250198
#17 0x08346344 in juce::juce_windowMessageReceive (event=0xbf8476e0) at juce/juce_amalgamated.cpp:251218
#18 0x0834657d in juce::juce_dispatchNextMessageOnSystemQueue (returnIfNoPendingMessages=false) at juce/juce_amalgamated.cpp:248091
(ok here it is setBounds(2,22) instead of (1,1) because of its non-native border)
So it that case, the window is finally resized to 2x22 instead of 500x500
An ugly workaround is to increment a flag “inConfigureNotify” at the begin of the handler of ConfigureNotify, decrement it at the end , and do the following test at the beginning of LinuxComponentPeer::setBounds:
if (inConfigureNotify) {
wx = x; wy = y; ww = jmax(1,w); wh = jmax(1,h); return;
}