I am not much acquainted with the LCL gtk2 stuff.
I do know, that gtk2 can hang all windows, if any single app fails to respond to certain messages. So if the IDE is stuck for some time, then it may not respond. In fact it may be stuck inside such a message (doing something inside a paint message, or focus, or click / not sure, not all of them cause the symptoms).
But then the IDE would have to do something. Maybe disk activity? Scanning the disc for something (still shouldn't be inside an event, but well one never knows).
You could run the IDE (with dwarf-2 debug info) from a terminal inside gdb
gdb lazarus
r
Then (if the terminal still reacts) when it hangs ctrl-c => that way gdb would stop it. Then go through the threads and get backtraces (bt).
Maybe that reveals something.
If the terminal is frozen too, ssh into your box, attach gdb to the running IDE, and then you can ctrl-c over ssh.
If the bt is inside gtk and does not reach lcl/ide, then "c" continue, ctrl-c again and hope for a better trace. If all are in gtk, then the time is actually spent there....
I also thought about "bad windows":
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41041Potentially gtk/gdk may take time to validate this???
But that is just an extremely wild guess.