summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/platformheaders/doc/snippets/qwindowswindowfunctions/main.cpp61
-rw-r--r--src/platformheaders/doc/src/qtplatformheaders.qdoc2
-rw-r--r--src/platformheaders/platformheaders.pro1
-rw-r--r--src/platformheaders/windowsfunctions/qwindowswindowfunctions.h69
-rw-r--r--src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc71
-rw-r--r--src/platformheaders/windowsfunctions/windowsfunctions.pri1
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp7
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.h2
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp31
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h4
10 files changed, 238 insertions, 11 deletions
diff --git a/src/platformheaders/doc/snippets/qwindowswindowfunctions/main.cpp b/src/platformheaders/doc/snippets/qwindowswindowfunctions/main.cpp
new file mode 100644
index 0000000000..c5f2f37f11
--- /dev/null
+++ b/src/platformheaders/doc/snippets/qwindowswindowfunctions/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtWidgets>
+#include <QtPlatformHeaders/qwindowswindowfunctions.h>
+
+//! [0]
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ QPushButton topLevelWidget("Hello World!");
+ topLevelWidget.winId(); //have to create the QWindow
+
+ QWindow *tlwWindow = topLevelWidget.windowHandle();
+
+ QWindowsWindowFunctions::setTouchWindowTouchType(tlwWindow, QWindowsWindowFunctions::WantPalmTouch);
+
+ topLevelWidget.show();
+
+ return app.exec();
+}
+//! [0]
+
diff --git a/src/platformheaders/doc/src/qtplatformheaders.qdoc b/src/platformheaders/doc/src/qtplatformheaders.qdoc
index 94059e5508..9df9f996bc 100644
--- a/src/platformheaders/doc/src/qtplatformheaders.qdoc
+++ b/src/platformheaders/doc/src/qtplatformheaders.qdoc
@@ -78,7 +78,7 @@
classes is only guaranteed to work with the Qt version it was developed
against. Unlike QPA however, source compatibility is guaranteed.
- \sa QXcbWindowFunctions
+ \sa QXcbWindowFunctions QWindowsWindowFunctions
\section1 API Reference
\list
diff --git a/src/platformheaders/platformheaders.pro b/src/platformheaders/platformheaders.pro
index a3132ecf23..5e875f7d2d 100644
--- a/src/platformheaders/platformheaders.pro
+++ b/src/platformheaders/platformheaders.pro
@@ -6,6 +6,7 @@ MODULE_INCNAME = QtPlatformHeaders
include(nativecontexts/nativecontexts.pri)
include(xcbfunctions/xcbfunctions.pri)
include(eglfsfunctions/eglfsfunctions.pri)
+include(windowsfunctions/windowsfunctions.pri)
QMAKE_DOCS = $$PWD/doc/qtplatformheaders.qdocconf
diff --git a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h
new file mode 100644
index 0000000000..6e585b9dfe
--- /dev/null
+++ b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSWINDOWFUNCTIONS_H
+#define QWINDOWSWINDOWFUNCTIONS_H
+
+#include <QtCore/QByteArray>
+#include <QtGui/QGuiApplication>
+
+QT_BEGIN_NAMESPACE
+
+class QWindow;
+
+class QWindowsWindowFunctions {
+public:
+ enum TouchWindowTouchType {
+ NormalTouch = 0x00000000,
+ FineTouch = 0x00000001,
+ WantPalmTouch = 0x00000002
+ };
+
+ Q_DECLARE_FLAGS(TouchWindowTouchTypes, TouchWindowTouchType)
+
+ typedef void (*SetTouchWindowTouchType)(QWindow *window, QWindowsWindowFunctions::TouchWindowTouchTypes touchType);
+ static const QByteArray setTouchWindowTouchTypeIdentifier() { return QByteArrayLiteral("WindowsSetTouchWindowTouchType"); }
+
+ static void setTouchWindowTouchType(QWindow *window, TouchWindowTouchTypes type)
+ {
+ SetTouchWindowTouchType func = reinterpret_cast<SetTouchWindowTouchType>(QGuiApplication::platformFunction(setTouchWindowTouchTypeIdentifier()));
+ if (func)
+ func(window, type);
+ }
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowsWindowFunctions::TouchWindowTouchTypes)
+
+QT_END_NAMESPACE
+
+#endif // QWINDOWSWINDOWFUNCTIONS_H
diff --git a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc
new file mode 100644
index 0000000000..494a106575
--- /dev/null
+++ b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QWindowsWindowFunctions
+ \inmodule QtPlatformHeaders
+ \since 5.5
+ \brief The QWindowsWindowFunctions class is an inline class containing
+ miscellaneous functionality for Windows window specific functionality.
+
+ A common usage pattern is as follows:
+ \snippet qwindowswindowfunctions/main.cpp 0
+
+ \note There is no binary compatibility guarantee for this class,
+ meaning that an application using it is only guaranteed to work with the Qt
+ version it was developed against.
+*/
+
+/*!
+ \enum QWindowsWindowFunctions::TouchWindowTouchType
+
+ This enum represents the supported TouchWindow touch flags for RegisterTouchWindow().
+
+ \value NormalTouch
+ \value FineTouch
+ \value WantPalmTouch
+*/
+
+/*!
+ \typedef QWindowsWindowFunctions::SetTouchWindowTouchType
+
+ This is the typedef for the function returned by QGuiApplication::platformFunction when passed setTouchWindowTouchTypeIdentifier.
+*/
+
+/*!
+ \fn QByteArray QWindowsWindowFunctions::setTouchWindowTouchTypeIdentifier()
+
+ This function returns the bytearray that can be used to query
+ QGuiApplication::platformFunction to retrieve the SetTouchWindowTouchType function.
+*/
+
+/*!
+ \fn void QWindowsWindowFunctions::setTouchWindowTouchType(QWindow *window, TouchWindowTouchTypes type)
+
+ This is a convenience function that can be used directly instead of resolving the function pointer.
+ \a window and \a type will be relayed to the function retrieved by QGuiApplication
+*/
diff --git a/src/platformheaders/windowsfunctions/windowsfunctions.pri b/src/platformheaders/windowsfunctions/windowsfunctions.pri
new file mode 100644
index 0000000000..479245db80
--- /dev/null
+++ b/src/platformheaders/windowsfunctions/windowsfunctions.pri
@@ -0,0 +1 @@
+HEADERS += $$PWD/qwindowswindowfunctions.h
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
index 002f4ae92c..bd5022505f 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
@@ -216,4 +216,11 @@ int QWindowsNativeInterface::registerMimeType(const QString &mimeType)
return QWindowsMime::registerMimeType(mimeType);
}
+QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &function) const
+{
+ if (function == QWindowsWindowFunctions::setTouchWindowTouchTypeIdentifier())
+ return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic);
+ return Q_NULLPTR;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h
index 3d47dbe721..9b2ac00986 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.h
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h
@@ -85,6 +85,8 @@ public:
QVariant windowProperty(QPlatformWindow *window, const QString &name) const Q_DECL_OVERRIDE;
QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const Q_DECL_OVERRIDE;
void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value) Q_DECL_OVERRIDE;
+
+ QFunctionPointer platformFunction(const QByteArray &function) const Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 7d67aa0d09..b7de580c44 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -889,16 +889,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
#endif // QT_NO_OPENGL
updateDropSite();
-#ifndef Q_OS_WINCE
- if ((QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)
- && aWindow->type() != Qt::ForeignWindow) {
- if (QWindowsContext::user32dll.registerTouchWindow(m_data.hwnd, 0)) {
- setFlag(TouchRegistered);
- } else {
- qErrnoWarning("RegisterTouchWindow() failed for window '%s'.", qPrintable(aWindow->objectName()));
- }
- }
-#endif // !Q_OS_WINCE
+ registerTouchWindow();
setWindowState(aWindow->windowState());
const qreal opacity = qt_window_private(aWindow)->opacity;
if (!qFuzzyCompare(opacity, qreal(1.0)))
@@ -2317,4 +2308,24 @@ void *QWindowsWindow::surface(void *nativeConfig)
#endif
}
+void QWindowsWindow::setTouchWindowTouchTypeStatic(QWindow *window, QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes)
+{
+ if (!window->handle())
+ return;
+ static_cast<QWindowsWindow *>(window->handle())->registerTouchWindow(touchTypes);
+}
+
+void QWindowsWindow::registerTouchWindow(QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes)
+{
+#ifndef Q_OS_WINCE
+ if ((QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)
+ && window()->type() != Qt::ForeignWindow) {
+ if (QWindowsContext::user32dll.registerTouchWindow(m_data.hwnd, (ULONG)touchTypes))
+ setFlag(TouchRegistered);
+ else
+ qErrnoWarning("RegisterTouchWindow() failed for window '%s'.", qPrintable(window()->objectName()));
+ }
+#endif // !Q_OS_WINCE
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index 9822ebce45..66102511e0 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -43,6 +43,7 @@
#include "qwindowsopenglcontext.h"
#include <qpa/qplatformwindow.h>
+#include <QtPlatformHeaders/qwindowswindowfunctions.h>
QT_BEGIN_NAMESPACE
@@ -261,6 +262,9 @@ public:
void stopAlertWindow();
#endif
+ static void setTouchWindowTouchTypeStatic(QWindow *window, QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes);
+ void registerTouchWindow(QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes = QWindowsWindowFunctions::NormalTouch);
+
private:
inline void show_sys() const;
inline void hide_sys() const;