From 1a14f7e91b065ed287a4982d4bea0027121926f4 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Wed, 3 Jul 2019 13:41:13 +0200 Subject: Windows QPA: Fix Wheel event coordinates In some cases, the wheel event coordinates would be incorrect, as the local coordinates were being determined relative to one window and the event being sent to another window, possibly incorrect. Fixes: QTBUG-75820 Change-Id: I4c3c4c6c4688bd9232d67ce4052d24365f6aea3a Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowspointerhandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index 8b88007949..b35629e2ce 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -684,7 +684,7 @@ bool QWindowsPointerHandler::translateMouseWheelEvent(QWindow *window, QPoint localPos = QWindowsGeometryHint::mapFromGlobal(receiver, globalPos); - QWindowSystemInterface::handleWheelEvent(window, localPos, globalPos, QPoint(), angleDelta, keyModifiers); + QWindowSystemInterface::handleWheelEvent(receiver, localPos, globalPos, QPoint(), angleDelta, keyModifiers); return true; } -- cgit v1.2.3 From cc873ec23a98ac32d10ac5fa569792fde2f6b2c8 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Wed, 3 Jul 2019 18:20:17 +0200 Subject: Windows QPA: Fix blinking dot on Windows 7/8/8.1 A blinking white dot could appear on dark backgrounds on Windows 7/8/8.1. It was caused by a workaround added to trigger the on-screen keyboard on the Microsoft Surface. This change effectively restricts that workaround to Windows 10, where the blinking dot was not an issue. And anyway, impact over the Surface functionality should be minimal, as all models produced since 2015 only support Windows 10 (and it's unknown if the workaround was ever necessary for early models running Windows 8.1). Fixes: QTBUG-74492 Change-Id: Ic9b9c0f71f23b75212054c56a29796cf0efa109a Reviewed-by: Volker Hilsheimer Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsinputcontext.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 8adcf56b11..61f971143d 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -279,7 +280,13 @@ void QWindowsInputContext::showInputPanel() // with Windows 10 if the Windows IME is (re)enabled _after_ the caret is shown. if (m_caretCreated) { cursorRectChanged(); - ShowCaret(platformWindow->handle()); + // We only call ShowCaret() on Windows 10 as in earlier versions the caret + // would actually be visible (QTBUG-74492) and the workaround for the + // Surface seems unnecessary there anyway. But leave it hidden for IME. + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10) + ShowCaret(platformWindow->handle()); + else + HideCaret(platformWindow->handle()); setWindowsImeEnabled(platformWindow, false); setWindowsImeEnabled(platformWindow, true); } -- cgit v1.2.3 From b55fac3f3763ffae3bf99f2afea7e5d5f8b7c2a8 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Fri, 5 Jul 2019 14:15:29 +0200 Subject: xcb: reduce focus-in delay This patch amends fe63900dc9891dd355ca1f10d6c7e5fd1516f5d5 The previous value of 400ms was a random and seemingly harmless choice. It turns out that 400ms is a bit too long and interferes with x11 async behavior tweaks in the VirtualBox source code. The original aim of specifying a concrete delay was to fix the nondeterministic behavior of the pre-existing code and to avoid flickering on KWin caused by waiting too little. This patch changes 400ms -> 100ms, which seems to work better in practice. Fixes: QTBUG-76742 Change-Id: Ia8168216819ac41d0124622c9472a98a1877262f Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection.cpp | 2 ++ src/plugins/platforms/xcb/qxcbwindow.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 06d1000993..f98b2dfe3a 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -132,7 +132,9 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra if (!m_startupId.isNull()) qunsetenv("DESKTOP_STARTUP_ID"); + const int focusInDelay = 100; m_focusInTimer.setSingleShot(true); + m_focusInTimer.setInterval(focusInDelay); m_focusInTimer.callOnTimeout([]() { // No FocusIn events for us, proceed with FocusOut normally. QWindowSystemInterface::handleWindowActivated(nullptr, Qt::ActiveWindowFocusReason); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 9382488b74..610eca06a5 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -848,7 +848,7 @@ void QXcbWindow::doFocusOut() connection()->setFocusWindow(nullptr); relayFocusToModalWindow(); // Do not set the active window to nullptr if there is a FocusIn coming. - connection()->focusInTimer().start(400); + connection()->focusInTimer().start(); } struct QtMotifWmHints { -- cgit v1.2.3 From a41701904e880f58e19b352ade1931d6cd1a7112 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Sun, 7 Jul 2019 13:44:26 +0200 Subject: xcb: fix thread synchronization issue in QXcbEventQueue::waitForNewEvents() This patch amends 730cbad8824bcfcb7ab60371a6563cfb6dd5658d The issue was that the event reader thread (QXcbEventQueue::run()) can enqueue events sometime between GUI thread has last time peeked at the queue and before it has called waitForNewEvents() and hence started waiting for more events (via QWaitCondition). This scenario is even mentioned in the QWaitCondition documentation: "[..] if some of the threads are still in do_something() when the key is pressed, they won't be woken up (since they're not waiting on the condition variable) and so the task will not be performed for that key press. [..]" And if there are no more events on the X11 connection, the waitForNewEvents() in QXcbClipboard::waitForClipboardEvent() would timeout. Fixes: QTBUG-75319 Change-Id: I8990a2a0c00571dfc334fb57d616dee999042885 Reviewed-by: Igor Kushnir Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbeventqueue.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbeventqueue.cpp b/src/plugins/platforms/xcb/qxcbeventqueue.cpp index acec0486c2..4ca73e3048 100644 --- a/src/plugins/platforms/xcb/qxcbeventqueue.cpp +++ b/src/plugins/platforms/xcb/qxcbeventqueue.cpp @@ -226,11 +226,13 @@ void QXcbEventQueue::run() }; while (!m_closeConnectionDetected && (event = xcb_wait_for_event(connection))) { + m_newEventsMutex.lock(); enqueueEvent(event); while (!m_closeConnectionDetected && (event = xcb_poll_for_queued_event(connection))) enqueueEvent(event); m_newEventsCondition.wakeOne(); + m_newEventsMutex.unlock(); wakeUpDispatcher(); } @@ -350,9 +352,12 @@ bool QXcbEventQueue::peekEventQueue(PeekerCallback peeker, void *peekerData, void QXcbEventQueue::waitForNewEvents(unsigned long time) { - m_newEventsMutex.lock(); + QMutexLocker locker(&m_newEventsMutex); + QXcbEventNode *tailBeforeFlush = m_flushedTail; + flushBufferedEvents(); + if (tailBeforeFlush != m_flushedTail) + return; m_newEventsCondition.wait(&m_newEventsMutex, time); - m_newEventsMutex.unlock(); } void QXcbEventQueue::sendCloseConnectionEvent() const -- cgit v1.2.3 From e96cea51da99629b33036e4b06738316a7ca4682 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Fri, 5 Jul 2019 17:12:18 +0200 Subject: Fix compilation with disabled deprecated APIs The QImageIOHandler::name() has been deprecated since 5.13, but its overrides weren't. Enabled compilation of the overrides only when the QImageIOHandler::name() is compiled. Task-number: QTBUG-76491 Change-Id: I8fea0032427d25bb0de01be8920c723fc21f6b7a Reviewed-by: Volker Hilsheimer Reviewed-by: Alex Blasche --- src/plugins/imageformats/gif/qgifhandler.cpp | 2 ++ src/plugins/imageformats/gif/qgifhandler_p.h | 2 ++ src/plugins/imageformats/ico/qicohandler.cpp | 3 ++- src/plugins/imageformats/ico/qicohandler.h | 2 ++ src/plugins/imageformats/jpeg/qjpeghandler.cpp | 2 ++ src/plugins/imageformats/jpeg/qjpeghandler_p.h | 2 ++ 6 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index 1aef1a24d2..a6029b691c 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -1215,9 +1215,11 @@ int QGifHandler::currentImageNumber() const return frameNumber; } +#if QT_DEPRECATED_SINCE(5, 13) QByteArray QGifHandler::name() const { return "gif"; } +#endif QT_END_NAMESPACE diff --git a/src/plugins/imageformats/gif/qgifhandler_p.h b/src/plugins/imageformats/gif/qgifhandler_p.h index b004ee610d..c6592043ce 100644 --- a/src/plugins/imageformats/gif/qgifhandler_p.h +++ b/src/plugins/imageformats/gif/qgifhandler_p.h @@ -73,7 +73,9 @@ public: bool read(QImage *image) override; bool write(const QImage &image) override; +#if QT_DEPRECATED_SINCE(5, 13) QByteArray name() const override; +#endif static bool canRead(QIODevice *device); diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 4908850cc5..c8e31dceac 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -818,6 +818,7 @@ bool QtIcoHandler::write(const QImage &image) return ICOReader::write(device, imgs); } +#if QT_DEPRECATED_SINCE(5, 13) /*! * Return the common identifier of the format. * For ICO format this will return "ico". @@ -826,7 +827,7 @@ QByteArray QtIcoHandler::name() const { return "ico"; } - +#endif /*! \reimp diff --git a/src/plugins/imageformats/ico/qicohandler.h b/src/plugins/imageformats/ico/qicohandler.h index 435f036113..328dfce47e 100644 --- a/src/plugins/imageformats/ico/qicohandler.h +++ b/src/plugins/imageformats/ico/qicohandler.h @@ -54,7 +54,9 @@ public: bool read(QImage *image) override; bool write(const QImage &image) override; +#if QT_DEPRECATED_SINCE(5, 13) QByteArray name() const override; +#endif int imageCount() const override; bool jumpToImage(int imageNumber) override; diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index 54fe857908..aed2900356 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -1124,9 +1124,11 @@ void QJpegHandler::setOption(ImageOption option, const QVariant &value) } } +#if QT_DEPRECATED_SINCE(5, 13) QByteArray QJpegHandler::name() const { return "jpeg"; } +#endif QT_END_NAMESPACE diff --git a/src/plugins/imageformats/jpeg/qjpeghandler_p.h b/src/plugins/imageformats/jpeg/qjpeghandler_p.h index d832bf82f3..fafa930c11 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler_p.h +++ b/src/plugins/imageformats/jpeg/qjpeghandler_p.h @@ -68,7 +68,9 @@ public: bool read(QImage *image) override; bool write(const QImage &image) override; +#if QT_DEPRECATED_SINCE(5, 13) QByteArray name() const override; +#endif static bool canRead(QIODevice *device); -- cgit v1.2.3 From 786c58817187bb18552934c807ba7a7ea845f49e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20de=20la=20Rocha?= Date: Wed, 10 Jul 2019 18:09:38 +0200 Subject: Windows QPA: Fix handling of mouse messages synthesized by the OS The old handler only marked mouse events associated with mouse messages synthesized by the OS with Qt::MouseEventSynthesizedBySystem when these messages resulted from touch screen, not tablet input. Quick seems to depend on this behavior. Fixes: QTBUG-76617 Change-Id: Ib863d73ae9325f9a19d8a175817fef4e82f7df0b Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowspointerhandler.cpp | 11 +++++++---- src/plugins/platforms/windows/qwindowspointerhandler.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index b35629e2ce..71a09304c5 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -80,13 +80,12 @@ bool QWindowsPointerHandler::translatePointerEvent(QWindow *window, HWND hwnd, Q *result = 0; const quint32 pointerId = GET_POINTERID_WPARAM(msg.wParam); - POINTER_INPUT_TYPE pointerType; - if (!QWindowsContext::user32dll.getPointerType(pointerId, &pointerType)) { + if (!QWindowsContext::user32dll.getPointerType(pointerId, &m_pointerType)) { qWarning() << "GetPointerType() failed:" << qt_error_string(); return false; } - switch (pointerType) { + switch (m_pointerType) { case QT_PT_POINTER: case QT_PT_MOUSE: case QT_PT_TOUCHPAD: { @@ -728,7 +727,11 @@ bool QWindowsPointerHandler::translateMouseEvent(QWindow *window, } Qt::MouseEventSource source = Qt::MouseEventNotSynthesized; - if (isMouseEventSynthesizedFromPenOrTouch()) { + // Following the logic of the old mouse handler, only events synthesized + // for touch screen are marked as such. On some systems, using the bit 7 of + // the extra msg info for checking if synthesized for touch does not work, + // so we use the pointer type of the last pointer message. + if (isMouseEventSynthesizedFromPenOrTouch() && m_pointerType == QT_PT_TOUCH) { if (QWindowsIntegration::instance()->options() & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch) return false; source = Qt::MouseEventSynthesizedBySystem; diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.h b/src/plugins/platforms/windows/qwindowspointerhandler.h index ccbb1d3939..b6b89cefed 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.h +++ b/src/plugins/platforms/windows/qwindowspointerhandler.h @@ -82,6 +82,7 @@ private: bool m_needsEnterOnPointerUpdate = false; QEvent::Type m_lastEventType = QEvent::None; Qt::MouseButton m_lastEventButton = Qt::NoButton; + DWORD m_pointerType = 0; }; QT_END_NAMESPACE -- cgit v1.2.3 From ae972a19288ddd47ceac2ee2b7b090c4d12f4731 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 5 Jul 2019 15:41:35 +0200 Subject: macOS: show QSystemTrayIcon message icons in notification popups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The icon provided was ignored, even though NSUserNotification provides the option to specify a contentImage. The message popping up will show that image on the right side of the notification; it will not repace the application icon on the left side. [ChangeLog][Widgets][QSystemTrayIcon] On macOS, show the icon passed into showMessage in the notification popup Change-Id: I8ecda7f893006e74a4f35f37ddc07063ebfe4e83 Fixes: QTBUG-76916 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm index 4982f5ee05..16543bfb8c 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -264,7 +264,6 @@ bool QCocoaSystemTrayIcon::supportsMessages() const void QCocoaSystemTrayIcon::showMessage(const QString &title, const QString &message, const QIcon& icon, MessageIcon, int) { - Q_UNUSED(icon); if (!m_sys) return; @@ -272,6 +271,12 @@ void QCocoaSystemTrayIcon::showMessage(const QString &title, const QString &mess notification.title = [NSString stringWithUTF8String:title.toUtf8().data()]; notification.informativeText = [NSString stringWithUTF8String:message.toUtf8().data()]; + if (!icon.isNull()) { + auto *nsimage = qt_mac_create_nsimage(icon); + [nsimage setTemplate:icon.isMask()]; + notification.contentImage = [nsimage autorelease]; + } + [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification]; } QT_END_NAMESPACE -- cgit v1.2.3 From 3c0ba6675b01118aac2fe551470afa3b72a7e969 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 24 Jun 2019 15:02:34 +0200 Subject: Fix warnings as errors on macOS with new Xcode 10.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A switch statement was comparing enum values of a different enum. Change-Id: I578f79b15b1007afaa64cd3a2a80d6a75d3bed77 Reviewed-by: Qt CI Bot Reviewed-by: Tor Arne Vestbø Reviewed-by: Leander Beernaert --- src/plugins/platforms/cocoa/qprintengine_mac.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index f2f29b26ee..58ad53a6e1 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -522,16 +522,16 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va if (mode == property(PPK_Duplex).toInt() || !d->m_printDevice->supportedDuplexModes().contains(mode)) break; switch (mode) { - case QPrinter::DuplexNone: + case QPrint::DuplexNone: PMSetDuplex(d->settings(), kPMDuplexNone); break; - case QPrinter::DuplexAuto: + case QPrint::DuplexAuto: PMSetDuplex(d->settings(), d->m_pageLayout.orientation() == QPageLayout::Landscape ? kPMDuplexTumble : kPMDuplexNoTumble); break; - case QPrinter::DuplexLongSide: + case QPrint::DuplexLongSide: PMSetDuplex(d->settings(), kPMDuplexNoTumble); break; - case QPrinter::DuplexShortSide: + case QPrint::DuplexShortSide: PMSetDuplex(d->settings(), kPMDuplexTumble); break; default: -- cgit v1.2.3 From 72d9222f7bda744f80d3602d3bfe5769ed1f19a8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 13 Jul 2019 10:33:31 +0200 Subject: QWasmFontDatabase: replace QStringList with a C array of strings The content is static, so a dynamic container is overkill. Use a C array. Don't make it static, as that creates more problems than is solves (static initialization). Change-Id: I07534c3336efbb6bbc19bfa1b8dad0c578d4e274 Reviewed-by: Volker Hilsheimer Reviewed-by: Lorn Potter --- src/plugins/platforms/wasm/qwasmfontdatabase.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmfontdatabase.cpp b/src/plugins/platforms/wasm/qwasmfontdatabase.cpp index dc6bb5847e..53e875ead6 100644 --- a/src/plugins/platforms/wasm/qwasmfontdatabase.cpp +++ b/src/plugins/platforms/wasm/qwasmfontdatabase.cpp @@ -38,10 +38,13 @@ void QWasmFontDatabase::populateFontDatabase() // Load font file from resources. Currently // all fonts needs to be bundled with the nexe // as Qt resources. - QStringList fontFileNames = QStringList() << QStringLiteral(":/fonts/DejaVuSansMono.ttf") - << QStringLiteral(":/fonts/Vera.ttf") - << QStringLiteral(":/fonts/DejaVuSans.ttf"); - foreach (const QString &fontFileName, fontFileNames) { + + const QString fontFileNames[] = { + QStringLiteral(":/fonts/DejaVuSansMono.ttf"), + QStringLiteral(":/fonts/Vera.ttf"), + QStringLiteral(":/fonts/DejaVuSans.ttf"), + }; + for (const QString &fontFileName : fontFileNames) { QFile theFont(fontFileName); if (!theFont.open(QIODevice::ReadOnly)) break; -- cgit v1.2.3 From 8155d0693f596c6b73d0acd977d5077dd7a6e6ea Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 13 Jul 2019 14:31:36 +0200 Subject: Eradicate Q_FOREACH in the WASM plugin and mark the plugin free of them The first one is trivially correct: it clearly doesn't modify the container under iteration. The second is a bit more subtle, because drawWindow() could be expected to call a paintEvent and this could theoretically lead to lowering, closing, or opening of a window. But this function just ends up blit()ting, so it doesn't call into user code. Change-Id: Id15e0102e9c8aa12516af27d771104e9993c48a1 Reviewed-by: Volker Hilsheimer Reviewed-by: Lorn Potter --- src/plugins/platforms/wasm/qwasmcompositor.cpp | 4 ++-- src/plugins/platforms/wasm/wasm.pro | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index 6d211667be..a810880c43 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -681,7 +681,7 @@ void QWasmCompositor::frame() QWasmWindow *someWindow = nullptr; - foreach (QWasmWindow *window, m_windowStack) { + for (QWasmWindow *window : qAsConst(m_windowStack)) { if (window->window()->surfaceClass() == QSurface::Window && qt_window_private(static_cast(window->window()))->receivedExpose) { someWindow = window; @@ -715,7 +715,7 @@ void QWasmCompositor::frame() m_blitter->bind(); m_blitter->setRedBlueSwizzle(true); - foreach (QWasmWindow *window, m_windowStack) { + for (QWasmWindow *window : qAsConst(m_windowStack)) { QWasmCompositedWindow &compositedWindow = m_compositedWindows[window]; if (!compositedWindow.visible) diff --git a/src/plugins/platforms/wasm/wasm.pro b/src/plugins/platforms/wasm/wasm.pro index c28df8f893..f8c8175525 100644 --- a/src/plugins/platforms/wasm/wasm.pro +++ b/src/plugins/platforms/wasm/wasm.pro @@ -7,6 +7,8 @@ QT += \ # Avoid X11 header collision, use generic EGL native types DEFINES += QT_EGL_NO_X11 +DEFINES += QT_NO_FOREACH + SOURCES = \ main.cpp \ qwasmintegration.cpp \ -- cgit v1.2.3 From c563e5b3c7f483684da0759a28393b2140541771 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 13 Jul 2019 10:29:36 +0200 Subject: QWasmEventTranslator: replace five QHash with constexpr C arrays The mapping is static, but a dynamic (even mutable) container was used. Fix by using C tables and liner scan, which will be just as fast or faster than a hash lookup, for the maximum of six entries of each table. Change-Id: I899d5b1428dc82cf58862f238595a266aef8279f Reviewed-by: Volker Hilsheimer Reviewed-by: Lorn Potter --- .../platforms/wasm/qwasmeventtranslator.cpp | 64 ++++++++++++++++++++-- src/plugins/platforms/wasm/qwasmeventtranslator.h | 36 ------------ 2 files changed, 59 insertions(+), 41 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index 3895646b89..d165ee5839 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -779,6 +779,60 @@ quint64 QWasmEventTranslator::getTimestamp() return QDeadlineTimer::current().deadlineNSecs() / 1000; } +struct KeyMapping { Qt::Key from, to; }; + +constexpr KeyMapping tildeKeyTable[] = { // ~ + { Qt::Key_A, Qt::Key_Atilde }, + { Qt::Key_N, Qt::Key_Ntilde }, + { Qt::Key_O, Qt::Key_Otilde }, +}; +constexpr KeyMapping graveKeyTable[] = { // ` + { Qt::Key_A, Qt::Key_Agrave }, + { Qt::Key_E, Qt::Key_Egrave }, + { Qt::Key_I, Qt::Key_Igrave }, + { Qt::Key_O, Qt::Key_Ograve }, + { Qt::Key_U, Qt::Key_Ugrave }, +}; +constexpr KeyMapping acuteKeyTable[] = { // ' + { Qt::Key_A, Qt::Key_Aacute }, + { Qt::Key_E, Qt::Key_Eacute }, + { Qt::Key_I, Qt::Key_Iacute }, + { Qt::Key_O, Qt::Key_Oacute }, + { Qt::Key_U, Qt::Key_Uacute }, + { Qt::Key_Y, Qt::Key_Yacute }, +}; +constexpr KeyMapping diaeresisKeyTable[] = { // umlaut ¨ + { Qt::Key_A, Qt::Key_Adiaeresis }, + { Qt::Key_E, Qt::Key_Ediaeresis }, + { Qt::Key_I, Qt::Key_Idiaeresis }, + { Qt::Key_O, Qt::Key_Odiaeresis }, + { Qt::Key_U, Qt::Key_Udiaeresis }, + { Qt::Key_Y, Qt::Key_ydiaeresis }, +}; +constexpr KeyMapping circumflexKeyTable[] = { // ^ + { Qt::Key_A, Qt::Key_Acircumflex }, + { Qt::Key_E, Qt::Key_Ecircumflex }, + { Qt::Key_I, Qt::Key_Icircumflex }, + { Qt::Key_O, Qt::Key_Ocircumflex }, + { Qt::Key_U, Qt::Key_Ucircumflex }, +}; + +static Qt::Key find_impl(const KeyMapping *first, const KeyMapping *last, Qt::Key key) noexcept +{ + while (first != last) { + if (first->from == key) + return first->to; + ++first; + } + return {}; +} + +template +static Qt::Key find(const KeyMapping (&map)[N], Qt::Key key) noexcept +{ + return find_impl(map, map + N, key); +} + Qt::Key QWasmEventTranslator::translateDeadKey(Qt::Key deadKey, Qt::Key accentBaseKey) { Qt::Key wasmKey = Qt::Key_unknown; @@ -788,25 +842,25 @@ Qt::Key QWasmEventTranslator::translateDeadKey(Qt::Key deadKey, Qt::Key accentBa #else case Qt::Key_O: // ´ Key_Dead_Grave #endif - wasmKey = graveKeyTable.value(accentBaseKey); + wasmKey = find(graveKeyTable, accentBaseKey); break; case Qt::Key_E: // ´ Key_Dead_Acute - wasmKey = acuteKeyTable.value(accentBaseKey); + wasmKey = find(acuteKeyTable, accentBaseKey); break; case Qt::Key_AsciiTilde: case Qt::Key_N:// Key_Dead_Tilde - wasmKey = tildeKeyTable.value(accentBaseKey); + wasmKey = find(tildeKeyTable, accentBaseKey); break; #ifndef Q_OS_MACOS case Qt::Key_QuoteLeft: #endif case Qt::Key_U:// ¨ Key_Dead_Diaeresis - wasmKey = diaeresisKeyTable.value(accentBaseKey); + wasmKey = find(diaeresisKeyTable, accentBaseKey); break; case Qt::Key_I:// macOS Key_Dead_Circumflex case Qt::Key_6:// linux case Qt::Key_Apostrophe:// linux - wasmKey = circumflexKeyTable.value(accentBaseKey); + wasmKey = find(circumflexKeyTable, accentBaseKey); break; break; default: diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.h b/src/plugins/platforms/wasm/qwasmeventtranslator.h index 1655b7226a..568ae00732 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.h +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.h @@ -77,42 +77,6 @@ private: Qt::Key translateDeadKey(Qt::Key deadKey, Qt::Key accentBaseKey); - QHash tildeKeyTable { // ~ - { Qt::Key_A, Qt::Key_Atilde}, - { Qt::Key_N, Qt::Key_Ntilde}, - { Qt::Key_O, Qt::Key_Otilde} - }; - QHash graveKeyTable { // ` - { Qt::Key_A, Qt::Key_Agrave}, - { Qt::Key_E, Qt::Key_Egrave}, - { Qt::Key_I, Qt::Key_Igrave}, - { Qt::Key_O, Qt::Key_Ograve}, - { Qt::Key_U, Qt::Key_Ugrave} - }; - QHash acuteKeyTable { // ' - { Qt::Key_A, Qt::Key_Aacute}, - { Qt::Key_E, Qt::Key_Eacute}, - { Qt::Key_I, Qt::Key_Iacute}, - { Qt::Key_O, Qt::Key_Oacute}, - { Qt::Key_U, Qt::Key_Uacute}, - { Qt::Key_Y, Qt::Key_Yacute} - }; - QHash diaeresisKeyTable { // umlaut ¨ - { Qt::Key_A, Qt::Key_Adiaeresis}, - { Qt::Key_E, Qt::Key_Ediaeresis}, - { Qt::Key_I, Qt::Key_Idiaeresis}, - { Qt::Key_O, Qt::Key_Odiaeresis}, - { Qt::Key_U, Qt::Key_Udiaeresis}, - { Qt::Key_Y, Qt::Key_ydiaeresis} - }; - QHash circumflexKeyTable { // ^ - { Qt::Key_A, Qt::Key_Acircumflex}, - { Qt::Key_E, Qt::Key_Ecircumflex}, - { Qt::Key_I, Qt::Key_Icircumflex}, - { Qt::Key_O, Qt::Key_Ocircumflex}, - { Qt::Key_U, Qt::Key_Ucircumflex} - }; - QMap pressedTouchIds; private: -- cgit v1.2.3 From 05bb156aaad8b539e9b28a6c7577e48319e281ba Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 12 Jul 2019 15:28:14 +0200 Subject: Windows QPA: Fix emitting of QScreen's changed signals When changing the primary screen, the various changed signals of QScreen were out of order. Most notably, the wrong DPI value was emitted since QGuiApplicationPrivate::processScreenGeometryChange() checks and emits DPI and orientation as well. Rearrange the code to assign new the values and emit DPI first. Task-number: QTBUG-76902 Change-Id: If4037108391c36ab3a8bfcb9b2989d5bea41202f Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsscreen.cpp | 31 ++++++++++++++---------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index cc0f3c1a6e..4137a4bd9a 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -303,23 +303,28 @@ void QWindowsScreen::handleChanges(const QWindowsScreenData &newData) m_data.hMonitor = newData.hMonitor; } - if (m_data.geometry != newData.geometry || m_data.availableGeometry != newData.availableGeometry) { - m_data.geometry = newData.geometry; - m_data.availableGeometry = newData.availableGeometry; - QWindowSystemInterface::handleScreenGeometryChange(screen(), - newData.geometry, newData.availableGeometry); - } - if (!qFuzzyCompare(m_data.dpi.first, newData.dpi.first) - || !qFuzzyCompare(m_data.dpi.second, newData.dpi.second)) { - m_data.dpi = newData.dpi; + // QGuiApplicationPrivate::processScreenGeometryChange() checks and emits + // DPI and orientation as well, so, assign new values and emit DPI first. + const bool geometryChanged = m_data.geometry != newData.geometry + || m_data.availableGeometry != newData.availableGeometry; + const bool dpiChanged = !qFuzzyCompare(m_data.dpi.first, newData.dpi.first) + || !qFuzzyCompare(m_data.dpi.second, newData.dpi.second); + const bool orientationChanged = m_data.orientation != newData.orientation; + m_data.dpi = newData.dpi; + m_data.orientation = newData.orientation; + m_data.geometry = newData.geometry; + m_data.availableGeometry = newData.availableGeometry; + + if (dpiChanged) { QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(screen(), newData.dpi.first, newData.dpi.second); } - if (m_data.orientation != newData.orientation) { - m_data.orientation = newData.orientation; - QWindowSystemInterface::handleScreenOrientationChange(screen(), - newData.orientation); + if (orientationChanged) + QWindowSystemInterface::handleScreenOrientationChange(screen(), newData.orientation); + if (geometryChanged) { + QWindowSystemInterface::handleScreenGeometryChange(screen(), + newData.geometry, newData.availableGeometry); } } -- cgit v1.2.3 From 7a7fe9dbb3be042b42a559e734df40ffdea7ebbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 16 Jul 2019 23:19:19 +0200 Subject: macOS: Move QCocoaGLContext initialization into dedicated method Change-Id: I9dc2c400c3d26e9fcfaac04b61c1503229f59dba Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoaglcontext.h | 2 ++ src/plugins/platforms/cocoa/qcocoaglcontext.mm | 16 ++++++++++++---- src/plugins/platforms/cocoa/qcocoaintegration.mm | 4 +--- 3 files changed, 15 insertions(+), 7 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index c1041ac2da..bb309c0713 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -56,6 +56,8 @@ public: QCocoaGLContext(QOpenGLContext *context); ~QCocoaGLContext(); + void initialize() override; + bool makeCurrent(QPlatformSurface *surface) override; void swapBuffers(QPlatformSurface *surface) override; void doneCurrent() override; diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index d0100d0410..c0579c7c1e 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -76,9 +76,14 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcQpaOpenGLContext, "qt.qpa.openglcontext", QtWarningMsg); QCocoaGLContext::QCocoaGLContext(QOpenGLContext *context) - : QPlatformOpenGLContext(), m_format(context->format()) + : QPlatformOpenGLContext() + , m_format(context->format()) { - QVariant nativeHandle = context->nativeHandle(); +} + +void QCocoaGLContext::initialize() +{ + QVariant nativeHandle = context()->nativeHandle(); if (!nativeHandle.isNull()) { if (!nativeHandle.canConvert()) { qCWarning(lcQpaOpenGLContext, "QOpenGLContext native handle must be a QCocoaNativeContext"); @@ -95,7 +100,7 @@ QCocoaGLContext::QCocoaGLContext(QOpenGLContext *context) // Note: We have no way of knowing whether the NSOpenGLContext was created with the // share context as reported by the QOpenGLContext, but we just have to trust that // it was. It's okey, as the only thing we're using it for is to report isShared(). - if (QPlatformOpenGLContext *shareContext = context->shareHandle()) + if (QPlatformOpenGLContext *shareContext = context()->shareHandle()) m_shareContext = static_cast(shareContext)->nativeContext(); updateSurfaceFormat(); @@ -110,7 +115,7 @@ QCocoaGLContext::QCocoaGLContext(QOpenGLContext *context) if (m_format.renderableType() != QSurfaceFormat::OpenGL) return; - if (QPlatformOpenGLContext *shareContext = context->shareHandle()) { + if (QPlatformOpenGLContext *shareContext = context()->shareHandle()) { m_shareContext = static_cast(shareContext)->nativeContext(); // Allow sharing between 3.2 Core and 4.1 Core profile versions in @@ -150,6 +155,9 @@ QCocoaGLContext::QCocoaGLContext(QOpenGLContext *context) return; } + // The native handle should reflect the underlying context, even if we created it + context()->setNativeHandle(QVariant::fromValue(m_context)); + // --------------------- Set NSOpenGLContext properties --------------------- const GLint interval = m_format.swapInterval() >= 0 ? m_format.swapInterval() : 1; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index b5d63f8331..dd2d1ba0f1 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -418,9 +418,7 @@ QPlatformOffscreenSurface *QCocoaIntegration::createPlatformOffscreenSurface(QOf #ifndef QT_NO_OPENGL QPlatformOpenGLContext *QCocoaIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { - QCocoaGLContext *glContext = new QCocoaGLContext(context); - context->setNativeHandle(QVariant::fromValue(glContext->nativeContext())); - return glContext; + return new QCocoaGLContext(context); } #endif -- cgit v1.2.3 From d2e4bde5d09816ebedb1a5cc9ec7c0af20fd1242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 16 Jul 2019 23:43:35 +0200 Subject: macOS: Use lambdas instead of Obj-C categories for GL helper functions Allows us to reference captured variables and keeps the function local to where it's used. Change-Id: I609892888720202021862d26a74ceb50e232f356 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoaglcontext.mm | 46 +++++++++++--------------- 1 file changed, 20 insertions(+), 26 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index c0579c7c1e..c5f0762ac2 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -53,24 +53,6 @@ static inline QByteArray getGlString(GLenum param) return QByteArray(); } -@implementation NSOpenGLPixelFormat (QtHelpers) -- (GLint)qt_getAttribute:(NSOpenGLPixelFormatAttribute)attribute -{ - int value = 0; - [self getValues:&value forAttribute:attribute forVirtualScreen:0]; - return value; -} -@end - -@implementation NSOpenGLContext (QtHelpers) -- (GLint)qt_getParameter:(NSOpenGLContextParameter)parameter -{ - int value = 0; - [self getValues:&value forParameter:parameter]; - return value; -} -@end - QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcQpaOpenGLContext, "qt.qpa.openglcontext", QtWarningMsg); @@ -293,7 +275,13 @@ void QCocoaGLContext::updateSurfaceFormat() NSOpenGLPixelFormat *pixelFormat = m_context.pixelFormat; - int colorSize = [pixelFormat qt_getAttribute:NSOpenGLPFAColorSize]; + auto pixelFormatAttribute = [&](NSOpenGLPixelFormatAttribute attribute) { + int value = 0; + [pixelFormat getValues:&value forAttribute:attribute forVirtualScreen:0]; + return value; + }; + + int colorSize = pixelFormatAttribute(NSOpenGLPFAColorSize); colorSize /= 4; // The attribute includes the alpha component m_format.setRedBufferSize(colorSize); m_format.setGreenBufferSize(colorSize); @@ -305,22 +293,28 @@ void QCocoaGLContext::updateSurfaceFormat() // size, as that will make the user believe the alpha channel can be used for // something useful, when in reality it can't, due to the surface being opaque. if (m_format.alphaBufferSize() > 0) - m_format.setAlphaBufferSize([pixelFormat qt_getAttribute:NSOpenGLPFAAlphaSize]); + m_format.setAlphaBufferSize(pixelFormatAttribute(NSOpenGLPFAAlphaSize)); - m_format.setDepthBufferSize([pixelFormat qt_getAttribute:NSOpenGLPFADepthSize]); - m_format.setStencilBufferSize([pixelFormat qt_getAttribute:NSOpenGLPFAStencilSize]); - m_format.setSamples([pixelFormat qt_getAttribute:NSOpenGLPFASamples]); + m_format.setDepthBufferSize(pixelFormatAttribute(NSOpenGLPFADepthSize)); + m_format.setStencilBufferSize(pixelFormatAttribute(NSOpenGLPFAStencilSize)); + m_format.setSamples(pixelFormatAttribute(NSOpenGLPFASamples)); - if ([pixelFormat qt_getAttribute:NSOpenGLPFATripleBuffer]) + if (pixelFormatAttribute(NSOpenGLPFATripleBuffer)) m_format.setSwapBehavior(QSurfaceFormat::TripleBuffer); - else if ([pixelFormat qt_getAttribute:NSOpenGLPFADoubleBuffer]) + else if (pixelFormatAttribute(NSOpenGLPFADoubleBuffer)) m_format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); else m_format.setSwapBehavior(QSurfaceFormat::SingleBuffer); // ------------------- Query the context ------------------- - m_format.setSwapInterval([m_context qt_getParameter:NSOpenGLCPSwapInterval]); + auto glContextParameter = [&](NSOpenGLContextParameter parameter) { + int value = 0; + [m_context getValues:&value forParameter:parameter]; + return value; + }; + + m_format.setSwapInterval(glContextParameter(NSOpenGLCPSwapInterval)); if (oldContext) [oldContext makeCurrentContext]; -- cgit v1.2.3 From d224c762bc9530236d255cc5cb851112fcc7cee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 16 Jul 2019 23:45:48 +0200 Subject: macOS: Use correct virtual screen when resolving GL surface format Change-Id: I8288db85c8e99bf9fccfcfbca7f9e3594d00fa48 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoaglcontext.mm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index c5f0762ac2..e45ea7efd3 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -40,6 +40,8 @@ #include "qcocoaglcontext.h" #include "qcocoawindow.h" #include "qcocoahelpers.h" +#include "qcocoascreen.h" + #include #include #include @@ -275,9 +277,28 @@ void QCocoaGLContext::updateSurfaceFormat() NSOpenGLPixelFormat *pixelFormat = m_context.pixelFormat; + GLint virtualScreen = [&, this]() { + auto *platformScreen = static_cast(context()->screen()->handle()); + auto displayId = platformScreen->nativeScreen().qt_displayId; + auto requestedDisplay = CGDisplayIDToOpenGLDisplayMask(displayId); + for (int i = 0; i < pixelFormat.numberOfVirtualScreens; ++i) { + GLint supportedDisplays; + [pixelFormat getValues:&supportedDisplays forAttribute:NSOpenGLPFAScreenMask forVirtualScreen:i]; + // Note: The mask returned for NSOpenGLPFAScreenMask is a bit mask of + // physical displays that the renderer can drive, while the one returned + // from CGDisplayIDToOpenGLDisplayMask has a single bit set, representing + // that particular display. + if (requestedDisplay & supportedDisplays) + return i; + } + qCWarning(lcQpaOpenGLContext) << "Could not find virtual screen for" + << platformScreen << "with displayId" << displayId; + return 0; + }(); + auto pixelFormatAttribute = [&](NSOpenGLPixelFormatAttribute attribute) { int value = 0; - [pixelFormat getValues:&value forAttribute:attribute forVirtualScreen:0]; + [pixelFormat getValues:&value forAttribute:attribute forVirtualScreen:virtualScreen]; return value; }; -- cgit v1.2.3 From a7d7f7155098d7c8e9d457ac411077b5d9121afb Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 15 Jul 2019 07:35:46 +0200 Subject: QWasmEventTranslator: return Key_unknown, not 0x00, when a key isn't found This matches what translateDeadKey() returns for unhandled keys, and processKeyboard() checks for when replacing qtKey with the result of translateDeadKey(). Change-Id: I1500576b7b31047a7a35633a15cd6975b77d842d Reviewed-by: Volker Hilsheimer --- src/plugins/platforms/wasm/qwasmeventtranslator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index d165ee5839..a34b957537 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -824,7 +824,7 @@ static Qt::Key find_impl(const KeyMapping *first, const KeyMapping *last, Qt::Ke return first->to; ++first; } - return {}; + return Qt::Key_unknown; } template -- cgit v1.2.3 From de775f2e62157a6d572b4c363bee48b84d3be630 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 12 Jul 2019 12:22:30 +0200 Subject: macOS: activate correct object when using multiple QSystemTrayIcons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since we need to set the delegate on the defaultUserNotificationCenter, which is a gobal object, we have to update the delegate when we show the message. Otherwise, the last delegate created and set will receive the notification, and the last QSystemTrayIcon created will emit the activated signal. Before clearing the delegate upon destruction, make sure that it's the right item first. Also updating coding style in the respective parts of the code, and plugging a memory leak. Change-Id: Ife62ae0776a5a610a6fd735b2959b807c3a410c7 Fixes: QTBUG-77003 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm index 16543bfb8c..597cfa8318 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -118,11 +118,13 @@ class QSystemTrayIconSys public: QSystemTrayIconSys(QCocoaSystemTrayIcon *sys) { item = [[QNSStatusItem alloc] initWithSysTray:sys]; - [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:item]; + NSUserNotificationCenter.defaultUserNotificationCenter.delegate = item; } ~QSystemTrayIconSys() { [[[item item] view] setHidden: YES]; - [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:nil]; + NSUserNotificationCenter *center = NSUserNotificationCenter.defaultUserNotificationCenter; + if (center.delegate == item) + center.delegate = nil; [item release]; } QNSStatusItem *item; @@ -277,7 +279,10 @@ void QCocoaSystemTrayIcon::showMessage(const QString &title, const QString &mess notification.contentImage = [nsimage autorelease]; } - [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification]; + NSUserNotificationCenter *center = NSUserNotificationCenter.defaultUserNotificationCenter; + center.delegate = m_sys->item; + [center deliverNotification:notification]; + [notification release]; } QT_END_NAMESPACE -- cgit v1.2.3 From af683471bde93d1859544e7fd4c0638995b1fd5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 17 Jul 2019 18:09:47 +0200 Subject: macOS: Add QCocoaWindowManager for dealing with window levels Moves and improves the logic for lowering splash screens to a dedicated window manager, which will learn more tricks in patches to come. Change-Id: I8b8fd1dd78fdaf6f106a59c84d2a59254f3539c3 Reviewed-by: Volker Hilsheimer Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/cocoa.pro | 2 + src/plugins/platforms/cocoa/qcocoaintegration.mm | 19 ---- src/plugins/platforms/cocoa/qcocoawindowmanager.h | 63 ++++++++++++ src/plugins/platforms/cocoa/qcocoawindowmanager.mm | 108 +++++++++++++++++++++ 4 files changed, 173 insertions(+), 19 deletions(-) create mode 100644 src/plugins/platforms/cocoa/qcocoawindowmanager.h create mode 100644 src/plugins/platforms/cocoa/qcocoawindowmanager.mm (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 083b7c1655..02e00039ae 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -6,6 +6,7 @@ SOURCES += main.mm \ qcocoatheme.mm \ qcocoabackingstore.mm \ qcocoawindow.mm \ + qcocoawindowmanager.mm \ qnsview.mm \ qnswindow.mm \ qnswindowdelegate.mm \ @@ -41,6 +42,7 @@ HEADERS += qcocoaintegration.h \ qcocoatheme.h \ qcocoabackingstore.h \ qcocoawindow.h \ + qcocoawindowmanager.h \ qnsview.h \ qnswindow.h \ qnswindowdelegate.h \ diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index dd2d1ba0f1..1eed6b5582 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -217,25 +217,6 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) connect(qGuiApp, &QGuiApplication::focusWindowChanged, this, &QCocoaIntegration::focusWindowChanged); - - static auto splashScreenHider = QMacKeyValueObserver(NSApp, @"modalWindow", []{ - const QWindowList allWindows = QGuiApplication::topLevelWindows(); - for (QWindow *window : allWindows) { - if ((window->flags() & Qt::SplashScreen) == Qt::SplashScreen) { - QCocoaWindow *platformWindow = static_cast(window->handle()); - NSWindow *splashWindow = platformWindow->view().window; - if (!splashWindow) - continue; - if (NSApp.modalWindow) { - NSInteger originalLevel = splashWindow.level; - splashWindow.level = NSNormalWindowLevel; - window->setProperty("_q_levelBeforeModalSession", (qlonglong)originalLevel); - } else if (NSInteger originalLevel = window->property("_q_levelBeforeModalSession").toLongLong()) { - splashWindow.level = originalLevel; - } - } - } - }); } QCocoaIntegration::~QCocoaIntegration() diff --git a/src/plugins/platforms/cocoa/qcocoawindowmanager.h b/src/plugins/platforms/cocoa/qcocoawindowmanager.h new file mode 100644 index 0000000000..54f17eeccd --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoawindowmanager.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOCOAWINDOWMANAGER_H +#define QCOCOAWINDOWMANAGER_H + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QCocoaWindowManager +{ +public: + static QCocoaWindowManager *instance(); + +private: + QCocoaWindowManager(); + void initialize(); + + void modalSessionChanged(); +}; + +QT_END_NAMESPACE + +#endif // QCOCOAWINDOWMANAGER_H diff --git a/src/plugins/platforms/cocoa/qcocoawindowmanager.mm b/src/plugins/platforms/cocoa/qcocoawindowmanager.mm new file mode 100644 index 0000000000..879bfaa546 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoawindowmanager.mm @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcocoawindowmanager.h" +#include "qcocoawindow.h" + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +QCocoaWindowManager *QCocoaWindowManager::instance() +{ + static auto *instance = new QCocoaWindowManager; + return instance; +} + +QCocoaWindowManager::QCocoaWindowManager() +{ + if (NSApp) { + initialize(); + } else { + static auto applicationDidFinishLaunching(QMacNotificationObserver(nil, + NSApplicationDidFinishLaunchingNotification, [this] { initialize(); })); + } +} + +void QCocoaWindowManager::initialize() +{ + Q_ASSERT(NSApp); + + // Whenever the modalWindow property of NSApplication changes we have a new + // modal session running. Observing the app modal window instead of our own + // event dispatcher sessions allows us to track session started by native + // APIs as well. We need to check the initial state as well, in case there + // is already a modal session running. + static auto modalSessionObserver(QMacKeyValueObserver( + NSApp, @"modalWindow", [this] { modalSessionChanged(); }, + NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew)); +} + +void QCocoaWindowManager::modalSessionChanged() +{ + // Make sure that no window is overlapping the modal window. This can + // happen for e.g. splash screens, which have the NSPopUpMenuWindowLevel. + for (auto *window : QGuiApplication::topLevelWindows()) { + auto *platformWindow = static_cast(window->handle()); + if (!platformWindow) + continue; + + auto naturalWindowLevel = platformWindow->windowLevel(window->flags()); + if (naturalWindowLevel > NSModalPanelWindowLevel) { + NSWindow *nativeWindow = platformWindow->nativeWindow(); + if (NSApp.modalWindow) { + // Lower window to that of the modal windows, but no less + nativeWindow.level = NSModalPanelWindowLevel; + [nativeWindow orderBack:nil]; + } else { + // Restore window's natural window level, whatever that was + nativeWindow.level = naturalWindowLevel; + } + } + } +} + +static void initializeWindowManager() { Q_UNUSED(QCocoaWindowManager::instance()); } +Q_CONSTRUCTOR_FUNCTION(initializeWindowManager) + +QT_END_NAMESPACE + -- cgit v1.2.3 From c5ab86976b8836f3c4beff22a5138eb6f72c2c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 18 Jul 2019 13:35:35 +0200 Subject: macOS: Modernize and clarify transient parent window level inheritance Task-number: QTBUG-71480 Change-Id: Ia026427844a674f6b36804571a897dc6f16364fa Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 36 +++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index dc7319484e..42b662cfe4 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -453,13 +453,35 @@ NSInteger QCocoaWindow::windowLevel(Qt::WindowFlags flags) if (type == Qt::ToolTip) windowLevel = NSScreenSaverWindowLevel; - // Any "special" window should be in at least the same level as its parent. - if (type != Qt::Window) { - const QWindow * const transientParent = window()->transientParent(); - const QCocoaWindow * const transientParentWindow = transientParent ? - static_cast(transientParent->handle()) : nullptr; - if (transientParentWindow) - windowLevel = qMax([transientParentWindow->nativeWindow() level], windowLevel); + auto *transientParent = window()->transientParent(); + if (transientParent && transientParent->handle()) { + // We try to keep windows in at least the same window level as + // their transient parent. Unfortunately this only works when the + // window is created. If the window level changes after that, as + // a result of a call to setWindowFlags, or by changing the level + // of the native window, we will not pick this up, and the window + // will be left behind (or in a different window level than) its + // parent. We could KVO-observe the window level of our transient + // parent, but that requires us to know when the parent goes away + // so that we can unregister the observation before the parent is + // dealloced, something we can't do for generic NSWindows. Another + // way would be to override [NSWindow setLevel:] and notify child + // windows about the change, but that doesn't work for foreign + // windows, which can still be transient parents via fromWinId(). + // One area where this problem is apparent is when AppKit tweaks + // the window level of modal windows during application activation + // and deactivation. Since we don't pick up on these window level + // changes in a generic way, we need to add logic explicitly to + // re-evaluate the window level after AppKit has done its tweaks. + + auto *transientCocoaWindow = static_cast(transientParent->handle()); + auto *nsWindow = transientCocoaWindow->nativeWindow(); + + // We only upgrade the window level for "special" windows, to work + // around Qt Designer parenting the designer windows to the widget + // palette window (QTBUG-31779). This should be fixed in designer. + if (type != Qt::Window) + windowLevel = qMax(windowLevel, nsWindow.level); } return windowLevel; -- cgit v1.2.3 From 857e4881c66b5db5c8cab654d33fafe5db55396c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 26 Jun 2019 12:56:12 +0200 Subject: macOS: Properly unpolish font and palette Explicitly setting the application font and palette will actually persist the current state of the application font and palette to the widget, and it will stop reacting to system style changes. Change-Id: Ib856fe86cd3edb618b7ee5819d6c6c892c61fd1d Reviewed-by: Timur Pocheptsov --- src/plugins/styles/mac/qmacstyle_mac.mm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index ce08725684..e10aa33623 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -2139,10 +2139,9 @@ void QMacStyle::unpolish(QWidget* w) #if QT_CONFIG(menu) qobject_cast(w) && #endif - !w->testAttribute(Qt::WA_SetPalette)) { - QPalette pal = qApp->palette(w); - w->setPalette(pal); - w->setAttribute(Qt::WA_SetPalette, false); + !w->testAttribute(Qt::WA_SetPalette)) + { + w->setPalette(QPalette()); w->setWindowOpacity(1.0); } @@ -2158,9 +2157,9 @@ void QMacStyle::unpolish(QWidget* w) #if QT_CONFIG(tabbar) if (qobject_cast(w)) { if (!w->testAttribute(Qt::WA_SetFont)) - w->setFont(qApp->font(w)); + w->setFont(QFont()); if (!w->testAttribute(Qt::WA_SetPalette)) - w->setPalette(qApp->palette(w)); + w->setPalette(QPalette()); } #endif -- cgit v1.2.3 From 547f216efdef3667b0b23ecddce93e5184806800 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Tue, 16 Jul 2019 14:51:02 +1000 Subject: wasm: fix international dead keys Emscripten has changed the key code to include the string 'Digit' on numerals. We use this to detect and translate any Dead keys that may be pressed. Fixes: QTBUG-77041 Change-Id: I054e98a6cf66390b1154f25fe385e5b12840851f Reviewed-by: Volker Hilsheimer --- .../platforms/wasm/qwasmeventtranslator.cpp | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index 3895646b89..43e82435cf 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -138,16 +138,16 @@ static constexpr const auto KeyTbl = qMakeArray( Emkb2Qt< Qt::Key_Minus, '-' >, Emkb2Qt< Qt::Key_Period, '.' >, Emkb2Qt< Qt::Key_Slash, '/' >, - Emkb2Qt< Qt::Key_0, '0' >, - Emkb2Qt< Qt::Key_1, '1' >, - Emkb2Qt< Qt::Key_2, '2' >, - Emkb2Qt< Qt::Key_3, '3' >, - Emkb2Qt< Qt::Key_4, '4' >, - Emkb2Qt< Qt::Key_5, '5' >, - Emkb2Qt< Qt::Key_6, '6' >, - Emkb2Qt< Qt::Key_7, '7' >, - Emkb2Qt< Qt::Key_8, '8' >, - Emkb2Qt< Qt::Key_9, '9' >, + Emkb2Qt< Qt::Key_0, 'D','i','g','i','t','0' >, + Emkb2Qt< Qt::Key_1, 'D','i','g','i','t','1' >, + Emkb2Qt< Qt::Key_2, 'D','i','g','i','t','2' >, + Emkb2Qt< Qt::Key_3, 'D','i','g','i','t','3' >, + Emkb2Qt< Qt::Key_4, 'D','i','g','i','t','4' >, + Emkb2Qt< Qt::Key_5, 'D','i','g','i','t','5' >, + Emkb2Qt< Qt::Key_6, 'D','i','g','i','t','6' >, + Emkb2Qt< Qt::Key_7, 'D','i','g','i','t','7' >, + Emkb2Qt< Qt::Key_8, 'D','i','g','i','t','8' >, + Emkb2Qt< Qt::Key_9, 'D','i','g','i','t','9' >, Emkb2Qt< Qt::Key_Semicolon, ';' >, Emkb2Qt< Qt::Key_Equal, '=' >, Emkb2Qt< Qt::Key_A, 'K','e','y','A' >, @@ -432,7 +432,8 @@ Qt::Key QWasmEventTranslator::translateEmscriptKey(const EmscriptenKeyboardEvent { Qt::Key qtKey = Qt::Key_unknown; - if (qstrncmp(emscriptKey->code, "Key", 3) == 0 || qstrncmp(emscriptKey->code, "Numpad", 6) == 0) { + if (qstrncmp(emscriptKey->code, "Key", 3) == 0 || qstrncmp(emscriptKey->code, "Numpad", 6) == 0 || + qstrncmp(emscriptKey->code, "Digit", 5) == 0) { emkb2qt_t searchKey{emscriptKey->code, 0}; // search emcsripten code auto it1 = std::lower_bound(KeyTbl.cbegin(), KeyTbl.cend(), searchKey); @@ -808,11 +809,10 @@ Qt::Key QWasmEventTranslator::translateDeadKey(Qt::Key deadKey, Qt::Key accentBa case Qt::Key_Apostrophe:// linux wasmKey = circumflexKeyTable.value(accentBaseKey); break; - break; default: break; - }; + }; return wasmKey; } -- cgit v1.2.3 From 589d96b9b06a4a7d0dca03a06c80716318761277 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 24 Jun 2019 15:38:45 +0200 Subject: winrt: Remove QWinrtScreen::pixelDensity so that the default of 1.0 is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Winrt does device independent scaling by default so that overwriting pixelDensity for QWinrtScreen will break the use case of setting Qt::AA_EnableHighDpiScaling. That mode is basically always active on winrt. Task-number: QTBUG-76363 Change-Id: Ib522201850d17757be4a80aa819c3f1245ca7147 Reviewed-by: Maurice Kalinowski Reviewed-by: André de la Rocha --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 6 ------ src/plugins/platforms/winrt/qwinrtscreen.h | 1 - 2 files changed, 7 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index e611c7be24..342e142a74 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -669,12 +669,6 @@ QDpi QWinRTScreen::logicalDpi() const return QDpi(d->logicalDpi, d->logicalDpi); } -qreal QWinRTScreen::pixelDensity() const -{ - Q_D(const QWinRTScreen); - return qMax(1, qRound(d->logicalDpi / 96)); -} - qreal QWinRTScreen::scaleFactor() const { Q_D(const QWinRTScreen); diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h index 63c254940d..6b57780fa1 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.h +++ b/src/plugins/platforms/winrt/qwinrtscreen.h @@ -96,7 +96,6 @@ public: QImage::Format format() const override; QSizeF physicalSize() const override; QDpi logicalDpi() const override; - qreal pixelDensity() const override; qreal scaleFactor() const; QPlatformCursor *cursor() const override; Qt::KeyboardModifiers keyboardModifiers() const; -- cgit v1.2.3 From 0ce3f7d62b93427ca5d0f4284ba774691cbbd4a7 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 24 Jul 2019 15:47:28 +0200 Subject: QMacStyle: workaround NSSliderCell's cached/stale geometry It's a bit cheesy solution, but works as I've noticed first on QSlider's with a ticks direction 'both'. Works because we were already using numberOfTickMarks property to trigger a special behavior for HIG non-compliant widgets. Works for our case too - we trigger a geometry update. Fixes: QTBUG-76811 Change-Id: I2cbf00d42d98e78519b281d138a2f74227ef5449 Reviewed-by: Volker Hilsheimer --- src/plugins/styles/mac/qmacstyle_mac.mm | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index e10aa33623..1d88d2c647 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -137,6 +137,8 @@ #include #include +#include + QT_USE_NAMESPACE static QWindow *qt_getWindow(const QWidget *widget) @@ -514,6 +516,37 @@ static bool setupSlider(NSSlider *slider, const QStyleOptionSlider *sl) return true; } +static void fixStaleGeometry(NSSlider *slider) +{ + // If it's later fixed in AppKit, this function is not needed. + // On macOS Mojave we suddenly have NSSliderCell with a cached + // (and stale) geometry, thus its -drawKnob, -drawBarInside:flipped:, + // -drawTickMarks fail to render the slider properly. Setting the number + // of tickmarks triggers an update in geometry. + + Q_ASSERT(slider); + + if (QOperatingSystemVersion::current() < QOperatingSystemVersion::MacOSMojave) + return; + + NSSliderCell *cell = slider.cell; + const NSRect barRect = [cell barRectFlipped:NO]; + const NSSize sliderSize = slider.frame.size; + CGFloat difference = 0.; + if (slider.vertical) + difference = std::abs(sliderSize.height - barRect.size.height); + else + difference = std::abs(sliderSize.width - barRect.size.width); + + if (difference > 6.) { + // Stale ... + const auto nOfTicks = slider.numberOfTickMarks; + // Non-zero, different from nOfTicks to force update + slider.numberOfTickMarks = nOfTicks + 10; + slider.numberOfTickMarks = nOfTicks; + } +} + static bool isInMacUnifiedToolbarArea(QWindow *window, int windowY) { QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); @@ -5318,6 +5351,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex #endif { [slider calcSize]; + if (!hasDoubleTicks) + fixStaleGeometry(slider); NSSliderCell *cell = slider.cell; const int numberOfTickMarks = slider.numberOfTickMarks; -- cgit v1.2.3 From a2fa624c793e0c571ac2f56d6a4786060d70bc47 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Wed, 24 Jul 2019 14:22:46 +0200 Subject: Revert "eglfs: Add vsync support when using NVIDIA eglstreams" This reverts commit df2b76046de4af7a47fa8303d5f261e3c5d120fe. The patches causes high cpu load and it looks like vsync is done by newer NVIDIA drivers out of the box without such a implementation. Change-Id: I41c9cfcf1bbdf7da9b764394e4442768084e9a35 Fixes: QTBUG-74866 Reviewed-by: Laszlo Agocs --- .../qeglfskmsegldeviceintegration.cpp | 50 ---------------------- .../qeglfskmsegldeviceintegration.h | 2 - 2 files changed, 52 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp index 2c6b4245b7..3e78196227 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp @@ -114,20 +114,16 @@ public: : QEglFSWindow(w) , m_integration(integration) , m_egl_stream(EGL_NO_STREAM_KHR) - , m_framePending(false) { } ~QEglFSKmsEglDeviceWindow() { destroy(); } void invalidateSurface() override; void resetSurface() override; - void flip(); - static void pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data); const QEglFSKmsEglDeviceIntegration *m_integration; EGLStreamKHR m_egl_stream; EGLint m_latency; - bool m_framePending; }; void QEglFSKmsEglDeviceWindow::invalidateSurface() @@ -148,9 +144,6 @@ void QEglFSKmsEglDeviceWindow::resetSurface() streamAttribs[streamAttribCount++] = EGL_STREAM_FIFO_LENGTH_KHR; streamAttribs[streamAttribCount++] = fifoLength; } - - streamAttribs[streamAttribCount++] = EGL_CONSUMER_AUTO_ACQUIRE_EXT; - streamAttribs[streamAttribCount++] = EGL_FALSE; streamAttribs[streamAttribCount++] = EGL_NONE; m_egl_stream = m_integration->m_funcs->create_stream(display, streamAttribs); @@ -248,49 +241,6 @@ void QEglFSKmsEglDeviceWindow::resetSurface() qCDebug(qLcEglfsKmsDebug, "Created stream producer surface %p", m_surface); } -void QEglFSKmsEglDeviceWindow::flip() -{ - EGLDisplay display = screen()->display(); - - EGLAttrib acquire_attribs[3] = { EGL_NONE }; - - acquire_attribs[0] = EGL_DRM_FLIP_EVENT_DATA_NV; - acquire_attribs[1] = (EGLAttrib)this; - acquire_attribs[2] = EGL_NONE; - - if (m_egl_stream != EGL_NO_STREAM_KHR) - if (!m_integration->m_funcs->acquire_stream_attrib_nv(display, m_egl_stream, acquire_attribs)) - qWarning("eglStreamConsumerAcquireAttribNV failed: eglError: %x", eglGetError()); - - m_framePending = true; - - while (m_framePending) { - drmEventContext drmEvent; - memset(&drmEvent, 0, sizeof(drmEvent)); - drmEvent.version = 3; - drmEvent.vblank_handler = nullptr; - drmEvent.page_flip_handler = pageFlipHandler; - drmHandleEvent(m_integration->m_device->fd(), &drmEvent); - } -} - -void QEglFSKmsEglDeviceWindow::pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data) -{ - Q_UNUSED(fd); - Q_UNUSED(sequence); - Q_UNUSED(tv_sec); - Q_UNUSED(tv_usec); - - QEglFSKmsEglDeviceWindow *window = static_cast(user_data); - window->m_framePending = false; -} - -void QEglFSKmsEglDeviceIntegration::presentBuffer(QPlatformSurface *surface) -{ - QEglFSKmsEglDeviceWindow *eglWindow = static_cast(surface); - eglWindow->flip(); -} - QEglFSWindow *QEglFSKmsEglDeviceIntegration::createWindow(QWindow *window) const { QEglFSKmsEglDeviceWindow *eglWindow = new QEglFSKmsEglDeviceWindow(window, this); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h index a5697ec831..5819d82ebf 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h @@ -62,8 +62,6 @@ public: bool supportsPBuffers() const override; QEglFSWindow *createWindow(QWindow *window) const override; - void presentBuffer(QPlatformSurface *surface) override; - EGLDeviceEXT eglDevice() const { return m_egl_device; } protected: -- cgit v1.2.3 From 5b3c09e35f71b5d848ee7554517d95deb9b577c7 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 26 Jul 2019 09:30:01 +0200 Subject: QMacStyle - another slider fix As a follow-up to fixed resize handling: the trick Gabriel wanted to use to enforce a specific look on a slider's bar, never actually worked due to misplaced statement which essentially is cancelling the 'magic' before the bar is drawn. Now it's fixed: bar is centered (between the rows of tickmarks above and below) + it's had a nice blue filling back! Change-Id: I3021c2b86e4c25981eeee015e32baa24ccebc3bd Reviewed-by: Volker Hilsheimer --- src/plugins/styles/mac/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 1d88d2c647..1ff1c22788 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -5362,10 +5362,10 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex const CGRect barRect = [cell barRectFlipped:hasTicks]; if (drawBar) { + [cell drawBarInside:barRect flipped:!verticalFlip]; // This ain't HIG kosher: force unfilled bar look. if (hasDoubleTicks) slider.numberOfTickMarks = numberOfTickMarks; - [cell drawBarInside:barRect flipped:!verticalFlip]; } if (hasTicks && drawTicks) { -- cgit v1.2.3 From e6498362fde937259295e9b2ddbe9b59136f47ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 25 Jul 2019 16:06:02 +0200 Subject: macOS: Respect color space set on NSWindow when flushing backingstore By default Qt tries to avoid potentially costly color matching by not assigning an sRGB color space to our backingstore, even if that's what we in practice fill it with. We used to do this by assigning the display's color space, which effectively opts out of color matching, similar to the old behavior of the device RGB color space (which nowadays implies sRGB). By picking up the color space from the NSWindow instead, we allow the user to override the color space to trigger color matching, for example by explicitly setting it to NSColorSpace.sRGBColorSpace. NSWindow will fall back to the screen's color space if the window doesn't have one set. Task-number: QTBUG-47660 Change-Id: Iac8177e85e86fe9044a41eb2c93fbf26bb83c248 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Timur Pocheptsov Reviewed-by: Simon Hausmann --- src/plugins/platforms/cocoa/qcocoabackingstore.h | 11 +++++++-- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 30 ++++++++++++++--------- 2 files changed, 28 insertions(+), 13 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h index 2398e6351e..9be6814ae7 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.h +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h @@ -49,7 +49,14 @@ QT_BEGIN_NAMESPACE -class QNSWindowBackingStore : public QRasterBackingStore +class QCocoaBackingStore : public QRasterBackingStore +{ +protected: + QCocoaBackingStore(QWindow *window); + QCFType colorSpace() const; +}; + +class QNSWindowBackingStore : public QCocoaBackingStore { public: QNSWindowBackingStore(QWindow *window); @@ -64,7 +71,7 @@ private: void redrawRoundedBottomCorners(CGRect) const; }; -class QCALayerBackingStore : public QPlatformBackingStore +class QCALayerBackingStore : public QCocoaBackingStore { public: QCALayerBackingStore(QWindow *window); diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 78aa98094c..af50aabe15 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -48,11 +48,24 @@ QT_BEGIN_NAMESPACE -QNSWindowBackingStore::QNSWindowBackingStore(QWindow *window) +QCocoaBackingStore::QCocoaBackingStore(QWindow *window) : QRasterBackingStore(window) { } +QCFType QCocoaBackingStore::colorSpace() const +{ + NSView *view = static_cast(window()->handle())->view(); + return QCFType::constructFromGet(view.window.colorSpace.CGColorSpace); +} + +// ---------------------------------------------------------------------------- + +QNSWindowBackingStore::QNSWindowBackingStore(QWindow *window) + : QCocoaBackingStore(window) +{ +} + QNSWindowBackingStore::~QNSWindowBackingStore() { } @@ -175,11 +188,10 @@ void QNSWindowBackingStore::flush(QWindow *window, const QRegion ®ion, const Q_ASSERT_X(graphicsContext, "QCocoaBackingStore", "Focusing the view should give us a current graphics context"); - // Prevent potentially costly color conversion by assigning the display color space - // to the backingstore image. This does not copy the underlying image data. - CGColorSpaceRef displayColorSpace = view.window.screen.colorSpace.CGColorSpace; + // Tag backingstore image with color space based on the window. + // Note: This does not copy the underlying image data. QCFType cgImage = CGImageCreateCopyWithColorSpace( - QCFType(m_image.toCGImage()), displayColorSpace); + QCFType(m_image.toCGImage()), colorSpace()); // Create temporary image to use for blitting, without copying image data NSImage *backingStoreImage = [[[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize] autorelease]; @@ -305,7 +317,7 @@ template constexpr backwards_t backwards(R&& r) { return {std::forward(r)}; } QCALayerBackingStore::QCALayerBackingStore(QWindow *window) - : QPlatformBackingStore(window) + : QCocoaBackingStore(window) { qCDebug(lcQpaBackingStore) << "Creating QCALayerBackingStore for" << window; m_buffers.resize(1); @@ -444,11 +456,7 @@ bool QCALayerBackingStore::recreateBackBufferIfNeeded() << "based on requested" << m_requestedSize << "and dpr =" << devicePixelRatio; static auto pixelFormat = QImage::toPixelFormat(QImage::Format_ARGB32_Premultiplied); - - NSView *view = static_cast(window()->handle())->view(); - auto colorSpace = QCFType::constructFromGet(view.window.screen.colorSpace.CGColorSpace); - - m_buffers.back().reset(new GraphicsBuffer(requestedBufferSize, devicePixelRatio, pixelFormat, colorSpace)); + m_buffers.back().reset(new GraphicsBuffer(requestedBufferSize, devicePixelRatio, pixelFormat, colorSpace())); return true; } -- cgit v1.2.3 From 7138d6fd6bba2c2e55d02bccf7fd0c6c287eab29 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 22 Jul 2019 15:50:49 +0200 Subject: QWinRTFileEngine: Implement setSize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-77132 Change-Id: Ic0410297a2215f1b7b656966cbe84b925706532f Reviewed-by: André de la Rocha Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/winrt/qwinrtfileengine.cpp | 23 +++++++++++++++++++++++ src/plugins/platforms/winrt/qwinrtfileengine.h | 1 + 2 files changed, 24 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/winrt/qwinrtfileengine.cpp b/src/plugins/platforms/winrt/qwinrtfileengine.cpp index 3014b30c38..e9b2a82763 100644 --- a/src/plugins/platforms/winrt/qwinrtfileengine.cpp +++ b/src/plugins/platforms/winrt/qwinrtfileengine.cpp @@ -257,6 +257,29 @@ qint64 QWinRTFileEngine::size() const return qint64(size); } +bool QWinRTFileEngine::setSize(qint64 size) +{ + Q_D(QWinRTFileEngine); + if (!d->stream) { + setError(QFileDevice::ResizeError, QLatin1String("File must be open to be resized")); + return false; + } + + if (size < 0) { + setError(QFileDevice::ResizeError, QLatin1String("File size cannot be negative")); + return false; + } + + HRESULT hr = d->stream->put_Size(static_cast(size)); + RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::ResizeError, false); + if (!flush()) { + setError(QFileDevice::ResizeError, QLatin1String("Could not flush file")); + return false; + } + + return true; +} + qint64 QWinRTFileEngine::pos() const { Q_D(const QWinRTFileEngine); diff --git a/src/plugins/platforms/winrt/qwinrtfileengine.h b/src/plugins/platforms/winrt/qwinrtfileengine.h index 4485917c9e..453565a95a 100644 --- a/src/plugins/platforms/winrt/qwinrtfileengine.h +++ b/src/plugins/platforms/winrt/qwinrtfileengine.h @@ -79,6 +79,7 @@ public: bool close() override; bool flush() override; qint64 size() const override; + bool setSize(qint64 size) override; qint64 pos() const override; bool seek(qint64 pos) override; bool remove() override; -- cgit v1.2.3 From adab531771a1ddce7df6652449b7977f340ebfc7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 26 Jul 2019 22:18:40 +0300 Subject: Port from QStringViewLiteral to u"" Now that all our supported compilers know char16_t, we no longer need QStringViewLiteral, whose only purpose in life was to turn u"" into L"" for MSVC < 2015. Change-Id: I25a094fe7992d9d5dbeb4a524d9e99e043dcb8ce Reviewed-by: Volker Hilsheimer --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 4 ++-- src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 2 +- src/plugins/sqldrivers/tds/qsql_tds.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index bf9424897d..0bae45382d 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -1506,7 +1506,7 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const // this is safe since postgresql stores only the UTC value and not the timezone offset (only used // while parsing), so we have correct behavior in both case of with timezone and without tz r = QStringLiteral("TIMESTAMP WITH TIME ZONE ") + QLatin1Char('\'') + - QLocale::c().toString(field.value().toDateTime().toUTC(), QStringViewLiteral("yyyy-MM-ddThh:mm:ss.zzz")) + + QLocale::c().toString(field.value().toDateTime().toUTC(), u"yyyy-MM-ddThh:mm:ss.zzz") + QLatin1Char('Z') + QLatin1Char('\''); } else { r = nullStr(); @@ -1518,7 +1518,7 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const case QVariant::Time: #if QT_CONFIG(datestring) if (field.value().toTime().isValid()) { - r = QLatin1Char('\'') + field.value().toTime().toString(QStringViewLiteral("hh:mm:ss.zzz")) + QLatin1Char('\''); + r = QLatin1Char('\'') + field.value().toTime().toString(u"hh:mm:ss.zzz") + QLatin1Char('\''); } else #endif { diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index f1a003ddcd..001bd673fc 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -531,7 +531,7 @@ bool QSQLiteResult::exec() } case QVariant::Time: { const QTime time = value.toTime(); - const QString str = time.toString(QStringViewLiteral("hh:mm:ss.zzz")); + const QString str = time.toString(u"hh:mm:ss.zzz"); res = sqlite3_bind_text16(d->stmt, i + 1, str.utf16(), str.size() * sizeof(ushort), SQLITE_TRANSIENT); break; diff --git a/src/plugins/sqldrivers/tds/qsql_tds.cpp b/src/plugins/sqldrivers/tds/qsql_tds.cpp index 603372230d..9c8d242028 100644 --- a/src/plugins/sqldrivers/tds/qsql_tds.cpp +++ b/src/plugins/sqldrivers/tds/qsql_tds.cpp @@ -813,7 +813,7 @@ QString QTDSDriver::formatValue(const QSqlField &field, r = QLatin1String("NULL"); else if (field.type() == QVariant::DateTime) { if (field.value().toDateTime().isValid()){ - r = field.value().toDateTime().toString(QStringViewLiteral("yyyyMMdd hh:mm:ss")); + r = field.value().toDateTime().toString(u"yyyyMMdd hh:mm:ss"); r.prepend(QLatin1String("'")); r.append(QLatin1String("'")); } else -- cgit v1.2.3 From 3fbb6a957227968951283107813271218058b719 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 23 Jul 2019 07:48:46 +0200 Subject: QWinRTFileEngine: Handle QIODevice::Truncate when opening files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-77095 Change-Id: I45b38fab779518c49b22077c493d8640572d40d9 Reviewed-by: André de la Rocha Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/winrt/qwinrtfileengine.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/winrt/qwinrtfileengine.cpp b/src/plugins/platforms/winrt/qwinrtfileengine.cpp index e9b2a82763..962e4ab938 100644 --- a/src/plugins/platforms/winrt/qwinrtfileengine.cpp +++ b/src/plugins/platforms/winrt/qwinrtfileengine.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -196,7 +197,19 @@ bool QWinRTFileEngine::open(QIODevice::OpenMode openMode) hr = QWinRTFunctions::await(op, d->stream.GetAddressOf()); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::OpenError, false); - d->openMode = openMode; + const ProcessOpenModeResult res = processOpenModeFlags(openMode); + if (!res.ok) { + setError(QFileDevice::OpenError, res.error); + return false; + } + d->openMode = res.openMode; + if (d->openMode & QIODevice::Truncate) { + if (!setSize(0)) { + close(); + setError(QFileDevice::OpenError, QLatin1String("Could not truncate file")); + return false; + } + } return SUCCEEDED(hr); } -- cgit v1.2.3 From c8bb8cb7614768156f9cc4bccc2df928d5430067 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Fri, 26 Jul 2019 18:16:33 +0200 Subject: Windows QPA: Fix detection of the Surface Pen eraser button The Surface Pen eraser button generates Meta+F18/19/20 keystrokes, but when it is not touching the screen the Fn WM_KEYDOWN message is eaten and only a Fn WM_KEYUP message with the previous state as "not pressed" is generated, which would be ignored. With this patch we detect this case and synthesize the expected key events to allow the button to be used in applications. Fixes: QTBUG-77153 Change-Id: I075f5cbb903cb36c9ec241ee1bb31d436b725e3a Reviewed-by: Friedemann Kleint Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index c5af4d8042..da630005d6 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -1301,7 +1301,23 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, MSG msg, || code == Qt::Key_Control || code == Qt::Key_Meta || code == Qt::Key_Alt)) { - // Someone ate the key down event + + // Workaround for QTBUG-77153: + // The Surface Pen eraser button generates Meta+F18/19/20 keystrokes, + // but when it is not touching the screen the Fn Down is eaten and only + // a Fn Up with the previous state as "not pressed" is generated, which + // would be ignored. We detect this case and synthesize the expected events. + if ((msg.lParam & 0x40000000) == 0 && + Qt::KeyboardModifier(state) == Qt::NoModifier && + ((code == Qt::Key_F18) || (code == Qt::Key_F19) || (code == Qt::Key_F20))) { + QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyPress, code, + Qt::MetaModifier, scancode, + quint32(msg.wParam), MetaLeft); + QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyRelease, code, + Qt::NoModifier, scancode, + quint32(msg.wParam), 0); + result = true; + } } else { if (!code) code = asciiToKeycode(rec->ascii ? char(rec->ascii) : char(msg.wParam), state); -- cgit v1.2.3 From f4647b40ca9319508468ead8144116d0a5718ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 29 Jul 2019 15:13:02 +0200 Subject: macOS: Respect QSurfaceFormat color space when creating NSWindow Task-number: QTBUG-47660 Change-Id: I90a2956bfaa52c361a3eba32f0ea19c0eca8c277 Reviewed-by: Simon Hausmann --- src/plugins/platforms/cocoa/qcocoawindow.mm | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 42b662cfe4..b609fb3995 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1647,6 +1647,9 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel) [nsWindow setDepthLimit:NSWindowDepthTwentyfourBitRGB]; } + if (format().colorSpace() == QSurfaceFormat::sRGBColorSpace) + nsWindow.colorSpace = NSColorSpace.sRGBColorSpace; + return nsWindow; } -- cgit v1.2.3 From 036e9d66f50f829299ac98debbf42b255f3b810c Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Fri, 11 Jan 2019 23:48:11 +0100 Subject: Fix CC_Slider rendering on macOS QSlider rendering is currently broken as the context used to render it is not properly translated. This patch fixes that. Fixes: QTBUG-72970 Change-Id: I30896ceee1f37f6dfcf01a342d10af3bb279ac8a Reviewed-by: Timur Pocheptsov --- src/plugins/styles/mac/qmacstyle_mac.mm | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 258aba2cda..c162cca048 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -5273,9 +5273,20 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } d->drawNSViewInRect(slider, opt->rect, p, ^(CGContextRef ctx, const CGRect &rect) { - if (isHorizontal && sl->upsideDown) { - CGContextTranslateCTM(ctx, rect.size.width, 0); - CGContextScaleCTM(ctx, -1, 1); + + // Since the GC is flipped, upsideDown means *not* inverted when vertical. + const bool verticalFlip = !isHorizontal && !sl->upsideDown; // FIXME: && !isSierraOrLater + + if (isHorizontal) { + if (sl->upsideDown) { + CGContextTranslateCTM(ctx, rect.size.width, rect.origin.y); + CGContextScaleCTM(ctx, -1, 1); + } else { + CGContextTranslateCTM(ctx, 0, rect.origin.y); + } + } else if (verticalFlip) { + CGContextTranslateCTM(ctx, rect.origin.x, rect.size.height); + CGContextScaleCTM(ctx, 1, -1); } if (hasDoubleTicks) { @@ -5286,9 +5297,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex CGContextTranslateCTM(ctx, 1, 0); } - // Since the GC is flipped, upsideDown means *not* inverted when vertical. - const bool verticalFlip = !isHorizontal && !sl->upsideDown; // FIXME: && !isSierraOrLater - #if 0 // FIXME: Sadly, this part doesn't work. It seems to somehow polute the // NSSlider's internal state and, when we need to use the "else" part, @@ -5352,9 +5360,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex // This ain't HIG kosher: force round knob look. if (hasDoubleTicks) slider.numberOfTickMarks = 0; - // Draw the knob in the symmetrical position instead of flipping. - if (verticalFlip) - slider.intValue = slider.maxValue - slider.intValue + slider.minValue; [cell drawKnob]; } } -- cgit v1.2.3