Allow configuring WASM without clipboard
Pick-to: 6.9 6.8 Fixes: QTBUG-135875 Change-Id: Ibf0a51ff0e1268f32d32511dff64003c28137795 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
4748d4303b
commit
0bf2fafd38
@ -13,7 +13,6 @@ qt_internal_add_plugin(QWasmIntegrationPlugin
|
|||||||
main.cpp
|
main.cpp
|
||||||
qwasmaccessibility.cpp qwasmaccessibility.h
|
qwasmaccessibility.cpp qwasmaccessibility.h
|
||||||
qwasmbase64iconstore.cpp qwasmbase64iconstore.h
|
qwasmbase64iconstore.cpp qwasmbase64iconstore.h
|
||||||
qwasmclipboard.cpp qwasmclipboard.h
|
|
||||||
qwasmcompositor.cpp qwasmcompositor.h
|
qwasmcompositor.cpp qwasmcompositor.h
|
||||||
qwasmcssstyle.cpp qwasmcssstyle.h
|
qwasmcssstyle.cpp qwasmcssstyle.h
|
||||||
qwasmcursor.cpp qwasmcursor.h
|
qwasmcursor.cpp qwasmcursor.h
|
||||||
@ -63,6 +62,11 @@ qt_internal_add_resource(QWasmIntegrationPlugin "wasmfonts"
|
|||||||
${wasmfonts_resource_files}
|
${wasmfonts_resource_files}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
qt_internal_extend_target(QWasmIntegrationPlugin CONDITION QT_FEATURE_clipboard
|
||||||
|
SOURCES
|
||||||
|
qwasmclipboard.cpp qwasmclipboard.h
|
||||||
|
)
|
||||||
|
|
||||||
qt_internal_extend_target(QWasmIntegrationPlugin CONDITION QT_FEATURE_opengl
|
qt_internal_extend_target(QWasmIntegrationPlugin CONDITION QT_FEATURE_opengl
|
||||||
SOURCES
|
SOURCES
|
||||||
qwasmbackingstore.cpp qwasmbackingstore.h
|
qwasmbackingstore.cpp qwasmbackingstore.h
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
#include <qwindow.h>
|
#include <qwindow.h>
|
||||||
#include <qpa/qplatforminputcontext.h>
|
#include <qpa/qplatforminputcontext.h>
|
||||||
#include <qpa/qwindowsysteminterface.h>
|
#include <qpa/qwindowsysteminterface.h>
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#endif
|
||||||
#include <QtGui/qtextobject.h>
|
#include <QtGui/qtextobject.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -90,6 +92,7 @@ void QWasmInputContext::inputCallback(emscripten::val event)
|
|||||||
} else if (!inputTypeString.compare("insertText")) {
|
} else if (!inputTypeString.compare("insertText")) {
|
||||||
wasmInput->insertText(inputStr);
|
wasmInput->insertText(inputStr);
|
||||||
event.call<void>("stopImmediatePropagation");
|
event.call<void>("stopImmediatePropagation");
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
} else if (!inputTypeString.compare("insertFromPaste")) {
|
} else if (!inputTypeString.compare("insertFromPaste")) {
|
||||||
wasmInput->insertText(QGuiApplication::clipboard()->text());
|
wasmInput->insertText(QGuiApplication::clipboard()->text());
|
||||||
event.call<void>("stopImmediatePropagation");
|
event.call<void>("stopImmediatePropagation");
|
||||||
@ -97,6 +100,7 @@ void QWasmInputContext::inputCallback(emscripten::val event)
|
|||||||
// But now, keyCallback in QWasmWindow
|
// But now, keyCallback in QWasmWindow
|
||||||
// will take them as exceptions.
|
// will take them as exceptions.
|
||||||
//} else if (!inputTypeString.compare("deleteByCut")) {
|
//} else if (!inputTypeString.compare("deleteByCut")) {
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
qCWarning(qLcQpaWasmInputContext) << Q_FUNC_INFO << "inputType \"" << inputType.as<std::string>() << "\" is not supported in Qt yet";
|
qCWarning(qLcQpaWasmInputContext) << Q_FUNC_INFO << "inputType \"" << inputType.as<std::string>() << "\" is not supported in Qt yet";
|
||||||
}
|
}
|
||||||
@ -189,6 +193,7 @@ void QWasmInputContext::compositionUpdateCallback(emscripten::val event)
|
|||||||
wasmInput->setPreeditString(compositionStr, 0);
|
wasmInput->setPreeditString(compositionStr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
static void copyCallback(emscripten::val event)
|
static void copyCallback(emscripten::val event)
|
||||||
{
|
{
|
||||||
qCDebug(qLcQpaWasmInputContext) << Q_FUNC_INFO;
|
qCDebug(qLcQpaWasmInputContext) << Q_FUNC_INFO;
|
||||||
@ -230,6 +235,7 @@ static void pasteCallback(emscripten::val event)
|
|||||||
|
|
||||||
// propagate to input event (insertFromPaste)
|
// propagate to input event (insertFromPaste)
|
||||||
}
|
}
|
||||||
|
#endif // QT_CONFIG(clipboard)
|
||||||
|
|
||||||
QWasmInputContext::QWasmInputContext()
|
QWasmInputContext::QWasmInputContext()
|
||||||
{
|
{
|
||||||
@ -258,10 +264,12 @@ QWasmInputContext::QWasmInputContext()
|
|||||||
m_compositionStartCallback = QWasmEventHandler(m_inputElement, "compositionstart", QWasmInputContext::compositionStartCallback);
|
m_compositionStartCallback = QWasmEventHandler(m_inputElement, "compositionstart", QWasmInputContext::compositionStartCallback);
|
||||||
m_compositionUpdateCallback = QWasmEventHandler(m_inputElement, "compositionupdate", QWasmInputContext::compositionUpdateCallback);
|
m_compositionUpdateCallback = QWasmEventHandler(m_inputElement, "compositionupdate", QWasmInputContext::compositionUpdateCallback);
|
||||||
|
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
// Clipboard for InputContext
|
// Clipboard for InputContext
|
||||||
m_clipboardCut = QWasmEventHandler(m_inputElement, "cut", cutCallback);
|
m_clipboardCut = QWasmEventHandler(m_inputElement, "cut", cutCallback);
|
||||||
m_clipboardCopy = QWasmEventHandler(m_inputElement, "copy", copyCallback);
|
m_clipboardCopy = QWasmEventHandler(m_inputElement, "copy", copyCallback);
|
||||||
m_clipboardPaste = QWasmEventHandler(m_inputElement, "paste", pasteCallback);
|
m_clipboardPaste = QWasmEventHandler(m_inputElement, "paste", pasteCallback);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QWasmInputContext::~QWasmInputContext()
|
QWasmInputContext::~QWasmInputContext()
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
#include "qwasmcompositor.h"
|
#include "qwasmcompositor.h"
|
||||||
#include "qwasmopenglcontext.h"
|
#include "qwasmopenglcontext.h"
|
||||||
#include "qwasmtheme.h"
|
#include "qwasmtheme.h"
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
#include "qwasmclipboard.h"
|
#include "qwasmclipboard.h"
|
||||||
|
#endif
|
||||||
#include "qwasmaccessibility.h"
|
#include "qwasmaccessibility.h"
|
||||||
#include "qwasmservices.h"
|
#include "qwasmservices.h"
|
||||||
#include "qwasmoffscreensurface.h"
|
#include "qwasmoffscreensurface.h"
|
||||||
@ -92,7 +94,9 @@ QWasmIntegration::QWasmIntegration()
|
|||||||
: m_suspendResume(std::make_shared<QWasmSuspendResumeControl>()) // create early in order to register event handlers at startup
|
: m_suspendResume(std::make_shared<QWasmSuspendResumeControl>()) // create early in order to register event handlers at startup
|
||||||
, m_fontDb(nullptr)
|
, m_fontDb(nullptr)
|
||||||
, m_desktopServices(nullptr)
|
, m_desktopServices(nullptr)
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
, m_clipboard(new QWasmClipboard)
|
, m_clipboard(new QWasmClipboard)
|
||||||
|
#endif
|
||||||
#if QT_CONFIG(accessibility)
|
#if QT_CONFIG(accessibility)
|
||||||
, m_accessibility(new QWasmAccessibility)
|
, m_accessibility(new QWasmAccessibility)
|
||||||
#endif
|
#endif
|
||||||
@ -309,10 +313,12 @@ QPlatformServices *QWasmIntegration::services() const
|
|||||||
return m_desktopServices;
|
return m_desktopServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
QPlatformClipboard* QWasmIntegration::clipboard() const
|
QPlatformClipboard* QWasmIntegration::clipboard() const
|
||||||
{
|
{
|
||||||
return m_clipboard;
|
return m_clipboard;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef QT_NO_ACCESSIBILITY
|
#ifndef QT_NO_ACCESSIBILITY
|
||||||
QPlatformAccessibility *QWasmIntegration::accessibility() const
|
QPlatformAccessibility *QWasmIntegration::accessibility() const
|
||||||
|
@ -59,7 +59,9 @@ public:
|
|||||||
QStringList themeNames() const override;
|
QStringList themeNames() const override;
|
||||||
QPlatformTheme *createPlatformTheme(const QString &name) const override;
|
QPlatformTheme *createPlatformTheme(const QString &name) const override;
|
||||||
QPlatformServices *services() const override;
|
QPlatformServices *services() const override;
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
QPlatformClipboard *clipboard() const override;
|
QPlatformClipboard *clipboard() const override;
|
||||||
|
#endif
|
||||||
#ifndef QT_NO_ACCESSIBILITY
|
#ifndef QT_NO_ACCESSIBILITY
|
||||||
QPlatformAccessibility *accessibility() const override;
|
QPlatformAccessibility *accessibility() const override;
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
|
|
||||||
#include "qwasmbase64iconstore.h"
|
#include "qwasmbase64iconstore.h"
|
||||||
#include "qwasmdom.h"
|
#include "qwasmdom.h"
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
#include "qwasmclipboard.h"
|
#include "qwasmclipboard.h"
|
||||||
|
#endif
|
||||||
#include "qwasmintegration.h"
|
#include "qwasmintegration.h"
|
||||||
#include "qwasmkeytranslator.h"
|
#include "qwasmkeytranslator.h"
|
||||||
#include "qwasmwindow.h"
|
#include "qwasmwindow.h"
|
||||||
@ -21,7 +23,6 @@
|
|||||||
#include "qwasmevent.h"
|
#include "qwasmevent.h"
|
||||||
#include "qwasmeventdispatcher.h"
|
#include "qwasmeventdispatcher.h"
|
||||||
#include "qwasmaccessibility.h"
|
#include "qwasmaccessibility.h"
|
||||||
#include "qwasmclipboard.h"
|
|
||||||
#include "qwasmdrag.h"
|
#include "qwasmdrag.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -86,12 +87,14 @@ QWasmWindow::QWasmWindow(QWindow *w, QWasmDeadKeySupport *deadKeySupport,
|
|||||||
|
|
||||||
m_canvas["classList"].call<void>("add", emscripten::val("qt-window-canvas"));
|
m_canvas["classList"].call<void>("add", emscripten::val("qt-window-canvas"));
|
||||||
|
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
// Set contentEditable so that the window gets clipboard events,
|
// Set contentEditable so that the window gets clipboard events,
|
||||||
// then hide the resulting focus frame.
|
// then hide the resulting focus frame.
|
||||||
m_window.set("contentEditable", std::string("true"));
|
m_window.set("contentEditable", std::string("true"));
|
||||||
m_window["style"].set("outline", std::string("none"));
|
m_window["style"].set("outline", std::string("none"));
|
||||||
|
|
||||||
QWasmClipboard::installEventHandlers(m_window);
|
QWasmClipboard::installEventHandlers(m_window);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Set inputMode to none to stop the mobile keyboard from opening
|
// Set inputMode to none to stop the mobile keyboard from opening
|
||||||
// when the user clicks on the window.
|
// when the user clicks on the window.
|
||||||
@ -574,19 +577,26 @@ bool QWasmWindow::processKey(const KeyEvent &event)
|
|||||||
constexpr bool ProceedToNativeEvent = false;
|
constexpr bool ProceedToNativeEvent = false;
|
||||||
Q_ASSERT(event.type == EventType::KeyDown || event.type == EventType::KeyUp);
|
Q_ASSERT(event.type == EventType::KeyDown || event.type == EventType::KeyUp);
|
||||||
|
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
const auto clipboardResult =
|
const auto clipboardResult =
|
||||||
QWasmIntegration::get()->getWasmClipboard()->processKeyboard(event);
|
QWasmIntegration::get()->getWasmClipboard()->processKeyboard(event);
|
||||||
|
|
||||||
using ProcessKeyboardResult = QWasmClipboard::ProcessKeyboardResult;
|
using ProcessKeyboardResult = QWasmClipboard::ProcessKeyboardResult;
|
||||||
if (clipboardResult == ProcessKeyboardResult::NativeClipboardEventNeeded)
|
if (clipboardResult == ProcessKeyboardResult::NativeClipboardEventNeeded)
|
||||||
return ProceedToNativeEvent;
|
return ProceedToNativeEvent;
|
||||||
|
#endif
|
||||||
|
|
||||||
const auto result = QWindowSystemInterface::handleKeyEvent(
|
const auto result = QWindowSystemInterface::handleKeyEvent(
|
||||||
0, event.type == EventType::KeyDown ? QEvent::KeyPress : QEvent::KeyRelease, event.key,
|
0, event.type == EventType::KeyDown ? QEvent::KeyPress : QEvent::KeyRelease, event.key,
|
||||||
event.modifiers, event.text, event.autoRepeat);
|
event.modifiers, event.text, event.autoRepeat);
|
||||||
|
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
return clipboardResult == ProcessKeyboardResult::NativeClipboardEventAndCopiedDataNeeded
|
return clipboardResult == ProcessKeyboardResult::NativeClipboardEventAndCopiedDataNeeded
|
||||||
? ProceedToNativeEvent
|
? ProceedToNativeEvent
|
||||||
: result;
|
: result;
|
||||||
|
#else
|
||||||
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWasmWindow::handleKeyForInputContextEvent(EventType eventType, const emscripten::val &event)
|
void QWasmWindow::handleKeyForInputContextEvent(EventType eventType, const emscripten::val &event)
|
||||||
@ -651,9 +661,11 @@ bool QWasmWindow::processKeyForInputContext(const KeyEvent &event)
|
|||||||
0, event.type == EventType::KeyDown ? QEvent::KeyPress : QEvent::KeyRelease, event.key,
|
0, event.type == EventType::KeyDown ? QEvent::KeyPress : QEvent::KeyRelease, event.key,
|
||||||
event.modifiers, event.text);
|
event.modifiers, event.text);
|
||||||
|
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
// Copy/Cut callback required to copy qtClipboard to system clipboard
|
// Copy/Cut callback required to copy qtClipboard to system clipboard
|
||||||
if (keySeq == QKeySequence::Copy || keySeq == QKeySequence::Cut)
|
if (keySeq == QKeySequence::Copy || keySeq == QKeySequence::Cut)
|
||||||
return false;
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user