Tool System: per space/mode tool support
[blender.git] / source / blender / windowmanager / intern / wm_event_system.c
index 7963bf16534518ca93b06d8fda06b082b812e6ce..8bbbd1b60dfcce4ba270a12a2a8914795095c9b0 100644 (file)
@@ -2875,11 +2875,14 @@ void wm_event_do_handlers(bContext *C)
                                                                        wmEventHandler sneaky_handler = {NULL};
                                                                        if (ar->regiontype == RGN_TYPE_WINDOW) {
                                                                                WorkSpace *workspace = WM_window_get_active_workspace(win);
-                                                                               if (workspace->tool.keymap[0] &&
-                                                                                   workspace->tool.spacetype == sa->spacetype)
-                                                                               {
+                                                                               const bToolKey tkey = {
+                                                                                       .space_type = sa->spacetype,
+                                                                                       .mode = WM_toolsystem_mode_from_spacetype(workspace, win->scene, sa, sa->spacetype),
+                                                                               };
+                                                                               bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_find(workspace, &tkey);
+                                                                               if (tref_rt && tref_rt->keymap[0]) {
                                                                                        wmKeyMap *km = WM_keymap_find_all(
-                                                                                               C, workspace->tool.keymap, sa->spacetype, RGN_TYPE_WINDOW);
+                                                                                               C, tref_rt->keymap, sa->spacetype, RGN_TYPE_WINDOW);
                                                                                        if (km != NULL) {
                                                                                                sneaky_handler.keymap = km;
                                                                                                /* Handle widgets first. */