diff options
author | Bastien Montagne <bastien@blender.org> | 2020-05-18 19:51:06 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-05-18 19:51:06 +0300 |
commit | 8f10f9d5dc7657b6e35d7cb108660db19034c049 (patch) | |
tree | a77783622a627f4905a1f0073c027cfffd6b4e08 /source/blender/windowmanager/intern | |
parent | ae97a7ac1026f1fe40365a2692abee7ef3ea06d2 (diff) |
Refactor: Move WindowManager and Screen foreach_id to new IDTypeInfo structure.
That one was a bit more complicated, and is still only partial refactor
(ultimately we want to have a foreach_id callback in SpaceType itself I
think...).
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 54e6735175d..4d0775b06fa 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -44,8 +44,10 @@ #include "BKE_idprop.h" #include "BKE_idtype.h" #include "BKE_lib_id.h" +#include "BKE_lib_query.h" #include "BKE_main.h" #include "BKE_report.h" +#include "BKE_screen.h" #include "BKE_workspace.h" #include "WM_api.h" @@ -73,6 +75,28 @@ static void window_manager_free_data(ID *id) wm_close_and_free(NULL, (wmWindowManager *)id); } +static void window_manager_foreach_id(ID *id, LibraryForeachIDData *data) +{ + wmWindowManager *wm = (wmWindowManager *)id; + + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { + BKE_LIB_FOREACHID_PROCESS(data, win->scene, IDWALK_CB_USER_ONE); + + /* This pointer can be NULL during old files reading, better be safe than sorry. */ + if (win->workspace_hook != NULL) { + ID *workspace = (ID *)BKE_workspace_active_get(win->workspace_hook); + BKE_LIB_FOREACHID_PROCESS_ID(data, workspace, IDWALK_CB_NOP); + /* allow callback to set a different workspace */ + BKE_workspace_active_set(win->workspace_hook, (WorkSpace *)workspace); + } + if (BKE_lib_query_foreachid_process_flags_get(data) & IDWALK_INCLUDE_UI) { + LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) { + BKE_screen_foreach_id_screen_area(data, area); + } + } + } +} + IDTypeInfo IDType_ID_WM = { .id_code = ID_WM, .id_filter = 0, @@ -87,6 +111,7 @@ IDTypeInfo IDType_ID_WM = { .copy_data = NULL, .free_data = window_manager_free_data, .make_local = NULL, + .foreach_id = window_manager_foreach_id, }; #define MAX_OP_REGISTERED 32 |