From d2a84319e73d3669fe4f64eb2d816cc3a8c77d1f Mon Sep 17 00:00:00 2001 From: David Rosca Date: Tue, 6 Oct 2015 11:15:17 +0200 Subject: [PATCH] Fix pointer flicker when enabling mouse lock --- .../html5permissions/html5permissionsnotification.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/tools/html5permissions/html5permissionsnotification.cpp b/src/lib/tools/html5permissions/html5permissionsnotification.cpp index 325871fbb..e011ec5fe 100644 --- a/src/lib/tools/html5permissions/html5permissionsnotification.cpp +++ b/src/lib/tools/html5permissions/html5permissionsnotification.cpp @@ -87,10 +87,13 @@ void HTML5PermissionsNotification::grantPermissions() return; } - if (m_feature == QWebEnginePage::MouseLock) - QCursor::setPos(m_page->view()->mapToGlobal(m_page->view()->rect().center())); - QTimer::singleShot(0, this, [this]() { + // We need to have cursor inside view to correctly grab mouse + if (m_feature == QWebEnginePage::MouseLock) { + QWidget *view = m_page->view(); + QCursor::setPos(view->mapToGlobal(view->rect().center())); + } + m_page->setFeaturePermission(m_origin, m_feature, QWebEnginePage::PermissionGrantedByUser); });