Existing code to replace the file operation was failing when done from the
window for the file operation itself.
Basically, this patch does two things:
- More carefully select the window to use as the "root" or parent of the File Browser window.
- Because of that, the context also needs to be set more carefully, to be valid for that window.
Idea is to more carefully set a "root context" (as in, the context from where
the File Browser was started from) with clearly defined rules. It is set up by
WM_event_add_fileselect() and passed to the file-select handler. On
execution of the file operation, it is restored (if possible), so the context of
the operation matches the context where the File Browser was invoked in.
When reusing the File Browser window, we also reuse the same root
area/region in the new file-select handler, so these are well defined for the
operator execution (and not dependent on the current mouse position for
example). Previously it would just hope the current context works well
enough for that.
Alternative to D12592.