Commit: 66c6cf0d7120737a90c9762a38188f7d4d49ad01
Author: jon denning
Date:   Tue Jul 26 09:50:35 2022 -0400
Branches: retopo_transform
https://developer.blender.org/rB66c6cf0d7120737a90c9762a38188f7d4d49ad01

Added operator to determine if operator is actively modal

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

M       source/blender/makesrna/intern/rna_wm_api.c
M       source/blender/windowmanager/WM_api.h
M       source/blender/windowmanager/intern/wm_window.c

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

diff --git a/source/blender/makesrna/intern/rna_wm_api.c 
b/source/blender/makesrna/intern/rna_wm_api.c
index b82458c4442..c57583d0969 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -714,6 +714,11 @@ void RNA_api_window(StructRNA *srna)
   FunctionRNA *func;
   PropertyRNA *parm;
 
+  func = RNA_def_function(srna, "is_operator_modal", 
"WM_active_modal_operator_test");
+  RNA_def_function_ui_description(func, "Test if an operator is actively 
running modal.");
+  parm = RNA_def_boolean(func, "result", 0, "", "Operator running modal");
+  RNA_def_function_return(func, parm);
+
   func = RNA_def_function(srna, "cursor_warp", "WM_cursor_warp");
   parm = RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
diff --git a/source/blender/windowmanager/WM_api.h 
b/source/blender/windowmanager/WM_api.h
index 44c5b86857d..f7d67274766 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -310,6 +310,11 @@ void WM_paint_cursor_remove_by_type(struct wmWindowManager 
*wm,
                                     void (*free)(void *));
 void WM_paint_cursor_tag_redraw(struct wmWindow *win, struct ARegion *region);
 
+/**
+ * Determines whether an operator is actively running modal.
+ */
+bool WM_active_modal_operator_test(struct wmWindow *win);
+
 /**
  * This function requires access to the GHOST_SystemHandle (g_system).
  */
diff --git a/source/blender/windowmanager/intern/wm_window.c 
b/source/blender/windowmanager/intern/wm_window.c
index a1ebe1fc76f..148b4419aaf 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -2000,6 +2000,22 @@ void WM_init_native_pixels(bool do_it)
 
 /** \} */
 
+/* -------------------------------------------------------------------- */
+/** \name Operator API
+ * \{ */
+
+bool WM_active_modal_operator_test(struct wmWindow *win)
+{
+  LISTBASE_FOREACH (wmEventHandler *, handler_base, &win->modalhandlers) {
+    if (handler_base->type == WM_HANDLER_TYPE_OP) {
+      return true;
+    }
+  }
+  return false;
+}
+
+/** \} */
+
 /* -------------------------------------------------------------------- */
 /** \name Cursor API
  * \{ */

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to