1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02:00

Leave event is now finally working correctly.

- it now distinguish leaving page on top, bottom, right and
  left and it now sends corresponding fake mouse events
This commit is contained in:
nowrep 2012-05-27 11:38:21 +02:00
parent aab7375d3c
commit c992778556

View File

@ -373,9 +373,27 @@ bool WebPage::event(QEvent* event)
// So we are faking mouse move event with proper coordinates for
// so called "just outside of the widget" position
QPoint mousePos(view()->mapFromGlobal(QCursor::pos()).x(), -1);
QMouseEvent fakeEvent(QEvent::MouseMove, mousePos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
const QPoint cursorPos = view()->mapFromGlobal(QCursor::pos());
QPoint mousePos;
if (cursorPos.y() < 0) {
// Left on top
mousePos = QPoint(cursorPos.x(), -1);
}
else if (cursorPos.x() < 0) {
// Left on left
mousePos = QPoint(-1, cursorPos.y());
}
else if(cursorPos.y() > view()->height()) {
// Left on bottom
mousePos = QPoint(cursorPos.x(), view()->height() + 1);
}
else {
// Left on right
mousePos = QPoint(view()->width() + 1, cursorPos.y());
}
QMouseEvent fakeEvent(QEvent::MouseMove, mousePos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
return QWebPage::event(&fakeEvent);
}