Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 10-01-2018, 07:50 AM   #1
lorcan
Human being with feelings
 
lorcan's Avatar
 
Join Date: Sep 2009
Location: France
Posts: 11
Default macOS VST3 host context menu position wrong (FIXED)

Hi,

Lorcan from lmdsp audio plug-ins here.
I've noticed that with macOS Reaper, the VST3 context menu y-position is incorrect (it should be placed around the mouse cursor).



Reaper macOS VST3 Context Menu - Cropped.png

I suspect this is because the Cocoa coordinates origin are bottom-left and not top-left a in windows.
Everything is fine on Windows and Steinberg, Presonus and other PC/Mac VST3 hosts by the way.

A demo is available here for testing, although the bug is present with all VST3's that make use of
Code:
IParameterFinder::findParameter (int32 xPos, int32 yPos, ParamID &resultTag)
Best,
Lorcan
__________________
lmdsp audio plug-ins
lorcan is offline   Reply With Quote
Old 10-01-2018, 08:51 AM   #2
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 11,704
Default

How are you calculating the xpos/ypos that you pass? If converting from screen coordinates to your view coordinates, be sure to use [-NSWindow convertScreenToBase:] and [-NSView convertPoint:fromView:nil] (I believe other VST3s use these APIs and work correctly with REAPER).
Justin is offline   Reply With Quote
Old 10-01-2018, 11:14 AM   #3
lorcan
Human being with feelings
 
lorcan's Avatar
 
Join Date: Sep 2009
Location: France
Posts: 11
Default

Quote:
Originally Posted by Justin View Post
How are you calculating the xpos/ypos that you pass? If converting from screen coordinates to your view coordinates, be sure to use [-NSWindow convertScreenToBase:] and [-NSView convertPoint:fromView:nil] (I believe other VST3s use these APIs and work correctly with REAPER).
The xpos/ypos is given to me through a Cocoa NSEvent. I get the position from there and invert the y coordinate to make it cross-platform agnostic for user code.
Quote:
Originally Posted by as per VST3 SDK docs:
Find out which parameter in Plug-in view is at given position (relative to Plug-in view).
Anyway I've found out that Reaper doesn't call findParameter() (by tracing).

Actually I think the problem lies elsewhere, in the host-side IContextMenu interface, the docs say
Code:
/// Pop-ups the menu.
/// Coordinates are relative to the top-left position of the Plug-ins view.
tresult IContextMenu::popup(UCoord x, UCoord y);
The coordinates I send to Reaper are in top-left, platform-independent coordinates (y upside down w.r.t to Cocoa conventions).
I've tried in Cubase, Studio One, FL Studio, Tracktion and VST3 SDK Test host and they all behave as intended.

I also tried the VST3 SDK plug-in samples and they do the same thing as my code (pass top-left coords) to Reaper, however their NSView returns YES for isFlipped (not the default), perhaps that could explain why Reaper displays the menu in the right position there?

So what do you suggest: should I implement a Reaper specific workaround in my code or should Reaper conform to the VST3 spec ?
__________________
lmdsp audio plug-ins
lorcan is offline   Reply With Quote
Old 10-02-2018, 11:05 AM   #4
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 11,704
Default

Quote:
Originally Posted by lorcan View Post
The xpos/ypos is given to me through a Cocoa NSEvent. I get the position from there and invert the y coordinate to make it cross-platform agnostic for user code.
You should convert the coordinates from the NSEvent to view coordinates using the NSWindow/NSView calls rather than flipping the Y coordinate. This will make it work reliably on REAPER (and other hosts too). Flipping the y-coordinate is a hack.
Justin is offline   Reply With Quote
Old 10-02-2018, 12:19 PM   #5
lorcan
Human being with feelings
 
lorcan's Avatar
 
Join Date: Sep 2009
Location: France
Posts: 11
Default

Quote:
Originally Posted by Justin View Post
You should convert the coordinates from the NSEvent to view coordinates using the NSWindow/NSView calls rather than flipping the Y coordinate. This will make it work reliably on REAPER (and other hosts too). Flipping the y-coordinate is a hack.
Yes of course I'm using the NSWindow/NSView calls to get the mouse pos:
Code:
Mouse::Point MouseOS::get_mouse_pos(const NSEvent* nsevent, const NSView* nsview)
{
  // The receiver’s location in the base coordinate system of the associated window.
  const NSPoint pwindow = [nsevent locationInWindow];
	
  // Convert to view coordinates.
  const NSPoint plocal = [nsview convertPoint: pwindow fromView: nil];					
	
  // Get frame height as Cocoa y coordinates are inverted.
  const NSSize slocal = [nsview frame].size;
	
  return Point(static_cast<metric_t>(plocal.x), static_cast<metric_t>(slocal.height - plocal.y));
}
Again my code works reliably in more than 20 major hosts that follow the VST spec which explicitly says
Code:
/// Coordinates are relative to the top-left position of the Plug-ins view.
tresult IContextMenu::popup(UCoord x, UCoord y);
If I pass (0, 0) there the popup is shown at the bottom-left of the plug-in window in Reaper - and that has nothing to do with my code

I thought you'd appreciate me helping me pointing out Reaper doesn't conform to the spec, but I'm not going to waste any more time on this, I've implemented a workaround just for Reaper, everything works fine with it.
__________________
lmdsp audio plug-ins
lorcan is offline   Reply With Quote
Old 10-02-2018, 01:38 PM   #6
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 11,704
Default

Ah, I apologize, I was wrong, you are correct. You can remove your workaround and we'll fix it on our end!

Last edited by Justin; 10-02-2018 at 01:48 PM.
Justin is offline   Reply With Quote
Old 10-02-2018, 01:42 PM   #7
lorcan
Human being with feelings
 
lorcan's Avatar
 
Join Date: Sep 2009
Location: France
Posts: 11
Default

Quote:
Originally Posted by Justin View Post
Ah, I'm sorry, you are correct. You can remove your workaround and we'll fix it on our end!
Cool, thanks!

To give you more precise context I noticed the problem only manifests if the plug-in's [NSView isFlipped] returns NO (bottom-left, the Cocoa default), and not YES (top-left).
I suppose many plug-in frameworks override this to YES to get consistent cross-platform behavior and simplify user code. My code was returning the default NO.
I've changed it to YES now so my plugs run properly with older versions of Reaper.
__________________
lmdsp audio plug-ins
lorcan is offline   Reply With Quote
Old 10-02-2018, 01:57 PM   #8
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 11,704
Default

Quote:
Originally Posted by lorcan View Post
Cool, thanks!

To give you more precise context I noticed the problem only manifests if the plug-in's [NSView isFlipped] returns NO (bottom-left, the Cocoa default), and not YES (top-left).
I suppose many plug-in frameworks override this to YES to get consistent cross-platform behavior and simplify user code. My code was returning the default NO.
I've changed it to YES now so my plugs run properly with older versions of Reaper.
Thanks -- we'll now check isFlipped and if it returns NO, flip the coordinates ourselves (for older versions of your plug-in, and any others around that are similar). Thanks again!
Justin is offline   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 04:12 AM.


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