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
|
||||
qwasmaccessibility.cpp qwasmaccessibility.h
|
||||
qwasmbase64iconstore.cpp qwasmbase64iconstore.h
|
||||
qwasmclipboard.cpp qwasmclipboard.h
|
||||
qwasmcompositor.cpp qwasmcompositor.h
|
||||
qwasmcssstyle.cpp qwasmcssstyle.h
|
||||
qwasmcursor.cpp qwasmcursor.h
|
||||
@ -63,6 +62,11 @@ qt_internal_add_resource(QWasmIntegrationPlugin "wasmfonts"
|
||||
${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
|
||||
SOURCES
|
||||
qwasmbackingstore.cpp qwasmbackingstore.h
|
||||
|
@ -10,7 +10,9 @@
|
||||
#include <qwindow.h>
|
||||
#include <qpa/qplatforminputcontext.h>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
#if QT_CONFIG(clipboard)
|
||||
#include <QClipboard>
|
||||
#endif
|
||||
#include <QtGui/qtextobject.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -90,6 +92,7 @@ void QWasmInputContext::inputCallback(emscripten::val event)
|
||||
} else if (!inputTypeString.compare("insertText")) {
|
||||
wasmInput->insertText(inputStr);
|
||||
event.call<void>("stopImmediatePropagation");
|
||||
#if QT_CONFIG(clipboard)
|
||||
} else if (!inputTypeString.compare("insertFromPaste")) {
|
||||
wasmInput->insertText(QGuiApplication::clipboard()->text());
|
||||
event.call<void>("stopImmediatePropagation");
|
||||
@ -97,6 +100,7 @@ void QWasmInputContext::inputCallback(emscripten::val event)
|
||||
// But now, keyCallback in QWasmWindow
|
||||
// will take them as exceptions.
|
||||
//} else if (!inputTypeString.compare("deleteByCut")) {
|
||||
#endif
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
#if QT_CONFIG(clipboard)
|
||||
static void copyCallback(emscripten::val event)
|
||||
{
|
||||
qCDebug(qLcQpaWasmInputContext) << Q_FUNC_INFO;
|
||||
@ -230,6 +235,7 @@ static void pasteCallback(emscripten::val event)
|
||||
|
||||
// propagate to input event (insertFromPaste)
|
||||
}
|
||||
#endif // QT_CONFIG(clipboard)
|
||||
|
||||
QWasmInputContext::QWasmInputContext()
|
||||
{
|
||||
@ -258,10 +264,12 @@ QWasmInputContext::QWasmInputContext()
|
||||
m_compositionStartCallback = QWasmEventHandler(m_inputElement, "compositionstart", QWasmInputContext::compositionStartCallback);
|
||||
m_compositionUpdateCallback = QWasmEventHandler(m_inputElement, "compositionupdate", QWasmInputContext::compositionUpdateCallback);
|
||||
|
||||
#if QT_CONFIG(clipboard)
|
||||
// Clipboard for InputContext
|
||||
m_clipboardCut = QWasmEventHandler(m_inputElement, "cut", cutCallback);
|
||||
m_clipboardCopy = QWasmEventHandler(m_inputElement, "copy", copyCallback);
|
||||
m_clipboardPaste = QWasmEventHandler(m_inputElement, "paste", pasteCallback);
|
||||
#endif
|
||||
}
|
||||
|
||||
QWasmInputContext::~QWasmInputContext()
|
||||
|
@ -6,7 +6,9 @@
|
||||
#include "qwasmcompositor.h"
|
||||
#include "qwasmopenglcontext.h"
|
||||
#include "qwasmtheme.h"
|
||||
#if QT_CONFIG(clipboard)
|
||||
#include "qwasmclipboard.h"
|
||||
#endif
|
||||
#include "qwasmaccessibility.h"
|
||||
#include "qwasmservices.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_fontDb(nullptr)
|
||||
, m_desktopServices(nullptr)
|
||||
#if QT_CONFIG(clipboard)
|
||||
, m_clipboard(new QWasmClipboard)
|
||||
#endif
|
||||
#if QT_CONFIG(accessibility)
|
||||
, m_accessibility(new QWasmAccessibility)
|
||||
#endif
|
||||
@ -309,10 +313,12 @@ QPlatformServices *QWasmIntegration::services() const
|
||||
return m_desktopServices;
|
||||
}
|
||||
|
||||
#if QT_CONFIG(clipboard)
|
||||
QPlatformClipboard* QWasmIntegration::clipboard() const
|
||||
{
|
||||
return m_clipboard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_ACCESSIBILITY
|
||||
QPlatformAccessibility *QWasmIntegration::accessibility() const
|
||||
|
@ -59,7 +59,9 @@ public:
|
||||
QStringList themeNames() const override;
|
||||
QPlatformTheme *createPlatformTheme(const QString &name) const override;
|
||||
QPlatformServices *services() const override;
|
||||
#if QT_CONFIG(clipboard)
|
||||
QPlatformClipboard *clipboard() const override;
|
||||
#endif
|
||||
#ifndef QT_NO_ACCESSIBILITY
|
||||
QPlatformAccessibility *accessibility() const override;
|
||||
#endif
|
||||
|
@ -12,7 +12,9 @@
|
||||
|
||||
#include "qwasmbase64iconstore.h"
|
||||
#include "qwasmdom.h"
|
||||
#if QT_CONFIG(clipboard)
|
||||
#include "qwasmclipboard.h"
|
||||
#endif
|
||||
#include "qwasmintegration.h"
|
||||
#include "qwasmkeytranslator.h"
|
||||
#include "qwasmwindow.h"
|
||||
@ -21,7 +23,6 @@
|
||||
#include "qwasmevent.h"
|
||||
#include "qwasmeventdispatcher.h"
|
||||
#include "qwasmaccessibility.h"
|
||||
#include "qwasmclipboard.h"
|
||||
#include "qwasmdrag.h"
|
||||
|
||||
#include <iostream>
|
||||
@ -86,12 +87,14 @@ QWasmWindow::QWasmWindow(QWindow *w, QWasmDeadKeySupport *deadKeySupport,
|
||||
|
||||
m_canvas["classList"].call<void>("add", emscripten::val("qt-window-canvas"));
|
||||
|
||||
#if QT_CONFIG(clipboard)
|
||||
// Set contentEditable so that the window gets clipboard events,
|
||||
// then hide the resulting focus frame.
|
||||
m_window.set("contentEditable", std::string("true"));
|
||||
m_window["style"].set("outline", std::string("none"));
|
||||
|
||||
QWasmClipboard::installEventHandlers(m_window);
|
||||
#endif
|
||||
|
||||
// Set inputMode to none to stop the mobile keyboard from opening
|
||||
// when the user clicks on the window.
|
||||
@ -574,19 +577,26 @@ bool QWasmWindow::processKey(const KeyEvent &event)
|
||||
constexpr bool ProceedToNativeEvent = false;
|
||||
Q_ASSERT(event.type == EventType::KeyDown || event.type == EventType::KeyUp);
|
||||
|
||||
#if QT_CONFIG(clipboard)
|
||||
const auto clipboardResult =
|
||||
QWasmIntegration::get()->getWasmClipboard()->processKeyboard(event);
|
||||
|
||||
using ProcessKeyboardResult = QWasmClipboard::ProcessKeyboardResult;
|
||||
if (clipboardResult == ProcessKeyboardResult::NativeClipboardEventNeeded)
|
||||
return ProceedToNativeEvent;
|
||||
#endif
|
||||
|
||||
const auto result = QWindowSystemInterface::handleKeyEvent(
|
||||
0, event.type == EventType::KeyDown ? QEvent::KeyPress : QEvent::KeyRelease, event.key,
|
||||
event.modifiers, event.text, event.autoRepeat);
|
||||
|
||||
#if QT_CONFIG(clipboard)
|
||||
return clipboardResult == ProcessKeyboardResult::NativeClipboardEventAndCopiedDataNeeded
|
||||
? ProceedToNativeEvent
|
||||
: result;
|
||||
#else
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
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,
|
||||
event.modifiers, event.text);
|
||||
|
||||
#if QT_CONFIG(clipboard)
|
||||
// Copy/Cut callback required to copy qtClipboard to system clipboard
|
||||
if (keySeq == QKeySequence::Copy || keySeq == QKeySequence::Cut)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user