10-01-2018, 07:50 AM | #1 |
Human being with feelings
Join Date: Sep 2009
Location: France
Posts: 18
|
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) Lorcan
__________________
lmdsp audio plug-ins |
10-01-2018, 08:51 AM | #2 |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 16,117
|
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).
|
10-01-2018, 11:14 AM | #3 | ||
Human being with feelings
Join Date: Sep 2009
Location: France
Posts: 18
|
Quote:
Quote:
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); 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 |
||
10-02-2018, 11:05 AM | #4 |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 16,117
|
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.
|
10-02-2018, 12:19 PM | #5 | |
Human being with feelings
Join Date: Sep 2009
Location: France
Posts: 18
|
Quote:
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)); } Code:
/// Coordinates are relative to the top-left position of the Plug-ins view. tresult IContextMenu::popup(UCoord x, UCoord y); 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 |
|
10-02-2018, 01:38 PM | #6 |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 16,117
|
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. |
10-02-2018, 01:42 PM | #7 | |
Human being with feelings
Join Date: Sep 2009
Location: France
Posts: 18
|
Quote:
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 |
|
10-02-2018, 01:57 PM | #8 | |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 16,117
|
Quote:
|
|
Thread Tools | |
Display Modes | |
|
|