From 37a1478787d64b34a0716421c8a47f3246e41bfd Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 20 Oct 2017 11:07:59 +0700 Subject: Cocoa QPA: Code clean up, make some bits more readable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7f37c1b0f7f72a79bb2ac5828ba54111a90a0a00 Reviewed-by: Jake Petroules Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/messages.cpp | 2 +- src/plugins/platforms/cocoa/messages.h | 11 +++++++++++ src/plugins/platforms/cocoa/qcocoamenuitem.mm | 10 +++------- src/plugins/platforms/cocoa/qcocoamenuloader.mm | 20 +++++++------------- 4 files changed, 22 insertions(+), 21 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/messages.cpp b/src/plugins/platforms/cocoa/messages.cpp index 85b814ce1c..8eea1e654e 100644 --- a/src/plugins/platforms/cocoa/messages.cpp +++ b/src/plugins/platforms/cocoa/messages.cpp @@ -75,7 +75,7 @@ QString qt_mac_applicationmenu_string(int type) QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption) { QString captionNoAmpersand(caption); - captionNoAmpersand.remove(QChar('&')); + captionNoAmpersand.remove(QLatin1Char('&')); const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About"); if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive) || caption.endsWith(aboutString, Qt::CaseInsensitive)) return QPlatformMenuItem::AboutRole; diff --git a/src/plugins/platforms/cocoa/messages.h b/src/plugins/platforms/cocoa/messages.h index a9c9cc42e5..e41898fe59 100644 --- a/src/plugins/platforms/cocoa/messages.h +++ b/src/plugins/platforms/cocoa/messages.h @@ -45,6 +45,17 @@ QT_BEGIN_NAMESPACE +enum { + ServicesAppMenuItem = 0, + HideAppMenuItem, + HideOthersAppMenuItem, + ShowAllAppMenuItem, + PreferencesAppMenuItem, + QuitAppMenuItem, + AboutAppMenuItem +}; + + QString msgAboutQt(); QString qt_mac_applicationmenu_string(int type); diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 21f2b4de85..ecbab38a83 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -370,24 +370,20 @@ NSMenuItem *QCocoaMenuItem::sync() return m_native; } -QT_BEGIN_NAMESPACE -extern QString qt_mac_applicationmenu_string(int type); -QT_END_NAMESPACE - QString QCocoaMenuItem::mergeText() { QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader]; if (m_native == [loader aboutMenuItem]) { - return qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName()); + return qt_mac_applicationmenu_string(AboutAppMenuItem).arg(qt_mac_applicationName()); } else if (m_native== [loader aboutQtMenuItem]) { if (m_text == QString("About Qt")) return msgAboutQt(); else return m_text; } else if (m_native == [loader preferencesMenuItem]) { - return qt_mac_applicationmenu_string(4); + return qt_mac_applicationmenu_string(PreferencesAppMenuItem); } else if (m_native == [loader quitMenuItem]) { - return qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName()); + return qt_mac_applicationmenu_string(QuitAppMenuItem).arg(qt_mac_applicationName()); } else if (m_text.contains('\t')) { return m_text.left(m_text.indexOf('\t')); } diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm index 01a3c04afb..0d9bb5009d 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm @@ -47,14 +47,8 @@ #include #include #include -#include -#include -#include #include -QT_FORWARD_DECLARE_CLASS(QCFString) -QT_FORWARD_DECLARE_CLASS(QString) - @implementation QCocoaMenuLoader + (instancetype)sharedMenuLoader @@ -314,13 +308,13 @@ QT_FORWARD_DECLARE_CLASS(QString) { #ifndef QT_NO_TRANSLATION - [servicesItem setTitle:qt_mac_applicationmenu_string(0).toNSString()]; - [hideItem setTitle:qt_mac_applicationmenu_string(1).arg(qt_mac_applicationName()).toNSString()]; - [hideAllOthersItem setTitle:qt_mac_applicationmenu_string(2).toNSString()]; - [showAllItem setTitle:qt_mac_applicationmenu_string(3).toNSString()]; - [preferencesItem setTitle:qt_mac_applicationmenu_string(4).toNSString()]; - [quitItem setTitle:qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName()).toNSString()]; - [aboutItem setTitle:qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName()).toNSString()]; + [servicesItem setTitle:qt_mac_applicationmenu_string(ServicesAppMenuItem).toNSString()]; + [hideItem setTitle:qt_mac_applicationmenu_string(HideAppMenuItem).arg(qt_mac_applicationName()).toNSString()]; + [hideAllOthersItem setTitle:qt_mac_applicationmenu_string(HideOthersAppMenuItem).toNSString()]; + [showAllItem setTitle:qt_mac_applicationmenu_string(ShowAllAppMenuItem).toNSString()]; + [preferencesItem setTitle:qt_mac_applicationmenu_string(PreferencesAppMenuItem).toNSString()]; + [quitItem setTitle:qt_mac_applicationmenu_string(QuitAppMenuItem).arg(qt_mac_applicationName()).toNSString()]; + [aboutItem setTitle:qt_mac_applicationmenu_string(AboutAppMenuItem).arg(qt_mac_applicationName()).toNSString()]; #endif } -- cgit v1.2.3 From ecd183455b8039ee15b9d51fd1111992af19ed1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Wed, 11 Oct 2017 11:35:42 +0200 Subject: Refactor childIdListForAccessibleObject It has several problems: 1. It could potentially create an intArray with uninitialized elements. This could happen because the index for getting interfaces were the same as the storage index. This was not correct, because they could diverge if iface->child() returned an invalid interface. 2. The count of accessible child elements could change while iterating. This could cause out-of-bounds condition when calling SetIntArrayRegion as described in QTBUG-45855. Instead now, we call SetIntArrayRegion only once, after we have gathered all the child interface ids. Task-number: QTBUG-45855 Change-Id: I77e813158df5f563d04931ac4e296e3fc2a16e67 Reviewed-by: Frederik Gladhorn --- src/plugins/platforms/android/androidjniaccessibility.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp index e4d670239f..a3bc58bb89 100644 --- a/src/plugins/platforms/android/androidjniaccessibility.cpp +++ b/src/plugins/platforms/android/androidjniaccessibility.cpp @@ -105,15 +105,15 @@ namespace QtAndroidAccessibility { QAccessibleInterface *iface = interfaceFromId(objectId); if (iface && iface->isValid()) { - jintArray jArray = env->NewIntArray(jsize(iface->childCount())); - for (int i = 0; i < iface->childCount(); ++i) { + const int childCount = iface->childCount(); + QVarLengthArray ifaceIdArray(childCount); + for (int i = 0; i < childCount; ++i) { QAccessibleInterface *child = iface->child(i); - if (child && child->isValid()) { - QAccessible::Id ifaceId = QAccessible::uniqueId(child); - jint jid = ifaceId; - env->SetIntArrayRegion(jArray, i, 1, &jid); - } + if (child && child->isValid()) + ifaceIdArray.append(QAccessible::uniqueId(child)); } + jintArray jArray = env->NewIntArray(jsize(ifaceIdArray.count())); + env->SetIntArrayRegion(jArray, 0, ifaceIdArray.count(), ifaceIdArray.data()); return jArray; } -- cgit v1.2.3 From 9f0dda29d5d070f63b7f098139f01f07ec91ffdf Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 27 Oct 2017 10:24:19 +0200 Subject: Windows QPA: Restrict warning about geometry failure Print warning only for visible windows or in debug mode. Task-number: QTBUG-63661 Change-Id: I742c86afcb40455074a6de753b0b1ce6a11d55af Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 16c2e16d64..402009c70d 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -66,6 +66,7 @@ #include #include +#include #include @@ -1473,7 +1474,7 @@ void QWindowsWindow::setGeometry(const QRect &rectIn) // achieve that size (for example, window title minimal constraint), // notify and warn. setGeometry_sys(rect); - if (m_data.geometry != rect) { + if (m_data.geometry != rect && (isVisible() || QLibraryInfo::isDebugBuild())) { qWarning("%s: Unable to set geometry %dx%d+%d+%d on %s/'%s'." " Resulting geometry: %dx%d+%d+%d " "(frame: %d, %d, %d, %d, custom margin: %d, %d, %d, %d" -- cgit v1.2.3 From 3a92f7cf4f1abd7ad91bdfc7251b1f3e82bdf89f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 25 Oct 2017 15:43:30 +0200 Subject: macOS: Retain NSWindow during event delivery We have logic to deal with self.platformWindow and frame strut mouse events which happens after delivering the event to the NSWindow, but delivering it might dealloc the window, e.g. when closing it, so we need to explicitly retain it for the duration of [QNSWindow sendEvent:] Task-number: QTBUG-64023 Change-Id: I223fe3e3ac36a309da375522ba11f20f1ad6fc4f Reviewed-by: Timur Pocheptsov Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnswindow.mm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm index 799704a407..5213008bd4 100644 --- a/src/plugins/platforms/cocoa/qnswindow.mm +++ b/src/plugins/platforms/cocoa/qnswindow.mm @@ -185,6 +185,10 @@ static bool isMouseEvent(NSEvent *ev) if (!self.platformWindow) return; + // Prevent deallocation of this NSWindow during event delivery, as we + // have logic further below that depends on the window being alive. + [[self retain] autorelease]; + const char *eventType = object_getClassName(theEvent); if (QWindowSystemInterface::handleNativeEvent(self.platformWindow->window(), QByteArray::fromRawData(eventType, qstrlen(eventType)), theEvent, nullptr)) { @@ -221,6 +225,7 @@ static bool isMouseEvent(NSEvent *ev) #pragma clang diagnostic ignored "-Wobjc-missing-super-calls" - (void)dealloc { + qCDebug(lcQpaCocoaWindow) << "dealloc" << self; qt_objcDynamicSuper(); } #pragma clang diagnostic pop -- cgit v1.2.3 From f4090b23b98c132c47237e4695bc4dc93170cbe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 25 Oct 2017 13:05:49 +0200 Subject: macOS: Add categorized logging of event and notification forwarding Useful for debugging issues in this area. Change-Id: Ic343ef790e20b66371028265efe2ec1816c954bd Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 17 ++++++++++++++++- src/plugins/platforms/cocoa/qnswindow.mm | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index ed942af1b1..af44564968 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -79,6 +79,8 @@ static void qt_closePopups() } } +Q_LOGGING_CATEGORY(lcCocoaNotifications, "qt.qpa.cocoa.notifications"); + static void qRegisterNotificationCallbacks() { static const QLatin1String notificationHandlerPrefix(Q_NOTIFICATION_PREFIX); @@ -110,11 +112,24 @@ static void qRegisterNotificationCallbacks() if (QNSView *qnsView = qnsview_cast(notification.object)) cocoaWindows += qnsView.platformWindow; } else { - qCWarning(lcQpaCocoaWindow) << "Unhandled notifcation" + qCWarning(lcCocoaNotifications) << "Unhandled notifcation" << notification.name << "for" << notification.object; return; } + if (lcCocoaNotifications().isDebugEnabled()) { + if (cocoaWindows.isEmpty()) { + qCDebug(lcCocoaNotifications) << "Could not find forwarding target for" << + qPrintable(notificationName) << "from" << notification.object; + } else { + QVector debugWindows; + for (QCocoaWindow *cocoaWindow : cocoaWindows) + debugWindows += cocoaWindow; + qCDebug(lcCocoaNotifications) << "Forwarding" << qPrintable(notificationName) << + "to" << debugWindows; + } + } + // FIXME: Could be a foreign window, look up by iterating top level QWindows for (QCocoaWindow *cocoaWindow : cocoaWindows) { diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm index 5213008bd4..e846fa043c 100644 --- a/src/plugins/platforms/cocoa/qnswindow.mm +++ b/src/plugins/platforms/cocoa/qnswindow.mm @@ -46,6 +46,8 @@ #include #include +Q_LOGGING_CATEGORY(lcCocoaEvents, "qt.qpa.cocoa.events"); + static bool isMouseEvent(NSEvent *ev) { switch ([ev type]) { @@ -116,6 +118,22 @@ static bool isMouseEvent(NSEvent *ev) return qnsview_cast(self.contentView).platformWindow; } +- (NSString *)description +{ + NSMutableString *description = [NSMutableString stringWithString:qt_objcDynamicSuper()]; + +#ifndef QT_NO_DEBUG_STREAM + QString contentViewDescription; + QDebug debug(&contentViewDescription); + debug.nospace() << "; contentView=" << qnsview_cast(self.contentView) << ">"; + + NSRange lastCharacter = [description rangeOfComposedCharacterSequenceAtIndex:description.length - 1]; + [description replaceCharactersInRange:lastCharacter withString:contentViewDescription.toNSString()]; +#endif + + return description; +} + - (BOOL)canBecomeKeyWindow { QCocoaWindow *pw = self.platformWindow; @@ -177,6 +195,8 @@ static bool isMouseEvent(NSEvent *ev) - (void)sendEvent:(NSEvent*)theEvent { + qCDebug(lcCocoaEvents) << "Sending" << theEvent << "to" << self; + // We might get events for a NSWindow after the corresponding platform // window has been deleted, as the NSWindow can outlive the QCocoaWindow // e.g. if being retained by other parts of AppKit, or in an auto-release -- cgit v1.2.3 From 2b7cf045bfbfa5d379698fdc18a3d200487a9457 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 30 Oct 2017 15:27:57 +0100 Subject: Replace includes with qglobal.h Nothing (except the *global*.h headers themselves) is supposed to include the generated *config*.h files directly. The QtConfig forwarding header should not exist in the first place. Change-Id: I5e9edd25d905582381cdc6386804c1f3ef8716ae Reviewed-by: Oswald Buddenhagen --- src/plugins/platforms/windows/accessible/iaccessible2.cpp | 2 +- src/plugins/platforms/windows/accessible/iaccessible2.h | 2 +- src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp | 2 +- src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp | 2 +- src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp index 9239facb0c..75af65b5ab 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp +++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp @@ -36,7 +36,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include +#include #ifndef QT_NO_ACCESSIBILITY #include "iaccessible2.h" diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.h b/src/plugins/platforms/windows/accessible/iaccessible2.h index e56106f247..d987016e15 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.h +++ b/src/plugins/platforms/windows/accessible/iaccessible2.h @@ -39,7 +39,7 @@ #ifndef IACCESSIBLE2_H #define IACCESSIBLE2_H -#include +#include #ifndef QT_NO_ACCESSIBILITY #include "qwindowscombase.h" diff --git a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp index e214d47137..d48cb9674f 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include +#include #ifndef QT_NO_ACCESSIBILITY diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp index 47b179250a..fe2b9335cb 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include +#include #ifndef QT_NO_ACCESSIBILITY #include "qwindowsmsaaaccessible.h" diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h index e654f262da..5380fc2411 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h @@ -39,9 +39,8 @@ #ifndef QWINDOWSMSAAACCESSIBLE_H #define QWINDOWSMSAAACCESSIBLE_H -#include -#ifndef QT_NO_ACCESSIBILITY #include +#ifndef QT_NO_ACCESSIBILITY #include #include -- cgit v1.2.3 From d366d6dfd30de6e6f83afc807a4648f008b396e5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 27 Oct 2017 13:21:22 +0200 Subject: Windows QPA: Restrict file dialog to file system items in Directory mode Qt cannot handle places like 'Network', etc. Task-number: QTBUG-63645 Change-Id: I53d0eedc2996af6a1ec3230e3d65a3e272aa3710 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index f4527bcc60..75ca090cef 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -1010,7 +1010,9 @@ void QWindowsNativeFileDialogBase::setMode(QFileDialogOptions::FileMode mode, break; case QFileDialogOptions::Directory: case QFileDialogOptions::DirectoryOnly: - flags |= FOS_PICKFOLDERS | FOS_FILEMUSTEXIST; + // QTBUG-63645: Restrict to file system items, as Qt cannot deal with + // places like 'Network', etc. + flags |= FOS_PICKFOLDERS | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM; break; case QFileDialogOptions::ExistingFiles: flags |= FOS_FILEMUSTEXIST | FOS_ALLOWMULTISELECT; @@ -1219,6 +1221,8 @@ void QWindowsNativeFileDialogBase::onSelectionChange() { const QList current = selectedFiles(); m_data.setSelectedFiles(current); + qDebug() << __FUNCTION__ << current << current.size(); + if (current.size() == 1) emit currentChanged(current.front()); } -- cgit v1.2.3 From b4ac5525612812dd411c93e671813d079a152e57 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 27 Oct 2017 13:28:44 +0200 Subject: Windows QPA: Pass on Url of non-filesystem directory items Do not attempt to copy directory items, which will fail and result in empty result lists. Amends 5865e582fd537fff530c13301e5229a7b4ed21c7. Task-number: QTBUG-57070 Task-number: QTBUG-63645 Change-Id: I59efce196b28099ec8aff5a802ef0a4d9a098453 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 75ca090cef..4b08528d17 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -1419,7 +1419,7 @@ QList QWindowsNativeOpenFileDialog::dialogResult() const for (IShellItem *item : QWindowsShellItem::itemsFromItemArray(items)) { QWindowsShellItem qItem(item); const QString path = qItem.path(); - if (path.isEmpty()) { + if (path.isEmpty() && !qItem.isDir()) { const QString temporaryCopy = createTemporaryItemCopy(qItem); if (temporaryCopy.isEmpty()) qWarning() << "Unable to create a local copy of" << qItem; -- cgit v1.2.3 From 8ba1f91d4eed03be09046bf4ef81944787316ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 26 Oct 2017 10:06:10 +0200 Subject: macOS: Add logging of screen add/remove/changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic9c9ac307441dde98bb43d656466a03805746917 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 5 +++++ src/plugins/platforms/cocoa/qcocoascreen.h | 4 ++++ src/plugins/platforms/cocoa/qcocoascreen.mm | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index dd17848109..d185905782 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -222,6 +222,8 @@ QCocoaIntegration::Options QCocoaIntegration::options() const return mOptions; } +Q_LOGGING_CATEGORY(lcCocoaScreen, "qt.qpa.cocoa.screens"); + /*! \brief Synchronizes the screen list, adds new screens, removes deleted ones */ @@ -261,9 +263,11 @@ void QCocoaIntegration::updateScreens() if (screen) { remainingScreens.remove(screen); screen->updateGeometry(); + qCDebug(lcCocoaScreen) << "Updated properties of" << screen; } else { screen = new QCocoaScreen(i); mScreens.append(screen); + qCDebug(lcCocoaScreen) << "Adding" << screen; screenAdded(screen); } siblings << screen; @@ -280,6 +284,7 @@ void QCocoaIntegration::updateScreens() mScreens.removeOne(screen); // Prevent stale references to NSScreen during destroy screen->m_screenIndex = -1; + qCDebug(lcCocoaScreen) << "Removing" << screen; destroyScreen(screen); } } diff --git a/src/plugins/platforms/cocoa/qcocoascreen.h b/src/plugins/platforms/cocoa/qcocoascreen.h index eb17efa937..937002f493 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.h +++ b/src/plugins/platforms/cocoa/qcocoascreen.h @@ -102,6 +102,10 @@ public: QList m_siblings; }; +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug debug, const QCocoaScreen *screen); +#endif + QT_END_NAMESPACE #endif diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 13e5220b6a..f523873bde 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -275,4 +275,22 @@ QCocoaScreen *QCocoaScreen::primaryScreen() return static_cast(QGuiApplication::primaryScreen()->handle()); } +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug debug, const QCocoaScreen *screen) +{ + QDebugStateSaver saver(debug); + debug.nospace(); + debug << "QCocoaScreen(" << (const void *)screen; + if (screen) { + debug << ", index=" << screen->m_screenIndex; + debug << ", native=" << screen->nativeScreen(); + debug << ", geometry=" << screen->geometry(); + debug << ", dpr=" << screen->devicePixelRatio(); + debug << ", name=" << screen->name(); + } + debug << ')'; + return debug; +} +#endif // !QT_NO_DEBUG_STREAM + QT_END_NAMESPACE -- cgit v1.2.3 From 385589ef458715fcaa533bbd01ca421dc1040eba Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 20 Oct 2017 17:39:08 +0700 Subject: QCocoaMenu: Attach menu items when updating the menubar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of waiting for the menu delegate to update each item, we can attach an NSMenu to its NSMenuItem as soon as we update the current window's menubar. This is safe to do because we know that this is going to be the main menubar right after, so we're not orphaning any NSMenuItem from its NSMenu at the wrong moment. By doing this, we also ensure that all menus from the active menubar are reachable by the key-equivalent dispatching logic, even before we display the actual menu. This was shown in BigMenuCreator where, under the menubar's ASP and SAP menus, all A*S submenus would be disabled. Furthermore, on the same menus, SAP would show the same issue. Added test in Menurama as well. Change-Id: If6e7311072e6b53ad1cbced73623d1832aa0df8e Task-number: QTBUG-57076 Task-number: QTBUG-63712 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoamenu.h | 2 ++ src/plugins/platforms/cocoa/qcocoamenu.mm | 16 +++++++++++++++- src/plugins/platforms/cocoa/qcocoamenubar.h | 2 ++ src/plugins/platforms/cocoa/qcocoamenubar.mm | 11 ++++++++--- 4 files changed, 27 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h index 06688dbf3d..7baaf971f4 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.h +++ b/src/plugins/platforms/cocoa/qcocoamenu.h @@ -98,6 +98,8 @@ public: void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; + void syncMenuItem_helper(QPlatformMenuItem *menuItem, bool menubarUpdate); + private: QCocoaMenuItem *itemOrNull(int index) const; void insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem); diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 3a11023a4d..8bdd0512de 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -434,6 +434,11 @@ void QCocoaMenu::timerEvent(QTimerEvent *e) } void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem) +{ + syncMenuItem_helper(menuItem, false /*menubarUpdate*/); +} + +void QCocoaMenu::syncMenuItem_helper(QPlatformMenuItem *menuItem, bool menubarUpdate) { QMacAutoReleasePool pool; QCocoaMenuItem *cocoaItem = static_cast(menuItem); @@ -444,8 +449,9 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem) const bool wasMerged = cocoaItem->isMerged(); NSMenuItem *oldItem = cocoaItem->nsItem(); + NSMenuItem *syncedItem = cocoaItem->sync(); - if (cocoaItem->sync() != oldItem) { + if (syncedItem != oldItem) { // native item was changed for some reason if (oldItem) { if (wasMerged) { @@ -463,6 +469,14 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem) // when an item's enabled state changes after menuWillOpen: scheduleUpdate(); } + + // This may be a good moment to attach this item's eventual submenu to the + // synced item, but only on the condition we're all currently hooked to the + // menunbar. A good indicator of this being the right moment is knowing that + // we got called from QCocoaMenuBar::updateMenuBarImmediately(). + if (menubarUpdate) + if (QCocoaMenu *submenu = cocoaItem->menu()) + submenu->setAttachedItem(syncedItem); } void QCocoaMenu::syncSeparatorsCollapsible(bool enable) diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.h b/src/plugins/platforms/cocoa/qcocoamenubar.h index 0725e9db68..a4ee531e91 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.h +++ b/src/plugins/platforms/cocoa/qcocoamenubar.h @@ -72,6 +72,8 @@ public: QList merged() const; NSMenuItem *itemForRole(QPlatformMenuItem::MenuRole r); + void syncMenu_helper(QPlatformMenu *menu, bool menubarUpdate); + private: static QCocoaWindow *findWindowForMenubar(); static QCocoaMenuBar *findGlobalMenubar(); diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 3e466c9587..a4cd465dae 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -155,7 +155,7 @@ void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *befor } } - syncMenu(menu); + syncMenu_helper(menu, false /*internaCall*/); if (needsImmediateUpdate()) updateMenuBarImmediately(); @@ -182,12 +182,17 @@ void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu) } void QCocoaMenuBar::syncMenu(QPlatformMenu *menu) +{ + syncMenu_helper(menu, false /*internaCall*/); +} + +void QCocoaMenuBar::syncMenu_helper(QPlatformMenu *menu, bool menubarUpdate) { QMacAutoReleasePool pool; QCocoaMenu *cocoaMenu = static_cast(menu); Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items()) - cocoaMenu->syncMenuItem(item); + cocoaMenu->syncMenuItem_helper(item, menubarUpdate); BOOL shouldHide = YES; if (cocoaMenu->isVisible()) { @@ -357,7 +362,7 @@ void QCocoaMenuBar::updateMenuBarImmediately() menu->setAttachedItem(item); menu->setMenuParent(mb); // force a sync? - mb->syncMenu(menu); + mb->syncMenu_helper(menu, true /*menubarUpdate*/); menu->propagateEnabledState(!disableForModal); } -- cgit v1.2.3 From e45ffd7bf6b05062590da039e0de64707d2fb536 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Thu, 26 Oct 2017 13:26:56 +0200 Subject: Xinput: Avoid misdetecting certain trackballs as tablets The algorithm triggers on the word "cursor" in the device name, which would also happen for devices from the manufacturer Cursor Controls. Task-number: QTBUG-48034 Change-Id: I9645c0d0bc1fa951d0ea00480572fd0df0220eb5 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 6f20ec25e3..26a9ba8d26 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -220,7 +220,7 @@ void QXcbConnection::xi2SetupDevices() isTablet = true; tabletData.pointerType = QTabletEvent::Eraser; dbgType = QLatin1String("eraser"); - } else if (name.contains("cursor")) { + } else if (name.contains("cursor") && !(name.contains("cursor controls") && name.contains("trackball"))) { isTablet = true; tabletData.pointerType = QTabletEvent::Cursor; dbgType = QLatin1String("cursor"); -- cgit v1.2.3 From 5194817941985c766bbc7f80039a58e0cf504b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 6 Nov 2017 15:08:37 +0100 Subject: Cocoa: optimize backingstore flush on 10-bit displays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Qt draws the backing store to the window using CoreGrahics, which will trigger a slow RGB32 -> RGB64 conversion when the output display is a deep color display. Disable NSWindow dynamicDepthLimit and force the depthLimit to WindowDepthTwentyforBitRGB for the common case of 8-bit-per-component raster surfaces. This was benchmarked by resizing a simple QRasterWindow test case which fills the window area using QPainter::fillRect(). Before: 67.1% rgba64_image_mark_rgb32 10.8% __vImageCopyBuffer_block_invoke 6.0% madvise 5.0% _kernelrpc_mach_vm_deallocate_trap 4.1% qt_memfill32(unsigned int*, unsigned int, int) After: 30.7% __vImageCopyBuffer_block_invoke 20.3% madvise 12.3% __vOverwriteChannelsWithScalar_ARGB8888_block_invoke 12.2% qt_memfill32(unsigned int*, unsigned int, int) 4.6% _kernelrpc_mach_vm_deallocate_trap The test program now spends significantly more of its time allocating/deallocating the backing store (madvise), and running the Qt paint event (qt_memfill32). Task-number: QTBUG-47660 Change-Id: I878be7a0e6eee4ad798f7a53f7f9f79b7950af26 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoawindow.mm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index c6fa6795c1..5cd4beb4f0 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1887,6 +1887,21 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBeChildNSWindow, bool sh applyContentBorderThickness(window); + // Prevent CoreGraphics RGB32 -> RGB64 backing store conversions on deep color + // displays by forcing 8-bit components, unless a deep color format has been + // requested. This conversion uses significant CPU time. + QSurface::SurfaceType surfaceType = QPlatformWindow::window()->surfaceType(); + bool usesCoreGraphics = surfaceType == QSurface::RasterSurface || surfaceType == QSurface::RasterGLSurface; + QSurfaceFormat surfaceFormat = QPlatformWindow::window()->format(); + bool usesDeepColor = surfaceFormat.redBufferSize() > 8 || + surfaceFormat.greenBufferSize() > 8 || + surfaceFormat.blueBufferSize() > 8; + bool usesLayer = view().layer; + if (usesCoreGraphics && !usesDeepColor && !usesLayer) { + [window setDynamicDepthLimit:NO]; + [window setDepthLimit:NSWindowDepthTwentyfourBitRGB]; + } + return window; } -- cgit v1.2.3 From 59c5f7bd9da63621887260fc45e6669282d71ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 6 Nov 2017 14:52:13 +0100 Subject: macOS: Fall back to QWindow::icon for application icon if not set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are three ways to set the application (Dock/task switcher) icon: 1. By setting an ICON in the project file 2. By calling QGuiApplication::setWindowIcon 3. By calling QWindow::setIcon The third one was not working on macOS, despite being documented as such: "The window icon might be used by the windowing system for example to decorate the window, and/or in the task switcher." We now update the application icon based on the active window, unless a global application icon has been set using ICON, or via QGuiApplication::setWindowIcon. The reason for not allowing the window's icon to override a global application icon is that the developer may have intended to set the document icon for a window (to represent QWindow::filePath), and we don't want that to affect the Dock icon of the application. The role of QGuiApplication::setWindowIcon is a bit dubious in this, as it's documented as "This property holds the default window icon", which would indicate it should follow the same logic as above by not letting it override the global ICON set in the project file, but this would not allow runtime switching of the application icon, so the QGuiApplication property is left as is. The property should probably have been named QGuiApplication::applicationIcon initially. Task-number: QTBUG-63340 Change-Id: I94d3710a8586bb729af42f59a915b8f49dded101 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaintegration.h | 6 ++++- src/plugins/platforms/cocoa/qcocoaintegration.mm | 32 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index dc7c5916a3..2fc5156d24 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -60,8 +60,9 @@ QT_BEGIN_NAMESPACE class QCocoaScreen; -class QCocoaIntegration : public QPlatformIntegration +class QCocoaIntegration : public QObject, public QPlatformIntegration { + Q_OBJECT public: enum Option { UseFreeTypeFontEngine = 0x1 @@ -120,6 +121,9 @@ public: void beep() const Q_DECL_OVERRIDE; +private Q_SLOTS: + void focusWindowChanged(QWindow *); + private: static QCocoaIntegration *mInstance; Options mOptions; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index d185905782..55b3805df3 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -179,6 +179,9 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) QMacInternalPasteboardMime::initializeMimeTypes(); QCocoaMimeTypes::initializeMimeTypes(); QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false); + + connect(qGuiApp, &QGuiApplication::focusWindowChanged, + this, &QCocoaIntegration::focusWindowChanged); } QCocoaIntegration::~QCocoaIntegration() @@ -510,4 +513,33 @@ void QCocoaIntegration::beep() const NSBeep(); } +void QCocoaIntegration::focusWindowChanged(QWindow *focusWindow) +{ + // Don't revert icon just because we lost focus + if (!focusWindow) + return; + + static bool hasDefaultApplicationIcon = [](){ + NSImage *genericApplicationIcon = [[NSWorkspace sharedWorkspace] + iconForFileType:NSFileTypeForHFSTypeCode(kGenericApplicationIcon)]; + NSImage *applicationIcon = [NSImage imageNamed:NSImageNameApplicationIcon]; + + NSRect rect = NSMakeRect(0, 0, 32, 32); + return [applicationIcon CGImageForProposedRect:&rect context:nil hints:nil] + == [genericApplicationIcon CGImageForProposedRect:&rect context:nil hints:nil]; + }(); + + // Don't let the window icon override an explicit application icon set in the Info.plist + if (!hasDefaultApplicationIcon) + return; + + // Or an explicit application icon set on QGuiApplication + if (!qGuiApp->windowIcon().isNull()) + return; + + setApplicationIcon(focusWindow->icon()); +} + +#include "moc_qcocoaintegration.cpp" + QT_END_NAMESPACE -- cgit v1.2.3 From 3f519ffa150ce5a2d9e3ad3f147745b312d29afb Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 25 Oct 2017 09:32:48 +0700 Subject: QCocoaMenuItem: Don't clear NSMenuItem.action when setting submenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contrarily to what the comment stated, we actually rely on automatic menu validation, even for submenu items. This is visible in the menu delegate's validateMenuItem: and itemFired: methods. This solves the last visible issue in BigMenuCreator where, under ASP/ASP, ASP/SAP, SAP/ASP and SAP/SAP, all A*S submenus would be disabled. The cause was an incorrect target/action setup. Menurama still behaves as expected. Change-Id: I2599d6fb0d51f56f5d36f03b69647e35ff6c550a Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index ecbab38a83..394e0fb8e4 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -150,10 +150,6 @@ void QCocoaMenuItem::setMenu(QPlatformMenu *menu) QMacAutoReleasePool pool; m_menu = static_cast(menu); if (m_menu) { - if (m_native) { - // Skip automatic menu item validation - m_native.action = nil; - } m_menu->setMenuParent(this); m_menu->propagateEnabledState(isEnabled()); } else { -- cgit v1.2.3 From d0736e9d17d0b3ec2f7aa3f323a1edf70aa83e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 7 Nov 2017 15:03:32 +0100 Subject: Cocoa: Make High DPI drag cursor work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ide4bc50ab7173529a00fe60a04204bad0b3f275e Task-id: QTBUG-60769 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qnsview.mm | 1 + 1 file changed, 1 insertion(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index ec9d25fff9..2e64204fb7 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -2068,6 +2068,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin } else { NSImage *nsimage = qt_mac_create_nsimage(pixmapCursor); + nsimage.size = NSSizeFromCGSize((pixmapCursor.size() / pixmapCursor.devicePixelRatioF()).toCGSize()); nativeCursor = [[NSCursor alloc] initWithImage:nsimage hotSpot:NSZeroPoint]; [nsimage release]; } -- cgit v1.2.3 From c84f7554894cef0cbeeba8a61f441286e190a797 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 13 Nov 2017 11:28:41 +0100 Subject: Offscreen QPA: Use fusion style always MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent it from crashing when naively using it for example on Windows, which defaults to the Windows Vista style operating on native window handles. Change-Id: I7b1dfb00a6b6860d0f0a134653ce1142b45959ec Reviewed-by: Sami Nurmenniemi Reviewed-by: Gatis Paeglis Reviewed-by: Morten Johan Sørvig --- .../platforms/offscreen/qoffscreenintegration.cpp | 32 ++++++++++++++++++++++ .../platforms/offscreen/qoffscreenintegration.h | 3 ++ 2 files changed, 35 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp index 3eb8675d77..75bb786b28 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp @@ -61,6 +61,7 @@ #include #include #include +#include #include @@ -167,6 +168,37 @@ QAbstractEventDispatcher *QOffscreenIntegration::createEventDispatcher() const #endif } +static QString themeName() { return QStringLiteral("offscreen"); } + +QStringList QOffscreenIntegration::themeNames() const +{ + return QStringList(themeName()); +} + +// Restrict the styles to "fusion" to prevent native styles requiring native +// window handles (eg Windows Vista style) from being used. +class OffscreenTheme : public QPlatformTheme +{ +public: + OffscreenTheme() {} + + QVariant themeHint(ThemeHint h) const override + { + switch (h) { + case StyleNames: + return QVariant(QStringList(QStringLiteral("fusion"))); + default: + break; + } + return QPlatformTheme::themeHint(h); + } +}; + +QPlatformTheme *QOffscreenIntegration::createPlatformTheme(const QString &name) const +{ + return name == themeName() ? new OffscreenTheme() : nullptr; +} + QPlatformFontDatabase *QOffscreenIntegration::fontDatabase() const { return m_fontDatabase.data(); diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.h b/src/plugins/platforms/offscreen/qoffscreenintegration.h index 569ec8fc28..f72587d11a 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.h +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.h @@ -69,6 +69,9 @@ public: QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE; QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE; + QStringList themeNames() const; + QPlatformTheme *createPlatformTheme(const QString &name) const; + static QOffscreenIntegration *createOffscreenIntegration(); private: -- cgit v1.2.3