Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qwasmsuspendresumecontrol_p.h
Go to the documentation of this file.
1
// Copyright (C) 2025 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
QWASMSUSPENDRESUMECONTROL_P_H
6
#
define
QWASMSUSPENDRESUMECONTROL_P_H
7
8
#
include
<
QtCore
/
qglobal
.
h
>
9
#
include
<
emscripten
/
val
.
h
>
10
#
include
<
map
>
11
#
include
<
functional
>
12
#
include
<
chrono
>
13
14
//
15
// W A R N I N G
16
// -------------
17
//
18
// This file is not part of the Qt API. It exists purely as an
19
// implementation detail. This header file may change from version to
20
// version without notice, or even be removed.
21
//
22
// We mean it.
23
//
24
25
class
Q_CORE_EXPORT
QWasmSuspendResumeControl
26
{
27
public
:
28
QWasmSuspendResumeControl();
29
~QWasmSuspendResumeControl();
30
31
QWasmSuspendResumeControl(
const
QWasmSuspendResumeControl&) =
delete
;
32
QWasmSuspendResumeControl& operator=(
const
QWasmSuspendResumeControl&) =
delete
;
33
34
static
QWasmSuspendResumeControl *get();
35
36
uint32_t registerEventHandler(std::function<
void
(emscripten::val)> handler);
37
void
removeEventHandler(uint32_t index);
38
emscripten::val jsEventHandlerAt(uint32_t index);
39
static
emscripten::val suspendResumeControlJs();
40
41
void
suspend();
42
// Accept events for all handlers, start to process events on last handler in list
43
void
suspendExclusive(QList<uint32_t> eventHandlerIndices);
44
int
sendPendingEvents();
45
46
emscripten::val currentEvent()
const
47
{
48
return
m_currentEvent;
49
}
50
void
setCurrentEvent(emscripten::val currentEvent)
51
{
52
m_currentEvent = currentEvent;
53
}
54
55
private
:
56
friend
void
qtSendPendingEvents();
57
58
std::map<
int
, std::function<
void
(emscripten::val)>> m_eventHandlers;
59
std::function<
bool
(
int
)> m_eventFilter = [](
int
) {
return
true
; };
60
emscripten::val m_currentEvent = emscripten::val::undefined();
61
};
62
63
class
Q_CORE_EXPORT
QWasmEventHandler
64
{
65
public
:
66
QWasmEventHandler() =
default
;
67
QWasmEventHandler(emscripten::val element,
const
std::string &name,
68
std::function<
void
(emscripten::val)> fn);
69
~QWasmEventHandler();
70
QWasmEventHandler(QWasmEventHandler
const
&) =
delete
;
71
QWasmEventHandler& operator=(QWasmEventHandler
const
&) =
delete
;
72
QWasmEventHandler(QWasmEventHandler&& other)
noexcept
;
73
QWasmEventHandler& operator=(QWasmEventHandler&& other)
noexcept
;
74
private
:
75
emscripten::val m_element;
76
emscripten::val m_name;
77
uint32_t m_eventHandlerIndex = 0;
78
};
79
80
class
QWasmTimer
81
{
82
public
:
83
QWasmTimer
(QWasmSuspendResumeControl* suspendResume,
std
::function<
void
()> handler);
84
~
QWasmTimer
();
85
QWasmTimer
(
QWasmTimer
const
&) =
delete
;
86
QWasmTimer
&
operator
=(
QWasmTimer
const
&) =
delete
;
87
void
setTimeout
(
std
::chrono::milliseconds timeout);
88
bool
hasTimeout
();
89
void
clearTimeout
();
90
91
private
:
92
QWasmSuspendResumeControl *m_suspendResume;
93
uint32_t m_handlerIndex;
94
uint64_t m_timerId = 0;
95
};
96
97
class
Q_CORE_EXPORT
QWasmAnimationFrameMultiHandler
98
{
99
public
:
100
using
Callback = std::function<
void
(
double
)>;
101
102
static
QWasmAnimationFrameMultiHandler *instance();
103
104
uint32_t registerAnimateCallback(Callback callback);
105
uint32_t registerDrawCallback(Callback callback);
106
107
void
unregisterAnimateCallback(uint32_t handle);
108
void
unregisterDrawCallback(uint32_t handle);
109
110
QWasmAnimationFrameMultiHandler();
111
~QWasmAnimationFrameMultiHandler();
112
QWasmAnimationFrameMultiHandler(
const
QWasmAnimationFrameMultiHandler&) =
delete
;
113
QWasmAnimationFrameMultiHandler& operator=(
const
QWasmAnimationFrameMultiHandler&) =
delete
;
114
115
private
:
116
void
handleAnimationFrame(
double
timestamp);
117
void
ensureAnimationFrameRequested();
118
void
cancelAnimationFrameRequest();
119
120
static
QWasmAnimationFrameMultiHandler *s_instance;
121
122
std::map<uint32_t, Callback> m_animateCallbacks;
123
std::map<uint32_t, Callback> m_drawCallbacks;
124
uint32_t m_nextAnimateHandle = 0;
125
uint32_t m_nextDrawHandle = 0;
126
uint32_t m_handlerIndex = 0;
127
int64_t m_requestId = -1;
128
};
129
130
#
endif
QWasmAnimationFrameMultiHandler
Definition
qwasmsuspendresumecontrol_p.h:98
QWasmEventHandler
Definition
qwasmsuspendresumecontrol_p.h:64
QWasmSuspendResumeControl
Definition
qwasmsuspendresumecontrol_p.h:26
QWasmTimer
Definition
qwasmsuspendresumecontrol_p.h:81
QWasmTimer::hasTimeout
bool hasTimeout()
Definition
qwasmsuspendresumecontrol.cpp:345
QWasmTimer::setTimeout
void setTimeout(std::chrono::milliseconds timeout)
Definition
qwasmsuspendresumecontrol.cpp:333
QWasmTimer::clearTimeout
void clearTimeout()
Definition
qwasmsuspendresumecontrol.cpp:350
QWasmTimer::QWasmTimer
QWasmTimer(QWasmSuspendResumeControl *suspendResume, std::function< void()> handler)
Definition
qwasmsuspendresumecontrol.cpp:312
QWasmTimer::~QWasmTimer
~QWasmTimer()
Definition
qwasmsuspendresumecontrol.cpp:326
QWasmTimer::QWasmTimer
QWasmTimer(QWasmTimer const &)=delete
QWasmTimer::operator=
QWasmTimer & operator=(QWasmTimer const &)=delete
qstdweb::ArrayBuffer
Definition
qstdweb_p.h:65
qstdweb::BlobIODevice
Definition
qstdweb_p.h:373
qstdweb::Blob
Definition
qstdweb_p.h:78
qstdweb::EventCallback
Definition
qstdweb_p.h:225
qstdweb::FileList
Definition
qstdweb_p.h:142
qstdweb::FileReader
Definition
qstdweb_p.h:156
qstdweb::FileSystemFileHandle
Definition
qstdweb_p.h:209
qstdweb::FileSystemFileIODevice
Definition
qstdweb_p.h:426
qstdweb::FileSystemWritableFileStreamIODevice
Definition
qstdweb_p.h:407
qstdweb::FileSystemWritableFileStream
Definition
qstdweb_p.h:199
qstdweb::FileUrlRegistration
Definition
qstdweb_p.h:124
qstdweb::File
Definition
qstdweb_p.h:95
qstdweb::Promise
Definition
qstdweb_p.h:243
qstdweb::Uint8ArrayIODevice
Definition
qstdweb_p.h:390
qstdweb::Uint8ArrayIODevice::size
qint64 size() const override
For open random-access devices, this function returns the size of the device.
Definition
qstdweb.cpp:733
qstdweb::Uint8ArrayIODevice::seek
bool seek(qint64 pos) override
For random-access devices, this function sets the current position to pos, returning true on success,...
Definition
qstdweb.cpp:738
qstdweb::Uint8ArrayIODevice::Uint8ArrayIODevice
Uint8ArrayIODevice(Uint8Array array)
Definition
qstdweb.cpp:717
qstdweb::Uint8ArrayIODevice::isSequential
bool isSequential() const override
Returns true if this device is sequential; otherwise returns false.
Definition
qstdweb.cpp:728
qstdweb::Uint8ArrayIODevice::writeData
qint64 writeData(const char *data, qint64 size) override
Writes up to maxSize bytes from data to the device.
Definition
qstdweb.cpp:755
qstdweb::Uint8ArrayIODevice::open
bool open(QIODevice::OpenMode mode) override
Definition
qstdweb.cpp:723
qstdweb::Uint8ArrayIODevice::readData
qint64 readData(char *data, qint64 maxSize) override
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
Definition
qstdweb.cpp:745
qstdweb::Uint8Array
Definition
qstdweb_p.h:173
qstdweb
Definition
qstdweb.cpp:29
qstdweb::canBlockCallingThread
bool canBlockCallingThread()
Definition
qstdweb.cpp:665
qstdweb::window
emscripten::val window()
Definition
qstdweb_p.h:446
qstdweb::uint53_t
double uint53_t
Definition
qstdweb.cpp:46
qstdweb::haveAsyncify
bool haveAsyncify()
Definition
qstdweb.cpp:659
qstdweb::haveJspi
bool haveJspi()
Definition
qstdweb.cpp:653
qstdweb::makeContextfulPromiseFunctionName
const char makeContextfulPromiseFunctionName[]
qstdweb::usePotentialyUnusedSymbols
static void usePotentialyUnusedSymbols()
Definition
qstdweb.cpp:31
qstdweb::bindForever
decltype(auto) bindForever(F wrappedCallback)
Definition
qstdweb_p.h:367
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qstdweb::PromiseCallbacks
Definition
qstdweb_p.h:235
qstdweb::PromiseCallbacks::thenFunc
std::function< void(emscripten::val)> thenFunc
Definition
qstdweb_p.h:236
qstdweb::PromiseCallbacks::finallyFunc
std::function< void()> finallyFunc
Definition
qstdweb_p.h:238
qstdweb::PromiseCallbacks::catchFunc
std::function< void(emscripten::val)> catchFunc
Definition
qstdweb_p.h:237
qtbase
src
corelib
platform
wasm
qwasmsuspendresumecontrol_p.h
Generated on
for Qt by
1.18.0