Fix T92476: wrong context in spreadsheet when area is maximized

Now, if a spreadsheet editor is maximized, it looks for its context in
the unmaximized screen "below".
This commit is contained in:
Jacques Lucke 2021-10-29 11:04:37 +02:00
parent 2d42dc4182
commit f13826a572
Notes: blender-bot 2023-02-14 08:42:54 +01:00
Referenced by issue #92476, Geometry Nodes: Spreadsheet Editor when maximized shows no active Viewer node
1 changed files with 23 additions and 2 deletions

View File

@ -373,6 +373,21 @@ void ED_spreadsheet_context_path_set_evaluated_object(SpaceSpreadsheet *sspreads
BLI_addtail(&sspreadsheet->context_path, context);
}
static bScreen *find_screen_to_search_for_context(wmWindow *window,
SpaceSpreadsheet *current_space)
{
bScreen *screen = BKE_workspace_active_screen_get(window->workspace_hook);
if (ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL)) {
/* If the spreadsheet is maximized, try to find the context in the unmaximized screen. */
ScrArea *main_area = (ScrArea *)screen->areabase.first;
SpaceLink *sl = (SpaceLink *)main_area->spacedata.first;
if (sl == (SpaceLink *)current_space) {
return main_area->full;
}
}
return screen;
}
void ED_spreadsheet_context_path_guess(const bContext *C, SpaceSpreadsheet *sspreadsheet)
{
ED_spreadsheet_context_path_clear(sspreadsheet);
@ -385,9 +400,12 @@ void ED_spreadsheet_context_path_guess(const bContext *C, SpaceSpreadsheet *sspr
if (sspreadsheet->object_eval_state == SPREADSHEET_OBJECT_EVAL_STATE_VIEWER_NODE) {
LISTBASE_FOREACH (wmWindow *, window, &wm->windows) {
bScreen *screen = BKE_workspace_active_screen_get(window->workspace_hook);
bScreen *screen = find_screen_to_search_for_context(window, sspreadsheet);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
SpaceLink *sl = (SpaceLink *)area->spacedata.first;
if (sl == nullptr) {
continue;
}
if (sl->spacetype == SPACE_NODE) {
SpaceNode *snode = (SpaceNode *)sl;
if (snode->edittree != nullptr) {
@ -466,9 +484,12 @@ bool ED_spreadsheet_context_path_is_active(const bContext *C, SpaceSpreadsheet *
}
LISTBASE_FOREACH (wmWindow *, window, &wm->windows) {
bScreen *screen = BKE_workspace_active_screen_get(window->workspace_hook);
bScreen *screen = find_screen_to_search_for_context(window, sspreadsheet);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
SpaceLink *sl = (SpaceLink *)area->spacedata.first;
if (sl == nullptr) {
continue;
}
if (sl->spacetype != SPACE_NODE) {
continue;
}