8#include <private/qeventdispatcher_wasm_p.h>
9#include <private/qwasmsuspendresumecontrol_p.h>
11#include <qpa/qwindowsysteminterface.h>
13#include <emscripten/html5.h>
15using namespace emscripten;
22 QWindowSystemInterface::setSynchronousWindowSystemEvents(
true);
27 if (m_drawCallbackHandle != 0)
28 QWasmAnimationFrameMultiHandler::instance()->unregisterDrawCallback(m_drawCallbackHandle);
38 auto allWindows =
screen()->allWindows();
39 setEnabled(std::any_of(allWindows.begin(), allWindows.end(), [](QWasmWindow *element) {
40 return !element->context2d().isUndefined();
42 if (changeType == QWasmWindowTreeNodeChangeType::NodeRemoval)
43 m_requestUpdateWindows.remove(window);
48 m_isEnabled = enabled;
56 const bool wasEnabled = m_requestUpdateHoldEnabled;
57 m_requestUpdateHoldEnabled =
false;
63 auto it = m_requestUpdateWindows.find(window);
64 if (it == m_requestUpdateWindows.end()) {
65 m_requestUpdateWindows.insert(window, std::make_tuple(updateRect, updateType));
69 if (
std::get<0>(it.value()) != updateRect) {
71 region |=
std::get<0>(it.value());
73 std::get<0>(it.value()) = region.boundingRect();
86 if (m_drawCallbackHandle != 0)
89 if (m_requestUpdateHoldEnabled)
92 m_drawCallbackHandle = QWasmAnimationFrameMultiHandler::instance()->registerDrawCallback(
93 [
this](
double frametime) {
95 m_drawCallbackHandle = 0;
96 deliverUpdateRequests();
105 auto requestUpdateWindows = m_requestUpdateWindows;
106 m_requestUpdateWindows.clear();
111 m_inDeliverUpdateRequest =
true;
112 for (
auto it = requestUpdateWindows.constBegin(); it != requestUpdateWindows.constEnd(); ++it) {
113 auto *window = it.key();
115 const QRect updateRect = std::get<0>(it.value());
117 deliverUpdateRequest(window, updateRect, updateType);
120 m_inDeliverUpdateRequest =
false;
121 frame(requestUpdateWindows.keys());
126 const QRect &updateRect,
129 QWindow *qwindow = window->window();
133 QWindowSystemInterface::handleWindowDevicePixelRatioChanged(qwindow);
140 if (qwindow->isExposed() ==
false)
141 QWindowSystemInterface::handleExposeEvent(qwindow, updateRect);
142 window->deliverUpdateRequest();
144 QWindowSystemInterface::handleExposeEvent(qwindow, updateRect);
148void QWasmCompositor::handleBackingStoreFlush(QWindow *window,
const QRect &updateRect)
152 if (!m_inDeliverUpdateRequest)
153 requestUpdateWindow(
static_cast<QWasmWindow *>(window->handle()), updateRect);
161 for (QWasmWindow *window : windows)
void onWindowTreeChanged(QWasmWindowTreeNodeChangeType changeType, QWasmWindow *window)
static bool releaseRequestUpdateHold()
void setEnabled(bool enabled)
UpdateRequestDeliveryType
QWasmCompositor(QWasmScreen *screen)
friend class QWasmCompositor
QWasmWindowTreeNodeChangeType