From 92cf38018afe8f598f2c337c0d202f3767b04ead Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Wed, 4 Dec 2019 10:40:20 +0100 Subject: Quit application when QWindowsSystemTrayIcon receives WM_CLOSE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an application only has a trayicon and is killed by `taskkill /IM binary.exe` the trayicon's HWND will receive a WM_CLOSE message. If we don't handle this, the tray icon will close anyway, but the app still runs in the task manager. Fixes: QTBUG-43855 Change-Id: I5f82a068df9c40360bd565a2681e1b37ff114e44 Reviewed-by: Tor Arne Vestbø Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowssystemtrayicon.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index f2dba4d06b..22cdefbbbc 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include #include @@ -136,7 +137,7 @@ extern "C" LRESULT QT_WIN_CALLBACK qWindowsTrayIconWndProc(HWND hwnd, UINT messa { if (message == MYWM_TASKBARCREATED || message == MYWM_NOTIFYICON || message == WM_INITMENU || message == WM_INITMENUPOPUP - || message == WM_COMMAND) { + || message == WM_CLOSE || message == WM_COMMAND) { const int index = indexOfHwnd(hwnd); if (index >= 0) { MSG msg; @@ -439,6 +440,9 @@ bool QWindowsSystemTrayIcon::winEvent(const MSG &message, long *result) case WM_INITMENUPOPUP: QWindowsPopupMenu::notifyAboutToShow(reinterpret_cast(message.wParam)); break; + case WM_CLOSE: + QWindowSystemInterface::handleApplicationTermination(); + break; case WM_COMMAND: QWindowsPopupMenu::notifyTriggered(LOWORD(message.wParam)); break; -- cgit v1.2.3 From c7fec68e1936576070d0fbac6cf40b818366d298 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 2 Dec 2019 14:08:29 +0100 Subject: Do not read Xft.dpi on platforms that shouldn't be using Xft settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We only read this for desktop environments that have traditionally used these to set settings for other toolkits. Fixes: QTBUG-80323 Change-Id: Ifa8c2682301e69c2770d3734115080a0e6b4e85c Reviewed-by: Morten Johan Sørvig Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbscreen.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 8da299d491..7c60ca06f9 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -41,6 +41,7 @@ #include "qxcbwindow.h" #include "qxcbcursor.h" #include "qxcbimage.h" +#include "qxcbintegration.h" #include "qnamespace.h" #include "qxcbxsettings.h" @@ -49,6 +50,7 @@ #include #include +#include #include #include #include @@ -356,6 +358,15 @@ static QFontEngine::SubpixelAntialiasingType parseXftRgba(const QByteArray& stri void QXcbVirtualDesktop::readXResources() { + const QPlatformServices *services = QXcbIntegration::instance()->services(); + bool useXftConf = false; + if (services) { + const QList desktopEnv = services->desktopEnvironment().split(':'); + useXftConf = desktopEnv.contains("GNOME") || desktopEnv.contains("UNITY") || desktopEnv.contains("XFCE"); + } + if (!useXftConf) + return; + int offset = 0; QByteArray resources; while (true) { -- cgit v1.2.3 From 35da2b87e3d04e4f7eb0895590be6952eeeb4a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 4 Dec 2019 19:50:28 +0100 Subject: macOS: Enable fullscreen for windows by default This matches the default collection behavior of NSWindows. Change-Id: I363ed211daf6c6c2e579eb11c7294ff509d53e91 Fixes: QTBUG-63829 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 6e2d446898..69d192b4f5 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -567,7 +567,10 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags) Qt::WindowType type = static_cast(int(flags & Qt::WindowType_Mask)); if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) { NSWindowCollectionBehavior behavior = m_view.window.collectionBehavior; - if ((flags & Qt::WindowFullscreenButtonHint) || m_view.window.qt_fullScreen) { + const bool enableFullScreen = m_view.window.qt_fullScreen + || !(flags & Qt::CustomizeWindowHint) + || (flags & Qt::WindowFullscreenButtonHint); + if (enableFullScreen) { behavior |= NSWindowCollectionBehaviorFullScreenPrimary; behavior &= ~NSWindowCollectionBehaviorFullScreenAuxiliary; } else { -- cgit v1.2.3 From aabf4fbbe932cbf5554062ed973f9b52388b5352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 3 Dec 2019 15:41:55 +0100 Subject: macOS: Improve QCocoaGLContext logging Change-Id: I27d0abe0eb5b0f0ba64b8787b430484c48b131c0 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoaglcontext.h | 4 ++++ src/plugins/platforms/cocoa/qcocoaglcontext.mm | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index 4210a4ed3f..238067568b 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -86,6 +86,10 @@ private: QSurfaceFormat m_format; QVarLengthArray m_updateObservers; QAtomicInt m_needsUpdate = false; + +#ifndef QT_NO_DEBUG_STREAM + friend QDebug operator<<(QDebug debug, const QCocoaGLContext *screen); +#endif }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index b312e033cd..6db4bdb9fd 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -158,6 +158,8 @@ void QCocoaGLContext::initialize() [m_context setValues:&order forParameter:NSOpenGLCPSurfaceOrder]; updateSurfaceFormat(); + + qCDebug(lcQpaOpenGLContext).verbosity(3) << "Created" << this << "based on requested" << context()->format(); } NSOpenGLPixelFormat *QCocoaGLContext::pixelFormatForSurfaceFormat(const QSurfaceFormat &format) @@ -355,7 +357,7 @@ QCocoaGLContext::~QCocoaGLContext() bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface) { - qCDebug(lcQpaOpenGLContext) << "Making" << m_context << "current" + qCDebug(lcQpaOpenGLContext) << "Making" << this << "current" << "in" << QThread::currentThread() << "for" << surface; Q_ASSERT(surface->surface()->supportsOpenGL()); @@ -555,4 +557,20 @@ QFunctionPointer QCocoaGLContext::getProcAddress(const char *procName) return (QFunctionPointer)dlsym(RTLD_DEFAULT, procName); } +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug debug, const QCocoaGLContext *context) +{ + QDebugStateSaver saver(debug); + debug.nospace(); + debug << "QCocoaGLContext(" << (const void *)context; + if (context) { + if (debug.verbosity() > QDebug::DefaultVerbosity) + debug << ", " << context->format(); + debug << ", " << context->nativeContext(); + } + debug << ')'; + return debug; +} +#endif // !QT_NO_DEBUG_STREAM + QT_END_NAMESPACE -- cgit v1.2.3 From 455e9e5be35b36d79b9541a6e014c5c9026d685b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 2 Dec 2019 13:53:35 +0100 Subject: Windows QPA: Fix tray geometry not updating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The application does not update its screens when there are no windows on which a WM_DPICHANGE could be received. Add a check for it to the tray window procedure and trigger an update from there if no top levels are present. Fixes: QTBUG-79248 Change-Id: I0b1c4db560662ecf2b473304942da373be6fdc73 Reviewed-by: André de la Rocha Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/windows/qwindowssystemtrayicon.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index 22cdefbbbc..ab830e1461 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -57,6 +57,7 @@ #include "qwindowsmenu.h" #include "qwindowsscreen.h" +#include #include #include #include @@ -135,6 +136,9 @@ static int indexOfHwnd(HWND hwnd) extern "C" LRESULT QT_WIN_CALLBACK qWindowsTrayIconWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { + // QTBUG-79248: Trigger screen update if there are no other windows. + if (message == WM_DPICHANGED && QGuiApplication::topLevelWindows().isEmpty()) + QWindowsContext::instance()->screenManager().handleScreenChanges(); if (message == MYWM_TASKBARCREATED || message == MYWM_NOTIFYICON || message == WM_INITMENU || message == WM_INITMENUPOPUP || message == WM_CLOSE || message == WM_COMMAND) { -- cgit v1.2.3 From 10f39c908db2e3df933de8fbc553204e9bee65d7 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 7 Dec 2019 20:34:12 +0100 Subject: PSQL: set correct empty QVariant in QPSQLResult::record() Since the QSqlField used to retrieve the data is reused in the loop, the default empty value of the QSqlField is not set for all except the first field since it was implicitly set by QSqlField::setType() only when the value is invalid. Therefore we have to call QSqlField::setValue() directly. Change-Id: I1d3abe4e3c46f6378f9ff25529a79bbe33bb7b74 Reviewed-by: Robert Szefner Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/plugins') diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 760685f64b..78ede6a0d3 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -838,6 +838,7 @@ QSqlRecord QPSQLResult::record() const } int ptype = PQftype(d->result, i); f.setType(qDecodePSQLType(ptype)); + f.setValue(QVariant(f.type())); // only set in setType() when it's invalid before int len = PQfsize(d->result, i); int precision = PQfmod(d->result, i); -- cgit v1.2.3 From e0a43e348c7af9e8bc5519e7e8a4b7502ad89f3f Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Thu, 21 Nov 2019 11:09:24 -0500 Subject: Register the screen pulse event Future versions of QNX will, by default, require the use of registered events. Currently, event registration is supported but optional. Change-Id: Ie45484d5ca9fa832a28ccf08cb1764cf24262dcc Reviewed-by: Dan Cape Reviewed-by: Samuli Piippo --- .../platforms/qnx/qqnxscreeneventthread.cpp | 24 +++++++++++++++++++--- src/plugins/platforms/qnx/qqnxscreeneventthread.h | 2 ++ 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp b/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp index 1b5f3b4954..491c314488 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp @@ -60,6 +60,18 @@ static const int c_screenCode = _PULSE_CODE_MINAVAIL + 0; static const int c_armCode = _PULSE_CODE_MINAVAIL + 1; static const int c_quitCode = _PULSE_CODE_MINAVAIL + 2; +#if !defined(screen_register_event) +int screen_register_event(screen_context_t, struct sigevent *event) +{ + return MsgRegisterEvent(event, -1); +} + +int screen_unregister_event(struct sigevent *event) +{ + return MsgUnregisterEvent(event); +} +#endif + QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context) : QThread() , m_screenContext(context) @@ -75,10 +87,14 @@ QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context) qFatal("QQnxScreenEventThread: Can't continue without a channel connection"); } - struct sigevent screenEvent; - SIGEV_PULSE_INIT(&screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_screenCode, 0); + SIGEV_PULSE_INIT(&m_screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_screenCode, 0); + if (screen_register_event(m_screenContext, &m_screenEvent) == -1) { + ConnectDetach(m_connectionId); + ChannelDestroy(m_channelId); + qFatal("QQnxScreenEventThread: Can't continue without a registered event"); + } - screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, &screenEvent); + screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, &m_screenEvent); } QQnxScreenEventThread::~QQnxScreenEventThread() @@ -86,6 +102,8 @@ QQnxScreenEventThread::~QQnxScreenEventThread() // block until thread terminates shutdown(); + screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, nullptr); + screen_unregister_event(&m_screenEvent); ConnectDetach(m_connectionId); ChannelDestroy(m_channelId); } diff --git a/src/plugins/platforms/qnx/qqnxscreeneventthread.h b/src/plugins/platforms/qnx/qqnxscreeneventthread.h index 3c8d197545..e5b762369c 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventthread.h +++ b/src/plugins/platforms/qnx/qqnxscreeneventthread.h @@ -45,6 +45,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -73,6 +74,7 @@ private: int m_channelId; int m_connectionId; + struct sigevent m_screenEvent; screen_context_t m_screenContext; bool m_emitNeededOnNextScreenPulse = true; int m_screenPulsesSinceLastArmPulse = 0; -- cgit v1.2.3 From baed8534bc1dac36a9d0ef4240fc14398076a192 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 5 Nov 2019 14:06:46 +0100 Subject: Move the tooltip out of the way of very large mouse cursors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users that have large mouse pointers configured in their settings can not see tooltips, as they are obscured by the pointer. Native applications on Windows and macOS have the same problem, which includes the tooltips for the minimize/maximize/close controls in the window frame of e.g. Explorer. Introduce QPlatformCursor::size that returns a value that is based on the user's settings, or a default value. We can then use that value to move the tooltip out of the way. On Windows, the calculation of the cursor size is based on experimenting with the settings, which are in logical independent pixels. The placement of the tooltip attempts to keep existing behavior, and to not end up with a tooltip that's very far away from the tip of the arrow even for very large mouse cursors. [ChangeLog][QtWidgets][QToolTip] Make sure that the tooltip is not obscured by very large mouse pointers on Windows and macOS. Change-Id: I8e13b7a166bfe8b59cef4765c950f90fefeaef9d Fixes: QTBUG-79627 Reviewed-by: Friedemann Kleint Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoacursor.h | 3 +++ src/plugins/platforms/cocoa/qcocoacursor.mm | 25 ++++++++++++++++++++++++ src/plugins/platforms/windows/qwindowscursor.cpp | 25 ++++++++++++++++++++++++ src/plugins/platforms/windows/qwindowscursor.h | 2 ++ 4 files changed, 55 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoacursor.h b/src/plugins/platforms/cocoa/qcocoacursor.h index 58b9ef2151..5b008eff35 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.h +++ b/src/plugins/platforms/cocoa/qcocoacursor.h @@ -56,6 +56,9 @@ public: void changeCursor(QCursor *cursor, QWindow *window) override; QPoint pos() const override; void setPos(const QPoint &position) override; + + QSize size() const override; + private: QHash m_cursors; NSCursor *convertCursor(QCursor *cursor); diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm index 87a57c78c8..e0d623fc4c 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.mm +++ b/src/plugins/platforms/cocoa/qcocoacursor.mm @@ -85,6 +85,31 @@ void QCocoaCursor::setPos(const QPoint &position) CFRelease(e); } + +QSize QCocoaCursor::size() const +{ + NSCursor *cocoaCursor = NSCursor.currentSystemCursor; + if (!cocoaCursor) + return QPlatformCursor::size(); + NSImage *cursorImage = cocoaCursor.image; + if (!cursorImage) + return QPlatformCursor::size(); + + QSizeF size = QSizeF::fromCGSize(cursorImage.size); + NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults; + NSDictionary *accessSettings = [defaults persistentDomainForName:@"com.apple.universalaccess"]; + if (accessSettings == nil) + return size.toSize(); + + float sizeScale = [accessSettings[@"mouseDriverCursorSize"] floatValue]; + if (sizeScale > 0) { + size.rwidth() *= sizeScale; + size.rheight() *= sizeScale; + } + + return size.toSize(); +} + NSCursor *QCocoaCursor::convertCursor(QCursor *cursor) { if (!cursor) diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index 17e8cffb76..59457f1720 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -50,6 +50,7 @@ #include #include // getPixmapCursor() #include +#include #include #include @@ -686,6 +687,30 @@ void QWindowsCursor::setPos(const QPoint &pos) SetCursorPos(pos.x() , pos.y()); } +/* + The standard size is 32x32, even though the cursor is actually just + 16 pixels large. If a large cursor is set in the accessibility settings, + then the cursor increases with 8 pixels for each step. +*/ +QSize QWindowsCursor::size() const +{ + const QPair cursorSizeSetting = + QWinRegistryKey(HKEY_CURRENT_USER, LR"(Control Panel\Cursors)") + .dwordValue(L"CursorBaseSize"); + const int baseSize = screenCursorSize(m_screen).width() / 2; + if (!cursorSizeSetting.second) + return QSize(baseSize / 2, baseSize / 2); + + // The registry values are dpi-independent, so we need to scale the result. + int cursorSizeValue = cursorSizeSetting.first * m_screen->logicalDpi().first + / m_screen->logicalBaseDpi().first; + + // map from registry value 32-256 to 0-14, and from there to pixels + cursorSizeValue = (cursorSizeValue - 2 * baseSize) / baseSize; + const int cursorSize = baseSize + cursorSizeValue * (baseSize / 2); + return QSize(cursorSize, cursorSize); +} + QPixmap QWindowsCursor::dragDefaultCursor(Qt::DropAction action) const { switch (action) { diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h index b896f4c7a9..cf3635bd6b 100644 --- a/src/plugins/platforms/windows/qwindowscursor.h +++ b/src/plugins/platforms/windows/qwindowscursor.h @@ -113,6 +113,8 @@ public: QPoint pos() const override; void setPos(const QPoint &pos) override; + QSize size() const override; + static HCURSOR createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot, qreal scaleFactor = 1); static HCURSOR createPixmapCursor(const PixmapCursor &pc, qreal scaleFactor = 1) { return createPixmapCursor(pc.pixmap, pc.hotSpot, scaleFactor); } static PixmapCursor customCursor(Qt::CursorShape cursorShape, const QPlatformScreen *screen = nullptr); -- cgit v1.2.3 From c978de990b6c448184e13a3c45d9aa268492b48a Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 26 Jun 2019 13:23:12 +1000 Subject: wasm: set focus on canvas on new screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows user to utilize the application without having to click on it first to cause the focus-in event. Change-Id: Ibc9582254dda91eb14ebcdf4b8ea4a4f862aa88d Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmscreen.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index 37f1ea832a..b6c9b9e377 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -54,6 +54,8 @@ QWasmScreen::QWasmScreen(const QString &canvasId) m_compositor = new QWasmCompositor(this); m_eventTranslator = new QWasmEventTranslator(this); updateQScreenAndCanvasRenderSize(); + emscripten::val canvas = emscripten::val::global(m_canvasId.toUtf8().constData()); + canvas.call("focus"); } QWasmScreen::~QWasmScreen() -- cgit v1.2.3 From c69a2448ab129d88411a4778f2350dcf971dc623 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 4 Dec 2019 15:06:36 +0100 Subject: macOS: support copying lazily provided data to the clipboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using always EagerRequest type forces the application to provide the data at copy or drag-begin time, even though the data might never be requested (pasted or dropped into another application). For data that is expensive to generate, this is wasteful, and on other platforms Qt uses the functionality provided by the native clipboard to allow for on-demand retrieval of data. Changing the request type to LazyRequest for the cocoa clipboard works, but then we need to make sure that we resolve all promises at shutdown time so that the data is available (which is what the end user expects). Commit ad0d2f463a0905c4705660d96e8a514539c51d36 disabled this for lazy requests to prevent crashes when using drag'n'drop, where the QMacPasteboard object is short-lived and stack allocated. We definitely don't need to worry about lazy data that is not yet retrieved at the end of a drag'n'drop operation, so limit the fix from the previous commit to the drag'n'drop scenario. [ChangeLog][QtGui][QClipboard] Support lazily provided copying of data to the clipboard on macOS Change-Id: Id2203999024a0d9d854d6933d39077cc4af925d0 Fixes: QTBUG-76263 Reviewed-by: Tomi Korpipää Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaclipboard.mm | 2 +- src/plugins/platforms/cocoa/qmacclipboard.mm | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaclipboard.mm b/src/plugins/platforms/cocoa/qcocoaclipboard.mm index a35c153084..141940cc50 100644 --- a/src/plugins/platforms/cocoa/qcocoaclipboard.mm +++ b/src/plugins/platforms/cocoa/qcocoaclipboard.mm @@ -67,7 +67,7 @@ void QCocoaClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) } pasteBoard->sync(); - pasteBoard->setMimeData(data); + pasteBoard->setMimeData(data, QMacPasteboard::LazyRequest); emitChanged(mode); } } diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index 358a6b49fd..654647b35a 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -138,8 +138,12 @@ QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt) QMacPasteboard::~QMacPasteboard() { - // commit all promises for paste after exit close - resolvingBeforeDestruction = true; + /* + Commit all promises for paste when shutting down, + unless we are the stack-allocated clipboard used by QCocoaDrag. + */ + if (mime_type == QMacInternalPasteboardMime::MIME_DND) + resolvingBeforeDestruction = true; PasteboardResolvePromises(paste); if (paste) CFRelease(paste); -- cgit v1.2.3 From b209270825cc2c3345d094e3dd547604c64e0b26 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Fri, 6 Dec 2019 20:21:41 +0100 Subject: Windows QPA: Export "checkable" info for menu items through UI Automation In order to allow screen readers to say checked/unchecked for checkable menu items, this information has to be provided through UI Automation. Checkable menu items should implement the "Toggle" UI Automation pattern. The "checkable" state must also be supported by QAccessibleMenuItem, which is being added by a separated change. Task-number: QTBUG-80551 Change-Id: I661668310d1b6b4701d0c0efdb1dcfd15d0db729 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index e5a9f275ae..cc293b777c 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -289,7 +289,8 @@ HRESULT QWindowsUiaMainProvider::GetPatternProvider(PATTERNID idPattern, IUnknow break; case UIA_TogglePatternId: // Checkbox controls. - if (accessible->role() == QAccessible::CheckBox) { + if (accessible->role() == QAccessible::CheckBox + || (accessible->role() == QAccessible::MenuItem && accessible->state().checkable)) { *pRetVal = new QWindowsUiaToggleProvider(id()); } break; -- cgit v1.2.3 From 30e32870a052fda1a23099e46864242e52d94a17 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 4 Dec 2019 14:58:27 +0100 Subject: QCocoaEventDispatcher: make 'interrupt' work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit even if we are currently inside processEvents (apparently called manually and not from QEventLoop::exec()). A carefully crafted application (see, for example, the linked QTBUG or even updated auto-test) can trigger itself into failing to exit the current (potentially nested) event loop. We can harden our Cocoa event dispatcher to detect such condition and properly propagate 'interrupt' to where it'll do its job, indeed, interrupting the real event loop (aka [NSApp run]). This mainly means we have to undo what bool blocker would erroneously do. Also, long live (as people love to say these days) to another tricky (somewhat) auto-test (surely, it's not flaky!). Fixes: QTBUG-79477 Change-Id: I794f0cda23e24d36be67f2bb63d52b74be057c31 Reviewed-by: Volker Hilsheimer Reviewed-by: Qt CI Bot Reviewed-by: Tor Arne Vestbø --- .../platforms/cocoa/qcocoaeventdispatcher.h | 1 + .../platforms/cocoa/qcocoaeventdispatcher.mm | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h index 69587a24be..b8d2532b8e 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h @@ -186,6 +186,7 @@ public: QAtomicInt serialNumber; int lastSerial; bool interrupt; + bool propagateInterrupt = false; static void postedEventsSourceCallback(void *info); static void waitingObserverCallback(CFRunLoopObserverRef observer, diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 110c82bf1f..94b9e62eab 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -84,13 +84,12 @@ #include "private/qthread_p.h" #include "private/qguiapplication_p.h" #include +#include #include QT_BEGIN_NAMESPACE -QT_USE_NAMESPACE - static inline CFRunLoopRef mainRunLoop() { return CFRunLoopGetMain(); @@ -348,6 +347,16 @@ static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRun bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QCocoaEventDispatcher); + + // In rare rather corner cases a user's application messes with + // QEventLoop::exec()/exit() and QCoreApplication::processEvents(), + // we have to undo what bool blocker normally does. + d->propagateInterrupt = false; + const auto boolBlockerUndo = qScopeGuard([d](){ + if (d->propagateInterrupt) + d->interrupt = true; + d->propagateInterrupt = false; + }); QBoolBlocker interruptBlocker(d->interrupt, false); bool interruptLater = false; @@ -496,7 +505,16 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) if ((d->processEventsFlags & QEventLoop::EventLoopExec) == 0) { // When called "manually", always process posted events and timers + bool oldInterrupt = d->interrupt; d->processPostedEvents(); + if (!oldInterrupt && d->interrupt && !d->currentModalSession()) { + // We had direct processEvent call, coming not from QEventLoop::exec(). + // One of the posted events triggered an application to interrupt the loop. + // But bool blocker will reset d->interrupt to false, so the real event + // loop will never notice it was interrupted. Now we'll have to fix it by + // enforcing the value of d->interrupt. + d->propagateInterrupt = true; + } retVal = d->processTimers() || retVal; } -- cgit v1.2.3