Every time I open a Calc worksheet which contains macros, a warning dialog appears. The problem is while I’m busy with other applications this warning also appeared and interrupted my workflow. Is there a way to make it appear only when I come back to LibreOffice?
Generally this is not implemented in any way in LibreOffice. And I’m not aware of any application implementing this. But if LibreOffice doesn’t have the focus, it shouldn’t steal it. This is normally handled by the operating system, not an application itself.
There was a change in the code, which brings windows to the front, in LibreOffice 6.4.2 on Windows. That might help in your situation, if you are using Windows. Generally focus steal handling / prevention is a tricky business. In Linux various DEs / window managers have their own setting to handle this more or less successful.