Multiwindow repait problem on Windows

I’m developing an multiwindow application intended to run on Windows using juce v 7.0.5.
There are three windows running at the same time in my application, and when I call repaint() method at the same time in the message thread at a frequency about one time per 2 milliseconds to repaint a component in these three windows, the window I’m focusing will repaint it’s component as I expected, but for the second window, the component will be repainted later, as for the third window, it actually won’t be repainted unless I set it as the focus window.

I know that calling repaint() actually won’t do any repaint immediately, but the problem is that the focus window will be repainted as soon as possible. Am I calling the repait() method too often?

I’ve tried to use getPeer()->performAnyPendingRepaintsNow(), it will fix this problem but it’s too time-consuming.

Is there any other way to make the the other two window being repainted as the focus window? Also this problem won’t happen on MacOS, so is it actually the OS’s issue?

Here is an video about this problem in case I didn’t discribe it clearly.
https://1drv.ms/v/s!AqYmYX8a4y7PnwkXyCbpOMzFvQRc?e=i2Ic62

Repainting is triggered by your window receiving a WM_PAINT message from Windows. As far as I can tell, Windows prioritizes foreground windows over background windows. The Desktop Window Manager seems to intentionally throttle the rate at which WM_PAINT messages are delivered to non-focused windows. It’s not a JUCE issue.

You could try Direct2D, but of course that’s a work in progress. I’ll have another update soon. More testing is good.

Matt

1 Like

Huh - actually you could paint synchronously in software mode.

https://learn.microsoft.com/en-us/windows/win32/gdi/synchronous-and-asynchronous-drawing