1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

WebView: Another take on forwarding events

Closes #1747
This commit is contained in:
David Rosca 2015-11-06 00:06:03 +01:00
parent 07f828ddd5
commit a6a6b33b09

View File

@ -1139,40 +1139,40 @@ bool WebView::eventFilter(QObject *obj, QEvent *event)
// Forward events to WebView // Forward events to WebView
if (obj == m_rwhvqt) { if (obj == m_rwhvqt) {
bool ret = false;
bool wasAccepted = event->isAccepted();
#define HANDLE_EVENT(x) \
event->setAccepted(false); \
(x); \
ret = event->isAccepted(); \
event->setAccepted(wasAccepted); \
return ret
switch (event->type()) { switch (event->type()) {
case QEvent::KeyPress: case QEvent::KeyPress:
event->setAccepted(false); HANDLE_EVENT(_keyPressEvent(static_cast<QKeyEvent*>(event)));
_keyPressEvent(static_cast<QKeyEvent*>(event));
return event->isAccepted();
case QEvent::KeyRelease: case QEvent::KeyRelease:
event->setAccepted(false); HANDLE_EVENT(_keyReleaseEvent(static_cast<QKeyEvent*>(event)));
_keyReleaseEvent(static_cast<QKeyEvent*>(event));
return event->isAccepted();
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
event->setAccepted(false); HANDLE_EVENT(_mousePressEvent(static_cast<QMouseEvent*>(event)));
_mousePressEvent(static_cast<QMouseEvent*>(event));
return event->isAccepted();
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
event->setAccepted(false); HANDLE_EVENT(_mouseReleaseEvent(static_cast<QMouseEvent*>(event)));
_mouseReleaseEvent(static_cast<QMouseEvent*>(event));
return event->isAccepted();
case QEvent::MouseMove: case QEvent::MouseMove:
event->setAccepted(false); HANDLE_EVENT(_mouseMoveEvent(static_cast<QMouseEvent*>(event)));
_mouseMoveEvent(static_cast<QMouseEvent*>(event));
return event->isAccepted();
case QEvent::Wheel: case QEvent::Wheel:
event->setAccepted(false); HANDLE_EVENT(_wheelEvent(static_cast<QWheelEvent*>(event)));
_wheelEvent(static_cast<QWheelEvent*>(event));
return event->isAccepted();
default: default:
break; break;
} }
#undef HANDLE_EVENT
} }
// Block already handled events // Block already handled events