summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-01-18 09:32:12 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-01-18 15:24:18 +0000
commit45f80a52c2d01ba14f550e48e32d95748a3ff444 (patch)
tree55d4297d9487a07a38207274a2b3f1303a922e27 /src
parenta0bc9d0027e5e46d66b7d9b62b04d8c3cac9c82f (diff)
Windows platform headers: Add isTabletMode()
Add a bool function querying Windows 10 tablet mode. Task-number: QTBUG-56831 Change-Id: Ief728a7d80a11ba79f7859033ff4be6ef79bbd4e Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/platformheaders/windowsfunctions/qwindowswindowfunctions.h9
-rw-r--r--src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc32
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp15
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.h2
4 files changed, 56 insertions, 2 deletions
diff --git a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h
index d0826bdb50..e51c2fde67 100644
--- a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h
+++ b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h
@@ -90,6 +90,15 @@ public:
if (func)
func(behavior);
}
+
+ typedef bool (*IsTabletModeType)();
+ static const QByteArray isTabletModeIdentifier() { return QByteArrayLiteral("WindowsIsTabletMode"); }
+
+ static bool isTabletMode()
+ {
+ IsTabletModeType func = reinterpret_cast<IsTabletModeType>(QGuiApplication::platformFunction(isTabletModeIdentifier()));
+ return func && func();
+ }
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowsWindowFunctions::TouchWindowTouchTypes)
diff --git a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc
index 24e4847042..898b1bbb29 100644
--- a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc
+++ b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc
@@ -144,3 +144,35 @@
\sa QWidget::activateWindow(), QWindow::requestActivate()
\since 5.7
*/
+
+/*!
+ \typedef QWindowsWindowFunctions::IsTabletModeType
+
+ This is the typedef for the function returned by QGuiApplication::platformFunction()
+ when passed isTabletModeIdentifier().
+
+ \since 5.9
+*/
+
+/*!
+ \fn QByteArray QWindowsWindowFunctions::isTabletModeIdentifier()
+
+ Returns a bytearray that can be used to query
+ QGuiApplication::platformFunction() to retrieve the IsTabletModeType
+ function.
+
+ \since 5.9
+*/
+
+/*!
+ \fn bool QWindowsWindowFunctions::isTabletMode()
+
+ This is a convenience function that can be used directly instead of resolving
+ the function pointer. The function can be used to query whether Windows 10
+ operates in \e{Tablet Mode}. In this mode, Windows forces all application
+ main windows to open in maximized state. Applications should then avoid
+ resizing windows or restoring geometries to non-maximized states.
+
+ \sa QWidget::showMaximized(), QWidget::saveGeometry(), QWidget::restoreGeometry()
+ \since 5.9
+*/
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
index cee5dbf165..d750eef19d 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qwindowsnativeinterface.h"
+#include "qwindowsclipboard.h"
#include "qwindowswindow.h"
#include "qwindowscontext.h"
#include "qwindowscursor.h"
@@ -45,6 +46,7 @@
#include "qwindowsopengltester.h"
#include "qwindowsintegration.h"
#include "qwindowsmime.h"
+#include "qwin10helpers.h"
#include <QtGui/QWindow>
#include <QtGui/QOpenGLContext>
@@ -253,14 +255,23 @@ QFont QWindowsNativeInterface::logFontToQFont(const void *logFont, int verticalD
return QWindowsFontDatabase::LOGFONT_to_QFont(*reinterpret_cast<const LOGFONT *>(logFont), verticalDpi);
}
+bool QWindowsNativeInterface::isTabletMode()
+{
+#if QT_CONFIG(clipboard)
+ if (const QWindowsClipboard *clipboard = QWindowsClipboard::instance())
+ return qt_windowsIsTabletMode(clipboard->clipboardViewer());
+#endif
+ return false;
+}
+
QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &function) const
{
if (function == QWindowsWindowFunctions::setTouchWindowTouchTypeIdentifier())
return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic);
else if (function == QWindowsWindowFunctions::setHasBorderInFullScreenIdentifier())
return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenStatic);
- else if (function == QWindowsWindowFunctions::setWindowActivationBehaviorIdentifier())
- return QFunctionPointer(QWindowsNativeInterface::setWindowActivationBehavior);
+ else if (function == QWindowsWindowFunctions::isTabletModeIdentifier())
+ return QFunctionPointer(QWindowsNativeInterface::isTabletMode);
return Q_NULLPTR;
}
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h
index 4a67400b15..d085a4afb3 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.h
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h
@@ -102,6 +102,8 @@ public:
static void setWindowActivationBehavior(QWindowsWindowFunctions::WindowActivationBehavior b)
{ QWindowsNativeInterface::m_windowActivationBehavior = b; }
+ static bool isTabletMode();
+
QFunctionPointer platformFunction(const QByteArray &function) const override;
private: