summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2013-09-13 12:22:45 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-20 13:53:59 +0200
commitd959c37eaa66298579ca55440aff5fdb8b3126b2 (patch)
tree6c61938d1046fd2e469f63b49f3e58c4da449f88
parent7e2b238c507ee2fdea26f2b57512f337de2c5f85 (diff)
WinRT: Basic global support
Various global changes, primarily preprocessor flow, to support the WinRT platform. Change-Id: I3fa9cf91d5fb24019362e88fcf205e31b4f810b5 Reviewed-by: Andrew Knight <andrew.knight@digia.com>
-rw-r--r--mkspecs/features/qt.prf2
-rw-r--r--mkspecs/features/simd.prf2
-rw-r--r--src/corelib/codecs/qwindowscodec.cpp2
-rw-r--r--src/corelib/global/qglobal.cpp21
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/global/qlogging.cpp12
-rw-r--r--src/corelib/global/qprocessordetection.h2
-rw-r--r--src/corelib/global/qsystemdetection.h14
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp4
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp16
-rw-r--r--src/corelib/kernel/qcorecmdlineargs_p.h6
-rw-r--r--src/gui/image/image.pri2
-rw-r--r--src/gui/kernel/qguiapplication.cpp4
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp4
-rw-r--r--src/plugins/plugins.pro2
-rw-r--r--src/src.pro2
-rw-r--r--src/testlib/qtestcase.cpp12
17 files changed, 80 insertions, 29 deletions
diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf
index 8de038c5f8..dc80f8d9e1 100644
--- a/mkspecs/features/qt.prf
+++ b/mkspecs/features/qt.prf
@@ -123,7 +123,7 @@ for(QT_CURRENT_VERIFY, $$list($$QT_PLUGIN_VERIFY)) {
# if the plugin is linked statically there is no need to deploy it
DEPLOYMENT_PLUGIN -= $$QT_CURRENT_VERIFY
}
- isEqual(QT_CURRENT_VERIFY, DEPLOYMENT_PLUGIN):shared:wince*: {
+ isEqual(QT_CURRENT_VERIFY, DEPLOYMENT_PLUGIN):shared:if(wince*|winrt): {
QT_ITEM =
debug: QT_ITEM = $${QTPLUG}d4.dll
else: QT_ITEM = $${QTPLUG}4.dll
diff --git a/mkspecs/features/simd.prf b/mkspecs/features/simd.prf
index e0cd5a3a58..a98683d929 100644
--- a/mkspecs/features/simd.prf
+++ b/mkspecs/features/simd.prf
@@ -188,7 +188,7 @@ QT_CPU_FEATURES = $$eval(QT_CPU_FEATURES.$$QT_ARCH)
silent:mips_dspr2_assembler.commands = @echo assembling[mips_dspr2] ${QMAKE_FILE_IN} && $$mips_dspr2_assembler.commands
QMAKE_EXTRA_COMPILERS += mips_dspr2_assembler
}
-} else:win32-msvc* {
+} else:win32-msvc*|winrt {
sse2 {
HEADERS += $$SSE2_HEADERS
diff --git a/src/corelib/codecs/qwindowscodec.cpp b/src/corelib/codecs/qwindowscodec.cpp
index 54d20ec4f4..cd3f403475 100644
--- a/src/corelib/codecs/qwindowscodec.cpp
+++ b/src/corelib/codecs/qwindowscodec.cpp
@@ -159,7 +159,7 @@ QString QWindowsLocalCodec::convertToUnicodeCharByChar(const char *chars, int le
state->remainingChars = 0;
}
const char *mb = mbcs;
-#ifndef Q_OS_WINCE
+#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
const char *next = 0;
QString s;
while ((next = CharNextExA(CP_ACP, mb, 0)) != mb) {
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 9ce820afff..ce87e4bfd9 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1133,6 +1133,21 @@ bool qSharedBuild() Q_DECL_NOTHROW
*/
/*!
+ \macro Q_OS_WINRT
+ \relates <QtGlobal>
+
+ Defined for Windows Runtime (Windows Store apps) on Windows 8, Windows RT,
+ and Windows Phone 8.
+*/
+
+/*!
+ \macro Q_OS_WINPHONE
+ \relates <QtGlobal>
+
+ Defined on Windows Phone 8.
+*/
+
+/*!
\macro Q_OS_CYGWIN
\relates <QtGlobal>
@@ -1715,7 +1730,7 @@ QSysInfo::MacVersion QSysInfo::macVersion()
}
const QSysInfo::MacVersion QSysInfo::MacintoshVersion = QSysInfo::macVersion();
-#elif defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINCE)
+#elif defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
QT_BEGIN_INCLUDE_NAMESPACE
#include "qt_windows.h"
@@ -1739,6 +1754,9 @@ QSysInfo::WinVersion QSysInfo::windowsVersion()
static QSysInfo::WinVersion winver;
if (winver)
return winver;
+#ifdef Q_OS_WINRT
+ winver = QSysInfo::WV_WINDOWS8;
+#else
winver = QSysInfo::WV_NT;
OSVERSIONINFO osver;
osver.dwOSVersionInfoSize = sizeof(osver);
@@ -1823,6 +1841,7 @@ QSysInfo::WinVersion QSysInfo::windowsVersion()
winver = QSysInfo::WV_WINDOWS8;
}
#endif
+#endif // !Q_OS_WINRT
return winver;
}
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index d3db3b9dde..62ec25f003 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -194,7 +194,7 @@ typedef quint64 qulonglong;
#ifndef QT_POINTER_SIZE
# if defined(Q_OS_WIN64)
# define QT_POINTER_SIZE 8
-# elif defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+# 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
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 117ce240d8..5aaa0716f1 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -88,7 +88,7 @@ static bool isFatal(QtMsgType msgType)
// Do we have stderr for QDebug? - Either there is a console or we are running
// with redirected stderr.
-# ifndef Q_OS_WINCE
+# if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
static inline bool hasStdErr()
{
if (GetConsoleWindow())
@@ -98,11 +98,11 @@ static inline bool hasStdErr()
return (info.dwFlags & STARTF_USESTDHANDLES) && info.hStdError
&& info.hStdError != INVALID_HANDLE_VALUE;
}
-# endif // !Q_OS_WINCE
+# endif // !Q_OS_WINCE && !Q_OS_WINRT
bool qWinLogToStderr()
{
-# ifndef Q_OS_WINCE
+# if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
static const bool result = hasStdErr();
return result;
# else
@@ -168,7 +168,7 @@ static void qEmergencyOut(QtMsgType msgType, const char *msg, va_list ap) Q_DECL
{
char emergency_buf[256] = { '\0' };
emergency_buf[sizeof emergency_buf - 1] = '\0';
-#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB) && defined(Q_OS_WINCE) \
+#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB) && (defined(Q_OS_WINCE) || defined(Q_OS_WINRT)) \
|| defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
wchar_t emergency_bufL[sizeof emergency_buf];
#endif
@@ -177,7 +177,7 @@ static void qEmergencyOut(QtMsgType msgType, const char *msg, va_list ap) Q_DECL
qvsnprintf(emergency_buf, sizeof emergency_buf - 1, msg, ap);
#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
-# ifdef Q_OS_WINCE
+# if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
convert_to_wchar_t_elided(emergency_bufL, sizeof emergency_buf, emergency_buf);
OutputDebugStringW(emergency_bufL);
# else
@@ -701,7 +701,7 @@ void QMessagePattern::setPattern(const QString &pattern)
else if (inIf)
error += QStringLiteral("QT_MESSAGE_PATTERN: missing %{endif}\n");
if (!error.isEmpty()) {
-#if defined(Q_OS_WINCE)
+#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
OutputDebugString(reinterpret_cast<const wchar_t*>(error.utf16()));
if (0)
#elif defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index fb664cbc82..623e30aa06 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -317,7 +317,7 @@
# elif defined(__BIG_ENDIAN__) || defined(_big_endian__) || defined(_BIG_ENDIAN)
# define Q_BYTE_ORDER Q_BIG_ENDIAN
# elif defined(__LITTLE_ENDIAN__) || defined(_little_endian__) || defined(_LITTLE_ENDIAN) \
- || defined(_WIN32_WCE) // Windows CE is always little-endian according to MSDN.
+ || defined(_WIN32_WCE) || defined(WINAPI_FAMILY) // Windows CE is always little-endian according to MSDN.
# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
# else
# error "Unable to determine byte order!"
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index dc9fa7383a..7b1c32663b 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -58,6 +58,7 @@
OS2EMX - XFree86 on OS/2 (not PM)
WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
WINCE - WinCE (Windows CE 5.0)
+ WINRT - WinRT (Windows 8 Runtime)
CYGWIN - Cygwin
SOLARIS - Sun Solaris
HPUX - HP-UX
@@ -105,12 +106,21 @@
# define Q_OS_LINUX
#elif defined(__CYGWIN__)
# define Q_OS_CYGWIN
-#elif !defined(SAG_COM) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
+#elif !defined(SAG_COM) && (!defined(WINAPI_FAMILY) || WINAPI_FAMILY==WINAPI_FAMILY_DESKTOP_APP) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
# define Q_OS_WIN32
# define Q_OS_WIN64
#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
# if defined(WINCE) || defined(_WIN32_WCE)
# define Q_OS_WINCE
+# elif defined(WINAPI_FAMILY)
+# if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
+# define Q_OS_WINPHONE
+# define Q_OS_WINRT
+# elif WINAPI_FAMILY==WINAPI_FAMILY_APP
+# define Q_OS_WINRT
+# else
+# define Q_OS_WIN32
+# endif
# else
# define Q_OS_WIN32
# endif
@@ -172,7 +182,7 @@
# error "Qt has not been ported to this OS - see http://www.qt-project.org/"
#endif
-#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
# define Q_OS_WIN
#endif
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 290248aa6d..bdb7dc17f6 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2028,7 +2028,7 @@ QString QCoreApplication::applicationFilePath()
*/
qint64 QCoreApplication::applicationPid()
{
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
return GetCurrentProcessId();
#elif defined(Q_OS_VXWORKS)
return (pid_t) taskIdCurrent;
@@ -2079,7 +2079,7 @@ QStringList QCoreApplication::arguments()
char ** const av = self->d_func()->argv;
list.reserve(ac);
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// On Windows, it is possible to pass Unicode arguments on
// the command line. To restore those, we split the command line
// and filter out arguments that were deleted by derived application
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 3e2fd6a689..dd1b84aa58 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -56,6 +56,20 @@ QT_BEGIN_NAMESPACE
int appCmdShow = 0;
+#if defined(Q_OS_WINRT)
+
+Q_CORE_EXPORT QString qAppFileName()
+{
+ return QFileInfo(QCoreApplication::arguments().first()).filePath();
+}
+
+QString QCoreApplicationPrivate::appName() const
+{
+ return QFileInfo(QCoreApplication::arguments().first()).baseName();
+}
+
+#else
+
Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle
{
return GetModuleHandle(0);
@@ -1000,4 +1014,6 @@ QDebug operator<<(QDebug dbg, const MSG &msg)
#endif // QT_NO_QOBJECT
+#endif // !defined(Q_OS_WINRT)
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcorecmdlineargs_p.h b/src/corelib/kernel/qcorecmdlineargs_p.h
index f2b109facd..d1cfa2dfa9 100644
--- a/src/corelib/kernel/qcorecmdlineargs_p.h
+++ b/src/corelib/kernel/qcorecmdlineargs_p.h
@@ -58,7 +58,7 @@
QT_BEGIN_NAMESPACE
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QT_BEGIN_INCLUDE_NAMESPACE
# include "QtCore/qvector.h"
@@ -149,7 +149,7 @@ static inline QStringList qCmdLineArgs(int argc, char *argv[])
return qWinCmdArgs(cmdLine);
}
-#else // !Q_OS_WIN
+#else // Q_OS_WIN && !Q_OS_WINRT
static inline QStringList qCmdLineArgs(int argc, char *argv[])
{
@@ -159,7 +159,7 @@ static inline QStringList qCmdLineArgs(int argc, char *argv[])
return args;
}
-#endif // Q_OS_WIN
+#endif // !Q_OS_WIN || Q_OS_WINRT
QT_END_NAMESPACE
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri
index f29385d0a5..a80ab4a2fe 100644
--- a/src/gui/image/image.pri
+++ b/src/gui/image/image.pri
@@ -52,7 +52,7 @@ SOURCES += \
image/qiconengineplugin.cpp \
-win32: SOURCES += image/qpixmap_win.cpp
+win32:!winrt: SOURCES += image/qpixmap_win.cpp
# Built-in image format support
HEADERS += \
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 7f258331d3..b242a3cc68 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -907,12 +907,12 @@ static void init_platform(const QString &pluginArgument, const QString &platform
keys.join(QStringLiteral(", ")));
}
fatalMessage += QStringLiteral("Reinstalling the application may fix this problem.");
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
// Windows: Display message box unless it is a console application
// or debug build showing an assert box.
if (!QLibraryInfo::isDebugBuild() && !GetConsoleWindow())
MessageBox(0, (LPCTSTR)fatalMessage.utf16(), (LPCTSTR)(QCoreApplication::applicationName().utf16()), MB_OK | MB_ICONERROR);
-#endif // Q_OS_WIN && !Q_OS_WINCE
+#endif // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT
qFatal("%s", qPrintable(fatalMessage));
return;
}
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 3586b3452a..824dbf7ae8 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -158,6 +158,9 @@ static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
static inline bool winClearTypeFontsEnabled()
{
+#ifdef Q_OS_WINRT
+ return false;
+#else // Q_OS_WINRT
UINT result = 0;
#if !defined(SPI_GETFONTSMOOTHINGTYPE) // MinGW
# define SPI_GETFONTSMOOTHINGTYPE 0x200A
@@ -165,6 +168,7 @@ static inline bool winClearTypeFontsEnabled()
#endif
SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0);
return result == FE_FONTSMOOTHINGCLEARTYPE;
+#endif // !Q_OS_WINRT
}
/*!
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 516105401e..6f4bca63be 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -5,4 +5,4 @@ qtHaveModule(network): SUBDIRS += bearer
qtHaveModule(gui): SUBDIRS *= imageformats platforms platforminputcontexts platformthemes generic
qtHaveModule(widgets): SUBDIRS += accessible
-!wince*:qtHaveModule(widgets): SUBDIRS += printsupport
+!winrt:!wince*:qtHaveModule(widgets):SUBDIRS += printsupport
diff --git a/src/src.pro b/src/src.pro
index c6ae533cff..377e8cb650 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -131,7 +131,7 @@ contains(QT_CONFIG, concurrent):SUBDIRS += src_concurrent
SUBDIRS += src_opengl
src_plugins.depends += src_opengl
}
- !wince* {
+ !wince*:!winrt {
SUBDIRS += src_printsupport
src_plugins.depends += src_printsupport
}
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 0cf2f3256b..d4869b6390 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -2079,7 +2079,7 @@ FatalSignalHandler::~FatalSignalHandler()
} // namespace
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
static LONG WINAPI windowsFaultHandler(struct _EXCEPTION_POINTERS *exInfo)
{
char appName[MAX_PATH];
@@ -2089,7 +2089,7 @@ static LONG WINAPI windowsFaultHandler(struct _EXCEPTION_POINTERS *exInfo)
appName, exInfo->ExceptionRecord->ExceptionCode);
return EXCEPTION_EXECUTE_HANDLER;
}
-#endif // Q_OS_WIN) && !Q_OS_WINCE
+#endif // Q_OS_WIN) && !Q_OS_WINCE && !Q_OS_WINRT
/*!
Executes tests declared in \a testObject. In addition, the private slots
@@ -2171,7 +2171,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
qtest_qParseArgs(argc, argv, false);
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
if (!noCrashHandler) {
# ifndef Q_CC_MINGW
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
@@ -2179,7 +2179,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX);
SetUnhandledExceptionFilter(windowsFaultHandler);
} // !noCrashHandler
-#endif // Q_OS_WIN) && !Q_OS_WINCE
+#endif // Q_OS_WIN) && !Q_OS_WINCE && !Q_OS_WINRT
#ifdef QTESTLIB_USE_VALGRIND
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) {
@@ -2570,7 +2570,9 @@ void QTest::qSleep(int ms)
{
QTEST_ASSERT(ms > 0);
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WINRT)
+ WaitForSingleObjectEx(GetCurrentThread(), ms, true);
+#elif defined(Q_OS_WIN)
Sleep(uint(ms));
#else
struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };