Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI parameter changes require window focus first #445

Open
MattKuebrich opened this issue Jan 19, 2024 · 7 comments
Open

UI parameter changes require window focus first #445

MattKuebrich opened this issue Jan 19, 2024 · 7 comments

Comments

@MattKuebrich
Copy link

I’m having an issue when using DPF-based plugins (VST3, CLAP, etc) that use GUIs. If the plugin UI window doesn’t already have focus (the menubar is greyed out), dragging on a knob in the UI (for example) won’t do anything. You have to click again for it start responding to the mouse movements, then it works fine. I hope that makes sense. I added a gif to help illustrate this... you can see I'm mousing down on the knob at the start and it's not moving.

This happens with all the DPF plugins I've tried including the DPF-Plugins, the Wasted Audio plugins (as shown) and my own plugin experiments using ImGui. Other non-DPF plugins don’t exhibit this behavior. I’m on an M1 Mac with Bitwig and Ableton Live. Any ideas on how to fix this? Thank you!

uidrag

@falkTX
Copy link
Contributor

falkTX commented Jan 19, 2024

this is sorta expected behaviour on macOS in my experience. the first click gives focus, 2nd click begins interaction.
it is like this in many other software under macOS, having a click automatically trigger some UI elements is the exception rather than the rule I would say (on other OSes it is not the case of course)

in any case, changing this behaviour would mean exposing the pugl side that controls this. the view (or window not sure now) contains a property that states wherever the first click only activates focus or does interaction straight away. we would need to make that optional and then expose it on dpf side as well.

PS: compare this to how web browsers work. you cannot press a button on a browser when it is not on focus first, I quite rather like this approach and personally prefer it to be this way

@MattKuebrich
Copy link
Author

MattKuebrich commented Jan 19, 2024

Thanks so much for the quick response! I do see what you're saying and in the macOS browser - it indeed works that way. But in the realm of audio plugins in the DAW, it's definitely not the expected behavior. I can't find a single non-DPF-based plugin that behaves like that (having to click for focus first).

For me as a user, it just "feels" wrong (because all the other plugins work differently) and is a barrier to quickly tweaking values. I'd love if there was an option to enable interaction straight away, if it's possible without too much headache.

@falkTX
Copy link
Contributor

falkTX commented Jan 19, 2024

You can try to tweak the code in dpf/dgl/src/pugl-upstream/src/mac.m and see if you find something that works for this.
I am not that knowledgeable about Cocoa related APIs to know the exact stop that needs to be tweaked, but the macOS integration stuff is there on that file to change.

@MattKuebrich
Copy link
Author

Thanks, I'll give it a shot and report back if I find something that works!

@MattKuebrich
Copy link
Author

MattKuebrich commented Jan 20, 2024

No luck yet. I tried adding this to mac.m, which which looks to be what I want, but unfortunately it didn't work.

- (BOOL)acceptsFirstMouse:(NSEvent*)event {
  return YES;
}

I found this GitHub comment about a similar issue and they point to JUCE using the same acceptsFirstMouse code. Indeed JUCE-generated plugins work on first-click, as I'm hoping to do with DPF. Would I need to update any other files for this to work?

@MattKuebrich
Copy link
Author

MattKuebrich commented Jan 22, 2024

I got it working! I added the acceptsFirstMouse code toPuglOpenGLView in dpf/dgl/src/pugl-upstream/src/mac_gl.m. Didn't change anything in mac.m.

@implementation PuglOpenGLView {
@public
  PuglView* puglview;
}

// activate the view with one click
- (BOOL)acceptsFirstMouse:(NSEvent *)event {
    return YES;
}

I do think you should consider adding this functionality, either by default or with an option, as it really is the expected way plugins work in macOS.

Curiously, there's similar code already in this older version of pugl(?) that was in DPF:
https://github.com/falkTX/DPF/blob/d49366db694fb9097210ba9665449f6a67025285/dgl/src/pugl/pugl_osx.m#L132

@dromer
Copy link
Contributor

dromer commented Jan 28, 2024

I'd say the behavior should be consistent with other plugins and other OSes, so the direct interaction would make most sense.

Especially in a context where you are moving between different screens regularly (ie. a DAW project) having to do this additional click every time, just for any DPF plugins specifically, would get pretty annoying.

Just because this is not the default for other programs or web-browsers does not mean it should be the default in this context.

[ps; on Linux/X11 I can interact with a browser immediately, rather than having to "click-to-focus" first. So I get this is a very specific macOS idiom, that other audio developers are explicitly circumventing as well]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants