Old 02-12-2017, 04:04 PM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 5,660
Default API: Getting coordinates with multiple monitors

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)

Last edited by Lokasenna; 02-12-2017 at 04:13 PM.
Lokasenna is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.