diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2019-11-04 20:59:59 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2019-11-04 23:01:38 +0300 |
commit | ef7fd50f8a9317f363eaeb29101cd7fce1111ff4 (patch) | |
tree | 367647df55a77e5a825b776b6a7e2d33c6f8d081 /source/blender/editors/screen/area.c | |
parent | 4b337a86f1dc230d6eb1720c8896b6cca26a2e72 (diff) |
UI: Rewrite stacked full-screen logic, fixing issues
To recreate the main issue:
* Set render and file browser to show in full-screen in the preferences
* Default scene, press F12 in 3D View
* Press Alt+S to save the image
* Escape the file browser
* Escape the image editor
The former 3D View would now show the image editor. This is a common
use-case that should work.
Full-screen code is a hassle to get to work as expected. There are
reports from 2.5, I did lots of work years ago to get these kind of
use-cases to work fine. But apparently I broke this one with a fix for
another common use-case in March (0a28bb14222c).
This now stores hints in the space, rather than the area, which should
make things much more controlable and hopefully help us fix issues like
this.
Here are a few references describing further common issues (all should
work fine now): 0a28bb14222c, e61588c5a544, T19296
Checked over this with Bastien, we agreed that at some point we should
do a big rewrite of all of this, for now this is acceptable.
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r-- | source/blender/editors/screen/area.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 41c3a2ca285..ccee88eb0d6 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1947,7 +1947,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi if (sa->spacetype != type) { SpaceType *st; - SpaceLink *slold; + SpaceLink *slold = sa->spacedata.first; SpaceLink *sl; /* store sa->type->exit callback */ void *sa_exit = sa->type ? sa->type->exit : NULL; @@ -1963,7 +1963,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi */ int header_alignment = ED_area_header_alignment_or_fallback(sa, -1); const bool sync_header_alignment = ((header_alignment != -1) && - (sa->flag & AREA_FLAG_TEMP_TYPE) == 0); + ((slold->link_flag & SPACE_FLAG_TYPE_TEMPORARY) == 0)); /* in some cases (opening temp space) we don't want to * call area exit callback, so we temporarily unset it */ @@ -1979,7 +1979,6 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi } st = BKE_spacetype_from_id(type); - slold = sa->spacedata.first; sa->spacetype = type; sa->type = st; @@ -2010,6 +2009,10 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi slold->regionbase = sa->regionbase; sa->regionbase = sl->regionbase; BLI_listbase_clear(&sl->regionbase); + /* SPACE_FLAG_TYPE_WAS_ACTIVE is only used to go back to a previously active space that is + * overlapped by temporary ones. It's now properly activated, so the flag should be cleared + * at this point. */ + sl->link_flag &= ~SPACE_FLAG_TYPE_WAS_ACTIVE; /* put in front of list */ BLI_remlink(&sa->spacedata, sl); @@ -2073,23 +2076,45 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi ED_area_tag_redraw(sa); } -void ED_area_prevspace(bContext *C, ScrArea *sa) +static SpaceLink *area_get_prevspace(ScrArea *sa) { SpaceLink *sl = sa->spacedata.first; - if (sl && sl->next) { - ED_area_newspace(C, sa, sl->next->spacetype, false); + /* First toggle to the next temporary space in the list. */ + for (SpaceLink *sl_iter = sl->next; sl_iter; sl_iter = sl_iter->next) { + if (sl_iter->link_flag & SPACE_FLAG_TYPE_TEMPORARY) { + return sl_iter; + } + } + + /* No temporary space, find the item marked as last active. */ + for (SpaceLink *sl_iter = sl->next; sl_iter; sl_iter = sl_iter->next) { + if (sl_iter->link_flag & SPACE_FLAG_TYPE_WAS_ACTIVE) { + return sl_iter; + } + } + + /* If neither is found, we can just return to the regular previous one. */ + return sl->next; +} + +void ED_area_prevspace(bContext *C, ScrArea *sa) +{ + SpaceLink *sl = sa->spacedata.first; + SpaceLink *prevspace = sl ? area_get_prevspace(sa) : NULL; - /* keep old spacedata but move it to end, so calling - * ED_area_prevspace once more won't open it again */ - BLI_remlink(&sa->spacedata, sl); - BLI_addtail(&sa->spacedata, sl); + if (prevspace) { + ED_area_newspace(C, sa, prevspace->spacetype, false); + /* We've exited the space, so it can't be considered temporary anymore. */ + sl->link_flag &= ~SPACE_FLAG_TYPE_TEMPORARY; } else { /* no change */ return; } - sa->flag &= ~(AREA_FLAG_STACKED_FULLSCREEN | AREA_FLAG_TEMP_TYPE); + /* If this is a stacked fullscreen, changing to previous area exits it (meaning we're still in a + * fullscreen, but not in a stacked one). */ + sa->flag &= ~AREA_FLAG_STACKED_FULLSCREEN; ED_area_tag_redraw(sa); |