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

(fix) waveform / spinnies: don't take keyboard focus on click #13174

Merged
merged 1 commit into from
May 5, 2024

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Apr 25, 2024

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.

@ronso0
Copy link
Member Author

ronso0 commented Apr 28, 2024

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):

  • start Mixxx, click either a waveform or a spinny
  • = OpenGLWindow is QApp's 'active window'
  • press Tab key:
  • QApp's focusWidget() changes multiple times, to be precise it seems to cycle through these widgets 3 times before finally stopping in the searchbar:
    WSearchLineEdit --> WLibrarySidebar --> WTrackTableView

With this branch OpenGL has no focus, doesn't receive key events and therefore the focus jumps to the searchbar right away.

@m0dB
Copy link
Contributor

m0dB commented May 5, 2024

It seems that for Qt 6 the flag is Qt::Tool instead of Qt::ToolTip. I'll create a PRs for main.

@m0dB
Copy link
Contributor

m0dB commented May 5, 2024

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setFlag(Qt::ToolTip);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
setFlag(Qt::ToolTip);
#else
setFlag(Qt::Tool);
#endif

Copy link
Member Author

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.

Copy link
Contributor

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...

Copy link
Member Author

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.

@m0dB
Copy link
Contributor

m0dB commented May 5, 2024

If you commit my proposed change, I will approve and merge the PR.

@m0dB m0dB merged commit bbd1cd2 into mixxxdj:2.4 May 5, 2024
14 checks passed
@ronso0 ronso0 deleted the waveform-focus-block2 branch July 23, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants