VSE in Preview mode, assigned hotkeys does not show in tooltip of transform tools in toolshelf #118190

Closed
opened 2024-02-13 09:47:48 +01:00 by Arunderan · 8 comments

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3060 Ti/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 536.23

Blender Version
Broken: version: 4.2.0 Alpha, branch: main, commit date: 2024-02-11 06:19, hash: 835b9a506d44
Worked: 4.0
Likely caused by fa6384eb39

Short description of error
Adding a shortcut to one of the transform tools in the vse toolshelf in preview mode does not show the shortcut in the tooltip, and is also not removeable. In the 3d view for example it is.

Exact steps for others to reproduce the error

  • In 3D View, add a shortcut to let's say the rotate tool in the tool shelf. Watch the tooltip. It shows the new shortcut. And it can be changed or removed in the right click menu.
  • In Video Sequencer in Preview mode, add a shortcut to let's say the rotate tool in the tool shelf. Watch the tooltip. It does not show the new shortcut. And it cannot be changed or removed in the right click menu.

Might be related: #92140

**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3060 Ti/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 536.23 **Blender Version** Broken: version: 4.2.0 Alpha, branch: main, commit date: 2024-02-11 06:19, hash: `835b9a506d44` Worked: 4.0 Likely caused by fa6384eb39f6f703bbbde06524c9246979876d3f **Short description of error** Adding a shortcut to one of the transform tools in the vse toolshelf in preview mode does not show the shortcut in the tooltip, and is also not removeable. In the 3d view for example it is. **Exact steps for others to reproduce the error** - In 3D View, add a shortcut to let's say the rotate tool in the tool shelf. Watch the tooltip. It shows the new shortcut. And it can be changed or removed in the right click menu. - In Video Sequencer in Preview mode, add a shortcut to let's say the rotate tool in the tool shelf. Watch the tooltip. It does not show the new shortcut. And it cannot be changed or removed in the right click menu. Might be related: https://projects.blender.org/blender/blender/issues/92140
Arunderan added the
Priority
Normal
Status
Needs Triage
Type
Report
labels 2024-02-13 09:47:48 +01:00
Member

Hi, thanks for the report. Can confirm
cc @iss

Hi, thanks for the report. Can confirm cc @iss

Will check

Will check

@Harley If you assign unused shortcut, VSE will not show it in tooltip, but also does not allow you to clear the shortcut.
In any case will check this more in detail now, and see if I can make sense of why this happens

@Harley If you assign unused shortcut, VSE will not show it in tooltip, but also does not allow you to clear the shortcut. In any case will check this more in detail now, and see if I can make sense of why this happens

I think, that priority could be lowered, since this is not exacly caused by anything, as assigning shortcuts to VSE tools did not work before.

Will post findings here in edits in order to not spam this thread:
So far it seems, that but->opcontext is set to incorrect value in ui_popup_context_menu_for_button()
Ok, so attempt to set but->opcontext from ED_region_panels_ex() is completely wrong. Even if this is fixed, it doesn't seem to work.

I think, that priority could be lowered, since this is not exacly caused by anything, as assigning shortcuts to VSE tools did not work before. Will post findings here in edits in order to not spam this thread: So far it seems, that `but->opcontext` is set to incorrect value in `ui_popup_context_menu_for_button()` Ok, so attempt to set ` but->opcontext` from `ED_region_panels_ex()` is completely wrong. Even if this is fixed, it doesn't seem to work.
Member

@iss

I am a little over my skiis here since I don't know these areas very well. So the following might only give clues to what the problem might be, not necessarily the fix.

But with the following changes...

diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc
index 6d28b25730c..97755234ed3 100644
--- a/source/blender/editors/interface/interface_context_menu.cc
+++ b/source/blender/editors/interface/interface_context_menu.cc
@@ -293,14 +293,10 @@ static void remove_shortcut_func(bContext *C, uiBut *but)
   IDProperty *prop;
   const char *idname = shortcut_get_operator_property(C, but, &prop);
 
-  wmKeyMap *km;
-  wmKeyMapItem *kmi = WM_key_event_operator(C,
-                                            idname,
-                                            but->opcontext,
-                                            prop,
-                                            EVT_TYPE_MASK_HOTKEY_INCLUDE,
-                                            EVT_TYPE_MASK_HOTKEY_EXCLUDE,
-                                            &km);
+  wmKeyMap *km = WM_keymap_guess_opname(C, idname);
+  wmKeyMapItem *kmi = WM_key_event_operator_from_keymap(
+      km, idname, prop, EVT_TYPE_MASK_HOTKEY_INCLUDE, EVT_TYPE_MASK_HOTKEY_EXCLUDE);
+
   BLI_assert(kmi != nullptr);
 
   WM_keymap_remove_item(km, kmi);
@@ -1156,9 +1152,8 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
     const int w = uiLayoutGetWidth(layout);
 
     /* We want to know if this op has a shortcut, be it hotkey or not. */
-    wmKeyMap *km;
-    wmKeyMapItem *kmi = WM_key_event_operator(
-        C, idname, but->opcontext, prop, EVT_TYPE_MASK_ALL, 0, &km);
+    wmKeyMap *km = WM_keymap_guess_opname(C, idname);
+    wmKeyMapItem *kmi = WM_key_event_operator_from_keymap(km, idname, prop, EVT_TYPE_MASK_ALL, 0);
 
     /* We do have a shortcut, but only keyboard ones are editable that way... */
     if (kmi) {
diff --git a/source/blender/windowmanager/intern/wm_keymap.cc b/source/blender/windowmanager/intern/wm_keymap.cc
index 200dd8953a0..5a04b0a9db2 100644
--- a/source/blender/windowmanager/intern/wm_keymap.cc
+++ b/source/blender/windowmanager/intern/wm_keymap.cc
@@ -1634,8 +1634,10 @@ std::optional<std::string> WM_key_event_operator_string(const bContext *C,
   wmKeyMapItemFind_Params params{};
   params.filter_fn = kmi_filter_is_visible;
   params.user_data = nullptr;
-  wmKeyMapItem *kmi = wm_keymap_item_find(
-      C, opname, opcontext, properties, is_strict, &params, nullptr);
+  wmKeyMap *km = WM_keymap_guess_opname(C, opname);
+  wmKeyMapItem *kmi = WM_key_event_operator_from_keymap(
+      km, opname, properties, EVT_TYPE_MASK_HOTKEY_INCLUDE, EVT_TYPE_MASK_HOTKEY_EXCLUDE);
+
   if (kmi) {
     return WM_keymap_item_to_string(kmi, false);
   }

The change to remove_shortcut_func allows the shortcut removal to work without error. Changes to ui_popup_context_menu_for_button allows the "remove shortcut" to appear in the context menu. And changes to WM_key_event_operator_string then show the shortcut on the tooltip.

But I really have no idea why this way of getting the wmKeyMap and wmKeyMapItem (using WM_keymap_guess_opname and WM_key_event_operator_from_keymap) work in these cases while wm_keymap_item_find and WM_key_event_operator do not. So I don't know if this points to errors in the latter, or if the above changes would have some bad side effects.

I am assuming you know this stuff better than me. If not, I could always post this as a fix for this issue and assign Campbell as reviewer?

@iss I am a little over my skiis here since I don't know these areas very well. So the following might only give clues to what the problem might be, not necessarily the fix. But with the following changes... ``` diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index 6d28b25730c..97755234ed3 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -293,14 +293,10 @@ static void remove_shortcut_func(bContext *C, uiBut *but) IDProperty *prop; const char *idname = shortcut_get_operator_property(C, but, &prop); - wmKeyMap *km; - wmKeyMapItem *kmi = WM_key_event_operator(C, - idname, - but->opcontext, - prop, - EVT_TYPE_MASK_HOTKEY_INCLUDE, - EVT_TYPE_MASK_HOTKEY_EXCLUDE, - &km); + wmKeyMap *km = WM_keymap_guess_opname(C, idname); + wmKeyMapItem *kmi = WM_key_event_operator_from_keymap( + km, idname, prop, EVT_TYPE_MASK_HOTKEY_INCLUDE, EVT_TYPE_MASK_HOTKEY_EXCLUDE); + BLI_assert(kmi != nullptr); WM_keymap_remove_item(km, kmi); @@ -1156,9 +1152,8 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev const int w = uiLayoutGetWidth(layout); /* We want to know if this op has a shortcut, be it hotkey or not. */ - wmKeyMap *km; - wmKeyMapItem *kmi = WM_key_event_operator( - C, idname, but->opcontext, prop, EVT_TYPE_MASK_ALL, 0, &km); + wmKeyMap *km = WM_keymap_guess_opname(C, idname); + wmKeyMapItem *kmi = WM_key_event_operator_from_keymap(km, idname, prop, EVT_TYPE_MASK_ALL, 0); /* We do have a shortcut, but only keyboard ones are editable that way... */ if (kmi) { diff --git a/source/blender/windowmanager/intern/wm_keymap.cc b/source/blender/windowmanager/intern/wm_keymap.cc index 200dd8953a0..5a04b0a9db2 100644 --- a/source/blender/windowmanager/intern/wm_keymap.cc +++ b/source/blender/windowmanager/intern/wm_keymap.cc @@ -1634,8 +1634,10 @@ std::optional<std::string> WM_key_event_operator_string(const bContext *C, wmKeyMapItemFind_Params params{}; params.filter_fn = kmi_filter_is_visible; params.user_data = nullptr; - wmKeyMapItem *kmi = wm_keymap_item_find( - C, opname, opcontext, properties, is_strict, &params, nullptr); + wmKeyMap *km = WM_keymap_guess_opname(C, opname); + wmKeyMapItem *kmi = WM_key_event_operator_from_keymap( + km, opname, properties, EVT_TYPE_MASK_HOTKEY_INCLUDE, EVT_TYPE_MASK_HOTKEY_EXCLUDE); + if (kmi) { return WM_keymap_item_to_string(kmi, false); } ``` The change to `remove_shortcut_func` allows the shortcut removal to work without error. Changes to `ui_popup_context_menu_for_button` allows the "remove shortcut" to appear in the context menu. And changes to `WM_key_event_operator_string` then show the shortcut on the tooltip. But I really have no idea why this way of getting the wmKeyMap and wmKeyMapItem (using WM_keymap_guess_opname and WM_key_event_operator_from_keymap) work in these cases while `wm_keymap_item_find` and `WM_key_event_operator` do not. So I don't know if this points to errors in the latter, or if the above changes would have some bad side effects. I am assuming you know this stuff better than me. If not, I could always post this as a fix for this issue and assign Campbell as reviewer?

Thanks for your pointers. Preview area should set but->opcontext for toolbar, but for some reason it is not picked up. Hardcoding opcontext for WM_key_event_operator() in ui_popup_context_menu_for_button() also causes VSE toolbar to work. So I would say, that code is OK and issue is somewhere on VSE UI side. I am also struggling a bit to follow data structures here and figuring out where to put debug prints :) Your code snippet is pretty much black magic :P

Thanks for your pointers. Preview area should set `but->opcontext` for toolbar, but for some reason it is not picked up. Hardcoding opcontext for `WM_key_event_operator() ` in `ui_popup_context_menu_for_button()` also causes VSE toolbar to work. So I would say, that code is OK and issue is somewhere on VSE UI side. I am also struggling a bit to follow data structures here and figuring out where to put debug prints :) Your code snippet is pretty much black magic :P
Member

So I would say, that code is OK and issue is somewhere on VSE UI side

Yes, that sounds right. My change probably just ignores that error and might cause problems elsewhere.

Preview area should set but->opcontext for toolbar, but for some reason it is not picked up. Hardcoding opcontext...

Oh, I see. That part works if you force it to WM_OP_INVOKE_REGION_PREVIEW. I see it set to WM_OP_INVOKE_REGION_WIN at that point.

A weird thing I am seeing is that sequencer_tools_region_draw seems to always set WM_OP_INVOKE_REGION_WIN. It has a switch in there that I never see hitting any of the cases. I only see this function called with a region->regiontype of RGN_TYPE_TOOLS, which makes sense to me because that is the type of the region as it is defined at about line 1047.

However, if I change sequencer_tools_region_draw to always sets an op_context of WM_OP_INVOKE_REGION_PREVIEW it doesn't seem to do anything. As in the op_context when it is evaluated in ui_popup_context_menu_for_button is still WM_OP_INVOKE_REGION_WIN.

> So I would say, that code is OK and issue is somewhere on VSE UI side Yes, that sounds right. My change probably just ignores that error and might cause problems elsewhere. > Preview area should set but->opcontext for toolbar, but for some reason it is not picked up. Hardcoding opcontext... Oh, I see. That part works if you force it to WM_OP_INVOKE_REGION_PREVIEW. I see it set to WM_OP_INVOKE_REGION_WIN at that point. A weird thing I am seeing is that `sequencer_tools_region_draw` seems to always set WM_OP_INVOKE_REGION_WIN. It has a switch in there that I never see hitting any of the cases. I only see this function called with a region->regiontype of RGN_TYPE_TOOLS, which makes sense to me because that is the type of the region as it is defined at about line 1047. However, if I change `sequencer_tools_region_draw` to always sets an op_context of WM_OP_INVOKE_REGION_PREVIEW it doesn't seem to do anything. As in the op_context when it is evaluated in ui_popup_context_menu_for_button is still WM_OP_INVOKE_REGION_WIN.

Well turns out, that solution looks about like #118292. That somehow works for toolbar in timeline, which it should not...

Well turns out, that solution looks about like #118292. That somehow works for toolbar in timeline, which it should not...
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-02-16 18:06:45 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser Project (Legacy)
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#118190
No description provided.