Merge branch 'master' into blender2.8
[blender.git] / source / blender / windowmanager / intern / wm_keymap.c
index 39dd26339eb4a65b93a3c077cad5c6102d36358c..27b9710cb4530fbcf3ffa9fd96f8b07e08e2dd0a 100644 (file)
@@ -38,6 +38,7 @@
 #include "DNA_space_types.h"
 #include "DNA_userdef_types.h"
 #include "DNA_windowmanager_types.h"
+#include "DNA_workspace_types.h"
 
 #include "MEM_guardedalloc.h"
 #include "CLG_log.h"
@@ -51,6 +52,7 @@
 #include "BKE_global.h"
 #include "BKE_main.h"
 #include "BKE_screen.h"
+#include "BKE_workspace.h"
 
 #include "BLT_translation.h"
 
@@ -343,6 +345,12 @@ static wmKeyMap *wm_keymap_new(const char *idname, int spaceid, int regionid)
        km->spaceid = spaceid;
        km->regionid = regionid;
 
+       {
+               const char *owner_id = RNA_struct_state_owner_get();
+               if (owner_id) {
+                       BLI_strncpy(km->owner_id, owner_id, sizeof(km->owner_id));
+               }
+       }
        return km;
 }
 
@@ -403,6 +411,14 @@ bool WM_keymap_remove(wmKeyConfig *keyconf, wmKeyMap *keymap)
 
 bool WM_keymap_poll(bContext *C, wmKeyMap *keymap)
 {
+       /* If we're tagged, only use compatible. */
+       if (keymap->owner_id[0] != '\0') {
+               const WorkSpace *workspace = CTX_wm_workspace(C);
+               if (BKE_workspace_owner_id_check(workspace, keymap->owner_id) == false) {
+                       return false;
+               }
+       }
+
        if (keymap->poll != NULL) {
                return keymap->poll(C);
        }
@@ -1801,10 +1817,6 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
                                break;
                }
        }
-       /* Timeline */
-       else if (STRPREFIX(opname, "TIME_OT")) {
-               km = WM_keymap_find_all(C, "Timeline", sl->spacetype, 0);
-       }
        /* Image Editor */
        else if (STRPREFIX(opname, "IMAGE_OT")) {
                km = WM_keymap_find_all(C, "Image", sl->spacetype, 0);