Windows RT and Windows Phone QPA

Change-Id: I6ab8af31f73439172e43fb709831821482b1cc99
Done-with: Kamil Trzcinski
Done-with: Oliver Wolff
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
bb10
Andrew Knight 2013-09-30 01:31:27 +03:00 committed by The Qt Project
parent 11a2226cfe
commit fc0f784e54
27 changed files with 3545 additions and 6 deletions

View File

@ -75,9 +75,12 @@ QMAKE_LFLAGS_DLL = /WINMD /MANIFEST:NO /DLL /WINMDFILE:$(DESTDIR_TARGET).
QMAKE_LFLAGS_LTCG = /LTCG
QMAKE_EXTENSION_STATICLIB = lib
QMAKE_LIBS_CORE += runtimeobject.lib
QMAKE_LIBS_GUI = d3d11.lib
QMAKE_LIBS += runtimeobject.lib
QMAKE_LIBS_CORE =
QMAKE_LIBS_GUI =
QMAKE_LIBS_NETWORK =
QMAKE_LIBS_OPENGL_ES2 = libEGL.lib libGLESv2.lib
QMAKE_LIBS_OPENGL_ES2_DEBUG = libEGLd.lib libGLESv2d.lib
QMAKE_LIBS_QT_ENTRY = -lqtmain /ENTRY:wmainCRTStartup

View File

@ -15,7 +15,8 @@ mac {
else: SUBDIRS += cocoa
}
win32: SUBDIRS += windows
win32:!winrt: SUBDIRS += windows
winrt: SUBDIRS += winrt
qnx {
SUBDIRS += qnx

View File

@ -0,0 +1,14 @@
uniform SamplerState Sampler : register(s0);
uniform Texture2D Texture : register(t0);
void blitvs(in float4 pos0 : TEXCOORD0, in float2 tex0 : TEXCOORD1,
out float4 gl_Position : SV_POSITION, out float2 coord : TEXCOORD0)
{
coord = tex0;
gl_Position = pos0 * float4(1.0, -1.0, 1.0, 1.0);
}
float4 blitps(in float4 gl_Position : SV_POSITION, in float2 coord : TEXCOORD0) : SV_TARGET0
{
return Texture.Sample(Sampler, coord);
}

View File

@ -0,0 +1,74 @@
/****************************************************************************
**
** 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 "qwinrtintegration.h"
#include <qpa/qplatformintegrationplugin.h>
QT_BEGIN_NAMESPACE
class QWinRTIntegrationPlugin : public QPlatformIntegrationPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "winrt.json")
public:
QStringList keys() const;
QPlatformIntegration *create(const QString&, const QStringList&);
};
QStringList QWinRTIntegrationPlugin::keys() const
{
return QStringList(QStringLiteral("WinRT"));
}
QPlatformIntegration *QWinRTIntegrationPlugin::create(const QString& system, const QStringList& paramList)
{
Q_UNUSED(paramList);
if (!system.compare(QLatin1String("winrt"), Qt::CaseInsensitive))
return QWinRTIntegration::create();
return 0;
}
QT_END_NAMESPACE
#include "main.moc"

View File

@ -0,0 +1,393 @@
/****************************************************************************
**
** 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 "qwinrtbackingstore.h"
#include "qwinrtscreen.h"
#include "qwinrtwindow.h"
#include "qwinrteglcontext.h"
#include <QtGui/QOpenGLContext>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <dxgi.h>
// Generated shader headers
#include "blitps.h"
#include "blitvs.h"
namespace { // Utility namespace for writing out an ANGLE-compatible binary blob
// Must match packaged ANGLE
enum : quint32 {
AngleMajorVersion = 1,
AngleMinorVersion = 2,
AngleBuildRevision = 2446,
AngleVersion = ((AngleMajorVersion << 24) | (AngleMinorVersion << 16) | AngleBuildRevision),
AngleOptimizationLevel = (1 << 14)
};
struct ShaderString
{
ShaderString(const char *data = 0) : data(data) { }
const char *data;
};
// ANGLE stream compatibility - when size_t is 32-bit, QDataStream::writeBytes() also works
QDataStream &operator<<(QDataStream &stream, const ShaderString &shaderString)
{
if (!shaderString.data)
return stream << size_t(0);
size_t len = strlen(shaderString.data);
stream << len;
stream.writeRawData(shaderString.data, int(len));
return stream;
}
struct Attribute
{
Attribute(GLenum type = 0, const char *name = 0, quint32 index = 0)
: type(type), name(name), index(index) { }
GLenum type;
ShaderString name;
quint32 index;
};
struct Sampler
{
enum TextureType { Texture2D, TextureCube };
Sampler(bool active = false, GLint unit = 0, TextureType type = Texture2D)
: active(active), unit(unit), type(type) { }
bool active;
GLint unit;
TextureType type;
};
struct Uniform
{
Uniform() { }
Uniform(GLenum type, quint32 precision, const char *name, quint32 arraySize,
quint32 psRegisterIndex, quint32 vsRegisterIndex, quint32 registerCount)
: type(type), precision(precision), name(name), arraySize(arraySize)
, psRegisterIndex(psRegisterIndex), vsRegisterIndex(vsRegisterIndex), registerCount(registerCount) { }
GLenum type;
quint32 precision;
ShaderString name;
quint32 arraySize;
quint32 psRegisterIndex;
quint32 vsRegisterIndex;
quint32 registerCount;
};
struct UniformIndex
{
UniformIndex(const char *name = 0, quint32 element = 0, quint32 index = 0)
: name(name), element(element), index(index) { }
ShaderString name;
quint32 element;
quint32 index;
};
static const QByteArray createAngleBinary(
const QVector<Attribute> &attributes,
const QVector<Sampler> &textureSamplers,
const QVector<Sampler> &vertexSamplers,
const QVector<Uniform> &uniforms,
const QVector<UniformIndex> &uniformIndex,
const QByteArray &pixelShader,
const QByteArray &vertexShader,
const QByteArray &geometryShader = QByteArray(),
bool usesPointSize = false)
{
QByteArray binary;
QDataStream stream(&binary, QIODevice::WriteOnly);
stream.setByteOrder(QDataStream::LittleEndian);
stream << quint32(GL_PROGRAM_BINARY_ANGLE)
<< quint32(AngleVersion)
<< quint32(AngleOptimizationLevel);
// Vertex attributes
for (int i = 0; i < 16; ++i) {
if (i < attributes.size())
stream << quint32(attributes[i].type) << attributes[i].name << attributes[i].index;
else
stream << quint32(GL_NONE) << ShaderString() << qint32(-1);
}
// Texture units
for (int i = 0; i < 16; ++i) {
if (i < textureSamplers.size())
stream << textureSamplers[i].active << textureSamplers[i].unit << qint32(textureSamplers[i].type);
else
stream << false << qint32(0) << qint32(Sampler::Texture2D);
}
// Vertex texture units
for (int i = 0; i < 16; ++i) {
if (i < vertexSamplers.size())
stream << vertexSamplers[i].active << vertexSamplers[i].unit << qint32(vertexSamplers[i].type);
else
stream << false << qint32(0) << qint32(Sampler::Texture2D);
}
stream << vertexSamplers.size()
<< textureSamplers.size()
<< usesPointSize;
stream << size_t(uniforms.size());
foreach (const Uniform &uniform, uniforms) {
stream << uniform.type << uniform.precision << uniform.name << uniform.arraySize
<< uniform.psRegisterIndex << uniform.vsRegisterIndex << uniform.registerCount;
}
stream << size_t(uniformIndex.size());
foreach (const UniformIndex &index, uniformIndex)
stream << index.name << index.element << index.index;
stream << quint32(pixelShader.size())
<< quint32(vertexShader.size())
<< quint32(geometryShader.size());
// ANGLE requires that we query the adapter for its LUID. Later on, it may be useful
// for checking feature level support, picking the best adapter on the system, etc.
IDXGIFactory1 *dxgiFactory;
if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&dxgiFactory)))) {
qCritical("QWinRTBackingStore: failed to create DXGI factory.");
return QByteArray();
}
IDXGIAdapter *dxgiAdapter;
if (FAILED(dxgiFactory->EnumAdapters(0, &dxgiAdapter))) {
qCritical("QWinRTBackingStore:: failed to enumerate adapter.");
dxgiFactory->Release();
return QByteArray();
}
DXGI_ADAPTER_DESC desc;
dxgiAdapter->GetDesc(&desc);
dxgiAdapter->Release();
QByteArray guid(sizeof(GUID), '\0');
memcpy(guid.data(), &desc.AdapterLuid, sizeof(LUID));
stream.writeRawData(guid.constData(), guid.size());
stream.writeRawData(pixelShader.constData(), pixelShader.size());
stream.writeRawData(vertexShader.constData(), vertexShader.size());
if (!geometryShader.isEmpty())
stream.writeRawData(geometryShader.constData(), geometryShader.size());
return binary;
}
} // namespace
QT_BEGIN_NAMESPACE
static const GLfloat normCoords[] = { -1, 1, 1, 1, 1, -1, -1, -1 };
static const GLfloat quadCoords[] = { 0, 0, 1, 0, 1, 1, 0, 1 };
QWinRTBackingStore::QWinRTBackingStore(QWindow *window)
: QPlatformBackingStore(window)
, m_context(new QOpenGLContext)
, m_shaderProgram(0)
, m_fbo(0)
, m_texture(0)
, m_screen(static_cast<QWinRTScreen*>(window->screen()->handle()))
{
window->setSurfaceType(QSurface::OpenGLSurface); // Required for flipping, but could be done in the swap
m_context->setFormat(window->requestedFormat());
m_context->setScreen(window->screen());
m_context->create();
m_context->makeCurrent(window);
glGenFramebuffers(1, &m_fbo);
glGenRenderbuffers(1, &m_rbo);
glGenTextures(1, &m_texture);
m_shaderProgram = glCreateProgram();
#if 0 // Standard GLES passthrough shader program
static const char *vertexShaderSource =
"attribute vec4 pos0;\n"
"attribute vec2 tex0;\n"
"varying vec2 coord;\n"
"void main() {\n"
" coord = tex0;\n"
" gl_Position = pos0;\n"
"}\n";
static const char *fragmentShaderSource =
"uniform sampler2D texture;\n"
"varying highp vec2 coord;\n"
"void main() {\n"
" gl_FragColor = texture2D(texture, coord);\n"
"}\n";
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
glCompileShader(vertexShader);
GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
glCompileShader(fragmentShader);
glAttachShader(m_shaderProgram, vertexShader);
glAttachShader(m_shaderProgram, fragmentShader);
glLinkProgram(m_shaderProgram);
#else // Precompiled passthrough shader
QVector<Attribute> attributes = QVector<Attribute>() << Attribute(GL_FLOAT_VEC4, "pos0", 0)
<< Attribute(GL_FLOAT_VEC2, "tex0", 1);
QVector<Sampler> textureSamplers = QVector<Sampler>() << Sampler(true, 0, Sampler::Texture2D);
QVector<Sampler> vertexSamplers;
QVector<Uniform> uniforms = QVector<Uniform>() << Uniform(GL_SAMPLER_2D, 0, "texture", 0, 0, -1, 1);
QVector<UniformIndex> uniformsIndex = QVector<UniformIndex>() << UniformIndex("texture", 0, 0);
QByteArray pixelShader(reinterpret_cast<const char *>(q_blitps), sizeof(q_blitps));
QByteArray vertexShader(reinterpret_cast<const char *>(q_blitvs), sizeof(q_blitvs));
QByteArray binary = createAngleBinary(attributes, textureSamplers, vertexSamplers,
uniforms, uniformsIndex, pixelShader, vertexShader);
glProgramBinaryOES(m_shaderProgram, GL_PROGRAM_BINARY_ANGLE, binary.constData(), binary.size());
#endif
m_context->doneCurrent();
resize(window->size(), QRegion());
}
QWinRTBackingStore::~QWinRTBackingStore()
{
glDeleteBuffers(1, &m_fbo);
glDeleteRenderbuffers(1, &m_rbo);
glDeleteTextures(1, &m_texture);
glDeleteProgram(m_shaderProgram);
}
QPaintDevice *QWinRTBackingStore::paintDevice()
{
return m_paintDevice.data();
}
void QWinRTBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(offset)
const QImage *image = static_cast<QImage *>(m_paintDevice.data());
m_context->makeCurrent(window);
// Blitting the entire image width trades zero image copy/relayout for a larger texture upload.
// Since we're blitting the whole width anyway, the boundingRect() is used in the assumption that
// we don't repeat upload. This is of course dependent on the distance between update regions.
// Ideally, we would use the GL_EXT_unpack_subimage extension, which should be possible to implement
// since D3D11_MAPPED_SUBRESOURCE supports RowPitch (see below).
// Note that single-line blits in a loop are *very* slow, so reducing calls to glTexSubImage2D
// is probably a good idea anyway.
glBindTexture(GL_TEXTURE_2D, m_texture);
QRect bounds = region.boundingRect();
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, bounds.y(), m_size.width(), bounds.height(),
GL_BGRA_EXT, GL_UNSIGNED_BYTE, image->scanLine(bounds.y()));
// TODO: Implement GL_EXT_unpack_subimage in ANGLE for more minimal uploads
//glPixelStorei(GL_UNPACK_ROW_LENGTH, image->bytesPerLine());
//glTexSubImage2D(GL_TEXTURE_2D, 0, bounds.x(), bounds.y(), bounds.width(), bounds.height(),
// GL_BGRA_EXT, GL_UNSIGNED_BYTE, image->scanLine(bounds.y()) + bounds.x() * 4);
// Bind render buffer
glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_rbo);
// Bind position
glUseProgram(m_shaderProgram);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, normCoords);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, quadCoords);
// Render
glViewport(0, 0, m_size.width(), m_size.height());
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
// Unbind
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glUseProgram(0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);
// fast blit - TODO: perform the blit inside swap buffers instead
glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, 0);
glBlitFramebufferANGLE(0, 0, m_size.width(), m_size.height(), // TODO: blit only the changed rectangle
0, 0, m_size.width(), m_size.height(),
GL_COLOR_BUFFER_BIT, GL_NEAREST);
m_context->swapBuffers(window);
m_context->doneCurrent();
}
void QWinRTBackingStore::resize(const QSize &size, const QRegion &staticContents)
{
Q_UNUSED(staticContents)
if (m_size == size)
return;
m_size = size;
m_paintDevice.reset(new QImage(m_size, QImage::Format_ARGB32_Premultiplied));
m_context->makeCurrent(window());
// Input texture
glBindTexture(GL_TEXTURE_2D, m_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, m_size.width(), m_size.height(),
0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
// Render buffer
glBindRenderbuffer(GL_RENDERBUFFER, m_rbo);
glRenderbufferStorage(GL_RENDERBUFFER, GL_BGRA8_EXT, m_size.width(), m_size.height());
glBindRenderbuffer(GL_RENDERBUFFER, 0);
m_context->doneCurrent();
}
void QWinRTBackingStore::beginPaint(const QRegion &region)
{
Q_UNUSED(region)
}
void QWinRTBackingStore::endPaint()
{
}
QT_END_NAMESPACE

View File

@ -0,0 +1,77 @@
/****************************************************************************
**
** 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 QWINRTBACKINGSTORE_H
#define QWINRTBACKINGSTORE_H
#include <qpa/qplatformbackingstore.h>
#include <QtCore/QScopedPointer>
QT_BEGIN_NAMESPACE
class QWinRTScreen;
class QOpenGLContext;
class QWinRTBackingStore : public QPlatformBackingStore
{
public:
explicit QWinRTBackingStore(QWindow *window);
~QWinRTBackingStore();
QPaintDevice *paintDevice();
void beginPaint(const QRegion &);
void endPaint();
void flush(QWindow *window, const QRegion &region, const QPoint &offset);
void resize(const QSize &size, const QRegion &staticContents);
private:
QSize m_size;
QScopedPointer<QPaintDevice> m_paintDevice;
QScopedPointer<QOpenGLContext> m_context;
quint32 m_shaderProgram;
quint32 m_fbo;
quint32 m_rbo;
quint32 m_texture;
QWinRTScreen *m_screen;
};
QT_END_NAMESPACE
#endif // QWINRTBACKINGSTORE_H

View File

@ -0,0 +1,153 @@
/****************************************************************************
**
** 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 "qwinrtcursor.h"
#include <wrl.h>
#include <windows.ui.core.h>
#include <windows.foundation.h>
using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::UI::Core;
using namespace ABI::Windows::Foundation;
QT_BEGIN_NAMESPACE
QWinRTCursor::QWinRTCursor(ICoreWindow *window) : m_window(window), m_cursorFactory(nullptr)
{
#ifndef Q_OS_WINPHONE
GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_Core_CoreCursor).Get(), &m_cursorFactory);
#endif
}
QWinRTCursor::~QWinRTCursor()
{
if (m_cursorFactory)
m_cursorFactory->Release();
}
#ifndef QT_NO_CURSOR
void QWinRTCursor::changeCursor(QCursor *windowCursor, QWindow *)
{
#ifndef Q_OS_WINPHONE
if (!m_cursorFactory)
return;
CoreCursorType type;
switch (windowCursor ? windowCursor->shape() : Qt::ArrowCursor) {
case Qt::BlankCursor:
m_window->put_PointerCursor(nullptr);
return;
default:
case Qt::OpenHandCursor:
case Qt::ClosedHandCursor:
case Qt::DragCopyCursor:
case Qt::DragMoveCursor:
case Qt::DragLinkCursor:
// (unavailable)
case Qt::ArrowCursor:
type = CoreCursorType_Arrow;
break;
case Qt::UpArrowCursor:
type = CoreCursorType_UpArrow;
break;
case Qt::CrossCursor:
type = CoreCursorType_Cross;
break;
case Qt::WaitCursor:
case Qt::BusyCursor:
type = CoreCursorType_Wait;
break;
case Qt::IBeamCursor:
type = CoreCursorType_IBeam;
break;
case Qt::SizeVerCursor:
case Qt::SplitVCursor:
type = CoreCursorType_SizeNorthSouth;
break;
case Qt::SizeHorCursor:
case Qt::SplitHCursor:
type = CoreCursorType_SizeWestEast;
break;
case Qt::SizeBDiagCursor:
type = CoreCursorType_SizeNortheastSouthwest;
break;
case Qt::SizeFDiagCursor:
type = CoreCursorType_SizeNorthwestSoutheast;
break;
case Qt::SizeAllCursor:
type = CoreCursorType_SizeAll;
break;
case Qt::PointingHandCursor:
type = CoreCursorType_Hand;
break;
case Qt::ForbiddenCursor:
type = CoreCursorType_UniversalNo;
break;
case Qt::WhatsThisCursor:
type = CoreCursorType_Help;
break;
case Qt::BitmapCursor:
case Qt::CustomCursor:
// TODO: figure out if arbitrary bitmaps can be made into resource IDs
// For now, we don't get enough info from QCursor to set a custom cursor
type = CoreCursorType_Custom;
break;
}
ICoreCursor *cursor;
if (SUCCEEDED(m_cursorFactory->CreateCursor(type, 0, &cursor)))
m_window->put_PointerCursor(cursor);
#endif // Q_OS_WINPHONE
}
#endif // QT_NO_CURSOR
QPoint QWinRTCursor::pos() const
{
#ifdef Q_OS_WINPHONE
return QPlatformCursor::pos();
#else
Point point;
m_window->get_PointerPosition(&point);
return QPoint(point.X, point.Y);
#endif
}
QT_END_NAMESPACE

View File

@ -0,0 +1,77 @@
/****************************************************************************
**
** 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 QWINRTCURSOR_H
#define QWINRTCURSOR_H
#include <qpa/qplatformcursor.h>
namespace ABI {
namespace Windows {
namespace UI {
namespace Core {
struct ICoreWindow;
struct ICoreCursorFactory;
}
}
}
}
QT_BEGIN_NAMESPACE
class QWinRTCursor : public QPlatformCursor
{
public:
explicit QWinRTCursor(ABI::Windows::UI::Core::ICoreWindow *window);
~QWinRTCursor();
#ifndef QT_NO_CURSOR
void changeCursor(QCursor * windowCursor, QWindow *);
#endif
QPoint pos() const;
private:
ABI::Windows::UI::Core::ICoreWindow *m_window;
ABI::Windows::UI::Core::ICoreCursorFactory *m_cursorFactory;
};
QT_END_NAMESPACE
#endif // QWINRTCURSOR_H

View File

@ -0,0 +1,63 @@
/****************************************************************************
**
** 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 "qwinrteglcontext.h"
QT_BEGIN_NAMESPACE
QWinRTEGLContext::QWinRTEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLSurface surface)
: QEGLPlatformContext(format, share, display, EGL_OPENGL_ES_API), m_eglSurface(surface)
{
}
EGLSurface QWinRTEGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface)
{
if (surface->surface()->surfaceClass() == QSurface::Window) {
// All windows use the same surface
return m_eglSurface;
} else {
// TODO: return EGL surfaces for offscreen surfaces
qWarning("This plugin does not support offscreen surfaces.");
return EGL_NO_SURFACE;
}
}
QT_END_NAMESPACE

View File

@ -0,0 +1,63 @@
/****************************************************************************
**
** 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 QWINDOWSEGLCONTEXT_H
#define QWINDOWSEGLCONTEXT_H
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
QT_BEGIN_NAMESPACE
class QWinRTEGLContext : public QEGLPlatformContext
{
public:
explicit QWinRTEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLSurface surface);
protected:
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface);
private:
EGLSurface m_eglSurface;
};
QT_END_NAMESPACE
#endif // QWINDOWSEGLCONTEXT_H

View File

@ -0,0 +1,79 @@
/****************************************************************************
**
** 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 "qwinrteventdispatcher.h"
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformscreen.h>
#include <qpa/qplatformscreenpageflipper.h>
#include <QtCore/QThread>
#include <QtGui/QGuiApplication>
#include <Windows.ui.core.h>
#include <Windows.ApplicationModel.core.h>
using namespace ABI::Windows::ApplicationModel::Core;
using namespace ABI::Windows::UI::Core;
using namespace ABI::Windows::Foundation;
QT_BEGIN_NAMESPACE
QWinRTEventDispatcher::QWinRTEventDispatcher(ICoreDispatcher *dispatcher, QObject *parent)
: QEventDispatcherWinRT(parent)
, m_dispatcher(dispatcher)
{
}
bool QWinRTEventDispatcher::hasPendingEvents()
{
return QEventDispatcherWinRT::hasPendingEvents() || QWindowSystemInterface::windowSystemEventsQueued();
}
bool QWinRTEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
{
if (m_dispatcher)
m_dispatcher->ProcessEvents(CoreProcessEventsOption_ProcessAllIfPresent);
const bool didProcess = QWindowSystemInterface::sendWindowSystemEvents(flags);
return QEventDispatcherWinRT::processEvents(flags & ~QEventLoop::WaitForMoreEvents) || didProcess;
}
QT_END_NAMESPACE

View File

@ -0,0 +1,80 @@
/****************************************************************************
**
** 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 QWINRTEVENTDISPATCHER_H
#define QWINRTEVENTDISPATCHER_H
#include <QtCore/QAbstractEventDispatcher>
#include <QtCore/QEvent>
#include <QtCore/private/qeventdispatcher_winrt_p.h>
namespace ABI {
namespace Windows {
namespace UI {
namespace Core {
struct ICoreDispatcher;
}
}
}
}
QT_BEGIN_NAMESPACE
class QWinRTEventDispatcher : public QEventDispatcherWinRT
{
Q_OBJECT
public:
explicit QWinRTEventDispatcher(ABI::Windows::UI::Core::ICoreDispatcher *dispatcher, QObject *parent = 0);
protected:
bool hasPendingEvents();
bool processEvents(QEventLoop::ProcessEventsFlags flags);
private:
ABI::Windows::UI::Core::ICoreDispatcher *m_dispatcher;
friend class QWinRTIntegration;
};
QT_END_NAMESPACE
#endif // QWINRTEVENTDISPATCHER_H

View File

@ -0,0 +1,64 @@
/****************************************************************************
**
** 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 "qwinrtfontdatabase.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QFile>
QT_BEGIN_NAMESPACE
QString QWinRTFontDatabase::fontDir() const
{
QString fontDirectory = QBasicFontDatabase::fontDir();
if (!QFile::exists(fontDirectory)) {
// Fall back to app directory + fonts, and just app directory after that
const QString applicationDirPath = QCoreApplication::applicationDirPath();
fontDirectory = applicationDirPath + QLatin1String("/fonts");
if (!QFile::exists(fontDirectory)) {
qWarning("No fonts directory found in application package.");
fontDirectory = applicationDirPath;
}
}
return fontDirectory;
}
QT_END_NAMESPACE

View File

@ -0,0 +1,57 @@
/****************************************************************************
**
** 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 QWINRTFONTDATABASE_H
#define QWINRTFONTDATABASE_H
#include <QtPlatformSupport/private/qbasicfontdatabase_p.h>
QT_BEGIN_NAMESPACE
class QWinRTFontDatabase : public QBasicFontDatabase
{
public:
QString fontDir() const;
};
QT_END_NAMESPACE
#endif // QWINRTFONTDATABASE_H

View File

@ -0,0 +1,300 @@
/****************************************************************************
**
** 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 "qwinrtinputcontext.h"
#include <QtGui/QWindow>
#include <wrl.h>
#include <roapi.h>
#include <windows.ui.viewmanagement.h>
#include <windows.ui.core.h>
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::UI::ViewManagement;
using namespace ABI::Windows::UI::Core;
#ifdef Q_OS_WINPHONE
#include <windows.phone.ui.core.h>
using namespace ABI::Windows::Phone::UI::Core;
#endif
typedef ITypedEventHandler<InputPane*, InputPaneVisibilityEventArgs*> InputPaneVisibilityHandler;
QT_BEGIN_NAMESPACE
/*!
\class QWinRTInputContext
\brief Manages Input Method visibility
\internal
\ingroup qt-qpa-winrt
Listens to the native virtual keyboard for hide/show events and provides
hints to the OS for showing/hiding. On WinRT, showInputPanel()/hideInputPanel()
have no effect because WinRT dictates that keyboard presence is user-driven:
(http://msdn.microsoft.com/en-us/library/windows/apps/hh465404.aspx)
Windows Phone, however, supports direct hiding/showing of the keyboard.
*/
QWinRTInputContext::QWinRTInputContext(ICoreWindow *window)
: m_window(window)
{
IInputPaneStatics *statics;
if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(),
&statics))) {
qWarning(Q_FUNC_INFO ": failed to retrieve input pane statics.");
return;
}
IInputPane *inputPane;
statics->GetForCurrentView(&inputPane);
statics->Release();
if (inputPane) {
EventRegistrationToken showToken, hideToken;
inputPane->add_Showing(Callback<InputPaneVisibilityHandler>(
this, &QWinRTInputContext::onShowing).Get(), &showToken);
inputPane->add_Hiding(Callback<InputPaneVisibilityHandler>(
this, &QWinRTInputContext::onHiding).Get(), &hideToken);
Rect rect;
inputPane->get_OccludedRect(&rect);
m_keyboardRect = QRectF(rect.X, rect.Y, rect.Width, rect.Height);
m_isInputPanelVisible = !m_keyboardRect.isEmpty();
} else {
qWarning(Q_FUNC_INFO ": failed to retrieve InputPane.");
}
}
QRectF QWinRTInputContext::keyboardRect() const
{
return m_keyboardRect;
}
bool QWinRTInputContext::isInputPanelVisible() const
{
return m_isInputPanelVisible;
}
HRESULT QWinRTInputContext::onShowing(IInputPane *pane, IInputPaneVisibilityEventArgs *)
{
m_isInputPanelVisible = true;
emitInputPanelVisibleChanged();
Rect rect;
pane->get_OccludedRect(&rect);
setKeyboardRect(QRectF(rect.X, rect.Y, rect.Width, rect.Height));
return S_OK;
}
HRESULT QWinRTInputContext::onHiding(IInputPane *pane, IInputPaneVisibilityEventArgs *)
{
m_isInputPanelVisible = false;
emitInputPanelVisibleChanged();
Rect rect;
pane->get_OccludedRect(&rect);
setKeyboardRect(QRectF(rect.X, rect.Y, rect.Width, rect.Height));
return S_OK;
}
void QWinRTInputContext::setKeyboardRect(const QRectF rect)
{
if (m_keyboardRect == rect)
return;
m_keyboardRect = rect;
emitKeyboardRectChanged();
}
#ifdef Q_OS_WINPHONE
void QWinRTInputContext::showInputPanel()
{
ICoreWindowKeyboardInput *input;
if (SUCCEEDED(m_window->QueryInterface(IID_PPV_ARGS(&input)))) {
input->put_IsKeyboardInputEnabled(true);
input->Release();
}
}
void QWinRTInputContext::hideInputPanel()
{
ICoreWindowKeyboardInput *input;
if (SUCCEEDED(m_window->QueryInterface(IID_PPV_ARGS(&input)))) {
input->put_IsKeyboardInputEnabled(false);
input->Release();
}
}
#else // Q_OS_WINPHONE
// IRawElementProviderSimple
HRESULT QWinRTInputContext::get_ProviderOptions(ProviderOptions *retVal)
{
*retVal = ProviderOptions_ServerSideProvider|ProviderOptions_UseComThreading;
return S_OK;
}
HRESULT QWinRTInputContext::GetPatternProvider(PATTERNID id, IUnknown **retVal)
{
switch (id) {
case 10002: //UIA_ValuePatternId
return QueryInterface(__uuidof(IValueProvider), (void**)retVal);
break;
case 10014: //UIA_TextPatternId:
return QueryInterface(__uuidof(ITextProvider), (void**)retVal);
case 10029: //UIA_TextChildPatternId:
*retVal = nullptr;
break;
default:
qWarning("Unhandled pattern ID: %d", id);
break;
}
return S_OK;
}
HRESULT QWinRTInputContext::GetPropertyValue(PROPERTYID idProp, VARIANT *retVal)
{
switch (idProp) {
case 30003: //UIA_ControlTypePropertyId
retVal->vt = VT_I4;
retVal->lVal = 50025; //UIA_CustomControlTypeId
break;
case 30008: //UIA_IsKeyboardFocusablePropertyId
case 30009: //UIA_HasKeyboardFocusPropertyId
// These are probably never actually called
case 30016: //UIA_IsControlElementPropertyId
case 30017: //UIA_IsContentElementPropertyId
retVal->vt = VT_BOOL;
retVal->boolVal = VARIANT_TRUE;
break;
case 30019: //UIA_IsPasswordPropertyId
retVal->vt = VT_BOOL;
retVal->boolVal = VARIANT_FALSE;
break;
case 30020: //UIA_NativeWindowHandlePropertyId
retVal->vt = VT_PTR;
retVal->punkVal = m_window;
break;
}
return S_OK;
}
HRESULT QWinRTInputContext::get_HostRawElementProvider(IRawElementProviderSimple **retVal)
{
// Return the window's element provider
IInspectable *hostProvider;
HRESULT hr = m_window->get_AutomationHostProvider(&hostProvider);
if (SUCCEEDED(hr)) {
hr = hostProvider->QueryInterface(IID_PPV_ARGS(retVal));
hostProvider->Release();
}
return hr;
}
// ITextProvider
HRESULT QWinRTInputContext::GetSelection(SAFEARRAY **)
{
// To be useful, requires listening to the focus object for a selection change and raising an event
return S_OK;
}
HRESULT QWinRTInputContext::GetVisibleRanges(SAFEARRAY **)
{
// To be useful, requires listening to the focus object for a selection change and raising an event
return S_OK;
}
HRESULT QWinRTInputContext::RangeFromChild(IRawElementProviderSimple *,ITextRangeProvider **)
{
// To be useful, requires listening to the focus object for a selection change and raising an event
return S_OK;
}
HRESULT QWinRTInputContext::RangeFromPoint(UiaPoint, ITextRangeProvider **)
{
// To be useful, requires listening to the focus object for a selection change and raising an event
return S_OK;
}
HRESULT QWinRTInputContext::get_DocumentRange(ITextRangeProvider **)
{
// To be useful, requires listening to the focus object for a selection change and raising an event
return S_OK;
}
HRESULT QWinRTInputContext::get_SupportedTextSelection(SupportedTextSelection *)
{
// To be useful, requires listening to the focus object for a selection change and raising an event
return S_OK;
}
// IValueProvider
HRESULT QWinRTInputContext::SetValue(LPCWSTR)
{
// To be useful, requires listening to the focus object for a value change and raising an event
// May be useful for inputPanel autocomplete, etc.
return S_OK;
}
HRESULT QWinRTInputContext::get_Value(BSTR *)
{
// To be useful, requires listening to the focus object for a value change and raising an event
// May be useful for inputPanel autocomplete, etc.
return S_OK;
}
HRESULT QWinRTInputContext::get_IsReadOnly(BOOL *isReadOnly)
{
// isReadOnly dictates keyboard opening behavior when view is tapped.
// We need to decide if the user tapped within a control which is about to receive focus...
// Since this isn't possible (this function gets called before we receive the touch event),
// the most platform-aligned option is to show the keyboard if an editable item has focus,
// and close the keyboard if it is already open.
*isReadOnly = m_isInputPanelVisible || !inputMethodAccepted();
return S_OK;
}
#endif // !Q_OS_WINPHONE
QT_END_NAMESPACE

View File

@ -0,0 +1,121 @@
/****************************************************************************
**
** 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 QWINRTINPUTCONTEXT_H
#define QWINRTINPUTCONTEXT_H
#include <qpa/qplatforminputcontext.h>
#include <QtCore/QRectF>
#include <wrl.h>
#ifndef Q_OS_WINPHONE
# include <UIAutomationCore.h>
#endif
namespace ABI {
namespace Windows {
namespace UI {
namespace Core {
struct ICoreWindow;
}
namespace ViewManagement {
struct IInputPane;
struct IInputPaneVisibilityEventArgs;
}
}
}
}
QT_BEGIN_NAMESPACE
class QWinRTInputContext : public QPlatformInputContext
#ifndef Q_OS_WINPHONE
, public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::WinRtClassicComMix>,
IRawElementProviderSimple, ITextProvider, IValueProvider>
#endif // !Q_OS_WINPHONE
{
public:
explicit QWinRTInputContext(ABI::Windows::UI::Core::ICoreWindow *window);
QRectF keyboardRect() const;
bool isInputPanelVisible() const;
#ifdef Q_OS_WINPHONE
void showInputPanel();
void hideInputPanel();
#else // Q_OS_WINPHONE
// IRawElementProviderSimple
HRESULT __stdcall get_ProviderOptions(ProviderOptions *retVal);
HRESULT __stdcall GetPatternProvider(PATTERNID, IUnknown **);
HRESULT __stdcall GetPropertyValue(PROPERTYID idProp, VARIANT *retVal);
HRESULT __stdcall get_HostRawElementProvider(IRawElementProviderSimple **retVal);
// ITextProvider
HRESULT __stdcall GetSelection(SAFEARRAY **);
HRESULT __stdcall GetVisibleRanges(SAFEARRAY **);
HRESULT __stdcall RangeFromChild(IRawElementProviderSimple *,ITextRangeProvider **);
HRESULT __stdcall RangeFromPoint(UiaPoint, ITextRangeProvider **);
HRESULT __stdcall get_DocumentRange(ITextRangeProvider **);
HRESULT __stdcall get_SupportedTextSelection(SupportedTextSelection *);
// IValueProvider
HRESULT __stdcall SetValue(LPCWSTR);
HRESULT __stdcall get_Value(BSTR *);
HRESULT __stdcall get_IsReadOnly(BOOL *);
#endif // !Q_OS_WINPHONE
private:
HRESULT onShowing(ABI::Windows::UI::ViewManagement::IInputPane *,
ABI::Windows::UI::ViewManagement::IInputPaneVisibilityEventArgs *);
HRESULT onHiding(ABI::Windows::UI::ViewManagement::IInputPane *,
ABI::Windows::UI::ViewManagement::IInputPaneVisibilityEventArgs *);
void setKeyboardRect(const QRectF rect);
ABI::Windows::UI::Core::ICoreWindow *m_window;
QRectF m_keyboardRect;
bool m_isInputPanelVisible;
};
QT_END_NAMESPACE
#endif // QWINRTINPUTCONTEXT_H

View File

@ -0,0 +1,192 @@
/****************************************************************************
**
** 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 "qwinrtintegration.h"
#include "qwinrtwindow.h"
#include "qwinrteventdispatcher.h"
#include "qwinrtbackingstore.h"
#include "qwinrtscreen.h"
#include "qwinrtinputcontext.h"
#include "qwinrtservices.h"
#include "qwinrteglcontext.h"
#include "qwinrtfontdatabase.h"
#include <QtGui/QOpenGLContext>
#include <wrl.h>
#include <windows.ui.core.h>
#include <windows.ui.viewmanagement.h>
#include <Windows.ApplicationModel.core.h>
using namespace Microsoft::WRL;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::UI::Core;
using namespace ABI::Windows::UI::ViewManagement;
using namespace ABI::Windows::ApplicationModel::Core;
static IUISettings *getSettings()
{
static IUISettings *settings = 0;
if (!settings) {
if (FAILED(RoActivateInstance(Wrappers::HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_UISettings).Get(),
reinterpret_cast<IInspectable **>(&settings)))) {
qWarning("Could not activate UISettings.");
}
}
return settings;
}
QT_BEGIN_NAMESPACE
QWinRTIntegration::QWinRTIntegration()
: m_success(false)
, m_fontDatabase(new QWinRTFontDatabase)
, m_services(new QWinRTServices)
{
// Obtain the WinRT Application, view, and window
ICoreApplication *application;
if (FAILED(RoGetActivationFactory(Wrappers::HString::MakeReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(),
IID_PPV_ARGS(&application))))
qCritical("Could not attach to the application factory.");
ICoreApplicationView *view;
if (FAILED(application->GetCurrentView(&view))) {
qCritical("Could not obtain the application view - have you started outside of WinRT?");
return;
}
// Get core window (will act as our screen)
ICoreWindow *window;
if (FAILED(view->get_CoreWindow(&window))) {
qCritical("Could not obtain the application window - have you started outside of WinRT?");
return;
}
window->Activate();
m_screen = new QWinRTScreen(window);
screenAdded(m_screen);
// Get event dispatcher
ICoreDispatcher *dispatcher;
if (FAILED(window->get_Dispatcher(&dispatcher)))
qCritical("Could not capture UI Dispatcher");
m_eventDispatcher = new QWinRTEventDispatcher(dispatcher);
m_success = true;
}
QWinRTIntegration::~QWinRTIntegration()
{
Windows::Foundation::Uninitialize();
}
QAbstractEventDispatcher *QWinRTIntegration::guiThreadEventDispatcher() const
{
return m_eventDispatcher;
}
bool QWinRTIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
switch (cap) {
case ThreadedPixmaps:
case OpenGL:
case ApplicationState:
return true;
default:
return QPlatformIntegration::hasCapability(cap);
}
}
QVariant QWinRTIntegration::styleHint(StyleHint hint) const
{
switch (hint) {
case CursorFlashTime:
if (IUISettings *settings = getSettings()) {
quint32 blinkRate;
settings->get_CaretBlinkRate(&blinkRate);
return blinkRate;
}
break;
case MouseDoubleClickInterval:
if (IUISettings *settings = getSettings()) {
quint32 doubleClickTime;
settings->get_DoubleClickTime(&doubleClickTime);
return doubleClickTime;
}
case ShowIsFullScreen:
return true;
default:
break;
}
return QPlatformIntegration::styleHint(hint);
}
QPlatformWindow *QWinRTIntegration::createPlatformWindow(QWindow *window) const
{
return new QWinRTWindow(window);
}
QPlatformBackingStore *QWinRTIntegration::createPlatformBackingStore(QWindow *window) const
{
return new QWinRTBackingStore(window);
}
QPlatformOpenGLContext *QWinRTIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
QWinRTScreen *screen = static_cast<QWinRTScreen *>(context->screen()->handle());
return new QWinRTEGLContext(context->format(), context->handle(), screen->eglDisplay(), screen->eglSurface());
}
QPlatformFontDatabase *QWinRTIntegration::fontDatabase() const
{
return m_fontDatabase;
}
QPlatformInputContext *QWinRTIntegration::inputContext() const
{
return m_screen->inputContext();
}
QPlatformServices *QWinRTIntegration::services() const
{
return m_services;
}
QT_END_NAMESPACE

View File

@ -0,0 +1,86 @@
/****************************************************************************
**
** 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 QWINRTINTEGRATION_H
#define QWINRTINTEGRATION_H
#include <qpa/qplatformintegration.h>
QT_BEGIN_NAMESPACE
class QAbstractEventDispatcher;
class QWinRTScreen;
class QWinRTIntegration : public QPlatformIntegration
{
private:
explicit QWinRTIntegration();
public:
~QWinRTIntegration();
static QWinRTIntegration *create()
{
QWinRTIntegration *integration = new QWinRTIntegration;
return integration->m_success ? integration : 0;
}
bool hasCapability(QPlatformIntegration::Capability cap) const;
QVariant styleHint(StyleHint hint) const;
QPlatformWindow *createPlatformWindow(QWindow *window) const;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
QAbstractEventDispatcher *guiThreadEventDispatcher() const;
QPlatformFontDatabase *fontDatabase() const;
QPlatformInputContext *inputContext() const;
QPlatformServices *services() const;
private:
bool m_success;
QWinRTScreen *m_screen;
QAbstractEventDispatcher *m_eventDispatcher;
QPlatformFontDatabase *m_fontDatabase;
QPlatformServices *m_services;
};
QT_END_NAMESPACE
#endif // QWINRTINTEGRATION_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,163 @@
/****************************************************************************
**
** 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 QWINRTSCREEN_H
#define QWINRTSCREEN_H
#include <qpa/qplatformscreen.h>
#include <qpa/qwindowsysteminterface.h>
#include <QtCore/QHash>
#include <QtGui/QSurfaceFormat>
#include <EGL/egl.h>
#include <EventToken.h>
namespace ABI {
namespace Windows {
namespace UI {
namespace Core {
struct IAutomationProviderRequestedEventArgs;
struct ICharacterReceivedEventArgs;
struct ICoreWindow;
struct ICoreWindowEventArgs;
struct IKeyEventArgs;
struct IPointerEventArgs;
struct IVisibilityChangedEventArgs;
struct IWindowActivatedEventArgs;
struct IWindowSizeChangedEventArgs;
}
namespace ViewManagement {
struct IApplicationViewStatics;
}
}
namespace Graphics {
namespace Display {
struct IDisplayPropertiesStatics;
}
}
}
}
struct IInspectable;
QT_BEGIN_NAMESPACE
class QTouchDevice;
class QWinRTEGLContext;
class QWinRTPageFlipper;
class QWinRTCursor;
class QWinRTInputContext;
struct Pointer {
enum Type { Unknown, Mouse, TouchScreen, Tablet };
Type type;
QTouchDevice *device;
};
class QWinRTScreen : public QPlatformScreen
{
public:
explicit QWinRTScreen(ABI::Windows::UI::Core::ICoreWindow *window);
QRect geometry() const;
int depth() const;
QImage::Format format() const;
QSurfaceFormat surfaceFormat() const;
QWinRTInputContext *inputContext() const;
QPlatformCursor *cursor() const;
Qt::ScreenOrientation nativeOrientation() const;
Qt::ScreenOrientation orientation() const;
QWindow *topWindow() const;
void addWindow(QWindow *window);
void removeWindow(QWindow *window);
void raise(QWindow *window);
void lower(QWindow *window);
ABI::Windows::UI::Core::ICoreWindow *coreWindow() const;
EGLDisplay eglDisplay() const; // To opengl context
EGLSurface eglSurface() const; // To window
private:
void handleExpose();
// Event handlers
QHash<QEvent::Type, EventRegistrationToken> m_tokens;
HRESULT onKey(ABI::Windows::UI::Core::ICoreWindow *window, ABI::Windows::UI::Core::IKeyEventArgs *args);
HRESULT onCharacterReceived(ABI::Windows::UI::Core::ICoreWindow *window, ABI::Windows::UI::Core::ICharacterReceivedEventArgs *args);
HRESULT onPointerEntered(ABI::Windows::UI::Core::ICoreWindow *window, ABI::Windows::UI::Core::IPointerEventArgs *args);
HRESULT onPointerExited(ABI::Windows::UI::Core::ICoreWindow *window, ABI::Windows::UI::Core::IPointerEventArgs *args);
HRESULT onPointerUpdated(ABI::Windows::UI::Core::ICoreWindow *window, ABI::Windows::UI::Core::IPointerEventArgs *args);
HRESULT onSizeChanged(ABI::Windows::UI::Core::ICoreWindow *window, ABI::Windows::UI::Core::IWindowSizeChangedEventArgs *args);
HRESULT onActivated(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IWindowActivatedEventArgs *args);
HRESULT onClosed(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::ICoreWindowEventArgs *args);
HRESULT onVisibilityChanged(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IVisibilityChangedEventArgs *args);
HRESULT onAutomationProviderRequested(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IAutomationProviderRequestedEventArgs *args);
HRESULT onOrientationChanged(IInspectable *);
ABI::Windows::UI::Core::ICoreWindow *m_coreWindow;
ABI::Windows::UI::ViewManagement::IApplicationViewStatics *m_applicationView;
QRect m_geometry;
QImage::Format m_format;
QSurfaceFormat m_surfaceFormat;
int m_depth;
QWinRTInputContext *m_inputContext;
QWinRTCursor *m_cursor;
QList<QWindow *> m_visibleWindows;
EGLDisplay m_eglDisplay;
EGLSurface m_eglSurface;
ABI::Windows::Graphics::Display::IDisplayPropertiesStatics *m_displayProperties;
Qt::ScreenOrientation m_nativeOrientation;
Qt::ScreenOrientation m_orientation;
QHash<quint32, QString> m_activeKeys;
QHash<quint32, Pointer> m_pointers;
QHash<quint32, QWindowSystemInterface::TouchPoint> m_touchPoints;
};
QT_END_NAMESPACE
#endif // QWINRTSCREEN_H

View File

@ -0,0 +1,138 @@
/****************************************************************************
**
** 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 "qwinrtservices.h"
#include <QtCore/QUrl>
#include <QtCore/QDir>
#include <QtCore/QCoreApplication>
#include <wrl.h>
#include <windows.foundation.h>
#include <windows.storage.h>
#include <windows.system.h>
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Storage;
using namespace ABI::Windows::System;
QT_BEGIN_NAMESPACE
QWinRTServices::QWinRTServices()
{
GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Foundation_Uri).Get(), &m_uriFactory);
GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_StorageFile).Get(), &m_fileFactory);
GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Launcher).Get(), &m_launcher);
}
QWinRTServices::~QWinRTServices()
{
if (m_uriFactory)
m_uriFactory->Release();
if (m_fileFactory)
m_fileFactory->Release();
if (m_launcher)
m_launcher->Release();
}
bool QWinRTServices::openUrl(const QUrl &url)
{
if (!(m_uriFactory && m_launcher))
return QPlatformServices::openUrl(url);
IUriRuntimeClass *uri;
QString urlString = url.toString(); HSTRING uriString; HSTRING_HEADER header;
WindowsCreateStringReference((const wchar_t*)urlString.utf16(), urlString.length(), &header, &uriString);
m_uriFactory->CreateUri(uriString, &uri);
if (!uri)
return false;
IAsyncOperation<bool> *launchOp;
m_launcher->LaunchUriAsync(uri, &launchOp);
uri->Release();
if (!launchOp)
return false;
boolean result = false;
while (launchOp->GetResults(&result) == E_ILLEGAL_METHOD_CALL)
QCoreApplication::processEvents();
launchOp->Release();
return result;
}
bool QWinRTServices::openDocument(const QUrl &url)
{
if (!(m_fileFactory && m_launcher))
return QPlatformServices::openDocument(url);
QString pathString = QDir::toNativeSeparators(
QDir::cleanPath(qApp->applicationDirPath().append(url.toString(QUrl::RemoveScheme))));
HSTRING_HEADER header; HSTRING path;
WindowsCreateStringReference((const wchar_t*)pathString.utf16(), pathString.length(), &header, &path);
IAsyncOperation<StorageFile*> *fileOp;
m_fileFactory->GetFileFromPathAsync(path, &fileOp);
if (!fileOp)
return false;
IStorageFile *file = nullptr;
while (fileOp->GetResults(&file) == E_ILLEGAL_METHOD_CALL)
QCoreApplication::processEvents();
fileOp->Release();
if (!file)
return false;
IAsyncOperation<bool> *launchOp;
m_launcher->LaunchFileAsync(file, &launchOp);
if (!launchOp)
return false;
boolean result = false;
while (launchOp->GetResults(&result) == E_ILLEGAL_METHOD_CALL)
QCoreApplication::processEvents();
launchOp->Release();
return result;
}
QT_END_NAMESPACE

View File

@ -0,0 +1,80 @@
/****************************************************************************
**
** 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 QWINRTSERVICES_H
#define QWINRTSERVICES_H
#include <qpa/qplatformservices.h>
namespace ABI {
namespace Windows {
namespace Foundation {
struct IUriRuntimeClassFactory;
}
namespace Storage {
struct IStorageFileStatics;
}
namespace System {
struct ILauncherStatics;
}
}
}
QT_BEGIN_NAMESPACE
class QWinRTServices : public QPlatformServices
{
public:
explicit QWinRTServices();
~QWinRTServices();
bool openUrl(const QUrl &url);
bool openDocument(const QUrl &url);
private:
ABI::Windows::Foundation::IUriRuntimeClassFactory *m_uriFactory;
ABI::Windows::Storage::IStorageFileStatics *m_fileFactory;
ABI::Windows::System::ILauncherStatics *m_launcher;
};
QT_END_NAMESPACE
#endif // QWINRTSERVICES_H

View File

@ -0,0 +1,119 @@
/****************************************************************************
**
** 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 "qwinrtwindow.h"
#include "qwinrtscreen.h"
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformscreen.h>
#include <QtGui/QGuiApplication>
#include <QtGui/QWindow>
#include <QtGui/QOpenGLContext>
QT_BEGIN_NAMESPACE
QWinRTWindow::QWinRTWindow(QWindow *window)
: QPlatformWindow(window)
, m_screen(static_cast<QWinRTScreen*>(screen()))
{
setWindowFlags(window->flags());
setWindowState(window->windowState());
handleContentOrientationChange(window->contentOrientation());
setGeometry(window->geometry());
}
QWinRTWindow::~QWinRTWindow()
{
m_screen->removeWindow(window());
}
QSurfaceFormat QWinRTWindow::format() const
{
return m_screen->surfaceFormat();
}
bool QWinRTWindow::isActive() const
{
return m_screen->topWindow() == window();
}
bool QWinRTWindow::isExposed() const
{
const bool exposed = isActive();
return exposed;
}
void QWinRTWindow::setGeometry(const QRect &rect)
{
if (window()->isTopLevel()) {
QPlatformWindow::setGeometry(m_screen->geometry());
QWindowSystemInterface::handleGeometryChange(window(), geometry());
} else {
QPlatformWindow::setGeometry(rect);
QWindowSystemInterface::handleGeometryChange(window(), rect);
}
}
void QWinRTWindow::setVisible(bool visible)
{
if (!window()->isTopLevel())
return;
if (visible)
m_screen->addWindow(window());
else
m_screen->removeWindow(window());
}
void QWinRTWindow::raise()
{
if (!window()->isTopLevel())
return;
m_screen->raise(window());
}
void QWinRTWindow::lower()
{
if (!window()->isTopLevel())
return;
m_screen->lower(window());
}
QT_END_NAMESPACE

View File

@ -0,0 +1,72 @@
/****************************************************************************
**
** 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 QWINRTWINDOW_H
#define QWINRTWINDOW_H
#include <qpa/qplatformwindow.h>
#include <qpa/qwindowsysteminterface.h>
QT_BEGIN_NAMESPACE
class QWinRTScreen;
class QWinRTWindow : public QPlatformWindow
{
public:
QWinRTWindow(QWindow *window);
~QWinRTWindow();
QSurfaceFormat format() const;
bool isActive() const;
bool isExposed() const;
void setGeometry(const QRect &rect);
void setVisible(bool visible);
void raise();
void lower();
private:
QWinRTScreen *m_screen;
};
QT_END_NAMESPACE
#endif // QWINRTWINDOW_H

View File

@ -0,0 +1,3 @@
{
"Keys": [ "winrt" ]
}

View File

@ -0,0 +1,55 @@
TARGET = qwinrt
CONFIG -= precompile_header
PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QWinRTIntegrationPlugin
load(qt_plugin)
QT += core-private gui-private platformsupport-private
DEFINES *= QT_NO_CAST_FROM_ASCII __WRL_NO_DEFAULT_LIB__ GL_GLEXT_PROTOTYPES
LIBS += $$QMAKE_LIBS_CORE -ldxgi
SOURCES = \
main.cpp \
qwinrtbackingstore.cpp \
qwinrtcursor.cpp \
qwinrteglcontext.cpp \
qwinrteventdispatcher.cpp \
qwinrtfontdatabase.cpp \
qwinrtinputcontext.cpp \
qwinrtintegration.cpp \
qwinrtscreen.cpp \
qwinrtservices.cpp \
qwinrtwindow.cpp
HEADERS = \
qwinrtbackingstore.h \
qwinrtcursor.h \
qwinrteglcontext.h \
qwinrteventdispatcher.h \
qwinrtfontdatabase.h \
qwinrtinputcontext.h \
qwinrtintegration.h \
qwinrtscreen.h \
qwinrtservices.h \
qwinrtwindow.h
BLIT_INPUT = $$PWD/blit.hlsl
fxc_blitps.commands = fxc.exe /nologo /T ps_4_0_level_9_1 /E blitps /Vn q_blitps /Fh ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
fxc_blitps.output = $$OUT_PWD/blitps.h
fxc_blitps.input = BLIT_INPUT
fxc_blitps.dependency_type = TYPE_C
fxc_blitps.variable_out = HEADERS
fxc_blitps.CONFIG += target_predeps
fxc_blitvs.commands = fxc.exe /nologo /T vs_4_0_level_9_1 /E blitvs /Vn q_blitvs /Fh ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
fxc_blitvs.output = $$OUT_PWD/blitvs.h
fxc_blitvs.input = BLIT_INPUT
fxc_blitvs.dependency_type = TYPE_C
fxc_blitvs.variable_out = HEADERS
fxc_blitvs.CONFIG += target_predeps
QMAKE_EXTRA_COMPILERS += fxc_blitps fxc_blitvs
OTHER_FILES += winrt.json \
blit.hlsl

View File

@ -1597,8 +1597,8 @@ void Configure::applySpecSpecifics()
dictionary[ "LIBPNG" ] = "qt";
dictionary[ "FREETYPE" ] = "yes";
dictionary[ "ACCESSIBILITY" ] = "no";
dictionary[ "OPENGL" ] = "no";
dictionary[ "OPENGL_ES_2" ] = "no";
dictionary[ "OPENGL" ] = "yes";
dictionary[ "OPENGL_ES_2" ] = "yes";
dictionary[ "OPENVG" ] = "no";
dictionary[ "OPENSSL" ] = "auto";
dictionary[ "DBUS" ] = "no";
@ -1607,7 +1607,7 @@ void Configure::applySpecSpecifics()
dictionary[ "ICU" ] = "qt";
dictionary[ "CE_CRT" ] = "yes";
dictionary[ "LARGE_FILE" ] = "no";
dictionary[ "ANGLE" ] = "no";
dictionary[ "ANGLE" ] = "d3d11";
if (dictionary.value("XQMAKESPEC").startsWith("winphone"))
dictionary[ "SQL_SQLITE" ] = "no";
} else if (dictionary.value("XQMAKESPEC").startsWith("wince")) {