From d920e6a3785f054ee306ba7712cd0cdafc3e02ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= <sybren@blender.org>
Date: Thu, 7 Oct 2021 17:39:03 +0200
Subject: [PATCH] Pose Library: do a broader search for the asset browser

When creating a pose, it gets assigned to the catalog that is currently
shown in the asset browser. To find which asset browser to use for this,
if the current window does not contain one, other windows are considered
as well. Before this change this was limited to the current screen.
---
 pose_library/asset_browser.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/pose_library/asset_browser.py b/pose_library/asset_browser.py
index 036a271bf..a95e48fe3 100644
--- a/pose_library/asset_browser.py
+++ b/pose_library/asset_browser.py
@@ -53,7 +53,19 @@ def area_from_context(context: bpy.types.Context) -> Optional[bpy.types.Area]:
     if asset_utils.SpaceAssetInfo.is_asset_browser(space_data):
         return context.area
 
-    return biggest_asset_browser_area(context.screen)
+    # Try the current screen first.
+    browser_area = biggest_asset_browser_area(context.screen)
+    if browser_area:
+        return browser_area
+
+    for win in context.window_manager.windows:
+        if win.screen == context.screen:
+            continue
+        browser_area = biggest_asset_browser_area(win.screen)
+        if browser_area:
+            return browser_area
+
+    return None
 
 
 def activate_asset(
-- 
GitLab