I'm having trouble getting a window to open at the mouse cursor when the user has two monitors; it always opens on the main screen, regardless of which one the mouse is on.
My current code looks roughly like:
Code:
x, y, w, h = Window dimensions and offset from the cursor
Get the screen size:
__, __, scr_w, scr_h = reaper.my_getViewport(x, y, x + w, y + h, x, y, x + w, y + h, 1)
Get the mouse position:
ax, ay = reaper.GetMousePosition()
Center the window to the mouse:
x, y = ax + x - (w / 2), ay + y - (h / 2)
Make sure every edge of the window would be on-screen:
l, t, r, b = x, y, x + w, y + h
if l < 0 then x = 0 end
if r > scr_w then x = (scr_w - w - 16) end
if t < 0 then y = 0 end
if b > scr_h then y = (scr_h - h - 40) end
return x, y
I suspect the issue lies with
reaper.my_getViewport - since there's zero documentation for it, the values I'm using are complete guesses that have happened to work up until this point.
Any insight would be appreciated.
(Note that I'm handling the "make sure we're completely on-screen" adjustments myself because
reaper.EnsureNotCompletelyOffscreen() is suffering from a lack of documentation AND a lack of parameters to be given)