Commit: bbb71ccbde023436a80230f286c1535afe96b753
Author: Campbell Barton
Date:   Wed Dec 12 15:52:34 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBbbb71ccbde023436a80230f286c1535afe96b753

Fix action-zones showing up as shortcuts

Toggle fullscreen area for eg, was showing the action-zone instead of
the key binding.

===================================================================

M       source/blender/windowmanager/intern/wm_keymap.c
M       source/blender/windowmanager/wm_event_types.h

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_keymap.c 
b/source/blender/windowmanager/intern/wm_keymap.c
index 311f34c0c74..13744aa04af 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -1169,7 +1169,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
 
                                bool kmi_match = false;
 
-                               if (STREQ(kmi->idname, opname) && 
WM_key_event_string(kmi->type, false)[0]) {
+                               if (STREQ(kmi->idname, opname)) {
                                        if (properties) {
                                                /* example of debugging keymaps 
*/
 #if 0
@@ -1389,12 +1389,24 @@ static wmKeyMapItem *wm_keymap_item_find(
        return found;
 }
 
+static bool kmi_filter_is_visible(const wmKeyMap *UNUSED(km), const 
wmKeyMapItem *kmi, void *UNUSED(user_data))
+{
+       return ((WM_key_event_string(kmi->type, false)[0] != '\0') &&
+               (IS_EVENT_ACTIONZONE(kmi->type) == false));
+}
+
 char *WM_key_event_operator_string(
         const bContext *C, const char *opname, int opcontext,
         IDProperty *properties, const bool is_strict,
         char *result, const int result_len)
 {
-       wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, 
properties, is_strict, NULL, NULL);
+       wmKeyMapItem *kmi = wm_keymap_item_find(
+               C, opname, opcontext, properties, is_strict,
+               &(struct wmKeyMapItemFind_Params){
+                   .filter_fn = kmi_filter_is_visible,
+                   .user_data = NULL,
+               },
+               NULL);
        if (kmi) {
                WM_keymap_item_to_string(kmi, false, result, result_len);
                return result;
@@ -1403,9 +1415,9 @@ char *WM_key_event_operator_string(
        return NULL;
 }
 
-static bool kmi_is_hotkey(const wmKeyMap *UNUSED(km), const wmKeyMapItem *kmi, 
void *UNUSED(user_data))
+static bool kmi_filter_is_visible_hotkey(const wmKeyMap *km, const 
wmKeyMapItem *kmi, void *user_data)
 {
-       return ISHOTKEY(kmi->type);
+       return (ISHOTKEY(kmi->type) && kmi_filter_is_visible(km, kmi, 
user_data));
 }
 
 wmKeyMapItem *WM_key_event_operator(
@@ -1415,9 +1427,8 @@ wmKeyMapItem *WM_key_event_operator(
 {
        return wm_keymap_item_find(
                C, opname, opcontext, properties, true,
-               (is_hotkey == false) ? NULL :
                &(struct wmKeyMapItemFind_Params){
-                   .filter_fn = kmi_is_hotkey,
+                   .filter_fn = is_hotkey ? kmi_filter_is_visible_hotkey : 
kmi_filter_is_visible,
                    .user_data = NULL,
                },
                r_keymap);
diff --git a/source/blender/windowmanager/wm_event_types.h 
b/source/blender/windowmanager/wm_event_types.h
index 40a3d148b7b..b2c4c0494ce 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -308,9 +308,11 @@ enum {
        TIMERF                = 0x011F,  /* last timer */
 
        /* Actionzones, tweak, gestures: 0x500x, 0x501x */
+#define EVT_ACTIONZONE_FIRST EVT_ACTIONZONE_AREA
        EVT_ACTIONZONE_AREA   = 0x5000,
        EVT_ACTIONZONE_REGION = 0x5001,
        EVT_ACTIONZONE_FULLSCREEN = 0x5011,
+#define EVT_ACTIONZONE_LAST (EVT_ACTIONZONE_FULLSCREEN + 1)
 
        /* NOTE: these values are saved in keymap files, do not change them but 
just add new ones */
 
@@ -374,6 +376,8 @@ enum {
 /* test whether the event is a NDOF event */
 #define ISNDOF(event_type)  ((event_type) >= NDOF_MOTION && (event_type) < 
NDOF_LAST)
 
+#define IS_EVENT_ACTIONZONE(event_type)  ((event_type) >= EVT_ACTIONZONE_FIRST 
&& (event_type) < EVT_ACTIONZONE_LAST)
+
 /* test whether event type is acceptable as hotkey, excluding modifiers */
 #define ISHOTKEY(event_type)                                                  \
        ((ISKEYBOARD(event_type) || ISMOUSE(event_type) || ISNDOF(event_type)) 
&& \

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to