diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-10-03 05:02:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-10-04 01:28:33 +0300 |
commit | ee79bde54dfbaf9914224a32dae090c326b5998b (patch) | |
tree | fe75cbbaec678bbdbff0bded179750529241dc63 /source/blender/windowmanager/intern/wm_event_system.c | |
parent | c4dca6522812670ab9782e4f90553c5054109f3d (diff) |
Keymap: print more verbose output for --debug-handlers
Include the short-cut text and the operator properties to make it easier
to track down the key-map item source that matched the event.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_event_system.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 537d5264ba9..cc0a13e96af 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2665,7 +2665,34 @@ static int wm_handlers_do_keymap_with_keymap_handler( if (wm_eventmatch(event, kmi)) { struct wmEventHandler_KeymapPost keymap_post = handler->post; - PRINT("%s: item matched '%s'\n", __func__, kmi->idname); + if (do_debug_handler) { + /* Short representation of the key that was pressed, + * include this since it may differ from the event in minor details + * which can help looking up the key-map definition. */ + char kmi_buf[256]; + WM_keymap_item_to_string(kmi, false, kmi_buf, sizeof(kmi_buf)); + + /* The key-map item properties can further help distinguish this item from others. */ + char *kmi_props = NULL; + if (kmi->properties != NULL) { + wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); + if (ot) { + kmi_props = RNA_pointer_as_string_keywords(C, kmi->ptr, false, false, true, 512); + } + else { /* Fallback. */ + kmi_props = IDP_reprN(kmi->properties, NULL); + } + } + + printf("%s: item matched: \"%s\", %s(%s)\n", + __func__, + kmi_buf, + kmi->idname, + kmi_props ? kmi_props : ""); + if (kmi_props != NULL) { + MEM_freeN(kmi_props); + } + } action |= wm_handler_operator_call( C, handlers, &handler->head, event, kmi->ptr, kmi->idname); |