diff options
author | Lorn Potter <lorn.potter@gmail.com> | 2018-06-30 08:48:52 +1000 |
---|---|---|
committer | Lorn Potter <lorn.potter@gmail.com> | 2018-07-16 08:18:17 +0000 |
commit | 51a614a419e9745d275793e36b6aab295bf1e8e3 (patch) | |
tree | 7ad6238bf1801d39bfb67d7d6823543d04d48dea | |
parent | 95e9cbb3eef695aa7b1192678c75d4be166b93a0 (diff) |
wasm: rename platform, refactor files and other things
Task-number: QTBUG-69168
Change-Id: I78a3ad5e16fbb1046eedf2056583c022f7a27d5b
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
-rw-r--r-- | configure.pri | 2 | ||||
-rw-r--r-- | mkspecs/features/wasm/qt.prf (renamed from mkspecs/features/html5/qt.prf) | 2 | ||||
-rw-r--r-- | mkspecs/features/wasm/wasm.prf (renamed from mkspecs/features/html5/html5.prf) | 14 | ||||
-rw-r--r-- | mkspecs/wasm-emscripten/qmake.conf (renamed from mkspecs/emscripten/qmake.conf) | 7 | ||||
-rw-r--r-- | mkspecs/wasm-emscripten/qplatformdefs.h (renamed from mkspecs/emscripten/qplatformdefs.h) | 0 | ||||
-rw-r--r-- | src/corelib/codecs/qtextcodec_p.h | 2 | ||||
-rw-r--r-- | src/corelib/global/qsystemdetection.h | 2 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 8 | ||||
-rw-r--r-- | src/corelib/io/qsettings.cpp | 4 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 6 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_unix.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qeventloop.cpp | 6 | ||||
-rw-r--r-- | src/corelib/mimetypes/qmimedatabase.cpp | 2 | ||||
-rw-r--r-- | src/corelib/plugin/qlibrary.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/tools.pri | 2 | ||||
-rw-r--r-- | src/gui/configure.json | 6 | ||||
-rw-r--r-- | src/gui/configure.pri | 2 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qopenglcontext.cpp | 2 | ||||
-rw-r--r-- | src/gui/opengl/qopenglframebufferobject.cpp | 8 | ||||
-rw-r--r-- | src/network/access/access.pri | 6 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessmanager.cpp | 12 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessmanager.h | 4 | ||||
-rw-r--r-- | src/network/access/qnetworkreplywasmimpl.cpp (renamed from src/network/access/qnetworkreplyemscriptenimpl.cpp) | 84 | ||||
-rw-r--r-- | src/network/access/qnetworkreplywasmimpl_p.h (renamed from src/network/access/qnetworkreplyemscriptenimpl_p.h) | 24 | ||||
-rw-r--r-- | src/opengl/qglframebufferobject.cpp | 2 | ||||
-rw-r--r-- | src/platformsupport/eglconvenience/qeglplatformcontext.cpp | 2 | ||||
-rw-r--r-- | src/plugins/imageformats/gif/gif.pro | 2 | ||||
-rw-r--r-- | src/plugins/imageformats/ico/ico.pro | 2 | ||||
-rw-r--r-- | src/plugins/imageformats/jpeg/jpeg.pro | 2 | ||||
-rw-r--r-- | src/plugins/platforminputcontexts/platforminputcontexts.pro | 2 | ||||
-rw-r--r-- | src/plugins/platforms/html5/html5.json | 3 | ||||
-rw-r--r-- | src/plugins/platforms/html5/html5.pro | 59 | ||||
-rw-r--r-- | src/plugins/platforms/platforms.pro | 2 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/fonts/DejaVuSans.ttf (renamed from src/plugins/platforms/html5/fonts/DejaVuSans.ttf) | bin | 493564 -> 493564 bytes | |||
-rw-r--r-- | src/plugins/platforms/wasm/fonts/Vera.ttf (renamed from src/plugins/platforms/html5/fonts/Vera.ttf) | bin | 65932 -> 65932 bytes | |||
-rw-r--r-- | src/plugins/platforms/wasm/fonts/wasmfonts.qrc (renamed from src/plugins/platforms/html5/fonts/html5fonts.qrc) | 0 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/main.cpp (renamed from src/plugins/platforms/html5/main.cpp) | 12 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qtloader.js (renamed from src/plugins/platforms/html5/qtloader.js) | 0 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qtlogo.svg (renamed from src/plugins/platforms/html5/qtlogo.svg) | 0 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmbackingstore.cpp (renamed from src/plugins/platforms/html5/qhtml5backingstore.cpp) | 32 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmbackingstore.h (renamed from src/plugins/platforms/html5/qhtml5backingstore.h) | 16 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmcompositor.cpp (renamed from src/plugins/platforms/html5/qhtml5compositor.cpp) | 108 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmcompositor.h (renamed from src/plugins/platforms/html5/qhtml5compositor.h) | 82 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmcursor.cpp (renamed from src/plugins/platforms/html5/qhtml5cursor.cpp) | 8 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmcursor.h (renamed from src/plugins/platforms/html5/qhtml5cursor.h) | 6 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmeventdispatcher.cpp (renamed from src/plugins/platforms/html5/qhtml5eventdispatcher.cpp) | 26 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmeventdispatcher.h (renamed from src/plugins/platforms/html5/qhtml5eventdispatcher.h) | 14 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmeventtranslator.cpp (renamed from src/plugins/platforms/html5/qhtml5eventtranslator.cpp) | 94 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmeventtranslator.h (renamed from src/plugins/platforms/html5/qhtml5eventtranslator.h) | 14 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmfontdatabase.cpp (renamed from src/plugins/platforms/html5/qhtml5fontdatabase.cpp) | 14 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmfontdatabase.h (renamed from src/plugins/platforms/html5/qhtml5fontdatabase.h) | 6 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmintegration.cpp (renamed from src/plugins/platforms/html5/qhtml5integration.cpp) | 82 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmintegration.h (renamed from src/plugins/platforms/html5/qhtml5integration.h) | 50 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmopenglcontext.cpp (renamed from src/plugins/platforms/html5/qhtml5openglcontext.cpp) | 30 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmopenglcontext.h (renamed from src/plugins/platforms/html5/qhtml5openglcontext.h) | 6 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmscreen.cpp (renamed from src/plugins/platforms/html5/qhtml5screen.cpp) | 32 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmscreen.h (renamed from src/plugins/platforms/html5/qhtml5screen.h) | 24 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmstylepixmaps_p.h (renamed from src/plugins/platforms/html5/qhtml5stylepixmaps_p.h) | 6 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmtheme.cpp (renamed from src/plugins/platforms/html5/qhtml5theme.cpp) | 8 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmtheme.h (renamed from src/plugins/platforms/html5/qhtml5theme.h) | 26 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmwindow.cpp (renamed from src/plugins/platforms/html5/qhtml5window.cpp) | 112 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmwindow.h (renamed from src/plugins/platforms/html5/qhtml5window.h) | 38 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/wasm.json | 3 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/wasm.pro | 59 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/wasm_shell.html (renamed from src/plugins/platforms/html5/html5_shell.html) | 0 | ||||
-rw-r--r-- | src/src.pro | 4 | ||||
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qopenglwidget.cpp | 2 |
69 files changed, 603 insertions, 602 deletions
diff --git a/configure.pri b/configure.pri index 0dcc335886..c00d368e6d 100644 --- a/configure.pri +++ b/configure.pri @@ -280,7 +280,7 @@ defineTest(qtConfTest_architecture) { content = $$cat($$test_out_dir/arch.exe, blob) else: android:exists($$test_out_dir/libarch.so): \ content = $$cat($$test_out_dir/libarch.so, blob) - else: html5:exists($$test_out_dir/arch.wasm): \ + else: wasm:exists($$test_out_dir/arch.wasm): \ content = $$cat($$test_out_dir/arch.wasm, blob) else: \ error("$$eval($${1}.label) detection binary not found.") diff --git a/mkspecs/features/html5/qt.prf b/mkspecs/features/wasm/qt.prf index 47d616ec90..2f6e3f8c34 100644 --- a/mkspecs/features/html5/qt.prf +++ b/mkspecs/features/wasm/qt.prf @@ -3,7 +3,7 @@ qt_depends = $$resolve_depends(QT, "QT.") !watchos:equals(TEMPLATE, app):contains(qt_depends, gui(-private)?) { LIBS *= -L$$[QT_INSTALL_PLUGINS/get]/platforms - lib_name = html5 + lib_name = wasm lib_path_and_base = $$[QT_INSTALL_PLUGINS/get]/platforms/lib$${lib_name}$$qtPlatformTargetSuffix() LIBS += -l$${lib_name}$$qtPlatformTargetSuffix() $$fromfile($${lib_path_and_base}.prl, QMAKE_PRL_LIBS) diff --git a/mkspecs/features/html5/html5.prf b/mkspecs/features/wasm/wasm.prf index 3e2b8399bb..bea50f98f0 100644 --- a/mkspecs/features/html5/html5.prf +++ b/mkspecs/features/wasm/wasm.prf @@ -41,27 +41,27 @@ contains(TEMPLATE, .*app) { } # Copy hosting html and javascript to the application build directory. - exists($$[QT_INSTALL_PLUGINS]/platforms/html5_shell.html) { + exists($$[QT_INSTALL_PLUGINS]/platforms/wasm_shell.html) { # dont pass this until it's installed somewhere # otherwise makespec test fails during qt configure - HTML5_PLUGIN_PATH = $$[QT_INSTALL_PLUGINS]/platforms + WASM_PLUGIN_PATH = $$[QT_INSTALL_PLUGINS]/platforms } else { ## internal build. not installed - HTML5_PLUGIN_PATH = $$PWD/../../../src/plugins/platforms/html5 + WASM_PLUGIN_PATH = $$PWD/../../../src/plugins/platforms/wasm } - # Copy/Generate main .html file (e.g. myapp.html) from the html5_shell.html by + # Copy/Generate main .html file (e.g. myapp.html) from the webassembly_shell.html by # replacing the app name placeholder with the actual app name. apphtml.target = $$DESTDIR/$$TARGET_HTML - apphtml.commands += sed -e s/APPNAME/$$TARGET_BASE/g $$quote($$HTML5_PLUGIN_PATH/html5_shell.html) > $$quote($$DESTDIR/$$TARGET_HTML) $$escape_expand(\\n\\t) + apphtml.commands += sed -e s/APPNAME/$$TARGET_BASE/g $$quote($$WASM_PLUGIN_PATH/wasm_shell.html) > $$quote($$DESTDIR/$$TARGET_HTML) $$escape_expand(\\n\\t) # Copy qtloader.js appjs.target = $$DESTDIR/qtloader.js - appjs.commands += $$QMAKE_COPY $$quote($$HTML5_PLUGIN_PATH/qtloader.js) $$quote($$DESTDIR) $$escape_expand(\\n\\t) + appjs.commands += $$QMAKE_COPY $$quote($$WASM_PLUGIN_PATH/qtloader.js) $$quote($$DESTDIR) $$escape_expand(\\n\\t) # Copy qtlogo.svg qtlogo.target = $$DESTDIR/qtlogo.svg - qtlogo.commands += $$QMAKE_COPY $$quote($$HTML5_PLUGIN_PATH/qtlogo.svg) $$quote($$DESTDIR) $$escape_expand(\\n\\t) + qtlogo.commands += $$QMAKE_COPY $$quote($$WASM_PLUGIN_PATH/qtlogo.svg) $$quote($$DESTDIR) $$escape_expand(\\n\\t) QMAKE_EXTRA_TARGETS += apphtml appjs qtlogo POST_TARGETDEPS += $$apphtml.target $$appjs.target $$qtlogo.target diff --git a/mkspecs/emscripten/qmake.conf b/mkspecs/wasm-emscripten/qmake.conf index ceb002895a..bf46a063a1 100644 --- a/mkspecs/emscripten/qmake.conf +++ b/mkspecs/wasm-emscripten/qmake.conf @@ -1,6 +1,6 @@ # qmake configuration for building with emscripten MAKEFILE_GENERATOR = UNIX -QMAKE_PLATFORM = html5 unix +QMAKE_PLATFORM = wasm unix include(../common/gcc-base.conf) include(../common/clang.conf) @@ -25,7 +25,7 @@ EMCC_COMMON_LFLAGS_DEBUG = $$EMCC_COMMON_LFLAGS -s ASSERTIONS=2 -s DEMANGLE_SUPP QMAKE_COMPILER += emscripten QMAKE_CC = emcc -QMAKE_CXX = em++ -s USE_LIBPNG=1 -s USE_FREETYPE=1 +QMAKE_CXX = em++ # QMAKE_CFLAGS_THREAD = -s USE_PTHREADS=1 # QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD @@ -69,6 +69,7 @@ QMAKE_AR = emar cqs QMAKE_CLEAN += *.html *.js *.wasm DEFINES += QT_NO_QFUTURE +QT_QPA_DEFAULT_PLATFORM = webassembly -QTPLUGIN.platforms = html5 +QTPLUGIN.platforms = wasm load(qt_config) diff --git a/mkspecs/emscripten/qplatformdefs.h b/mkspecs/wasm-emscripten/qplatformdefs.h index c1a0d7b1a8..c1a0d7b1a8 100644 --- a/mkspecs/emscripten/qplatformdefs.h +++ b/mkspecs/wasm-emscripten/qplatformdefs.h diff --git a/src/corelib/codecs/qtextcodec_p.h b/src/corelib/codecs/qtextcodec_p.h index 7635fce2af..be0cab93e6 100644 --- a/src/corelib/codecs/qtextcodec_p.h +++ b/src/corelib/codecs/qtextcodec_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_TEXTCODEC -#if defined(Q_OS_MAC) || defined(Q_OS_ANDROID) || defined(Q_OS_QNX) || defined(Q_OS_HTML5) +#if defined(Q_OS_MAC) || defined(Q_OS_ANDROID) || defined(Q_OS_QNX) || defined(Q_OS_WASM) #define QT_LOCALE_IS_UTF8 #endif diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index 96dd9aa9bf..2600f7b661 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -138,7 +138,7 @@ #elif defined(__native_client__) # define Q_OS_NACL #elif defined(__EMSCRIPTEN__) -# define Q_OS_HTML5 +# define Q_OS_WASM #elif defined(__linux__) || defined(__linux) # define Q_OS_LINUX #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 5561ecbb6d..71a7fc7d42 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -859,10 +859,10 @@ QString QFileSystemEngine::resolveUserName(uint userId) size_max = 1024; QVarLengthArray<char, 1024> buf(size_max); #endif -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM Q_UNUSED(userId) #endif -#if !defined(Q_OS_INTEGRITY) && !defined(Q_OS_HTML5) +#if !defined(Q_OS_INTEGRITY) && !defined(Q_OS_WASM) struct passwd *pw = 0; #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) struct passwd entry; @@ -885,10 +885,10 @@ QString QFileSystemEngine::resolveGroupName(uint groupId) size_max = 1024; QVarLengthArray<char, 1024> buf(size_max); #endif -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM Q_UNUSED(groupId) #endif -#if !defined(Q_OS_INTEGRITY) && !defined(Q_OS_HTML5) +#if !defined(Q_OS_INTEGRITY) && !defined(Q_OS_WASM) struct group *gr = 0; #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID) && (__ANDROID_API__ >= 24)) size_max = sysconf(_SC_GETGR_R_SIZE_MAX); diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index e3d78e7fd4..6d83b34a8b 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -77,7 +77,7 @@ # include <ioLib.h> #endif -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM #include <emscripten.h> #endif @@ -1548,7 +1548,7 @@ void QConfFileSettingsPrivate::syncConfFile(QConfFile *confFile) perms |= QFile::ReadGroup | QFile::ReadOther; QFile(confFile->name).setPermissions(perms); } -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM EM_ASM( Module.print("Start QSettings Emscripten current data to persistent Indexed Db"); FS.syncfs(false, function(err) { diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 7ddc6186a1..1ff9275935 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -116,7 +116,7 @@ # include <taskLib.h> #endif -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM #include <emscripten.h> #endif @@ -503,7 +503,7 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint QCoreApplicationPrivate::~QCoreApplicationPrivate() { -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM EM_ASM( //unmount persistent directory as IDBFS FS.unmount('/home/web_user'); @@ -801,7 +801,7 @@ void QCoreApplicationPrivate::init() Q_ASSERT_X(!QCoreApplication::self, "QCoreApplication", "there should be only one application object"); QCoreApplication::self = q; -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM EM_ASM( Module.print("mount persistent directory as IDBFS"); FS.mount(IDBFS, {}, '/home/web_user'); diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index 85846c3f6f..535f86fefe 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -130,7 +130,7 @@ static void initThreadPipeFD(int fd) bool QThreadPipe::init() { -#if defined(Q_OS_NACL) || defined(Q_OS_HTML5) +#if defined(Q_OS_NACL) || defined(Q_OS_WASM) // do nothing. #elif defined(Q_OS_VXWORKS) qsnprintf(name, sizeof(name), "/pipe/qt_%08x", int(taskIdSelf())); diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp index e9f26e5070..502b075f98 100644 --- a/src/corelib/kernel/qeventloop.cpp +++ b/src/corelib/kernel/qeventloop.cpp @@ -49,7 +49,7 @@ #include <private/qthread_p.h> #include <QDebug> -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM #include <emscripten.h> #endif @@ -215,7 +215,7 @@ int QEventLoop::exec(ProcessEventsFlags flags) if (app && app->thread() == thread()) QCoreApplication::removePostedEvents(app, QEvent::Quit); -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM // Partial support for nested event loops: Make the runtime throw a JavaSrcript // exception, which returns control to the browser while preserving the C++ stack. // Event processing then continues as normal. The sleep call below newer returns. @@ -285,7 +285,7 @@ void QEventLoop::exit(int returnCode) d->exit.storeRelease(true); d->threadData->eventDispatcher.load()->interrupt(); -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM // QEventLoop::exec() never returns. We implement opproximate behavior here. if (d->threadData->loopLevel == 1) { emscripten_force_exit(returnCode); diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index d5f8b4a71b..f0a9486a7c 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -151,7 +151,7 @@ void QMimeDatabasePrivate::loadProviders() QVector<QMimeProviderBase *> QMimeDatabasePrivate::providers() { -#ifndef Q_OS_HTML5 //we dont have working mutex locks +#ifndef Q_OS_WASM //we dont have working mutex locks Q_ASSERT(!mutex.tryLock()); // caller should have locked mutex #endif if (m_providers.isEmpty()) { diff --git a/src/corelib/plugin/qlibrary.h b/src/corelib/plugin/qlibrary.h index fe60d36277..4337f338d8 100644 --- a/src/corelib/plugin/qlibrary.h +++ b/src/corelib/plugin/qlibrary.h @@ -42,7 +42,7 @@ #include <QtCore/qobject.h> -#ifndef Q_OS_HTML5 +#ifndef Q_OS_WASM QT_REQUIRE_CONFIG(library); #endif diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 4cd38d67f9..4d6c969592 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -216,7 +216,7 @@ qtConfig(system-doubleconversion) { } # Note: libm should be present by default becaue this is C++ -unix:!macx-icc:!vxworks:!haiku:!integrity:!html5: LIBS_PRIVATE += -lm +unix:!macx-icc:!vxworks:!haiku:!integrity:!wasm: LIBS_PRIVATE += -lm TR_EXCLUDE += ../3rdparty/* diff --git a/src/gui/configure.json b/src/gui/configure.json index 413305be4b..51e0389f14 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1081,7 +1081,7 @@ "opengles3": { "label": "OpenGL ES 3.0", "condition": "features.opengles2 && !features.angle && tests.opengles3", - "disable": "config.html5", + "disable": "config.webassembly", "output": [ "publicFeature", { "type": "define", "name": "QT_OPENGL_ES_3" } @@ -1090,7 +1090,7 @@ "opengles31": { "label": "OpenGL ES 3.1", "condition": "features.opengles3 && tests.opengles31", - "disable": "config.html5", + "disable": "config.webassembly", "output": [ "publicFeature", { "type": "define", "name": "QT_OPENGL_ES_3_1" } @@ -1109,7 +1109,7 @@ "enable": "input.opengl == 'desktop'", "disable": "input.opengl == 'es2' || input.opengl == 'dynamic' || input.opengl == 'no'", "condition": "(config.win32 && !config.winrt && !features.opengles2 && (config.msvc || libs.opengl)) - || (!config.watchos && !config.win32 && !config.html5 && libs.opengl)" + || (!config.watchos && !config.win32 && !config.webassembly && libs.opengl)" }, "opengl-dynamic": { "label": "Dynamic OpenGL", diff --git a/src/gui/configure.pri b/src/gui/configure.pri index 6eb9d0fe07..be4378e4fd 100644 --- a/src/gui/configure.pri +++ b/src/gui/configure.pri @@ -55,7 +55,7 @@ defineTest(qtConfTest_qpaDefaultPlatform) { else: qnx: name = qnx else: integrity: name = integrityfb else: haiku: name = haiku - else: html5: name = html5 + else: wasm: name = webassembly else: name = xcb $${1}.value = $$name diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index cc66827b41..09805369f0 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -114,7 +114,7 @@ # include <QtCore/QLibraryInfo> #endif // Q_OS_WIN -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM #include <emscripten.h> #endif @@ -1609,7 +1609,7 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() qt_gl_set_global_share_context(0); } #endif -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM EM_ASM( //unmount persistent directory as IDBFS FS.unmount('/home/web_user'); diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index deaace2db2..16224b6cd6 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -977,7 +977,7 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) if (!surface->surfaceHandle()) return false; if (!surface->supportsOpenGL()) { -#ifndef Q_OS_HTML5 // ### work around the HTML5 platform plugin using QOpenGLContext with raster surfaces. +#ifndef Q_OS_WASM // ### work around the WASM platform plugin using QOpenGLContext with raster surfaces. qWarning() << "QOpenGLContext::makeCurrent() called with non-opengl surface" << surface; return false; #endif diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 20f1d06895..0831ca32a0 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -602,7 +602,7 @@ void QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments(QOpenGLContext const int samples = requestedSamples; // free existing attachments -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM if (depth_buffer_guard) { funcs.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0); depth_buffer_guard->free(); @@ -628,7 +628,7 @@ void QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments(QOpenGLContext // In practice, a combined depth-stencil buffer is supported by all desktop platforms, while a // separate stencil buffer is not. On embedded devices however, a combined depth-stencil buffer // might not be supported while separate buffers are, according to QTBUG-12861. -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM // WebGL doesn't allow separately attach buffers to // STENCIL_ATTACHMENT and DEPTH_ATTACHMENT if (attachment == QOpenGLFramebufferObject::CombinedDepthStencil) { @@ -747,12 +747,12 @@ void QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments(QOpenGLContext stencil_buffer = 0; } } -#endif //Q_OS_HTML5 +#endif //Q_OS_WASM // The FBO might have become valid after removing the depth or stencil buffer. valid = checkFramebufferStatus(ctx); -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM if (depth_buffer) { #else if (depth_buffer && stencil_buffer) { diff --git a/src/network/access/access.pri b/src/network/access/access.pri index caa81b9497..410bf18ad0 100644 --- a/src/network/access/access.pri +++ b/src/network/access/access.pri @@ -68,11 +68,11 @@ qtConfig(networkdiskcache) { mac: LIBS_PRIVATE += -framework Security -emscripten: { +wasm: { SOURCES += \ - access/qnetworkreplyemscriptenimpl.cpp + access/qnetworkreplywasmimpl.cpp HEADERS += \ - access/qnetworkreplyemscriptenimpl_p.h + access/qnetworkreplywasmimpl_p.h } include($$PWD/../../3rdparty/zlib_dependency.pri) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 8b174d813f..08a17f8f77 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -82,9 +82,9 @@ #include <SystemConfiguration/SystemConfiguration.h> #include <Security/SecKeychain.h> #endif -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM #include <QDebug> -#include "qnetworkreplyemscriptenimpl_p.h" +#include "qnetworkreplywasmimpl_p.h" #endif QT_BEGIN_NAMESPACE @@ -1347,12 +1347,12 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera bool isLocalFile = req.url().isLocalFile(); QString scheme = req.url().scheme(); -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) { - // return new QNetworkReplyEmscriptenImpl(this, req, op); + // return new QNetworkReplyWasmImpl(this, req, op); - QNetworkReplyEmscriptenImpl *reply = new QNetworkReplyEmscriptenImpl(this); - QNetworkReplyEmscriptenImplPrivate *priv = reply->d_func(); + QNetworkReplyWasmImpl *reply = new QNetworkReplyWasmImpl(this); + QNetworkReplyWasmImplPrivate *priv = reply->d_func(); priv->manager = this; priv->setup(op, req, outgoingData); return reply; diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h index 6082e73977..0dc2be3543 100644 --- a/src/network/access/qnetworkaccessmanager.h +++ b/src/network/access/qnetworkaccessmanager.h @@ -194,8 +194,8 @@ private: friend class QNetworkReplyHttpImpl; friend class QNetworkReplyHttpImplPrivate; friend class QNetworkReplyFileImpl; -#ifdef Q_OS_HTML5 - friend class QNetworkReplyEmscriptenImpl; +#ifdef Q_OS_WASM + friend class QNetworkReplyWasmImpl; #endif Q_DECLARE_PRIVATE(QNetworkAccessManager) Q_PRIVATE_SLOT(d_func(), void _q_replyFinished()) diff --git a/src/network/access/qnetworkreplyemscriptenimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp index e81c7a52a4..18dcd3d4b3 100644 --- a/src/network/access/qnetworkreplyemscriptenimpl.cpp +++ b/src/network/access/qnetworkreplywasmimpl.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include "qnetworkreplyemscriptenimpl_p.h" +#include "qnetworkreplywasmimpl_p.h" #include <QTimer> #include "QtCore/qdatetime.h" @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE -QNetworkReplyEmscriptenImplPrivate::QNetworkReplyEmscriptenImplPrivate() +QNetworkReplyWasmImplPrivate::QNetworkReplyWasmImplPrivate() : QNetworkReplyPrivate(), managerPrivate(0), downloadBufferReadPosition(0), @@ -63,20 +63,20 @@ QNetworkReplyEmscriptenImplPrivate::QNetworkReplyEmscriptenImplPrivate() { } -QNetworkReplyEmscriptenImplPrivate::~QNetworkReplyEmscriptenImplPrivate() +QNetworkReplyWasmImplPrivate::~QNetworkReplyWasmImplPrivate() { } -QNetworkReplyEmscriptenImpl::~QNetworkReplyEmscriptenImpl() +QNetworkReplyWasmImpl::~QNetworkReplyWasmImpl() { } -QNetworkReplyEmscriptenImpl::QNetworkReplyEmscriptenImpl(QObject *parent) - : QNetworkReply(*new QNetworkReplyEmscriptenImplPrivate(), parent) +QNetworkReplyWasmImpl::QNetworkReplyWasmImpl(QObject *parent) + : QNetworkReply(*new QNetworkReplyWasmImplPrivate(), parent) { } -QByteArray QNetworkReplyEmscriptenImpl::methodName() const +QByteArray QNetworkReplyWasmImpl::methodName() const { switch (operation()) { case QNetworkAccessManager::HeadOperation: @@ -97,19 +97,19 @@ QByteArray QNetworkReplyEmscriptenImpl::methodName() const return QByteArray(); } -void QNetworkReplyEmscriptenImpl::close() +void QNetworkReplyWasmImpl::close() { QNetworkReply::close(); } -void QNetworkReplyEmscriptenImpl::abort() +void QNetworkReplyWasmImpl::abort() { close(); } -qint64 QNetworkReplyEmscriptenImpl::bytesAvailable() const +qint64 QNetworkReplyWasmImpl::bytesAvailable() const { - Q_D(const QNetworkReplyEmscriptenImpl); + Q_D(const QNetworkReplyWasmImpl); if (!d->isFinished) return QNetworkReply::bytesAvailable(); @@ -117,12 +117,12 @@ qint64 QNetworkReplyEmscriptenImpl::bytesAvailable() const return QNetworkReply::bytesAvailable() + d->downloadBufferCurrentSize - d->downloadBufferReadPosition; } -bool QNetworkReplyEmscriptenImpl::isSequential() const +bool QNetworkReplyWasmImpl::isSequential() const { return true; } -qint64 QNetworkReplyEmscriptenImpl::size() const +qint64 QNetworkReplyWasmImpl::size() const { return QNetworkReply::size(); } @@ -130,9 +130,9 @@ qint64 QNetworkReplyEmscriptenImpl::size() const /*! \internal */ -qint64 QNetworkReplyEmscriptenImpl::readData(char *data, qint64 maxlen) +qint64 QNetworkReplyWasmImpl::readData(char *data, qint64 maxlen) { - Q_D(QNetworkReplyEmscriptenImpl); + Q_D(QNetworkReplyWasmImpl); qint64 howMuch = qMin(maxlen, (d->downloadBuffer.size()- d->downloadBufferReadPosition)); memcpy(data, d->downloadBuffer.constData(), howMuch); @@ -141,10 +141,10 @@ qint64 QNetworkReplyEmscriptenImpl::readData(char *data, qint64 maxlen) return howMuch; } -void QNetworkReplyEmscriptenImplPrivate::setup(QNetworkAccessManager::Operation op, const QNetworkRequest &req, +void QNetworkReplyWasmImplPrivate::setup(QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *data) { - Q_Q(QNetworkReplyEmscriptenImpl); + Q_Q(QNetworkReplyWasmImpl); outgoingData = data; request = req; @@ -186,9 +186,9 @@ void QNetworkReplyEmscriptenImplPrivate::setup(QNetworkAccessManager::Operation doSendRequest(); } -void QNetworkReplyEmscriptenImplPrivate::onLoadCallback(void *data, int statusCode, int statusReason, int readyState, int buffer, int bufferSize) +void QNetworkReplyWasmImplPrivate::onLoadCallback(void *data, int statusCode, int statusReason, int readyState, int buffer, int bufferSize) { - QNetworkReplyEmscriptenImplPrivate *handler = reinterpret_cast<QNetworkReplyEmscriptenImplPrivate*>(data); + QNetworkReplyWasmImplPrivate *handler = reinterpret_cast<QNetworkReplyWasmImplPrivate*>(data); QString reasonStr = QString::fromUtf8((char *)statusReason); @@ -217,19 +217,19 @@ void QNetworkReplyEmscriptenImplPrivate::onLoadCallback(void *data, int statusCo }; } -void QNetworkReplyEmscriptenImplPrivate::onProgressCallback(void* data, int bytesWritten, int total, uint timestamp) +void QNetworkReplyWasmImplPrivate::onProgressCallback(void* data, int bytesWritten, int total, uint timestamp) { Q_UNUSED(timestamp); - QNetworkReplyEmscriptenImplPrivate *handler = reinterpret_cast<QNetworkReplyEmscriptenImplPrivate*>(data); + QNetworkReplyWasmImplPrivate *handler = reinterpret_cast<QNetworkReplyWasmImplPrivate*>(data); handler->emitDataReadProgress(bytesWritten, total); } -void QNetworkReplyEmscriptenImplPrivate::onRequestErrorCallback(void* data, int statusCode, int statusReason) +void QNetworkReplyWasmImplPrivate::onRequestErrorCallback(void* data, int statusCode, int statusReason) { QString reasonStr = QString::fromUtf8((char *)statusReason); - QNetworkReplyEmscriptenImplPrivate *handler = reinterpret_cast<QNetworkReplyEmscriptenImplPrivate*>(data); + QNetworkReplyWasmImplPrivate *handler = reinterpret_cast<QNetworkReplyWasmImplPrivate*>(data); handler->q_func()->setAttribute(QNetworkRequest::HttpStatusCodeAttribute, statusCode); if (!reasonStr.isEmpty()) @@ -241,15 +241,15 @@ void QNetworkReplyEmscriptenImplPrivate::onRequestErrorCallback(void* data, int } } -void QNetworkReplyEmscriptenImplPrivate::onResponseHeadersCallback(void* data, int headers) +void QNetworkReplyWasmImplPrivate::onResponseHeadersCallback(void* data, int headers) { - QNetworkReplyEmscriptenImplPrivate *handler = reinterpret_cast<QNetworkReplyEmscriptenImplPrivate*>(data); + QNetworkReplyWasmImplPrivate *handler = reinterpret_cast<QNetworkReplyWasmImplPrivate*>(data); handler->headersReceived((char *)headers); } -void QNetworkReplyEmscriptenImplPrivate::doSendRequest() +void QNetworkReplyWasmImplPrivate::doSendRequest() { - Q_Q(QNetworkReplyEmscriptenImpl); + Q_Q(QNetworkReplyWasmImpl); totalDownloadSize = 0; jsRequest(QString::fromUtf8(q->methodName()), // GET POST request.url().toString(), @@ -260,7 +260,7 @@ void QNetworkReplyEmscriptenImplPrivate::doSendRequest() } /* const QString &body, const QList<QPair<QByteArray, QByteArray> > &headers ,*/ -void QNetworkReplyEmscriptenImplPrivate::jsRequest(const QString &verb, const QString &url, void *loadCallback, void *progressCallback, void *errorCallback, void *onResponseHeadersCallback) +void QNetworkReplyWasmImplPrivate::jsRequest(const QString &verb, const QString &url, void *loadCallback, void *progressCallback, void *errorCallback, void *onResponseHeadersCallback) { QString extraDataString; @@ -419,10 +419,10 @@ void QNetworkReplyEmscriptenImplPrivate::jsRequest(const QString &verb, const QS ); } -void QNetworkReplyEmscriptenImplPrivate::emitReplyError(QNetworkReply::NetworkError errorCode, const QString &errorString) +void QNetworkReplyWasmImplPrivate::emitReplyError(QNetworkReply::NetworkError errorCode, const QString &errorString) { Q_UNUSED(errorCode) - Q_Q(QNetworkReplyEmscriptenImpl); + Q_Q(QNetworkReplyWasmImpl); q->setError(errorCode, errorString); emit q->error(errorCode); @@ -431,9 +431,9 @@ void QNetworkReplyEmscriptenImplPrivate::emitReplyError(QNetworkReply::NetworkEr emit q->finished(); } -void QNetworkReplyEmscriptenImplPrivate::emitDataReadProgress(qint64 bytesReceived, qint64 bytesTotal) +void QNetworkReplyWasmImplPrivate::emitDataReadProgress(qint64 bytesReceived, qint64 bytesTotal) { - Q_Q(QNetworkReplyEmscriptenImpl); + Q_Q(QNetworkReplyWasmImpl); totalDownloadSize = bytesTotal; @@ -442,9 +442,9 @@ void QNetworkReplyEmscriptenImplPrivate::emitDataReadProgress(qint64 bytesReceiv emit q->downloadProgress(bytesReceived, totalDownloadSize); } -void QNetworkReplyEmscriptenImplPrivate::dataReceived(char *buffer, int bufferSize) +void QNetworkReplyWasmImplPrivate::dataReceived(char *buffer, int bufferSize) { - Q_Q(QNetworkReplyEmscriptenImpl); + Q_Q(QNetworkReplyWasmImpl); if (bufferSize > 0) q->setReadBufferSize(bufferSize); @@ -506,9 +506,9 @@ static int parseHeaderName(const QByteArray &headerName) } -void QNetworkReplyEmscriptenImplPrivate::headersReceived(char *buffer) +void QNetworkReplyWasmImplPrivate::headersReceived(char *buffer) { - Q_Q(QNetworkReplyEmscriptenImpl); + Q_Q(QNetworkReplyWasmImpl); QString bufferString = QString::fromUtf8(buffer); if (!bufferString.isEmpty()) { @@ -531,9 +531,9 @@ void QNetworkReplyEmscriptenImplPrivate::headersReceived(char *buffer) emit q->metaDataChanged(); } -void QNetworkReplyEmscriptenImplPrivate::_q_bufferOutgoingDataFinished() +void QNetworkReplyWasmImplPrivate::_q_bufferOutgoingDataFinished() { - Q_Q(QNetworkReplyEmscriptenImpl); + Q_Q(QNetworkReplyWasmImpl); // make sure this is only called once, ever. //_q_bufferOutgoingData may call it or the readChannelFinished emission @@ -548,9 +548,9 @@ void QNetworkReplyEmscriptenImplPrivate::_q_bufferOutgoingDataFinished() doSendRequest(); } -void QNetworkReplyEmscriptenImplPrivate::_q_bufferOutgoingData() +void QNetworkReplyWasmImplPrivate::_q_bufferOutgoingData() { - Q_Q(QNetworkReplyEmscriptenImpl); + Q_Q(QNetworkReplyWasmImpl); if (!outgoingDataBuffer) { // first call, create our buffer @@ -592,7 +592,7 @@ void QNetworkReplyEmscriptenImplPrivate::_q_bufferOutgoingData() } //taken from qhttpthreaddelegate.cpp -QNetworkReply::NetworkError QNetworkReplyEmscriptenImplPrivate::statusCodeFromHttp(int httpStatusCode, const QUrl &url) +QNetworkReply::NetworkError QNetworkReplyWasmImplPrivate::statusCodeFromHttp(int httpStatusCode, const QUrl &url) { QNetworkReply::NetworkError code; // we've got an error @@ -665,5 +665,5 @@ QNetworkReply::NetworkError QNetworkReplyEmscriptenImplPrivate::statusCodeFromHt QT_END_NAMESPACE -#include "moc_qnetworkreplyemscriptenimpl_p.cpp" +#include "moc_qnetworkreplywasmimpl_p.cpp" diff --git a/src/network/access/qnetworkreplyemscriptenimpl_p.h b/src/network/access/qnetworkreplywasmimpl_p.h index 89df7771cc..e683da61f3 100644 --- a/src/network/access/qnetworkreplyemscriptenimpl_p.h +++ b/src/network/access/qnetworkreplywasmimpl_p.h @@ -37,8 +37,8 @@ ** ****************************************************************************/ -#ifndef QNETWORKREPLYEMSCRIPTENIMPL_H -#define QNETWORKREPLYEMSCRIPTENIMPL_H +#ifndef QNETWORKREPLYWASMIMPL_H +#define QNETWORKREPLYWASMIMPL_H // // W A R N I N G @@ -66,13 +66,13 @@ QT_BEGIN_NAMESPACE class QIODevice; //class QNetworkAccessBackend; -class QNetworkReplyEmscriptenImplPrivate; -class QNetworkReplyEmscriptenImpl: public QNetworkReply +class QNetworkReplyWasmImplPrivate; +class QNetworkReplyWasmImpl: public QNetworkReply { Q_OBJECT public: - QNetworkReplyEmscriptenImpl(QObject *parent = 0/*QNetworkAccessManager *manager, const QNetworkRequest &req, const QNetworkAccessManager::Operation op, QIODevice *outgoingData*/); - ~QNetworkReplyEmscriptenImpl(); + QNetworkReplyWasmImpl(QObject *parent = 0/*QNetworkAccessManager *manager, const QNetworkRequest &req, const QNetworkAccessManager::Operation op, QIODevice *outgoingData*/); + ~QNetworkReplyWasmImpl(); virtual void abort() Q_DECL_OVERRIDE; // reimplemented from QNetworkReply @@ -86,7 +86,7 @@ public: void setup(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData); - Q_DECLARE_PRIVATE(QNetworkReplyEmscriptenImpl) + Q_DECLARE_PRIVATE(QNetworkReplyWasmImpl) Q_PRIVATE_SLOT(d_func(), void emitReplyError(QNetworkReply::NetworkError errorCode, const QString &errorString)) Q_PRIVATE_SLOT(d_func(), void emitDataReadProgress(qint64 done, qint64 total)) @@ -98,11 +98,11 @@ private: }; -class QNetworkReplyEmscriptenImplPrivate: public QNetworkReplyPrivate +class QNetworkReplyWasmImplPrivate: public QNetworkReplyPrivate { public: - QNetworkReplyEmscriptenImplPrivate(); - ~QNetworkReplyEmscriptenImplPrivate(); + QNetworkReplyWasmImplPrivate(); + ~QNetworkReplyWasmImplPrivate(); QNetworkAccessManagerPrivate *managerPrivate; void doSendRequest(); @@ -144,11 +144,11 @@ public: QSharedPointer<QRingBuffer> outgoingDataBuffer; static QNetworkReply::NetworkError statusCodeFromHttp(int httpStatusCode, const QUrl &url); - Q_DECLARE_PUBLIC(QNetworkReplyEmscriptenImpl) + Q_DECLARE_PUBLIC(QNetworkReplyWasmImpl) }; QT_END_NAMESPACE //Q_DECLARE_METATYPE(QNetworkRequest::KnownHeaders) -#endif // QNETWORKREPLYEMSCRIPTENIMPL_H +#endif // QNETWORKREPLYWASMIMPL_H diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 5bfc23a338..a7a998393c 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -570,7 +570,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, funcs.glGenRenderbuffers(1, &depth_buffer); funcs.glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer); Q_ASSERT(funcs.glIsRenderbuffer(depth_buffer)); -#ifndef Q_OS_HTML5 +#ifndef Q_OS_WASM if (samples != 0 && funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_DEPTH24_STENCIL8, size.width(), size.height()); diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index 5131816213..4e86852bc8 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -277,7 +277,7 @@ EGLSurface QEGLPlatformContext::createTemporaryOffscreenSurface() EGL_LARGEST_PBUFFER, EGL_FALSE, EGL_NONE }; -#ifndef Q_OS_HTML5 +#ifndef Q_OS_WASM // eglCreateWindowSurface is not supported by emscripten // Cannot just pass m_eglConfig because it may not be suitable for pbuffers. Instead, diff --git a/src/plugins/imageformats/gif/gif.pro b/src/plugins/imageformats/gif/gif.pro index c6b8a231c9..2e519bb35e 100644 --- a/src/plugins/imageformats/gif/gif.pro +++ b/src/plugins/imageformats/gif/gif.pro @@ -9,4 +9,4 @@ PLUGIN_TYPE = imageformats PLUGIN_CLASS_NAME = QGifPlugin load(qt_plugin) -emscripten: CONFIG += static plugin +wasm: CONFIG += static plugin diff --git a/src/plugins/imageformats/ico/ico.pro b/src/plugins/imageformats/ico/ico.pro index f47470e751..6431b738c4 100644 --- a/src/plugins/imageformats/ico/ico.pro +++ b/src/plugins/imageformats/ico/ico.pro @@ -9,4 +9,4 @@ PLUGIN_TYPE = imageformats PLUGIN_CLASS_NAME = QICOPlugin load(qt_plugin) -emscripten: CONFIG += static plugin +wasm: CONFIG += static plugin diff --git a/src/plugins/imageformats/jpeg/jpeg.pro b/src/plugins/imageformats/jpeg/jpeg.pro index 37a5211625..6bdc4b0ce7 100644 --- a/src/plugins/imageformats/jpeg/jpeg.pro +++ b/src/plugins/imageformats/jpeg/jpeg.pro @@ -17,4 +17,4 @@ PLUGIN_TYPE = imageformats PLUGIN_CLASS_NAME = QJpegPlugin load(qt_plugin) -emscripten: CONFIG += static plugin +wasm: CONFIG += static plugin diff --git a/src/plugins/platforminputcontexts/platforminputcontexts.pro b/src/plugins/platforminputcontexts/platforminputcontexts.pro index d437d554e0..397490eae3 100644 --- a/src/plugins/platforminputcontexts/platforminputcontexts.pro +++ b/src/plugins/platforminputcontexts/platforminputcontexts.pro @@ -1,7 +1,7 @@ TEMPLATE = subdirs QT_FOR_CONFIG += gui-private -!emscripten:qtHaveModule(dbus) { +!wasm:qtHaveModule(dbus) { !mac:!win32:SUBDIRS += ibus } diff --git a/src/plugins/platforms/html5/html5.json b/src/plugins/platforms/html5/html5.json deleted file mode 100644 index b5fbc59fd7..0000000000 --- a/src/plugins/platforms/html5/html5.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Keys": [ "html5" ] -} diff --git a/src/plugins/platforms/html5/html5.pro b/src/plugins/platforms/html5/html5.pro deleted file mode 100644 index 6072f1e1f8..0000000000 --- a/src/plugins/platforms/html5/html5.pro +++ /dev/null @@ -1,59 +0,0 @@ -TARGET = html5 -CONFIG += static plugin -QT += \ - core-private gui-private \ - eventdispatcher_support-private fontdatabase_support-private egl_support-private - -#DEFINES += QEGL_EXTRA_DEBUG - -# Avoid X11 header collision, use generic EGL native types -DEFINES += QT_EGL_NO_X11 - -SOURCES = main.cpp \ - qhtml5integration.cpp \ - qhtml5window.cpp \ - qhtml5screen.cpp \ - qhtml5fontdatabase.cpp \ - qhtml5eventtranslator.cpp \ - qhtml5eventdispatcher.cpp \ - qhtml5compositor.cpp \ - qhtml5cursor.cpp \ - qhtml5openglcontext.cpp \ - qhtml5theme.cpp - -HEADERS = qhtml5integration.h \ - qhtml5window.h \ - qhtml5screen.h \ - qhtml5fontdatabase.h \ - qhtml5eventtranslator.h \ - qhtml5eventdispatcher.h \ - qhtml5compositor.h \ - qhtml5stylepixmaps_p.h \ - qhtml5cursor.h \ - qhtml5openglcontext.h \ - qhtml5theme.h - -RESOURCES += fonts/html5fonts.qrc - -qtConfig(opengl) { - SOURCES += qhtml5backingstore.cpp - HEADERS += qhtml5backingstore.h -} -CONFIG += egl - -OTHER_FILES += \ - html5.json \ - html5_shell.html \ - qtloader.js - -shell_files.path = $$[QT_INSTALL_PLUGINS]/platforms -shell_files.files = html5_shell.html \ - qtloader.js \ - qtlogo.svg - -INSTALLS += shell_files - -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QHtml5IntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro index 17e617931b..806fb23812 100644 --- a/src/plugins/platforms/platforms.pro +++ b/src/plugins/platforms/platforms.pro @@ -46,7 +46,7 @@ haiku { SUBDIRS += haiku } -emscripten: SUBDIRS = html5 +wasm: SUBDIRS = wasm qtConfig(mirclient): SUBDIRS += mirclient diff --git a/src/plugins/platforms/html5/fonts/DejaVuSans.ttf b/src/plugins/platforms/wasm/fonts/DejaVuSans.ttf Binary files differindex 7e411a71be..7e411a71be 100644 --- a/src/plugins/platforms/html5/fonts/DejaVuSans.ttf +++ b/src/plugins/platforms/wasm/fonts/DejaVuSans.ttf diff --git a/src/plugins/platforms/html5/fonts/Vera.ttf b/src/plugins/platforms/wasm/fonts/Vera.ttf Binary files differindex 58cd6b5e61..58cd6b5e61 100644 --- a/src/plugins/platforms/html5/fonts/Vera.ttf +++ b/src/plugins/platforms/wasm/fonts/Vera.ttf diff --git a/src/plugins/platforms/html5/fonts/html5fonts.qrc b/src/plugins/platforms/wasm/fonts/wasmfonts.qrc index d017417ee5..d017417ee5 100644 --- a/src/plugins/platforms/html5/fonts/html5fonts.qrc +++ b/src/plugins/platforms/wasm/fonts/wasmfonts.qrc diff --git a/src/plugins/platforms/html5/main.cpp b/src/plugins/platforms/wasm/main.cpp index 27aa30b371..1f629d9db8 100644 --- a/src/plugins/platforms/html5/main.cpp +++ b/src/plugins/platforms/wasm/main.cpp @@ -28,23 +28,23 @@ ****************************************************************************/ #include <qpa/qplatformintegrationplugin.h> -#include "qhtml5integration.h" +#include "qwasmintegration.h" QT_BEGIN_NAMESPACE -class QHtml5IntegrationPlugin : public QPlatformIntegrationPlugin +class QWasmIntegrationPlugin : public QPlatformIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "html5.json") + Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "wasm.json") public: QPlatformIntegration *create(const QString&, const QStringList&) override; }; -QPlatformIntegration* QHtml5IntegrationPlugin::create(const QString& system, const QStringList& paramList) +QPlatformIntegration* QWasmIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (!system.compare(QStringLiteral("html5"), Qt::CaseInsensitive)) - return new QHtml5Integration; + if (!system.compare(QStringLiteral("webassembly"), Qt::CaseInsensitive)) + return new QWasmIntegration; return nullptr; } diff --git a/src/plugins/platforms/html5/qtloader.js b/src/plugins/platforms/wasm/qtloader.js index 2b8ae40fd9..2b8ae40fd9 100644 --- a/src/plugins/platforms/html5/qtloader.js +++ b/src/plugins/platforms/wasm/qtloader.js diff --git a/src/plugins/platforms/html5/qtlogo.svg b/src/plugins/platforms/wasm/qtlogo.svg index cb8989bb79..cb8989bb79 100644 --- a/src/plugins/platforms/html5/qtlogo.svg +++ b/src/plugins/platforms/wasm/qtlogo.svg diff --git a/src/plugins/platforms/html5/qhtml5backingstore.cpp b/src/plugins/platforms/wasm/qwasmbackingstore.cpp index 7bddc1b66b..8b33f62ce0 100644 --- a/src/plugins/platforms/html5/qhtml5backingstore.cpp +++ b/src/plugins/platforms/wasm/qwasmbackingstore.cpp @@ -27,9 +27,9 @@ ** ****************************************************************************/ -#include "qhtml5backingstore.h" -#include "qhtml5window.h" -#include "qhtml5compositor.h" +#include "qwasmbackingstore.h" +#include "qwasmwindow.h" +#include "qwasmcompositor.h" #include <QtGui/QOpenGLTexture> #include <QtGui/QMatrix4x4> @@ -41,26 +41,26 @@ QT_BEGIN_NAMESPACE -QHtml5BackingStore::QHtml5BackingStore(QHtml5Compositor *compositor, QWindow *window) +QWasmBackingStore::QWasmBackingStore(QWasmCompositor *compositor, QWindow *window) : QPlatformBackingStore(window) , mCompositor(compositor) , mTexture(new QOpenGLTexture(QOpenGLTexture::Target2D)) { - QHtml5Window *html5Window = static_cast<QHtml5Window *>(window->handle()); - if (html5Window) - html5Window->setBackingStore(this); + QWasmWindow *wasmWindow = static_cast<QWasmWindow *>(window->handle()); + if (wasmWindow) + wasmWindow->setBackingStore(this); } -QHtml5BackingStore::~QHtml5BackingStore() +QWasmBackingStore::~QWasmBackingStore() { } -QPaintDevice *QHtml5BackingStore::paintDevice() +QPaintDevice *QWasmBackingStore::paintDevice() { return &mImage; } -void QHtml5BackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) +void QWasmBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(window); Q_UNUSED(region); @@ -70,7 +70,7 @@ void QHtml5BackingStore::flush(QWindow *window, const QRegion ®ion, const QPo mCompositor->requestRedraw(); } -void QHtml5BackingStore::updateTexture() +void QWasmBackingStore::updateTexture() { if (mDirty.isNull()) return; @@ -120,7 +120,7 @@ void QHtml5BackingStore::updateTexture() mDirty = QRegion(); } -void QHtml5BackingStore::beginPaint(const QRegion ®ion) +void QWasmBackingStore::beginPaint(const QRegion ®ion) { mDirty |= region; // Keep backing store device pixel ratio in sync with window @@ -134,7 +134,7 @@ void QHtml5BackingStore::beginPaint(const QRegion ®ion) painter.fillRect(rect, blank); } -void QHtml5BackingStore::resize(const QSize &size, const QRegion &staticContents) +void QWasmBackingStore::resize(const QSize &size, const QRegion &staticContents) { Q_UNUSED(staticContents) @@ -145,18 +145,18 @@ void QHtml5BackingStore::resize(const QSize &size, const QRegion &staticContents mTexture->destroy(); } -QImage QHtml5BackingStore::toImage() const +QImage QWasmBackingStore::toImage() const { // used by QPlatformBackingStore::composeAndFlush return mImage; } -const QImage &QHtml5BackingStore::getImageRef() const +const QImage &QWasmBackingStore::getImageRef() const { return mImage; } -const QOpenGLTexture* QHtml5BackingStore::getUpdatedTexture() +const QOpenGLTexture* QWasmBackingStore::getUpdatedTexture() { updateTexture(); return mTexture.data(); diff --git a/src/plugins/platforms/html5/qhtml5backingstore.h b/src/plugins/platforms/wasm/qwasmbackingstore.h index d808d10254..9f8e503b88 100644 --- a/src/plugins/platforms/html5/qhtml5backingstore.h +++ b/src/plugins/platforms/wasm/qwasmbackingstore.h @@ -27,8 +27,8 @@ ** ****************************************************************************/ -#ifndef QHTML5BACKINGSTORE_H -#define QHTML5BACKINGSTORE_H +#ifndef QWASMBACKINGSTORE_H +#define QWASMBACKINGSTORE_H #include <qpa/qplatformbackingstore.h> #include <QtGui/QImage> @@ -37,13 +37,13 @@ QT_BEGIN_NAMESPACE class QOpenGLTexture; class QRegion; -class QHtml5Compositor; +class QWasmCompositor; -class QHtml5BackingStore : public QPlatformBackingStore +class QWasmBackingStore : public QPlatformBackingStore { public: - QHtml5BackingStore(QHtml5Compositor *compositor, QWindow *window); - ~QHtml5BackingStore(); + QWasmBackingStore(QWasmCompositor *compositor, QWindow *window); + ~QWasmBackingStore(); QPaintDevice *paintDevice() override; @@ -59,7 +59,7 @@ protected: void updateTexture(); private: - QHtml5Compositor *mCompositor; + QWasmCompositor *mCompositor; QImage mImage; @@ -71,4 +71,4 @@ private: QT_END_NAMESPACE -#endif // QHTML5BACKINGSTORE_H +#endif // QWASMBACKINGSTORE_H diff --git a/src/plugins/platforms/html5/qhtml5compositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index 2c30985832..925201b1b9 100644 --- a/src/plugins/platforms/html5/qhtml5compositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -27,9 +27,9 @@ ** ****************************************************************************/ -#include "qhtml5compositor.h" -#include "qhtml5window.h" -#include "qhtml5stylepixmaps_p.h" +#include "qwasmcompositor.h" +#include "qwasmwindow.h" +#include "qwasmstylepixmaps_p.h" #include <QOpenGLTexture> @@ -50,7 +50,7 @@ Q_GUI_EXPORT int qt_defaultDpiX(); -QHtml5CompositedWindow::QHtml5CompositedWindow() +QWasmCompositedWindow::QWasmCompositedWindow() : window(0) , parentWindow(nullptr) , flushPending(false) @@ -58,7 +58,7 @@ QHtml5CompositedWindow::QHtml5CompositedWindow() { } -QHtml5Compositor::QHtml5Compositor() +QWasmCompositor::QWasmCompositor() : m_frameBuffer(nullptr) , mBlitter(new QOpenGLTextureBlitter) , m_needComposit(false) @@ -69,19 +69,19 @@ QHtml5Compositor::QHtml5Compositor() { } -QHtml5Compositor::~QHtml5Compositor() +QWasmCompositor::~QWasmCompositor() { delete m_frameBuffer; } -void QHtml5Compositor::setEnabled(bool enabled) +void QWasmCompositor::setEnabled(bool enabled) { m_isEnabled = enabled; } -void QHtml5Compositor::addWindow(QHtml5Window *window, QHtml5Window *parentWindow) +void QWasmCompositor::addWindow(QWasmWindow *window, QWasmWindow *parentWindow) { - QHtml5CompositedWindow compositedWindow; + QWasmCompositedWindow compositedWindow; compositedWindow.window = window; compositedWindow.parentWindow = parentWindow; m_compositedWindows.insert(window, compositedWindow); @@ -95,12 +95,12 @@ void QHtml5Compositor::addWindow(QHtml5Window *window, QHtml5Window *parentWindo notifyTopWindowChanged(window); } -void QHtml5Compositor::removeWindow(QHtml5Window *window) +void QWasmCompositor::removeWindow(QWasmWindow *window) { - QHtml5Window *platformWindow = m_compositedWindows[window].parentWindow; + QWasmWindow *platformWindow = m_compositedWindows[window].parentWindow; if (platformWindow) { - QHtml5Window *parentWindow = window; + QWasmWindow *parentWindow = window; m_compositedWindows[parentWindow].childWindows.removeAll(window); } @@ -110,14 +110,14 @@ void QHtml5Compositor::removeWindow(QHtml5Window *window) notifyTopWindowChanged(window); } -void QHtml5Compositor::setScreen(QHtml5Screen *screen) +void QWasmCompositor::setScreen(QWasmScreen *screen) { mScreen = screen; } -void QHtml5Compositor::setVisible(QHtml5Window *window, bool visible) +void QWasmCompositor::setVisible(QWasmWindow *window, bool visible) { - QHtml5CompositedWindow &compositedWindow = m_compositedWindows[window]; + QWasmCompositedWindow &compositedWindow = m_compositedWindows[window]; if (compositedWindow.visible == visible) return; @@ -131,12 +131,12 @@ void QHtml5Compositor::setVisible(QHtml5Window *window, bool visible) requestRedraw(); } -void QHtml5Compositor::raise(QHtml5Window *window) +void QWasmCompositor::raise(QWasmWindow *window) { if (m_compositedWindows.size() <= 1) return; - QHtml5CompositedWindow &compositedWindow = m_compositedWindows[window]; + QWasmCompositedWindow &compositedWindow = m_compositedWindows[window]; compositedWindow.damage = compositedWindow.window->geometry(); m_windowStack.removeAll(window); m_windowStack.append(window); @@ -144,54 +144,54 @@ void QHtml5Compositor::raise(QHtml5Window *window) notifyTopWindowChanged(window); } -void QHtml5Compositor::lower(QHtml5Window *window) +void QWasmCompositor::lower(QWasmWindow *window) { if (m_compositedWindows.size() <= 1) return; m_windowStack.removeAll(window); m_windowStack.prepend(window); - QHtml5CompositedWindow &compositedWindow = m_compositedWindows[window]; + QWasmCompositedWindow &compositedWindow = m_compositedWindows[window]; globalDamage = compositedWindow.window->geometry(); // repaint previosly covered area. notifyTopWindowChanged(window); } -void QHtml5Compositor::setParent(QHtml5Window *window, QHtml5Window *parent) +void QWasmCompositor::setParent(QWasmWindow *window, QWasmWindow *parent) { m_compositedWindows[window].parentWindow = parent; requestRedraw(); } -void QHtml5Compositor::flush(QHtml5Window *window, const QRegion ®ion) +void QWasmCompositor::flush(QWasmWindow *window, const QRegion ®ion) { - QHtml5CompositedWindow &compositedWindow = m_compositedWindows[window]; + QWasmCompositedWindow &compositedWindow = m_compositedWindows[window]; compositedWindow.flushPending = true; compositedWindow.damage = region; requestRedraw(); } -int QHtml5Compositor::windowCount() const +int QWasmCompositor::windowCount() const { return m_windowStack.count(); } -void QHtml5Compositor::redrawWindowContent() +void QWasmCompositor::redrawWindowContent() { // Redraw window content by sending expose events. This redraw // will cause a backing store flush, which will call requestRedraw() // to composit. - for (QHtml5Window *platformWindow : m_windowStack) { + for (QWasmWindow *platformWindow : m_windowStack) { QWindow *window = platformWindow->window(); QWindowSystemInterface::handleExposeEvent<QWindowSystemInterface::SynchronousDelivery>( window, QRect(QPoint(0, 0), window->geometry().size())); } } -void QHtml5Compositor::requestRedraw() +void QWasmCompositor::requestRedraw() { if (m_needComposit) return; @@ -200,13 +200,13 @@ void QHtml5Compositor::requestRedraw() QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest)); } -QWindow *QHtml5Compositor::windowAt(QPoint p, int padding) const +QWindow *QWasmCompositor::windowAt(QPoint p, int padding) const { int index = m_windowStack.count() - 1; // qDebug() << "window at" << "point" << p << "window count" << index; while (index >= 0) { - const QHtml5CompositedWindow &compositedWindow = m_compositedWindows[m_windowStack.at(index)]; + const QWasmCompositedWindow &compositedWindow = m_compositedWindows[m_windowStack.at(index)]; //qDebug() << "windwAt testing" << compositedWindow.window << QRect geometry = compositedWindow.window->windowFrameGeometry() @@ -220,12 +220,12 @@ QWindow *QHtml5Compositor::windowAt(QPoint p, int padding) const return 0; } -QWindow *QHtml5Compositor::keyWindow() const +QWindow *QWasmCompositor::keyWindow() const { return m_windowStack.at(m_windowStack.count() - 1)->window(); } -bool QHtml5Compositor::event(QEvent *ev) +bool QWasmCompositor::event(QEvent *ev) { if (ev->type() == QEvent::UpdateRequest) { if (m_isEnabled) @@ -236,7 +236,7 @@ bool QHtml5Compositor::event(QEvent *ev) return QObject::event(ev); } -void QHtml5Compositor::blit(QOpenGLTextureBlitter *blitter, QHtml5Screen *screen, const QOpenGLTexture *texture, QRect targetGeometry) +void QWasmCompositor::blit(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, const QOpenGLTexture *texture, QRect targetGeometry) { QMatrix4x4 m; m.translate(-1.0f, -1.0f); @@ -255,16 +255,16 @@ void QHtml5Compositor::blit(QOpenGLTextureBlitter *blitter, QHtml5Screen *screen blitter->blit(texture->textureId(), m, QOpenGLTextureBlitter::OriginTopLeft); } -void QHtml5Compositor::drawWindowContent(QOpenGLTextureBlitter *blitter, QHtml5Screen *screen, QHtml5Window *window) +void QWasmCompositor::drawWindowContent(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window) { - QHtml5BackingStore* backingStore = window->backingStore(); + QWasmBackingStore* backingStore = window->backingStore(); QOpenGLTexture const* texture = backingStore->getUpdatedTexture(); blit(blitter, screen, texture, window->geometry()); } -QPalette QHtml5Compositor::makeWindowPalette() +QPalette QWasmCompositor::makeWindowPalette() { QPalette palette; palette.setColor(QPalette::Active, QPalette::Highlight, @@ -281,7 +281,7 @@ QPalette QHtml5Compositor::makeWindowPalette() return palette; } -QRect QHtml5Compositor::titlebarRect(QHtml5TitleBarOptions tb, QHtml5Compositor::SubControls subcontrol) +QRect QWasmCompositor::titlebarRect(QWasmTitleBarOptions tb, QWasmCompositor::SubControls subcontrol) { QRect ret; const int controlMargin = 2; @@ -347,12 +347,12 @@ int dpiScaled(qreal value) return value * (qreal(qt_defaultDpiX()) / 96.0); } -QHtml5Compositor::QHtml5TitleBarOptions QHtml5Compositor::makeTitleBarOptions(const QHtml5Window *window) +QWasmCompositor::QWasmTitleBarOptions QWasmCompositor::makeTitleBarOptions(const QWasmWindow *window) { int width = window->windowFrameGeometry().width(); int border = window->borderWidth(); - QHtml5TitleBarOptions titleBarOptions; + QWasmTitleBarOptions titleBarOptions; titleBarOptions.rect = QRect(border, border, width - 2 * border, window->titleHeight()); titleBarOptions.flags = window->window()->flags(); @@ -374,7 +374,7 @@ QHtml5Compositor::QHtml5TitleBarOptions QHtml5Compositor::makeTitleBarOptions(co } - titleBarOptions.palette = QHtml5Compositor::makeWindowPalette(); + titleBarOptions.palette = QWasmCompositor::makeWindowPalette(); if (window->window()->isActive()) { titleBarOptions.palette.setCurrentColorGroup(QPalette::Active); @@ -382,7 +382,7 @@ QHtml5Compositor::QHtml5TitleBarOptions QHtml5Compositor::makeTitleBarOptions(co titleBarOptions.palette.setCurrentColorGroup(QPalette::Inactive); } - if (window->activeSubControl() != QHtml5Compositor::SC_None) { + if (window->activeSubControl() != QWasmCompositor::SC_None) { titleBarOptions.subControls = window->activeSubControl(); } @@ -394,7 +394,7 @@ QHtml5Compositor::QHtml5TitleBarOptions QHtml5Compositor::makeTitleBarOptions(co return titleBarOptions; } -void QHtml5Compositor::drawWindowDecorations(QOpenGLTextureBlitter *blitter, QHtml5Screen *screen, QHtml5Window *window) +void QWasmCompositor::drawWindowDecorations(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window) { int width = window->windowFrameGeometry().width(); int height = window->windowFrameGeometry().height(); @@ -405,11 +405,11 @@ void QHtml5Compositor::drawWindowDecorations(QOpenGLTextureBlitter *blitter, QHt QPainter painter(&image); painter.fillRect(QRect(0, 0, width, height), painter.background()); - QHtml5TitleBarOptions titleBarOptions = makeTitleBarOptions(window); + QWasmTitleBarOptions titleBarOptions = makeTitleBarOptions(window); drawTitlebarWindow(titleBarOptions, &painter); - QHtml5FrameOptions frameOptions; + QWasmFrameOptions frameOptions; frameOptions.rect = QRect(0, 0, width, height); frameOptions.lineWidth = dpiScaled(4.); @@ -431,7 +431,7 @@ void QHtml5Compositor::drawWindowDecorations(QOpenGLTextureBlitter *blitter, QHt blit(blitter, screen, &texture, QRect(window->windowFrameGeometry().topLeft(), QSize(width, height))); } -void QHtml5Compositor::drawFrameWindow(QHtml5FrameOptions options, QPainter *painter) +void QWasmCompositor::drawFrameWindow(QWasmFrameOptions options, QPainter *painter) { int x = options.rect.x(); int y = options.rect.y(); @@ -485,7 +485,7 @@ static QPixmap cachedPixmapFromXPM(const char * const *xpm) return result; } -void QHtml5Compositor::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, +void QWasmCompositor::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const { qreal scale = pixmap.devicePixelRatio(); @@ -510,7 +510,7 @@ void QHtml5Compositor::drawItemPixmap(QPainter *painter, const QRect &rect, int } -void QHtml5Compositor::drawTitlebarWindow(QHtml5TitleBarOptions tb, QPainter *painter) +void QWasmCompositor::drawTitlebarWindow(QWasmTitleBarOptions tb, QPainter *painter) { QRect ir; if (tb.subControls.testFlag(SC_TitleBarLabel)) { @@ -575,7 +575,7 @@ void QHtml5Compositor::drawTitlebarWindow(QHtml5TitleBarOptions tb, QPainter *pa } } -void QHtml5Compositor::drawShadePanel(QHtml5TitleBarOptions options, QPainter *painter) +void QWasmCompositor::drawShadePanel(QWasmTitleBarOptions options, QPainter *painter) { int lineWidth = 1; QPalette palette = options.palette; @@ -647,14 +647,14 @@ void QHtml5Compositor::drawShadePanel(QHtml5TitleBarOptions options, QPainter *p } -void QHtml5Compositor::drawWindow(QOpenGLTextureBlitter *blitter, QHtml5Screen *screen, QHtml5Window *window) +void QWasmCompositor::drawWindow(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window) { if (window->window()->type() != Qt::Popup) drawWindowDecorations(blitter, screen, window); drawWindowContent(blitter, screen, window); } -void QHtml5Compositor::frame() +void QWasmCompositor::frame() { if (!m_needComposit) return; @@ -664,9 +664,9 @@ void QHtml5Compositor::frame() if (m_windowStack.empty() || !mScreen) return; - QHtml5Window *someWindow = nullptr; + QWasmWindow *someWindow = nullptr; - foreach (QHtml5Window *window, m_windowStack) { + foreach (QWasmWindow *window, m_windowStack) { if (window->window()->surfaceClass() == QSurface::Window && qt_window_private(static_cast<QWindow *>(window->window()))->receivedExpose) { someWindow = window; @@ -698,8 +698,8 @@ void QHtml5Compositor::frame() mBlitter->bind(); mBlitter->setRedBlueSwizzle(true); - foreach (QHtml5Window *window, m_windowStack) { - QHtml5CompositedWindow &compositedWindow = m_compositedWindows[window]; + foreach (QWasmWindow *window, m_windowStack) { + QWasmCompositedWindow &compositedWindow = m_compositedWindows[window]; if (!compositedWindow.visible) continue; @@ -713,13 +713,13 @@ void QHtml5Compositor::frame() mContext->swapBuffers(someWindow->window()); } -void QHtml5Compositor::notifyTopWindowChanged(QHtml5Window* window) +void QWasmCompositor::notifyTopWindowChanged(QWasmWindow* window) { QWindow *modalWindow; bool blocked = QGuiApplicationPrivate::instance()->isWindowBlocked(window->window(), &modalWindow); if (blocked) { - raise(static_cast<QHtml5Window*>(modalWindow->handle())); + raise(static_cast<QWasmWindow*>(modalWindow->handle())); return; } diff --git a/src/plugins/platforms/html5/qhtml5compositor.h b/src/plugins/platforms/wasm/qwasmcompositor.h index 8ce3f1948a..06ddb88270 100644 --- a/src/plugins/platforms/html5/qhtml5compositor.h +++ b/src/plugins/platforms/wasm/qwasmcompositor.h @@ -27,8 +27,8 @@ ** ****************************************************************************/ -#ifndef QHTML5COMPOSITOR_H -#define QHTML5COMPOSITOR_H +#ifndef QWASMCOMPOSITOR_H +#define QWASMCOMPOSITOR_H #include <QtGui/QRegion> #include <qpa/qplatformwindow.h> @@ -41,32 +41,32 @@ QT_BEGIN_NAMESPACE -class QHtml5Window; -class QHtml5Screen; +class QWasmWindow; +class QWasmScreen; class QOpenGLContext; class QOpenGLTextureBlitter; -class QHtml5CompositedWindow +class QWasmCompositedWindow { public: - QHtml5CompositedWindow(); + QWasmCompositedWindow(); - QHtml5Window *window; - QHtml5Window *parentWindow; + QWasmWindow *window; + QWasmWindow *parentWindow; QRegion damage; bool flushPending; bool visible; - QList<QHtml5Window *> childWindows; + QList<QWasmWindow *> childWindows; }; -class QHtml5Compositor : public QObject +class QWasmCompositor : public QObject { Q_OBJECT public: - QHtml5Compositor(); - ~QHtml5Compositor(); + QWasmCompositor(); + ~QWasmCompositor(); - enum QHtml5SubControl { + enum QWasmSubControl { SC_None = 0x00000000, SC_TitleBarSysMenu = 0x00000001, SC_TitleBarMinButton = 0x00000002, @@ -75,26 +75,26 @@ public: SC_TitleBarNormalButton = 0x00000010, SC_TitleBarLabel = 0x00000100 }; - Q_DECLARE_FLAGS(SubControls, QHtml5SubControl) + Q_DECLARE_FLAGS(SubControls, QWasmSubControl) - enum QHtml5StateFlag { + enum QWasmStateFlag { State_None = 0x00000000, State_Enabled = 0x00000001, State_Raised = 0x00000002, State_Sunken = 0x00000004 }; - Q_DECLARE_FLAGS(StateFlags, QHtml5StateFlag) + Q_DECLARE_FLAGS(StateFlags, QWasmStateFlag) - struct QHtml5TitleBarOptions { + struct QWasmTitleBarOptions { QRect rect; Qt::WindowFlags flags; int state; QPalette palette; QString titleBarOptionsString; - QHtml5Compositor::SubControls subControls; + QWasmCompositor::SubControls subControls; }; - struct QHtml5FrameOptions { + struct QWasmFrameOptions { QRect rect; int lineWidth; QPalette palette; @@ -102,16 +102,16 @@ public: void setEnabled(bool enabled); - void addWindow(QHtml5Window *window, QHtml5Window *parentWindow = nullptr); - void removeWindow(QHtml5Window *window); - void setScreen(QHtml5Screen *screen); + void addWindow(QWasmWindow *window, QWasmWindow *parentWindow = nullptr); + void removeWindow(QWasmWindow *window); + void setScreen(QWasmScreen *screen); - void setVisible(QHtml5Window *window, bool visible); - void raise(QHtml5Window *window); - void lower(QHtml5Window *window); - void setParent(QHtml5Window *window, QHtml5Window *parent); + void setVisible(QWasmWindow *window, bool visible); + void raise(QWasmWindow *window); + void lower(QWasmWindow *window); + void setParent(QWasmWindow *window, QWasmWindow *parent); - void flush(QHtml5Window *surface, const QRegion ®ion); + void flush(QWasmWindow *surface, const QRegion ®ion); int windowCount() const; @@ -123,8 +123,8 @@ public: bool event(QEvent *event); - static QHtml5TitleBarOptions makeTitleBarOptions(const QHtml5Window *window); - static QRect titlebarRect(QHtml5TitleBarOptions tb, QHtml5Compositor::SubControls subcontrol); + static QWasmTitleBarOptions makeTitleBarOptions(const QWasmWindow *window); + static QRect titlebarRect(QWasmTitleBarOptions tb, QWasmCompositor::SubControls subcontrol); private slots: void frame(); @@ -133,21 +133,21 @@ private: void createFrameBuffer(); void flush2(const QRegion ®ion); void flushCompletedCallback(int32_t); - void notifyTopWindowChanged(QHtml5Window* window); - void drawWindow(QOpenGLTextureBlitter *blitter, QHtml5Screen *screen, QHtml5Window *window); - void drawWindowContent(QOpenGLTextureBlitter *blitter, QHtml5Screen *screen, QHtml5Window *window); - void blit(QOpenGLTextureBlitter *blitter, QHtml5Screen *screen, const QOpenGLTexture *texture, QRect targetGeometry); + void notifyTopWindowChanged(QWasmWindow* window); + void drawWindow(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window); + void drawWindowContent(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window); + void blit(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, const QOpenGLTexture *texture, QRect targetGeometry); - void drawWindowDecorations(QOpenGLTextureBlitter *blitter, QHtml5Screen *screen, QHtml5Window *window); + void drawWindowDecorations(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window); void drwPanelButton(); private: QImage *m_frameBuffer; QScopedPointer<QOpenGLContext> mContext; QScopedPointer<QOpenGLTextureBlitter> mBlitter; - QHtml5Screen *mScreen; + QWasmScreen *mScreen; - QHash<QHtml5Window *, QHtml5CompositedWindow> m_compositedWindows; - QList<QHtml5Window *> m_windowStack; + QHash<QWasmWindow *, QWasmCompositedWindow> m_compositedWindows; + QList<QWasmWindow *> m_windowStack; QRegion globalDamage; // damage caused by expose, window close, etc. bool m_needComposit; bool m_inFlush; @@ -158,13 +158,13 @@ private: static QPalette makeWindowPalette(); - void drawFrameWindow(QHtml5FrameOptions options, QPainter *painter); - void drawTitlebarWindow(QHtml5TitleBarOptions options, QPainter *painter); - void drawShadePanel(QHtml5TitleBarOptions options, QPainter *painter); + void drawFrameWindow(QWasmFrameOptions options, QPainter *painter); + void drawTitlebarWindow(QWasmTitleBarOptions options, QPainter *painter); + void drawShadePanel(QWasmTitleBarOptions options, QPainter *painter); void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const; }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QHtml5Compositor::SubControls) +Q_DECLARE_OPERATORS_FOR_FLAGS(QWasmCompositor::SubControls) QT_END_NAMESPACE diff --git a/src/plugins/platforms/html5/qhtml5cursor.cpp b/src/plugins/platforms/wasm/qwasmcursor.cpp index 20c6633acd..2a4ca2067f 100644 --- a/src/plugins/platforms/html5/qhtml5cursor.cpp +++ b/src/plugins/platforms/wasm/qwasmcursor.cpp @@ -27,13 +27,13 @@ ** ****************************************************************************/ -#include "qhtml5cursor.h" +#include "qwasmcursor.h" #include <QtCore/qdebug.h> #include <emscripten/emscripten.h> -void QHtml5Cursor::changeCursor(QCursor *windowCursor, QWindow *window) +void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window) { if (windowCursor == nullptr) return; @@ -44,7 +44,7 @@ void QHtml5Cursor::changeCursor(QCursor *windowCursor, QWindow *window) // Bitmap and custom cursors are not implemented (will fall back to "auto") if (windowCursor->shape() == Qt::BitmapCursor || windowCursor->shape() >= Qt::CustomCursor) - qWarning() << "QHtml5Cursor: bitmap and custom cursors are not supported"; + qWarning() << "QWasmCursor: bitmap and custom cursors are not supported"; QByteArray htmlCursorName = cursorShapeToHtml(windowCursor->shape()); @@ -59,7 +59,7 @@ void QHtml5Cursor::changeCursor(QCursor *windowCursor, QWindow *window) }, htmlCursorName.constData()); } -QByteArray QHtml5Cursor::cursorShapeToHtml(Qt::CursorShape shape) +QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) { QByteArray cursorName; diff --git a/src/plugins/platforms/html5/qhtml5cursor.h b/src/plugins/platforms/wasm/qwasmcursor.h index fdf8abae0d..ef3ef80126 100644 --- a/src/plugins/platforms/html5/qhtml5cursor.h +++ b/src/plugins/platforms/wasm/qwasmcursor.h @@ -27,12 +27,12 @@ ** ****************************************************************************/ -#ifndef QHTML5CURSOR_H -#define QHTML5CURSOR_H +#ifndef QWASMCURSOR_H +#define QWASMCURSOR_H #include <qpa/qplatformcursor.h> -class QHtml5Cursor : public QPlatformCursor +class QWasmCursor : public QPlatformCursor { public: void changeCursor(QCursor * windowCursor, QWindow * window) override; diff --git a/src/plugins/platforms/html5/qhtml5eventdispatcher.cpp b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp index af698032f2..a1c206e441 100644 --- a/src/plugins/platforms/html5/qhtml5eventdispatcher.cpp +++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp @@ -27,33 +27,33 @@ ** ****************************************************************************/ -#include "qhtml5eventdispatcher.h" +#include "qwasmeventdispatcher.h" #include <QtCore/QDebug> #include <QtCore/QCoreApplication> #include <emscripten.h> -class QHtml5EventDispatcherPrivate : public QUnixEventDispatcherQPAPrivate +class QWasmEventDispatcherPrivate : public QUnixEventDispatcherQPAPrivate { }; -QHtml5EventDispatcher *g_htmlEventDispatcher; +QWasmEventDispatcher *g_htmlEventDispatcher; -QHtml5EventDispatcher::QHtml5EventDispatcher(QObject *parent) +QWasmEventDispatcher::QWasmEventDispatcher(QObject *parent) : QUnixEventDispatcherQPA(parent) { g_htmlEventDispatcher = this; } -QHtml5EventDispatcher::~QHtml5EventDispatcher() +QWasmEventDispatcher::~QWasmEventDispatcher() { g_htmlEventDispatcher = nullptr; } -bool QHtml5EventDispatcher::registerRequestUpdateCallback(std::function<void(void)> callback) +bool QWasmEventDispatcher::registerRequestUpdateCallback(std::function<void(void)> callback) { if (!g_htmlEventDispatcher || !g_htmlEventDispatcher->m_hasMainLoop) return false; @@ -63,7 +63,7 @@ bool QHtml5EventDispatcher::registerRequestUpdateCallback(std::function<void(voi return true; } -void QHtml5EventDispatcher::maintainTimers() +void QWasmEventDispatcher::maintainTimers() { if (!g_htmlEventDispatcher || !g_htmlEventDispatcher->m_hasMainLoop) return; @@ -71,7 +71,7 @@ void QHtml5EventDispatcher::maintainTimers() g_htmlEventDispatcher->doMaintainTimers(); } -bool QHtml5EventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) +bool QWasmEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) { // WaitForMoreEvents is not supported (except for in combination with EventLoopExec below), // and we don't want the unix event dispatcher base class to attempt to wait either. @@ -99,7 +99,7 @@ bool QHtml5EventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) // events. Also set simulateInfiniteLoop to true which makes emscripten // return control to the browser without unwinding the C++ stack. auto callback = [](void *eventDispatcher) { - QHtml5EventDispatcher *that = static_cast<QHtml5EventDispatcher *>(eventDispatcher); + QWasmEventDispatcher *that = static_cast<QWasmEventDispatcher *>(eventDispatcher); // Save and clear updateRequest callbacks so we can register new ones auto requestUpdateCallbacksCopy = that->m_requestUpdateCallbacks; @@ -124,9 +124,9 @@ bool QHtml5EventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) return false; } -void QHtml5EventDispatcher::doMaintainTimers() +void QWasmEventDispatcher::doMaintainTimers() { - Q_D(QHtml5EventDispatcher); + Q_D(QWasmEventDispatcher); // This functon schedules native timers in order to wake up to // process events and activate Qt timers. This is done using the @@ -137,7 +137,7 @@ void QHtml5EventDispatcher::doMaintainTimers() // Schedule a zero-timer to continue processing any pending events. if (!m_hasZeroTimer && hasPendingEvents()) { auto callback = [](void *eventDispatcher) { - QHtml5EventDispatcher *that = static_cast<QHtml5EventDispatcher *>(eventDispatcher); + QWasmEventDispatcher *that = static_cast<QWasmEventDispatcher *>(eventDispatcher); that->m_hasZeroTimer = false; that->QUnixEventDispatcherQPA::processEvents(QEventLoop::AllEvents); @@ -170,7 +170,7 @@ void QHtml5EventDispatcher::doMaintainTimers() // Schedule a native timer with a callback which processes events (and timers) auto callback = [](void *eventDispatcher) { - QHtml5EventDispatcher *that = static_cast<QHtml5EventDispatcher *>(eventDispatcher); + QWasmEventDispatcher *that = static_cast<QWasmEventDispatcher *>(eventDispatcher); that->m_currentTargetTime = std::numeric_limits<uint64_t>::max(); that->QUnixEventDispatcherQPA::processEvents(QEventLoop::AllEvents); diff --git a/src/plugins/platforms/html5/qhtml5eventdispatcher.h b/src/plugins/platforms/wasm/qwasmeventdispatcher.h index 95aacb7d2e..aa562ebad2 100644 --- a/src/plugins/platforms/html5/qhtml5eventdispatcher.h +++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.h @@ -27,8 +27,8 @@ ** ****************************************************************************/ -#ifndef QHTML5EVENTDISPATCHER_H -#define QHTML5EVENTDISPATCHER_H +#ifndef QWASMEVENTDISPATCHER_H +#define QWASMEVENTDISPATCHER_H #include <QtCore/QHash> #include <QtCore/QLoggingCategory> @@ -36,14 +36,14 @@ QT_BEGIN_NAMESPACE -class QHtml5EventDispatcherPrivate; +class QWasmEventDispatcherPrivate; -class QHtml5EventDispatcher : public QUnixEventDispatcherQPA +class QWasmEventDispatcher : public QUnixEventDispatcherQPA { - Q_DECLARE_PRIVATE(QHtml5EventDispatcher) + Q_DECLARE_PRIVATE(QWasmEventDispatcher) public: - explicit QHtml5EventDispatcher(QObject *parent = 0); - ~QHtml5EventDispatcher(); + explicit QWasmEventDispatcher(QObject *parent = 0); + ~QWasmEventDispatcher(); static bool registerRequestUpdateCallback(std::function<void(void)> callback); static void maintainTimers(); diff --git a/src/plugins/platforms/html5/qhtml5eventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index 0bb5768ba6..67669b1482 100644 --- a/src/plugins/platforms/html5/qhtml5eventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -27,10 +27,10 @@ ** ****************************************************************************/ -#include "qhtml5eventtranslator.h" -#include "qhtml5eventdispatcher.h" -#include "qhtml5compositor.h" -#include "qhtml5integration.h" +#include "qwasmeventtranslator.h" +#include "qwasmeventdispatcher.h" +#include "qwasmcompositor.h" +#include "qwasmintegration.h" #include <QDebug> #include <QEvent> @@ -49,11 +49,11 @@ QT_BEGIN_NAMESPACE // the existing switching code in QtGui, but for now do it here. static bool g_usePlatformMacCtrlMetaSwitching = false; -QHtml5EventTranslator::QHtml5EventTranslator(QObject *parent) +QWasmEventTranslator::QWasmEventTranslator(QObject *parent) : QObject(parent) , draggedWindow(nullptr) , pressedButtons(Qt::NoButton) - , resizeMode(QHtml5Window::ResizeNone) + , resizeMode(QWasmWindow::ResizeNone) { emscripten_set_keydown_callback(0,(void *)this,1,&keyboard_cb); emscripten_set_keyup_callback(0,(void *)this,1,&keyboard_cb); @@ -88,7 +88,7 @@ QHtml5EventTranslator::QHtml5EventTranslator(QObject *parent) } template <typename Event> -QFlags<Qt::KeyboardModifier> QHtml5EventTranslator::translatKeyModifier(const Event *event) +QFlags<Qt::KeyboardModifier> QWasmEventTranslator::translatKeyModifier(const Event *event) { QFlags<Qt::KeyboardModifier> keyModifier = Qt::NoModifier; if (event->shiftKey) { @@ -112,7 +112,7 @@ QFlags<Qt::KeyboardModifier> QHtml5EventTranslator::translatKeyModifier(const Ev return keyModifier; } -QFlags<Qt::KeyboardModifier> QHtml5EventTranslator::translateKeyboardEventModifier(const EmscriptenKeyboardEvent *keyEvent) +QFlags<Qt::KeyboardModifier> QWasmEventTranslator::translateKeyboardEventModifier(const EmscriptenKeyboardEvent *keyEvent) { QFlags<Qt::KeyboardModifier> keyModifier = translatKeyModifier(keyEvent); if (keyEvent->location == DOM_KEY_LOCATION_NUMPAD) { @@ -122,12 +122,12 @@ QFlags<Qt::KeyboardModifier> QHtml5EventTranslator::translateKeyboardEventModifi return keyModifier; } -QFlags<Qt::KeyboardModifier> QHtml5EventTranslator::translateMouseEventModifier(const EmscriptenMouseEvent *mouseEvent) +QFlags<Qt::KeyboardModifier> QWasmEventTranslator::translateMouseEventModifier(const EmscriptenMouseEvent *mouseEvent) { return translatKeyModifier(mouseEvent); } -int QHtml5EventTranslator::keyboard_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData) +int QWasmEventTranslator::keyboard_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData) { Q_UNUSED(userData) @@ -153,11 +153,11 @@ int QHtml5EventTranslator::keyboard_cb(int eventType, const EmscriptenKeyboardEv QString keyText = alphanumeric ? QString(keyEvent->key) : QString(); bool accepted = QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>( 0, keyType, qtKey, translateKeyboardEventModifier(keyEvent), keyText); - QHtml5EventDispatcher::maintainTimers(); + QWasmEventDispatcher::maintainTimers(); return accepted ? 1 : 0; } -Qt::Key QHtml5EventTranslator::translateEmscriptKey(const EmscriptenKeyboardEvent *emscriptKey, bool *outAlphanumeric) +Qt::Key QWasmEventTranslator::translateEmscriptKey(const EmscriptenKeyboardEvent *emscriptKey, bool *outAlphanumeric) { Qt::Key qtKey; if (outAlphanumeric) @@ -259,7 +259,7 @@ Qt::Key QHtml5EventTranslator::translateEmscriptKey(const EmscriptenKeyboardEven return qtKey; } -Qt::MouseButton QHtml5EventTranslator::translateMouseButton(unsigned short button) +Qt::MouseButton QWasmEventTranslator::translateMouseButton(unsigned short button) { if (button == 0) return Qt::LeftButton; @@ -271,35 +271,35 @@ Qt::MouseButton QHtml5EventTranslator::translateMouseButton(unsigned short butto return Qt::NoButton; } -int QHtml5EventTranslator::mouse_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) +int QWasmEventTranslator::mouse_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) { - QHtml5EventTranslator *translator = (QHtml5EventTranslator*)userData; + QWasmEventTranslator *translator = (QWasmEventTranslator*)userData; translator->processMouse(eventType,mouseEvent); - QHtml5EventDispatcher::maintainTimers(); + QWasmEventDispatcher::maintainTimers(); return 0; } -void resizeWindow(QWindow *window, QHtml5Window::ResizeMode mode, +void resizeWindow(QWindow *window, QWasmWindow::ResizeMode mode, QRect startRect, QPoint amount) { - if (mode == QHtml5Window::ResizeNone) + if (mode == QWasmWindow::ResizeNone) return; - bool top = mode == QHtml5Window::ResizeTopLeft || - mode == QHtml5Window::ResizeTop || - mode == QHtml5Window::ResizeTopRight; + bool top = mode == QWasmWindow::ResizeTopLeft || + mode == QWasmWindow::ResizeTop || + mode == QWasmWindow::ResizeTopRight; - bool bottom = mode == QHtml5Window::ResizeBottomLeft || - mode == QHtml5Window::ResizeBottom || - mode == QHtml5Window::ResizeBottomRight; + bool bottom = mode == QWasmWindow::ResizeBottomLeft || + mode == QWasmWindow::ResizeBottom || + mode == QWasmWindow::ResizeBottomRight; - bool left = mode == QHtml5Window::ResizeLeft || - mode == QHtml5Window::ResizeTopLeft || - mode == QHtml5Window::ResizeBottomLeft; + bool left = mode == QWasmWindow::ResizeLeft || + mode == QWasmWindow::ResizeTopLeft || + mode == QWasmWindow::ResizeBottomLeft; - bool right = mode == QHtml5Window::ResizeRight || - mode == QHtml5Window::ResizeTopRight || - mode == QHtml5Window::ResizeBottomRight; + bool right = mode == QWasmWindow::ResizeRight || + mode == QWasmWindow::ResizeTopRight || + mode == QWasmWindow::ResizeBottomRight; int x1 = startRect.left(); int y1 = startRect.top(); @@ -335,7 +335,7 @@ void resizeWindow(QWindow *window, QHtml5Window::ResizeMode mode, window->setGeometry(x1, y1, w, h); } -void QHtml5EventTranslator::processMouse(int eventType, const EmscriptenMouseEvent *mouseEvent) +void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEvent *mouseEvent) { auto timestamp = mouseEvent->timestamp; QPoint point(mouseEvent->canvasX, mouseEvent->canvasY); @@ -345,8 +345,8 @@ void QHtml5EventTranslator::processMouse(int eventType, const EmscriptenMouseEve Qt::MouseButton button = translateMouseButton(mouseEvent->button); Qt::KeyboardModifiers modifiers = translateMouseEventModifier(mouseEvent); - QWindow *window2 = QHtml5Integration::get()->compositor()->windowAt(point, 5); - QHtml5Window *htmlWindow = static_cast<QHtml5Window*>(window2->handle()); + QWindow *window2 = QWasmIntegration::get()->compositor()->windowAt(point, 5); + QWasmWindow *htmlWindow = static_cast<QWasmWindow*>(window2->handle()); bool onFrame = false; if (window2 && !window2->geometry().contains(point)) onFrame = true; @@ -381,17 +381,17 @@ void QHtml5EventTranslator::processMouse(int eventType, const EmscriptenMouseEve { pressedButtons.setFlag(translateMouseButton(mouseEvent->button), false); buttonEventType = QEvent::MouseButtonRelease; - QHtml5Window *oldWindow = nullptr; + QWasmWindow *oldWindow = nullptr; if (mouseEvent->button == 0 && pressedWindow) { - oldWindow = static_cast<QHtml5Window*>(pressedWindow->handle()); + oldWindow = static_cast<QWasmWindow*>(pressedWindow->handle()); pressedWindow = nullptr; } if (mouseEvent->button == 0) { draggedWindow = nullptr; - resizeMode = QHtml5Window::ResizeNone; + resizeMode = QWasmWindow::ResizeNone; } if (oldWindow) @@ -401,12 +401,12 @@ void QHtml5EventTranslator::processMouse(int eventType, const EmscriptenMouseEve case 8://move //drag event { buttonEventType = QEvent::MouseMove; - if (resizeMode == QHtml5Window::ResizeNone && draggedWindow) { + if (resizeMode == QWasmWindow::ResizeNone && draggedWindow) { draggedWindow->setX(draggedWindow->x() + mouseEvent->movementX); draggedWindow->setY(draggedWindow->y() + mouseEvent->movementY); } - if (resizeMode != QHtml5Window::ResizeNone) { + if (resizeMode != QWasmWindow::ResizeNone) { QPoint delta = QPoint(mouseEvent->canvasX, mouseEvent->canvasY) - resizePoint; resizeWindow(draggedWindow, resizeMode, resizeStartRect, delta); } @@ -422,12 +422,12 @@ void QHtml5EventTranslator::processMouse(int eventType, const EmscriptenMouseEve } } -int QHtml5EventTranslator::focus_cb(int /*eventType*/, const EmscriptenFocusEvent */*focusEvent*/, void */*userData*/) +int QWasmEventTranslator::focus_cb(int /*eventType*/, const EmscriptenFocusEvent */*focusEvent*/, void */*userData*/) { return 0; } -int QHtml5EventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData) +int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData) { Q_UNUSED(eventType) Q_UNUSED(userData) @@ -451,7 +451,7 @@ int QHtml5EventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *w auto timestamp = mouseEvent.timestamp; QPoint globalPoint(mouseEvent.canvasX, mouseEvent.canvasY); - QWindow *window2 = QHtml5Integration::get()->compositor()->windowAt(globalPoint, 5); + QWindow *window2 = QWasmIntegration::get()->compositor()->windowAt(globalPoint, 5); QPoint localPoint(globalPoint.x() - window2->geometry().x(), globalPoint.y() - window2->geometry().y()); @@ -464,7 +464,7 @@ int QHtml5EventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *w return 1; } -int QHtml5EventTranslator::touchCallback(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData) +int QWasmEventTranslator::touchCallback(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData) { QList<QWindowSystemInterface::TouchPoint> touchPointList; touchPointList.reserve(touchEvent->numTouches); @@ -475,7 +475,7 @@ int QHtml5EventTranslator::touchCallback(int eventType, const EmscriptenTouchEve const EmscriptenTouchPoint *touches = &touchEvent->touches[i]; QPoint point(touches->canvasX, touches->canvasY); - window2 = QHtml5Integration::get()->compositor()->windowAt(point, 5); + window2 = QWasmIntegration::get()->compositor()->windowAt(point, 5); QWindowSystemInterface::TouchPoint touchPoint; @@ -504,19 +504,19 @@ int QHtml5EventTranslator::touchCallback(int eventType, const EmscriptenTouchEve touchPointList.append(touchPoint); } - QHtml5EventTranslator *html5EventTranslator = (QHtml5EventTranslator*)userData; + QWasmEventTranslator *wasmEventTranslator = (QWasmEventTranslator*)userData; QFlags<Qt::KeyboardModifier> keyModifier = translatKeyModifier(touchEvent); if (eventType != EMSCRIPTEN_EVENT_TOUCHCANCEL) - QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(window2, html5EventTranslator->getTimestamp(), html5EventTranslator->touchDevice, touchPointList, keyModifier); + QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(window2, wasmEventTranslator->getTimestamp(), wasmEventTranslator->touchDevice, touchPointList, keyModifier); else - QWindowSystemInterface::handleTouchCancelEvent(window2, html5EventTranslator->getTimestamp(), html5EventTranslator->touchDevice, keyModifier); + QWindowSystemInterface::handleTouchCancelEvent(window2, wasmEventTranslator->getTimestamp(), wasmEventTranslator->touchDevice, keyModifier); QCoreApplication::processEvents(); return 1; } -quint64 QHtml5EventTranslator::getTimestamp() +quint64 QWasmEventTranslator::getTimestamp() { return QDeadlineTimer::current().deadlineNSecs() / 1000; } diff --git a/src/plugins/platforms/html5/qhtml5eventtranslator.h b/src/plugins/platforms/wasm/qwasmeventtranslator.h index 9821b41630..a5e6b24836 100644 --- a/src/plugins/platforms/html5/qhtml5eventtranslator.h +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.h @@ -27,21 +27,21 @@ ** ****************************************************************************/ -#ifndef QHTML5EVENTTRANSLATOR_H -#define QHTML5EVENTTRANSLATOR_H +#ifndef QWASMEVENTTRANSLATOR_H +#define QWASMEVENTTRANSLATOR_H #include <QObject> #include <QRect> #include <QtCore/QPoint> #include <emscripten/html5.h> -#include "qhtml5window.h" +#include "qwasmwindow.h" #include <QTouchDevice> QT_BEGIN_NAMESPACE class QWindow; -class QHtml5EventTranslator : public QObject +class QWasmEventTranslator : public QObject { Q_OBJECT @@ -172,7 +172,7 @@ class QHtml5EventTranslator : public QObject public: - explicit QHtml5EventTranslator(QObject *parent = 0); + explicit QWasmEventTranslator(QObject *parent = 0); static int keyboard_cb(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData); static int mouse_cb(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); @@ -200,7 +200,7 @@ private: QWindow *pressedWindow; Qt::MouseButtons pressedButtons; - QHtml5Window::ResizeMode resizeMode; + QWasmWindow::ResizeMode resizeMode; QPoint resizePoint; QRect resizeStartRect; QTouchDevice* touchDevice; @@ -208,4 +208,4 @@ private: }; QT_END_NAMESPACE -#endif // QHTML5EVENTTRANSLATOR_H +#endif // QWASMEVENTTRANSLATOR_H diff --git a/src/plugins/platforms/html5/qhtml5fontdatabase.cpp b/src/plugins/platforms/wasm/qwasmfontdatabase.cpp index 43d2c9eb53..1b44675066 100644 --- a/src/plugins/platforms/html5/qhtml5fontdatabase.cpp +++ b/src/plugins/platforms/wasm/qwasmfontdatabase.cpp @@ -27,14 +27,14 @@ ** ****************************************************************************/ -#include "qhtml5fontdatabase.h" +#include "qwasmfontdatabase.h" #include <QtCore/QFile> QT_BEGIN_NAMESPACE -void QHtml5FontDatabase::populateFontDatabase() +void QWasmFontDatabase::populateFontDatabase() { - Q_INIT_RESOURCE(html5fonts); + Q_INIT_RESOURCE(wasmfonts); // Load font file from resources. Currently // all fonts needs to be bundled with the nexe @@ -52,12 +52,12 @@ void QHtml5FontDatabase::populateFontDatabase() } } -QFontEngine *QHtml5FontDatabase::fontEngine(const QFontDef &fontDef, void *handle) +QFontEngine *QWasmFontDatabase::fontEngine(const QFontDef &fontDef, void *handle) { return QFreeTypeFontDatabase::fontEngine(fontDef, handle); } -QStringList QHtml5FontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, +QStringList QWasmFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const { @@ -73,13 +73,13 @@ QStringList QHtml5FontDatabase::fallbacksForFamily(const QString &family, QFont: return fallbacks; } -QStringList QHtml5FontDatabase::addApplicationFont(const QByteArray &fontData, +QStringList QWasmFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName) { return QFreeTypeFontDatabase::addApplicationFont(fontData, fileName); } -void QHtml5FontDatabase::releaseHandle(void *handle) +void QWasmFontDatabase::releaseHandle(void *handle) { QFreeTypeFontDatabase::releaseHandle(handle); } diff --git a/src/plugins/platforms/html5/qhtml5fontdatabase.h b/src/plugins/platforms/wasm/qwasmfontdatabase.h index 53ce952663..891f12859e 100644 --- a/src/plugins/platforms/html5/qhtml5fontdatabase.h +++ b/src/plugins/platforms/wasm/qwasmfontdatabase.h @@ -27,14 +27,14 @@ ** ****************************************************************************/ -#ifndef QHTML5FONTDATABASE_H -#define QHTML5FONTDATABASE_H +#ifndef QWASMFONTDATABASE_H +#define QWASMFONTDATABASE_H #include <QtFontDatabaseSupport/private/qfreetypefontdatabase_p.h> QT_BEGIN_NAMESPACE -class QHtml5FontDatabase : public QFreeTypeFontDatabase +class QWasmFontDatabase : public QFreeTypeFontDatabase { public: void populateFontDatabase() override; diff --git a/src/plugins/platforms/html5/qhtml5integration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index f5945744f8..196b2c6575 100644 --- a/src/plugins/platforms/html5/qhtml5integration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -27,18 +27,18 @@ ** ****************************************************************************/ -#include "qhtml5integration.h" -#include "qhtml5eventtranslator.h" -#include "qhtml5eventdispatcher.h" -#include "qhtml5compositor.h" -#include "qhtml5openglcontext.h" -#include "qhtml5theme.h" - -#include "qhtml5window.h" +#include "qwasmintegration.h" +#include "qwasmeventtranslator.h" +#include "qwasmeventdispatcher.h" +#include "qwasmcompositor.h" +#include "qwasmopenglcontext.h" +#include "qwasmtheme.h" + +#include "qwasmwindow.h" #ifndef QT_NO_OPENGL -# include "qhtml5backingstore.h" +# include "qwasmbackingstore.h" #endif -#include "qhtml5fontdatabase.h" +#include "qwasmfontdatabase.h" #if defined(Q_OS_UNIX) #include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h> #endif @@ -50,21 +50,21 @@ #include <emscripten/bind.h> // this is where EGL headers are pulled in, make sure it is last -#include "qhtml5screen.h" +#include "qwasmscreen.h" using namespace emscripten; QT_BEGIN_NAMESPACE void browserBeforeUnload() { - QHtml5Integration::QHtml5BrowserExit(); + QWasmIntegration::QWasmBrowserExit(); } EMSCRIPTEN_BINDINGS(my_module) { function("browserBeforeUnload", &browserBeforeUnload); } -static QHtml5Integration *globalHtml5Integration; -QHtml5Integration *QHtml5Integration::get() { return globalHtml5Integration; } +static QWasmIntegration *globalHtml5Integration; +QWasmIntegration *QWasmIntegration::get() { return globalHtml5Integration; } void emscriptenOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { @@ -93,10 +93,10 @@ void emscriptenOutput(QtMsgType type, const QMessageLogContext &context, const Q } } -QHtml5Integration::QHtml5Integration() +QWasmIntegration::QWasmIntegration() : mFontDb(nullptr), - mCompositor(new QHtml5Compositor), - mScreen(new QHtml5Screen(mCompositor)), + mCompositor(new QWasmCompositor), + mScreen(new QWasmScreen(mCompositor)), m_eventDispatcher(nullptr) { qSetMessagePattern(QString("(%{function}:%{line}) - %{message}")); @@ -108,7 +108,7 @@ QHtml5Integration::QHtml5Integration() screenAdded(mScreen); emscripten_set_resize_callback(0, (void *)this, 1, uiEvent_cb); - m_eventTranslator = new QHtml5EventTranslator(); + m_eventTranslator = new QWasmEventTranslator(); EM_ASM(// exit app if browser closes window.onbeforeunload = function () { @@ -117,7 +117,7 @@ QHtml5Integration::QHtml5Integration() ); } -QHtml5Integration::~QHtml5Integration() +QWasmIntegration::~QWasmIntegration() { delete mCompositor; destroyScreen(mScreen); @@ -125,13 +125,13 @@ QHtml5Integration::~QHtml5Integration() delete m_eventTranslator; } -void QHtml5Integration::QHtml5BrowserExit() +void QWasmIntegration::QWasmBrowserExit() { QCoreApplication *app = QCoreApplication::instance(); app->quit(); } -bool QHtml5Integration::hasCapability(QPlatformIntegration::Capability cap) const +bool QWasmIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { case ThreadedPixmaps: return true; @@ -144,18 +144,18 @@ bool QHtml5Integration::hasCapability(QPlatformIntegration::Capability cap) cons } } -QPlatformWindow *QHtml5Integration::createPlatformWindow(QWindow *window) const +QPlatformWindow *QWasmIntegration::createPlatformWindow(QWindow *window) const { - QHtml5Window *w = new QHtml5Window(window, mCompositor, m_backingStores.value(window)); + QWasmWindow *w = new QWasmWindow(window, mCompositor, m_backingStores.value(window)); w->create(); return w; } -QPlatformBackingStore *QHtml5Integration::createPlatformBackingStore(QWindow *window) const +QPlatformBackingStore *QWasmIntegration::createPlatformBackingStore(QWindow *window) const { #ifndef QT_NO_OPENGL - QHtml5BackingStore *backingStore = new QHtml5BackingStore(mCompositor, window); + QWasmBackingStore *backingStore = new QWasmBackingStore(mCompositor, window); m_backingStores.insert(window, backingStore); return backingStore; #else @@ -164,43 +164,43 @@ QPlatformBackingStore *QHtml5Integration::createPlatformBackingStore(QWindow *wi } #ifndef QT_NO_OPENGL -QPlatformOpenGLContext *QHtml5Integration::createPlatformOpenGLContext(QOpenGLContext *context) const +QPlatformOpenGLContext *QWasmIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { - return new QHtml5OpenGLContext(context->format()); + return new QWasmOpenGLContext(context->format()); } #endif -QPlatformFontDatabase *QHtml5Integration::fontDatabase() const +QPlatformFontDatabase *QWasmIntegration::fontDatabase() const { if (mFontDb == 0) - mFontDb = new QHtml5FontDatabase(); + mFontDb = new QWasmFontDatabase(); return mFontDb; } -QAbstractEventDispatcher *QHtml5Integration::createEventDispatcher() const +QAbstractEventDispatcher *QWasmIntegration::createEventDispatcher() const { - return new QHtml5EventDispatcher(); + return new QWasmEventDispatcher(); } -QVariant QHtml5Integration::styleHint(QPlatformIntegration::StyleHint hint) const +QVariant QWasmIntegration::styleHint(QPlatformIntegration::StyleHint hint) const { return QPlatformIntegration::styleHint(hint); } -QStringList QHtml5Integration::themeNames() const +QStringList QWasmIntegration::themeNames() const { - return QStringList() << QLatin1String("html5"); + return QStringList() << QLatin1String("webassembly"); } -QPlatformTheme *QHtml5Integration::createPlatformTheme(const QString &name) const +QPlatformTheme *QWasmIntegration::createPlatformTheme(const QString &name) const { - if (name == QLatin1String("html5")) - return new QHtml5Theme(); + if (name == QLatin1String("webassembly")) + return new QWasmTheme(); return QPlatformIntegration::createPlatformTheme(name); } -int QHtml5Integration::uiEvent_cb(int eventType, const EmscriptenUiEvent *e, void *userData) +int QWasmIntegration::uiEvent_cb(int eventType, const EmscriptenUiEvent *e, void *userData) { Q_UNUSED(e) Q_UNUSED(userData) @@ -224,7 +224,7 @@ static void set_canvas_size(double width, double height) }, width, height); } -void QHtml5Integration::updateQScreenAndCanvasRenderSize() +void QWasmIntegration::updateQScreenAndCanvasRenderSize() { // The HTML canvas has two sizes: the CSS size and the canvas render size. // The CSS size is determined according to standard CSS rules, while the @@ -238,12 +238,12 @@ void QHtml5Integration::updateQScreenAndCanvasRenderSize() emscripten_get_element_css_size(0, &css_width, &css_height); QSizeF cssSize(css_width, css_height); - QHtml5Screen *screen = QHtml5Integration::get()->mScreen; + QWasmScreen *screen = QWasmIntegration::get()->mScreen; QSizeF canvasSize = cssSize * screen->devicePixelRatio(); set_canvas_size(canvasSize.width(), canvasSize.height()); screen->setGeometry(QRect(QPoint(0, 0), cssSize.toSize())); - QHtml5Integration::get()->mCompositor->redrawWindowContent(); + QWasmIntegration::get()->mCompositor->redrawWindowContent(); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/html5/qhtml5integration.h b/src/plugins/platforms/wasm/qwasmintegration.h index 727f9ee72b..a4b3ca939d 100644 --- a/src/plugins/platforms/html5/qhtml5integration.h +++ b/src/plugins/platforms/wasm/qwasmintegration.h @@ -27,10 +27,10 @@ ** ****************************************************************************/ -#ifndef QHTML5INTEGRATION_H -#define QHTML5INTEGRATION_H +#ifndef QWASMINTEGRATION_H +#define QWASMINTEGRATION_H -#include "qhtml5window.h" +#include "qwasmwindow.h" #include <qpa/qplatformintegration.h> #include <qpa/qplatformscreen.h> @@ -42,20 +42,20 @@ QT_BEGIN_NAMESPACE -class QHtml5EventTranslator; -class QHtml5FontDatabase; -class QHtml5Window; -class QHtml5EventDispatcher; -class QHtml5Screen; -class QHtml5Compositor; -class QHtml5BackingStore; +class QWasmEventTranslator; +class QWasmFontDatabase; +class QWasmWindow; +class QWasmEventDispatcher; +class QWasmScreen; +class QWasmCompositor; +class QWasmBackingStore; -class QHtml5Integration : public QObject, public QPlatformIntegration +class QWasmIntegration : public QObject, public QPlatformIntegration { Q_OBJECT public: - QHtml5Integration(); - ~QHtml5Integration(); + QWasmIntegration(); + ~QWasmIntegration(); bool hasCapability(QPlatformIntegration::Capability cap) const override; QPlatformWindow *createPlatformWindow(QWindow *window) const override; @@ -69,24 +69,24 @@ public: QStringList themeNames() const override; QPlatformTheme *createPlatformTheme(const QString &name) const override; - static QHtml5Integration *get(); - QHtml5Screen *screen() { return mScreen; } - QHtml5Compositor *compositor() { return mCompositor; } - QHtml5EventTranslator *eventTranslator() { return m_eventTranslator; } + static QWasmIntegration *get(); + QWasmScreen *screen() { return mScreen; } + QWasmCompositor *compositor() { return mCompositor; } + QWasmEventTranslator *eventTranslator() { return m_eventTranslator; } - static void QHtml5BrowserExit(); + static void QWasmBrowserExit(); static void updateQScreenAndCanvasRenderSize(); private: - mutable QHtml5FontDatabase *mFontDb; - QHtml5Compositor *mCompositor; - mutable QHtml5Screen *mScreen; - mutable QHtml5EventTranslator *m_eventTranslator; - mutable QHtml5EventDispatcher *m_eventDispatcher; + mutable QWasmFontDatabase *mFontDb; + QWasmCompositor *mCompositor; + mutable QWasmScreen *mScreen; + mutable QWasmEventTranslator *m_eventTranslator; + mutable QWasmEventDispatcher *m_eventDispatcher; static int uiEvent_cb(int eventType, const EmscriptenUiEvent *e, void *userData); - mutable QHash<QWindow *, QHtml5BackingStore *> m_backingStores; + mutable QHash<QWindow *, QWasmBackingStore *> m_backingStores; }; QT_END_NAMESPACE -#endif // QHTML5INTEGRATION_H +#endif // QWASMINTEGRATION_H diff --git a/src/plugins/platforms/html5/qhtml5openglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp index 16fe73f935..73af3d1878 100644 --- a/src/plugins/platforms/html5/qhtml5openglcontext.cpp +++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp @@ -27,25 +27,25 @@ ** ****************************************************************************/ -#include "qhtml5openglcontext.h" +#include "qwasmopenglcontext.h" #include <EGL/egl.h> QT_BEGIN_NAMESPACE -QHtml5OpenGLContext::QHtml5OpenGLContext(const QSurfaceFormat &format) +QWasmOpenGLContext::QWasmOpenGLContext(const QSurfaceFormat &format) : m_requestedFormat(format) { m_requestedFormat.setRenderableType(QSurfaceFormat::OpenGLES); } -QHtml5OpenGLContext::~QHtml5OpenGLContext() +QWasmOpenGLContext::~QWasmOpenGLContext() { if (m_context) emscripten_webgl_destroy_context(m_context); } -void QHtml5OpenGLContext::maybeRecreateEmscriptenContext(QPlatformSurface *surface) +void QWasmOpenGLContext::maybeRecreateEmscriptenContext(QPlatformSurface *surface) { // Native emscripten contexts are tied to a single surface. Recreate // the context if the surface is changed. @@ -67,9 +67,9 @@ void QHtml5OpenGLContext::maybeRecreateEmscriptenContext(QPlatformSurface *surfa Q_UNUSED(reserved); // The application may get contex-lost if e.g. moved to the background. Set // m_contextLost which will make isValid() return false. Application code will - // then detect this and recrate the the context, resulting in a new QHtml5OpenGLContext + // then detect this and recrate the the context, resulting in a new QWasmOpenGLContext // instance. - reinterpret_cast<QHtml5OpenGLContext *>(userData)->m_contextLost = true; + reinterpret_cast<QWasmOpenGLContext *>(userData)->m_contextLost = true; return true; }; bool capture = true; @@ -77,7 +77,7 @@ void QHtml5OpenGLContext::maybeRecreateEmscriptenContext(QPlatformSurface *surfa } } -EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QHtml5OpenGLContext::createEmscriptenContext(const char *canvasId, QSurfaceFormat format) +EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(const char *canvasId, QSurfaceFormat format) { EmscriptenWebGLContextAttributes attributes; emscripten_webgl_init_context_attributes(&attributes); // Populate with default attributes @@ -101,45 +101,45 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QHtml5OpenGLContext::createEmscriptenContext(con return context; } -QSurfaceFormat QHtml5OpenGLContext::format() const +QSurfaceFormat QWasmOpenGLContext::format() const { return m_requestedFormat; } -GLuint QHtml5OpenGLContext::defaultFramebufferObject(QPlatformSurface *surface) const +GLuint QWasmOpenGLContext::defaultFramebufferObject(QPlatformSurface *surface) const { return QPlatformOpenGLContext::defaultFramebufferObject(surface); } -bool QHtml5OpenGLContext::makeCurrent(QPlatformSurface *surface) +bool QWasmOpenGLContext::makeCurrent(QPlatformSurface *surface) { maybeRecreateEmscriptenContext(surface); return emscripten_webgl_make_context_current(m_context) == EMSCRIPTEN_RESULT_SUCCESS; } -void QHtml5OpenGLContext::swapBuffers(QPlatformSurface *surface) +void QWasmOpenGLContext::swapBuffers(QPlatformSurface *surface) { Q_UNUSED(surface); // No swapbuffers on WebGl } -void QHtml5OpenGLContext::doneCurrent() +void QWasmOpenGLContext::doneCurrent() { // No doneCurrent on WebGl } -bool QHtml5OpenGLContext::isSharing() const +bool QWasmOpenGLContext::isSharing() const { return false; } -bool QHtml5OpenGLContext::isValid() const +bool QWasmOpenGLContext::isValid() const { return (m_contextLost == false); } -QFunctionPointer QHtml5OpenGLContext::getProcAddress(const char *procName) +QFunctionPointer QWasmOpenGLContext::getProcAddress(const char *procName) { return reinterpret_cast<QFunctionPointer>(eglGetProcAddress(procName)); } diff --git a/src/plugins/platforms/html5/qhtml5openglcontext.h b/src/plugins/platforms/wasm/qwasmopenglcontext.h index 6503cf3ab9..9123100479 100644 --- a/src/plugins/platforms/html5/qhtml5openglcontext.h +++ b/src/plugins/platforms/wasm/qwasmopenglcontext.h @@ -34,11 +34,11 @@ QT_BEGIN_NAMESPACE -class QHtml5OpenGLContext : public QPlatformOpenGLContext +class QWasmOpenGLContext : public QPlatformOpenGLContext { public: - QHtml5OpenGLContext(const QSurfaceFormat &format); - ~QHtml5OpenGLContext(); + QWasmOpenGLContext(const QSurfaceFormat &format); + ~QWasmOpenGLContext(); QSurfaceFormat format() const override; void swapBuffers(QPlatformSurface *surface) override; diff --git a/src/plugins/platforms/html5/qhtml5screen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index b0f64044a4..8667191033 100644 --- a/src/plugins/platforms/html5/qhtml5screen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -27,9 +27,9 @@ ** ****************************************************************************/ -#include "qhtml5screen.h" -#include "qhtml5window.h" -#include "qhtml5compositor.h" +#include "qwasmscreen.h" +#include "qwasmwindow.h" +#include "qwasmcompositor.h" #include <QtEglSupport/private/qeglconvenience_p.h> #ifndef QT_NO_OPENGL @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE -QHtml5Screen::QHtml5Screen(QHtml5Compositor *compositor) +QWasmScreen::QWasmScreen(QWasmCompositor *compositor) : mCompositor(compositor) , m_depth(32) , m_format(QImage::Format_RGB32) @@ -52,27 +52,27 @@ QHtml5Screen::QHtml5Screen(QHtml5Compositor *compositor) mCompositor->setScreen(this); } -QHtml5Screen::~QHtml5Screen() +QWasmScreen::~QWasmScreen() { } -QRect QHtml5Screen::geometry() const +QRect QWasmScreen::geometry() const { return m_geometry; } -int QHtml5Screen::depth() const +int QWasmScreen::depth() const { return m_depth; } -QImage::Format QHtml5Screen::format() const +QImage::Format QWasmScreen::format() const { return m_format; } -qreal QHtml5Screen::devicePixelRatio() const +qreal QWasmScreen::devicePixelRatio() const { // FIXME: The effective device pixel ratio may be different from the // HTML window dpr if the OpenGL driver/GPU allocates a less than @@ -84,12 +84,12 @@ qreal QHtml5Screen::devicePixelRatio() const return qreal(htmlWindowDpr); } -QPlatformCursor *QHtml5Screen::cursor() const +QPlatformCursor *QWasmScreen::cursor() const { - return const_cast<QHtml5Cursor *>(&m_cursor); + return const_cast<QWasmCursor *>(&m_cursor); } -void QHtml5Screen::resizeMaximizedWindows() +void QWasmScreen::resizeMaximizedWindows() { QList<QWindow*> windows = QGuiApplication::allWindows(); // 'screen()' still has the old geometry info while 'this' has the new geometry info @@ -118,22 +118,22 @@ void QHtml5Screen::resizeMaximizedWindows() } } -QWindow *QHtml5Screen::topWindow() const +QWindow *QWasmScreen::topWindow() const { return mCompositor->keyWindow(); } -QWindow *QHtml5Screen::topLevelAt(const QPoint & p) const +QWindow *QWasmScreen::topLevelAt(const QPoint & p) const { return mCompositor->windowAt(p); } -void QHtml5Screen::invalidateSize() +void QWasmScreen::invalidateSize() { m_geometry = QRect(); } -void QHtml5Screen::setGeometry(const QRect &rect) +void QWasmScreen::setGeometry(const QRect &rect) { m_geometry = rect; QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), geometry(), availableGeometry()); diff --git a/src/plugins/platforms/html5/qhtml5screen.h b/src/plugins/platforms/wasm/qwasmscreen.h index d3b81f234e..1777860c60 100644 --- a/src/plugins/platforms/html5/qhtml5screen.h +++ b/src/plugins/platforms/wasm/qwasmscreen.h @@ -27,10 +27,10 @@ ** ****************************************************************************/ -#ifndef QHTML5SCREEN_H -#define QHTML5SCREEN_H +#ifndef QWASMSCREEN_H +#define QWASMSCREEN_H -#include "qhtml5cursor.h" +#include "qwasmcursor.h" #include <qpa/qplatformscreen.h> @@ -40,18 +40,18 @@ QT_BEGIN_NAMESPACE class QPlatformOpenGLContext; -class QHtml5Window; -class QHtml5BackingStore; -class QHtml5Compositor; +class QWasmWindow; +class QWasmBackingStore; +class QWasmCompositor; class QOpenGLContext; -class QHtml5Screen : public QObject, public QPlatformScreen +class QWasmScreen : public QObject, public QPlatformScreen { Q_OBJECT public: - QHtml5Screen(QHtml5Compositor *compositor); - ~QHtml5Screen(); + QWasmScreen(QWasmCompositor *compositor); + ~QWasmScreen(); QRect geometry() const override; int depth() const override; @@ -73,13 +73,13 @@ private: bool mUpdatePending; private: - QHtml5Compositor *mCompositor; + QWasmCompositor *mCompositor; QRect m_geometry = QRect(0, 0, 100, 100); int m_depth; QImage::Format m_format; - QHtml5Cursor m_cursor; + QWasmCursor m_cursor; }; QT_END_NAMESPACE -#endif // QHTML5SCREEN_H +#endif // QWASMSCREEN_H diff --git a/src/plugins/platforms/html5/qhtml5stylepixmaps_p.h b/src/plugins/platforms/wasm/qwasmstylepixmaps_p.h index 809fb8e5af..2b5860f42f 100644 --- a/src/plugins/platforms/html5/qhtml5stylepixmaps_p.h +++ b/src/plugins/platforms/wasm/qwasmstylepixmaps_p.h @@ -27,8 +27,8 @@ ** ****************************************************************************/ -#ifndef QHTML5STYLEPIXMAPS_P_H -#define QHTML5STYLEPIXMAPS_P_H +#ifndef QWASMSTYLEPIXMAPS_P_H +#define QWASMSTYLEPIXMAPS_P_H // // W A R N I N G @@ -180,4 +180,4 @@ static const char * const qt_normalizeup_xpm[] = { ".........."}; -#endif // QHTML5STYLEPIXMAPS_P_H +#endif // QWASMSTYLEPIXMAPS_P_H diff --git a/src/plugins/platforms/html5/qhtml5theme.cpp b/src/plugins/platforms/wasm/qwasmtheme.cpp index 31edcfb0cd..793c252adc 100644 --- a/src/plugins/platforms/html5/qhtml5theme.cpp +++ b/src/plugins/platforms/wasm/qwasmtheme.cpp @@ -27,22 +27,22 @@ ** ****************************************************************************/ -#include "qhtml5theme.h" +#include "qwasmtheme.h" #include <QtCore/QVariant> QT_BEGIN_NAMESPACE -QHtml5Theme::QHtml5Theme() +QWasmTheme::QWasmTheme() { } -QHtml5Theme::~QHtml5Theme() +QWasmTheme::~QWasmTheme() { } -QVariant QHtml5Theme::themeHint(ThemeHint hint) const +QVariant QWasmTheme::themeHint(ThemeHint hint) const { if (hint == QPlatformTheme::StyleNames) return QVariant(QStringList() << QLatin1String("fusion")); diff --git a/src/plugins/platforms/html5/qhtml5theme.h b/src/plugins/platforms/wasm/qwasmtheme.h index 7f3d58e171..e4cc06e049 100644 --- a/src/plugins/platforms/html5/qhtml5theme.h +++ b/src/plugins/platforms/wasm/qwasmtheme.h @@ -27,30 +27,30 @@ ** ****************************************************************************/ -#ifndef QHTML5THEME_H -#define QHTML5THEME_H +#ifndef QWASMTHEME_H +#define QWASMTHEME_H #include <qpa/qplatformtheme.h> QT_BEGIN_NAMESPACE -class QHtml5EventTranslator; -class QHtml5FontDatabase; -class QHtml5Window; -class QHtml5EventDispatcher; -class QHtml5Screen; -class QHtml5Compositor; -class QHtml5BackingStore; +class QWasmEventTranslator; +class QWasmFontDatabase; +class QWasmWindow; +class QWasmEventDispatcher; +class QWasmScreen; +class QWasmCompositor; +class QWasmBackingStore; -class QHtml5Theme : public QPlatformTheme +class QWasmTheme : public QPlatformTheme { public: - QHtml5Theme(); - ~QHtml5Theme(); + QWasmTheme(); + ~QWasmTheme(); QVariant themeHint(ThemeHint hint) const override; }; QT_END_NAMESPACE -#endif // QHTML5THEME_H +#endif // QWASMTHEME_H diff --git a/src/plugins/platforms/html5/qhtml5window.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp index 7c4546a0e6..9283c20d00 100644 --- a/src/plugins/platforms/html5/qhtml5window.cpp +++ b/src/plugins/platforms/wasm/qwasmwindow.cpp @@ -33,10 +33,10 @@ #include <QtGui/private/qwindow_p.h> #include <QtGui/QOpenGLContext> -#include "qhtml5window.h" -#include "qhtml5screen.h" -#include "qhtml5compositor.h" -#include "qhtml5eventdispatcher.h" +#include "qwasmwindow.h" +#include "qwasmscreen.h" +#include "qwasmcompositor.h" +#include "qwasmeventdispatcher.h" #include <QDebug> @@ -46,7 +46,7 @@ Q_GUI_EXPORT int qt_defaultDpiX(); QT_BEGIN_NAMESPACE -QHtml5Window::QHtml5Window(QWindow *w, QHtml5Compositor* compositor, QHtml5BackingStore *backingStore) +QWasmWindow::QWasmWindow(QWindow *w, QWasmCompositor* compositor, QWasmBackingStore *backingStore) : QPlatformWindow(w), mWindow(w), mCompositor(compositor), @@ -55,7 +55,7 @@ QHtml5Window::QHtml5Window(QWindow *w, QHtml5Compositor* compositor, QHtml5Backi needsCompositor = w->surfaceType() != QSurface::OpenGLSurface; static int serialNo = 0; m_winid = ++serialNo; - qWarning("QHtml5Window %p: %p 0x%x\n", this, w, uint(m_winid)); + qWarning("QWasmWindow %p: %p 0x%x\n", this, w, uint(m_winid)); mCompositor->addWindow(this); @@ -63,12 +63,12 @@ QHtml5Window::QHtml5Window(QWindow *w, QHtml5Compositor* compositor, QHtml5Backi mCompositor->setEnabled(w->surfaceType() != QSurface::OpenGLSurface); } -QHtml5Window::~QHtml5Window() +QWasmWindow::~QWasmWindow() { mCompositor->removeWindow(this); } -void QHtml5Window::create() +void QWasmWindow::create() { QRect rect = windowGeometry(); @@ -92,12 +92,12 @@ void QHtml5Window::create() mNormalGeometry = rect; } -QHtml5Screen *QHtml5Window::platformScreen() const +QWasmScreen *QWasmWindow::platformScreen() const { - return static_cast<QHtml5Screen *>(window()->screen()->handle()); + return static_cast<QWasmScreen *>(window()->screen()->handle()); } -void QHtml5Window::setGeometry(const QRect &rect) +void QWasmWindow::setGeometry(const QRect &rect) { QRect r = rect; if (needsCompositor) { @@ -113,13 +113,13 @@ void QHtml5Window::setGeometry(const QRect &rect) invalidate(); } -void QHtml5Window::setVisible(bool visible) +void QWasmWindow::setVisible(bool visible) { QRect newGeom; if (visible) { bool convOk = false; - static bool envDisableForceFullScreen = qEnvironmentVariableIntValue("QT_QPA_HTML5_FORCE_FULLSCREEN", &convOk) == 0 && convOk; + static bool envDisableForceFullScreen = qEnvironmentVariableIntValue("QT_QPA_WEBASSEMBLY_FORCE_FULLSCREEN", &convOk) == 0 && convOk; const bool forceFullScreen = /*!envDisableForceFullScreen && */!needsCompositor;//make gl apps fullscreen for now @@ -140,7 +140,7 @@ void QHtml5Window::setVisible(bool visible) invalidate(); } -QMargins QHtml5Window::frameMargins() const +QMargins QWasmWindow::frameMargins() const { int border = hasTitle ? 4. * (qreal(qt_defaultDpiX()) / 96.0) : 0; int titleBarHeight = hasTitle ? titleHeight() : 0; @@ -154,31 +154,31 @@ QMargins QHtml5Window::frameMargins() const return margins; } -void QHtml5Window::raise() +void QWasmWindow::raise() { mCompositor->raise(this); QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), geometry().size())); invalidate(); } -void QHtml5Window::lower() +void QWasmWindow::lower() { mCompositor->lower(this); QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), geometry().size())); invalidate(); } -WId QHtml5Window::winId() const +WId QWasmWindow::winId() const { return m_winid; } -void QHtml5Window::propagateSizeHints() +void QWasmWindow::propagateSizeHints() { // get rid of base class warning } -void QHtml5Window::injectMousePressed(const QPoint &local, const QPoint &global, +void QWasmWindow::injectMousePressed(const QPoint &local, const QPoint &global, Qt::MouseButton button, Qt::KeyboardModifiers mods) { Q_UNUSED(local); @@ -188,18 +188,18 @@ void QHtml5Window::injectMousePressed(const QPoint &local, const QPoint &global, return; if (maxButtonRect().contains(global)) - mActiveControl = QHtml5Compositor::SC_TitleBarMaxButton; + mActiveControl = QWasmCompositor::SC_TitleBarMaxButton; else if (minButtonRect().contains(global)) - mActiveControl = QHtml5Compositor::SC_TitleBarMinButton; + mActiveControl = QWasmCompositor::SC_TitleBarMinButton; else if (closeButtonRect().contains(global)) - mActiveControl = QHtml5Compositor::SC_TitleBarCloseButton; + mActiveControl = QWasmCompositor::SC_TitleBarCloseButton; else if (normButtonRect().contains(global)) - mActiveControl = QHtml5Compositor::SC_TitleBarNormalButton; + mActiveControl = QWasmCompositor::SC_TitleBarNormalButton; invalidate(); } -void QHtml5Window::injectMouseReleased(const QPoint &local, const QPoint &global, +void QWasmWindow::injectMouseReleased(const QPoint &local, const QPoint &global, Qt::MouseButton button, Qt::KeyboardModifiers mods) { Q_UNUSED(local); @@ -208,35 +208,35 @@ void QHtml5Window::injectMouseReleased(const QPoint &local, const QPoint &global if (!hasTitle || button != Qt::LeftButton) return; - if (closeButtonRect().contains(global) && mActiveControl == QHtml5Compositor::SC_TitleBarCloseButton) + if (closeButtonRect().contains(global) && mActiveControl == QWasmCompositor::SC_TitleBarCloseButton) window()->close(); - if (maxButtonRect().contains(global) && mActiveControl == QHtml5Compositor::SC_TitleBarMaxButton) { + if (maxButtonRect().contains(global) && mActiveControl == QWasmCompositor::SC_TitleBarMaxButton) { window()->setWindowState(Qt::WindowMaximized); platformScreen()->resizeMaximizedWindows(); } - if (normButtonRect().contains(global) && mActiveControl == QHtml5Compositor::SC_TitleBarNormalButton) { + if (normButtonRect().contains(global) && mActiveControl == QWasmCompositor::SC_TitleBarNormalButton) { window()->setWindowState(Qt::WindowNoState); setGeometry(normalGeometry()); } - mActiveControl = QHtml5Compositor::SC_None; + mActiveControl = QWasmCompositor::SC_None; invalidate(); } -int QHtml5Window::titleHeight() const +int QWasmWindow::titleHeight() const { return 18. * (qreal(qt_defaultDpiX()) / 96.0);//dpiScaled(18.); } -int QHtml5Window::borderWidth() const +int QWasmWindow::borderWidth() const { return 4. * (qreal(qt_defaultDpiX()) / 96.0);// dpiScaled(4.); } -QRegion QHtml5Window::titleGeometry() const +QRegion QWasmWindow::titleGeometry() const { int border = borderWidth(); @@ -250,7 +250,7 @@ QRegion QHtml5Window::titleGeometry() const return result; } -QRegion QHtml5Window::resizeRegion() const +QRegion QWasmWindow::resizeRegion() const { int border = borderWidth(); QRegion result(window()->frameGeometry().adjusted(-border, -border, border, border)); @@ -259,18 +259,18 @@ QRegion QHtml5Window::resizeRegion() const return result; } -bool QHtml5Window::isPointOnTitle(QPoint point) const +bool QWasmWindow::isPointOnTitle(QPoint point) const { bool ok = titleGeometry().contains(point); return ok; } -bool QHtml5Window::isPointOnResizeRegion(QPoint point) const +bool QWasmWindow::isPointOnResizeRegion(QPoint point) const { return resizeRegion().contains(point); } -QHtml5Window::ResizeMode QHtml5Window::resizeModeAtPoint(QPoint point) const +QWasmWindow::ResizeMode QWasmWindow::resizeModeAtPoint(QPoint point) const { QPoint p1 = window()->frameGeometry().topLeft() - QPoint(5, 5); QPoint p2 = window()->frameGeometry().bottomRight() + QPoint(5, 5); @@ -311,42 +311,42 @@ QHtml5Window::ResizeMode QHtml5Window::resizeModeAtPoint(QPoint point) const return ResizeNone; } -QRect getSubControlRect(const QHtml5Window *window, QHtml5Compositor::SubControls subControl) +QRect getSubControlRect(const QWasmWindow *window, QWasmCompositor::SubControls subControl) { - QHtml5Compositor::QHtml5TitleBarOptions options = QHtml5Compositor::makeTitleBarOptions(window); + QWasmCompositor::QWasmTitleBarOptions options = QWasmCompositor::makeTitleBarOptions(window); - QRect r = QHtml5Compositor::titlebarRect(options, subControl); + QRect r = QWasmCompositor::titlebarRect(options, subControl); r.translate(window->window()->frameGeometry().x(), window->window()->frameGeometry().y()); return r; } -QRect QHtml5Window::maxButtonRect() const +QRect QWasmWindow::maxButtonRect() const { - return getSubControlRect(this, QHtml5Compositor::SC_TitleBarMaxButton); + return getSubControlRect(this, QWasmCompositor::SC_TitleBarMaxButton); } -QRect QHtml5Window::minButtonRect() const +QRect QWasmWindow::minButtonRect() const { - return getSubControlRect(this, QHtml5Compositor::SC_TitleBarMinButton); + return getSubControlRect(this, QWasmCompositor::SC_TitleBarMinButton); } -QRect QHtml5Window::closeButtonRect() const +QRect QWasmWindow::closeButtonRect() const { - return getSubControlRect(this, QHtml5Compositor::SC_TitleBarCloseButton); + return getSubControlRect(this, QWasmCompositor::SC_TitleBarCloseButton); } -QRect QHtml5Window::normButtonRect() const +QRect QWasmWindow::normButtonRect() const { - return getSubControlRect(this, QHtml5Compositor::SC_TitleBarNormalButton); + return getSubControlRect(this, QWasmCompositor::SC_TitleBarNormalButton); } -QRect QHtml5Window::sysMenuRect() const +QRect QWasmWindow::sysMenuRect() const { - return getSubControlRect(this, QHtml5Compositor::SC_TitleBarSysMenu); + return getSubControlRect(this, QWasmCompositor::SC_TitleBarSysMenu); } -QRegion QHtml5Window::titleControlRegion() const +QRegion QWasmWindow::titleControlRegion() const { QRegion result; result += closeButtonRect(); @@ -357,17 +357,17 @@ QRegion QHtml5Window::titleControlRegion() const return result; } -void QHtml5Window::invalidate() +void QWasmWindow::invalidate() { mCompositor->requestRedraw(); } -QHtml5Compositor::SubControls QHtml5Window::activeSubControl() const +QWasmCompositor::SubControls QWasmWindow::activeSubControl() const { return mActiveControl; } -void QHtml5Window::setWindowState(Qt::WindowStates states) +void QWasmWindow::setWindowState(Qt::WindowStates states) { mWindowState = Qt::WindowNoState; if (states & Qt::WindowMinimized) @@ -378,20 +378,20 @@ void QHtml5Window::setWindowState(Qt::WindowStates states) mWindowState = Qt::WindowMaximized; } -QRect QHtml5Window::normalGeometry() const +QRect QWasmWindow::normalGeometry() const { return mNormalGeometry; } -qreal QHtml5Window::devicePixelRatio() const +qreal QWasmWindow::devicePixelRatio() const { return screen()->devicePixelRatio(); } -void QHtml5Window::requestUpdate() +void QWasmWindow::requestUpdate() { QPointer<QWindow> windowPointer(window()); - bool registered = QHtml5EventDispatcher::registerRequestUpdateCallback([=](){ + bool registered = QWasmEventDispatcher::registerRequestUpdateCallback([=](){ if (windowPointer.isNull()) return; diff --git a/src/plugins/platforms/html5/qhtml5window.h b/src/plugins/platforms/wasm/qwasmwindow.h index 709cb6c910..80664ad4fc 100644 --- a/src/plugins/platforms/html5/qhtml5window.h +++ b/src/plugins/platforms/wasm/qwasmwindow.h @@ -27,21 +27,21 @@ ** ****************************************************************************/ -#ifndef QHTML5WINDOW_H -#define QHTML5WINDOW_H +#ifndef QWASMWINDOW_H +#define QWASMWINDOW_H -#include "qhtml5integration.h" +#include "qwasmintegration.h" #include <qpa/qplatformwindow.h> #include <emscripten/html5.h> -#include "qhtml5backingstore.h" -#include "qhtml5screen.h" -#include "qhtml5compositor.h" +#include "qwasmbackingstore.h" +#include "qwasmscreen.h" +#include "qwasmcompositor.h" QT_BEGIN_NAMESPACE -class QHtml5Compositor; +class QWasmCompositor; -class QHtml5Window : public QPlatformWindow +class QWasmWindow : public QPlatformWindow { public: enum ResizeMode { @@ -56,8 +56,8 @@ public: ResizeLeft }; - QHtml5Window(QWindow *w, QHtml5Compositor *compositor, QHtml5BackingStore *backingStore); - ~QHtml5Window(); + QWasmWindow(QWindow *w, QWasmCompositor *compositor, QWasmBackingStore *backingStore); + ~QWasmWindow(); void create(); @@ -74,9 +74,9 @@ public: qreal devicePixelRatio() const override; void requestUpdate() override; - QHtml5Screen *platformScreen() const; - void setBackingStore(QHtml5BackingStore *store) { mBackingStore = store; } - QHtml5BackingStore *backingStore() const { return mBackingStore; } + QWasmScreen *platformScreen() const; + void setBackingStore(QWasmBackingStore *store) { mBackingStore = store; } + QWasmBackingStore *backingStore() const { return mBackingStore; } QWindow *window() const { return mWindow; } void injectMousePressed(const QPoint &local, const QPoint &global, @@ -97,7 +97,7 @@ public: QRect sysMenuRect() const; QRect normButtonRect() const; QRegion titleControlRegion() const; - QHtml5Compositor::SubControls activeSubControl() const; + QWasmCompositor::SubControls activeSubControl() const; void setWindowState(Qt::WindowStates state) override; bool setKeyboardGrabEnabled(bool) override { return false; } @@ -107,19 +107,19 @@ protected: void invalidate(); protected: - friend class QHtml5Screen; + friend class QWasmScreen; QWindow* mWindow = nullptr; - QHtml5Compositor *mCompositor = nullptr; - QHtml5BackingStore *mBackingStore = nullptr; + QWasmCompositor *mCompositor = nullptr; + QWasmBackingStore *mBackingStore = nullptr; QRect mNormalGeometry {0, 0, 0 ,0}; QRect mOldGeometry; Qt::WindowFlags mWindowFlags = Qt::Window; Qt::WindowState mWindowState = Qt::WindowNoState; - QHtml5Compositor::SubControls mActiveControl = QHtml5Compositor::SC_None; + QWasmCompositor::SubControls mActiveControl = QWasmCompositor::SC_None; WId m_winid = 0; bool hasTitle = false; bool needsCompositor = false; }; QT_END_NAMESPACE -#endif // QHTML5WINDOW_H +#endif // QWASMWINDOW_H diff --git a/src/plugins/platforms/wasm/wasm.json b/src/plugins/platforms/wasm/wasm.json new file mode 100644 index 0000000000..b84ff9edae --- /dev/null +++ b/src/plugins/platforms/wasm/wasm.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "webassembly" ] +} diff --git a/src/plugins/platforms/wasm/wasm.pro b/src/plugins/platforms/wasm/wasm.pro new file mode 100644 index 0000000000..e16e810ee6 --- /dev/null +++ b/src/plugins/platforms/wasm/wasm.pro @@ -0,0 +1,59 @@ +TARGET = wasm +CONFIG += static plugin +QT += \ + core-private gui-private \ + eventdispatcher_support-private fontdatabase_support-private egl_support-private + +#DEFINES += QEGL_EXTRA_DEBUG + +# Avoid X11 header collision, use generic EGL native types +DEFINES += QT_EGL_NO_X11 + +SOURCES = main.cpp \ + qwasmintegration.cpp \ + qwasmwindow.cpp \ + qwasmscreen.cpp \ + qwasmfontdatabase.cpp \ + qwasmeventtranslator.cpp \ + qwasmeventdispatcher.cpp \ + qwasmcompositor.cpp \ + qwasmcursor.cpp \ + qwasmopenglcontext.cpp \ + qwasmtheme.cpp + +HEADERS = qwasmintegration.h \ + qwasmwindow.h \ + qwasmscreen.h \ + qwasmfontdatabase.h \ + qwasmeventtranslator.h \ + qwasmeventdispatcher.h \ + qwasmcompositor.h \ + qwasmstylepixmaps_p.h \ + qwasmcursor.h \ + qwasmopenglcontext.h \ + qwasmtheme.h + +RESOURCES += fonts/wasmfonts.qrc + +qtConfig(opengl) { + SOURCES += qwasmbackingstore.cpp + HEADERS += qwasmbackingstore.h +} +CONFIG += egl + +OTHER_FILES += \ + wasm.json \ + wasm_shell.html \ + qtloader.js + +shell_files.path = $$[QT_INSTALL_PLUGINS]/platforms +shell_files.files = wasm_shell.html \ + qtloader.js \ + qtlogo.svg + +INSTALLS += shell_files + +PLUGIN_TYPE = platforms +PLUGIN_CLASS_NAME = QWasmIntegrationPlugin +!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - +load(qt_plugin) diff --git a/src/plugins/platforms/html5/html5_shell.html b/src/plugins/platforms/wasm/wasm_shell.html index 67bfcdfbdc..67bfcdfbdc 100644 --- a/src/plugins/platforms/html5/html5_shell.html +++ b/src/plugins/platforms/wasm/wasm_shell.html diff --git a/src/src.pro b/src/src.pro index 3390471a32..ca3f82e2e7 100644 --- a/src/src.pro +++ b/src/src.pro @@ -70,7 +70,7 @@ src_xml.subdir = $$PWD/xml src_xml.target = sub-xml src_xml.depends = src_corelib -!emscripten: { +!wasm: { src_dbus.subdir = $$PWD/dbus src_dbus.target = sub-dbus src_dbus.depends = src_corelib @@ -185,7 +185,7 @@ qtConfig(thread):qtConfig(dbus) { src_platformsupport.depends += src_dbus src_tools_qdbusxml2cpp src_plugins.depends += src_dbus src_tools_qdbusxml2cpp src_tools_qdbuscpp2xml } -!emscripten: qtConfig(concurrent): SUBDIRS += src_concurrent +!wasm: qtConfig(concurrent): SUBDIRS += src_concurrent qtConfig(gui) { qtConfig(harfbuzz):!qtConfig(system-harfbuzz) { SUBDIRS += src_3rdparty_harfbuzzng diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index e59666ea43..4c7dc73cfb 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1108,7 +1108,7 @@ Q_AUTOTEST_EXPORT QString qt_tildeExpansion(const QString &path) const QString homePath = QDir::homePath(); #else const QByteArray userName = path.midRef(1, separatorPosition - 1).toLocal8Bit(); -# if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_HTML5) +# if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_WASM) passwd pw; passwd *tmpPw; char buf[200]; diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index c1bf3cd4af..6f4224e734 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -906,7 +906,7 @@ void QOpenGLWidgetPrivate::invalidateFbo() const int gl_color_attachment0 = 0x8CE0; // GL_COLOR_ATTACHMENT0 const int gl_depth_attachment = 0x8D00; // GL_DEPTH_ATTACHMENT const int gl_stencil_attachment = 0x8D20; // GL_STENCIL_ATTACHMENT -#ifdef Q_OS_HTML5 +#ifdef Q_OS_WASM const int gl_depth_stencil_attachment = 0x821A; // GL_DEPTH_STENCIL_ATTACHMENT const GLenum attachments[] = { |