diff options
author | Szabolcs David <davidsz@inf.u-szeged.hu> | 2020-04-27 12:28:06 +0200 |
---|---|---|
committer | Szabolcs David <davidsz@inf.u-szeged.hu> | 2020-05-04 15:08:35 +0200 |
commit | 00f7ad50e99037a121c684726065c416b0b995eb (patch) | |
tree | f66065093a09ecc0a11a8aa73be50c5f6be54450 /src/core/web_contents_adapter.cpp | |
parent | 810eb3b20247ef3b162182f6a31f5e745615d3e3 (diff) |
Revive Pointer Lock feature
This change fixes several issues:
- Accepting mouse lock permission from modal dialog was not working on
Linux. XCB needs some time to activate the parent window after accepting
the dialog and we expected to have immediate active focus.
- Implementation of RenderWidgetHostViewBase::IsMouseLocked() was
missing.
- Fixed event.movementX/movementY by disabling ConsolidatedMovementXY
feature. Calculate movement properties in WebEngine instead of blink.
Task-number: QTBUG-83294
Change-Id: Ic03d05c1026a113cf5e8d22544fc508d9f285876
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r-- | src/core/web_contents_adapter.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index c8bb10fd6..0f2f21f83 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1372,20 +1372,40 @@ void WebContentsAdapter::runFeatureRequestCallback(const QUrl &securityOrigin, P m_profileAdapter->permissionRequestReply(securityOrigin, feature, allowed); } -void WebContentsAdapter::grantMouseLockPermission(bool granted) +void WebContentsAdapter::grantMouseLockPermission(const QUrl &securityOrigin, bool granted) { CHECK_INITIALIZED(); + if (securityOrigin != toQt(m_webContents->GetLastCommittedURL().GetOrigin())) + return; if (granted) { - if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())) + if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())) { rwhv->Focus(); - else + if (!rwhv->HasFocus()) { + // We tried to activate our RWHVQtDelegate, but we failed. This probably means that + // the permission was granted from a modal dialog and the windowing system is not ready + // to set focus on the originating view. Since pointer lock strongly requires it, we just + // wait until the next FocusIn event. + m_pendingMouseLockPermissions.insert(securityOrigin, granted); + return; + } + } else granted = false; } m_webContents->GotResponseToLockMouseRequest(granted); } +void WebContentsAdapter::handlePendingMouseLockPermission() +{ + CHECK_INITIALIZED(); + auto it = m_pendingMouseLockPermissions.find(toQt(m_webContents->GetLastCommittedURL().GetOrigin())); + if (it != m_pendingMouseLockPermissions.end()) { + m_webContents->GotResponseToLockMouseRequest(it.value()); + m_pendingMouseLockPermissions.erase(it); + } +} + void WebContentsAdapter::setBackgroundColor(const QColor &color) { CHECK_INITIALIZED(); |