diff options
author | Julian Eisel <julian@blender.org> | 2021-03-11 19:30:39 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-03-11 19:43:45 +0300 |
commit | 46aa70cb486d719139ac43e5c9ac4b0fe998e202 (patch) | |
tree | 008d868815e983b906f0e7c792c90fb9a6132c5c /source/blender/windowmanager | |
parent | ed2c4825d3e23441444e5d371278588c946e7551 (diff) |
UI: Avoid unnecessary redraws of unrelated editors on space changes
When adding a notifier, `reference` data can be passed. The notifier system
uses this to filter out listeners, for example if data of a scene changes,
windows showing a different scene won't get the notifiers sent to their
listeners.
For the `NC_SPACE` notifiers, a number of places also passed the space as
`reference`, but that wasn't used at all. The notifier would still be sent to
all listeners in all windows (and the listeners didn't use it either). Causing
some unnecessary updates (e.g. see ed2c4825d3e2344).
With this commit, passing a space will make sure the notifier is only sent to
that exact space. Some code seems to already have expected that to be the case.
However there were some cases that passed the space as `reference` without
reason, which would break with this commit (meaning they wouldn't redraw or
update correctly).
Corrected these so they don't pass the space anymore.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index b46a354c7ae..385a572ab85 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -287,6 +287,9 @@ typedef struct wmNotifier { #define NC_TEXT (12 << 24) #define NC_WORLD (13 << 24) #define NC_ANIMATION (14 << 24) +/* When passing a space as reference data with this (e.g. `WM_event_add_notifier(..., space)`), + * the notifier will only be sent to this space. That avoids unnecessary updates for unrelated + * spaces. */ #define NC_SPACE (15 << 24) #define NC_GEOM (16 << 24) #define NC_NODE (17 << 24) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index a39200537d5..33ba27c849c 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -577,6 +577,10 @@ void wm_event_do_notifiers(bContext *C) } ED_screen_areas_iter (win, screen, area) { + if ((note->category == NC_SPACE) && note->reference && + (note->reference != area->spacedata.first)) { + continue; + } wmSpaceTypeListenerParams area_params = { .window = win, .area = area, |