diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/windowmanager/WM_keymap.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 19 |
3 files changed, 23 insertions, 1 deletions
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h index 0e8a468192c..7f7612cea35 100644 --- a/source/blender/windowmanager/WM_keymap.h +++ b/source/blender/windowmanager/WM_keymap.h @@ -74,8 +74,10 @@ bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem * int WM_keymap_item_to_string(wmKeyMapItem *kmi, const bool compact, char *result, const int result_len); wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid); +wmKeyMap *WM_keymap_list_find_spaceid_or_empty(ListBase *lb, const char *idname, int spaceid, int regionid); wmKeyMap *WM_keymap_ensure(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid); wmKeyMap *WM_keymap_find_all(const struct bContext *C, const char *idname, int spaceid, int regionid); +wmKeyMap *WM_keymap_find_all_spaceid_or_empty(const struct bContext *C, const char *idname, int spaceid, int regionid); wmKeyMap *WM_keymap_active(struct wmWindowManager *wm, struct wmKeyMap *keymap); bool WM_keymap_remove(struct wmKeyConfig *keyconfig, struct wmKeyMap *keymap); bool WM_keymap_poll(struct bContext *C, struct wmKeyMap *keymap); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index f760b95a1f2..23c149b46b5 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2860,8 +2860,9 @@ static void wm_event_temp_tool_handler_apply( if (ar->regiontype == RGN_TYPE_WINDOW) { bToolRef_Runtime *tref_rt = sa->runtime.tool ? sa->runtime.tool->runtime : NULL; if (tref_rt && tref_rt->keymap[0]) { - wmKeyMap *km = WM_keymap_find_all( + wmKeyMap *km = WM_keymap_find_all_spaceid_or_empty( C, tref_rt->keymap, sa->spacetype, RGN_TYPE_WINDOW); + /* We shouldn't use keymaps from unrelated spaces. */ if (km != NULL) { // printf("Keymap: '%s' -> '%s'\n", tref_rt->keymap, sa->runtime.tool->idname); sneaky_handler->keymap = km; diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 27c816a4d7d..4c00b99e13e 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -806,6 +806,18 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int return NULL; } +wmKeyMap *WM_keymap_list_find_spaceid_or_empty(ListBase *lb, const char *idname, int spaceid, int regionid) +{ + wmKeyMap *km; + + for (km = lb->first; km; km = km->next) + if (ELEM(km->spaceid, spaceid, SPACE_EMPTY) && km->regionid == regionid) + if (STREQLEN(idname, km->idname, KMAP_MAX_NAME)) + return km; + + return NULL; +} + wmKeyMap *WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid) { wmKeyMap *km = WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid); @@ -827,6 +839,13 @@ wmKeyMap *WM_keymap_find_all(const bContext *C, const char *idname, int spaceid, return WM_keymap_list_find(&wm->userconf->keymaps, idname, spaceid, regionid); } +wmKeyMap *WM_keymap_find_all_spaceid_or_empty(const bContext *C, const char *idname, int spaceid, int regionid) +{ + wmWindowManager *wm = CTX_wm_manager(C); + + return WM_keymap_list_find_spaceid_or_empty(&wm->userconf->keymaps, idname, spaceid, regionid); +} + /* ****************** modal keymaps ************ */ /* modal maps get linked to a running operator, and filter the keys before sending to modal() callback */ |