Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_keymap.c
| Show First 20 Lines • Show All 1,327 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { | ||||
| if (kmi->flag & KMI_INACTIVE) { | if (kmi->flag & KMI_INACTIVE) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| bool kmi_match = false; | bool kmi_match = false; | ||||
| if (STREQ(kmi->idname, opname)) { | if (STREQ(kmi->idname, opname)) { | ||||
| if (properties) { | if (properties) { | ||||
| /* example of debugging keymaps */ | |||||
| #if 0 | |||||
| if (kmi->ptr) { | |||||
| if (STREQ("MESH_OT_rip_move", opname)) { | |||||
| printf("OPERATOR\n"); | |||||
| IDP_print(properties); | |||||
| printf("KEYMAP\n"); | |||||
| IDP_print(kmi->ptr->data); | |||||
| } | |||||
| } | |||||
| #endif | |||||
| if (kmi->ptr && IDP_EqualsProperties_ex(properties, kmi->ptr->data, is_strict)) { | if (kmi->ptr && IDP_EqualsProperties_ex(properties, kmi->ptr->data, is_strict)) { | ||||
| kmi_match = true; | kmi_match = true; | ||||
| } | } | ||||
| /* Debug only, helps spotting mismatches between menu entries and shortcuts! */ | /* Debug only, helps spotting mismatches between menu entries and shortcuts! */ | ||||
| else if (G.debug & G_DEBUG_WM) { | else if (CLOG_CHECK_IN_USE(WM_LOG_KEYMAPS)) { | ||||
| if (is_strict && kmi->ptr) { | if (is_strict && kmi->ptr) { | ||||
| wmOperatorType *ot = WM_operatortype_find(opname, true); | wmOperatorType *ot = WM_operatortype_find(opname, true); | ||||
| if (ot) { | if (ot) { | ||||
| /* make a copy of the properties and set unset ones to their default values. */ | /* make a copy of the properties and set unset ones to their default values. */ | ||||
| PointerRNA opptr; | PointerRNA opptr; | ||||
| IDProperty *properties_default = IDP_CopyProperty(kmi->ptr->data); | IDProperty *properties_default = IDP_CopyProperty(kmi->ptr->data); | ||||
| RNA_pointer_create(NULL, ot->srna, properties_default, &opptr); | RNA_pointer_create(NULL, ot->srna, properties_default, &opptr); | ||||
| WM_operator_properties_default(&opptr, true); | WM_operator_properties_default(&opptr, true); | ||||
| if (IDP_EqualsProperties_ex(properties, properties_default, is_strict)) { | if (IDP_EqualsProperties_ex(properties, properties_default, is_strict)) { | ||||
| char kmi_str[128]; | char kmi_str[128]; | ||||
| WM_keymap_item_to_string(kmi, false, kmi_str, sizeof(kmi_str)); | WM_keymap_item_to_string(kmi, false, kmi_str, sizeof(kmi_str)); | ||||
| /* Note gievn properties could come from other things than menu entry... */ | /* Note gievn properties could come from other things than menu entry... */ | ||||
| printf( | CLOG_VERBOSE(WM_LOG_KEYMAPS, | ||||
| 2, | |||||
| "%s: Some set values in menu entry match default op values, " | "%s: Some set values in menu entry match default op values, " | ||||
| "this might not be desired!\n", | "this might not be desired!\nkm: '%s', kmi: '%s'", | ||||
| opname); | opname, | ||||
| printf("\tkm: '%s', kmi: '%s'\n", keymap->idname, kmi_str); | keymap->idname, | ||||
| #ifndef NDEBUG | kmi_str); | ||||
| # ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| printf("OPERATOR\n"); | char *operator_str = IDP_sprintN(properties); | ||||
| IDP_print(properties); | CLOG_VERBOSE(WM_LOG_KEYMAPS, 4, "OPERATOR: %s", operator_str); | ||||
| printf("KEYMAP\n"); | MEM_freeN(operator_str); | ||||
| IDP_print(kmi->ptr->data); | char *keymap_str = IDP_sprintN(kmi->ptr->data); | ||||
| # endif | CLOG_VERBOSE(WM_LOG_KEYMAPS, 4, "KEYMAP: %s", keymap_str); | ||||
| MEM_freeN(keymap_str); | |||||
| #endif | #endif | ||||
| printf("\n"); | |||||
| } | } | ||||
| IDP_FreeProperty(properties_default); | IDP_FreeProperty(properties_default); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | if (ot && ot->prop) { /* XXX Shall we also check ot->prop is actually an enum? */ | ||||
| C, opname, opcontext, properties_temp, is_strict, params, r_keymap); | C, opname, opcontext, properties_temp, is_strict, params, r_keymap); | ||||
| } | } | ||||
| IDP_FreeProperty(properties_temp); | IDP_FreeProperty(properties_temp); | ||||
| } | } | ||||
| } | } | ||||
| /* Debug only, helps spotting mismatches between menu entries and shortcuts! */ | /* Debug only, helps spotting mismatches between menu entries and shortcuts! */ | ||||
| if (G.debug & G_DEBUG_WM) { | if (CLOG_CHECK_IN_USE(WM_LOG_KEYMAPS)) { | ||||
| if (!found && is_strict && properties) { | if (!found && is_strict && properties) { | ||||
| wmKeyMap *km; | wmKeyMap *km; | ||||
| wmKeyMapItem *kmi; | wmKeyMapItem *kmi; | ||||
| if (ot) { | if (ot) { | ||||
| /* make a copy of the properties and set unset ones to their default values. */ | /* make a copy of the properties and set unset ones to their default values. */ | ||||
| PointerRNA opptr; | PointerRNA opptr; | ||||
| IDProperty *properties_default = IDP_CopyProperty(properties); | IDProperty *properties_default = IDP_CopyProperty(properties); | ||||
| RNA_pointer_create(NULL, ot->srna, properties_default, &opptr); | RNA_pointer_create(NULL, ot->srna, properties_default, &opptr); | ||||
| WM_operator_properties_default(&opptr, true); | WM_operator_properties_default(&opptr, true); | ||||
| kmi = wm_keymap_item_find_props( | kmi = wm_keymap_item_find_props( | ||||
| C, opname, opcontext, properties_default, is_strict, params, &km); | C, opname, opcontext, properties_default, is_strict, params, &km); | ||||
| if (kmi) { | if (kmi) { | ||||
| char kmi_str[128]; | char kmi_str[128]; | ||||
| WM_keymap_item_to_string(kmi, false, kmi_str, sizeof(kmi_str)); | WM_keymap_item_to_string(kmi, false, kmi_str, sizeof(kmi_str)); | ||||
| printf( | CLOG_INFO(WM_LOG_KEYMAPS, | ||||
| "%s: Some set values in keymap entry match default op values, " | "%s: Some set values in keymap entry match default op values, " | ||||
| "this might not be desired!\n", | "this might not be desired!\nkm: '%s', kmi: '%s'", | ||||
| opname); | opname, | ||||
| printf("\tkm: '%s', kmi: '%s'\n", km->idname, kmi_str); | km->idname, | ||||
| #ifndef NDEBUG | kmi_str); | ||||
| # ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| printf("OPERATOR\n"); | char *operator_str = IDP_sprintN(properties); | ||||
| IDP_print(properties); | CLOG_VERBOSE(WM_LOG_KEYMAPS, 4, "OPERATOR: %s", operator_str); | ||||
| printf("KEYMAP\n"); | MEM_freeN(operator_str); | ||||
| IDP_print(kmi->ptr->data); | char *keymap_str = IDP_sprintN(kmi->ptr->data); | ||||
| # endif | CLOG_VERBOSE(WM_LOG_KEYMAPS, 4, "KEYMAP: %s", keymap_str); | ||||
| MEM_freeN(keymap_str); | |||||
| #endif | #endif | ||||
| printf("\n"); | |||||
| } | } | ||||
| IDP_FreeProperty(properties_default); | IDP_FreeProperty(properties_default); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return found; | return found; | ||||
| ▲ Show 20 Lines • Show All 454 Lines • Show Last 20 Lines | |||||