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;
20 QWindowSystemInterface::setSynchronousWindowSystemEvents(
true);
25 if (m_drawCallbackHandle != 0)
26 QWasmAnimationFrameMultiHandler::instance()->unregisterDrawCallback(m_drawCallbackHandle);
36 auto allWindows =
screen()->allWindows();
37 setEnabled(std::any_of(allWindows.begin(), allWindows.end(), [](QWasmWindow *element) {
38 return !element->context2d().isUndefined();
40 if (changeType == QWasmWindowTreeNodeChangeType::NodeRemoval)
41 m_requestUpdateWindows.remove(window);
46 m_isEnabled = enabled;
51 auto it = m_requestUpdateWindows.find(window);
52 if (it == m_requestUpdateWindows.end()) {
53 m_requestUpdateWindows.insert(window, std::make_tuple(updateRect, updateType));
57 if (
std::get<0>(it.value()) != updateRect) {
59 region |=
std::get<0>(it.value());
61 std::get<0>(it.value()) = region.boundingRect();
74 if (m_drawCallbackHandle != 0)
77 m_drawCallbackHandle = QWasmAnimationFrameMultiHandler::instance()->registerDrawCallback(
78 [
this](
double frametime) {
80 m_drawCallbackHandle = 0;
81 deliverUpdateRequests();
90 auto requestUpdateWindows = m_requestUpdateWindows;
91 m_requestUpdateWindows.clear();
96 m_inDeliverUpdateRequest =
true;
97 for (
auto it = requestUpdateWindows.constBegin(); it != requestUpdateWindows.constEnd(); ++it) {
98 auto *window = it.key();
100 const QRect updateRect = std::get<0>(it.value());
102 deliverUpdateRequest(window, updateRect, updateType);
105 m_inDeliverUpdateRequest =
false;
106 frame(requestUpdateWindows.keys());
111 const QRect &updateRect,
114 QWindow *qwindow = window->window();
118 QWindowSystemInterface::handleWindowDevicePixelRatioChanged(qwindow);
125 if (qwindow->isExposed() ==
false)
126 QWindowSystemInterface::handleExposeEvent(qwindow, updateRect);
127 window->deliverUpdateRequest();
129 QWindowSystemInterface::handleExposeEvent(qwindow, updateRect);
133void QWasmCompositor::handleBackingStoreFlush(QWindow *window,
const QRect &updateRect)
137 if (!m_inDeliverUpdateRequest)
138 requestUpdateWindow(
static_cast<QWasmWindow *>(window->handle()), updateRect);
146 for (QWasmWindow *window : windows)
void onWindowTreeChanged(QWasmWindowTreeNodeChangeType changeType, QWasmWindow *window)
void setEnabled(bool enabled)
UpdateRequestDeliveryType
QWasmCompositor(QWasmScreen *screen)
friend class QWasmCompositor
QWasmWindowTreeNodeChangeType