Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-01-19 02:28:47 +0300
committerHans Goudey <h.goudey@me.com>2021-01-19 02:28:47 +0300
commit09c7c638905230a608a9b0204b68c775cf71bf67 (patch)
tree4b21efd9b23283ef236e756f46e3f75f5d2e6c61 /source/blender/windowmanager
parent4b4aec288458dd24721fdd61af38d3c316c2520b (diff)
UI Code Quality: Use "params" struct for area and region callbacks
These functions with many arguments can be unwieldy. Aside from the obvious issues with rewriting the list of arguments and the opportunities for error and frustration that presents, the long list of arguments make these systems hard to change. So when an argument should be added, someone might skip that and add some hack instead. So, as proposed in T73586#1037210, this patch instead uses a "params" struct for each of these callbacks. - Use param argument for `ARegionType.listener` - Remove unused window field in region listener - Use param argument for `SpaceType.listener` - Use params struct for `ARegionType.message_subscribe` Differential Revision: https://developer.blender.org/D9750
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/gizmo/WM_gizmo_api.h2
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c2
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c24
3 files changed, 23 insertions, 5 deletions
diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h
index 70ddae4d724..cf1a7628267 100644
--- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h
+++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h
@@ -301,7 +301,7 @@ void WM_gizmomap_draw(struct wmGizmoMap *gzmap,
void WM_gizmomap_add_handlers(struct ARegion *region, struct wmGizmoMap *gzmap);
bool WM_gizmomap_select_all(struct bContext *C, struct wmGizmoMap *gzmap, const int action);
bool WM_gizmomap_cursor_set(const struct wmGizmoMap *gzmap, struct wmWindow *win);
-void WM_gizmomap_message_subscribe(struct bContext *C,
+void WM_gizmomap_message_subscribe(const struct bContext *C,
struct wmGizmoMap *gzmap,
struct ARegion *region,
struct wmMsgBus *mbus);
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index 479768c3536..12c6eb46c12 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -1156,7 +1156,7 @@ ListBase *wm_gizmomap_groups_get(wmGizmoMap *gzmap)
return &gzmap->groups;
}
-void WM_gizmomap_message_subscribe(bContext *C,
+void WM_gizmomap_message_subscribe(const bContext *C,
wmGizmoMap *gzmap,
ARegion *region,
struct wmMsgBus *mbus)
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 859336d0338..d08051dd5fb 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -543,13 +543,31 @@ void wm_event_do_notifiers(bContext *C)
ED_screen_do_listen(C, note);
LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
- ED_region_do_listen(win, NULL, region, note, scene);
+ wmRegionListenerParams region_params = {
+ .area = NULL,
+ .region = region,
+ .scene = scene,
+ .notifier = note,
+ };
+ ED_region_do_listen(&region_params);
}
ED_screen_areas_iter (win, screen, area) {
- ED_area_do_listen(win, area, note, scene);
+ wmSpaceTypeListenerParams area_params = {
+ .window = win,
+ .area = area,
+ .notifier = note,
+ .scene = scene,
+ };
+ ED_area_do_listen(&area_params);
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
- ED_region_do_listen(win, area, region, note, scene);
+ wmRegionListenerParams region_params = {
+ .area = area,
+ .region = region,
+ .scene = scene,
+ .notifier = note,
+ };
+ ED_region_do_listen(&region_params);
}
}
}