summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenutypes.cpp1
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenutypes_p.h15
-rw-r--r--src/platformsupport/dbustray/qdbustraytypes.cpp2
-rw-r--r--src/platformsupport/dbustray/qdbustraytypes_p.h2
-rw-r--r--src/platformsupport/eglconvenience/eglconvenience.pri25
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcontext.cpp17
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcontext_p.h1
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcursor.cpp410
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcursor_p.h142
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformintegration.cpp366
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformintegration_p.h122
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformscreen.cpp146
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformscreen_p.h79
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformwindow.cpp138
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformwindow_p.h85
-rw-r--r--src/platformsupport/fbconvenience/qfbscreen.cpp5
-rw-r--r--src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp22
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp5
-rw-r--r--src/platformsupport/fontdatabases/mac/coretext.pri7
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm154
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h7
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtablet.cpp2
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtablet_p.h3
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp12
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h3
-rw-r--r--src/platformsupport/input/libinput/qlibinputhandler.cpp6
-rw-r--r--src/platformsupport/input/libinput/qlibinputkeyboard.cpp17
-rw-r--r--src/platformsupport/linuxaccessibility/atspiadaptor.cpp10
-rw-r--r--src/platformsupport/linuxaccessibility/cache.cpp3
-rw-r--r--src/platformsupport/linuxaccessibility/dbusconnection.cpp26
-rw-r--r--src/platformsupport/linuxaccessibility/dbusconnection_p.h1
-rw-r--r--src/platformsupport/linuxaccessibility/struct_marshallers_p.h32
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp69
33 files changed, 314 insertions, 1621 deletions
diff --git a/src/platformsupport/dbusmenu/qdbusmenutypes.cpp b/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
index 73957eacfe..94df0f53dd 100644
--- a/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
+++ b/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
@@ -208,6 +208,7 @@ QDBusMenuItemList QDBusMenuItem::items(const QList<int> &ids, const QStringList
Q_UNUSED(propertyNames)
QDBusMenuItemList ret;
QList<const QDBusPlatformMenuItem *> items = QDBusPlatformMenuItem::byIds(ids);
+ ret.reserve(items.size());
Q_FOREACH (const QDBusPlatformMenuItem *item, items)
ret << QDBusMenuItem(item);
return ret;
diff --git a/src/platformsupport/dbusmenu/qdbusmenutypes_p.h b/src/platformsupport/dbusmenu/qdbusmenutypes_p.h
index 28d16b32d5..8dae75281c 100644
--- a/src/platformsupport/dbusmenu/qdbusmenutypes_p.h
+++ b/src/platformsupport/dbusmenu/qdbusmenutypes_p.h
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
class QDBusPlatformMenu;
class QDBusPlatformMenuItem;
class QDBusMenuItem;
-typedef QList<QDBusMenuItem> QDBusMenuItemList;
+typedef QVector<QDBusMenuItem> QDBusMenuItemList;
class QDBusMenuItem
{
@@ -61,6 +61,7 @@ public:
int m_id;
QVariantMap m_properties;
};
+Q_DECLARE_TYPEINFO(QDBusMenuItem, Q_MOVABLE_TYPE);
const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuItem &item);
const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuItem &item);
@@ -72,11 +73,12 @@ public:
int id;
QStringList properties;
};
+Q_DECLARE_TYPEINFO(QDBusMenuItemKeys, Q_MOVABLE_TYPE);
const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuItemKeys &keys);
const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuItemKeys &keys);
-typedef QList<QDBusMenuItemKeys> QDBusMenuItemKeysList;
+typedef QVector<QDBusMenuItemKeys> QDBusMenuItemKeysList;
class QDBusMenuLayoutItem
{
@@ -87,13 +89,14 @@ public:
int m_id;
QVariantMap m_properties;
- QList<QDBusMenuLayoutItem> m_children;
+ QVector<QDBusMenuLayoutItem> m_children;
};
+Q_DECLARE_TYPEINFO(QDBusMenuLayoutItem, Q_MOVABLE_TYPE);
const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuLayoutItem &);
const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuLayoutItem &item);
-typedef QList<QDBusMenuLayoutItem> QDBusMenuLayoutItemList;
+typedef QVector<QDBusMenuLayoutItem> QDBusMenuLayoutItemList;
class QDBusMenuEvent
{
@@ -103,11 +106,13 @@ public:
QDBusVariant m_data;
uint m_timestamp;
};
+Q_DECLARE_TYPEINFO(QDBusMenuEvent, Q_MOVABLE_TYPE); // QDBusVariant is movable, even though it cannot
+ // be marked as such until Qt 6.
const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuEvent &ev);
const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuEvent &ev);
-typedef QList<QDBusMenuEvent> QDBusMenuEventList;
+typedef QVector<QDBusMenuEvent> QDBusMenuEventList;
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug d, const QDBusMenuItem &item);
diff --git a/src/platformsupport/dbustray/qdbustraytypes.cpp b/src/platformsupport/dbustray/qdbustraytypes.cpp
index 7b7d31b7c3..83b5d5da3f 100644
--- a/src/platformsupport/dbustray/qdbustraytypes.cpp
+++ b/src/platformsupport/dbustray/qdbustraytypes.cpp
@@ -82,6 +82,8 @@ QXdgDBusImageVector iconToQXdgDBusImageVector(const QIcon &icon)
sizes.append(QSize(IconNormalSmallSize * dpr, IconNormalSmallSize * dpr));
if (!hasMediumIcon)
sizes.append(QSize(IconNormalMediumSize * dpr, IconNormalMediumSize * dpr));
+
+ ret.reserve(sizes.size());
foreach (QSize size, sizes) {
// Protocol specifies ARGB32 format in network byte order
QImage im = icon.pixmap(size).toImage().convertToFormat(QImage::Format_ARGB32);
diff --git a/src/platformsupport/dbustray/qdbustraytypes_p.h b/src/platformsupport/dbustray/qdbustraytypes_p.h
index 4e7ae70a96..e6f200362f 100644
--- a/src/platformsupport/dbustray/qdbustraytypes_p.h
+++ b/src/platformsupport/dbustray/qdbustraytypes_p.h
@@ -56,6 +56,7 @@ struct QXdgDBusImageStruct
int height;
QByteArray data;
};
+Q_DECLARE_TYPEINFO(QXdgDBusImageStruct, Q_MOVABLE_TYPE);
typedef QVector<QXdgDBusImageStruct> QXdgDBusImageVector;
@@ -69,6 +70,7 @@ struct QXdgDBusToolTipStruct
QString title;
QString subTitle;
};
+Q_DECLARE_TYPEINFO(QXdgDBusToolTipStruct, Q_MOVABLE_TYPE);
const QDBusArgument &operator<<(QDBusArgument &argument, const QXdgDBusImageStruct &icon);
const QDBusArgument &operator>>(const QDBusArgument &argument, QXdgDBusImageStruct &icon);
diff --git a/src/platformsupport/eglconvenience/eglconvenience.pri b/src/platformsupport/eglconvenience/eglconvenience.pri
index d102203d5e..457efd68fb 100644
--- a/src/platformsupport/eglconvenience/eglconvenience.pri
+++ b/src/platformsupport/eglconvenience/eglconvenience.pri
@@ -1,29 +1,16 @@
contains(QT_CONFIG,egl) {
HEADERS += \
- $$PWD/qeglconvenience_p.h \
- $$PWD/qeglpbuffer_p.h
+ $$PWD/qeglconvenience_p.h
SOURCES += \
- $$PWD/qeglconvenience.cpp \
- $$PWD/qeglpbuffer.cpp
+ $$PWD/qeglconvenience.cpp
contains(QT_CONFIG,opengl) {
- HEADERS += $$PWD/qeglplatformcontext_p.h
- SOURCES += $$PWD/qeglplatformcontext.cpp
+ HEADERS += $$PWD/qeglplatformcontext_p.h \
+ $$PWD/qeglpbuffer_p.h
- unix {
- HEADERS += \
- $$PWD/qeglplatformcursor_p.h \
- $$PWD/qeglplatformwindow_p.h \
- $$PWD/qeglplatformscreen_p.h \
- $$PWD/qeglplatformintegration_p.h
-
- SOURCES += \
- $$PWD/qeglplatformcursor.cpp \
- $$PWD/qeglplatformwindow.cpp \
- $$PWD/qeglplatformscreen.cpp \
- $$PWD/qeglplatformintegration.cpp
- }
+ SOURCES += $$PWD/qeglplatformcontext.cpp \
+ $$PWD/qeglpbuffer.cpp
}
# Avoid X11 header collision
diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
index 5bee29afef..905f7695bb 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
@@ -154,6 +154,7 @@ void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLCont
}
}
contextAttrs.append(EGL_NONE);
+ m_contextAttrs = contextAttrs;
switch (m_format.renderableType()) {
case QSurfaceFormat::OpenVG:
@@ -244,6 +245,8 @@ void QEGLPlatformContext::initialize()
updateFormatFromGL();
}
+// Base implementation for pbuffers. Subclasses will handle the specialized cases for
+// platforms without pbuffers.
EGLSurface QEGLPlatformContext::createTemporaryOffscreenSurface()
{
// Make the context current to ensure the GL version query works. This needs a surface too.
@@ -283,10 +286,18 @@ void QEGLPlatformContext::updateFormatFromGL()
// avoid creating an extra pbuffer surface which is apparently troublesome with some
// drivers (Mesa) when certain attributes are present (multisampling).
EGLSurface tempSurface = EGL_NO_SURFACE;
+ EGLContext tempContext = EGL_NO_CONTEXT;
if (!q_hasEglExtension(m_eglDisplay, "EGL_KHR_surfaceless_context"))
tempSurface = createTemporaryOffscreenSurface();
- if (eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, m_eglContext)) {
+ EGLBoolean ok = eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, m_eglContext);
+ if (!ok) {
+ EGLConfig config = q_configFromGLFormat(m_eglDisplay, m_format, false, EGL_PBUFFER_BIT);
+ tempContext = eglCreateContext(m_eglDisplay, config, 0, m_contextAttrs.constData());
+ if (tempContext != EGL_NO_CONTEXT)
+ ok = eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, tempContext);
+ }
+ if (ok) {
if (m_format.renderableType() == QSurfaceFormat::OpenGL
|| m_format.renderableType() == QSurfaceFormat::OpenGLES) {
const GLubyte *s = glGetString(GL_VERSION);
@@ -324,10 +335,12 @@ void QEGLPlatformContext::updateFormatFromGL()
}
eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext);
} else {
- qWarning("QEGLPlatformContext: Failed to make temporary surface current, format not updated");
+ qWarning("QEGLPlatformContext: Failed to make temporary surface current, format not updated (%x)", eglGetError());
}
if (tempSurface != EGL_NO_SURFACE)
destroyTemporaryOffscreenSurface(tempSurface);
+ if (tempContext != EGL_NO_CONTEXT)
+ eglDestroyContext(m_eglDisplay, tempContext);
#endif // QT_NO_OPENGL
}
diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h
index 50c264e1dc..2ab7ad28d0 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h
+++ b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h
@@ -94,6 +94,7 @@ private:
bool m_swapIntervalEnvChecked;
int m_swapIntervalFromEnv;
bool m_ownsContext;
+ QVector<EGLint> m_contextAttrs;
};
QT_END_NAMESPACE
diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
deleted file mode 100644
index 09243487c7..0000000000
--- a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
+++ /dev/null
@@ -1,410 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qpa/qwindowsysteminterface.h>
-#include <QtGui/QOpenGLContext>
-#include <QtGui/QOpenGLShaderProgram>
-#include <QtCore/QJsonDocument>
-#include <QtCore/QJsonArray>
-#include <QtCore/QJsonObject>
-#include <QtDebug>
-
-#include <QtGui/private/qguiapplication_p.h>
-
-#include "qeglplatformcursor_p.h"
-#include "qeglplatformintegration_p.h"
-#include "qeglplatformscreen_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QEGLPlatformCursor
- \brief Mouse cursor implementation using OpenGL.
- \since 5.2
- \internal
- \ingroup qpa
- */
-
-QEGLPlatformCursor::QEGLPlatformCursor(QPlatformScreen *screen)
- : m_visible(true),
- m_screen(static_cast<QEGLPlatformScreen *>(screen)),
- m_program(0),
- m_vertexCoordEntry(0),
- m_textureCoordEntry(0),
- m_textureEntry(0),
- m_deviceListener(0),
- m_updateRequested(false)
-{
- QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR");
- if (!hideCursorVal.isEmpty())
- m_visible = hideCursorVal.toInt() == 0;
- if (!m_visible)
- return;
-
- // Try to load the cursor atlas. If this fails, m_visible is set to false and
- // paintOnScreen() and setCurrentCursor() become no-ops.
- initCursorAtlas();
-
- // initialize the cursor
-#ifndef QT_NO_CURSOR
- QCursor cursor(Qt::ArrowCursor);
- setCurrentCursor(&cursor);
-#endif
-
- m_deviceListener = new QEGLPlatformCursorDeviceListener(this);
- connect(QGuiApplicationPrivate::inputDeviceManager(), &QInputDeviceManager::deviceListChanged,
- m_deviceListener, &QEGLPlatformCursorDeviceListener::onDeviceListChanged);
- updateMouseStatus();
-}
-
-QEGLPlatformCursor::~QEGLPlatformCursor()
-{
- resetResources();
- delete m_deviceListener;
-}
-
-void QEGLPlatformCursor::updateMouseStatus()
-{
- m_visible = m_deviceListener->hasMouse();
-}
-
-bool QEGLPlatformCursorDeviceListener::hasMouse() const
-{
- return QGuiApplicationPrivate::inputDeviceManager()->deviceCount(QInputDeviceManager::DeviceTypePointer) > 0;
-}
-
-void QEGLPlatformCursorDeviceListener::onDeviceListChanged(QInputDeviceManager::DeviceType type)
-{
- if (type == QInputDeviceManager::DeviceTypePointer)
- m_cursor->updateMouseStatus();
-}
-
-void QEGLPlatformCursor::resetResources()
-{
- if (QOpenGLContext::currentContext()) {
- delete m_program;
- glDeleteTextures(1, &m_cursor.customCursorTexture);
- glDeleteTextures(1, &m_cursorAtlas.texture);
- }
- m_program = 0;
- m_cursor.customCursorTexture = 0;
- m_cursor.customCursorPending = !m_cursor.customCursorImage.isNull();
- m_cursorAtlas.texture = 0;
-}
-
-void QEGLPlatformCursor::createShaderPrograms()
-{
- static const char *textureVertexProgram =
- "attribute highp vec2 vertexCoordEntry;\n"
- "attribute highp vec2 textureCoordEntry;\n"
- "varying highp vec2 textureCoord;\n"
- "void main() {\n"
- " textureCoord = textureCoordEntry;\n"
- " gl_Position = vec4(vertexCoordEntry, 1.0, 1.0);\n"
- "}\n";
-
- static const char *textureFragmentProgram =
- "uniform sampler2D texture;\n"
- "varying highp vec2 textureCoord;\n"
- "void main() {\n"
- " gl_FragColor = texture2D(texture, textureCoord).bgra;\n"
- "}\n";
-
- m_program = new QOpenGLShaderProgram;
- m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, textureVertexProgram);
- m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, textureFragmentProgram);
- m_program->link();
-
- m_vertexCoordEntry = m_program->attributeLocation("vertexCoordEntry");
- m_textureCoordEntry = m_program->attributeLocation("textureCoordEntry");
- m_textureEntry = m_program->uniformLocation("texture");
-}
-
-void QEGLPlatformCursor::createCursorTexture(uint *texture, const QImage &image)
-{
- if (!*texture)
- glGenTextures(1, texture);
- glBindTexture(GL_TEXTURE_2D, *texture);
- 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);
-
- glTexImage2D(GL_TEXTURE_2D, 0 /* level */, GL_RGBA, image.width(), image.height(), 0 /* border */,
- GL_RGBA, GL_UNSIGNED_BYTE, image.constBits());
-}
-
-void QEGLPlatformCursor::initCursorAtlas()
-{
- static QByteArray json = qgetenv("QT_QPA_EGLFS_CURSOR");
- if (json.isEmpty())
- json = ":/cursor.json";
-
- QFile file(QString::fromUtf8(json));
- if (!file.open(QFile::ReadOnly)) {
- m_visible = false;
- return;
- }
-
- QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
- QJsonObject object = doc.object();
-
- QString atlas = object.value(QLatin1String("image")).toString();
- Q_ASSERT(!atlas.isEmpty());
-
- const int cursorsPerRow = object.value(QLatin1String("cursorsPerRow")).toDouble();
- Q_ASSERT(cursorsPerRow);
- m_cursorAtlas.cursorsPerRow = cursorsPerRow;
-
- const QJsonArray hotSpots = object.value(QLatin1String("hotSpots")).toArray();
- Q_ASSERT(hotSpots.count() == Qt::LastCursor + 1);
- for (int i = 0; i < hotSpots.count(); i++) {
- QPoint hotSpot(hotSpots[i].toArray()[0].toDouble(), hotSpots[i].toArray()[1].toDouble());
- m_cursorAtlas.hotSpots << hotSpot;
- }
-
- QImage image = QImage(atlas).convertToFormat(QImage::Format_ARGB32_Premultiplied);
- m_cursorAtlas.cursorWidth = image.width() / m_cursorAtlas.cursorsPerRow;
- m_cursorAtlas.cursorHeight = image.height() / ((Qt::LastCursor + cursorsPerRow) / cursorsPerRow);
- m_cursorAtlas.width = image.width();
- m_cursorAtlas.height = image.height();
- m_cursorAtlas.image = image;
-}
-
-#ifndef QT_NO_CURSOR
-void QEGLPlatformCursor::changeCursor(QCursor *cursor, QWindow *window)
-{
- Q_UNUSED(window);
- const QRect oldCursorRect = cursorRect();
- if (setCurrentCursor(cursor))
- update(oldCursorRect | cursorRect());
-}
-
-bool QEGLPlatformCursor::setCurrentCursor(QCursor *cursor)
-{
- if (!m_visible)
- return false;
-
- const Qt::CursorShape newShape = cursor ? cursor->shape() : Qt::ArrowCursor;
- if (m_cursor.shape == newShape && newShape != Qt::BitmapCursor)
- return false;
-
- if (m_cursor.shape == Qt::BitmapCursor) {
- m_cursor.customCursorImage = QImage();
- m_cursor.customCursorPending = false;
- }
- m_cursor.shape = newShape;
- if (newShape != Qt::BitmapCursor) { // standard cursor
- const float ws = (float)m_cursorAtlas.cursorWidth / m_cursorAtlas.width,
- hs = (float)m_cursorAtlas.cursorHeight / m_cursorAtlas.height;
- m_cursor.textureRect = QRectF(ws * (m_cursor.shape % m_cursorAtlas.cursorsPerRow),
- hs * (m_cursor.shape / m_cursorAtlas.cursorsPerRow),
- ws, hs);
- m_cursor.hotSpot = m_cursorAtlas.hotSpots[m_cursor.shape];
- m_cursor.texture = m_cursorAtlas.texture;
- m_cursor.size = QSize(m_cursorAtlas.cursorWidth, m_cursorAtlas.cursorHeight);
- } else {
- QImage image = cursor->pixmap().toImage();
- m_cursor.textureRect = QRectF(0, 0, 1, 1);
- m_cursor.hotSpot = cursor->hotSpot();
- m_cursor.texture = 0; // will get updated in the next render()
- m_cursor.size = image.size();
- m_cursor.customCursorImage = image;
- m_cursor.customCursorPending = true;
- }
-
- return true;
-}
-#endif
-
-class CursorUpdateEvent : public QEvent
-{
-public:
- CursorUpdateEvent(const QPoint &pos, const QRegion &rgn)
- : QEvent(QEvent::Type(QEvent::User + 1)),
- m_pos(pos),
- m_region(rgn)
- { }
- QPoint pos() const { return m_pos; }
- QRegion region() const { return m_region; }
-
-private:
- QPoint m_pos;
- QRegion m_region;
-};
-
-bool QEGLPlatformCursor::event(QEvent *e)
-{
- if (e->type() == QEvent::User + 1) {
- CursorUpdateEvent *ev = static_cast<CursorUpdateEvent *>(e);
- m_updateRequested = false;
- QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(ev->pos()), ev->region());
- QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
- return true;
- }
- return QPlatformCursor::event(e);
-}
-
-void QEGLPlatformCursor::update(const QRegion &rgn)
-{
- if (!m_updateRequested) {
- // Must not flush the window system events directly from here since we are likely to
- // be a called directly from QGuiApplication's processMouseEvents. Flushing events
- // could cause reentering by dispatching more queued mouse events.
- m_updateRequested = true;
- QCoreApplication::postEvent(this, new CursorUpdateEvent(m_cursor.pos, rgn));
- }
-}
-
-QRect QEGLPlatformCursor::cursorRect() const
-{
- return QRect(m_cursor.pos - m_cursor.hotSpot, m_cursor.size);
-}
-
-QPoint QEGLPlatformCursor::pos() const
-{
- return m_cursor.pos;
-}
-
-void QEGLPlatformCursor::setPos(const QPoint &pos)
-{
- QGuiApplicationPrivate::inputDeviceManager()->setCursorPos(pos);
- const QRect oldCursorRect = cursorRect();
- m_cursor.pos = pos;
- update(oldCursorRect | cursorRect());
- m_screen->handleCursorMove(m_cursor.pos);
-}
-
-void QEGLPlatformCursor::pointerEvent(const QMouseEvent &event)
-{
- if (event.type() != QEvent::MouseMove)
- return;
- const QRect oldCursorRect = cursorRect();
- m_cursor.pos = event.screenPos().toPoint();
- update(oldCursorRect | cursorRect());
- m_screen->handleCursorMove(m_cursor.pos);
-}
-
-void QEGLPlatformCursor::paintOnScreen()
-{
- if (!m_visible)
- return;
-
- const QRectF cr = cursorRect();
- const QRect screenRect(m_screen->geometry());
- const GLfloat x1 = 2 * (cr.left() / screenRect.width()) - 1;
- const GLfloat x2 = 2 * (cr.right() / screenRect.width()) - 1;
- const GLfloat y1 = 1 - (cr.top() / screenRect.height()) * 2;
- const GLfloat y2 = 1 - (cr.bottom() / screenRect.height()) * 2;
- QRectF r(QPointF(x1, y1), QPointF(x2, y2));
-
- draw(r);
-}
-
-void QEGLPlatformCursor::draw(const QRectF &r)
-{
- if (!m_program) {
- // one time initialization
- initializeOpenGLFunctions();
-
- createShaderPrograms();
-
- if (!m_cursorAtlas.texture) {
- createCursorTexture(&m_cursorAtlas.texture, m_cursorAtlas.image);
-
- if (m_cursor.shape != Qt::BitmapCursor)
- m_cursor.texture = m_cursorAtlas.texture;
- }
- }
-
- if (m_cursor.shape == Qt::BitmapCursor && m_cursor.customCursorPending) {
- // upload the custom cursor
- createCursorTexture(&m_cursor.customCursorTexture, m_cursor.customCursorImage);
- m_cursor.texture = m_cursor.customCursorTexture;
- m_cursor.customCursorPending = false;
- }
-
- Q_ASSERT(m_cursor.texture);
-
- m_program->bind();
-
- const GLfloat x1 = r.left();
- const GLfloat x2 = r.right();
- const GLfloat y1 = r.top();
- const GLfloat y2 = r.bottom();
- const GLfloat cursorCoordinates[] = {
- x1, y2,
- x2, y2,
- x1, y1,
- x2, y1
- };
-
- const GLfloat s1 = m_cursor.textureRect.left();
- const GLfloat s2 = m_cursor.textureRect.right();
- const GLfloat t1 = m_cursor.textureRect.top();
- const GLfloat t2 = m_cursor.textureRect.bottom();
- const GLfloat textureCoordinates[] = {
- s1, t2,
- s2, t2,
- s1, t1,
- s2, t1
- };
-
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, m_cursor.texture);
- glBindBuffer(GL_ARRAY_BUFFER, 0);
-
- m_program->enableAttributeArray(m_vertexCoordEntry);
- m_program->enableAttributeArray(m_textureCoordEntry);
-
- m_program->setAttributeArray(m_vertexCoordEntry, cursorCoordinates, 2);
- m_program->setAttributeArray(m_textureCoordEntry, textureCoordinates, 2);
-
- m_program->setUniformValue(m_textureEntry, 0);
-
- glDisable(GL_CULL_FACE);
- glFrontFace(GL_CCW);
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_DEPTH_TEST); // disable depth testing to make sure cursor is always on top
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- glDisable(GL_BLEND);
-
- glBindTexture(GL_TEXTURE_2D, 0);
- m_program->disableAttributeArray(m_textureCoordEntry);
- m_program->disableAttributeArray(m_vertexCoordEntry);
-
- m_program->release();
-}
-
-QT_END_NAMESPACE
diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
deleted file mode 100644
index b89dd1ca43..0000000000
--- a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QEGLPLATFORMCURSOR_H
-#define QEGLPLATFORMCURSOR_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qpa/qplatformcursor.h>
-#include <qpa/qplatformscreen.h>
-#include <QtGui/QOpenGLFunctions>
-#include <QtGui/private/qinputdevicemanager_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLShaderProgram;
-class QEGLPlatformCursor;
-class QEGLPlatformScreen;
-
-class QEGLPlatformCursorDeviceListener : public QObject
-{
- Q_OBJECT
-
-public:
- QEGLPlatformCursorDeviceListener(QEGLPlatformCursor *cursor) : m_cursor(cursor) { }
- bool hasMouse() const;
-
-public slots:
- void onDeviceListChanged(QInputDeviceManager::DeviceType type);
-
-private:
- QEGLPlatformCursor *m_cursor;
-};
-
-class QEGLPlatformCursor : public QPlatformCursor, protected QOpenGLFunctions
-{
- Q_OBJECT
-public:
- QEGLPlatformCursor(QPlatformScreen *screen);
- ~QEGLPlatformCursor();
-
-#ifndef QT_NO_CURSOR
- void changeCursor(QCursor *cursor, QWindow *widget) Q_DECL_OVERRIDE;
-#endif
- void pointerEvent(const QMouseEvent &event) Q_DECL_OVERRIDE;
- QPoint pos() const Q_DECL_OVERRIDE;
- void setPos(const QPoint &pos) Q_DECL_OVERRIDE;
-
- QRect cursorRect() const;
- void paintOnScreen();
- void resetResources();
-
- void updateMouseStatus();
-
-private:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
-#ifndef QT_NO_CURSOR
- bool setCurrentCursor(QCursor *cursor);
-#endif
- void draw(const QRectF &rect);
- void update(const QRegion &region);
- void createShaderPrograms();
- void createCursorTexture(uint *texture, const QImage &image);
- void initCursorAtlas();
-
- // current cursor information
- struct Cursor {
- Cursor() : texture(0), shape(Qt::BlankCursor), customCursorTexture(0), customCursorPending(false) { }
- uint texture; // a texture from 'image' or the atlas
- Qt::CursorShape shape;
- QRectF textureRect; // normalized rect inside texture
- QSize size; // size of the cursor
- QPoint hotSpot;
- QImage customCursorImage;
- QPoint pos; // current cursor position
- uint customCursorTexture;
- bool customCursorPending;
- } m_cursor;
-
- // cursor atlas information
- struct CursorAtlas {
- CursorAtlas() : cursorsPerRow(0), texture(0), cursorWidth(0), cursorHeight(0) { }
- int cursorsPerRow;
- uint texture;
- int width, height; // width and height of the atlas
- int cursorWidth, cursorHeight; // width and height of cursors inside the atlas
- QList<QPoint> hotSpots;
- QImage image; // valid until it's uploaded
- } m_cursorAtlas;
-
- bool m_visible;
- QEGLPlatformScreen *m_screen;
- QOpenGLShaderProgram *m_program;
- int m_vertexCoordEntry;
- int m_textureCoordEntry;
- int m_textureEntry;
- QEGLPlatformCursorDeviceListener *m_deviceListener;
- bool m_updateRequested;
-};
-
-QT_END_NAMESPACE
-
-#endif // QEGLPLATFORMCURSOR_H
diff --git a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp
deleted file mode 100644
index 1868ff1665..0000000000
--- a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp
+++ /dev/null
@@ -1,366 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui/QWindow>
-#include <QtGui/QOpenGLContext>
-#include <QtGui/QOffscreenSurface>
-#include <QtGui/QGuiApplication>
-#include <QtGui/private/qguiapplication_p.h>
-#include <qpa/qwindowsysteminterface.h>
-#include <qpa/qplatforminputcontextfactory_p.h>
-
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
-#include <QtPlatformSupport/private/qgenericunixservices_p.h>
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
-#include <QtPlatformSupport/private/qfbvthandler_p.h>
-#include <QtPlatformSupport/private/qopenglcompositorbackingstore_p.h>
-
-#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
-#include <QtPlatformSupport/private/qevdevmousemanager_p.h>
-#include <QtPlatformSupport/private/qevdevkeyboardmanager_p.h>
-#include <QtPlatformSupport/private/qevdevtouchmanager_p.h>
-#endif
-
-#if !defined(QT_NO_TSLIB) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
-#include <QtPlatformSupport/private/qtslib_p.h>
-#endif
-
-#include <QtPlatformHeaders/qeglfsfunctions.h>
-
-#include "qeglplatformintegration_p.h"
-#include "qeglplatformcontext_p.h"
-#include "qeglplatformwindow_p.h"
-#include "qeglplatformscreen_p.h"
-#include "qeglplatformcursor_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QEGLPlatformIntegration
- \brief Base class for EGL-based QPlatformIntegration implementations.
- \since 5.2
- \internal
- \ingroup qpa
-
- This class provides most of the necessary platform integration for
- an EGL-based Unix system. Platform plugins must subclass this and
- reimplement the virtuals for creating platform screens and windows
- since they will most likely wish to use a subclass for these.
-
- The backing store, native interface accessors, font database,
- basic capability flags, etc. are provided out of the box, no
- further customization is needed.
-
- \note It is critical that this class' implementation of
- initialize() is called. Therefore subclasses should either avoid
- to reimplement this function or call the base class
- implementation.
- */
-
-QEGLPlatformIntegration::QEGLPlatformIntegration()
- : m_display(EGL_NO_DISPLAY),
- m_inputContext(0),
- m_fontDb(new QGenericUnixFontDatabase),
- m_services(new QGenericUnixServices),
- m_kbdMgr(0)
-{
-}
-
-QEGLPlatformIntegration::~QEGLPlatformIntegration()
-{
-}
-
-void QEGLPlatformIntegration::initialize()
-{
- m_display = eglGetDisplay(nativeDisplay());
- if (m_display == EGL_NO_DISPLAY)
- qFatal("Could not open egl display");
-
- EGLint major, minor;
- if (!eglInitialize(m_display, &major, &minor))
- qFatal("Could not initialize egl display");
-
- m_inputContext = QPlatformInputContextFactory::create();
-
- m_vtHandler.reset(new QFbVtHandler);
-}
-
-void QEGLPlatformIntegration::destroy()
-{
- foreach (QWindow *w, qGuiApp->topLevelWindows())
- w->destroy();
-
- if (m_display != EGL_NO_DISPLAY)
- eglTerminate(m_display);
-}
-
-QAbstractEventDispatcher *QEGLPlatformIntegration::createEventDispatcher() const
-{
- return createUnixEventDispatcher();
-}
-
-QPlatformServices *QEGLPlatformIntegration::services() const
-{
- return m_services.data();
-}
-
-QPlatformFontDatabase *QEGLPlatformIntegration::fontDatabase() const
-{
- return m_fontDb.data();
-}
-
-QPlatformBackingStore *QEGLPlatformIntegration::createPlatformBackingStore(QWindow *window) const
-{
- QOpenGLCompositorBackingStore *bs = new QOpenGLCompositorBackingStore(window);
- if (!window->handle())
- window->create();
- static_cast<QEGLPlatformWindow *>(window->handle())->setBackingStore(bs);
- return bs;
-}
-
-QPlatformWindow *QEGLPlatformIntegration::createPlatformWindow(QWindow *window) const
-{
- QWindowSystemInterface::flushWindowSystemEvents();
- QEGLPlatformWindow *w = createWindow(window);
- w->create();
- if (window->type() != Qt::ToolTip)
- w->requestActivateWindow();
- return w;
-}
-
-QPlatformOpenGLContext *QEGLPlatformIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
-{
- // If there is a "root" window into which raster and QOpenGLWidget content is
- // composited, all other contexts must share with its context.
- QOpenGLContext *compositingContext = QOpenGLCompositor::instance()->context();
- QPlatformOpenGLContext *share = compositingContext ? compositingContext->handle() : context->shareHandle();
- QVariant nativeHandle = context->nativeHandle();
- QPlatformOpenGLContext *platformContext = createContext(context->format(),
- share,
- display(),
- &nativeHandle);
- context->setNativeHandle(nativeHandle);
- return platformContext;
-}
-
-QPlatformOffscreenSurface *QEGLPlatformIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
-{
- QEGLPlatformScreen *screen = static_cast<QEGLPlatformScreen *>(surface->screen()->handle());
- return createOffscreenSurface(screen->display(), surface->requestedFormat(), surface);
-}
-
-bool QEGLPlatformIntegration::hasCapability(QPlatformIntegration::Capability cap) const
-{
- switch (cap) {
- case ThreadedPixmaps: return true;
- case OpenGL: return true;
- case ThreadedOpenGL: return true;
- case WindowManagement: return false;
- case RasterGLSurface: return true;
- default: return QPlatformIntegration::hasCapability(cap);
- }
-}
-
-QPlatformNativeInterface *QEGLPlatformIntegration::nativeInterface() const
-{
- return const_cast<QEGLPlatformIntegration *>(this);
-}
-
-enum ResourceType {
- EglDisplay,
- EglWindow,
- EglContext,
- EglConfig,
- NativeDisplay,
- XlibDisplay
-};
-
-static int resourceType(const QByteArray &key)
-{
- static const QByteArray names[] = { // match ResourceType
- QByteArrayLiteral("egldisplay"),
- QByteArrayLiteral("eglwindow"),
- QByteArrayLiteral("eglcontext"),
- QByteArrayLiteral("eglconfig"),
- QByteArrayLiteral("nativedisplay"),
- QByteArrayLiteral("display")
- };
- const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
- const QByteArray *result = std::find(names, end, key);
- if (result == end)
- result = std::find(names, end, key.toLower());
- return int(result - names);
-}
-
-void *QEGLPlatformIntegration::nativeResourceForIntegration(const QByteArray &resource)
-{
- void *result = 0;
-
- switch (resourceType(resource)) {
- case EglDisplay:
- result = display();
- break;
- case NativeDisplay:
- result = reinterpret_cast<void*>(nativeDisplay());
- break;
- default:
- break;
- }
-
- return result;
-}
-
-void *QEGLPlatformIntegration::nativeResourceForScreen(const QByteArray &resource, QScreen *)
-{
- void *result = 0;
-
- switch (resourceType(resource)) {
- case XlibDisplay:
- // Play nice when using the x11 hooks: Be compatible with xcb that allows querying
- // the X Display pointer, which is nothing but our native display.
- result = reinterpret_cast<void*>(nativeDisplay());
- break;
- default:
- break;
- }
-
- return result;
-}
-
-void *QEGLPlatformIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
-{
- void *result = 0;
-
- switch (resourceType(resource)) {
- case EglDisplay:
- if (window && window->handle())
- result = static_cast<QEGLPlatformScreen *>(window->handle()->screen())->display();
- else
- result = display();
- break;
- case EglWindow:
- if (window && window->handle())
- result = reinterpret_cast<void*>(static_cast<QEGLPlatformWindow *>(window->handle())->eglWindow());
- break;
- default:
- break;
- }
-
- return result;
-}
-
-void *QEGLPlatformIntegration::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)
-{
- void *result = 0;
-
- switch (resourceType(resource)) {
- case EglContext:
- if (context->handle())
- result = static_cast<QEGLPlatformContext *>(context->handle())->eglContext();
- break;
- case EglConfig:
- if (context->handle())
- result = static_cast<QEGLPlatformContext *>(context->handle())->eglConfig();
- break;
- case EglDisplay:
- if (context->handle())
- result = static_cast<QEGLPlatformContext *>(context->handle())->eglDisplay();
- break;
- default:
- break;
- }
-
- return result;
-}
-
-static void *eglContextForContext(QOpenGLContext *context)
-{
- Q_ASSERT(context);
-
- QEGLPlatformContext *handle = static_cast<QEGLPlatformContext *>(context->handle());
- if (!handle)
- return 0;
-
- return handle->eglContext();
-}
-
-QPlatformNativeInterface::NativeResourceForContextFunction QEGLPlatformIntegration::nativeResourceFunctionForContext(const QByteArray &resource)
-{
- QByteArray lowerCaseResource = resource.toLower();
- if (lowerCaseResource == "get_egl_context")
- return NativeResourceForContextFunction(eglContextForContext);
-
- return 0;
-}
-
-QFunctionPointer QEGLPlatformIntegration::platformFunction(const QByteArray &function) const
-{
-#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
- if (function == QEglFSFunctions::loadKeymapTypeIdentifier())
- return QFunctionPointer(loadKeymapStatic);
-#else
- Q_UNUSED(function)
-#endif
-
- return 0;
-}
-
-void QEGLPlatformIntegration::loadKeymapStatic(const QString &filename)
-{
-#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
- QEGLPlatformIntegration *self = static_cast<QEGLPlatformIntegration *>(QGuiApplicationPrivate::platformIntegration());
- if (self->m_kbdMgr)
- self->m_kbdMgr->loadKeymap(filename);
- else
- qWarning("QEGLPlatformIntegration: Cannot load keymap, no keyboard handler found");
-#else
- Q_UNUSED(filename);
-#endif
-}
-
-void QEGLPlatformIntegration::createInputHandlers()
-{
-#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
- m_kbdMgr = new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this);
- new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this);
-#ifndef QT_NO_TSLIB
- const bool useTslib = qEnvironmentVariableIntValue("QT_QPA_EGLFS_TSLIB");
- if (useTslib)
- new QTsLibMouseHandler(QLatin1String("TsLib"), QString() /* spec */);
- else
-#endif // QT_NO_TSLIB
- new QEvdevTouchManager(QLatin1String("EvdevTouch"), QString() /* spec */, this);
-#endif
-}
-
-QT_END_NAMESPACE
diff --git a/src/platformsupport/eglconvenience/qeglplatformintegration_p.h b/src/platformsupport/eglconvenience/qeglplatformintegration_p.h
deleted file mode 100644
index 42fbf8c8a1..0000000000
--- a/src/platformsupport/eglconvenience/qeglplatformintegration_p.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QEGLPLATFORMINTEGRATION_H
-#define QEGLPLATFORMINTEGRATION_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QVariant>
-#include <qpa/qplatformintegration.h>
-#include <qpa/qplatformnativeinterface.h>
-#include <EGL/egl.h>
-
-QT_BEGIN_NAMESPACE
-
-class QEGLPlatformWindow;
-class QEGLPlatformContext;
-class QFbVtHandler;
-class QEvdevKeyboardManager;
-
-class QEGLPlatformIntegration : public QPlatformIntegration, public QPlatformNativeInterface
-{
-public:
- QEGLPlatformIntegration();
- ~QEGLPlatformIntegration();
-
- void initialize() Q_DECL_OVERRIDE;
- void destroy() Q_DECL_OVERRIDE;
-
- EGLDisplay display() const { return m_display; }
-
- QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
- QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
- QPlatformServices *services() const Q_DECL_OVERRIDE;
- QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE { return m_inputContext; }
-
- QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE;
- QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
- QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE;
- QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE;
-
- bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
-
- QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE;
- // QPlatformNativeInterface
- void *nativeResourceForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
- void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) Q_DECL_OVERRIDE;
- void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) Q_DECL_OVERRIDE;
- void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) Q_DECL_OVERRIDE;
- NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) Q_DECL_OVERRIDE;
-
- QFunctionPointer platformFunction(const QByteArray &function) const Q_DECL_OVERRIDE;
-
- QFbVtHandler *vtHandler() { return m_vtHandler.data(); }
-
-protected:
- virtual QEGLPlatformWindow *createWindow(QWindow *window) const = 0;
- virtual QEGLPlatformContext *createContext(const QSurfaceFormat &format,
- QPlatformOpenGLContext *shareContext,
- EGLDisplay display,
- QVariant *nativeHandle) const = 0;
- virtual QPlatformOffscreenSurface *createOffscreenSurface(EGLDisplay display,
- const QSurfaceFormat &format,
- QOffscreenSurface *surface) const = 0;
-
- virtual EGLNativeDisplayType nativeDisplay() const { return EGL_DEFAULT_DISPLAY; }
-
- void createInputHandlers();
-
-private:
- static void loadKeymapStatic(const QString &filename);
-
- EGLDisplay m_display;
- QPlatformInputContext *m_inputContext;
- QScopedPointer<QPlatformFontDatabase> m_fontDb;
- QScopedPointer<QPlatformServices> m_services;
- QScopedPointer<QFbVtHandler> m_vtHandler;
- QEvdevKeyboardManager *m_kbdMgr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QEGLPLATFORMINTEGRATION_H
diff --git a/src/platformsupport/eglconvenience/qeglplatformscreen.cpp b/src/platformsupport/eglconvenience/qeglplatformscreen.cpp
deleted file mode 100644
index 61f8cdd9b4..0000000000
--- a/src/platformsupport/eglconvenience/qeglplatformscreen.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qeglplatformscreen_p.h"
-#include "qeglplatformwindow_p.h"
-#include <QtGui/qwindow.h>
-#include <qpa/qwindowsysteminterface.h>
-#include <QtPlatformSupport/private/qopenglcompositor_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QEGLPlatformScreen
- \brief Base class for EGL-based platform screen implementations.
- \since 5.2
- \internal
- \ingroup qpa
- */
-
-QEGLPlatformScreen::QEGLPlatformScreen(EGLDisplay dpy)
- : m_dpy(dpy),
- m_pointerWindow(0)
-{
-}
-
-QEGLPlatformScreen::~QEGLPlatformScreen()
-{
- QOpenGLCompositor::destroy();
-}
-
-void QEGLPlatformScreen::handleCursorMove(const QPoint &pos)
-{
- const QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
- const QList<QOpenGLCompositorWindow *> windows = compositor->windows();
-
- // Generate enter and leave events like a real windowing system would do.
- if (windows.isEmpty())
- return;
-
- // First window is always fullscreen.
- if (windows.count() == 1) {
- QWindow *window = windows[0]->sourceWindow();
- if (m_pointerWindow != window) {
- m_pointerWindow = window;
- QWindowSystemInterface::handleEnterEvent(window, window->mapFromGlobal(pos), pos);
- }
- return;
- }
-
- QWindow *enter = 0, *leave = 0;
- for (int i = windows.count() - 1; i >= 0; --i) {
- QWindow *window = windows[i]->sourceWindow();
- const QRect geom = window->geometry();
- if (geom.contains(pos)) {
- if (m_pointerWindow != window) {
- leave = m_pointerWindow;
- m_pointerWindow = window;
- enter = window;
- }
- break;
- }
- }
-
- if (enter && leave)
- QWindowSystemInterface::handleEnterLeaveEvent(enter, leave, enter->mapFromGlobal(pos), pos);
-}
-
-QPixmap QEGLPlatformScreen::grabWindow(WId wid, int x, int y, int width, int height) const
-{
- QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
- const QList<QOpenGLCompositorWindow *> windows = compositor->windows();
- Q_ASSERT(!windows.isEmpty());
-
- QImage img;
-
- if (static_cast<QEGLPlatformWindow *>(windows.first()->sourceWindow()->handle())->isRaster()) {
- // Request the compositor to render everything into an FBO and read it back. This
- // is of course slow, but it's safe and reliable. It will not include the mouse
- // cursor, which is a plus.
- img = compositor->grab();
- } else {
- // Just a single OpenGL window without compositing. Do not support this case for now. Doing
- // glReadPixels is not an option since it would read from the back buffer which may have
- // undefined content when calling right after a swapBuffers (unless preserved swap is
- // available and enabled, but we have no support for that).
- qWarning("grabWindow: Not supported for non-composited OpenGL content. Use QQuickWindow::grabWindow() instead.");
- return QPixmap();
- }
-
- if (!wid) {
- const QSize screenSize = geometry().size();
- if (width < 0)
- width = screenSize.width() - x;
- if (height < 0)
- height = screenSize.height() - y;
- return QPixmap::fromImage(img).copy(x, y, width, height);
- }
-
- foreach (QOpenGLCompositorWindow *w, windows) {
- const QWindow *window = w->sourceWindow();
- if (window->winId() == wid) {
- const QRect geom = window->geometry();
- if (width < 0)
- width = geom.width() - x;
- if (height < 0)
- height = geom.height() - y;
- QRect rect(geom.topLeft() + QPoint(x, y), QSize(width, height));
- rect &= window->geometry();
- return QPixmap::fromImage(img).copy(rect);
- }
- }
-
- return QPixmap();
-}
-
-QT_END_NAMESPACE
diff --git a/src/platformsupport/eglconvenience/qeglplatformscreen_p.h b/src/platformsupport/eglconvenience/qeglplatformscreen_p.h
deleted file mode 100644
index 4a987f6860..0000000000
--- a/src/platformsupport/eglconvenience/qeglplatformscreen_p.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QEGLPLATFORMSCREEN_H
-#define QEGLPLATFORMSCREEN_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QList>
-#include <QtCore/QPoint>
-#include <QtCore/qtextstream.h>
-#include <qpa/qplatformscreen.h>
-#include <EGL/egl.h>
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLContext;
-class QWindow;
-class QEGLPlatformWindow;
-
-class QEGLPlatformScreen : public QPlatformScreen
-{
-public:
- QEGLPlatformScreen(EGLDisplay dpy);
- ~QEGLPlatformScreen();
-
- EGLDisplay display() const { return m_dpy; }
-
- void handleCursorMove(const QPoint &pos);
-
- QPixmap grabWindow(WId wid, int x, int y, int width, int height) const Q_DECL_OVERRIDE;
-
-private:
- EGLDisplay m_dpy;
- QWindow *m_pointerWindow;
-};
-
-QT_END_NAMESPACE
-
-#endif // QEGLPLATFORMSCREEN_H
diff --git a/src/platformsupport/eglconvenience/qeglplatformwindow.cpp b/src/platformsupport/eglconvenience/qeglplatformwindow.cpp
deleted file mode 100644
index 35f38ac29a..0000000000
--- a/src/platformsupport/eglconvenience/qeglplatformwindow.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qpa/qwindowsysteminterface.h>
-#include <QtPlatformSupport/private/qopenglcompositor_p.h>
-#include <QtPlatformSupport/private/qopenglcompositorbackingstore_p.h>
-
-#include "qeglplatformwindow_p.h"
-#include "qeglplatformscreen_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QEGLPlatformWindow
- \brief Base class for EGL-based platform window implementations.
- \since 5.2
- \internal
- \ingroup qpa
-
- Lightweight class providing some basic platform window operations
- and interfacing with QOpenGLCompositorBackingStore.
-
- Almost no QPlatformWindow functions are implemented here. This is
- intentional because different platform plugins may use different
- strategies for their window management (some may force fullscreen
- windows, some may not, some may share the underlying native
- surface, some may not, etc.) and therefore it is not sensible to
- enforce anything for these functions.
-
- \note Subclasses are responsible for invoking this class'
- implementation of create() and are expected to utilize the window
- stack management functions (addWindow() etc.) in
- QOpenGLCompositor.
- */
-
-QEGLPlatformWindow::QEGLPlatformWindow(QWindow *w)
- : QPlatformWindow(w),
- m_backingStore(0),
- m_raster(false),
- m_winId(0)
-{
-}
-
-static WId newWId()
-{
- static WId id = 0;
-
- if (id == std::numeric_limits<WId>::max())
- qWarning("QEGLPlatformWindow: Out of window IDs");
-
- return ++id;
-}
-
-void QEGLPlatformWindow::create()
-{
- m_winId = newWId();
-
- // Save the original surface type before changing to OpenGLSurface.
- m_raster = (window()->surfaceType() == QSurface::RasterSurface);
- if (m_raster) // change to OpenGL, but not for RasterGLSurface
- window()->setSurfaceType(QSurface::OpenGLSurface);
-
- if (window()->type() == Qt::Desktop) {
- QRect fullscreenRect(QPoint(), screen()->availableGeometry().size());
- QPlatformWindow::setGeometry(fullscreenRect);
- QWindowSystemInterface::handleGeometryChange(window(), fullscreenRect);
- return;
- }
-}
-
-bool QEGLPlatformWindow::isRaster() const
-{
- return m_raster || window()->surfaceType() == QSurface::RasterGLSurface;
-}
-
-QWindow *QEGLPlatformWindow::sourceWindow() const
-{
- return window();
-}
-
-const QPlatformTextureList *QEGLPlatformWindow::textures() const
-{
- if (m_backingStore)
- return m_backingStore->textures();
-
- return 0;
-}
-
-void QEGLPlatformWindow::endCompositing()
-{
- if (m_backingStore)
- m_backingStore->notifyComposited();
-}
-
-WId QEGLPlatformWindow::winId() const
-{
- return m_winId;
-}
-
-void QEGLPlatformWindow::setOpacity(qreal)
-{
- if (!isRaster())
- qWarning("QEGLPlatformWindow: Cannot set opacity for non-raster windows");
-
- // Nothing to do here. The opacity is stored in the QWindow.
-}
-
-QT_END_NAMESPACE
diff --git a/src/platformsupport/eglconvenience/qeglplatformwindow_p.h b/src/platformsupport/eglconvenience/qeglplatformwindow_p.h
deleted file mode 100644
index 852d690c92..0000000000
--- a/src/platformsupport/eglconvenience/qeglplatformwindow_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QEGLPLATFORMWINDOW_H
-#define QEGLPLATFORMWINDOW_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qpa/qplatformwindow.h>
-#include <QtPlatformSupport/private/qopenglcompositor_p.h>
-#include <EGL/egl.h>
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLCompositorBackingStore;
-class QPlatformTextureList;
-
-class QEGLPlatformWindow : public QPlatformWindow, public QOpenGLCompositorWindow
-{
-public:
- QEGLPlatformWindow(QWindow *w);
-
- virtual void create();
-
- QOpenGLCompositorBackingStore *backingStore() { return m_backingStore; }
- void setBackingStore(QOpenGLCompositorBackingStore *backingStore) { m_backingStore = backingStore; }
- bool isRaster() const;
-
- QWindow *sourceWindow() const Q_DECL_OVERRIDE;
- const QPlatformTextureList *textures() const Q_DECL_OVERRIDE;
- void endCompositing() Q_DECL_OVERRIDE;
-
- WId winId() const Q_DECL_OVERRIDE;
- void setOpacity(qreal opacity) Q_DECL_OVERRIDE;
-
- virtual EGLNativeWindowType eglWindow() const = 0;
-
-private:
- QOpenGLCompositorBackingStore *m_backingStore;
- bool m_raster;
- WId m_winId;
-};
-
-QT_END_NAMESPACE
-
-#endif // QEGLPLATFORMWINDOW_H
diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp
index 566f84c9ea..d00954375d 100644
--- a/src/platformsupport/fbconvenience/qfbscreen.cpp
+++ b/src/platformsupport/fbconvenience/qfbscreen.cpp
@@ -206,10 +206,11 @@ void QFbScreen::generateRects()
}
#endif
}
- foreach (const QRect &rect, remainingScreen.rects())
+ const QVector<QRect> remainingScreenRects = remainingScreen.rects();
+ mCachedRects.reserve(mCachedRects.count() + remainingScreenRects.count());
+ foreach (const QRect &rect, remainingScreenRects)
mCachedRects += QPair<QRect, int>(rect, -1);
mIsUpToDate = true;
- return;
}
QRegion QFbScreen::doRedraw()
diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
index c41061a9fd..b04ae8ee52 100644
--- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
+++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
@@ -76,24 +76,6 @@ void QBasicFontDatabase::populateFontDatabase()
}
}
-inline static void setHintingPreference(QFontEngine *engine, QFont::HintingPreference hintingPreference)
-{
- switch (hintingPreference) {
- case QFont::PreferNoHinting:
- engine->setDefaultHintStyle(QFontEngineFT::HintNone);
- break;
- case QFont::PreferFullHinting:
- engine->setDefaultHintStyle(QFontEngineFT::HintFull);
- break;
- case QFont::PreferVerticalHinting:
- engine->setDefaultHintStyle(QFontEngineFT::HintLight);
- break;
- case QFont::PreferDefaultHinting:
- // Leave it as it is
- break;
- }
-}
-
QFontEngine *QBasicFontDatabase::fontEngine(const QFontDef &fontDef, void *usrPtr)
{
FontFile *fontfile = static_cast<FontFile *> (usrPtr);
@@ -119,7 +101,7 @@ QFontEngine *QBasicFontDatabase::fontEngine(const QFontDef &fontDef, void *usrPt
delete engine;
engine = 0;
} else {
- setHintingPreference(engine, static_cast<QFont::HintingPreference>(fontDef.hintingPreference));
+ engine->setQtDefaultHintStyle(static_cast<QFont::HintingPreference>(fontDef.hintingPreference));
}
return engine;
@@ -172,7 +154,7 @@ QFontEngine *QBasicFontDatabase::fontEngine(const QByteArray &fontData, qreal pi
}
fe->updateFamilyNameAndStyle();
- setHintingPreference(fe, hintingPreference);
+ fe->setQtDefaultHintStyle(static_cast<QFont::HintingPreference>(fontDef.hintingPreference));
return fe;
}
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index 112bb8e0a6..022bc8bec2 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -44,6 +44,7 @@
#include <QtGui/private/qfontengine_ft_p.h>
#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/private/qhighdpiscaling_p.h>
#include <QtGui/qguiapplication.h>
@@ -553,10 +554,8 @@ QFontEngine::HintStyle defaultHintStyleFromMatch(QFont::HintingPreference hintin
break;
}
- if (QGuiApplication::platformNativeInterface()->nativeResourceForScreen("nofonthinting",
- QGuiApplication::primaryScreen())) {
+ if (QHighDpiScaling::isActive())
return QFontEngine::HintNone;
- }
int hint_style = 0;
if (FcPatternGetInteger (match, FC_HINT_STYLE, 0, &hint_style) == FcResultMatch) {
diff --git a/src/platformsupport/fontdatabases/mac/coretext.pri b/src/platformsupport/fontdatabases/mac/coretext.pri
index f67f00672a..ebb64d15b4 100644
--- a/src/platformsupport/fontdatabases/mac/coretext.pri
+++ b/src/platformsupport/fontdatabases/mac/coretext.pri
@@ -1,6 +1,13 @@
HEADERS += $$PWD/qcoretextfontdatabase_p.h $$PWD/qfontengine_coretext_p.h
OBJECTIVE_SOURCES += $$PWD/qfontengine_coretext.mm $$PWD/qcoretextfontdatabase.mm
+contains(QT_CONFIG, freetype) {
+ include($$QT_SOURCE_TREE/src/3rdparty/freetype_dependency.pri)
+ HEADERS += $$QT_SOURCE_TREE/src/gui/text/qfontengine_ft_p.h
+ SOURCES += $$QT_SOURCE_TREE/src/gui/text/qfontengine_ft.cpp
+ CONFIG += opentype
+}
+
ios: \
# On iOS CoreText and CoreGraphics are stand-alone frameworks
LIBS_PRIVATE += -framework CoreText -framework CoreGraphics
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index be70092010..1f000421cc 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -33,6 +33,8 @@
#include "qglobal.h"
+#include <sys/param.h>
+
#if defined(Q_OS_MACX)
#import <Cocoa/Cocoa.h>
#import <IOKit/graphics/IOGraphicsLib.h>
@@ -45,21 +47,12 @@
#include <QtCore/QSettings>
#include <QtGui/QGuiApplication>
#include <QtCore/QtEndian>
+#ifndef QT_NO_FREETYPE
+#include <QtGui/private/qfontengine_ft_p.h>
+#endif
QT_BEGIN_NAMESPACE
-namespace {
-class AutoReleasePool
-{
-public:
- AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
- ~AutoReleasePool() { [pool release]; }
-
-private:
- NSAutoreleasePool *pool;
-};
-}
-
// this could become a list of all languages used for each writing
// system, instead of using the single most common language.
static const char *languageForWritingSystem[] = {
@@ -114,8 +107,12 @@ static NSInteger languageMapSort(id obj1, id obj2, void *context)
}
#endif
-QCoreTextFontDatabase::QCoreTextFontDatabase()
+QCoreTextFontDatabase::QCoreTextFontDatabase(bool useFreeType)
+#ifndef QT_NO_FREETYPE
+ : m_useFreeType(useFreeType)
+#endif
{
+ Q_UNUSED(useFreeType)
#ifdef Q_OS_MACX
QSettings appleSettings(QLatin1String("apple.com"));
QVariant appleValue = appleSettings.value(QLatin1String("AppleAntiAliasingThreshold"));
@@ -360,10 +357,48 @@ void QCoreTextFontDatabase::releaseHandle(void *handle)
CFRelease(CTFontDescriptorRef(handle));
}
+#ifndef QT_NO_FREETYPE
+static QByteArray filenameForCFUrl(CFURLRef url)
+{
+ // The on-stack buffer prevents that a QByteArray allocated for the worst case (MAXPATHLEN)
+ // stays around for the lifetime of the font. Additionally, it helps to move the char
+ // signedness cast to an acceptable place.
+ uchar buffer[MAXPATHLEN];
+ QByteArray filename;
+
+ if (!CFURLGetFileSystemRepresentation(url, true, buffer, sizeof(buffer))) {
+ qWarning("QCoreTextFontDatabase::filenameForCFUrl: could not resolve file for URL %s",
+ qPrintable(QString::fromCFString(CFURLGetString(url))));
+ } else {
+ QCFType<CFStringRef> scheme = CFURLCopyScheme(url);
+ if (QString::fromCFString(scheme) == QLatin1String("qrc"))
+ filename = ":";
+
+ filename += reinterpret_cast<char *>(buffer);
+ }
+
+ return filename;
+}
+#endif
+
extern CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef);
QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &f, void *usrPtr)
{
+ CTFontDescriptorRef descriptor = static_cast<CTFontDescriptorRef>(usrPtr);
+
+#ifndef QT_NO_FREETYPE
+ if (m_useFreeType) {
+ QCFType<CFURLRef> url(static_cast<CFURLRef>(CTFontDescriptorCopyAttribute(descriptor, kCTFontURLAttribute)));
+
+ QByteArray filename;
+ if (url)
+ filename = filenameForCFUrl(url);
+
+ return freeTypeFontEngine(f, filename);
+ }
+#endif
+
qreal scaledPointSize = f.pixelSize;
// When 96 DPI is forced, the Mac plugin will use DPI 72 for some
@@ -375,7 +410,6 @@ QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &f, void *usrPtr)
if (QGuiApplication::testAttribute(Qt::AA_Use96Dpi))
scaledPointSize = f.pointSize;
- CTFontDescriptorRef descriptor = (CTFontDescriptorRef) usrPtr;
CGAffineTransform matrix = qt_transform_from_fontdef(f);
CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, scaledPointSize, &matrix);
if (font) {
@@ -397,6 +431,29 @@ static void releaseFontData(void* info, const void* data, size_t size)
QFontEngine *QCoreTextFontDatabase::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference)
{
+#ifndef QT_NO_FREETYPE
+ if (m_useFreeType) {
+ QByteArray *fontDataCopy = new QByteArray(fontData);
+ QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(fontDataCopy,
+ fontDataCopy->constData(), fontDataCopy->size(), releaseFontData);
+ QCFType<CGFontRef> cgFont(CGFontCreateWithDataProvider(dataProvider));
+
+ if (!cgFont) {
+ qWarning("QCoreTextFontDatabase::fontEngine: CGFontCreateWithDataProvider failed");
+ return Q_NULLPTR;
+ }
+
+ QFontDef fontDef;
+ fontDef.pixelSize = pixelSize;
+ fontDef.pointSize = pixelSize * 72.0 / qt_defaultDpi();
+ fontDef.hintingPreference = hintingPreference;
+ CGAffineTransform transform = qt_transform_from_fontdef(fontDef);
+ QCFType<CTFontRef> ctFont(CTFontCreateWithGraphicsFont(cgFont, fontDef.pixelSize, &transform, Q_NULLPTR));
+ QCFType<CFURLRef> url(static_cast<CFURLRef>(CTFontCopyAttribute(ctFont, kCTFontURLAttribute)));
+ return freeTypeFontEngine(fontDef, filenameForCFUrl(url), fontData);
+ }
+#endif
+
Q_UNUSED(hintingPreference);
QByteArray* fontDataCopy = new QByteArray(fontData);
@@ -453,7 +510,7 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
Q_UNUSED(style);
Q_UNUSED(script);
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
static QHash<QString, QStringList> fallbackLists;
@@ -568,10 +625,36 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
}
#if HAVE_CORETEXT
-static CFArrayRef createDescriptorArrayForFont(CTFontRef font)
+static CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fileName = QString())
{
CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
- CFArrayAppendValue(array, QCFType<CTFontDescriptorRef>(CTFontCopyFontDescriptor(font)));
+ QCFType<CTFontDescriptorRef> descriptor = CTFontCopyFontDescriptor(font);
+
+ Q_UNUSED(fileName)
+#ifndef QT_NO_FREETYPE
+ // The physical font source URL (usually a local file or Qt resource) is only required for
+ // FreeType, when using non-system fonts, and needs some hackery to attach in a format
+ // agreeable to OSX.
+ if (!fileName.isEmpty()) {
+ QCFType<CFURLRef> fontURL;
+
+ if (fileName.startsWith(QLatin1String(":/"))) {
+ // QUrl::fromLocalFile() doesn't accept qrc pseudo-paths like ":/fonts/myfont.ttf".
+ // Therefore construct from QString with the qrc:// scheme -> "qrc:///fonts/myfont.ttf".
+ fontURL = QUrl(QStringLiteral("qrc://") + fileName.mid(1)).toCFURL();
+ } else if (!fileName.isEmpty()) {
+ // At this point we hope that filename is in a format that QUrl can handle.
+ fontURL = QUrl::fromLocalFile(fileName).toCFURL();
+ }
+
+ QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 1,
+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionaryAddValue(attributes, kCTFontURLAttribute, fontURL);
+ descriptor = CTFontDescriptorCreateCopyWithAttributes(descriptor, attributes);
+ }
+#endif
+
+ CFArrayAppendValue(array, descriptor);
return array;
}
#endif
@@ -592,7 +675,11 @@ QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData
if (cgFont) {
if (CTFontManagerRegisterGraphicsFont(cgFont, &error)) {
QCFType<CTFontRef> font = CTFontCreateWithGraphicsFont(cgFont, 0.0, NULL, NULL);
- fonts = createDescriptorArrayForFont(font);
+ fonts = createDescriptorArrayForFont(font
+#ifndef QT_NO_FREETYPE
+ , m_useFreeType ? fileName : QString()
+#endif
+ );
m_applicationFonts.append(QVariant::fromValue(QCFType<CGFontRef>::constructFromGet(cgFont)));
}
}
@@ -892,5 +979,36 @@ void QCoreTextFontDatabase::removeApplicationFonts()
#endif
}
+#ifndef QT_NO_FREETYPE
+QFontEngine *QCoreTextFontDatabase::freeTypeFontEngine(const QFontDef &fontDef, const QByteArray &filename,
+ const QByteArray &fontData)
+{
+ QFontEngine::FaceId faceId;
+ faceId.filename = filename;
+ const bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias);
+
+ QScopedPointer<QFontEngineFT> engine(new QFontEngineFT(fontDef));
+ QFontEngineFT::GlyphFormat format = QFontEngineFT::Format_Mono;
+ if (antialias) {
+ QFontEngine::SubpixelAntialiasingType subpixelType = subpixelAntialiasingTypeHint();
+ if (subpixelType == QFontEngine::Subpixel_None || (fontDef.styleStrategy & QFont::NoSubpixelAntialias)) {
+ format = QFontEngineFT::Format_A8;
+ engine->subpixelType = QFontEngine::Subpixel_None;
+ } else {
+ format = QFontEngineFT::Format_A32;
+ engine->subpixelType = subpixelType;
+ }
+ }
+
+ if (!engine->init(faceId, antialias, format, fontData) || engine->invalid()) {
+ qWarning() << "QCoreTextFontDatabase::freeTypefontEngine Failed to create engine";
+ return Q_NULLPTR;
+ }
+ engine->setQtDefaultHintStyle(static_cast<QFont::HintingPreference>(fontDef.hintingPreference));
+
+ return engine.take();
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
index a423ed5ae2..95af1210b3 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
class QCoreTextFontDatabase : public QPlatformFontDatabase
{
public:
- QCoreTextFontDatabase();
+ QCoreTextFontDatabase(bool useFreeType = false);
~QCoreTextFontDatabase();
void populateFontDatabase() Q_DECL_OVERRIDE;
void populateFamily(const QString &familyName) Q_DECL_OVERRIDE;
@@ -95,6 +95,11 @@ public:
private:
void populateFromDescriptor(CTFontDescriptorRef font);
+#ifndef QT_NO_FREETYPE
+ bool m_useFreeType;
+ QFontEngine *freeTypeFontEngine(const QFontDef &fontDef, const QByteArray &filename,
+ const QByteArray &fontData = QByteArray());
+#endif
mutable QString defaultFontName;
void removeApplicationFonts();
diff --git a/src/platformsupport/input/evdevtablet/qevdevtablet.cpp b/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
index c59f0f390a..c6f952c64d 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
+++ b/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
@@ -292,7 +292,7 @@ void QEvdevTabletHandler::readData()
QEvdevTabletHandlerThread::QEvdevTabletHandlerThread(const QString &spec, QObject *parent)
- : QThread(parent), m_spec(spec), m_handler(0)
+ : QDaemonThread(parent), m_spec(spec), m_handler(0)
{
start();
}
diff --git a/src/platformsupport/input/evdevtablet/qevdevtablet_p.h b/src/platformsupport/input/evdevtablet/qevdevtablet_p.h
index f9682290d9..f546f9a88a 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtablet_p.h
+++ b/src/platformsupport/input/evdevtablet/qevdevtablet_p.h
@@ -48,6 +48,7 @@
#include <QObject>
#include <QString>
#include <QThread>
+#include <QtCore/private/qthread_p.h>
QT_BEGIN_NAMESPACE
@@ -68,7 +69,7 @@ private:
QEvdevTabletData *d;
};
-class QEvdevTabletHandlerThread : public QThread
+class QEvdevTabletHandlerThread : public QDaemonThread
{
public:
explicit QEvdevTabletHandlerThread(const QString &spec, QObject *parent = 0);
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
index 885326e512..1ca95074b9 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
@@ -418,11 +418,11 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data)
m_currentData.y = qBound(hw_range_y_min, data->value, hw_range_y_max);
if (m_singleTouch)
m_contacts[m_currentSlot].y = m_currentData.y;
- if (m_typeB) {
- m_contacts[m_currentSlot].y = m_currentData.y;
- if (m_contacts[m_currentSlot].state == Qt::TouchPointStationary)
- m_contacts[m_currentSlot].state = Qt::TouchPointMoved;
- }
+ if (m_typeB) {
+ m_contacts[m_currentSlot].y = m_currentData.y;
+ if (m_contacts[m_currentSlot].state == Qt::TouchPointStationary)
+ m_contacts[m_currentSlot].state = Qt::TouchPointMoved;
+ }
} else if (data->code == ABS_MT_TRACKING_ID) {
m_currentData.trackingId = data->value;
if (m_typeB) {
@@ -642,7 +642,7 @@ void QEvdevTouchScreenData::reportPoints()
QEvdevTouchScreenHandlerThread::QEvdevTouchScreenHandlerThread(const QString &device, const QString &spec, QObject *parent)
- : QThread(parent), m_device(device), m_spec(spec), m_handler(0)
+ : QDaemonThread(parent), m_device(device), m_spec(spec), m_handler(0)
{
start();
}
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
index a6d3a860f5..8e7dfe59bb 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
@@ -49,6 +49,7 @@
#include <QString>
#include <QList>
#include <QThread>
+#include <QtCore/private/qthread_p.h>
#include <qpa/qwindowsysteminterface.h>
#if !defined(QT_NO_MTDEV)
@@ -80,7 +81,7 @@ private:
#endif
};
-class QEvdevTouchScreenHandlerThread : public QThread
+class QEvdevTouchScreenHandlerThread : public QDaemonThread
{
public:
explicit QEvdevTouchScreenHandlerThread(const QString &device, const QString &spec, QObject *parent = 0);
diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp
index 1a64ad5a30..5aa66a4eaf 100644
--- a/src/platformsupport/input/libinput/qlibinputhandler.cpp
+++ b/src/platformsupport/input/libinput/qlibinputhandler.cpp
@@ -46,7 +46,7 @@
QT_BEGIN_NAMESPACE
-Q_LOGGING_CATEGORY(qLcInput, "qt.qpa.input")
+Q_LOGGING_CATEGORY(qLcLibInput, "qt.qpa.input")
static int liOpen(const char *path, int flags, void *user_data)
{
@@ -75,7 +75,7 @@ static void liLogHandler(libinput *libinput, libinput_log_priority priority, con
if (n > 0) {
if (buf[n - 1] == '\n')
buf[n - 1] = '\0';
- qCDebug(qLcInput, "libinput: %s", buf);
+ qCDebug(qLcLibInput, "libinput: %s", buf);
}
}
@@ -93,7 +93,7 @@ QLibInputHandler::QLibInputHandler(const QString &key, const QString &spec)
qFatal("Failed to get libinput context");
libinput_log_set_handler(m_li, liLogHandler);
- if (qLcInput().isDebugEnabled())
+ if (qLcLibInput().isDebugEnabled())
libinput_log_set_priority(m_li, LIBINPUT_LOG_PRIORITY_DEBUG);
if (libinput_udev_assign_seat(m_li, "seat0"))
diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
index 5f1bc550b4..ec7ea7ef0d 100644
--- a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
+++ b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
@@ -33,6 +33,7 @@
#include "qlibinputkeyboard_p.h"
#include <QtCore/QTextCodec>
+#include <QtCore/QLoggingCategory>
#include <qpa/qwindowsysteminterface.h>
#include <libinput.h>
#ifndef QT_NO_XKBCOMMON_EVDEV
@@ -42,6 +43,8 @@
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(qLcLibInput)
+
const int REPEAT_DELAY = 500;
const int REPEAT_RATE = 100;
@@ -128,6 +131,7 @@ QLibInputKeyboard::QLibInputKeyboard()
#endif
{
#ifndef QT_NO_XKBCOMMON_EVDEV
+ qCDebug(qLcLibInput) << "Using xkbcommon for key mapping";
m_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
if (!m_ctx) {
qWarning("Failed to create xkb context");
@@ -150,6 +154,8 @@ QLibInputKeyboard::QLibInputKeyboard()
m_repeatTimer.setSingleShot(true);
connect(&m_repeatTimer, &QTimer::timeout, this, &QLibInputKeyboard::handleRepeat);
+#else
+ qCWarning(qLcLibInput) << "X-less xkbcommon not available, not performing key mapping";
#endif
}
@@ -174,10 +180,13 @@ void QLibInputKeyboard::processKey(libinput_event_keyboard *e)
const uint32_t k = libinput_event_keyboard_get_key(e) + 8;
const bool pressed = libinput_event_keyboard_get_key_state(e) == LIBINPUT_KEY_STATE_PRESSED;
- QByteArray chars;
- chars.resize(1 + xkb_state_key_get_utf8(m_state, k, Q_NULLPTR, 0));
- xkb_state_key_get_utf8(m_state, k, chars.data(), chars.size());
- const QString text = QString::fromUtf8(chars);
+ QVarLengthArray<char, 32> chars(32);
+ const int size = xkb_state_key_get_utf8(m_state, k, chars.data(), chars.size());
+ if (Q_UNLIKELY(size + 1 > chars.size())) { // +1 for NUL
+ chars.resize(size + 1);
+ xkb_state_key_get_utf8(m_state, k, chars.data(), chars.size());
+ }
+ const QString text = QString::fromUtf8(chars.constData(), size);
const xkb_keysym_t sym = xkb_state_key_get_one_sym(m_state, k);
diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
index c040dab5e1..d155cecd89 100644
--- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
@@ -1431,7 +1431,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
QSpiObjectReference(connection, QDBusObjectPath(QSPI_OBJECT_PATH_ROOT))));
} else if (function == QLatin1String("GetChildren")) {
QSpiObjectReferenceArray children;
- for (int i = 0; i < interface->childCount(); ++i) {
+ const int numChildren = interface->childCount();
+ children.reserve(numChildren);
+ for (int i = 0; i < numChildren; ++i) {
QString childPath = pathForInterface(interface->child(i));
QSpiObjectReference ref(connection, QDBusObjectPath(childPath));
children << ref;
@@ -1507,7 +1509,7 @@ QSpiRelationArray AtSpiAdaptor::relationSet(QAccessibleInterface *interface, con
Q_FOREACH (const RelationPair &pair, relationInterfaces) {
// FIXME: this loop seems a bit strange... "related" always have one item when we check.
//And why is it a list, when it always have one item? And it seems to assume that the QAccessible::Relation enum maps directly to AtSpi
- QList<QSpiObjectReference> related;
+ QSpiObjectReferenceArray related;
QDBusObjectPath path = QDBusObjectPath(pathForInterface(pair.first));
related.append(QSpiObjectReference(connection, path));
@@ -1747,7 +1749,9 @@ QSpiActionArray AtSpiAdaptor::getActions(QAccessibleInterface *interface) const
{
QAccessibleActionInterface *actionInterface = interface->actionInterface();
QSpiActionArray actions;
- Q_FOREACH (const QString &actionName, QAccessibleBridgeUtils::effectiveActionNames(interface)) {
+ const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface);
+ actions.reserve(actionNames.size());
+ Q_FOREACH (const QString &actionName, actionNames) {
QSpiAction action;
QStringList keyBindings;
diff --git a/src/platformsupport/linuxaccessibility/cache.cpp b/src/platformsupport/linuxaccessibility/cache.cpp
index 2ece905fdf..0ccd2cba6e 100644
--- a/src/platformsupport/linuxaccessibility/cache.cpp
+++ b/src/platformsupport/linuxaccessibility/cache.cpp
@@ -78,8 +78,7 @@ void QSpiDBusCache::emitRemoveAccessible(const QSpiObjectReference& item)
QSpiAccessibleCacheArray QSpiDBusCache::GetItems()
{
- QList <QSpiAccessibleCacheItem> cacheArray;
- return cacheArray;
+ return QSpiAccessibleCacheArray();
}
QT_END_NAMESPACE
diff --git a/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/src/platformsupport/linuxaccessibility/dbusconnection.cpp
index 45729fa065..637b06549a 100644
--- a/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+++ b/src/platformsupport/linuxaccessibility/dbusconnection.cpp
@@ -42,6 +42,9 @@
#include <QDBusConnectionInterface>
#include "bus_interface.h"
+#include <QtGui/qguiapplication.h>
+#include <qplatformnativeinterface.h>
+
QT_BEGIN_NAMESPACE
QString A11Y_SERVICE = QStringLiteral("org.a11y.Bus");
@@ -65,6 +68,29 @@ DBusConnection::DBusConnection(QObject *parent)
// If it is registered already, setup a11y right away
if (c.interface()->isServiceRegistered(A11Y_SERVICE))
serviceRegistered();
+
+ // In addition try if there is an xatom exposing the bus address, this allows applications run as root to work
+ QString address = getAddressFromXCB();
+ if (!address.isEmpty()) {
+ m_enabled = true;
+ connectA11yBus(address);
+ }
+}
+
+QString DBusConnection::getAddressFromXCB()
+{
+ QGuiApplication *app = qobject_cast<QGuiApplication *>(QCoreApplication::instance());
+ if (!app)
+ return QString();
+ QPlatformNativeInterface *platformNativeInterface = app->platformNativeInterface();
+ QByteArray *addressByteArray = reinterpret_cast<QByteArray*>(
+ platformNativeInterface->nativeResourceForIntegration(QByteArrayLiteral("AtspiBus")));
+ if (addressByteArray) {
+ QString address = QString::fromLatin1(*addressByteArray);
+ delete addressByteArray;
+ return address;
+ }
+ return QString();
}
// We have the a11y registry on the session bus.
diff --git a/src/platformsupport/linuxaccessibility/dbusconnection_p.h b/src/platformsupport/linuxaccessibility/dbusconnection_p.h
index a0bd6450bf..30707a3f95 100644
--- a/src/platformsupport/linuxaccessibility/dbusconnection_p.h
+++ b/src/platformsupport/linuxaccessibility/dbusconnection_p.h
@@ -68,6 +68,7 @@ Q_SIGNALS:
void enabledChanged(bool enabled);
private Q_SLOTS:
+ QString getAddressFromXCB();
void serviceRegistered();
void serviceUnregistered();
void connectA11yBus(const QString &address);
diff --git a/src/platformsupport/linuxaccessibility/struct_marshallers_p.h b/src/platformsupport/linuxaccessibility/struct_marshallers_p.h
index 7788ceb7cc..61d79e6daa 100644
--- a/src/platformsupport/linuxaccessibility/struct_marshallers_p.h
+++ b/src/platformsupport/linuxaccessibility/struct_marshallers_p.h
@@ -46,7 +46,7 @@
// We mean it.
//
-#include <QtCore/qlist.h>
+#include <QtCore/qvector.h>
#include <QtCore/qpair.h>
#include <QtDBus/QDBusArgument>
#include <QtDBus/QDBusConnection>
@@ -55,8 +55,8 @@
#ifndef QT_NO_ACCESSIBILITY
QT_BEGIN_NAMESPACE
-typedef QList <int> QSpiIntList;
-typedef QList <uint> QSpiUIntList;
+typedef QVector<int> QSpiIntList;
+typedef QVector<uint> QSpiUIntList;
// FIXME: make this copy on write
struct QSpiObjectReference
@@ -68,26 +68,29 @@ struct QSpiObjectReference
QSpiObjectReference(const QDBusConnection& connection, const QDBusObjectPath& path)
: service(connection.baseService()), path(path) {}
};
+Q_DECLARE_TYPEINFO(QSpiObjectReference, Q_MOVABLE_TYPE); // QDBusObjectPath is movable, even though it
+ // cannot be marked that way until Qt 6
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiObjectReference &address);
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiObjectReference &address);
-typedef QList <QSpiObjectReference> QSpiObjectReferenceArray;
+typedef QVector<QSpiObjectReference> QSpiObjectReferenceArray;
struct QSpiAccessibleCacheItem
{
QSpiObjectReference path;
QSpiObjectReference application;
QSpiObjectReference parent;
- QList <QSpiObjectReference> children;
+ QSpiObjectReferenceArray children;
QStringList supportedInterfaces;
QString name;
uint role;
QString description;
QSpiUIntList state;
};
+Q_DECLARE_TYPEINFO(QSpiAccessibleCacheItem, Q_MOVABLE_TYPE);
-typedef QList <QSpiAccessibleCacheItem> QSpiAccessibleCacheArray;
+typedef QVector<QSpiAccessibleCacheItem> QSpiAccessibleCacheArray;
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAccessibleCacheItem &item);
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAccessibleCacheItem &item);
@@ -98,8 +101,9 @@ struct QSpiAction
QString description;
QString keyBinding;
};
+Q_DECLARE_TYPEINFO(QSpiAction, Q_MOVABLE_TYPE);
-typedef QList <QSpiAction> QSpiActionArray;
+typedef QVector<QSpiAction> QSpiActionArray;
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAction &action);
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAction &action);
@@ -109,14 +113,15 @@ struct QSpiEventListener
QString listenerAddress;
QString eventName;
};
+Q_DECLARE_TYPEINFO(QSpiEventListener, Q_MOVABLE_TYPE);
-typedef QList <QSpiEventListener> QSpiEventListenerArray;
+typedef QVector<QSpiEventListener> QSpiEventListenerArray;
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiEventListener &action);
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiEventListener &action);
-typedef QPair < unsigned int, QList < QSpiObjectReference > > QSpiRelationArrayEntry;
-typedef QList< QSpiRelationArrayEntry > QSpiRelationArray;
+typedef QPair<unsigned int, QSpiObjectReferenceArray> QSpiRelationArrayEntry;
+typedef QVector<QSpiRelationArrayEntry> QSpiRelationArray;
//a(iisv)
struct QSpiTextRange {
@@ -125,18 +130,22 @@ struct QSpiTextRange {
QString contents;
QVariant v;
};
-typedef QList <QSpiTextRange> QSpiTextRangeList;
+Q_DECLARE_TYPEINFO(QSpiTextRange, Q_MOVABLE_TYPE);
+
+typedef QVector<QSpiTextRange> QSpiTextRangeList;
typedef QMap <QString, QString> QSpiAttributeSet;
enum QSpiAppUpdateType {
QSPI_APP_UPDATE_ADDED = 0,
QSPI_APP_UPDATE_REMOVED = 1
};
+Q_DECLARE_TYPEINFO(QSpiAppUpdateType, Q_PRIMITIVE_TYPE);
struct QSpiAppUpdate {
int type; /* Is an application added or removed */
QString address; /* D-Bus address of application added or removed */
};
+Q_DECLARE_TYPEINFO(QSpiAppUpdate, Q_MOVABLE_TYPE);
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAppUpdate &update);
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAppUpdate &update);
@@ -150,6 +159,7 @@ struct QSpiDeviceEvent {
QString text;
bool isText;
};
+Q_DECLARE_TYPEINFO(QSpiDeviceEvent, Q_MOVABLE_TYPE);
QDBusArgument &operator<<(QDBusArgument &argument, const QSpiDeviceEvent &event);
const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiDeviceEvent &event);
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index ba328bfb41..cd38498217 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -47,6 +47,7 @@
#include <QtCore/QLoggingCategory>
#include <QtCore/QSettings>
#include <QtCore/QVariant>
+#include <QtCore/QStandardPaths>
#include <QtCore/QStringList>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
@@ -209,14 +210,16 @@ public:
, wheelScrollLines(3)
{ }
- static QString kdeGlobals(const QString &kdeDir)
+ static QString kdeGlobals(const QString &kdeDir, int kdeVersion)
{
+ if (kdeVersion > 4)
+ return kdeDir + QStringLiteral("/kdeglobals");
return kdeDir + QStringLiteral("/share/config/kdeglobals");
}
void refresh();
- static QVariant readKdeSetting(const QString &key, const QStringList &kdeDirs, QHash<QString, QSettings*> &kdeSettings);
- static void readKdeSystemPalette(const QStringList &kdeDirs, QHash<QString, QSettings*> &kdeSettings, QPalette *pal);
+ static QVariant readKdeSetting(const QString &key, const QStringList &kdeDirs, int kdeVersion, QHash<QString, QSettings*> &kdeSettings);
+ static void readKdeSystemPalette(const QStringList &kdeDirs, int kdeVersion, QHash<QString, QSettings*> &kdeSettings, QPalette *pal);
static QFont *kdeFont(const QVariant &fontValue);
static QStringList kdeIconThemeSearchPaths(const QStringList &kdeDirs);
@@ -246,30 +249,30 @@ void QKdeThemePrivate::refresh()
QHash<QString, QSettings*> kdeSettings;
QPalette systemPalette = QPalette();
- readKdeSystemPalette(kdeDirs, kdeSettings, &systemPalette);
+ readKdeSystemPalette(kdeDirs, kdeVersion, kdeSettings, &systemPalette);
resources.palettes[QPlatformTheme::SystemPalette] = new QPalette(systemPalette);
//## TODO tooltip color
- const QVariant styleValue = readKdeSetting(QStringLiteral("widgetStyle"), kdeDirs, kdeSettings);
+ const QVariant styleValue = readKdeSetting(QStringLiteral("widgetStyle"), kdeDirs, kdeVersion, kdeSettings);
if (styleValue.isValid()) {
const QString style = styleValue.toString();
if (style != styleNames.front())
styleNames.push_front(style);
}
- const QVariant singleClickValue = readKdeSetting(QStringLiteral("KDE/SingleClick"), kdeDirs, kdeSettings);
+ const QVariant singleClickValue = readKdeSetting(QStringLiteral("KDE/SingleClick"), kdeDirs, kdeVersion, kdeSettings);
if (singleClickValue.isValid())
singleClick = singleClickValue.toBool();
- const QVariant themeValue = readKdeSetting(QStringLiteral("Icons/Theme"), kdeDirs, kdeSettings);
+ const QVariant themeValue = readKdeSetting(QStringLiteral("Icons/Theme"), kdeDirs, kdeVersion, kdeSettings);
if (themeValue.isValid())
iconThemeName = themeValue.toString();
- const QVariant toolBarIconSizeValue = readKdeSetting(QStringLiteral("ToolbarIcons/Size"), kdeDirs, kdeSettings);
+ const QVariant toolBarIconSizeValue = readKdeSetting(QStringLiteral("ToolbarIcons/Size"), kdeDirs, kdeVersion, kdeSettings);
if (toolBarIconSizeValue.isValid())
toolBarIconSize = toolBarIconSizeValue.toInt();
- const QVariant toolbarStyleValue = readKdeSetting(QStringLiteral("Toolbar style/ToolButtonStyle"), kdeDirs, kdeSettings);
+ const QVariant toolbarStyleValue = readKdeSetting(QStringLiteral("Toolbar style/ToolButtonStyle"), kdeDirs, kdeVersion, kdeSettings);
if (toolbarStyleValue.isValid()) {
const QString toolBarStyle = toolbarStyleValue.toString();
if (toolBarStyle == QLatin1String("TextBesideIcon"))
@@ -280,17 +283,17 @@ void QKdeThemePrivate::refresh()
toolButtonStyle = Qt::ToolButtonTextUnderIcon;
}
- const QVariant wheelScrollLinesValue = readKdeSetting(QStringLiteral("KDE/WheelScrollLines"), kdeDirs, kdeSettings);
+ const QVariant wheelScrollLinesValue = readKdeSetting(QStringLiteral("KDE/WheelScrollLines"), kdeDirs, kdeVersion, kdeSettings);
if (wheelScrollLinesValue.isValid())
wheelScrollLines = wheelScrollLinesValue.toInt();
// Read system font, ignore 'smallestReadableFont'
- if (QFont *systemFont = kdeFont(readKdeSetting(QStringLiteral("font"), kdeDirs, kdeSettings)))
+ if (QFont *systemFont = kdeFont(readKdeSetting(QStringLiteral("font"), kdeDirs, kdeVersion, kdeSettings)))
resources.fonts[QPlatformTheme::SystemFont] = systemFont;
else
resources.fonts[QPlatformTheme::SystemFont] = new QFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize);
- if (QFont *fixedFont = kdeFont(readKdeSetting(QStringLiteral("fixed"), kdeDirs, kdeSettings))) {
+ if (QFont *fixedFont = kdeFont(readKdeSetting(QStringLiteral("fixed"), kdeDirs, kdeVersion, kdeSettings))) {
resources.fonts[QPlatformTheme::FixedFont] = fixedFont;
} else {
fixedFont = new QFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize);
@@ -301,12 +304,12 @@ void QKdeThemePrivate::refresh()
qDeleteAll(kdeSettings);
}
-QVariant QKdeThemePrivate::readKdeSetting(const QString &key, const QStringList &kdeDirs, QHash<QString, QSettings*> &kdeSettings)
+QVariant QKdeThemePrivate::readKdeSetting(const QString &key, const QStringList &kdeDirs, int kdeVersion, QHash<QString, QSettings*> &kdeSettings)
{
foreach (const QString &kdeDir, kdeDirs) {
QSettings *settings = kdeSettings.value(kdeDir);
if (!settings) {
- const QString kdeGlobalsPath = kdeGlobals(kdeDir);
+ const QString kdeGlobalsPath = kdeGlobals(kdeDir, kdeVersion);
if (QFileInfo(kdeGlobalsPath).isReadable()) {
settings = new QSettings(kdeGlobalsPath, QSettings::IniFormat);
kdeSettings.insert(kdeDir, settings);
@@ -334,9 +337,9 @@ static inline bool kdeColor(QPalette *pal, QPalette::ColorRole role, const QVari
return true;
}
-void QKdeThemePrivate::readKdeSystemPalette(const QStringList &kdeDirs, QHash<QString, QSettings*> &kdeSettings, QPalette *pal)
+void QKdeThemePrivate::readKdeSystemPalette(const QStringList &kdeDirs, int kdeVersion, QHash<QString, QSettings*> &kdeSettings, QPalette *pal)
{
- if (!kdeColor(pal, QPalette::Button, readKdeSetting(QStringLiteral("Colors:Button/BackgroundNormal"), kdeDirs, kdeSettings))) {
+ if (!kdeColor(pal, QPalette::Button, readKdeSetting(QStringLiteral("Colors:Button/BackgroundNormal"), kdeDirs, kdeVersion, kdeSettings))) {
// kcolorscheme.cpp: SetDefaultColors
const QColor defaultWindowBackground(214, 210, 208);
const QColor defaultButtonBackground(223, 220, 217);
@@ -344,18 +347,18 @@ void QKdeThemePrivate::readKdeSystemPalette(const QStringList &kdeDirs, QHash<QS
return;
}
- kdeColor(pal, QPalette::Window, readKdeSetting(QStringLiteral("Colors:Window/BackgroundNormal"), kdeDirs, kdeSettings));
- kdeColor(pal, QPalette::Text, readKdeSetting(QStringLiteral("Colors:View/ForegroundNormal"), kdeDirs, kdeSettings));
- kdeColor(pal, QPalette::WindowText, readKdeSetting(QStringLiteral("Colors:Window/ForegroundNormal"), kdeDirs, kdeSettings));
- kdeColor(pal, QPalette::Base, readKdeSetting(QStringLiteral("Colors:View/BackgroundNormal"), kdeDirs, kdeSettings));
- kdeColor(pal, QPalette::Highlight, readKdeSetting(QStringLiteral("Colors:Selection/BackgroundNormal"), kdeDirs, kdeSettings));
- kdeColor(pal, QPalette::HighlightedText, readKdeSetting(QStringLiteral("Colors:Selection/ForegroundNormal"), kdeDirs, kdeSettings));
- kdeColor(pal, QPalette::AlternateBase, readKdeSetting(QStringLiteral("Colors:View/BackgroundAlternate"), kdeDirs, kdeSettings));
- kdeColor(pal, QPalette::ButtonText, readKdeSetting(QStringLiteral("Colors:Button/ForegroundNormal"), kdeDirs, kdeSettings));
- kdeColor(pal, QPalette::Link, readKdeSetting(QStringLiteral("Colors:View/ForegroundLink"), kdeDirs, kdeSettings));
- kdeColor(pal, QPalette::LinkVisited, readKdeSetting(QStringLiteral("Colors:View/ForegroundVisited"), kdeDirs, kdeSettings));
- kdeColor(pal, QPalette::ToolTipBase, readKdeSetting(QStringLiteral("Colors:Tooltip/BackgroundNormal"), kdeDirs, kdeSettings));
- kdeColor(pal, QPalette::ToolTipText, readKdeSetting(QStringLiteral("Colors:Tooltip/ForegroundNormal"), kdeDirs, kdeSettings));
+ kdeColor(pal, QPalette::Window, readKdeSetting(QStringLiteral("Colors:Window/BackgroundNormal"), kdeDirs, kdeVersion, kdeSettings));
+ kdeColor(pal, QPalette::Text, readKdeSetting(QStringLiteral("Colors:View/ForegroundNormal"), kdeDirs, kdeVersion, kdeSettings));
+ kdeColor(pal, QPalette::WindowText, readKdeSetting(QStringLiteral("Colors:Window/ForegroundNormal"), kdeDirs, kdeVersion, kdeSettings));
+ kdeColor(pal, QPalette::Base, readKdeSetting(QStringLiteral("Colors:View/BackgroundNormal"), kdeDirs, kdeVersion, kdeSettings));
+ kdeColor(pal, QPalette::Highlight, readKdeSetting(QStringLiteral("Colors:Selection/BackgroundNormal"), kdeDirs, kdeVersion, kdeSettings));
+ kdeColor(pal, QPalette::HighlightedText, readKdeSetting(QStringLiteral("Colors:Selection/ForegroundNormal"), kdeDirs, kdeVersion, kdeSettings));
+ kdeColor(pal, QPalette::AlternateBase, readKdeSetting(QStringLiteral("Colors:View/BackgroundAlternate"), kdeDirs, kdeVersion, kdeSettings));
+ kdeColor(pal, QPalette::ButtonText, readKdeSetting(QStringLiteral("Colors:Button/ForegroundNormal"), kdeDirs, kdeVersion, kdeSettings));
+ kdeColor(pal, QPalette::Link, readKdeSetting(QStringLiteral("Colors:View/ForegroundLink"), kdeDirs, kdeVersion, kdeSettings));
+ kdeColor(pal, QPalette::LinkVisited, readKdeSetting(QStringLiteral("Colors:View/ForegroundVisited"), kdeDirs, kdeVersion, kdeSettings));
+ kdeColor(pal, QPalette::ToolTipBase, readKdeSetting(QStringLiteral("Colors:Tooltip/BackgroundNormal"), kdeDirs, kdeVersion, kdeSettings));
+ kdeColor(pal, QPalette::ToolTipText, readKdeSetting(QStringLiteral("Colors:Tooltip/ForegroundNormal"), kdeDirs, kdeVersion, kdeSettings));
// The above code sets _all_ color roles to "normal" colors. In KDE, the disabled
// color roles are calculated by applying various effects described in kdeglobals.
@@ -497,6 +500,11 @@ QPlatformTheme *QKdeTheme::createKdeTheme()
if (kdeVersion < 4)
return 0;
+ if (kdeVersion > 4)
+ // Plasma 5 follows XDG spec
+ // but uses the same config file format:
+ return new QKdeTheme(QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation), kdeVersion);
+
// Determine KDE prefixes in the following priority order:
// - KDEHOME and KDEDIRS environment variables
// - ~/.kde(<version>)
@@ -678,7 +686,7 @@ QPlatformTheme *QGenericUnixTheme::createUnixTheme(const QString &name)
#endif
if (name == QLatin1String(QGnomeTheme::name))
return new QGnomeTheme;
- return new QGenericUnixTheme;
+ return Q_NULLPTR;
}
QStringList QGenericUnixTheme::themeNames()
@@ -710,8 +718,7 @@ QStringList QGenericUnixTheme::themeNames()
if (!session.isEmpty() && session != QLatin1String("default") && !result.contains(session))
result.push_back(session);
} // desktopSettingsAware
- if (result.isEmpty())
- result.push_back(QLatin1String(QGenericUnixTheme::name));
+ result.append(QLatin1String(QGenericUnixTheme::name));
return result;
}