Well, this is a bit more complicated issue. I guess it is Windows specific.
I have a main window on the main screen and a secondary window that I display on another monitor in full-screen. But what happens when I do this is that the main window is all white and does not paint until I click anywhere within. From this point on, everything works as normal.
This is what I do in the constructor of the window that is displayed on the secondary monitor:
PreviewWindow() : DocumentWindow("PreviewWindow", Colours::black, allButtons) {
setContentNonOwned(&content, false);
setSize(800, 800);
const Desktop::Displays& ds = Desktop::getInstance().getDisplays();
if (ds.displays.size() > 1) {
for (auto i :ds.displays) {
if (!i.isMain) {
setBounds(i.userArea);
setFullScreen(true);
setTitleBarHeight(0);
break;
}
}
}
setVisible(true);
}
Well, if I remove that “setVisible
” line, the secondary window is of course not shown, but there is no problem with the main window.
I have also tried explicitly calling repaint()
on the main window after it is created but that does not help.
And it’s really more complicated then it looks. It started after I implemented HighResolutionTimer
within my main window (that is, the window inherits from HighResolutionTimer
) as described here:
Note that after I click the main window everything works fine. But before that, no repaint call makes any difference. It looks as if the main window didn’t know it is visible.
If I call mainWindow->grabKeyboardFocus()
at the end of my Application::initialize
function, the problem with the main window not being refreshed at the app startup is gone, but the secondary window is not visible. I can see it on the taskbar, but it does not show until I click on it… So it’s either that or that. When I say the secondary window is not visible I mean… It is there, but it is completely transparent until I click anywhere on the monitor where it should be. This is probably the same what happens with the main window when I do not grab the focus with it. The only difference is that the secondary window is in fullscreen so probably that’s the reason I cannot see at least the white rectangle as with the main window. In other words I am just not able to show both windows on startup… Only one of them.
Again, when the content component on the main window does not inherit from the HighResolutionTimer
but rather from standard Timer
, both problems go away. Any hints what I could try?