diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-25 08:06:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-25 08:06:47 +0300 |
commit | 6d49b623e2efce59b58bb1295024ab8ac492370a (patch) | |
tree | ebe29d04b2e9730dfb4f7cd733e63e2676794dfc /source/blender/windowmanager/intern | |
parent | 46587b3ccb0ec842500ce2c3f2359b78550aad0f (diff) |
WM: space, region type filtering for paint cursor
Avoids calling poll on mouse-move for unrelated space/region types.
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 14 |
2 files changed, 22 insertions, 5 deletions
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index b76fc0abfa7..c8e0360ed88 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -85,7 +85,7 @@ /* ******************* paint cursor *************** */ -static void wm_paintcursor_draw(bContext *C, ARegion *ar) +static void wm_paintcursor_draw(bContext *C, ScrArea *sa, ARegion *ar) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); @@ -94,6 +94,15 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar) if (ar->visible && ar == screen->active_region) { for (pc = wm->paintcursors.first; pc; pc = pc->next) { + + if ((pc->space_type != SPACE_TYPE_ANY) && (sa->spacetype != pc->space_type)) { + continue; + } + + if ((pc->region_type != RGN_TYPE_ANY) && (ar->regiontype != pc->region_type)) { + continue; + } + if (pc->poll == NULL || pc->poll(C)) { /* Prevent drawing outside region. */ glEnable(GL_SCISSOR_TEST); @@ -612,7 +621,7 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) CTX_wm_region_set(C, ar); /* make region ready for draw, scissor, pixelspace */ - wm_paintcursor_draw(C, ar); + wm_paintcursor_draw(C, sa, ar); CTX_wm_region_set(C, NULL); CTX_wm_area_set(C, NULL); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index fa654e46cf1..e12107283a5 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1845,7 +1845,9 @@ static void WM_OT_console_toggle(wmOperatorType *ot) */ wmPaintCursor *WM_paint_cursor_activate( - wmWindowManager *wm, bool (*poll)(bContext *C), + wmWindowManager *wm, + short space_type, short region_type, + bool (*poll)(bContext *C), wmPaintCursorDraw draw, void *customdata) { wmPaintCursor *pc = MEM_callocN(sizeof(wmPaintCursor), "paint cursor"); @@ -1856,6 +1858,9 @@ wmPaintCursor *WM_paint_cursor_activate( pc->poll = poll; pc->draw = draw; + pc->space_type = space_type; + pc->region_type = region_type; + return pc; } @@ -2443,8 +2448,11 @@ static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *eve BLI_listbase_clear(&wm->paintcursors); /* add radial control paint cursor */ - rc->cursor = WM_paint_cursor_activate(wm, op->type->poll, - radial_control_paint_cursor, rc); + rc->cursor = WM_paint_cursor_activate( + wm, + SPACE_TYPE_ANY, RGN_TYPE_ANY, + op->type->poll, + radial_control_paint_cursor, rc); WM_event_add_modal_handler(C, op); |