summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKari Oikarinen <kari.oikarinen@qt.io>2019-02-20 12:37:31 +0200
committerKari Oikarinen <kari.oikarinen@qt.io>2019-02-20 12:37:31 +0200
commit33707f5b2fa45eea6c1163d98cf9d23015bacf02 (patch)
tree6e24046e64432bccf11d00177f425de1f4d2c9c7 /src
parent655e8623afed01de63ce43f55227fb019e800fe9 (diff)
parent2fc4635e9889ade1ae79b787cc18aae654e65e3b (diff)
Merge 5.12 into 5.12.2
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/freetype/src/sfnt/pngshim.c1
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java17
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtNative.java65
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java14
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm59
-rw-r--r--src/gui/configure.json3
-rw-r--r--src/gui/painting/qbackingstore.cpp23
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp3
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp4
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp45
-rw-r--r--src/plugins/platforms/android/qandroidsystemlocale.cpp18
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm60
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm40
-rw-r--r--src/plugins/platforms/cocoa/qcocoascreen.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm93
-rw-r--r--src/plugins/platforms/cocoa/qnswindow.h10
-rw-r--r--src/plugins/platforms/cocoa/qnswindow.mm218
-rw-r--r--src/plugins/platforms/winrt/qwinrtscreen.cpp18
-rw-r--r--src/plugins/platforms/winrt/qwinrtscreen.h3
-rw-r--r--src/plugins/platforms/winrt/qwinrtwindow.cpp5
-rw-r--r--src/tools/androiddeployqt/main.cpp15
-rw-r--r--src/tools/moc/util/generate_keywords.pro2
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp1
25 files changed, 356 insertions, 367 deletions
diff --git a/src/3rdparty/freetype/src/sfnt/pngshim.c b/src/3rdparty/freetype/src/sfnt/pngshim.c
index 16020266af..cd110776c8 100644
--- a/src/3rdparty/freetype/src/sfnt/pngshim.c
+++ b/src/3rdparty/freetype/src/sfnt/pngshim.c
@@ -68,6 +68,7 @@
( ( __clang_major__ >= 4 ) || \
( ( __clang_major__ == 3 ) && ( __clang_minor__ >= 2 ) ) ) ) ) && \
defined( __OPTIMIZE__ ) && \
+ !defined( __EMSCRIPTEN__ ) && \
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#ifdef __clang__
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
index 02033859e9..4b87c25787 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -606,11 +606,14 @@ public class QtActivityDelegate
}
QtNative.loadQtLibraries(loaderParams.getStringArrayList(NATIVE_LIBRARIES_KEY));
ArrayList<String> libraries = loaderParams.getStringArrayList(BUNDLED_LIBRARIES_KEY);
- QtNative.loadBundledLibraries(libraries, QtNativeLibrariesDir.nativeLibrariesDir(m_activity));
+ String nativeLibsDir = QtNativeLibrariesDir.nativeLibrariesDir(m_activity);
+ QtNative.loadBundledLibraries(libraries, nativeLibsDir);
m_mainLib = loaderParams.getString(MAIN_LIBRARY_KEY);
// older apps provide the main library as the last bundled library; look for this if the main library isn't provided
- if (null == m_mainLib && libraries.size() > 0)
+ if (null == m_mainLib && libraries.size() > 0) {
m_mainLib = libraries.get(libraries.size() - 1);
+ libraries.remove(libraries.size() - 1);
+ }
if (loaderParams.containsKey(EXTRACT_STYLE_KEY)) {
String path = loaderParams.getString(EXTRACT_STYLE_KEY);
@@ -664,8 +667,8 @@ public class QtActivityDelegate
} catch (Exception e) {
e.printStackTrace();
}
-
- return true;
+ m_mainLib = QtNative.loadMainLibrary(m_mainLib, nativeLibsDir);
+ return m_mainLib != null;
}
public boolean startApplication()
@@ -728,11 +731,7 @@ public class QtActivityDelegate
@Override
public void run() {
try {
- String nativeLibraryDir = QtNativeLibrariesDir.nativeLibrariesDir(m_activity);
- QtNative.startApplication(m_applicationParameters,
- m_environmentVariables,
- m_mainLib,
- nativeLibraryDir);
+ QtNative.startApplication(m_applicationParameters, m_environmentVariables, m_mainLib);
m_started = true;
} catch (Exception e) {
e.printStackTrace();
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
index 5562c010aa..1d2b70ab5f 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
@@ -231,6 +231,41 @@ public class QtNative
});
}
+ public static String loadMainLibrary(final String mainLibrary, final String nativeLibraryDir)
+ {
+ final String[] res = new String[1];
+ res[0] = null;
+ m_qtThread.run(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ String mainLibNameTemplate = "lib" + mainLibrary + ".so";
+ File f = new File(nativeLibraryDir + mainLibNameTemplate);
+ if (!f.exists()) {
+ try {
+ ActivityInfo info = m_activity.getPackageManager().getActivityInfo(m_activity.getComponentName(),
+ PackageManager.GET_META_DATA);
+ String systemLibraryDir = QtNativeLibrariesDir.systemLibrariesDir;
+ if (info.metaData.containsKey("android.app.system_libs_prefix"))
+ systemLibraryDir = info.metaData.getString("android.app.system_libs_prefix");
+ f = new File(systemLibraryDir + mainLibNameTemplate);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return;
+ }
+ }
+ if (!f.exists())
+ return;
+ System.load(f.getAbsolutePath());
+ res[0] = f.getAbsolutePath();
+ } catch (Exception e) {
+ Log.e(QtTAG, "Can't load '" + mainLibrary + "'", e);
+ }
+ }
+ });
+ return res[0];
+ }
+
public static void setActivity(Activity qtMainActivity, QtActivityDelegate qtActivityDelegate)
{
synchronized (m_mainActivityMutex) {
@@ -308,46 +343,20 @@ public class QtNative
});
}
- public static boolean startApplication(String params,
- final String environment,
- String mainLibrary,
- String nativeLibraryDir) throws Exception
+ public static boolean startApplication(String params, final String environment, String mainLib) throws Exception
{
- String mainLibNameTemplate = "lib" + mainLibrary + ".so";
- File f = new File(nativeLibraryDir + mainLibNameTemplate);
- if (!f.exists()) {
- try {
- ActivityInfo info = m_activity.getPackageManager().getActivityInfo(m_activity.getComponentName(),
- PackageManager.GET_META_DATA);
- String systemLibraryDir = QtNativeLibrariesDir.systemLibrariesDir;
- if (info.metaData.containsKey("android.app.system_libs_prefix"))
- systemLibraryDir = info.metaData.getString("android.app.system_libs_prefix");
- f = new File(systemLibraryDir + mainLibNameTemplate);
- } catch (Exception e) {
-
- }
- }
- if (!f.exists())
- throw new Exception("Can't find main library '" + mainLibrary + "'");
-
if (params == null)
params = "-platform\tandroid";
- final String mainLibraryPath = f.getAbsolutePath();
final boolean[] res = new boolean[1];
res[0] = false;
synchronized (m_mainActivityMutex) {
if (params.length() > 0 && !params.startsWith("\t"))
params = "\t" + params;
- final String qtParams = f.getAbsolutePath() + params;
+ final String qtParams = mainLib + params;
m_qtThread.run(new Runnable() {
@Override
public void run() {
- try {
- System.load(mainLibraryPath);
- } catch (Exception e) {
- Log.i(QtTAG, "Can't load '" + mainLibraryPath + "'", e);
- }
res[0] = startQtAndroidPlugin(qtParams, environment);
setDisplayMetrics(m_displayMetricsScreenWidthPixels,
m_displayMetricsScreenHeightPixels,
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java
index ae06fa6268..33bcb364de 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java
@@ -98,8 +98,8 @@ public class QtServiceDelegate
private static final String APP_DISPLAY_METRIC_SCREEN_YDPI_KEY = "display.screen.dpi.y";
private static final String APP_DISPLAY_METRIC_SCREEN_DENSITY_KEY = "display.screen.density";
+ private String m_mainLib = null;
private Service m_service = null;
- private String m_mainLib;
private static String m_environmentVariables = null;
private static String m_applicationParameters = null;
@@ -142,9 +142,9 @@ public class QtServiceDelegate
}
QtNative.loadQtLibraries(loaderParams.getStringArrayList(NATIVE_LIBRARIES_KEY));
ArrayList<String> libraries = loaderParams.getStringArrayList(BUNDLED_LIBRARIES_KEY);
- QtNative.loadBundledLibraries(libraries, QtNativeLibrariesDir.nativeLibrariesDir(m_service));
+ String nativeLibsDir = QtNativeLibrariesDir.nativeLibrariesDir(m_service);
+ QtNative.loadBundledLibraries(libraries, nativeLibsDir);
m_mainLib = loaderParams.getString(MAIN_LIBRARY_KEY);
-
m_environmentVariables = loaderParams.getString(ENVIRONMENT_VARIABLES_KEY);
String additionalEnvironmentVariables = "QT_ANDROID_FONTS_MONOSPACE=Droid Sans Mono;Droid Sans;Droid Sans Fallback"
+ "\tQT_ANDROID_FONTS_SERIF=Droid Serif"
@@ -165,7 +165,8 @@ public class QtServiceDelegate
else
m_applicationParameters = "";
- return true;
+ m_mainLib = QtNative.loadMainLibrary(m_mainLib, nativeLibsDir);
+ return m_mainLib != null;
}
public boolean startApplication()
@@ -173,10 +174,7 @@ public class QtServiceDelegate
// start application
try {
String nativeLibraryDir = QtNativeLibrariesDir.nativeLibrariesDir(m_service);
- QtNative.startApplication(m_applicationParameters,
- m_environmentVariables,
- m_mainLib,
- nativeLibraryDir);
+ QtNative.startApplication(m_applicationParameters, m_environmentVariables, m_mainLib);
return true;
} catch (Exception e) {
e.printStackTrace();
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index 140c60a080..4550891e2a 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -48,6 +48,11 @@
#include <UIKit/UIKit.h>
#endif
+#include <execinfo.h>
+#include <dlfcn.h>
+#include <cxxabi.h>
+#include <objc/runtime.h>
+
#include <qdebug.h>
QT_BEGIN_NAMESPACE
@@ -127,22 +132,54 @@ QT_USE_NAMESPACE
}
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAutoReleasePoolTracker);
-QT_BEGIN_NAMESPACE
-
-/*
- Manages a scoped auto-release pool.
-
- To track autoreleases without any pools in place, such as in main()
- before the runloop has started, export OBJC_DEBUG_MISSING_POOLS=YES
- and break in objc_autoreleaseNoPool, e.g.:
+QT_BEGIN_NAMESPACE
- br set -n objc_autoreleaseNoPool -c "[((NSObject*)$r14) class] == [QNSWindow class]"
-*/
QMacAutoReleasePool::QMacAutoReleasePool()
: pool([[NSAutoreleasePool alloc] init])
{
- [[[QMacAutoReleasePoolTracker alloc] initWithPool:
+ Class trackerClass = [QMacAutoReleasePoolTracker class];
+
+#ifdef QT_DEBUG
+ void *poolFrame = nullptr;
+ if (__builtin_available(macOS 10.14, iOS 12.0, tvOS 12.0, watchOS 5.0, *)) {
+ void *frame;
+ if (backtrace_from_fp(__builtin_frame_address(0), &frame, 1))
+ poolFrame = frame;
+ } else {
+ static const int maxFrames = 3;
+ void *callstack[maxFrames];
+ if (backtrace(callstack, maxFrames) == maxFrames)
+ poolFrame = callstack[maxFrames - 1];
+ }
+
+ if (poolFrame) {
+ Dl_info info;
+ if (dladdr(poolFrame, &info) && info.dli_sname) {
+ const char *symbolName = info.dli_sname;
+ if (symbolName[0] == '_') {
+ int status;
+ if (char *demangled = abi::__cxa_demangle(info.dli_sname, nullptr, 0, &status))
+ symbolName = demangled;
+ }
+
+ char *className = nullptr;
+ asprintf(&className, " ^-- allocated in function: %s", symbolName);
+
+ if (Class existingClass = objc_getClass(className))
+ trackerClass = existingClass;
+ else
+ trackerClass = objc_duplicateClass(trackerClass, className, 0);
+
+ free(className);
+
+ if (symbolName != info.dli_sname)
+ free((char*)symbolName);
+ }
+ }
+#endif
+
+ [[[trackerClass alloc] initWithPool:
reinterpret_cast<NSAutoreleasePool **>(&pool)] autorelease];
}
diff --git a/src/gui/configure.json b/src/gui/configure.json
index 70d0817791..44140bc7b6 100644
--- a/src/gui/configure.json
+++ b/src/gui/configure.json
@@ -59,8 +59,9 @@
},
"bcm_host": {
"export": "",
+ "headers": ["bcm_host.h"],
"sources": [
- "-lbcm_host"
+ { "type": "makeSpec", "spec": "BCM_HOST" }
]
},
"dxguid": {
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index 0dfb52e7c3..d935deb4d6 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -62,7 +62,7 @@ public:
}
QWindow *window;
- QPlatformBackingStore *platformBackingStore;
+ QPlatformBackingStore *platformBackingStore = nullptr;
QScopedPointer<QImage> highDpiBackingstore;
QRegion staticContents;
QSize size;
@@ -95,8 +95,6 @@ public:
QBackingStore::QBackingStore(QWindow *window)
: d_ptr(new QBackingStorePrivate(window))
{
- d_ptr->platformBackingStore = QGuiApplicationPrivate::platformIntegration()->createPlatformBackingStore(window);
- d_ptr->platformBackingStore->setBackingStore(this);
}
/*!
@@ -131,7 +129,8 @@ void QBackingStore::beginPaint(const QRegion &region)
d_ptr->highDpiBackingstore->devicePixelRatio() != d_ptr->window->devicePixelRatio())
resize(size());
- d_ptr->platformBackingStore->beginPaint(QHighDpi::toNativeLocalRegion(region, d_ptr->window));
+ QPlatformBackingStore *platformBackingStore = handle();
+ platformBackingStore->beginPaint(QHighDpi::toNativeLocalRegion(region, d_ptr->window));
// When QtGui is applying a high-dpi scale factor the backing store
// creates a "large" backing store image. This image needs to be
@@ -139,7 +138,7 @@ void QBackingStore::beginPaint(const QRegion &region)
// devicePixelRatio. Do this on a separate image instance that shares
// the image data to avoid having the new devicePixelRatio be propagated
// back to the platform plugin.
- QPaintDevice *device = d_ptr->platformBackingStore->paintDevice();
+ QPaintDevice *device = platformBackingStore->paintDevice();
if (QHighDpiScaling::isActive() && device->devType() == QInternal::Image) {
QImage *source = static_cast<QImage *>(device);
const bool needsNewImage = d_ptr->highDpiBackingstore.isNull()
@@ -168,7 +167,7 @@ void QBackingStore::beginPaint(const QRegion &region)
*/
QPaintDevice *QBackingStore::paintDevice()
{
- QPaintDevice *device = d_ptr->platformBackingStore->paintDevice();
+ QPaintDevice *device = handle()->paintDevice();
if (QHighDpiScaling::isActive() && device->devType() == QInternal::Image)
return d_ptr->highDpiBackingstore.data();
@@ -189,7 +188,7 @@ void QBackingStore::endPaint()
if (paintDevice()->paintingActive())
qWarning() << "QBackingStore::endPaint() called with active painter on backingstore paint device";
- d_ptr->platformBackingStore->endPaint();
+ handle()->endPaint();
}
static bool isRasterSurface(QWindow *window)
@@ -247,7 +246,7 @@ void QBackingStore::flush(const QRegion &region, QWindow *window, const QPoint &
Q_ASSERT(window == topLevelWindow || topLevelWindow->isAncestorOf(window, QWindow::ExcludeTransients));
- d_ptr->platformBackingStore->flush(window, QHighDpi::toNativeLocalRegion(region, window),
+ handle()->flush(window, QHighDpi::toNativeLocalRegion(region, window),
QHighDpi::toNativeLocalPosition(offset, window));
}
@@ -259,7 +258,7 @@ void QBackingStore::flush(const QRegion &region, QWindow *window, const QPoint &
void QBackingStore::resize(const QSize &size)
{
d_ptr->size = size;
- d_ptr->platformBackingStore->resize(QHighDpi::toNativePixels(size, d_ptr->window), d_ptr->staticContents);
+ handle()->resize(QHighDpi::toNativePixels(size, d_ptr->window), d_ptr->staticContents);
}
/*!
@@ -286,7 +285,7 @@ bool QBackingStore::scroll(const QRegion &area, int dx, int dy)
if (qFloor(nativeDx) != nativeDx || qFloor(nativeDy) != nativeDy)
return false;
- return d_ptr->platformBackingStore->scroll(QHighDpi::toNativeLocalRegion(area, d_ptr->window),
+ return handle()->scroll(QHighDpi::toNativeLocalRegion(area, d_ptr->window),
nativeDx, nativeDy);
}
@@ -367,6 +366,10 @@ void Q_GUI_EXPORT qt_scrollRectInImage(QImage &img, const QRect &rect, const QPo
*/
QPlatformBackingStore *QBackingStore::handle() const
{
+ if (!d_ptr->platformBackingStore) {
+ d_ptr->platformBackingStore = QGuiApplicationPrivate::platformIntegration()->createPlatformBackingStore(d_ptr->window);
+ d_ptr->platformBackingStore->setBackingStore(const_cast<QBackingStore*>(this));
+ }
return d_ptr->platformBackingStore;
}
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index e7eaa54a45..6b3604afb5 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -1139,7 +1139,8 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processBlockNode()
// ####################
// block.setFloatPosition(node->cssFloat);
- if (wsm == QTextHtmlParserNode::WhiteSpacePre) {
+ if (wsm == QTextHtmlParserNode::WhiteSpacePre
+ || wsm == QTextHtmlParserNode::WhiteSpaceNoWrap) {
block.setNonBreakableLines(true);
modifiedBlockFormat = true;
}
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
index 40ac46df85..bd4338feb8 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
@@ -1429,8 +1429,8 @@ QT_WARNING_POP
reinterpret_cast<const OS2Table *>(fontData.constData()
+ qFromBigEndian<quint32>(os2TableEntry->offset));
- bool italic = qFromBigEndian<quint16>(os2Table->selection) & 1;
- bool oblique = qFromBigEndian<quint16>(os2Table->selection) & 128;
+ bool italic = qFromBigEndian<quint16>(os2Table->selection) & (1 << 0);
+ bool oblique = qFromBigEndian<quint16>(os2Table->selection) & (1 << 9);
if (italic)
fontEngine->fontDef.style = QFont::StyleItalic;
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp
index f68ea54dcf..db2186644b 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp
@@ -115,30 +115,33 @@ static FontKeys &fontKeys()
{
static FontKeys result;
if (result.isEmpty()) {
- const QSettings fontRegistry(QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"),
- QSettings::NativeFormat);
- const QStringList allKeys = fontRegistry.allKeys();
- const QString trueType = QStringLiteral("(TrueType)");
+ const QStringList keys = { QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"),
+ QStringLiteral("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts") };
+ for (const auto key : keys) {
+ const QSettings fontRegistry(key, QSettings::NativeFormat);
+ const QStringList allKeys = fontRegistry.allKeys();
+ const QString trueType = QStringLiteral("(TrueType)");
#if QT_CONFIG(regularexpression)
- const QRegularExpression sizeListMatch(QStringLiteral("\\s(\\d+,)+\\d+"));
+ const QRegularExpression sizeListMatch(QStringLiteral("\\s(\\d+,)+\\d+"));
#else
- const QRegExp sizeListMatch(QLatin1String("\\s(\\d+,)+\\d+"));
+ const QRegExp sizeListMatch(QLatin1String("\\s(\\d+,)+\\d+"));
#endif
- Q_ASSERT(sizeListMatch.isValid());
- const int size = allKeys.size();
- result.reserve(size);
- for (int i = 0; i < size; ++i) {
- FontKey fontKey;
- const QString &registryFontKey = allKeys.at(i);
- fontKey.fileName = fontRegistry.value(registryFontKey).toString();
- QString realKey = registryFontKey;
- realKey.remove(trueType);
- realKey.remove(sizeListMatch);
- const auto fontNames = QStringRef(&realKey).trimmed().split(QLatin1Char('&'));
- fontKey.fontNames.reserve(fontNames.size());
- for (const QStringRef &fontName : fontNames)
- fontKey.fontNames.append(fontName.trimmed().toString());
- result.append(fontKey);
+ Q_ASSERT(sizeListMatch.isValid());
+ const int size = allKeys.size();
+ result.reserve(result.size() + size);
+ for (int i = 0; i < size; ++i) {
+ FontKey fontKey;
+ const QString &registryFontKey = allKeys.at(i);
+ fontKey.fileName = fontRegistry.value(registryFontKey).toString();
+ QString realKey = registryFontKey;
+ realKey.remove(trueType);
+ realKey.remove(sizeListMatch);
+ const auto fontNames = QStringRef(&realKey).trimmed().split(QLatin1Char('&'));
+ fontKey.fontNames.reserve(fontNames.size());
+ for (const QStringRef &fontName : fontNames)
+ fontKey.fontNames.append(fontName.trimmed().toString());
+ result.append(fontKey);
+ }
}
}
return result;
diff --git a/src/plugins/platforms/android/qandroidsystemlocale.cpp b/src/plugins/platforms/android/qandroidsystemlocale.cpp
index 7fe36aa9bc..f9d566ff1a 100644
--- a/src/plugins/platforms/android/qandroidsystemlocale.cpp
+++ b/src/plugins/platforms/android/qandroidsystemlocale.cpp
@@ -40,6 +40,7 @@
#include "qandroidsystemlocale.h"
#include "androidjnimain.h"
#include <QtCore/private/qjni_p.h>
+#include <QtCore/private/qjnihelpers_p.h>
#include "qdatetime.h"
#include "qstringlist.h"
#include "qvariant.h"
@@ -162,6 +163,23 @@ QVariant QAndroidSystemLocale::query(QueryType type, QVariant in) const
return m_locale.createSeparatedList(in.value<QStringList>());
case LocaleChanged:
Q_ASSERT_X(false, Q_FUNC_INFO, "This can't happen.");
+ case UILanguages: {
+ if (QtAndroidPrivate::androidSdkVersion() >= 24) {
+ QJNIObjectPrivate localeListObject =
+ QJNIObjectPrivate::callStaticObjectMethod("android/os/LocaleList", "getDefault",
+ "()Landroid/os/LocaleList;");
+ if (localeListObject.isValid()) {
+ QString lang = localeListObject.callObjectMethod("toLanguageTags",
+ "()Ljava/lang/String;").toString();
+ // Some devices return with it enclosed in []'s so check if both exists before
+ // removing to ensure it is formatted correctly
+ if (lang.startsWith(QChar('[')) && lang.endsWith(QChar(']')))
+ lang = lang.mid(1, lang.length() - 2);
+ return lang.split(QChar(','));
+ }
+ }
+ return QVariant();
+ }
default:
break;
}
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index 44ab16d300..e255719cc1 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -94,7 +94,6 @@ QT_USE_NAMESPACE
bool startedQuit;
NSObject <NSApplicationDelegate> *reflectionDelegate;
bool inLaunch;
- QWindowList hiddenWindows;
}
+ (instancetype)sharedDelegate
@@ -311,41 +310,6 @@ QT_USE_NAMESPACE
return NO; // Someday qApp->quitOnLastWindowClosed(); when QApp and NSApp work closer together.
}
-- (void)applicationWillHide:(NSNotification *)notification
-{
- if (reflectionDelegate
- && [reflectionDelegate respondsToSelector:@selector(applicationWillHide:)]) {
- [reflectionDelegate applicationWillHide:notification];
- }
-
- // When the application is hidden Qt will hide the popup windows associated with
- // it when it has lost the activation for the application. However, when it gets
- // to this point it believes the popup windows to be hidden already due to the
- // fact that the application itself is hidden, which will cause a problem when
- // the application is made visible again.
- const QWindowList topLevelWindows = QGuiApplication::topLevelWindows();
- for (QWindow *topLevelWindow : topLevelWindows) {
- if ((topLevelWindow->type() & Qt::Popup) == Qt::Popup && topLevelWindow->isVisible()) {
- topLevelWindow->hide();
-
- if ((topLevelWindow->type() & Qt::Tool) == Qt::Tool)
- hiddenWindows << topLevelWindow;
- }
- }
-}
-
-- (void)applicationDidUnhide:(NSNotification *)notification
-{
- if (reflectionDelegate
- && [reflectionDelegate respondsToSelector:@selector(applicationDidUnhide:)])
- [reflectionDelegate applicationDidUnhide:notification];
-
- for (QWindow *window : qAsConst(hiddenWindows))
- window->show();
-
- hiddenWindows.clear();
-}
-
- (void)applicationDidBecomeActive:(NSNotification *)notification
{
if (reflectionDelegate
@@ -353,21 +317,6 @@ QT_USE_NAMESPACE
[reflectionDelegate applicationDidBecomeActive:notification];
QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive);
-/*
- onApplicationChangedActivation(true);
-
- if (!QWidget::mouseGrabber()){
- // Update enter/leave immidiatly, don't wait for a move event. But only
- // if no grab exists (even if the grab points to this widget, it seems, ref X11)
- QPoint qlocal, qglobal;
- QWidget *widgetUnderMouse = 0;
- qt_mac_getTargetForMouseEvent(0, QEvent::Enter, qlocal, qglobal, 0, &widgetUnderMouse);
- QApplicationPrivate::dispatchEnterLeave(widgetUnderMouse, 0);
- qt_last_mouse_receiver = widgetUnderMouse;
- qt_last_native_mouse_receiver = widgetUnderMouse ?
- (widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget()) : 0;
- }
-*/
}
- (void)applicationDidResignActive:(NSNotification *)notification
@@ -377,15 +326,6 @@ QT_USE_NAMESPACE
[reflectionDelegate applicationDidResignActive:notification];
QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive);
-/*
- onApplicationChangedActivation(false);
-
- if (!QWidget::mouseGrabber())
- QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver);
- qt_last_mouse_receiver = 0;
- qt_last_native_mouse_receiver = 0;
- qt_button_down = 0;
-*/
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
index ebf33cf4e2..9771cd0289 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
@@ -168,10 +168,10 @@ public:
uint processEventsCalled;
NSModalSession currentModalSessionCached;
NSModalSession currentModalSession();
- void updateChildrenWorksWhenModal();
void temporarilyStopAllModalSessions();
void beginModalSession(QWindow *widget);
void endModalSession(QWindow *widget);
+ bool hasModalSession() const;
void cleanupModalSessions();
void cancelWaitForMoreEvents();
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index b0f2b6d940..84ffadea83 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -672,43 +672,9 @@ NSModalSession QCocoaEventDispatcherPrivate::currentModalSession()
return currentModalSessionCached;
}
-static void setChildrenWorksWhenModal(QWindow *window, bool worksWhenModal)
+bool QCocoaEventDispatcherPrivate::hasModalSession() const
{
- Q_UNUSED(window)
- Q_UNUSED(worksWhenModal)
-
- // For NSPanels (but not NSWindows, sadly), we can set the flag
- // worksWhenModal, so that they are active even when they are not modal.
-/*
- ### not ported
- QList<QDialog *> dialogs = window->findChildren<QDialog *>();
- for (int i=0; i<dialogs.size(); ++i){
- NSWindow *window = qt_mac_window_for(dialogs[i]);
- if (window && [window isKindOfClass:[NSPanel class]]) {
- [static_cast<NSPanel *>(window) setWorksWhenModal:worksWhenModal];
- if (worksWhenModal && [window isVisible]){
- [window orderFront:window];
- }
- }
- }
-*/
-}
-
-void QCocoaEventDispatcherPrivate::updateChildrenWorksWhenModal()
-{
- // Make the dialog children of the window
- // active. And make the dialog children of
- // the previous modal dialog unactive again:
- QMacAutoReleasePool pool;
- int size = cocoaModalSessionStack.size();
- if (size > 0){
- if (QWindow *prevModal = cocoaModalSessionStack[size-1].window)
- setChildrenWorksWhenModal(prevModal, true);
- if (size > 1){
- if (QWindow *prevModal = cocoaModalSessionStack[size-2].window)
- setChildrenWorksWhenModal(prevModal, false);
- }
- }
+ return !cocoaModalSessionStack.isEmpty();
}
void QCocoaEventDispatcherPrivate::cleanupModalSessions()
@@ -743,7 +709,6 @@ void QCocoaEventDispatcherPrivate::cleanupModalSessions()
cocoaModalSessionStack.remove(i);
}
- updateChildrenWorksWhenModal();
cleanupModalSessionsNeeded = false;
}
@@ -764,7 +729,6 @@ void QCocoaEventDispatcherPrivate::beginModalSession(QWindow *window)
// stopped in cleanupModalSessions()).
QCocoaModalSessionInfo info = {window, nullptr, nullptr};
cocoaModalSessionStack.push(info);
- updateChildrenWorksWhenModal();
currentModalSessionCached = nullptr;
}
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm
index 830a387fd1..6a5b0e6e3e 100644
--- a/src/plugins/platforms/cocoa/qcocoascreen.mm
+++ b/src/plugins/platforms/cocoa/qcocoascreen.mm
@@ -410,8 +410,7 @@ QWindow *QCocoaScreen::topLevelAt(const QPoint &point) const
if (![nsWindow conformsToProtocol:@protocol(QNSWindowProtocol)])
continue;
- id<QNSWindowProtocol> proto = static_cast<id<QNSWindowProtocol> >(nsWindow);
- QCocoaWindow *cocoaWindow = proto.platformWindow;
+ QCocoaWindow *cocoaWindow = qnsview_cast(nsWindow.contentView).platformWindow;
if (!cocoaWindow)
continue;
window = cocoaWindow->window();
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 0a913ef66e..fef72bc496 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -253,7 +253,6 @@ public: // for QNSView
bool m_needsInvalidateShadow;
- bool m_hasModalSession;
bool m_frameStrutEventsEnabled;
QRect m_exposedRect;
int m_registerTouchCount;
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index ebdd51acb4..50adbad518 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -153,7 +153,6 @@ QCocoaWindow::QCocoaWindow(QWindow *win, WId nativeHandle)
, m_inSetStyleMask(false)
, m_menubar(nullptr)
, m_needsInvalidateShadow(false)
- , m_hasModalSession(false)
, m_frameStrutEventsEnabled(false)
, m_registerTouchCount(0)
, m_resizableTransientParent(false)
@@ -303,13 +302,17 @@ void QCocoaWindow::setVisible(bool visible)
{
qCDebug(lcQpaWindow) << "QCocoaWindow::setVisible" << window() << visible;
- m_inSetVisible = true;
+ QScopedValueRollback<bool> rollback(m_inSetVisible, true);
QMacAutoReleasePool pool;
QCocoaWindow *parentCocoaWindow = nullptr;
if (window()->transientParent())
parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle());
+ auto eventDispatcher = [] {
+ return static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(qApp->eventDispatcher()));
+ };
+
if (visible) {
// We need to recreate if the modality has changed as the style mask will need updating
recreateWindowIfNeeded();
@@ -350,68 +353,46 @@ void QCocoaWindow::setVisible(bool visible)
applyWindowState(window()->windowStates());
if (window()->windowState() != Qt::WindowMinimized) {
- if ((window()->modality() == Qt::WindowModal
- || window()->type() == Qt::Sheet)
- && parentCocoaWindow) {
- // show the window as a sheet
+ if (parentCocoaWindow && (window()->modality() == Qt::WindowModal || window()->type() == Qt::Sheet)) {
+ // Show the window as a sheet
[parentCocoaWindow->nativeWindow() beginSheet:m_view.window completionHandler:nil];
- } else if (window()->modality() != Qt::NonModal) {
- // show the window as application modal
- QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
- Q_ASSERT(cocoaEventDispatcher);
- QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
- cocoaEventDispatcherPrivate->beginModalSession(window());
- m_hasModalSession = true;
- } else if ([m_view.window canBecomeKeyWindow]) {
- QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
- QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = nullptr;
- if (cocoaEventDispatcher)
- cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
-
- if (cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->cocoaModalSessionStack.isEmpty())
- [m_view.window makeKeyAndOrderFront:nil];
- else
- [m_view.window orderFront:nil];
+ } else if (window()->modality() == Qt::ApplicationModal) {
+ // Show the window as application modal
+ eventDispatcher()->beginModalSession(window());
+ } else if (m_view.window.canBecomeKeyWindow && !eventDispatcher()->hasModalSession()) {
+ [m_view.window makeKeyAndOrderFront:nil];
} else {
[m_view.window orderFront:nil];
}
- // We want the events to properly reach the popup, dialog, and tool
- if ((window()->type() == Qt::Popup || window()->type() == Qt::Dialog || window()->type() == Qt::Tool)
- && [m_view.window isKindOfClass:[NSPanel class]]) {
- ((NSPanel *)m_view.window).worksWhenModal = YES;
- if (!(parentCocoaWindow && window()->transientParent()->isActive()) && window()->type() == Qt::Popup) {
- removeMonitor();
- NSEventMask eventMask = NSEventMaskLeftMouseDown | NSEventMaskRightMouseDown
- | NSEventMaskOtherMouseDown | NSEventMaskMouseMoved;
- monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:eventMask handler:^(NSEvent *e) {
- const auto button = cocoaButton2QtButton(e);
- const auto buttons = currentlyPressedMouseButtons();
- const auto eventType = cocoaEvent2QtMouseEvent(e);
- const auto globalPoint = QCocoaScreen::mapFromNative(NSEvent.mouseLocation);
- const auto localPoint = window()->mapFromGlobal(globalPoint.toPoint());
- QWindowSystemInterface::handleMouseEvent(window(), localPoint, globalPoint, buttons, button, eventType);
- }];
- }
+ // Close popup when clicking outside it
+ if (window()->type() == Qt::Popup && !(parentCocoaWindow && window()->transientParent()->isActive())) {
+ removeMonitor();
+ NSEventMask eventMask = NSEventMaskLeftMouseDown | NSEventMaskRightMouseDown
+ | NSEventMaskOtherMouseDown | NSEventMaskMouseMoved;
+ monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:eventMask handler:^(NSEvent *e) {
+ const auto button = cocoaButton2QtButton(e);
+ const auto buttons = currentlyPressedMouseButtons();
+ const auto eventType = cocoaEvent2QtMouseEvent(e);
+ const auto globalPoint = QCocoaScreen::mapFromNative(NSEvent.mouseLocation);
+ const auto localPoint = window()->mapFromGlobal(globalPoint.toPoint());
+ QWindowSystemInterface::handleMouseEvent(window(), localPoint, globalPoint, buttons, button, eventType);
+ }];
}
}
}
+
// In some cases, e.g. QDockWidget, the content view is hidden before moving to its own
// Cocoa window, and then shown again. Therefore, we test for the view being hidden even
// if it's attached to an NSWindow.
if ([m_view isHidden])
[m_view setHidden:NO];
+
} else {
- // qDebug() << "close" << this;
- QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
- QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = nullptr;
- if (cocoaEventDispatcher)
- cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
+ // Window not visible, hide it
if (isContentView()) {
- if (m_hasModalSession) {
- if (cocoaEventDispatcherPrivate)
- cocoaEventDispatcherPrivate->endModalSession(window());
- m_hasModalSession = false;
+ if (eventDispatcher()->hasModalSession()) {
+ eventDispatcher()->endModalSession(window());
} else {
if ([m_view.window isSheet]) {
Q_ASSERT_X(parentCocoaWindow, "QCocoaWindow", "Window modal dialog has no transient parent.");
@@ -419,10 +400,14 @@ void QCocoaWindow::setVisible(bool visible)
}
}
+ // Note: We do not guard the order out by checking NSWindow.visible, as AppKit will
+ // in some cases, such as when hiding the application, order out and make a window
+ // invisible, but keep it in a list of "hidden windows", that it then restores again
+ // when the application is unhidden. We need to call orderOut explicitly, to bring
+ // the window out of this "hidden list".
[m_view.window orderOut:nil];
- if (m_view.window == [NSApp keyWindow]
- && !(cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->currentModalSession())) {
+ if (m_view.window == [NSApp keyWindow] && !eventDispatcher()->hasModalSession()) {
// Probably because we call runModalSession: outside [NSApp run] in QCocoaEventDispatcher
// (e.g., when show()-ing a modal QDialog instead of exec()-ing it), it can happen that
// the current NSWindow is still key after being ordered out. Then, after checking we
@@ -434,6 +419,7 @@ void QCocoaWindow::setVisible(bool visible)
} else {
[m_view setHidden:YES];
}
+
removeMonitor();
if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
@@ -447,8 +433,6 @@ void QCocoaWindow::setVisible(bool visible)
nativeParentWindow.styleMask |= NSWindowStyleMaskResizable;
}
}
-
- m_inSetVisible = false;
}
NSInteger QCocoaWindow::windowLevel(Qt::WindowFlags flags)
@@ -1560,7 +1544,8 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
// Deferring window creation breaks OpenGL (the GL context is
// set up before the window is shown and needs a proper window)
backing:NSBackingStoreBuffered defer:NO
- screen:cocoaScreen->nativeScreen()];
+ screen:cocoaScreen->nativeScreen()
+ platformWindow:this];
Q_ASSERT_X(nsWindow.screen == cocoaScreen->nativeScreen(), "QCocoaWindow",
"Resulting NSScreen should match the requested NSScreen");
diff --git a/src/plugins/platforms/cocoa/qnswindow.h b/src/plugins/platforms/cocoa/qnswindow.h
index 64f1ed0802..5fc48d826f 100644
--- a/src/plugins/platforms/cocoa/qnswindow.h
+++ b/src/plugins/platforms/cocoa/qnswindow.h
@@ -60,14 +60,10 @@ QT_FORWARD_DECLARE_CLASS(QCocoaWindow)
#define QNSWindowProtocol QT_MANGLE_NAMESPACE(QNSWindowProtocol)
@protocol QNSWindowProtocol
-@optional
-- (BOOL)canBecomeKeyWindow;
-- (void)sendEvent:(NSEvent*)theEvent;
+- (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)style
+ backing:(NSBackingStoreType)backingStoreType defer:(BOOL)flag screen:(NSScreen *)screen
+ platformWindow:(QCocoaWindow*)window;
- (void)closeAndRelease;
-- (void)dealloc;
-- (BOOL)isOpaque;
-- (NSColor *)backgroundColor;
-- (NSString *)description;
@property (nonatomic, readonly) QCocoaWindow *platformWindow;
@end
diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm
index c17ad47aba..52f765eb31 100644
--- a/src/plugins/platforms/cocoa/qnswindow.mm
+++ b/src/plugins/platforms/cocoa/qnswindow.mm
@@ -37,6 +37,8 @@
**
****************************************************************************/
+#if !defined(QNSWINDOW_PROTOCOL_IMPLMENTATION)
+
#include "qnswindow.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
@@ -89,44 +91,104 @@ static bool isMouseEvent(NSEvent *ev)
}
@end
-#define super USE_qt_objcDynamicSuper_INSTEAD
-
@implementation QNSWindow
+#define QNSWINDOW_PROTOCOL_IMPLMENTATION 1
+#include "qnswindow.mm"
+#undef QNSWINDOW_PROTOCOL_IMPLMENTATION
-+ (void)load
++ (void)applicationActivationChanged:(NSNotification*)notification
{
- const Class windowClass = [self class];
- const Class panelClass = [QNSPanel class];
-
- unsigned int protocolCount;
- Protocol **protocols = class_copyProtocolList(windowClass, &protocolCount);
- for (unsigned int i = 0; i < protocolCount; ++i) {
- Protocol *protocol = protocols[i];
-
- unsigned int methodDescriptionsCount;
- objc_method_description *methods = protocol_copyMethodDescriptionList(
- protocol, NO, YES, &methodDescriptionsCount);
-
- for (unsigned int j = 0; j < methodDescriptionsCount; ++j) {
- objc_method_description method = methods[j];
- class_addMethod(panelClass, method.name,
- class_getMethodImplementation(windowClass, method.name),
- method.types);
+ const id sender = self;
+ NSEnumerator<NSWindow*> *windowEnumerator = nullptr;
+ NSApplication *application = [NSApplication sharedApplication];
+
+ // Unfortunately there's no NSWindowListOrderedBackToFront,
+ // so we have to manually reverse the order using an array.
+ NSMutableArray<NSWindow *> *windows = [NSMutableArray<NSWindow *> new];
+ [application enumerateWindowsWithOptions:NSWindowListOrderedFrontToBack
+ usingBlock:^(NSWindow *window, BOOL *) {
+ // For some reason AppKit will give us nil-windows, skip those
+ if (!window)
+ return;
+
+ [windows addObject:window];
+ }
+ ];
+
+ windowEnumerator = windows.reverseObjectEnumerator;
+
+ for (NSWindow *window in windowEnumerator) {
+ // We're meddling with normal and floating windows, so leave others alone
+ if (!(window.level == NSNormalWindowLevel || window.level == NSFloatingWindowLevel))
+ continue;
+
+ // Windows that hide automatically will keep their NSFloatingWindowLevel,
+ // and hence be on top of the window stack. We don't want to affect these
+ // windows, as otherwise we might end up with key windows being ordered
+ // behind these auto-hidden windows when activating the application by
+ // clicking on a new tool window.
+ if (window.hidesOnDeactivate)
+ continue;
+
+ if ([window conformsToProtocol:@protocol(QNSWindowProtocol)]) {
+ QCocoaWindow *cocoaWindow = static_cast<QCocoaNSWindow *>(window).platformWindow;
+ window.level = notification.name == NSApplicationWillResignActiveNotification ?
+ NSNormalWindowLevel : cocoaWindow->windowLevel(cocoaWindow->window()->flags());
}
- free(methods);
+
+ // The documentation says that "when a window enters a new level, it’s ordered
+ // in front of all its peers in that level", but that doesn't seem to be the
+ // case in practice. To keep the order correct after meddling with the window
+ // levels, we explicitly order each window to the front. Since we are iterating
+ // the windows in back-to-front order, this is okey. The call also triggers AppKit
+ // to re-evaluate the level in relation to windows from other applications,
+ // working around an issue where our tool windows would stay on top of other
+ // application windows if activation was transferred to another application by
+ // clicking on it instead of via the application switcher or Dock. Finally, we
+ // do this re-ordering for all windows (except auto-hiding ones), otherwise we would
+ // end up triggering a bug in AppKit where the tool windows would disappear behind
+ // the application window.
+ [window orderFront:sender];
}
+}
+
+@end
+
+@implementation QNSPanel
+#define QNSWINDOW_PROTOCOL_IMPLMENTATION 1
+#include "qnswindow.mm"
+#undef QNSWINDOW_PROTOCOL_IMPLMENTATION
+@end
- free(protocols);
+#else // QNSWINDOW_PROTOCOL_IMPLMENTATION
+
+// The following content is mixed in to the QNSWindow and QNSPanel classes via includes
+
+{
+ // Member variables
+ QPointer<QCocoaWindow> m_platformWindow;
+}
+
+- (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)style
+ backing:(NSBackingStoreType)backingStoreType defer:(BOOL)defer screen:(NSScreen *)screen
+ platformWindow:(QCocoaWindow*)window
+{
+ // Initializing the window will end up in [NSWindow _commonAwake], which calls many
+ // of the getters below. We need to set up the platform window reference first, so
+ // we can properly reflect the window's state during initialization.
+ m_platformWindow = window;
+
+ return [super initWithContentRect:contentRect styleMask:style backing:backingStoreType defer:defer screen:screen];
}
- (QCocoaWindow *)platformWindow
{
- return qnsview_cast(self.contentView).platformWindow;
+ return m_platformWindow;
}
- (NSString *)description
{
- NSMutableString *description = [NSMutableString stringWithString:qt_objcDynamicSuper()];
+ NSMutableString *description = [NSMutableString stringWithString:[super description]];
#ifndef QT_NO_DEBUG_STREAM
QString contentViewDescription;
@@ -142,16 +204,15 @@ static bool isMouseEvent(NSEvent *ev)
- (BOOL)canBecomeKeyWindow
{
- QCocoaWindow *pw = self.platformWindow;
- if (!pw)
+ if (!m_platformWindow)
return NO;
- if (pw->shouldRefuseKeyWindowAndFirstResponder())
+ if (m_platformWindow->shouldRefuseKeyWindowAndFirstResponder())
return NO;
if ([self isKindOfClass:[QNSPanel class]]) {
// Only tool or dialog windows should become key:
- Qt::WindowType type = pw->window()->type();
+ Qt::WindowType type = m_platformWindow->window()->type();
if (type == Qt::Tool || type == Qt::Dialog)
return YES;
@@ -170,17 +231,26 @@ static bool isMouseEvent(NSEvent *ev)
// Windows with a transient parent (such as combobox popup windows)
// cannot become the main window:
- QCocoaWindow *pw = self.platformWindow;
- if (!pw || pw->window()->transientParent())
+ if (!m_platformWindow || m_platformWindow->window()->transientParent())
canBecomeMain = NO;
return canBecomeMain;
}
+- (BOOL)worksWhenModal
+{
+ if (m_platformWindow && [self isKindOfClass:[QNSPanel class]]) {
+ Qt::WindowType type = m_platformWindow->window()->type();
+ if (type == Qt::Popup || type == Qt::Dialog || type == Qt::Tool)
+ return YES;
+ }
+
+ return [super worksWhenModal];
+}
+
- (BOOL)isOpaque
{
- return self.platformWindow ?
- self.platformWindow->isOpaque() : qt_objcDynamicSuper();
+ return m_platformWindow ? m_platformWindow->isOpaque() : [super isOpaque];
}
/*!
@@ -196,7 +266,7 @@ static bool isMouseEvent(NSEvent *ev)
- (NSColor *)backgroundColor
{
return self.styleMask == NSWindowStyleMaskBorderless
- ? [NSColor clearColor] : qt_objcDynamicSuper();
+ ? [NSColor clearColor] : [super backgroundColor];
}
- (void)sendEvent:(NSEvent*)theEvent
@@ -208,7 +278,7 @@ static bool isMouseEvent(NSEvent *ev)
// e.g. if being retained by other parts of AppKit, or in an auto-release
// pool. We guard against this in QNSView as well, as not all callbacks
// come via events, but if they do there's no point in propagating them.
- if (!self.platformWindow)
+ if (!m_platformWindow)
return;
// Prevent deallocation of this NSWindow during event delivery, as we
@@ -216,23 +286,22 @@ static bool isMouseEvent(NSEvent *ev)
[[self retain] autorelease];
const char *eventType = object_getClassName(theEvent);
- if (QWindowSystemInterface::handleNativeEvent(self.platformWindow->window(),
+ if (QWindowSystemInterface::handleNativeEvent(m_platformWindow->window(),
QByteArray::fromRawData(eventType, qstrlen(eventType)), theEvent, nullptr)) {
return;
}
- qt_objcDynamicSuper(theEvent);
+ [super sendEvent:theEvent];
- if (!self.platformWindow)
+ if (!m_platformWindow)
return; // Platform window went away while processing event
- QCocoaWindow *pw = self.platformWindow;
- if (pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
+ if (m_platformWindow->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
NSPoint loc = [theEvent locationInWindow];
NSRect windowFrame = [self convertRectFromScreen:self.frame];
NSRect contentFrame = self.contentView.frame;
if (NSMouseInRect(loc, windowFrame, NO) && !NSMouseInRect(loc, contentFrame, NO))
- [qnsview_cast(pw->view()) handleFrameStrutMouseEvent:theEvent];
+ [qnsview_cast(m_platformWindow->view()) handleFrameStrutMouseEvent:theEvent];
}
}
@@ -243,77 +312,12 @@ static bool isMouseEvent(NSEvent *ev)
[self release];
}
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
- (void)dealloc
{
qCDebug(lcQpaWindow) << "Deallocating" << self;
self.delegate = nil;
- qt_objcDynamicSuper();
+ [super dealloc];
}
-#pragma clang diagnostic pop
-
-+ (void)applicationActivationChanged:(NSNotification*)notification
-{
- const id sender = self;
- NSEnumerator<NSWindow*> *windowEnumerator = nullptr;
- NSApplication *application = [NSApplication sharedApplication];
-
- // Unfortunately there's no NSWindowListOrderedBackToFront,
- // so we have to manually reverse the order using an array.
- NSMutableArray<NSWindow *> *windows = [NSMutableArray<NSWindow *> new];
- [application enumerateWindowsWithOptions:NSWindowListOrderedFrontToBack
- usingBlock:^(NSWindow *window, BOOL *) {
- // For some reason AppKit will give us nil-windows, skip those
- if (!window)
- return;
-
- [windows addObject:window];
- }
- ];
-
- windowEnumerator = windows.reverseObjectEnumerator;
- for (NSWindow *window in windowEnumerator) {
- // We're meddling with normal and floating windows, so leave others alone
- if (!(window.level == NSNormalWindowLevel || window.level == NSFloatingWindowLevel))
- continue;
-
- // Windows that hide automatically will keep their NSFloatingWindowLevel,
- // and hence be on top of the window stack. We don't want to affect these
- // windows, as otherwise we might end up with key windows being ordered
- // behind these auto-hidden windows when activating the application by
- // clicking on a new tool window.
- if (window.hidesOnDeactivate)
- continue;
-
- if ([window conformsToProtocol:@protocol(QNSWindowProtocol)]) {
- QCocoaWindow *cocoaWindow = static_cast<QCocoaNSWindow *>(window).platformWindow;
- window.level = notification.name == NSApplicationWillResignActiveNotification ?
- NSNormalWindowLevel : cocoaWindow->windowLevel(cocoaWindow->window()->flags());
- }
-
- // The documentation says that "when a window enters a new level, it’s ordered
- // in front of all its peers in that level", but that doesn't seem to be the
- // case in practice. To keep the order correct after meddling with the window
- // levels, we explicitly order each window to the front. Since we are iterating
- // the windows in back-to-front order, this is okey. The call also triggers AppKit
- // to re-evaluate the level in relation to windows from other applications,
- // working around an issue where our tool windows would stay on top of other
- // application windows if activation was transferred to another application by
- // clicking on it instead of via the application switcher or Dock. Finally, we
- // do this re-ordering for all windows (except auto-hiding ones), otherwise we would
- // end up triggering a bug in AppKit where the tool windows would disappear behind
- // the application window.
- [window orderFront:sender];
- }
-}
-
-@end
-
-@implementation QNSPanel
-// Implementation shared with QNSWindow, see +[QNSWindow load] above
-@end
-
-#undef super
+#endif
diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp
index 7f1854c601..e611c7be24 100644
--- a/src/plugins/platforms/winrt/qwinrtscreen.cpp
+++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp
@@ -511,6 +511,7 @@ public:
QWindow *currentPressWindow = nullptr;
QWindow *currentTargetWindow = nullptr;
bool firstMouseMove = true;
+ bool resizePending = false;
};
// To be called from the XAML thread
@@ -1402,6 +1403,18 @@ void QWinRTScreen::emulateMouseMove(const QPointF &point, MousePositionTransitio
Qt::NoModifier);
}
+void QWinRTScreen::setResizePending()
+{
+ Q_D(QWinRTScreen);
+ d->resizePending = true;
+}
+
+bool QWinRTScreen::resizePending() const
+{
+ Q_D(const QWinRTScreen);
+ return d->resizePending;
+}
+
HRESULT QWinRTScreen::onActivated(ICoreWindow *, IWindowActivatedEventArgs *args)
{
Q_D(QWinRTScreen);
@@ -1507,7 +1520,7 @@ HRESULT QWinRTScreen::onRedirectReleased(ICorePointerRedirector *, IPointerEvent
return onPointerUpdated(nullptr, args);
}
-HRESULT QWinRTScreen::onWindowSizeChanged(IApplicationView *, IInspectable *)
+HRESULT QWinRTScreen::onWindowSizeChanged(IApplicationView *w, IInspectable *)
{
Q_D(QWinRTScreen);
@@ -1527,6 +1540,9 @@ HRESULT QWinRTScreen::onWindowSizeChanged(IApplicationView *, IInspectable *)
QWindowSystemInterface::handleScreenGeometryChange(screen(), geometry(), availableGeometry());
QPlatformScreen::resizeMaximizedWindows();
handleExpose();
+ // If we "emulate" a resize, w will be nullptr.Checking w shows whether it's a real resize
+ if (w)
+ d->resizePending = false;
return S_OK;
}
diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h
index e28cfd8cc8..63c254940d 100644
--- a/src/plugins/platforms/winrt/qwinrtscreen.h
+++ b/src/plugins/platforms/winrt/qwinrtscreen.h
@@ -136,6 +136,9 @@ public:
void emulateMouseMove(const QPointF &point, MousePositionTransition transition);
+ void setResizePending();
+ bool resizePending() const;
+
private:
void handleExpose();
diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp
index 83c3715bfd..73816b6512 100644
--- a/src/plugins/platforms/winrt/qwinrtwindow.cpp
+++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp
@@ -225,7 +225,8 @@ bool QWinRTWindow::isActive() const
bool QWinRTWindow::isExposed() const
{
- const bool exposed = isActive();
+ Q_D(const QWinRTWindow);
+ const bool exposed = isActive() && !d->screen->resizePending();
return exposed;
}
@@ -360,6 +361,7 @@ void QWinRTWindow::setWindowState(Qt::WindowStates state)
qCDebug(lcQpaWindows) << "Failed to enter full screen mode.";
return;
}
+ d->screen->setResizePending();
d->state = state;
return;
}
@@ -384,6 +386,7 @@ void QWinRTWindow::setWindowState(Qt::WindowStates state)
qCDebug(lcQpaWindows) << "Failed to exit full screen mode.";
return;
}
+ d->screen->setResizePending();
}
if (d->state & Qt::WindowMinimized || state == Qt::WindowNoState || state == Qt::WindowActive)
diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp
index 6f08238bcc..cf85c244cd 100644
--- a/src/tools/androiddeployqt/main.cpp
+++ b/src/tools/androiddeployqt/main.cpp
@@ -43,6 +43,15 @@
#include <QRegExp>
#include <algorithm>
+
+#ifdef Q_CC_MSVC
+#define popen _popen
+#define QT_POPEN_READ "rb"
+#define pclose _pclose
+#else
+#define QT_POPEN_READ "r"
+#endif
+
static const bool mustReadOutputAnyway = true; // pclose seems to return the wrong error code unless we read the output
void deleteRecursively(const QString &dirName)
@@ -70,7 +79,7 @@ FILE *openProcess(const QString &command)
QString processedCommand = command;
#endif
- return popen(processedCommand.toLocal8Bit().constData(), "r");
+ return popen(processedCommand.toLocal8Bit().constData(), QT_POPEN_READ);
}
struct QtDependency
@@ -1721,7 +1730,7 @@ bool scanImports(Options *options, QSet<QString> *usedDependencies)
.arg(shellQuote(rootPath))
.arg(importPaths.join(QLatin1Char(' ')));
- FILE *qmlImportScannerCommand = popen(qmlImportScanner.toLocal8Bit().constData(), "r");
+ FILE *qmlImportScannerCommand = popen(qmlImportScanner.toLocal8Bit().constData(), QT_POPEN_READ);
if (qmlImportScannerCommand == 0) {
fprintf(stderr, "Couldn't run qmlimportscanner.\n");
return false;
@@ -2160,7 +2169,7 @@ bool createAndroidProject(const Options &options)
if (options.verbose)
fprintf(stdout, " -- Command: %s\n", qPrintable(androidTool));
- FILE *androidToolCommand = popen(androidTool.toLocal8Bit().constData(), "r");
+ FILE *androidToolCommand = popen(androidTool.toLocal8Bit().constData(), QT_POPEN_READ);
if (androidToolCommand == 0) {
fprintf(stderr, "Cannot run command '%s'\n", qPrintable(androidTool));
return false;
diff --git a/src/tools/moc/util/generate_keywords.pro b/src/tools/moc/util/generate_keywords.pro
index 88e5553f54..2bbc3ced61 100644
--- a/src/tools/moc/util/generate_keywords.pro
+++ b/src/tools/moc/util/generate_keywords.pro
@@ -1,4 +1,4 @@
CONFIG -= moc
-mac:CONFIG -= app_bundle
+CONFIG += cmdline
SOURCES += generate_keywords.cpp
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index c66400f423..41d9faa5c2 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -1092,6 +1092,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event)
d->setSelected(d->currentSectionIndex, true);
event->ignore();
emit editingFinished();
+ emit d->edit->returnPressed();
return;
default:
#ifdef QT_KEYPAD_NAVIGATION