Until fairly recently, joining screen areas required that the edges of those areas line up exactly (as seen in the left of the following image). But that requirement has been relaxed somewhat over the last year and we can now join areas that are bit misaligned (as shown in the second image). This patch allows joining areas that are misaligned as much as the third image:
Basically any areas that can be joined by simply moving existing edges around, without wrecking or dramatically changing neighbors, will be successful. Additionally, some other common joins that require a bit more work under the hood will also work:
An animated GIF showing some of the new possibilities:
Because more neighboring areas can successfully join, it now (finally) means that all areas can be closed. So I added a SCREEN_OT_area_close operator and then fleshed out the "Header" context menu:
There has been lots of buzz lately about different ways of managing areas, but this patch does not compete or interfere with them but in fact complements them. This patch mainly adds the under-the-hood code to better join and to close areas: shared functions used by the visible UI code. Once we are able to do these things then we can explore different ways to initiate them.
This patch is very small and is designed to be easy to evaluate. You should just see a bunch of one-line changes were I need to get the "screen" to area_getorientation() so that it can use knowledge of other areas in its decisions. The code to allow misaligned areas mostly just adds one new 30-line function. Then a bit more code In order to support fancier joining. But you should find it minimal, logical, and well-commented.