Cleanup: rename generic handler -> handler_base

Avoids having type specific handler names.
This commit is contained in:
2019-02-20 10:05:40 +11:00
parent 4d83507f39
commit 079099e8db

View File

@@ -2343,7 +2343,6 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
#define PRINT if (do_debug_handler) printf #define PRINT if (do_debug_handler) printf
wmWindowManager *wm = CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
wmEventHandler *handler, *nexthandler;
int action = WM_HANDLER_CONTINUE; int action = WM_HANDLER_CONTINUE;
int always_pass; int always_pass;
@@ -2357,26 +2356,29 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
* by the event that's called, for eg: * by the event that's called, for eg:
* *
* Calling a python script which changes the area.type, see [#32232] */ * Calling a python script which changes the area.type, see [#32232] */
for (handler = handlers->first; handler && handlers->first; handler = nexthandler) { for (wmEventHandler *handler_base = handlers->first, *handler_base_next;
handler_base && handlers->first;
nexthandler = handler->next; handler_base = handler_base_next)
{
handler_base_next = handler_base->next;
/* during this loop, ui handlers for nested menus can tag multiple handlers free */ /* during this loop, ui handlers for nested menus can tag multiple handlers free */
if (handler->flag & WM_HANDLER_DO_FREE) { if (handler_base->flag & WM_HANDLER_DO_FREE) {
/* pass */ /* pass */
} }
else if (handler_boundbox_test(handler, event)) { /* optional boundbox */ else if (handler_boundbox_test(handler_base, event)) { /* optional boundbox */
/* in advance to avoid access to freed event on window close */ /* in advance to avoid access to freed event on window close */
always_pass = wm_event_always_pass(event); always_pass = wm_event_always_pass(event);
/* modal+blocking handler */ /* modal+blocking handler_base */
if (handler->flag & WM_HANDLER_BLOCKING) if (handler_base->flag & WM_HANDLER_BLOCKING) {
action |= WM_HANDLER_BREAK; action |= WM_HANDLER_BREAK;
}
/* Handle all types here. */ /* Handle all types here. */
if (handler->type == WM_HANDLER_TYPE_KEYMAP) { if (handler_base->type == WM_HANDLER_TYPE_KEYMAP) {
wmEventHandler_Keymap *handler_km = (wmEventHandler_Keymap *)handler; wmEventHandler_Keymap *handler = (wmEventHandler_Keymap *)handler_base;
wmKeyMap *keymap = WM_keymap_active(wm, handler_km->keymap); wmKeyMap *keymap = WM_keymap_active(wm, handler->keymap);
wmKeyMapItem *kmi; wmKeyMapItem *kmi;
PRINT("%s: checking '%s' ...", __func__, keymap->idname); PRINT("%s: checking '%s' ...", __func__, keymap->idname);
@@ -2387,17 +2389,17 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
for (kmi = keymap->items.first; kmi; kmi = kmi->next) { for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
if (wm_eventmatch(event, kmi)) { if (wm_eventmatch(event, kmi)) {
struct wmEventHandler_KeymapFn keymap_callback = handler_km->keymap_callback; struct wmEventHandler_KeymapFn keymap_callback = handler->keymap_callback;
PRINT("%s: item matched '%s'\n", __func__, kmi->idname); PRINT("%s: item matched '%s'\n", __func__, kmi->idname);
/* weak, but allows interactive callback to not use rawkey */ /* weak, but allows interactive callback to not use rawkey */
event->keymap_idname = kmi->idname; event->keymap_idname = kmi->idname;
action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr); action |= wm_handler_operator_call(C, handlers, handler_base, event, kmi->ptr);
if (action & WM_HANDLER_BREAK) { if (action & WM_HANDLER_BREAK) {
/* not always_pass here, it denotes removed handler */ /* not always_pass here, it denotes removed handler_base */
CLOG_INFO(WM_LOG_HANDLERS, 2, "handled! '%s'", kmi->idname); CLOG_INFO(WM_LOG_HANDLERS, 2, "handled! '%s'", kmi->idname);
if (keymap_callback.handle_post_fn != NULL) { if (keymap_callback.handle_post_fn != NULL) {
keymap_callback.handle_post_fn(keymap, kmi, keymap_callback.user_data); keymap_callback.handle_post_fn(keymap, kmi, keymap_callback.user_data);
@@ -2419,17 +2421,17 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
PRINT("fail\n"); PRINT("fail\n");
} }
} }
else if (handler->type == WM_HANDLER_TYPE_UI) { else if (handler_base->type == WM_HANDLER_TYPE_UI) {
wmEventHandler_UI *handler_ui = (wmEventHandler_UI *)handler; wmEventHandler_UI *handler = (wmEventHandler_UI *)handler_base;
BLI_assert(handler_ui->handle_fn != NULL); BLI_assert(handler->handle_fn != NULL);
if (!wm->is_interface_locked) { if (!wm->is_interface_locked) {
action |= wm_handler_ui_call(C, handler_ui, event, always_pass); action |= wm_handler_ui_call(C, handler, event, always_pass);
} }
} }
else if (handler->type == WM_HANDLER_TYPE_DROPBOX) { else if (handler_base->type == WM_HANDLER_TYPE_DROPBOX) {
wmEventHandler_Dropbox *handler_db = (wmEventHandler_Dropbox *)handler; wmEventHandler_Dropbox *handler = (wmEventHandler_Dropbox *)handler_base;
if (!wm->is_interface_locked && event->type == EVT_DROP) { if (!wm->is_interface_locked && event->type == EVT_DROP) {
wmDropBox *drop = handler_db->dropboxes->first; wmDropBox *drop = handler->dropboxes->first;
for (; drop; drop = drop->next) { for (; drop; drop = drop->next) {
/* other drop custom types allowed */ /* other drop custom types allowed */
if (event->custom == EVT_DATA_DRAGDROP) { if (event->custom == EVT_DATA_DRAGDROP) {
@@ -2471,19 +2473,19 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
} }
} }
} }
else if (handler->type == WM_HANDLER_TYPE_GIZMO) { else if (handler_base->type == WM_HANDLER_TYPE_GIZMO) {
wmEventHandler_Gizmo *handler_gz = (wmEventHandler_Gizmo *)handler; wmEventHandler_Gizmo *handler = (wmEventHandler_Gizmo *)handler_base;
ScrArea *area = CTX_wm_area(C); ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C); ARegion *region = CTX_wm_region(C);
wmGizmoMap *gzmap = handler_gz->gizmo_map; wmGizmoMap *gzmap = handler->gizmo_map;
BLI_assert(gzmap != NULL); BLI_assert(gzmap != NULL);
wmGizmo *gz = wm_gizmomap_highlight_get(gzmap); wmGizmo *gz = wm_gizmomap_highlight_get(gzmap);
if (region->gizmo_map != handler_gz->gizmo_map) { if (region->gizmo_map != handler->gizmo_map) {
WM_gizmomap_tag_refresh(handler_gz->gizmo_map); WM_gizmomap_tag_refresh(handler->gizmo_map);
} }
wm_gizmomap_handler_context_gizmo(C, handler_gz); wm_gizmomap_handler_context_gizmo(C, handler);
wm_region_mouse_co(C, event); wm_region_mouse_co(C, event);
/* handle gizmo highlighting */ /* handle gizmo highlighting */
@@ -2555,7 +2557,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
CTX_wm_gizmo_group_set(C, gzgroup); CTX_wm_gizmo_group_set(C, gzgroup);
/* handler->op is called later, we want keymap op to be triggered here */ /* handler->op is called later, we want keymap op to be triggered here */
action |= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr); action |= wm_handler_operator_call(C, handlers, handler_base, event, kmi->ptr);
CTX_wm_gizmo_group_set(C, NULL); CTX_wm_gizmo_group_set(C, NULL);
@@ -2599,16 +2601,16 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
CTX_wm_area_set(C, area); CTX_wm_area_set(C, area);
CTX_wm_region_set(C, region); CTX_wm_region_set(C, region);
} }
else if (handler->type == WM_HANDLER_TYPE_OP) { else if (handler_base->type == WM_HANDLER_TYPE_OP) {
wmEventHandler_Op *handler_op = (wmEventHandler_Op *)handler; wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
if (handler_op->is_fileselect) { if (handler->is_fileselect) {
if (!wm->is_interface_locked) { if (!wm->is_interface_locked) {
/* screen context changes here */ /* screen context changes here */
action |= wm_handler_fileselect_call(C, handlers, handler_op, event); action |= wm_handler_fileselect_call(C, handlers, handler, event);
} }
} }
else { else {
action |= wm_handler_operator_call(C, handlers, handler, event, NULL); action |= wm_handler_operator_call(C, handlers, handler_base, event, NULL);
} }
} }
else { else {
@@ -2633,10 +2635,10 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
/* XXX code this for all modal ops, and ensure free only happens here */ /* XXX code this for all modal ops, and ensure free only happens here */
/* modal ui handler can be tagged to be freed */ /* modal ui handler can be tagged to be freed */
if (BLI_findindex(handlers, handler) != -1) { /* could be freed already by regular modal ops */ if (BLI_findindex(handlers, handler_base) != -1) { /* could be freed already by regular modal ops */
if (handler->flag & WM_HANDLER_DO_FREE) { if (handler_base->flag & WM_HANDLER_DO_FREE) {
BLI_remlink(handlers, handler); BLI_remlink(handlers, handler_base);
wm_event_free_handler(handler); wm_event_free_handler(handler_base);
} }
} }
} }