@@ -25,7 +25,12 @@ After embedding you will be able to use the following methods:
2525
2626local MAJOR = " LibMagicUtil-1.0"
2727local MINOR = tonumber (" @project-date-integer@" ) or tonumber (date (" %Y%m%d%H%M%S" ))
28-
28+ -- Standalone addon sets this flag via bootstrap.lua (loaded from .toc before lib.xml).
29+ -- Embedded copies don't run bootstrap.lua, so the flag is nil for them.
30+ -- Bumping MINOR ensures the standalone copy always wins over embedded copies.
31+ if LIBMAGICUTIL_STANDALONE then
32+ MINOR = MINOR + 1
33+ end
2934local lib = LibStub :NewLibrary (MAJOR , MINOR )
3035local media = LibStub (" LibSharedMedia-3.0" )
3136local L = LibStub (" AceLocale-3.0" ):GetLocale (" LibMagicUtil-1.0" , false )
@@ -256,19 +261,42 @@ function lib:InterfaceOptionsFrame_OpenToCategory(categoryIDOrFrame)
256261 end
257262end
258263
259- -- Returns the currently visible mail frame. Checks for TSM's mail frame first
260- -- (which replaces the default MailFrame), then falls back to the default MailFrame.
264+ -- Returns the active mail frame and whether it's TSM.
265+ -- Second return value is true if the returned frame is TSM's mail frame.
266+ -- Finds TSM's mail window by looking for the MailsScrollTable element
267+ -- (unique to TSM's mail UI) and walking up to the top-level parent.
268+ local cachedTSMMailFrame
269+ local function FindTSMMailFrame ()
270+ if cachedTSMMailFrame then
271+ return cachedTSMMailFrame
272+ end
273+ -- Find MailsScrollTable, then walk up to the LargeApplicationFrame
274+ local frame = EnumerateFrames ()
275+ while frame do
276+ local name = frame :GetName ()
277+ if name and type (name ) == " string" and name :match (" ^TSM_FRAME:MailsScrollTable:" ) then
278+ -- Walk up the parent chain to find the top-level TSM frame
279+ local parent = frame :GetParent ()
280+ while parent and parent ~= UIParent do
281+ local parentName = parent :GetName ()
282+ if parentName and type (parentName ) == " string" and parentName :match (" ^TSM_FRAME:LargeApplicationFrame:" ) then
283+ cachedTSMMailFrame = parent
284+ return parent
285+ end
286+ parent = parent :GetParent ()
287+ end
288+ end
289+ frame = EnumerateFrames (frame )
290+ end
291+ return nil
292+ end
293+
261294function lib :GetMailFrame ()
262- for i = 1 , # UISpecialFrames do
263- local name = UISpecialFrames [i ]
264- if name :match (" ^TSM_FRAME:LargeApplicationFrame:" ) then
265- local frame = _G [name ]
266- if frame and frame :IsShown () then
267- return frame
268- end
269- end
270- end
271- return MailFrame
295+ local tsmFrame = FindTSMMailFrame ()
296+ if tsmFrame and tsmFrame :IsShown () then
297+ return tsmFrame , true
298+ end
299+ return MailFrame , false
272300end
273301
274302-- Config template for a frame background
0 commit comments