Hello Issypo,
Have you restarted your Mac since this began? Here are the steps to do so if you need: Shut down or restart your Mac - Apple Support
Additionally, does this happen with multiple apps? We see you're using Safari here. How is the iMac behaving when this happens too? Are you still able to navigate and use the window, or does it stop?
We look forward to hearing back from you!