-
-
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
(fix) waveform / spinnies: don't take keyboard focus on click #13174
Conversation
I was curious what's happening in general with the embedded OpenGL window so I added some trace output to LibraryControl's widget focus slots (plain 2.4 branch):
With this branch OpenGL has no focus, doesn't receive key events and therefore the focus jumps to the searchbar right away. |
It seems that for Qt 6 the flag is Qt::Tool instead of Qt::ToolTip. I'll create a PRs for main. |
Actually, I think it's better to do it in this PR, with a conditional. |
@@ -12,6 +12,9 @@ | |||
OpenGLWindow::OpenGLWindow(WGLWidget* pWidget) | |||
: m_pWidget(pWidget) { | |||
setFormat(WaveformWidgetFactory::getSurfaceFormat()); | |||
// Set the tooltip flag to prevent this window/widget from getting | |||
// keyboard focus on click. | |||
setFlag(Qt::ToolTip); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setFlag(Qt::ToolTip); | |
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | |
setFlag(Qt::ToolTip); | |
#else | |
setFlag(Qt::Tool); | |
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this doesn't work either in Qt6.
Also tried SplashScreen and SubWindow
I suggest to stick with this for 2.4.x and take a closer look at the qt sources, i.e. the Qt5 -> Qt6 changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange. Adding setFlag(Qt::Tool) definitely works for me with main on macOS...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, obvious Qt::WindowDoesNotAcceptFocus
flag does the trick on Linux wit Qt 6.2.3
Will open a fixup.
If you commit my proposed change, I will approve and merge the PR. |
Currently keyboard shortcuts still work when waveforms/spinnies are click (OpenGLWindow is activated), but focus is removed from the library widgets for example which is not optimal since waveforms/spinnies don't have any special keyboard functions.
This PR just prevents the focus shift.
Simply set the
ToolTip
flag to reject focus.Couldn't spot any regressions, waveform/spinny interaction works flawlessly, tooltips are shown correctly.
Tested on Linux with Qt 5.12.8
Note: this trick does apparently not work with Qt 6 😆 (Qt 6.2.3)
Remaining issue:
on window activation, and when no widget has focus, the searchbar gets focus, which also prevents keyboard shortcuts to work right away.