Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_event_system.c
| Show All 33 Lines | |||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "DNA_listBase.h" | #include "DNA_listBase.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| #include "DNA_workspace_types.h" | |||||
| #include "DNA_userdef_types.h" | #include "DNA_userdef_types.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "GHOST_C-api.h" | #include "GHOST_C-api.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_dynstr.h" | #include "BLI_dynstr.h" | ||||
| Show All 21 Lines | |||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "PIL_time.h" | #include "PIL_time.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "WM_message.h" | |||||
| #include "wm.h" | #include "wm.h" | ||||
| #include "wm_window.h" | #include "wm_window.h" | ||||
| #include "wm_event_system.h" | #include "wm_event_system.h" | ||||
| #include "wm_event_types.h" | #include "wm_event_types.h" | ||||
| #include "RNA_enum_types.h" | #include "RNA_enum_types.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| ▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | for (note = wm->queue.first; note; note = note_next) { | ||||
| note_next = note->next; | note_next = note->next; | ||||
| if (note->reference == reference) { | if (note->reference == reference) { | ||||
| /* don't remove because this causes problems for #wm_event_do_notifiers | /* don't remove because this causes problems for #wm_event_do_notifiers | ||||
| * which may be looping on the data (deleting screens) */ | * which may be looping on the data (deleting screens) */ | ||||
| wm_notifier_clear(note); | wm_notifier_clear(note); | ||||
| } | } | ||||
| } | } | ||||
| /* Remap instead. */ | |||||
| #if 0 | |||||
| if (wm->message_bus) { | |||||
| WM_msg_id_remove(wm->message_bus, reference); | |||||
| } | |||||
| #endif | |||||
| } | } | ||||
| } | } | ||||
| void WM_main_remap_editor_id_reference(ID *old_id, ID *new_id) | void WM_main_remap_editor_id_reference(ID *old_id, ID *new_id) | ||||
| { | { | ||||
| Main *bmain = G.main; | Main *bmain = G.main; | ||||
| bScreen *sc; | bScreen *sc; | ||||
| for (sc = bmain->screen.first; sc; sc = sc->id.next) { | for (sc = bmain->screen.first; sc; sc = sc->id.next) { | ||||
| ScrArea *sa; | ScrArea *sa; | ||||
| for (sa = sc->areabase.first; sa; sa = sa->next) { | for (sa = sc->areabase.first; sa; sa = sa->next) { | ||||
| SpaceLink *sl; | SpaceLink *sl; | ||||
| for (sl = sa->spacedata.first; sl; sl = sl->next) { | for (sl = sa->spacedata.first; sl; sl = sl->next) { | ||||
| ED_spacedata_id_remap(sa, sl, old_id, new_id); | ED_spacedata_id_remap(sa, sl, old_id, new_id); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| wmWindowManager *wm = bmain->wm.first; | |||||
| if (wm && wm->message_bus) { | |||||
| struct wmMsgBus *mbus = wm->message_bus; | |||||
| if (new_id != NULL) { | |||||
| WM_msg_id_update(mbus, old_id, new_id); | |||||
| } | |||||
| else { | |||||
| WM_msg_id_remove(mbus, old_id); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| static void wm_notifier_clear(wmNotifier *note) | static void wm_notifier_clear(wmNotifier *note) | ||||
| { | { | ||||
| /* NULL the entire notifier, only leaving (next, prev) members intact */ | /* NULL the entire notifier, only leaving (next, prev) members intact */ | ||||
| memset(((char *)note) + sizeof(Link), 0, sizeof(*note) - sizeof(Link)); | memset(((char *)note) + sizeof(Link), 0, sizeof(*note) - sizeof(Link)); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| void wm_event_do_notifiers(bContext *C) | void wm_event_do_notifiers(bContext *C) | ||||
| { | { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| wmNotifier *note, *next; | wmNotifier *note, *next; | ||||
| wmWindow *win; | wmWindow *win; | ||||
| if (wm == NULL) | if (wm == NULL) | ||||
| return; | return; | ||||
| // disable? - keep for now since its used for window level notifiers. | |||||
| if (1) { | |||||
| /* cache & catch WM level notifiers, such as frame change, scene/screen set */ | /* cache & catch WM level notifiers, such as frame change, scene/screen set */ | ||||
| for (win = wm->windows.first; win; win = win->next) { | for (win = wm->windows.first; win; win = win->next) { | ||||
| Scene *scene = WM_window_get_active_scene(win); | Scene *scene = WM_window_get_active_scene(win); | ||||
| bool do_anim = false; | bool do_anim = false; | ||||
| CTX_wm_window_set(C, win); | CTX_wm_window_set(C, win); | ||||
| for (note = wm->queue.first; note; note = next) { | for (note = wm->queue.first; note; note = next) { | ||||
| ▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | for (win = wm->windows.first; win; win = win->next) { | ||||
| ED_region_do_listen(screen, sa, ar, note, scene); | ED_region_do_listen(screen, sa, ar, note, scene); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(note); | MEM_freeN(note); | ||||
| } | } | ||||
| } // disable | |||||
| { | |||||
| for (win = wm->windows.first; win; win = win->next) { | |||||
| CTX_wm_window_set(C, win); | |||||
| WM_msgbus_handle(wm->message_bus, C); | |||||
| } | |||||
| CTX_wm_window_set(C, NULL); | |||||
| } | |||||
| wm_event_do_refresh_wm_and_depsgraph(C); | wm_event_do_refresh_wm_and_depsgraph(C); | ||||
| } | } | ||||
| static int wm_event_always_pass(const wmEvent *event) | static int wm_event_always_pass(const wmEvent *event) | ||||
| { | { | ||||
| /* some events we always pass on, to ensure proper communication */ | /* some events we always pass on, to ensure proper communication */ | ||||
| return ISTIMER(event->type) || (event->type == WINDEACTIVATE); | return ISTIMER(event->type) || (event->type == WINDEACTIVATE); | ||||
| ▲ Show 20 Lines • Show All 3,521 Lines • Show Last 20 Lines | |||||