diff options
Diffstat (limited to 'src/core/render_widget_host_view_qt_delegate_client.cpp')
-rw-r--r-- | src/core/render_widget_host_view_qt_delegate_client.cpp | 59 |
1 files changed, 13 insertions, 46 deletions
diff --git a/src/core/render_widget_host_view_qt_delegate_client.cpp b/src/core/render_widget_host_view_qt_delegate_client.cpp index aa48b869e..3e8cad669 100644 --- a/src/core/render_widget_host_view_qt_delegate_client.cpp +++ b/src/core/render_widget_host_view_qt_delegate_client.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "render_widget_host_view_qt_delegate_client.h" @@ -52,9 +16,7 @@ #include <QEvent> #include <QInputMethodEvent> -#include <QScopeGuard> #include <QSet> -#include <QSGNode> #include <QStyleHints> #include <QTextFormat> #include <QVariant> @@ -93,7 +55,7 @@ QList<TouchPoint> RenderWidgetHostViewQtDelegateClient::mapTouchPointIds(const Q Q_ASSERT(output.size() == std::accumulate(output.cbegin(), output.cend(), QSet<int>(), [] (QSet<int> s, const TouchPoint &p) { s.insert(p.second.id()); return s; }).size()); - for (auto &&point : qAsConst(input)) + for (auto &&point : std::as_const(input)) if (point.state() == QEventPoint::Released) m_touchIdMapping.remove(point.id()); @@ -246,7 +208,7 @@ bool RenderWidgetHostViewQtDelegateClient::forwardEvent(QEvent *event) switch (event->type()) { case QEvent::ShortcutOverride: { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); - + event->ignore(); auto acceptKeyOutOfInputField = [](QKeyEvent *keyEvent) -> bool { #ifdef Q_OS_MACOS // Check if a shortcut is registered for this key sequence. @@ -382,6 +344,7 @@ QVariant RenderWidgetHostViewQtDelegateClient::inputMethodQuery(Qt::InputMethodQ } return QVariant(); } + case Qt::ImAbsolutePosition: case Qt::ImCursorPosition: return m_cursorPosition; case Qt::ImAnchorPosition: @@ -446,6 +409,7 @@ void RenderWidgetHostViewQtDelegateClient::handlePointerEvent(T *event) webEvent.movement_x = event->globalPosition().x() - m_previousMousePosition.x(); webEvent.movement_y = event->globalPosition().y() - m_previousMousePosition.y(); + webEvent.is_raw_movement_event = true; if (m_rwhv->IsMouseLocked()) QCursor::setPos(m_previousMousePosition); @@ -512,6 +476,9 @@ void RenderWidgetHostViewQtDelegateClient::handleKeyEvent(QKeyEvent *event) if (event->type() == QEvent::KeyRelease && event->isAutoRepeat()) return; + if (!m_rwhv->GetFocusedWidget()) + return; + content::NativeWebKeyboardEvent webEvent = WebEventFactory::toWebKeyboardEvent(event); if (webEvent.GetType() == blink::WebInputEvent::Type::kRawKeyDown && !m_editCommand.empty()) { ui::LatencyInfo latency; @@ -525,14 +492,14 @@ void RenderWidgetHostViewQtDelegateClient::handleKeyEvent(QKeyEvent *event) bool keyDownTextInsertion = webEvent.GetType() == blink::WebInputEvent::Type::kRawKeyDown && webEvent.text[0]; - webEvent.skip_in_browser = keyDownTextInsertion; + webEvent.skip_if_unhandled = keyDownTextInsertion; m_rwhv->GetFocusedWidget()->ForwardKeyboardEvent(webEvent); if (keyDownTextInsertion) { // Blink won't consume the RawKeyDown, but rather the Char event in this case. // The RawKeyDown is skipped on the way back (see above). // The same os_event will be set on both NativeWebKeyboardEvents. - webEvent.skip_in_browser = false; + webEvent.skip_if_unhandled = false; webEvent.SetType(blink::WebInputEvent::Type::kChar); m_rwhv->GetFocusedWidget()->ForwardKeyboardEvent(webEvent); } @@ -560,7 +527,7 @@ void RenderWidgetHostViewQtDelegateClient::handleTouchEvent(QTouchEvent *event) m_eventsToNowDelta = (base::TimeTicks::Now() - eventTimestamp).InMicroseconds(); eventTimestamp += base::Microseconds(m_eventsToNowDelta); - auto touchPoints = mapTouchPointIds(event->touchPoints()); + auto touchPoints = mapTouchPointIds(event->points()); // Make sure that POINTER_DOWN action is delivered before MOVE, and MOVE before POINTER_UP std::sort(touchPoints.begin(), touchPoints.end(), [] (const TouchPoint &l, const TouchPoint &r) { return l.second.state() < r.second.state(); @@ -569,7 +536,7 @@ void RenderWidgetHostViewQtDelegateClient::handleTouchEvent(QTouchEvent *event) auto sc = qScopeGuard([&] () { switch (event->type()) { case QEvent::TouchCancel: - for (auto &&it : qAsConst(touchPoints)) + for (auto &&it : std::as_const(touchPoints)) m_touchIdMapping.remove(it.second.id()); Q_FALLTHROUGH(); |