gui: Restore currently visible pages on top of all the others
Currently if pages A, B, C were opened in that order, and that page B is the currently visible one for this frame, it won't be the one which will be visible when re-opening the project. This is because the internal order stays in the order that the pages were opened, it doesn't change when a different page is shown, unlike the MRU order.
So this commit now detects when a page is the currently shown one, and in that case saves it with the highest depth so that it is restored on top of all others.
Follow-up from !345 (merged)