UI: Region polling support #105088

Merged
Julian Eisel merged 39 commits from JulianEisel/blender:temp-region-poll into main 2023-04-05 15:30:46 +02:00
2 changed files with 4 additions and 19 deletions
Showing only changes of commit 73ec577c03 - Show all commits

View File

@ -156,13 +156,11 @@ typedef struct wmRegionMessageSubscribeParams {
} wmRegionMessageSubscribeParams;
typedef struct RegionPollParams {
/** Context in case non-WM context is needed. Any screen/area/region context should be obtained
* using the members below instead (avoids many context queries on redraws). */
const struct bContext *context;
const struct bScreen *screen;
const struct ScrArea *area;
const struct ARegion *region;
/* For now only WM context members here, could add the scene or even #bContext if needed. */
} RegionPollParams;
typedef struct ARegionType {

View File

@ -713,10 +713,7 @@ void ED_screens_init(Main *bmain, wmWindowManager *wm)
}
}
static bool region_poll(const bContext *C,
const bScreen *screen,
const ScrArea *area,
const ARegion *region)
static bool region_poll(const bScreen *screen, const ScrArea *area, const ARegion *region)
{
if (!region->type || !region->type->poll) {
/* Show region by default. */
@ -724,7 +721,6 @@ static bool region_poll(const bContext *C,
}
RegionPollParams params = {0};
params.context = C;
params.screen = screen;
params.area = area;
params.region = region;
@ -734,20 +730,14 @@ static bool region_poll(const bContext *C,
static void screen_regions_poll(bContext *C, const wmWindow *win, bScreen *screen)
{
ScrArea *previous_area = CTX_wm_area(C);
ARegion *previous_region = CTX_wm_region(C);
bool any_changed = false;
ED_screen_areas_iter (win, screen, area) {
CTX_wm_area_set(C, area);
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
const int old_region_flag = region->flag;
region->flag &= ~RGN_FLAG_POLL_FAILED;
CTX_wm_region_set(C, region);
if (region_poll(C, screen, area, region) == false) {
if (region_poll(screen, area, region) == false) {
region->flag |= RGN_FLAG_POLL_FAILED;
}
@ -764,9 +754,6 @@ static void screen_regions_poll(bContext *C, const wmWindow *win, bScreen *scree
if (any_changed) {
screen->do_refresh = true;
}
CTX_wm_area_set(C, previous_area);
CTX_wm_region_set(C, previous_region);
}
void ED_screen_ensure_updated(bContext *C, wmWindowManager *wm, wmWindow *win, bScreen *screen)