UI squeezed after switching Display Mode from Fullscreen to Windowed

In Windows 11, when I switch the Disaply Mode from “Fullscreen (Windowed)” to “Windowed” the UI is vertically compressed. You can see the the mini-map is not round any more but egg-shaped. Furthermore, to click a UI element I have to move the mouse below it. The further down an element is the more extreme this effect gets.

Fullscreen (everything fine):
https://i.imgur.com/9onC5Wt.jpeg

After switching to Windowed:
https://i.imgur.com/PowYXOR.jpeg

This corrects itself when I double click the window title bar, thereby changing the window form maximized to not maximized. I can afterwards maximize by double clicking the title bar again and the UI is OK again.

Pease make it such that the UI is correct right away after switching to Windowed.
I am doing this frequently and even have a macro keybind to do this.

if GetCVar("gxMaximize") == "0" then
  SetCVar("gxMaximize", "1")
else
  SetCVar("gxMaximize", "0")
end
UpdateWindow()

I figured out that this does only happen when the window is maximised. If I leave the window non-maximised and switch between fullscreen and windowed, everything works fine.