From c99277855626aaca063ab987988d81e7e0323d91 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 27 May 2012 11:38:21 +0200 Subject: [PATCH] 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 --- src/lib/webview/webpage.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/lib/webview/webpage.cpp b/src/lib/webview/webpage.cpp index d9513afa9..2ab06caed 100644 --- a/src/lib/webview/webpage.cpp +++ b/src/lib/webview/webpage.cpp @@ -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); }