Shuffle things around in preparation for Direct2D platform plugin

Add a layer of abstraction in some spots where the Direct2D plugin will hook in.

Change-Id: Ifca7daf6ad0284af52a81822e970c2317d339234
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Louai Al-Khanji 2013-12-04 13:38:41 +02:00 committed by The Qt Project
parent 8166a34fc5
commit 5a2fc4c367
12 changed files with 724 additions and 369 deletions

View File

@ -43,7 +43,7 @@
#include <qpa/qplatformintegrationplugin.h>
#include <QtCore/QStringList>
#include "qwindowsintegration.h"
#include "qwindowsgdiintegration.h"
QT_BEGIN_NAMESPACE
@ -113,7 +113,7 @@ public:
QPlatformIntegration *QWindowsIntegrationPlugin::create(const QString& system, const QStringList& paramList, int &, char **)
{
if (system.compare(system, QStringLiteral("windows"), Qt::CaseInsensitive) == 0)
return new QWindowsIntegration(paramList);
return new QWindowsGdiIntegration(paramList);
return 0;
}

View File

@ -105,6 +105,8 @@ public:
static QString fontNameSubstitute(const QString &familyName);
IDWriteFontFace *directWriteFontFace() const { return m_directWriteFontFace; }
private:
QImage imageForGlyph(glyph_t t, QFixed subPixelPosition, int margin, const QTransform &xform);
void collectMetrics();

View File

@ -0,0 +1,83 @@
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwindowsgdiintegration.h"
#include "qwindowscontext.h"
#include "qwindowsbackingstore.h"
#include "qwindowsgdinativeinterface.h"
#include <QtCore/QDebug>
#include <QtGui/private/qpixmap_raster_p.h>
QT_BEGIN_NAMESPACE
class QWindowsGdiIntegrationPrivate
{
public:
QWindowsGdiNativeInterface m_nativeInterface;
};
QWindowsGdiIntegration::QWindowsGdiIntegration(const QStringList &paramList)
: QWindowsIntegration(paramList)
, d(new QWindowsGdiIntegrationPrivate)
{}
QWindowsGdiIntegration::~QWindowsGdiIntegration()
{}
QPlatformNativeInterface *QWindowsGdiIntegration::nativeInterface() const
{
return &d->m_nativeInterface;
}
QPlatformPixmap *QWindowsGdiIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const
{
return new QRasterPlatformPixmap(type);
}
QPlatformBackingStore *QWindowsGdiIntegration::createPlatformBackingStore(QWindow *window) const
{
if (QWindowsContext::verboseIntegration)
qDebug() << __FUNCTION__ << window;
return new QWindowsBackingStore(window);
}
QT_END_NAMESPACE

View File

@ -0,0 +1,66 @@
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWINDOWSGDIINTEGRATION_H
#define QWINDOWSGDIINTEGRATION_H
#include "qwindowsintegration.h"
QT_BEGIN_NAMESPACE
class QWindowsGdiIntegrationPrivate;
class QWindowsGdiIntegration : public QWindowsIntegration
{
public:
explicit QWindowsGdiIntegration(const QStringList &paramList);
virtual ~QWindowsGdiIntegration();
QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE;
QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const Q_DECL_OVERRIDE;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
private:
QScopedPointer<QWindowsGdiIntegrationPrivate> d;
};
QT_END_NAMESPACE
#endif // QWINDOWSGDIINTEGRATION_H

View File

@ -0,0 +1,62 @@
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwindowsgdinativeinterface.h"
#include "qwindowsbackingstore.h"
#include <QtGui/QBackingStore>
QT_BEGIN_NAMESPACE
void *QWindowsGdiNativeInterface::nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *bs)
{
if (!bs || !bs->handle()) {
qWarning("%s: '%s' requested for null backingstore or backingstore without handle.", __FUNCTION__, resource.constData());
return 0;
}
QWindowsBackingStore *wbs = static_cast<QWindowsBackingStore *>(bs->handle());
if (resource == "getDC")
return wbs->getDC();
qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData());
return 0;
}
QT_END_NAMESPACE

View File

@ -0,0 +1,58 @@
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWINDOWSGDINATIVEINTERFACE_H
#define QWINDOWSGDINATIVEINTERFACE_H
#include "qwindowsnativeinterface.h"
QT_BEGIN_NAMESPACE
class QWindowsGdiNativeInterface : public QWindowsNativeInterface
{
Q_OBJECT
public:
void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *bs) Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
#endif // QWINDOWSGDINATIVEINTERFACE_H

View File

@ -41,7 +41,6 @@
****************************************************************************/
#include "qwindowsintegration.h"
#include "qwindowsbackingstore.h"
#include "qwindowswindow.h"
#include "qwindowscontext.h"
#if defined(QT_OPENGL_ES_2)
@ -75,8 +74,6 @@
#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
# include "qwindowssessionmanager.h"
#endif
#include <QtGui/QBackingStore>
#include <QtGui/private/qpixmap_raster_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtCore/private/qeventdispatcher_win_p.h>
@ -85,174 +82,6 @@
QT_BEGIN_NAMESPACE
/*!
\class QWindowsNativeInterface
\brief Provides access to native handles.
Currently implemented keys
\list
\li handle (HWND)
\li getDC (DC)
\li releaseDC Releases the previously acquired DC and returns 0.
\endlist
\internal
\ingroup qt-lighthouse-win
*/
class QWindowsNativeInterface : public QPlatformNativeInterface
{
Q_OBJECT
Q_PROPERTY(bool asyncExpose READ asyncExpose WRITE setAsyncExpose)
public:
#ifndef QT_NO_OPENGL
virtual void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context);
#endif
virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window);
virtual void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *bs);
Q_INVOKABLE void *createMessageWindow(const QString &classNameTemplate,
const QString &windowName,
void *eventProc) const;
Q_INVOKABLE QString registerWindowClass(const QString &classNameIn, void *eventProc) const;
Q_INVOKABLE void beep() { MessageBeep(MB_OK); } // For QApplication
bool asyncExpose() const;
void setAsyncExpose(bool value);
QVariantMap windowProperties(QPlatformWindow *window) const;
QVariant windowProperty(QPlatformWindow *window, const QString &name) const;
QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const;
void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value);
};
void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
{
if (!window || !window->handle()) {
qWarning("%s: '%s' requested for null window or window without handle.", __FUNCTION__, resource.constData());
return 0;
}
QWindowsWindow *bw = static_cast<QWindowsWindow *>(window->handle());
if (resource == "handle")
return bw->handle();
if (window->surfaceType() == QWindow::RasterSurface) {
if (resource == "getDC")
return bw->getDC();
if (resource == "releaseDC") {
bw->releaseDC();
return 0;
}
}
qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData());
return 0;
}
void *QWindowsNativeInterface::nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *bs)
{
if (!bs || !bs->handle()) {
qWarning("%s: '%s' requested for null backingstore or backingstore without handle.", __FUNCTION__, resource.constData());
return 0;
}
QWindowsBackingStore *wbs = static_cast<QWindowsBackingStore *>(bs->handle());
if (resource == "getDC")
return wbs->getDC();
qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData());
return 0;
}
static const char customMarginPropertyC[] = "WindowsCustomMargins";
QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const
{
QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window);
if (name == QLatin1String(customMarginPropertyC))
return qVariantFromValue(platformWindow->customMargins());
return QVariant();
}
QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const
{
const QVariant result = windowProperty(window, name);
return result.isValid() ? result : defaultValue;
}
void QWindowsNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value)
{
QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window);
if (name == QLatin1String(customMarginPropertyC))
platformWindow->setCustomMargins(qvariant_cast<QMargins>(value));
}
QVariantMap QWindowsNativeInterface::windowProperties(QPlatformWindow *window) const
{
QVariantMap result;
const QString customMarginProperty = QLatin1String(customMarginPropertyC);
result.insert(customMarginProperty, windowProperty(window, customMarginProperty));
return result;
}
#ifndef QT_NO_OPENGL
void *QWindowsNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)
{
if (!context || !context->handle()) {
qWarning("%s: '%s' requested for null context or context without handle.", __FUNCTION__, resource.constData());
return 0;
}
#ifdef QT_OPENGL_ES_2
QWindowsEGLContext *windowsEglContext = static_cast<QWindowsEGLContext *>(context->handle());
if (resource == QByteArrayLiteral("eglDisplay"))
return windowsEglContext->eglDisplay();
if (resource == QByteArrayLiteral("eglContext"))
return windowsEglContext->eglContext();
if (resource == QByteArrayLiteral("eglConfig"))
return windowsEglContext->eglConfig();
#else // QT_OPENGL_ES_2
QWindowsGLContext *windowsContext = static_cast<QWindowsGLContext *>(context->handle());
if (resource == QByteArrayLiteral("renderingContext"))
return windowsContext->renderingContext();
#endif // !QT_OPENGL_ES_2
qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData());
return 0;
}
#endif // !QT_NO_OPENGL
/*!
\brief Creates a non-visible window handle for filtering messages.
*/
void *QWindowsNativeInterface::createMessageWindow(const QString &classNameTemplate,
const QString &windowName,
void *eventProc) const
{
QWindowsContext *ctx = QWindowsContext::instance();
const HWND hwnd = ctx->createDummyWindow(classNameTemplate,
(wchar_t*)windowName.utf16(),
(WNDPROC)eventProc);
return hwnd;
}
/*!
\brief Registers a unique window class with a callback function based on \a classNameIn.
*/
QString QWindowsNativeInterface::registerWindowClass(const QString &classNameIn, void *eventProc) const
{
return QWindowsContext::instance()->registerWindowClass(classNameIn, (WNDPROC)eventProc);
}
bool QWindowsNativeInterface::asyncExpose() const
{
return QWindowsContext::instance()->asyncExpose();
}
void QWindowsNativeInterface::setAsyncExpose(bool value)
{
QWindowsContext::instance()->setAsyncExpose(value);
}
/*!
\class QWindowsIntegration
\brief QPlatformIntegration implementation for Windows.
@ -308,7 +137,6 @@ struct QWindowsIntegrationPrivate
const unsigned m_options;
QWindowsContext m_context;
QPlatformFontDatabase *m_fontDatabase;
QWindowsNativeInterface m_nativeInterface;
#ifndef QT_NO_CLIPBOARD
QWindowsClipboard m_clipboard;
# ifndef QT_NO_DRAGANDDROP
@ -406,11 +234,6 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co
return false;
}
QPlatformPixmap *QWindowsIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const
{
return new QRasterPlatformPixmap(type);
}
QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) const
{
QWindowsWindow::WindowData requested;
@ -444,13 +267,6 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons
return new QWindowsWindow(window, obtained);
}
QPlatformBackingStore *QWindowsIntegration::createPlatformBackingStore(QWindow *window) const
{
if (QWindowsContext::verboseIntegration)
qDebug() << __FUNCTION__ << window;
return new QWindowsBackingStore(window);
}
#ifndef QT_NO_OPENGL
QPlatformOpenGLContext
*QWindowsIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
@ -583,11 +399,6 @@ QList<int> QWindowsIntegration::possibleKeys(const QKeyEvent *e) const
return d->m_context.possibleKeys(e);
}
QPlatformNativeInterface *QWindowsIntegration::nativeInterface() const
{
return &d->m_nativeInterface;
}
#ifndef QT_NO_CLIPBOARD
QPlatformClipboard * QWindowsIntegration::clipboard() const
{
@ -653,5 +464,3 @@ QPlatformServices *QWindowsIntegration::services() const
}
QT_END_NAMESPACE
#include "qwindowsintegration.moc"

View File

@ -68,9 +68,7 @@ public:
bool hasCapability(QPlatformIntegration::Capability cap) const;
virtual QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWindow *window) const;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
#ifndef QT_NO_OPENGL
virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
#endif
@ -85,7 +83,6 @@ public:
#ifndef QT_NO_ACCESSIBILITY
virtual QPlatformAccessibility *accessibility() const;
#endif
virtual QPlatformNativeInterface *nativeInterface() const;
virtual QPlatformFontDatabase *fontDatabase() const;
virtual QStringList themeNames() const;
virtual QPlatformTheme *createPlatformTheme(const QString &name) const;

View File

@ -0,0 +1,169 @@
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qwindowsnativeinterface.h"
#include "qwindowswindow.h"
#include "qwindowscontext.h"
#if defined(QT_OPENGL_ES_2)
# include "qwindowseglcontext.h"
# include <QtGui/QOpenGLContext>
#elif !defined(QT_NO_OPENGL)
# include "qwindowsglcontext.h"
#endif
#include <QtGui/QWindow>
QT_BEGIN_NAMESPACE
void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
{
if (!window || !window->handle()) {
qWarning("%s: '%s' requested for null window or window without handle.", __FUNCTION__, resource.constData());
return 0;
}
QWindowsWindow *bw = static_cast<QWindowsWindow *>(window->handle());
if (resource == "handle")
return bw->handle();
if (window->surfaceType() == QWindow::RasterSurface) {
if (resource == "getDC")
return bw->getDC();
if (resource == "releaseDC") {
bw->releaseDC();
return 0;
}
}
qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData());
return 0;
}
static const char customMarginPropertyC[] = "WindowsCustomMargins";
QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const
{
QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window);
if (name == QLatin1String(customMarginPropertyC))
return qVariantFromValue(platformWindow->customMargins());
return QVariant();
}
QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const
{
const QVariant result = windowProperty(window, name);
return result.isValid() ? result : defaultValue;
}
void QWindowsNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value)
{
QWindowsWindow *platformWindow = static_cast<QWindowsWindow *>(window);
if (name == QLatin1String(customMarginPropertyC))
platformWindow->setCustomMargins(qvariant_cast<QMargins>(value));
}
QVariantMap QWindowsNativeInterface::windowProperties(QPlatformWindow *window) const
{
QVariantMap result;
const QString customMarginProperty = QLatin1String(customMarginPropertyC);
result.insert(customMarginProperty, windowProperty(window, customMarginProperty));
return result;
}
#ifndef QT_NO_OPENGL
void *QWindowsNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)
{
if (!context || !context->handle()) {
qWarning("%s: '%s' requested for null context or context without handle.", __FUNCTION__, resource.constData());
return 0;
}
#ifdef QT_OPENGL_ES_2
QWindowsEGLContext *windowsEglContext = static_cast<QWindowsEGLContext *>(context->handle());
if (resource == QByteArrayLiteral("eglDisplay"))
return windowsEglContext->eglDisplay();
if (resource == QByteArrayLiteral("eglContext"))
return windowsEglContext->eglContext();
if (resource == QByteArrayLiteral("eglConfig"))
return windowsEglContext->eglConfig();
#else // QT_OPENGL_ES_2
QWindowsGLContext *windowsContext = static_cast<QWindowsGLContext *>(context->handle());
if (resource == QByteArrayLiteral("renderingContext"))
return windowsContext->renderingContext();
#endif // !QT_OPENGL_ES_2
qWarning("%s: Invalid key '%s' requested.", __FUNCTION__, resource.constData());
return 0;
}
#endif // !QT_NO_OPENGL
/*!
\brief Creates a non-visible window handle for filtering messages.
*/
void *QWindowsNativeInterface::createMessageWindow(const QString &classNameTemplate,
const QString &windowName,
void *eventProc) const
{
QWindowsContext *ctx = QWindowsContext::instance();
const HWND hwnd = ctx->createDummyWindow(classNameTemplate,
(wchar_t*)windowName.utf16(),
(WNDPROC)eventProc);
return hwnd;
}
/*!
\brief Registers a unique window class with a callback function based on \a classNameIn.
*/
QString QWindowsNativeInterface::registerWindowClass(const QString &classNameIn, void *eventProc) const
{
return QWindowsContext::instance()->registerWindowClass(classNameIn, (WNDPROC)eventProc);
}
bool QWindowsNativeInterface::asyncExpose() const
{
return QWindowsContext::instance()->asyncExpose();
}
void QWindowsNativeInterface::setAsyncExpose(bool value)
{
QWindowsContext::instance()->setAsyncExpose(value);
}
QT_END_NAMESPACE

View File

@ -0,0 +1,94 @@
/****************************************************************************
**
** Copyright (C) 2013 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:LGPL$
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWINDOWSNATIVEINTERFACE_H
#define QWINDOWSNATIVEINTERFACE_H
#include "qtwindows_additional.h"
#include <QtGui/qpa/qplatformnativeinterface.h>
QT_BEGIN_NAMESPACE
/*!
\class QWindowsNativeInterface
\brief Provides access to native handles.
Currently implemented keys
\list
\li handle (HWND)
\li getDC (DC)
\li releaseDC Releases the previously acquired DC and returns 0.
\endlist
\internal
\ingroup qt-lighthouse-win
*/
class QWindowsNativeInterface : public QPlatformNativeInterface
{
Q_OBJECT
Q_PROPERTY(bool asyncExpose READ asyncExpose WRITE setAsyncExpose)
public:
#ifndef QT_NO_OPENGL
virtual void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context);
#endif
virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window);
Q_INVOKABLE void *createMessageWindow(const QString &classNameTemplate,
const QString &windowName,
void *eventProc) const;
Q_INVOKABLE QString registerWindowClass(const QString &classNameIn, void *eventProc) const;
Q_INVOKABLE void beep() { MessageBeep(MB_OK); } // For QApplication
bool asyncExpose() const;
void setAsyncExpose(bool value);
QVariantMap windowProperties(QPlatformWindow *window) const;
QVariant windowProperty(QPlatformWindow *window, const QString &name) const;
QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const;
void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value);
};
QT_END_NAMESPACE
#endif // QWINDOWSNATIVEINTERFACE_H

View File

@ -0,0 +1,180 @@
# Note: OpenGL32 must precede Gdi32 as it overwrites some functions.
LIBS *= -lole32
!wince*:LIBS *= -luser32 -lwinspool -limm32 -lwinmm -loleaut32
contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2):LIBS *= -lopengl32
win32-g++*: LIBS *= -luuid
# For the dialog helpers:
!wince*:LIBS *= -lshlwapi -lshell32
!wince*:LIBS *= -ladvapi32
wince*:DEFINES *= QT_LIBINFIX=L"\"\\\"$${QT_LIBINFIX}\\\"\""
DEFINES *= QT_NO_CAST_FROM_ASCII
contains(QT_CONFIG, directwrite) {
LIBS *= -ldwrite
SOURCES += $$PWD/qwindowsfontenginedirectwrite.cpp
HEADERS += $$PWD/qwindowsfontenginedirectwrite.h
} else {
DEFINES *= QT_NO_DIRECTWRITE
}
SOURCES += \
$$PWD/qwindowswindow.cpp \
$$PWD/qwindowsintegration.cpp \
$$PWD/qwindowscontext.cpp \
$$PWD/qwindowsscreen.cpp \
$$PWD/qwindowskeymapper.cpp \
$$PWD/qwindowsfontengine.cpp \
$$PWD/qwindowsfontdatabase.cpp \
$$PWD/qwindowsmousehandler.cpp \
$$PWD/qwindowsguieventdispatcher.cpp \
$$PWD/qwindowsole.cpp \
$$PWD/qwindowsmime.cpp \
$$PWD/qwindowsinternalmimedata.cpp \
$$PWD/qwindowscursor.cpp \
$$PWD/qwindowsinputcontext.cpp \
$$PWD/qwindowstheme.cpp \
$$PWD/qwindowsdialoghelpers.cpp \
$$PWD/qwindowsservices.cpp \
$$PWD/qwindowsnativeimage.cpp \
$$PWD/qwindowsnativeinterface.cpp
HEADERS += \
$$PWD/qwindowswindow.h \
$$PWD/qwindowsintegration.h \
$$PWD/qwindowscontext.h \
$$PWD/qwindowsscreen.h \
$$PWD/qwindowskeymapper.h \
$$PWD/qwindowsfontengine.h \
$$PWD/qwindowsfontdatabase.h \
$$PWD/qwindowsmousehandler.h \
$$PWD/qwindowsguieventdispatcher.h \
$$PWD/qtwindowsglobal.h \
$$PWD/qtwindows_additional.h \
$$PWD/qwindowsole.h \
$$PWD/qwindowsmime.h \
$$PWD/qwindowsinternalmimedata.h \
$$PWD/qwindowscursor.h \
$$PWD/array.h \
$$PWD/qwindowsinputcontext.h \
$$PWD/qwindowstheme.h \
$$PWD/qwindowsdialoghelpers.h \
$$PWD/qwindowsservices.h \
$$PWD/qplatformfunctions_wince.h \
$$PWD/qwindowsnativeimage.h \
$$PWD/qwindowsnativeinterface.h
INCLUDEPATH += $$PWD
contains(QT_CONFIG, opengles2) {
SOURCES += $$PWD/qwindowseglcontext.cpp
HEADERS += $$PWD/qwindowseglcontext.h
} else {
contains(QT_CONFIG, opengl) {
SOURCES += $$PWD/qwindowsglcontext.cpp
HEADERS += $$PWD/qwindowsglcontext.h
}
}
!contains( DEFINES, QT_NO_CLIPBOARD ) {
SOURCES += $$PWD/qwindowsclipboard.cpp
HEADERS += $$PWD/qwindowsclipboard.h
}
# drag and drop on windows only works if a clipboard is available
!contains( DEFINES, QT_NO_DRAGANDDROP ) {
!win32:SOURCES += $$PWD/qwindowsdrag.cpp
!win32:HEADERS += $$PWD/qwindowsdrag.h
win32:!contains( DEFINES, QT_NO_CLIPBOARD ) {
HEADERS += $$PWD/qwindowsdrag.h
SOURCES += $$PWD/qwindowsdrag.cpp
}
}
!wince*:!contains( DEFINES, QT_NO_TABLETEVENT ) {
INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/wintab
HEADERS += $$PWD/qwindowstabletsupport.h
SOURCES += $$PWD/qwindowstabletsupport.cpp
}
!wince*:!contains( DEFINES, QT_NO_SESSIONMANAGER ) {
SOURCES += $$PWD/qwindowssessionmanager.cpp
HEADERS += $$PWD/qwindowssessionmanager.h
}
contains(QT_CONFIG, freetype) {
DEFINES *= QT_NO_FONTCONFIG
QT_FREETYPE_DIR = $$QT_SOURCE_TREE/src/3rdparty/freetype
HEADERS += \
$$PWD/qwindowsfontdatabase_ft.h
SOURCES += \
$$PWD/qwindowsfontdatabase_ft.cpp \
$$QT_FREETYPE_DIR/src/base/ftbase.c \
$$QT_FREETYPE_DIR/src/base/ftbbox.c \
$$QT_FREETYPE_DIR/src/base/ftdebug.c \
$$QT_FREETYPE_DIR/src/base/ftglyph.c \
$$QT_FREETYPE_DIR/src/base/ftinit.c \
$$QT_FREETYPE_DIR/src/base/ftmm.c \
$$QT_FREETYPE_DIR/src/base/fttype1.c \
$$QT_FREETYPE_DIR/src/base/ftsynth.c \
$$QT_FREETYPE_DIR/src/base/ftbitmap.c \
$$QT_FREETYPE_DIR/src/bdf/bdf.c \
$$QT_FREETYPE_DIR/src/cache/ftcache.c \
$$QT_FREETYPE_DIR/src/cff/cff.c \
$$QT_FREETYPE_DIR/src/cid/type1cid.c \
$$QT_FREETYPE_DIR/src/gzip/ftgzip.c \
$$QT_FREETYPE_DIR/src/pcf/pcf.c \
$$QT_FREETYPE_DIR/src/pfr/pfr.c \
$$QT_FREETYPE_DIR/src/psaux/psaux.c \
$$QT_FREETYPE_DIR/src/pshinter/pshinter.c \
$$QT_FREETYPE_DIR/src/psnames/psmodule.c \
$$QT_FREETYPE_DIR/src/raster/raster.c \
$$QT_FREETYPE_DIR/src/sfnt/sfnt.c \
$$QT_FREETYPE_DIR/src/smooth/smooth.c \
$$QT_FREETYPE_DIR/src/truetype/truetype.c \
$$QT_FREETYPE_DIR/src/type1/type1.c \
$$QT_FREETYPE_DIR/src/type42/type42.c \
$$QT_FREETYPE_DIR/src/winfonts/winfnt.c \
$$QT_FREETYPE_DIR/src/lzw/ftlzw.c\
$$QT_FREETYPE_DIR/src/otvalid/otvalid.c\
$$QT_FREETYPE_DIR/src/otvalid/otvbase.c\
$$QT_FREETYPE_DIR/src/otvalid/otvgdef.c\
$$QT_FREETYPE_DIR/src/otvalid/otvjstf.c\
$$QT_FREETYPE_DIR/src/otvalid/otvcommn.c\
$$QT_FREETYPE_DIR/src/otvalid/otvgpos.c\
$$QT_FREETYPE_DIR/src/otvalid/otvgsub.c\
$$QT_FREETYPE_DIR/src/otvalid/otvmod.c\
$$QT_FREETYPE_DIR/src/autofit/afangles.c\
$$QT_FREETYPE_DIR/src/autofit/afglobal.c\
$$QT_FREETYPE_DIR/src/autofit/aflatin.c\
$$QT_FREETYPE_DIR/src/autofit/afmodule.c\
$$QT_FREETYPE_DIR/src/autofit/afdummy.c\
$$QT_FREETYPE_DIR/src/autofit/afhints.c\
$$QT_FREETYPE_DIR/src/autofit/afloader.c\
$$QT_FREETYPE_DIR/src/autofit/autofit.c
SOURCES += $$QT_FREETYPE_DIR/src/base/ftsystem.c
INCLUDEPATH += \
$$QT_FREETYPE_DIR/src \
$$QT_FREETYPE_DIR/include
TR_EXCLUDE += $$QT_FREETYPE_DIR/*
DEFINES += FT2_BUILD_LIBRARY
contains(QT_CONFIG, system-zlib) {
DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB
}
} else:contains(QT_CONFIG, system-freetype) {
include($$QT_SOURCE_TREE/src/platformsupport/fontdatabases/basic/basic.pri)
HEADERS += \
$$PWD/qwindowsfontdatabase_ft.h
SOURCES += \
$$PWD/qwindowsfontdatabase_ft.cpp
}
contains(QT_CONFIG, accessibility):include($$PWD/accessible/accessible.pri)

View File

@ -8,184 +8,19 @@ QT *= core-private
QT *= gui-private
QT *= platformsupport-private
# Note: OpenGL32 must precede Gdi32 as it overwrites some functions.
LIBS *= -lole32
!wince*:LIBS *= -lgdi32 -luser32 -lwinspool -limm32 -lwinmm -loleaut32
!wince:LIBS *= -lgdi32
contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2):LIBS *= -lopengl32
include(windows.pri)
win32-g++*: LIBS *= -luuid
# For the dialog helpers:
!wince*:LIBS *= -lshlwapi -lshell32
!wince*:LIBS *= -ladvapi32
wince*:DEFINES *= QT_LIBINFIX=L"\"\\\"$${QT_LIBINFIX}\\\"\""
DEFINES *= QT_NO_CAST_FROM_ASCII
contains(QT_CONFIG, directwrite) {
LIBS *= -ldwrite
SOURCES += qwindowsfontenginedirectwrite.cpp
HEADERS += qwindowsfontenginedirectwrite.h
} else {
DEFINES *= QT_NO_DIRECTWRITE
}
SOURCES += \
SOURCES += \
main.cpp \
qwindowsnativeimage.cpp \
qwindowswindow.cpp \
qwindowsintegration.cpp \
qwindowscontext.cpp \
qwindowsbackingstore.cpp \
qwindowsscreen.cpp \
qwindowskeymapper.cpp \
qwindowsfontengine.cpp \
qwindowsfontdatabase.cpp \
qwindowsmousehandler.cpp \
qwindowsguieventdispatcher.cpp \
qwindowsole.cpp \
qwindowsmime.cpp \
qwindowsinternalmimedata.cpp \
qwindowscursor.cpp \
qwindowsinputcontext.cpp \
qwindowstheme.cpp \
qwindowsdialoghelpers.cpp \
qwindowsservices.cpp
qwindowsgdiintegration.cpp \
qwindowsgdinativeinterface.cpp
HEADERS += \
qwindowsnativeimage.h \
qwindowswindow.h \
qwindowsintegration.h \
qwindowscontext.h \
HEADERS += \
qwindowsbackingstore.h \
qwindowsscreen.h \
qwindowskeymapper.h \
qwindowsfontengine.h \
qwindowsfontdatabase.h \
qwindowsmousehandler.h \
qwindowsguieventdispatcher.h \
qtwindowsglobal.h \
qtwindows_additional.h \
qwindowsole.h \
qwindowsmime.h \
qwindowsinternalmimedata.h \
qwindowscursor.h \
array.h \
qwindowsinputcontext.h \
qwindowstheme.h \
qwindowsdialoghelpers.h \
qwindowsservices.h \
qplatformfunctions_wince.h
contains(QT_CONFIG, opengles2) {
SOURCES += qwindowseglcontext.cpp
HEADERS += qwindowseglcontext.h
} else {
contains(QT_CONFIG, opengl) {
SOURCES += qwindowsglcontext.cpp
HEADERS += qwindowsglcontext.h
}
}
!contains( DEFINES, QT_NO_CLIPBOARD ) {
SOURCES += qwindowsclipboard.cpp
HEADERS += qwindowsclipboard.h
}
# drag and drop on windows only works if a clipboard is available
!contains( DEFINES, QT_NO_DRAGANDDROP ) {
!win32:SOURCES += qwindowsdrag.cpp
!win32:HEADERS += qwindowsdrag.h
win32:!contains( DEFINES, QT_NO_CLIPBOARD ) {
HEADERS += qwindowsdrag.h
SOURCES += qwindowsdrag.cpp
}
}
!wince*:!contains( DEFINES, QT_NO_TABLETEVENT ) {
INCLUDEPATH += ../../../3rdparty/wintab
HEADERS += qwindowstabletsupport.h
SOURCES += qwindowstabletsupport.cpp
}
!wince*:!contains( DEFINES, QT_NO_SESSIONMANAGER ) {
SOURCES += qwindowssessionmanager.cpp
HEADERS += qwindowssessionmanager.h
}
contains(QT_CONFIG, freetype) {
DEFINES *= QT_NO_FONTCONFIG
QT_FREETYPE_DIR = $$QT_SOURCE_TREE/src/3rdparty/freetype
HEADERS += \
qwindowsfontdatabase_ft.h
SOURCES += \
qwindowsfontdatabase_ft.cpp \
$$QT_FREETYPE_DIR/src/base/ftbase.c \
$$QT_FREETYPE_DIR/src/base/ftbbox.c \
$$QT_FREETYPE_DIR/src/base/ftdebug.c \
$$QT_FREETYPE_DIR/src/base/ftglyph.c \
$$QT_FREETYPE_DIR/src/base/ftinit.c \
$$QT_FREETYPE_DIR/src/base/ftmm.c \
$$QT_FREETYPE_DIR/src/base/fttype1.c \
$$QT_FREETYPE_DIR/src/base/ftsynth.c \
$$QT_FREETYPE_DIR/src/base/ftbitmap.c \
$$QT_FREETYPE_DIR/src/bdf/bdf.c \
$$QT_FREETYPE_DIR/src/cache/ftcache.c \
$$QT_FREETYPE_DIR/src/cff/cff.c \
$$QT_FREETYPE_DIR/src/cid/type1cid.c \
$$QT_FREETYPE_DIR/src/gzip/ftgzip.c \
$$QT_FREETYPE_DIR/src/pcf/pcf.c \
$$QT_FREETYPE_DIR/src/pfr/pfr.c \
$$QT_FREETYPE_DIR/src/psaux/psaux.c \
$$QT_FREETYPE_DIR/src/pshinter/pshinter.c \
$$QT_FREETYPE_DIR/src/psnames/psmodule.c \
$$QT_FREETYPE_DIR/src/raster/raster.c \
$$QT_FREETYPE_DIR/src/sfnt/sfnt.c \
$$QT_FREETYPE_DIR/src/smooth/smooth.c \
$$QT_FREETYPE_DIR/src/truetype/truetype.c \
$$QT_FREETYPE_DIR/src/type1/type1.c \
$$QT_FREETYPE_DIR/src/type42/type42.c \
$$QT_FREETYPE_DIR/src/winfonts/winfnt.c \
$$QT_FREETYPE_DIR/src/lzw/ftlzw.c\
$$QT_FREETYPE_DIR/src/otvalid/otvalid.c\
$$QT_FREETYPE_DIR/src/otvalid/otvbase.c\
$$QT_FREETYPE_DIR/src/otvalid/otvgdef.c\
$$QT_FREETYPE_DIR/src/otvalid/otvjstf.c\
$$QT_FREETYPE_DIR/src/otvalid/otvcommn.c\
$$QT_FREETYPE_DIR/src/otvalid/otvgpos.c\
$$QT_FREETYPE_DIR/src/otvalid/otvgsub.c\
$$QT_FREETYPE_DIR/src/otvalid/otvmod.c\
$$QT_FREETYPE_DIR/src/autofit/afangles.c\
$$QT_FREETYPE_DIR/src/autofit/afglobal.c\
$$QT_FREETYPE_DIR/src/autofit/aflatin.c\
$$QT_FREETYPE_DIR/src/autofit/afmodule.c\
$$QT_FREETYPE_DIR/src/autofit/afdummy.c\
$$QT_FREETYPE_DIR/src/autofit/afhints.c\
$$QT_FREETYPE_DIR/src/autofit/afloader.c\
$$QT_FREETYPE_DIR/src/autofit/autofit.c
SOURCES += $$QT_FREETYPE_DIR/src/base/ftsystem.c
INCLUDEPATH += \
$$QT_FREETYPE_DIR/src \
$$QT_FREETYPE_DIR/include
TR_EXCLUDE += $$QT_FREETYPE_DIR/*
DEFINES += FT2_BUILD_LIBRARY
contains(QT_CONFIG, system-zlib) {
DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB
}
} else:contains(QT_CONFIG, system-freetype) {
include($$QT_SOURCE_TREE/src/platformsupport/fontdatabases/basic/basic.pri)
HEADERS += \
qwindowsfontdatabase_ft.h
SOURCES += \
qwindowsfontdatabase_ft.cpp
}
qwindowsgdiintegration.h \
qwindowsgdinativeinterface.h
OTHER_FILES += windows.json
contains(QT_CONFIG, accessibility):include(accessible/accessible.pri)