-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Knobs/sliders: avoid stuck 'pressed' state after resetting with Ctrl + left-click on macOS #10839
Conversation
fef6d05
to
7ca758a
Compare
The ctrl-click now resets the sliders and the knobs without making them unresponsive. Great! But there is a new issue now: after a ctrl-click, the knob gets in a state where it hides the mouse cursor on hovering (just like how the mouse cursor disappears when the knob is being dragged). The sliders don't have this problem, but I guess that is not surprising, since they don't hide the cursor on drag either. After doing a real right-click or after left-click-dragging (changing value) the knob gets back into it's normal state. On a sidenote, I am surprised that you have to resort to using QContextMenuEvent. I am developing with Qt as well and I don't think I ever have had issues with receiving simulated right button press and release events. I will test this tomorrow. What version of Qt are you using? |
I have been looking at the code and I am wondering if the problem isn't in WWidget::event, where mouse events are being synthesized from touch events. This seems a likely spot for the right click to get lost. I will try to get set up to build mixxx myself and run it in the debugger, but I see that I need to build some required third-party libraries first. Is there a list of dependencies somewhere? Anyway, it might be interesting to revert your changes and disabling touch events altogether (not calling setAttribute(Qt::WA_AcceptTouchEvents); in WWidget constructor), and leave the touch event to mouse events mapping to Qt / the OS. I guess there are situations where you do need to do this yourself, to support certain hardware, but in my experience, if you don't call setAttribute(Qt::WA_AcceptTouchEvents); you'll get mouse events from the macbook trackpad just fine. |
Thanks for testing and investigating the issue further.
take a look at https://github.com/mixxxdj/mixxx/#building-mixxx If you find an alternative solution, great!
Oh, so it still suffers the issue of lacking a mouse release event (cursor is unset in mouseReleaseEvent).
IIRC the click event synthesization in |
Ok, after running I will investigate the issue further when I have some time. I also have experience with moving from Qt 5.12.x to Qt 5.15.9, so I can give that a try as well. (Qt 5.15.9 provides M1 support, so that could be interesting as well). I still suspect the event synthesization in WWidget::event, in combination with the code in MixxxApplication::notify, to be at fault. I'll let you know. |
Good to hear you're up & running! The 2nd commit should fix the blank cursor issue (and ignores undesired mouseMoveEvents), please test that.
Sure, go ahead!
Great. Though, what's holding back the Qt upgrade to 5.15 is that the rather complicated waveform code relies on QGLWidget which has some nasty, platform-specific regressions in 5.15. IIUC the current goal is to rewrite the GUI with QML |
Ok, I was wrong about that. Without |
I am logging press and release events in MixxxApplication::notify. I do get the simulated right click event there. But: I get all press and release events twice and the simulated right click release only once. Maybe this helps. |
Did you try to keep the Qt::RightButton case and just remove the m_bRightButtonPressed flag. For my understanding is the remove of that flag the actual fix and not the different event, that is also triggered by the menu button and Shift-F10 https://docs.microsoft.com/en-us/windows/win32/menurc/wm-contextmenu I have crawled the QT source and could not clearly identify a cocoa signal creates the context menu event like in windows. My guess is that the signal is a windows only signal and QT fakes it for the others targets. The Crtl modifier in cocoa is also Implemented in QT itself: We may single step through the code to check if the release event is even received or if it is just not forwarded. There are some related changes in that file (among others): A side catch is this code: |
Even if the issue is fixed here for the knobs, the issue will probably remain for buttons. |
That alone would allow moving sliders with the right button which is unusable because the control is already reset on press.
It works well, though of course the alternative is preferred if it works well, too.
Thanks for digging! |
Playing Be's role here: This issue will persist as long as we have our XML-based skin system. |
@ronso0 I am simply logging in
and I see that I get here twice (!) for each mouse button press or release, and only once on the simulated right button release. The comment in the top mentions that "All touch events are translated into two simultaneous events". Edit: okay, reading up on the Qt documentation of notify, I understand that it is expected that notify can get called multiple times for each event, for different receivers, so the question seems to be why does the widget stop being a receiver for this event. |
@m0dB Just for the fun of it, could you check which events are received if you Ctrl+click
Just trying to figure if the issue is indead related to WWidget only or to QWidgets, too. |
Ok, after going through a lot of mixxx code (well, at least I learned a thing or two) I decided to try with a minimal Qt app. Should have done that first thing... because it shows that the problem is in Qt itself! Even with this minimal app there are no release events for emulated right-click... Code attached. |
I just tried compiling the test against Qt 5.15.8, which works fine. |
Welp, either we ditch that Qt version (requires GUI rewrite) or we backport yet another 5.15 patch... |
This is an interesting rabbit hole. The odd behavior around release events may also explain the odd behavior of Mixxx on macOS when clicking on star ratings (#10110) which then would be just one of many strange side effects I guess. Probably also related: #10614 The Qt version trouble really is a dilemma :( |
@Swiftb0y I looked for the fix in the Qt code and changelogs, but so far no luck. I have a way to work around the Qt bug, which is posting the missing release event for the widget when we get the release event for the widgetwindow (and avoid posting it twice in case we do get the real release event after that). See attached file. I tried this in my test and it works fine, I will try using it in mixxx next. But of course this is not ideal either. |
Yes, this works. With this patch I can reset knobs and sliders with the simulated right click and at a first glance I haven't noticed any side effects. I don't know if this approach is preferable over @ronso0's contentMenuEvent solution though. |
As discussed above the context menu method is not preferred. Tracking left & middle pressed state and remove tracking the right button works as well and is cleaner. |
Sounds good. I'll test the fix once you have it ready. I joined Zulip as you suggested, @ronso0 , to ask about building with Qt 5.15.x. I am new to Zulip so I hope I followed the correct procedure, creating a stream under development. |
…left-click on macOS
77cbd59
to
8bd2b06
Compare
Sliders and Knobs remain usable after being reset with control+click using 2.3.3-32-geabf91c612 (HEAD) on macOS 12.5.1. |
Is this the macOS CI build of this PR? |
Yes |
Backporting a bugfix from 5.15 is a more practical approach than trying to fix the problems with 5.15. |
@m0dB Is there a left button release event instead of a right button release event in case of Qt 5.12 and a Ctrl click? Can you please share backtraces of a break point in the TestWidget::mousePressEvent and TestWidget::mouseReleaseEvent using a Ctrl click in Qt 5.15 and Qt 5.12 There have been some changes applies to https://github.com/qt/qtbase/blob/5.12.4/src/plugins/platforms/cocoa/qnsview_mouse.mm |
Indeed the fix is qnsview_mouse.mm, it was not easy to find. As discussed in Zulip: 5.12.3:
5.15.5:
Changing buttons to m_buttons in Qt 5.12.3 qtbase/src/plugins/platforms/cocoa/qnsview_mouse.mm:268 fixes the issue with the lost simulated right click. It would be great if the vcpkg could be updated with a Qt 5.12.3 build with this fix applied. |
superseded by #10869 |
On macOS, Ctrl + left-click is a native solution to emulate right-clicks
with a one-button mouse / touchpad. Unfortunately, this 'right-click'
doesn't emit a release event, thus, when issueing such a right-click,
to reset a control to default value, m_rightButtonPressed is never reset
and the knob / slider doesn't react on further mouse input until Ctrl is
pressed/released again.
Simply using QContextMenuEvent seems to be the easiest way to fix this,
which also allows to use any physical button for dragging knob and slider
handles.
Closes #10831