Please check this to understand my problem better:
As you can see, everything works as it should on the login screen.
But when I entered my password, the screen goes to sleep (I think this is because macOS doesn't send a video signal for a short time when switching from login screen to desktop). But then, when my MacBook shows the desktop, the monitor comes back from idle mode and shows "HDMI" but it doesn't show a picture. After a few seconds, it goes back to idle, then it shows "HDMI" again and this loop keeps repeating. What can I do to fix that?
P.S.: I had the setup working as expected yesterday once, but I don't really know what I changed since then. The only thing that would come to my mind is that I plugged an unused DP cable into the monitor, but I never connected any device to that DP cable.
My MacBook is connected via HDMI.