Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/screen/workspace_listen.cc')
-rw-r--r--source/blender/editors/screen/workspace_listen.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/editors/screen/workspace_listen.cc b/source/blender/editors/screen/workspace_listen.cc
new file mode 100644
index 00000000000..84326007d66
--- /dev/null
+++ b/source/blender/editors/screen/workspace_listen.cc
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include "BKE_context.h"
+
+#include "ED_screen.h"
+#include "ED_viewer_path.hh"
+
+#include "WM_api.h"
+
+/**
+ * Checks if the viewer path stored in the workspace is still active and resets it if not.
+ * The viewer path stored in the workspace is the ground truth for other editors, so it should be
+ * updated before other editors look at it.
+ */
+static void validate_viewer_paths(bContext &C, WorkSpace &workspace)
+{
+ if (BLI_listbase_is_empty(&workspace.viewer_path.path)) {
+ return;
+ }
+
+ const std::optional<blender::ed::viewer_path::ViewerPathForGeometryNodesViewer> parsed_path =
+ blender::ed::viewer_path::parse_geometry_nodes_viewer(workspace.viewer_path);
+ if (parsed_path.has_value() &&
+ blender::ed::viewer_path::is_active_geometry_nodes_viewer(C, *parsed_path)) {
+ /* The current viewer path is still valid and active. */
+ return;
+ }
+ /* Reset inactive viewer path. */
+ BKE_viewer_path_clear(&workspace.viewer_path);
+ WM_event_add_notifier(&C, NC_VIEWER_PATH, nullptr);
+}
+
+void ED_workspace_do_listen(bContext *C, const wmNotifier * /*note*/)
+{
+ WorkSpace *workspace = CTX_wm_workspace(C);
+ validate_viewer_paths(*C, *workspace);
+}