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);
35 updateEnabledForWindows();
40 m_requestUpdateWindows.remove(window);
41 updateEnabledForWindows();
46 auto allWindows =
screen()->allWindows();
47 setEnabled(std::any_of(allWindows.begin(), allWindows.end(), [](QWasmWindow *element) {
48 return !element->context2d().isUndefined();
54 m_isEnabled = enabled;
59 auto it = m_requestUpdateWindows.find(window);
60 if (it == m_requestUpdateWindows.end()) {
61 m_requestUpdateWindows.insert(window, std::make_tuple(updateRect, updateType));
65 if (
std::get<0>(it.value()) != updateRect) {
67 region |=
std::get<0>(it.value());
69 std::get<0>(it.value()) = region.boundingRect();
82 if (m_drawCallbackHandle != 0)
85 m_drawCallbackHandle = QWasmAnimationFrameMultiHandler::instance()->registerDrawCallback(
86 [
this](
double frametime) {
88 m_drawCallbackHandle = 0;
89 deliverUpdateRequests();
98 auto requestUpdateWindows = m_requestUpdateWindows;
99 m_requestUpdateWindows.clear();
104 m_inDeliverUpdateRequest =
true;
105 for (
auto it = requestUpdateWindows.constBegin(); it != requestUpdateWindows.constEnd(); ++it) {
106 auto *window = it.key();
108 const QRect updateRect = std::get<0>(it.value());
110 deliverUpdateRequest(window, updateRect, updateType);
113 m_inDeliverUpdateRequest =
false;
114 frame(requestUpdateWindows.keys());
119 const QRect &updateRect,
122 QWindow *qwindow = window->window();
126 QWindowSystemInterface::handleWindowDevicePixelRatioChanged(qwindow);
133 if (qwindow->isExposed() ==
false)
134 QWindowSystemInterface::handleExposeEvent(qwindow, updateRect);
135 window->deliverUpdateRequest();
137 QWindowSystemInterface::handleExposeEvent(qwindow, updateRect);
141void QWasmCompositor::handleBackingStoreFlush(QWindow *window,
const QRect &updateRect)
145 if (!m_inDeliverUpdateRequest)
146 requestUpdateWindow(
static_cast<QWasmWindow *>(window->handle()), updateRect);
154 for (QWasmWindow *window : windows)
void onWindowAdded(QWasmWindow *window)
void onWindowRemoved(QWasmWindow *window)
void setEnabled(bool enabled)
UpdateRequestDeliveryType
QWasmCompositor(QWasmScreen *screen)
friend class QWasmCompositor