include/vcl/sysdata.hxx | 2 +- vcl/qt5/QtClipboard.cxx | 7 +++++++ vcl/qt5/QtFrame.cxx | 11 ++++++++++- vcl/qt5/QtWidget.cxx | 5 ++++- 4 files changed, 22 insertions(+), 3 deletions(-)
New commits: commit c3d25b55990e2205af56747aa2935f4ff11ad0aa Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Fri Oct 29 22:24:12 2021 +0200 Commit: Jan-Marek Glogowski <glo...@fbihome.de> CommitDate: Wed Jan 19 10:55:56 2022 +0100 WASM Qt: various EMSCRIPTEN adaptions * Don't create a native window handle * Use a static QMimeData for non-working clipboard * Use Qt::Tooltip for LO's popup windows Change-Id: I6b6edfa26466814cb0500116098eafcbe41bba26 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128587 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de> diff --git a/include/vcl/sysdata.hxx b/include/vcl/sysdata.hxx index 57d9c2220ecf..00cd5142c2e3 100644 --- a/include/vcl/sysdata.hxx +++ b/include/vcl/sysdata.hxx @@ -62,7 +62,7 @@ struct VCL_DLLPUBLIC SystemEnvData #elif defined( IOS ) // Nothing #elif defined( UNX ) - enum class Platform { Wayland, Xcb }; + enum class Platform { Wayland, Xcb, WASM }; void* pDisplay; // the relevant display connection SalFrame* pSalFrame; // contains a salframe, if object has one diff --git a/vcl/qt5/QtClipboard.cxx b/vcl/qt5/QtClipboard.cxx index 55977d36642a..5d1a167a92a2 100644 --- a/vcl/qt5/QtClipboard.cxx +++ b/vcl/qt5/QtClipboard.cxx @@ -81,6 +81,9 @@ void QtClipboard::flushClipboard() css::uno::Reference<css::datatransfer::XTransferable> QtClipboard::getContents() { +#if defined(EMSCRIPTEN) + static QMimeData aMimeData; +#endif osl::MutexGuard aGuard(m_aMutex); // if we're the owner, we might have the XTransferable from setContents. but @@ -91,6 +94,10 @@ css::uno::Reference<css::datatransfer::XTransferable> QtClipboard::getContents() // check if we can still use the shared QtClipboardTransferable const QMimeData* pMimeData = QApplication::clipboard()->mimeData(m_aClipboardMode); +#if defined(EMSCRIPTEN) + if (!pMimeData) + pMimeData = &aMimeData; +#endif if (m_aContents.is()) { const auto* pTrans = dynamic_cast<QtClipboardTransferable*>(m_aContents.get()); diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index 9b645205946e..a70b6616c0a7 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -151,7 +151,11 @@ QtFrame::QtFrame(QtFrame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo) // a focus-out event, reaching the combo box. This used to map to // Qt::ToolTip, which doesn't feel that correct... else if (isPopup()) +#ifdef EMSCRIPTEN + aWinFlags = Qt::ToolTip | Qt::FramelessWindowHint; +#else aWinFlags = Qt::Window | Qt::FramelessWindowHint | Qt::BypassWindowManagerHint; +#endif else if (nStyle & SalFrameStyleFlags::TOOLWINDOW) aWinFlags = Qt::Tool; // top level windows can't be transient in Qt, so make them dialogs, if they have a parent. At least @@ -194,6 +198,8 @@ void QtFrame::FillSystemEnvData(SystemEnvData& rData, sal_IntPtr pWindow, QWidge rData.platform = SystemEnvData::Platform::Wayland; else if (QGuiApplication::platformName() == "xcb") rData.platform = SystemEnvData::Platform::Xcb; + else if (QGuiApplication::platformName() == "wasm") + rData.platform = SystemEnvData::Platform::WASM; else { // maybe add a SystemEnvData::Platform::Unsupported to avoid special cases and not abort? @@ -349,7 +355,10 @@ QWindow* QtFrame::windowHandle() const // set attribute 'Qt::WA_NativeWindow' first to make sure a window handle actually exists QWidget* pChild = asChild(); assert(pChild->window() == pChild); +#ifndef EMSCRIPTEN + // no idea, why this breaks the menubar for EMSCRIPTEN pChild->setAttribute(Qt::WA_NativeWindow); +#endif return pChild->windowHandle(); } @@ -480,7 +489,7 @@ void QtFrame::Show(bool bVisible, bool bNoActivate) modalReparent(true); pChild->setVisible(true); pChild->raise(); - if (!bNoActivate && !isPopup()) + if (!bNoActivate) { pChild->activateWindow(); pChild->setFocus(); diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx index 979d345f679a..d999ebbb7bd8 100644 --- a/vcl/qt5/QtWidget.cxx +++ b/vcl/qt5/QtWidget.cxx @@ -631,7 +631,10 @@ QtWidget::QtWidget(QtFrame& rFrame, Qt::WindowFlags f) { create(); setMouseTracking(true); - setFocusPolicy(Qt::StrongFocus); + if (!rFrame.isPopup()) + setFocusPolicy(Qt::StrongFocus); + else + setFocusPolicy(Qt::ClickFocus); } static ExtTextInputAttr lcl_MapUndrelineStyle(QTextCharFormat::UnderlineStyle us)