diff --git a/api.lua b/api.lua index 12511d3..85979fb 100644 --- a/api.lua +++ b/api.lua @@ -77,6 +77,9 @@ API.eventutils = type(_G.C_EventUtils) == "table" API.timer = type(_G.C_Timer) == "table" and type(_G.C_Timer.After) == "function" +API.regionmouseover = _G.UIParent + and type(_G.UIParent.IsMouseOver) == "function" + -- ClassicAPI v1.12.5 made nameplate lifecycle events reload-safe by clearing -- and rebuilding their token/wrapper state around /reload. Older builds can -- expose the same event names without those guarantees, so keep them on the @@ -362,6 +365,14 @@ API.Defer = function(callback) end end +API.IsMouseOver = function(region, topOffset, bottomOffset, leftOffset, rightOffset) + if API.regionmouseover and region then + return region:IsMouseOver(topOffset, bottomOffset, leftOffset, rightOffset) + and true or false + end + return false +end + API.GetContainerNumFreeSlots = function(bag) if API.inventory then return _G.C_Container.GetContainerNumFreeSlots(bag) diff --git a/mods/minimap-clean.lua b/mods/minimap-clean.lua index fee3813..cd4513b 100644 --- a/mods/minimap-clean.lua +++ b/mods/minimap-clean.lua @@ -1,4 +1,5 @@ local T = ShaguTweaks.T +local API = ShaguTweaks.API local module = ShaguTweaks:register({ title = T["Minimap Clean"], @@ -120,6 +121,11 @@ module.enable = function(self) local THROTTLE = 0.1 local MARGIN = 30 + -- ClassicAPI's native Region:IsMouseOver handles cursor scaling and frame + -- bounds directly. Without that capability, leave the feature inactive + -- instead of restoring the old permanent Lua coordinate polling path. + if not API or not API.regionmouseover then return end + self.frame = self.frame or CreateFrame("Frame") -- Prime the cache once. Future scans only happen when the minimap child count @@ -131,18 +137,7 @@ module.enable = function(self) if self.elapsed < THROTTLE then return end self.elapsed = 0 - local x, y = GetCursorPosition() - local scale = Minimap:GetEffectiveScale() - local mx, my = x / scale, y / scale - - local left = Minimap:GetLeft() - local right = Minimap:GetRight() - local bottom = Minimap:GetBottom() - local top = Minimap:GetTop() - if not left or not right or not bottom or not top then return end - - local isOver = mx >= (left - MARGIN) and mx <= (right + MARGIN) - and my >= (bottom - MARGIN) and my <= (top + MARGIN) + local isOver = API.IsMouseOver(Minimap, MARGIN, -MARGIN, -MARGIN, MARGIN) if isOver then self.leaveTime = nil