[Bf-blender-cvs] [ee79bde54df] master: Keymap: print more verbose output for --debug-handlers
Campbell Barton
noreply at git.blender.org
Mon Oct 4 00:37:24 CEST 2021
Commit: ee79bde54dfbaf9914224a32dae090c326b5998b
Author: Campbell Barton
Date: Sun Oct 3 13:02:22 2021 +1100
Branches: master
https://developer.blender.org/rBee79bde54dfbaf9914224a32dae090c326b5998b
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.
===================================================================
M source/blender/windowmanager/intern/wm_event_system.c
===================================================================
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);
More information about the Bf-blender-cvs
mailing list