Active Viewlayer and Multiple Mainwindows

Hi, in a scenario with multiple main-windows I am trying to get bpy.context.viewlayer ( in this case in a pre render handler) , but the viewlayer returned is not the one of the “active” window and context.window is none. (I think the viewlayer returned is the one of the last created window, but not sure on that) I would try to get the correct viewlayer by going through window_manager and window, but it seems theres’ also no way to get to any info about the window with focus. Is that intentional and/or is there a way around that problem ?

To be more precise here, the context is filled correct when called from an operator triggered eg in a menu. Its really specific to calls from a handler. If the window_manager would have the collection index of the windows in focus, that’d be great.