diff options
Diffstat (limited to 'src')
32 files changed, 359 insertions, 100 deletions
diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp index 8be6ae7d2f..d41c5a4da5 100644 --- a/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp +++ b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp @@ -659,7 +659,11 @@ void GL_APIENTRY BlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLi { if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter, +#ifndef ANGLE_ENABLE_WINDOWS_STORE true)) +#else + false)) +#endif { return; } diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java b/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java index 408636dcf3..5181cc7e11 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java @@ -65,8 +65,8 @@ public class QtLayout extends ViewGroup { DisplayMetrics metrics = new DisplayMetrics(); ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); - QtNative.setApplicationDisplayMetrics(metrics.widthPixels, - metrics.heightPixels, w, h, metrics.xdpi, metrics.ydpi, metrics.scaledDensity); + QtNative.setApplicationDisplayMetrics(metrics.widthPixels, metrics.heightPixels, w, h, + metrics.xdpi, metrics.ydpi, metrics.scaledDensity, metrics.density); if (m_startApplicationRunnable != null) { m_startApplicationRunnable.run(); m_startApplicationRunnable = null; 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 07ef6d657d..371e4e4a61 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -77,6 +77,7 @@ public class QtNative private static double m_displayMetricsXDpi = .0; private static double m_displayMetricsYDpi = .0; private static double m_displayMetricsScaledDensity = 1.0; + private static double m_displayMetricsDensity = 1.0; private static int m_oldx, m_oldy; private static final int m_moveThreshold = 0; private static ClipboardManager m_clipboardManager = null; @@ -229,7 +230,8 @@ public class QtNative m_displayMetricsDesktopHeightPixels, m_displayMetricsXDpi, m_displayMetricsYDpi, - m_displayMetricsScaledDensity); + m_displayMetricsScaledDensity, + m_displayMetricsDensity); if (params.length() > 0 && !params.startsWith("\t")) params = "\t" + params; startQtApplication(f.getAbsolutePath() + params, environment); @@ -244,7 +246,8 @@ public class QtNative int desktopHeightPixels, double XDpi, double YDpi, - double scaledDensity) + double scaledDensity, + double density) { /* Fix buggy dpi report */ if (XDpi < android.util.DisplayMetrics.DENSITY_LOW) @@ -260,7 +263,8 @@ public class QtNative desktopHeightPixels, XDpi, YDpi, - scaledDensity); + scaledDensity, + density); } else { m_displayMetricsScreenWidthPixels = screenWidthPixels; m_displayMetricsScreenHeightPixels = screenHeightPixels; @@ -269,6 +273,7 @@ public class QtNative m_displayMetricsXDpi = XDpi; m_displayMetricsYDpi = YDpi; m_displayMetricsScaledDensity = scaledDensity; + m_displayMetricsDensity = density; } } } @@ -621,7 +626,8 @@ public class QtNative int desktopHeightPixels, double XDpi, double YDpi, - double scaledDensity); + double scaledDensity, + double density); public static native void handleOrientationChanged(int newRotation, int nativeOrientation); // screen methods diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java index e5ed690f07..146d6b34f2 100644 --- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java +++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java @@ -897,6 +897,12 @@ public class QtActivity extends Activity } else { ENVIRONMENT_VARIABLES += "QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED=1\t"; } + + if (m_activityInfo.metaData.containsKey("android.app.auto_screen_scale_factor") + && m_activityInfo.metaData.getBoolean("android.app.auto_screen_scale_factor")) { + ENVIRONMENT_VARIABLES += "QT_AUTO_SCREEN_SCALE_FACTOR=1\t"; + } + startApp(true); } } diff --git a/src/android/templates/AndroidManifest.xml b/src/android/templates/AndroidManifest.xml index ad240956ef..262a5f6dba 100644 --- a/src/android/templates/AndroidManifest.xml +++ b/src/android/templates/AndroidManifest.xml @@ -44,6 +44,10 @@ signal is sent! --> <meta-data android:name="android.app.background_running" android:value="false"/> <!-- Background running --> + + <!-- auto screen scale factor --> + <meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/> + <!-- auto screen scale factor --> </activity> </application> <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14"/> diff --git a/src/angle/patches/0009-ANGLE-Fix-winrt-backing-store-to-support-feature-lev.patch b/src/angle/patches/0009-ANGLE-Fix-winrt-backing-store-to-support-feature-lev.patch new file mode 100644 index 0000000000..8f66b0c1d8 --- /dev/null +++ b/src/angle/patches/0009-ANGLE-Fix-winrt-backing-store-to-support-feature-lev.patch @@ -0,0 +1,38 @@ +From 54461670e035ffcb41268a02e9b0c441cc008ddb Mon Sep 17 00:00:00 2001 +From: Samuel Nevala <samuel.nevala@intopalo.com> +Date: Thu, 22 Oct 2015 14:02:28 +0300 +Subject: [PATCH] ANGLE: Fix winrt backing store to support feature level 9_3 + devices. + +Partially revert c7abf81786f4a0c. Instead of using ES3 entry point +use ES2 for blitting. Small change is also required to ANGLE that +makes ES2 entry to behave same as ES3. + +Task-Id: QTBUG-48266 +Change-Id: Idc51f00a659c91f740876be071eb71bff69e0e38 +--- + .../src/libGLESv2/entry_points_gles_2_0_ext.cpp | 4 +++ + ...inrt-backing-store-to-support-feature-lev.patch | 33 ++++++++++++++++++++++ + src/plugins/platforms/winrt/qwinrtbackingstore.cpp | 11 ++++---- + 3 files changed, 42 insertions(+), 6 deletions(-) + create mode 100644 src/angle/patches/0009-ANGLE-Fix-winrt-backing-store-to-support-feature-lev.patch + +diff --git a/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp +index 8be6ae7..d41c5a4 100644 +--- a/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp ++++ b/src/3rdparty/angle/src/libGLESv2/entry_points_gles_2_0_ext.cpp +@@ -659,7 +659,11 @@ void GL_APIENTRY BlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLi + { + if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, mask, filter, ++#ifndef ANGLE_ENABLE_WINDOWS_STORE + true)) ++#else ++ false)) ++#endif + { + return; + } +-- +1.9.5.msysgit.1 + diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 02220d0db2..ed8a9163d4 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -120,9 +120,7 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n); // (if this list becomes too long, consider factoring into a separate file) Q_STATIC_ASSERT_X(sizeof(int) == 4, "Qt assumes that int is 32 bits"); Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits"); -#ifndef QT_BOOTSTRAPPED -Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "configure test ptrsize failed to correctly determine QT_POINTER_SIZE"); -#endif +Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined incorrectly"); /*! \class QFlag diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index d86e410194..db8c60831f 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -193,18 +193,6 @@ typedef unsigned long long quint64; /* 64 bit unsigned */ typedef qint64 qlonglong; typedef quint64 qulonglong; -#ifndef QT_POINTER_SIZE -# if defined(Q_OS_WIN64) || (defined(Q_OS_WINRT) && defined(_M_X64)) -# define QT_POINTER_SIZE 8 -# elif defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT) -# define QT_POINTER_SIZE 4 -# elif defined(Q_OS_ANDROID) -# define QT_POINTER_SIZE 4 // ### Add auto-detection to Windows configure -# elif !defined(QT_BOOTSTRAPPED) -# error could not determine QT_POINTER_SIZE -# endif -#endif - /* Useful type definitions for Qt */ diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h index a026224021..4b75872bb6 100644 --- a/src/corelib/global/qprocessordetection.h +++ b/src/corelib/global/qprocessordetection.h @@ -91,6 +91,7 @@ # define Q_PROCESSOR_ARM # if defined(__aarch64__) # define Q_PROCESSOR_ARM_64 +# define Q_PROCESSOR_WORDSIZE 8 # else # define Q_PROCESSOR_ARM_32 # endif @@ -228,6 +229,7 @@ # endif # if defined(_MIPS_ARCH_MIPS64) || defined(__mips64) # define Q_PROCESSOR_MIPS_64 +# define Q_PROCESSOR_WORDSIZE 8 # endif # if defined(__MIPSEL__) # define Q_BYTE_ORDER Q_LITTLE_ENDIAN @@ -252,6 +254,7 @@ # define Q_PROCESSOR_POWER # if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__) # define Q_PROCESSOR_POWER_64 +# define Q_PROCESSOR_WORDSIZE 8 # else # define Q_PROCESSOR_POWER_32 # endif @@ -323,6 +326,28 @@ #endif /* + Size of a pointer and the machine register size. We detect a 64-bit system by: + * GCC and compatible compilers (Clang, ICC on OS X and Windows) always define + __SIZEOF_POINTER__. This catches all known cases of ILP32 builds on 64-bit + processors. + * Most other Unix compilers define __LP64__ or _LP64 on 64-bit mode + (Long and Pointer 64-bit) + * If Q_PROCESSOR_WORDSIZE was defined above, it's assumed to match the pointer + size. + Otherwise, we assume to be 32-bit and then check in qglobal.cpp that it is right. +*/ + +#if defined __SIZEOF_POINTER__ +# define QT_POINTER_SIZE __SIZEOF_POINTER__ +#elif defined(__LP64__) || defined(_LP64) +# define QT_POINTER_SIZE 8 +#elif defined(Q_PROCESSOR_WORDSIZE) +# define QT_POINTER_SIZE Q_PROCESSOR_WORDSIZE +#else +# define QT_POINTER_SIZE 4 +#endif + +/* Define Q_PROCESSOR_WORDSIZE to be the size of the machine's word (usually, the size of the register). On some architectures where a pointer could be smaller than the register, the macro is defined above. @@ -330,14 +355,8 @@ Falls back to QT_POINTER_SIZE if not set explicitly for the platform. */ #ifndef Q_PROCESSOR_WORDSIZE -# ifdef __SIZEOF_POINTER__ - /* GCC & friends define this */ -# define Q_PROCESSOR_WORDSIZE __SIZEOF_POINTER__ -# elif defined(_LP64) || defined(__LP64__) || defined(WIN64) || defined(_WIN64) -# define Q_PROCESSOR_WORDSIZE 8 -# else -# define Q_PROCESSOR_WORDSIZE QT_POINTER_SIZE -# endif +# define Q_PROCESSOR_WORDSIZE QT_POINTER_SIZE #endif + #endif // QPROCESSORDETECTION_H diff --git a/src/corelib/kernel/qsharedmemory_android.cpp b/src/corelib/kernel/qsharedmemory_android.cpp index cdcd5685e0..12afff5dce 100644 --- a/src/corelib/kernel/qsharedmemory_android.cpp +++ b/src/corelib/kernel/qsharedmemory_android.cpp @@ -50,12 +50,12 @@ QSharedMemoryPrivate::QSharedMemoryPrivate() void QSharedMemoryPrivate::setErrorString(QLatin1String function) { Q_UNUSED(function); - qWarning() << Q_FUNC_INFO << "Not yet implemented on Android"; + Q_UNIMPLEMENTED(); } key_t QSharedMemoryPrivate::handle() { - qWarning() << Q_FUNC_INFO << "Not yet implemented on Android"; + Q_UNIMPLEMENTED(); return 0; } @@ -65,7 +65,7 @@ key_t QSharedMemoryPrivate::handle() int QSharedMemoryPrivate::createUnixKeyFile(const QString &fileName) { Q_UNUSED(fileName); - qWarning() << Q_FUNC_INFO << "Not yet implemented on Android"; + Q_UNIMPLEMENTED(); return 0; } #endif // QT_NO_SHAREDMEMORY && QT_NO_SYSTEMSEMAPHORE @@ -74,27 +74,27 @@ int QSharedMemoryPrivate::createUnixKeyFile(const QString &fileName) bool QSharedMemoryPrivate::cleanHandle() { - qWarning() << Q_FUNC_INFO << "Not yet implemented on Android"; + Q_UNIMPLEMENTED(); return true; } bool QSharedMemoryPrivate::create(int size) { Q_UNUSED(size); - qWarning() << Q_FUNC_INFO << "Not yet implemented on Android"; + Q_UNIMPLEMENTED(); return false; } bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode) { Q_UNUSED(mode); - qWarning() << Q_FUNC_INFO << "Not yet implemented on Android"; + Q_UNIMPLEMENTED(); return false; } bool QSharedMemoryPrivate::detach() { - qWarning() << Q_FUNC_INFO << "Not yet implemented on Android"; + Q_UNIMPLEMENTED(); return false; } diff --git a/src/corelib/kernel/qsystemsemaphore_android.cpp b/src/corelib/kernel/qsystemsemaphore_android.cpp index f501779db9..536b09bb41 100644 --- a/src/corelib/kernel/qsystemsemaphore_android.cpp +++ b/src/corelib/kernel/qsystemsemaphore_android.cpp @@ -49,25 +49,25 @@ QSystemSemaphorePrivate::QSystemSemaphorePrivate() : void QSystemSemaphorePrivate::setErrorString(const QString &function) { Q_UNUSED(function); - qWarning() << Q_FUNC_INFO << "Not yet implemented on Android"; + Q_UNIMPLEMENTED(); } key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode) { Q_UNUSED(mode); - qWarning() << Q_FUNC_INFO << "Not yet implemented on Android"; + Q_UNIMPLEMENTED(); return -1; } void QSystemSemaphorePrivate::cleanHandle() { - qWarning() << Q_FUNC_INFO << "Not yet implemented on Android"; + Q_UNIMPLEMENTED(); } bool QSystemSemaphorePrivate::modifySemaphore(int count) { Q_UNUSED(count); - qWarning() << Q_FUNC_INFO << "Not yet implemented on Android"; + Q_UNIMPLEMENTED(); return false; } diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 2e0595152b..216537e51a 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -129,6 +129,8 @@ QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive; +bool QGuiApplicationPrivate::highDpiScalingUpdated = false; + QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; @@ -1051,6 +1053,13 @@ static void init_platform(const QString &pluginArgument, const QString &platform return; } + // Many platforms have created QScreens at this point. Finish initializing + // QHighDpiScaling to be prepared for early calls to qt_defaultDpi(). + if (QGuiApplication::primaryScreen()) { + QGuiApplicationPrivate::highDpiScalingUpdated = true; + QHighDpiScaling::updateHighDpiScaling(); + } + // Create the platform theme: // 1) Fetch the platform name from the environment if present. @@ -1220,9 +1229,10 @@ void QGuiApplicationPrivate::eventDispatcherReady() platform_integration->initialize(); - // Do this here in order to play nice with platforms that add screens only - // in initialize(). - QHighDpiScaling::updateHighDpiScaling(); + // All platforms should have added screens at this point. Finish + // QHighDpiScaling initialization if it has not been done so already. + if (!QGuiApplicationPrivate::highDpiScalingUpdated) + QHighDpiScaling::updateHighDpiScaling(); } void QGuiApplicationPrivate::init() diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 0559442049..c3c5acf17c 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -202,6 +202,7 @@ public: static QWindow *currentMouseWindow; static QWindow *currentMousePressWindow; static Qt::ApplicationState applicationState; + static bool highDpiScalingUpdated; #ifndef QT_NO_CLIPBOARD static QClipboard *qt_clipboard; diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 6cfc4b9307..5c1cd8adef 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1257,9 +1257,8 @@ static inline void qConvertARGB64PMToA2RGB30PM_sse2(uint *dest, const QRgba64 *b const __m128i cmask = _mm_set1_epi32(0x000003ff); int i = 0; __m128i vr, vg, vb, va; - if (i < count && (const uintptr_t)buffer & 0x8) { + for (; i < count && (const uintptr_t)buffer & 0xF; ++i) { *dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++); - ++i; } for (; i < count-15; i += 16) { diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 513fdfa2b6..3a686bd209 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -548,11 +548,11 @@ void SegmentTree::produceIntersectionsLeaf(const TreeNode &node, int segment) for (int k = 0; k < m_intersections.size(); ++k) { QPathSegments::Intersection i_isect, j_isect; - i_isect.vertex = j_isect.vertex = m_segments.addPoint(m_intersections.at(k).pos); - i_isect.t = m_intersections.at(k).alphaA; j_isect.t = m_intersections.at(k).alphaB; + i_isect.vertex = j_isect.vertex = m_segments.addPoint(m_intersections.at(k).pos); + i_isect.next = 0; j_isect.next = 0; diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h index 36330052dd..d1caea4a1a 100644 --- a/src/gui/painting/qpathclipper_p.h +++ b/src/gui/painting/qpathclipper_p.h @@ -156,9 +156,8 @@ class QPathSegments { public: struct Intersection { - int vertex; qreal t; - + int vertex; int next; bool operator<(const Intersection &o) const { diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index bef4dc5547..6567859a5b 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -960,6 +960,7 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph) pt.x = -glyph_x; pt.y = -glyph_y; // the baseline QPainterPath path; + path.setFillRule(Qt::WindingFill); QImage im(glyph_width + 4, glyph_height, QImage::Format_ARGB32_Premultiplied); im.fill(Qt::transparent); QPainter p(&im); diff --git a/src/network/access/qnetworkaccesscache.cpp b/src/network/access/qnetworkaccesscache.cpp index 19316bda75..3d029f118b 100644 --- a/src/network/access/qnetworkaccesscache.cpp +++ b/src/network/access/qnetworkaccesscache.cpp @@ -151,7 +151,7 @@ void QNetworkAccessCache::linkEntry(const QByteArray &key) oldest = node; } - node->timestamp = QDateTime::currentDateTime().addSecs(ExpiryTime); + node->timestamp = QDateTime::currentDateTimeUtc().addSecs(ExpiryTime); newest = node; } @@ -190,7 +190,7 @@ void QNetworkAccessCache::updateTimer() if (!oldest) return; - int interval = QDateTime::currentDateTime().secsTo(oldest->timestamp); + int interval = QDateTime::currentDateTimeUtc().secsTo(oldest->timestamp); if (interval <= 0) { interval = 0; } else { @@ -216,7 +216,7 @@ bool QNetworkAccessCache::emitEntryReady(Node *node, QObject *target, const char void QNetworkAccessCache::timerEvent(QTimerEvent *) { // expire old items - QDateTime now = QDateTime::currentDateTime(); + const QDateTime now = QDateTime::currentDateTimeUtc(); while (oldest && oldest->timestamp < now) { Node *next = oldest->newer; diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 99cb58830c..d419e42cd5 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -55,6 +55,7 @@ #include <QtCore/private/qjnihelpers_p.h> #include <QtCore/private/qjni_p.h> #include <QtGui/private/qguiapplication_p.h> +#include <QtGui/private/qhighdpiscaling_p.h> #include <qpa/qwindowsysteminterface.h> @@ -109,6 +110,7 @@ static QAndroidPlatformIntegration *m_androidPlatformIntegration = nullptr; static int m_desktopWidthPixels = 0; static int m_desktopHeightPixels = 0; static double m_scaledDensity = 0; +static double m_density = 1.0; static volatile bool m_pauseApplication; @@ -157,6 +159,11 @@ namespace QtAndroid return m_scaledDensity; } + double pixelDensity() + { + return m_density; + } + JavaVM *javaVM() { return m_javaVM; @@ -547,7 +554,8 @@ static void setSurface(JNIEnv *env, jobject /*thiz*/, jint id, jobject jSurface, static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, jint widthPixels, jint heightPixels, jint desktopWidthPixels, jint desktopHeightPixels, - jdouble xdpi, jdouble ydpi, jdouble scaledDensity) + jdouble xdpi, jdouble ydpi, + jdouble scaledDensity, jdouble density) { // Android does not give us the correct screen size for immersive mode, but // the surface does have the right size @@ -558,6 +566,7 @@ static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, m_desktopWidthPixels = desktopWidthPixels; m_desktopHeightPixels = desktopHeightPixels; m_scaledDensity = scaledDensity; + m_density = density; if (!m_androidPlatformIntegration) { QAndroidPlatformIntegration::setDefaultDisplayMetrics(desktopWidthPixels, @@ -683,7 +692,7 @@ static JNINativeMethod methods[] = { {"startQtApplication", "(Ljava/lang/String;Ljava/lang/String;)V", (void *)startQtApplication}, {"quitQtAndroidPlugin", "()V", (void *)quitQtAndroidPlugin}, {"terminateQt", "()V", (void *)terminateQt}, - {"setDisplayMetrics", "(IIIIDDD)V", (void *)setDisplayMetrics}, + {"setDisplayMetrics", "(IIIIDDDD)V", (void *)setDisplayMetrics}, {"setSurface", "(ILjava/lang/Object;II)V", (void *)setSurface}, {"updateWindow", "()V", (void *)updateWindow}, {"updateApplicationState", "(I)V", (void *)updateApplicationState}, diff --git a/src/plugins/platforms/android/androidjnimain.h b/src/plugins/platforms/android/androidjnimain.h index 4d037f4b74..cdedeb38f8 100644 --- a/src/plugins/platforms/android/androidjnimain.h +++ b/src/plugins/platforms/android/androidjnimain.h @@ -71,6 +71,7 @@ namespace QtAndroid int desktopWidthPixels(); int desktopHeightPixels(); double scaledDensity(); + double pixelDensity(); JavaVM *javaVM(); AAssetManager *assetManager(); jclass applicationClass(); diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index 7a509e4d61..209ce2f7db 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -382,6 +382,11 @@ QDpi QAndroidPlatformScreen::logicalDpi() const return QDpi(lDpi, lDpi); } +qreal QAndroidPlatformScreen::pixelDensity() const +{ + return QtAndroid::pixelDensity(); +} + Qt::ScreenOrientation QAndroidPlatformScreen::orientation() const { return QAndroidPlatformIntegration::m_orientation; diff --git a/src/plugins/platforms/android/qandroidplatformscreen.h b/src/plugins/platforms/android/qandroidplatformscreen.h index f4f9cedb70..1b7bc91c83 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.h +++ b/src/plugins/platforms/android/qandroidplatformscreen.h @@ -95,6 +95,7 @@ protected: private: QDpi logicalDpi() const; + qreal pixelDensity() const; Qt::ScreenOrientation orientation() const; Qt::ScreenOrientation nativeOrientation() const; void surfaceChanged(JNIEnv *env, jobject surface, int w, int h); diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp index 3e2ae7c939..71a3f910d2 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.cpp +++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp @@ -31,6 +31,7 @@ ** ****************************************************************************/ +#include "androidjnimain.h" #include "androidjnimenu.h" #include "qandroidplatformtheme.h" #include "qandroidplatformmenubar.h" @@ -216,6 +217,7 @@ QJsonObject AndroidStyle::loadStyleData() static std::shared_ptr<AndroidStyle> loadAndroidStyle(QPalette *defaultPalette) { + double pixelDensity = qEnvironmentVariableIsSet("QT_AUTO_SCREEN_SCALE_FACTOR") ? QtAndroid::pixelDensity() : 1.0; std::shared_ptr<AndroidStyle> style(new AndroidStyle); style->m_styleData = AndroidStyle::loadStyleData(); if (style->m_styleData.isEmpty()) @@ -245,7 +247,7 @@ static std::shared_ptr<AndroidStyle> loadAndroidStyle(QPalette *defaultPalette) // Font size (in pixels) attributeIterator = item.find(QLatin1String("TextAppearance_textSize")); if (attributeIterator != item.constEnd()) - font.setPixelSize(int(attributeIterator.value().toDouble())); + font.setPixelSize(int(attributeIterator.value().toDouble() / pixelDensity)); // Font style attributeIterator = item.find(QLatin1String("TextAppearance_textStyle")); diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.h b/src/plugins/platforms/cocoa/qcocoainputcontext.h index c7df823dc4..054c4795cb 100644 --- a/src/plugins/platforms/cocoa/qcocoainputcontext.h +++ b/src/plugins/platforms/cocoa/qcocoainputcontext.h @@ -35,6 +35,7 @@ #define QCOCOAINPUTCONTEXT_H #include <qpa/qplatforminputcontext.h> +#include <QtCore/QLocale> #include <QtCore/QPointer> QT_BEGIN_NAMESPACE @@ -50,12 +51,16 @@ public: void reset() Q_DECL_OVERRIDE; + QLocale locale() const Q_DECL_OVERRIDE { return m_locale; } + void updateLocale(); + private Q_SLOTS: void connectSignals(); void focusObjectChanged(QObject *focusObject); private: QPointer<QWindow> mWindow; + QLocale m_locale; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.mm b/src/plugins/platforms/cocoa/qcocoainputcontext.mm index f072991bdd..7d01826ffe 100644 --- a/src/plugins/platforms/cocoa/qcocoainputcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoainputcontext.mm @@ -36,6 +36,8 @@ #include "qcocoanativeinterface.h" #include "qcocoawindow.h" +#include <Carbon/Carbon.h> + #include <QtCore/QRect> #include <QtGui/QGuiApplication> #include <QtGui/QWindow> @@ -76,6 +78,7 @@ QCocoaInputContext::QCocoaInputContext() , mWindow(QGuiApplication::focusWindow()) { QMetaObject::invokeMethod(this, "connectSignals", Qt::QueuedConnection); + updateLocale(); } QCocoaInputContext::~QCocoaInputContext() @@ -116,4 +119,20 @@ void QCocoaInputContext::focusObjectChanged(QObject *focusObject) mWindow = QGuiApplication::focusWindow(); } +void QCocoaInputContext::updateLocale() +{ + TISInputSourceRef source = TISCopyCurrentKeyboardInputSource(); + CFArrayRef languages = (CFArrayRef) TISGetInputSourceProperty(source, kTISPropertyInputSourceLanguages); + if (CFArrayGetCount(languages) > 0) { + CFStringRef langRef = (CFStringRef)CFArrayGetValueAtIndex(languages, 0); + QString name = QCFString::toQString(langRef); + QLocale locale(name); + if (m_locale != locale) { + m_locale = locale; + emitLocaleChanged(); + } + CFRelease(langRef); + } +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index a2890d9b4a..de28b8d74a 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -95,6 +95,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); - (void)notifyWindowStateChanged:(Qt::WindowState)newState; - (void)windowNotification : (NSNotification *) windowNotification; - (void)notifyWindowWillZoom:(BOOL)willZoom; +- (void)textInputContextKeyboardSelectionDidChangeNotification : (NSNotification *) textInputContextKeyboardSelectionDidChangeNotification; - (void)viewDidHide; - (void)viewDidUnhide; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 6e6e128aed..faa048874f 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -41,6 +41,7 @@ #include "qcocoahelpers.h" #include "qmultitouch_mac_p.h" #include "qcocoadrag.h" +#include "qcocoainputcontext.h" #include <qpa/qplatformintegration.h> #include <qpa/qwindowsysteminterface.h> @@ -215,6 +216,11 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; name:NSViewFrameDidChangeNotification object:self]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(textInputContextKeyboardSelectionDidChangeNotification:) + name:NSTextInputContextKeyboardSelectionDidChangeNotification + object:nil]; + return self; } @@ -464,6 +470,15 @@ QT_WARNING_POP } } +- (void)textInputContextKeyboardSelectionDidChangeNotification : (NSNotification *) textInputContextKeyboardSelectionDidChangeNotification +{ + Q_UNUSED(textInputContextKeyboardSelectionDidChangeNotification) + if (([NSApp keyWindow] == [self window]) && [[self window] firstResponder] == self) { + QCocoaInputContext *ic = qobject_cast<QCocoaInputContext *>(QCocoaIntegration::instance()->inputContext()); + ic->updateLocale(); + } +} + - (void)notifyWindowWillZoom:(BOOL)willZoom { Qt::WindowState newState = willZoom ? Qt::WindowMaximized : Qt::WindowNoState; diff --git a/src/plugins/platforms/winrt/qwinrtbackingstore.cpp b/src/plugins/platforms/winrt/qwinrtbackingstore.cpp index dcf8239538..ee54bf795c 100644 --- a/src/plugins/platforms/winrt/qwinrtbackingstore.cpp +++ b/src/plugins/platforms/winrt/qwinrtbackingstore.cpp @@ -42,8 +42,8 @@ #include <QtGui/QOpenGLContext> #include <QtGui/QOpenGLFramebufferObject> -#include <GLES3/gl3.h> -#include <GLES3/gl3ext.h> +#include <GLES2/gl2.h> +#include <GLES2/gl2ext.h> QT_BEGIN_NAMESPACE @@ -78,7 +78,6 @@ bool QWinRTBackingStore::initialize() d->context.reset(new QOpenGLContext); QSurfaceFormat format = window()->requestedFormat(); - format.setVersion(3, 0); // Required for ES3 framebuffer blit d->context->setFormat(format); d->context->setScreen(window()->screen()); if (!d->context->create()) @@ -121,13 +120,13 @@ void QWinRTBackingStore::flush(QWindow *window, const QRegion ®ion, const QPo GL_RGBA, GL_UNSIGNED_BYTE, d->paintDevice.constScanLine(bounds.y())); glBindTexture(GL_TEXTURE_2D, 0); - glBindFramebuffer(GL_READ_FRAMEBUFFER, d->fbo->handle()); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, d->fbo->handle()); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, 0); const int y1 = bounds.y(); const int y2 = y1 + bounds.height(); const int x1 = bounds.x(); const int x2 = x1 + bounds.width(); - glBlitFramebuffer(x1, y1, x2, y2, + glBlitFramebufferANGLE(x1, y1, x2, y2, x1, d->size.height() - y1, x2, d->size.height() - y2, GL_COLOR_BUFFER_BIT, GL_NEAREST); diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp index c32ec8a151..7d09551f5b 100644 --- a/src/plugins/platforms/winrt/qwinrttheme.cpp +++ b/src/plugins/platforms/winrt/qwinrttheme.cpp @@ -44,7 +44,13 @@ #include <wrl.h> #include <windows.ui.h> #include <windows.ui.viewmanagement.h> +#if _MSC_VER >= 1900 +#include <windows.foundation.metadata.h> +using namespace ABI::Windows::Foundation::Metadata; +#endif + using namespace Microsoft::WRL; +using namespace Microsoft::WRL::Wrappers; using namespace ABI::Windows::UI; using namespace ABI::Windows::UI::ViewManagement; @@ -73,102 +79,215 @@ static inline QColor fromColor(const Color &color) return QColor(color.R, color.G, color.B, color.A); } -QWinRTTheme::QWinRTTheme() - : d_ptr(new QWinRTThemePrivate) +#if _MSC_VER >= 1900 +static bool uiColorSettings(const wchar_t *value, UIElementType type, Color *color) { - Q_D(QWinRTTheme); + static ComPtr<IApiInformationStatics> apiInformationStatics; + HRESULT hr; + if (!apiInformationStatics) { + hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Foundation_Metadata_ApiInformation).Get(), + IID_PPV_ARGS(&apiInformationStatics)); + RETURN_FALSE_IF_FAILED("Could not get ApiInformationStatics"); + } + + static const HStringReference enumRef(L"Windows.UI.ViewManagement.UIElementType"); + HStringReference valueRef(value); + + boolean exists; + hr = apiInformationStatics->IsEnumNamedValuePresent(enumRef.Get(), valueRef.Get(), &exists); + + if (hr != S_OK || !exists) + return false; + + return SUCCEEDED(uiSettings()->UIElementColor(type, color)); +} + +static void nativeColorSettings(QPalette &p) +{ + Color color; + + if (uiColorSettings(L"ActiveCaption", UIElementType_ActiveCaption, &color)) + p.setColor(QPalette::ToolTipBase, fromColor(color)); + + if (uiColorSettings(L"Background", UIElementType_Background, &color)) + p.setColor(QPalette::AlternateBase, fromColor(color)); + + if (uiColorSettings(L"ButtonFace", UIElementType_ButtonFace, &color)) { + p.setColor(QPalette::Button, fromColor(color)); + p.setColor(QPalette::Midlight, fromColor(color).lighter(110)); + p.setColor(QPalette::Light, fromColor(color).lighter(150)); + p.setColor(QPalette::Mid, fromColor(color).dark(130)); + p.setColor(QPalette::Dark, fromColor(color).dark(150)); + } + + if (uiColorSettings(L"ButtonText", UIElementType_ButtonText, &color)) { + p.setColor(QPalette::ButtonText, fromColor(color)); + p.setColor(QPalette::Text, fromColor(color)); + } + + if (uiColorSettings(L"CaptionText", UIElementType_CaptionText, &color)) + p.setColor(QPalette::ToolTipText, fromColor(color)); + + if (uiColorSettings(L"Highlight", UIElementType_Highlight, &color)) + p.setColor(QPalette::Highlight, fromColor(color)); + + if (uiColorSettings(L"HighlightText", UIElementType_HighlightText, &color)) + p.setColor(QPalette::HighlightedText, fromColor(color)); + + if (uiColorSettings(L"Window", UIElementType_Window, &color)) { + p.setColor(QPalette::Window, fromColor(color)); + p.setColor(QPalette::Base, fromColor(color)); + } + + if (uiColorSettings(L"Hotlight", UIElementType_Hotlight, &color)) + p.setColor(QPalette::BrightText, fromColor(color)); + + //Phone related + if (uiColorSettings(L"PopupBackground", UIElementType_PopupBackground, &color)) { + p.setColor(QPalette::ToolTipBase, fromColor(color)); + p.setColor(QPalette::AlternateBase, fromColor(color)); + } + + if (uiColorSettings(L"NonTextMedium", UIElementType_NonTextMedium, &color)) + p.setColor(QPalette::Button, fromColor(color)); + + if (uiColorSettings(L"NonTextMediumHigh", UIElementType_NonTextMediumHigh, &color)) + p.setColor(QPalette::Midlight, fromColor(color)); + + if (uiColorSettings(L"NonTextHigh", UIElementType_NonTextHigh, &color)) + p.setColor(QPalette::Light, fromColor(color)); + + if (uiColorSettings(L"NonTextMediumLow", UIElementType_NonTextMediumLow, &color)) + p.setColor(QPalette::Mid, fromColor(color)); + + if (uiColorSettings(L"NonTextLow", UIElementType_NonTextLow, &color)) + p.setColor(QPalette::Dark, fromColor(color)); + + if (uiColorSettings(L"TextHigh", UIElementType_TextHigh, &color)) { + p.setColor(QPalette::ButtonText, fromColor(color)); + p.setColor(QPalette::Text, fromColor(color)); + p.setColor(QPalette::WindowText, fromColor(color)); + } + + if (uiColorSettings(L"TextMedium", UIElementType_TextMedium, &color)) + p.setColor(QPalette::ToolTipText, fromColor(color)); + + if (uiColorSettings(L"AccentColor", UIElementType_AccentColor, &color)) + p.setColor(QPalette::Highlight, fromColor(color)); + if (uiColorSettings(L"PageBackground", UIElementType_PageBackground, &color)) { + p.setColor(QPalette::Window, fromColor(color)); + p.setColor(QPalette::Base, fromColor(color)); + } + + if (uiColorSettings(L"TextContrastWithHigh", UIElementType_TextContrastWithHigh, &color)) + p.setColor(QPalette::BrightText, fromColor(color)); +} + +#else // _MSC_VER >= 1900 + +static void nativeColorSettings(QPalette &p) +{ HRESULT hr; Color color; #ifdef Q_OS_WINPHONE hr = uiSettings()->UIElementColor(UIElementType_PopupBackground, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::ToolTipBase, fromColor(color)); - d->palette.setColor(QPalette::AlternateBase, fromColor(color)); + p.setColor(QPalette::ToolTipBase, fromColor(color)); + p.setColor(QPalette::AlternateBase, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_NonTextMedium, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::Button, fromColor(color)); + p.setColor(QPalette::Button, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_NonTextMediumHigh, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::Midlight, fromColor(color)); + p.setColor(QPalette::Midlight, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_NonTextHigh, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::Light, fromColor(color)); + p.setColor(QPalette::Light, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_NonTextMediumLow, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::Mid, fromColor(color)); + p.setColor(QPalette::Mid, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_NonTextLow, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::Dark, fromColor(color)); + p.setColor(QPalette::Dark, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_TextHigh, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::ButtonText, fromColor(color)); - d->palette.setColor(QPalette::Text, fromColor(color)); - d->palette.setColor(QPalette::WindowText, fromColor(color)); + p.setColor(QPalette::ButtonText, fromColor(color)); + p.setColor(QPalette::Text, fromColor(color)); + p.setColor(QPalette::WindowText, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_TextMedium, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::ToolTipText, fromColor(color)); + p.setColor(QPalette::ToolTipText, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_AccentColor, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::Highlight, fromColor(color)); + p.setColor(QPalette::Highlight, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_PageBackground, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::Window, fromColor(color)); - d->palette.setColor(QPalette::Base, fromColor(color)); + p.setColor(QPalette::Window, fromColor(color)); + p.setColor(QPalette::Base, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_TextContrastWithHigh, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::BrightText, fromColor(color)); + p.setColor(QPalette::BrightText, fromColor(color)); #else hr = uiSettings()->UIElementColor(UIElementType_ActiveCaption, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::ToolTipBase, fromColor(color)); + p.setColor(QPalette::ToolTipBase, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_Background, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::AlternateBase, fromColor(color)); + p.setColor(QPalette::AlternateBase, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_ButtonFace, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::Button, fromColor(color)); - d->palette.setColor(QPalette::Midlight, fromColor(color).lighter(110)); - d->palette.setColor(QPalette::Light, fromColor(color).lighter(150)); - d->palette.setColor(QPalette::Mid, fromColor(color).dark(130)); - d->palette.setColor(QPalette::Dark, fromColor(color).dark(150)); + p.setColor(QPalette::Button, fromColor(color)); + p.setColor(QPalette::Midlight, fromColor(color).lighter(110)); + p.setColor(QPalette::Light, fromColor(color).lighter(150)); + p.setColor(QPalette::Mid, fromColor(color).dark(130)); + p.setColor(QPalette::Dark, fromColor(color).dark(150)); hr = uiSettings()->UIElementColor(UIElementType_ButtonText, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::ButtonText, fromColor(color)); - d->palette.setColor(QPalette::Text, fromColor(color)); + p.setColor(QPalette::ButtonText, fromColor(color)); + p.setColor(QPalette::Text, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_CaptionText, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::ToolTipText, fromColor(color)); + p.setColor(QPalette::ToolTipText, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_Highlight, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::Highlight, fromColor(color)); + p.setColor(QPalette::Highlight, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_HighlightText, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::HighlightedText, fromColor(color)); + p.setColor(QPalette::HighlightedText, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_Window, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::Window, fromColor(color)); - d->palette.setColor(QPalette::Base, fromColor(color)); + p.setColor(QPalette::Window, fromColor(color)); + p.setColor(QPalette::Base, fromColor(color)); hr = uiSettings()->UIElementColor(UIElementType_Hotlight, &color); Q_ASSERT_SUCCEEDED(hr); - d->palette.setColor(QPalette::BrightText, fromColor(color)); + p.setColor(QPalette::BrightText, fromColor(color)); #endif } +#endif // _MSC_VER < 1900 + +QWinRTTheme::QWinRTTheme() + : d_ptr(new QWinRTThemePrivate) +{ + Q_D(QWinRTTheme); + + nativeColorSettings(d->palette); +} bool QWinRTTheme::usePlatformNativeDialog(DialogType type) const { diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index e62d515b62..1825a463d0 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -146,8 +146,8 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI int id = shmget(IPC_PRIVATE, segmentSize, IPC_CREAT | 0600); if (id == -1) - qWarning("QXcbShmImage: shmget() failed (%d) for size %d (%dx%d)", - errno, segmentSize, size.width(), size.height()); + qWarning("QXcbShmImage: shmget() failed (%d: %s) for size %d (%dx%d)", + errno, strerror(errno), segmentSize, size.width(), size.height()); else m_shm_info.shmid = id; m_shm_info.shmaddr = m_xcb_image->data = (quint8 *)shmat (m_shm_info.shmid, 0, 0); @@ -311,9 +311,12 @@ QPaintDevice *QXcbBackingStore::paintDevice() void QXcbBackingStore::beginPaint(const QRegion ®ion) { + if (!m_image && !m_size.isEmpty()) + resize(m_size, QRegion()); + if (!m_image) return; - + m_size = QSize(); m_paintRegion = region; m_image->preparePaint(m_paintRegion); @@ -420,7 +423,8 @@ void QXcbBackingStore::resize(const QSize &size, const QRegion &) return; Q_XCB_NOOP(connection()); - QXcbScreen *screen = static_cast<QXcbScreen *>(window()->screen()->handle()); + + QXcbScreen *screen = window()->screen() ? static_cast<QXcbScreen *>(window()->screen()->handle()) : 0; QPlatformWindow *pw = window()->handle(); if (!pw) { window()->create(); @@ -429,6 +433,11 @@ void QXcbBackingStore::resize(const QSize &size, const QRegion &) QXcbWindow* win = static_cast<QXcbWindow *>(pw); delete m_image; + if (!screen) { + m_image = 0; + m_size = size; + return; + } m_image = new QXcbShmImage(screen, size, win->depth(), win->imageFormat()); // Slow path for bgr888 VNC: Create an additional image, paint into that and // swap R and B while copying to m_image after each paint. diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.h b/src/plugins/platforms/xcb/qxcbbackingstore.h index b58a32d313..1bea36d423 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.h +++ b/src/plugins/platforms/xcb/qxcbbackingstore.h @@ -71,6 +71,7 @@ private: QXcbShmImage *m_image; QRegion m_paintRegion; QImage m_rgbImage; + QSize m_size; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index bde8826792..b691c7550f 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -652,7 +652,7 @@ void QXcbWindow::setGeometry(const QRect &rect) m_xcbScreen = newScreen; const QRect wmGeometry = windowToWmGeometry(rect); - if (newScreen != currentScreen) + if (newScreen && newScreen != currentScreen) QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen()); if (qt_window_private(window())->positionAutomatic) { @@ -1606,7 +1606,7 @@ void QXcbWindow::requestActivateWindow() return; } - if (!m_mapped) { + if (!m_mapped || !xcbScreen()) { m_deferredActivation = true; return; } |