Add a platform function to enable setting the touch flags on Windows
This makes it possible for the flags that RegisterTouchWindow takes to be specified after the window has been created. Task-number: QTBUG-41433 Change-Id: I166143875ef54ab6a249cffb31d017845a694a01 Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
This commit is contained in:
parent
84a3dacf46
commit
f444b25ac1
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
@ -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
|
||||
*/
|
@ -0,0 +1 @@
|
||||
HEADERS += $$PWD/qwindowswindowfunctions.h
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user