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 ed2c4825d3
).
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.
This commit is contained in:
parent
ed2c4825d3
commit
46aa70cb48
Notes:
blender-bot
2023-02-14 09:33:11 +01:00
Referenced by commitf5edc69150
, Fix frame overlay not refreshing the sequencer preview Referenced by commit7ee365d8c7
, Fix missing view3d updates after recent NC_SPACE notifier filters Referenced by commit8c6337e587
, Fix missing UI updates, caused by own earlier commit Referenced by issue #86670, Regression: viewport, camera image movement late update
|
@ -3095,7 +3095,6 @@ static int gpencil_snap_cursor_to_sel(bContext *C, wmOperator *op)
|
|||
const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
|
||||
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
float *cursor = scene->cursor.location;
|
||||
float centroid[3] = {0.0f};
|
||||
|
@ -3125,7 +3124,7 @@ static int gpencil_snap_cursor_to_sel(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
|
|
@ -1756,7 +1756,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
DEG_relations_tag_update(bmain);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, CTX_wm_view3d(C));
|
||||
WM_event_add_notifier(C, NC_OBJECT, NULL);
|
||||
|
||||
|
@ -2712,7 +2712,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent
|
|||
DEG_id_tag_update(&base->object->id, ID_RECALC_TRANSFORM);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, base->object);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
|
|
@ -647,7 +647,7 @@ static int material_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve
|
|||
BKE_object_material_assign(bmain, ob, ma, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
|
|
@ -1575,7 +1575,7 @@ static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event
|
|||
}
|
||||
|
||||
/* default for now */
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
}
|
||||
|
||||
static bool view3d_panel_transform_poll(const bContext *C, PanelType *UNUSED(pt))
|
||||
|
|
|
@ -667,7 +667,7 @@ static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
curs[1] = gridf * floorf(0.5f + curs[1] / gridf);
|
||||
curs[2] = gridf * floorf(0.5f + curs[2] / gridf);
|
||||
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); /* hrm */
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* hrm */
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
@ -913,7 +913,7 @@ static int snap_curs_to_active_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
if (snap_calc_active_center(C, false, scene->cursor.location)) {
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
|
|
@ -163,14 +163,13 @@ const EnumPropertyItem rna_enum_transform_mode_types[] = {
|
|||
static int select_orientation_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
int orientation = RNA_enum_get(op->ptr, "orientation");
|
||||
|
||||
BKE_scene_orientation_slot_set_index(&scene->orientation_slots[SCE_ORIENT_DEFAULT], orientation);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
|
||||
WM_msg_publish_rna_prop(mbus, &scene->id, scene, TransformOrientationSlot, type);
|
||||
|
@ -286,7 +285,7 @@ static int create_orientation_exec(bContext *C, wmOperator *op)
|
|||
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue