[Bf-blender-cvs] [ba4e5399fc8] master: Fix screenshot editor showing status text in the editor

Campbell Barton noreply at git.blender.org
Thu Oct 7 19:08:42 CEST 2021


Commit: ba4e5399fc85e318c41380b0b1c81b23a8334786
Author: Campbell Barton
Date:   Fri Oct 8 03:59:20 2021 +1100
Branches: master
https://developer.blender.org/rBba4e5399fc85e318c41380b0b1c81b23a8334786

Fix screenshot editor showing status text in the editor

This caused problems calling screenshot from menu-search
which included the status text in the screenshot.

Now the status text is shown in the global status bar
for any operators called from a screen context.

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

M	release/scripts/startup/bl_ui/space_topbar.py
M	source/blender/windowmanager/WM_types.h
M	source/blender/windowmanager/intern/wm_event_system.c

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

diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 1d75ad8ff0a..9d5e2a78631 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -634,6 +634,8 @@ class TOPBAR_MT_window(Menu):
 
         layout = self.layout
 
+        operator_context_default = layout.operator_context
+
         layout.operator("wm.window_new")
         layout.operator("wm.window_new_main")
 
@@ -655,7 +657,15 @@ class TOPBAR_MT_window(Menu):
         layout.separator()
 
         layout.operator("screen.screenshot")
+
+        # Showing the status in the area doesn't work well in this case.
+        # - From the top-bar, the text replaces the file-menu (not so bad but strange).
+        # - From menu-search it replaces the area that the user may want to screen-shot.
+        # Setting the context to screen causes the status to show in the global status-bar.
+        print(layout.operator_context)
+        layout.operator_context = 'INVOKE_SCREEN'
         layout.operator("screen.screenshot_area")
+        layout.operator_context = operator_context_default
 
         if sys.platform[:3] == "win":
             layout.separator()
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 28c7a270554..c4612485e5a 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -227,6 +227,10 @@ enum {
   WM_OP_EXEC_SCREEN,
 };
 
+#define WM_OP_CONTEXT_HAS_AREA(type) (!ELEM(type, WM_OP_INVOKE_SCREEN, WM_OP_EXEC_SCREEN))
+#define WM_OP_CONTEXT_HAS_REGION(type) \
+  (WM_OP_CONTEXT_HAS_AREA(type) && !ELEM(type, WM_OP_INVOKE_AREA, WM_OP_EXEC_AREA))
+
 /* property tags for RNA_OperatorProperties */
 typedef enum eOperatorPropTags {
   OP_PROP_TAG_ADVANCED = (1 << 0),
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index f4753c7c190..785434c301c 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1790,7 +1790,10 @@ void WM_operator_name_call_ptr_with_depends_on_cursor(
   }
 
   wmWindow *win = CTX_wm_window(C);
-  ScrArea *area = CTX_wm_area(C);
+  /* The operator context is applied when the operator is called,
+   * the check for the area needs to be explicitly limited here.
+   * Useful so it's possible to screen-shot an area without drawing into it's header. */
+  ScrArea *area = WM_OP_CONTEXT_HAS_AREA(opcontext) ? CTX_wm_area(C) : NULL;
 
   {
     char header_text[UI_MAX_DRAW_STR];



More information about the Bf-blender-cvs mailing list