From a1867208a654509c85a54914d1fe6178675c7fdc Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Thu, 2 Feb 2023 15:43:50 +0100 Subject: [PATCH] wasm: Don't grab menu bar item shortcuts on Mac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Mac there's no concept of menu bar alt+key shortcuts. Therefore we cannot expect users on Mac, even when in a web application, to be familiar with those. Additionally, alt+key combinations yield special characters on Mac so that is the behavior we should support in WASM apps on Mac. To disable the menu bar item shortcuts, a new platform style hint UnderlineShortcut was created. Shortcut grabbing was disabled exactly the same as on regular Mac builds, i.e. through qt_set_sequence_auto_mnemonic. Task-number: QTBUG-76587 Change-Id: Ice6ed123c01e46b58d6d2c3e639813161b5a9a40 Reviewed-by: Mikołaj Boc Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmintegration.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index a88de18f2a..2bdb3b7c69 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -10,7 +10,7 @@ #include "qwasmaccessibility.h" #include "qwasmservices.h" #include "qwasmoffscreensurface.h" - +#include "qwasmplatform.h" #include "qwasmwindow.h" #include "qwasmbackingstore.h" #include "qwasmfontdatabase.h" @@ -32,6 +32,8 @@ QT_BEGIN_NAMESPACE +extern void qt_set_sequence_auto_mnemonic(bool); + using namespace emscripten; using namespace Qt::StringLiterals; @@ -81,6 +83,9 @@ QWasmIntegration::QWasmIntegration() { s_instance = this; + if (platform() == Platform::MacOS) + qt_set_sequence_auto_mnemonic(false); + touchPoints = emscripten::val::global("navigator")["maxTouchPoints"].as(); // Create screens for container elements. Each container element will ultimately become a @@ -226,10 +231,14 @@ QAbstractEventDispatcher *QWasmIntegration::createEventDispatcher() const QVariant QWasmIntegration::styleHint(QPlatformIntegration::StyleHint hint) const { - if (hint == ShowIsFullScreen) + switch (hint) { + case ShowIsFullScreen: return true; - - return QPlatformIntegration::styleHint(hint); + case UnderlineShortcut: + return platform() != Platform::MacOS; + default: + return QPlatformIntegration::styleHint(hint); + } } Qt::WindowState QWasmIntegration::defaultWindowState(Qt::WindowFlags flags) const