wasm: Make sure we can add screen after releaseRequestUpdateHold has been called
Before this fix, such screens would not render due to requestUpdateHold is initialized to true and never reset. The fix is to change the requestUpdateHold member to be a static variable, so that it can be read by screens added after requestUpdateHold has been called. Also, add a test that would fail without this fix Change-Id: Idf2ac916766a03480272cd550f9d1ab7fc5c5158 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
e06c67d448
commit
d8a6a9bfcb
@ -12,6 +12,8 @@
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
bool QWasmCompositor::m_requestUpdateHoldEnabled = true;
|
||||
|
||||
QWasmCompositor::QWasmCompositor(QWasmScreen *screen) : QObject(screen)
|
||||
{
|
||||
QWindowSystemInterface::setSynchronousWindowSystemEvents(true);
|
||||
@ -46,12 +48,11 @@ void QWasmCompositor::setEnabled(bool enabled)
|
||||
// requestUpdate delivery is initially disabled at startup, while Qt completes
|
||||
// startup tasks such as font loading. This function enables requestUpdate delivery
|
||||
// again.
|
||||
void QWasmCompositor::releaseRequesetUpdateHold()
|
||||
bool QWasmCompositor::releaseRequestUpdateHold()
|
||||
{
|
||||
if (!m_requestUpdateHoldEnabled)
|
||||
return;
|
||||
const bool wasEnabled = m_requestUpdateHoldEnabled;
|
||||
m_requestUpdateHoldEnabled = false;
|
||||
requestUpdate();
|
||||
return wasEnabled;
|
||||
}
|
||||
|
||||
void QWasmCompositor::requestUpdateWindow(QWasmWindow *window, UpdateRequestDeliveryType updateType)
|
||||
|
@ -31,7 +31,9 @@ public:
|
||||
QWasmScreen *screen();
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
void releaseRequesetUpdateHold();
|
||||
static bool releaseRequestUpdateHold();
|
||||
|
||||
void requestUpdate();
|
||||
enum UpdateRequestDeliveryType { ExposeEventDelivery, UpdateRequestDelivery };
|
||||
void requestUpdateWindow(QWasmWindow *window, UpdateRequestDeliveryType updateType = ExposeEventDelivery);
|
||||
|
||||
@ -43,15 +45,14 @@ private:
|
||||
|
||||
void deregisterEventHandlers();
|
||||
|
||||
void requestUpdate();
|
||||
void deliverUpdateRequests();
|
||||
void deliverUpdateRequest(QWasmWindow *window, UpdateRequestDeliveryType updateType);
|
||||
|
||||
bool m_isEnabled = true;
|
||||
QMap<QWasmWindow *, UpdateRequestDeliveryType> m_requestUpdateWindows;
|
||||
int m_requestAnimationFrameId = -1;
|
||||
bool m_requestUpdateHoldEnabled = true;
|
||||
bool m_inDeliverUpdateRequest = false;
|
||||
static bool m_requestUpdateHoldEnabled;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -208,8 +208,11 @@ void QWasmIntegration::removeBackingStore(QWindow* window)
|
||||
|
||||
void QWasmIntegration::releaseRequesetUpdateHold()
|
||||
{
|
||||
for (const auto &elementAndScreen : m_screens) {
|
||||
elementAndScreen.wasmScreen->compositor()->releaseRequesetUpdateHold();
|
||||
if (QWasmCompositor::releaseRequestUpdateHold())
|
||||
{
|
||||
for (const auto &elementAndScreen : m_screens) {
|
||||
elementAndScreen.wasmScreen->compositor()->requestUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,8 +372,6 @@ class WidgetTestCase(unittest.TestCase):
|
||||
|
||||
self.assertFalse(w4 in screen.query_windows())
|
||||
|
||||
#TODO FIX
|
||||
@unittest.skip('Does not work currently')
|
||||
def test_window_painting(self):
|
||||
screen = Screen(self._driver, ScreenPosition.FIXED,
|
||||
x=0, y=0, width=800, height=800)
|
||||
@ -389,13 +387,15 @@ class WidgetTestCase(unittest.TestCase):
|
||||
|
||||
self.assertEqual(w1.color_at(0, 0), Color(r=0, g=255, b=0))
|
||||
|
||||
w1_w1 = Window(parent=w1, rect=Rect(x=100, y=100, width=400, height=400), title='w1_w1')
|
||||
w1_w1 = Window(parent=screen, rect=Rect(x=100, y=100, width=400, height=400), title='w1_w1')
|
||||
w1_w1.set_parent(w1)
|
||||
w1_w1.set_background_color(Color(r=0, g=0, b=255))
|
||||
wait_for_animation_frame(self._driver)
|
||||
|
||||
self.assertEqual(w1_w1.color_at(0, 0), Color(r=0, g=0, b=255))
|
||||
|
||||
w1_w1_w1 = Window(parent=w1_w1, rect=Rect(x=100, y=100, width=200, height=200), title='w1_w1_w1')
|
||||
w1_w1_w1 = Window(parent=screen, rect=Rect(x=100, y=100, width=200, height=200), title='w1_w1_w1')
|
||||
w1_w1_w1.set_parent(w1_w1)
|
||||
w1_w1_w1.set_background_color(Color(r=255, g=255, b=0))
|
||||
wait_for_animation_frame(self._driver)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user