7#include <private/qeventdispatcher_wasm_p.h>
8#include <private/qwasmsuspendresumecontrol_p.h>
10#include <qpa/qwindowsysteminterface.h>
12#include <emscripten/html5.h>
14using namespace emscripten;
21 QWindowSystemInterface::setSynchronousWindowSystemEvents(
true);
26 if (m_drawCallbackHandle != 0)
27 QWasmAnimationFrameMultiHandler::instance()->unregisterDrawCallback(m_drawCallbackHandle);
37 auto allWindows =
screen()->allWindows();
38 setEnabled(std::any_of(allWindows.begin(), allWindows.end(), [](QWasmWindow *element) {
39 return !element->context2d().isUndefined();
41 if (changeType == QWasmWindowTreeNodeChangeType::NodeRemoval)
42 m_requestUpdateWindows.remove(window);
47 m_isEnabled = enabled;
55 const bool wasEnabled = m_requestUpdateHoldEnabled;
56 m_requestUpdateHoldEnabled =
false;
62 auto it = m_requestUpdateWindows.find(window);
63 if (it == m_requestUpdateWindows.end()) {
64 m_requestUpdateWindows.insert(window, std::make_tuple(updateRect, updateType));
68 if (
std::get<0>(it.value()) != updateRect) {
70 region |=
std::get<0>(it.value());
72 std::get<0>(it.value()) = region.boundingRect();
85 if (m_drawCallbackHandle != 0)
88 if (m_requestUpdateHoldEnabled)
91 m_drawCallbackHandle = QWasmAnimationFrameMultiHandler::instance()->registerDrawCallback(
92 [
this](
double frametime) {
94 m_drawCallbackHandle = 0;
95 deliverUpdateRequests();
104 auto requestUpdateWindows = m_requestUpdateWindows;
105 m_requestUpdateWindows.clear();
110 m_inDeliverUpdateRequest =
true;
111 for (
auto it = requestUpdateWindows.constBegin(); it != requestUpdateWindows.constEnd(); ++it) {
112 auto *window = it.key();
114 const QRect updateRect = std::get<0>(it.value());
116 deliverUpdateRequest(window, updateRect, updateType);
119 m_inDeliverUpdateRequest =
false;
120 frame(requestUpdateWindows.keys());
125 const QRect &updateRect,
128 QWindow *qwindow = window->window();
132 QWindowSystemInterface::handleWindowDevicePixelRatioChanged(qwindow);
139 if (qwindow->isExposed() ==
false)
140 QWindowSystemInterface::handleExposeEvent(qwindow, updateRect);
141 window->deliverUpdateRequest();
143 QWindowSystemInterface::handleExposeEvent(qwindow, updateRect);
147void QWasmCompositor::handleBackingStoreFlush(QWindow *window,
const QRect &updateRect)
151 if (!m_inDeliverUpdateRequest)
152 requestUpdateWindow(
static_cast<QWasmWindow *>(window->handle()), updateRect);
160 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