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

Key strokes are not received anymore with the QTBUG-42183 workaround. #12

Open
ghost opened this issue Aug 23, 2021 · 2 comments
Open

Comments

@ghost
Copy link

ghost commented Aug 23, 2021

Following #11 (comment) brought to my attention that key strokes are not received anymore with the QTBUG-42183 workaround.

bool QDirect3D12Widget::event(QEvent * event)
{
switch (event->type())
{
// Workaround for https://bugreports.qt.io/browse/QTBUG-42183 to get key strokes.
// To make sure that we always have focus on the widget when we enter the rect area.
case QEvent::Enter:
case QEvent::FocusIn:
case QEvent::FocusAboutToChange:
if (::GetFocus() != m_hWnd)
{
QWidget * nativeParent = this;
while (true)
{
if (nativeParent->isWindow()) break;
QWidget * parent = nativeParent->nativeParentWidget();
if (!parent) break;
nativeParent = parent;
}
if (nativeParent && nativeParent != this &&
::GetFocus() == reinterpret_cast<HWND>(nativeParent->winId()))
::SetFocus(m_hWnd);
}
break;
case QEvent::KeyPress:
emit keyPressed((QKeyEvent *)event);
break;
case QEvent::MouseMove:
emit mouseMoved((QMouseEvent *)event);
break;
case QEvent::MouseButtonPress:
emit mouseClicked((QMouseEvent *)event);
break;
case QEvent::MouseButtonRelease:
emit mouseReleased((QMouseEvent *)event);
break;
}
return QWidget::event(event);
}

@giladreich
Copy link
Owner

@wroy-ca, it was a good idea to create a ticket for it for future reference, thanks for that! Looks like the Qt folks unfortunately haven't got around looking into that issue yet. I'm wondering at this point if it's worth looking at some Qt internals and sending them a patch for that, as this issue has been created ages ago.

@ghost
Copy link
Author

ghost commented Aug 23, 2021

@wroy-ca, it was a good idea to create a ticket for it for future reference, thanks for that! Looks like the Qt folks unfortunately haven't got around looking into that issue yet. I'm wondering at this point if it's worth looking at some Qt internals and sending them a patch for that, as this issue has been created ages ago.

It is as you said. Meanwhile, I believe I’d be worth it to investigate QDirect3D12Widget::event to figure out what and/or which commit caused the regression so that a workaround can be made, once again, for the time being. This is assuming that it worked fine prior to the day. 🙂

Edit:
The issue is now more explicit that this is about the workaround not working anymore rather than the Qt bug itself. I apologies for the confusion—if any—.

@ghost ghost changed the title Key strokes are not received by QKeyEvent. Key strokes are not received anymore with the QKeyEvent workaround. Aug 23, 2021
@ghost ghost changed the title Key strokes are not received anymore with the QKeyEvent workaround. Key strokes are not received anymore with the QTBUG-42183 workaround. Aug 23, 2021
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

1 participant