summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmcompositor.cpp
diff options
context:
space:
mode:
authorMikolaj Boc <mikolaj.boc@qt.io>2022-08-23 14:24:36 +0200
committerMikolaj Boc <mikolaj.boc@qt.io>2022-08-24 17:50:25 +0200
commit11f12521bcd9c76f0ff5c60fb8785aba33ec7ca7 (patch)
tree5cf2eb6ccad5143628146c793f84ae64e2b73261 /src/plugins/platforms/wasm/qwasmcompositor.cpp
parent0acb56518d72c09650dd83ca34a7d5bb0763b06a (diff)
Resolve window focusing problems on WASM
- Moved the modal window resolution to QWasmWindow::requestActivateWindow so that multiple async activation events are not issued in unpredictable patterns. - Request activation on added windows and on stack top in case of window removal Pick-to: 6.4 Change-Id: I6f02cf1b7e83abb7961caf311ffc83e91c8bf810 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmcompositor.cpp')
-rw-r--r--src/plugins/platforms/wasm/qwasmcompositor.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp
index fff448ddef8..270f8e65e70 100644
--- a/src/plugins/platforms/wasm/qwasmcompositor.cpp
+++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp
@@ -53,7 +53,7 @@ EMSCRIPTEN_BINDINGS(qtMouseModule) {
QWasmCompositor::QWasmCompositor(QWasmScreen *screen)
: QObject(screen),
m_windowManipulation(screen),
- m_windowStack(std::bind(&QWasmCompositor::onTopWindowChanged, this, std::placeholders::_1)),
+ m_windowStack(std::bind(&QWasmCompositor::onTopWindowChanged, this)),
m_blitter(new QOpenGLTextureBlitter),
m_eventTranslator(std::make_unique<QWasmEventTranslator>())
{
@@ -174,6 +174,7 @@ void QWasmCompositor::addWindow(QWasmWindow *window)
{
m_windowVisibility.insert(window, false);
m_windowStack.pushWindow(window);
+ m_windowStack.topWindow()->requestActivateWindow();
}
void QWasmCompositor::removeWindow(QWasmWindow *window)
@@ -181,6 +182,8 @@ void QWasmCompositor::removeWindow(QWasmWindow *window)
m_windowVisibility.remove(window);
m_requestUpdateWindows.remove(window);
m_windowStack.removeWindow(window);
+ if (m_windowStack.topWindow())
+ m_windowStack.topWindow()->requestActivateWindow();
}
void QWasmCompositor::setVisible(QWasmWindow *window, bool visible)
@@ -755,21 +758,8 @@ void QWasmCompositor::WindowManipulation::resizeWindow(const QPoint& amount)
));
}
-void QWasmCompositor::onTopWindowChanged(QWasmWindow *window)
+void QWasmCompositor::onTopWindowChanged()
{
- if (!QGuiApplication::focusWindow())
- window->requestActivateWindow();
-
- QWindow *modalWindow;
- const bool isTargetWindowBlocked =
- QGuiApplicationPrivate::instance()->isWindowBlocked(window->window(), &modalWindow);
-
- if (isTargetWindowBlocked) {
- modalWindow->requestActivate();
- raise(asWasmWindow(modalWindow));
- return;
- }
-
requestUpdate();
}