summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/accessibility/qaccessiblebridgeutils.cpp14
-rw-r--r--src/platformsupport/accessibility/qaccessiblebridgeutils_p.h18
-rw-r--r--src/platformsupport/cfsocketnotifier/qcfsocketnotifier.cpp14
-rw-r--r--src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h14
-rw-r--r--src/platformsupport/cglconvenience/cglconvenience.mm45
-rw-r--r--src/platformsupport/cglconvenience/cglconvenience_p.h14
-rw-r--r--src/platformsupport/clipboard/qmacmime.mm36
-rw-r--r--src/platformsupport/clipboard/qmacmime_p.h14
-rw-r--r--src/platformsupport/dbusmenu/dbusmenu.pri15
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenuadaptor.cpp132
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenuadaptor_p.h162
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenuconnection.cpp127
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenuconnection_p.h88
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenutypes.cpp257
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenutypes_p.h127
-rw-r--r--src/platformsupport/dbusmenu/qdbusplatformmenu.cpp249
-rw-r--r--src/platformsupport/dbusmenu/qdbusplatformmenu_p.h181
-rw-r--r--src/platformsupport/dbustray/dbustray.pri15
-rw-r--r--src/platformsupport/dbustray/qdbustrayicon.cpp293
-rw-r--r--src/platformsupport/dbustray/qdbustrayicon_p.h165
-rw-r--r--src/platformsupport/dbustray/qdbustraytypes.cpp204
-rw-r--r--src/platformsupport/dbustray/qdbustraytypes_p.h89
-rw-r--r--src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp174
-rw-r--r--src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h185
-rw-r--r--src/platformsupport/dbustray/qxdgnotificationproxy.cpp47
-rw-r--r--src/platformsupport/dbustray/qxdgnotificationproxy_p.h135
-rw-r--r--src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp14
-rw-r--r--src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h14
-rw-r--r--src/platformsupport/devicediscovery/qdevicediscovery_p.h14
-rw-r--r--src/platformsupport/devicediscovery/qdevicediscovery_static.cpp14
-rw-r--r--src/platformsupport/devicediscovery/qdevicediscovery_static_p.h14
-rw-r--r--src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp14
-rw-r--r--src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h14
-rw-r--r--src/platformsupport/eglconvenience/eglconvenience.pri4
-rw-r--r--src/platformsupport/eglconvenience/qeglcompositor.cpp185
-rw-r--r--src/platformsupport/eglconvenience/qeglconvenience.cpp26
-rw-r--r--src/platformsupport/eglconvenience/qeglconvenience_p.h14
-rw-r--r--src/platformsupport/eglconvenience/qeglpbuffer.cpp20
-rw-r--r--src/platformsupport/eglconvenience/qeglpbuffer_p.h18
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcontext.cpp88
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcontext_p.h31
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcursor.cpp54
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcursor_p.h26
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformintegration.cpp66
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformintegration_p.h19
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformscreen.cpp63
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformscreen_p.h28
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformwindow.cpp38
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformwindow_p.h31
-rw-r--r--src/platformsupport/eglconvenience/qxlibeglintegration.cpp48
-rw-r--r--src/platformsupport/eglconvenience/qxlibeglintegration_p.h14
-rw-r--r--src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm36
-rw-r--r--src/platformsupport/eventdispatchers/qeventdispatcher_cf_p.h14
-rw-r--r--src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp14
-rw-r--r--src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h16
-rw-r--r--src/platformsupport/eventdispatchers/qgenericunixeventdispatcher.cpp14
-rw-r--r--src/platformsupport/eventdispatchers/qgenericunixeventdispatcher_p.h14
-rw-r--r--src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp14
-rw-r--r--src/platformsupport/eventdispatchers/qunixeventdispatcher_qpa_p.h14
-rw-r--r--src/platformsupport/fbconvenience/qfbbackingstore.cpp14
-rw-r--r--src/platformsupport/fbconvenience/qfbbackingstore_p.h20
-rw-r--r--src/platformsupport/fbconvenience/qfbcursor.cpp61
-rw-r--r--src/platformsupport/fbconvenience/qfbcursor_p.h42
-rw-r--r--src/platformsupport/fbconvenience/qfbscreen.cpp14
-rw-r--r--src/platformsupport/fbconvenience/qfbscreen_p.h14
-rw-r--r--src/platformsupport/fbconvenience/qfbvthandler.cpp16
-rw-r--r--src/platformsupport/fbconvenience/qfbvthandler_p.h14
-rw-r--r--src/platformsupport/fbconvenience/qfbwindow.cpp14
-rw-r--r--src/platformsupport/fbconvenience/qfbwindow_p.h14
-rw-r--r--src/platformsupport/fontdatabases/basic/basic.pri4
-rw-r--r--src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp178
-rw-r--r--src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h27
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp63
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h30
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp20
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig_p.h18
-rw-r--r--src/platformsupport/fontdatabases/genericunix/qgenericunixfontdatabase_p.h14
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm77
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h15
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm182
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h22
-rw-r--r--src/platformsupport/glxconvenience/qglxconvenience.cpp14
-rw-r--r--src/platformsupport/glxconvenience/qglxconvenience_p.h14
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h14
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp86
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h14
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp49
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h14
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp42
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h14
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp54
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h20
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtablet.cpp30
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtablet_p.h16
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouch.cpp61
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouch_p.h16
-rw-r--r--src/platformsupport/input/input.pri8
-rw-r--r--src/platformsupport/input/libinput/libinput.pri23
-rw-r--r--src/platformsupport/input/libinput/qlibinputhandler.cpp230
-rw-r--r--src/platformsupport/input/libinput/qlibinputhandler_p.h93
-rw-r--r--src/platformsupport/input/libinput/qlibinputkeyboard.cpp279
-rw-r--r--src/platformsupport/input/libinput/qlibinputkeyboard_p.h98
-rw-r--r--src/platformsupport/input/libinput/qlibinputpointer.cpp111
-rw-r--r--src/platformsupport/input/libinput/qlibinputpointer_p.h (renamed from src/platformsupport/eglconvenience/qeglcompositor_p.h)55
-rw-r--r--src/platformsupport/input/libinput/qlibinputtouch.cpp165
-rw-r--r--src/platformsupport/input/libinput/qlibinputtouch_p.h83
-rw-r--r--src/platformsupport/input/tslib/qtslib.cpp134
-rw-r--r--src/platformsupport/input/tslib/qtslib_p.h66
-rw-r--r--src/platformsupport/input/tslib/tslib.pri7
-rw-r--r--src/platformsupport/linuxaccessibility/application.cpp17
-rw-r--r--src/platformsupport/linuxaccessibility/application_p.h18
-rw-r--r--src/platformsupport/linuxaccessibility/atspiadaptor.cpp16
-rw-r--r--src/platformsupport/linuxaccessibility/atspiadaptor_p.h16
-rw-r--r--src/platformsupport/linuxaccessibility/bridge.cpp16
-rw-r--r--src/platformsupport/linuxaccessibility/bridge_p.h18
-rw-r--r--src/platformsupport/linuxaccessibility/cache.cpp20
-rw-r--r--src/platformsupport/linuxaccessibility/cache_p.h16
-rw-r--r--src/platformsupport/linuxaccessibility/constant_mappings.cpp16
-rw-r--r--src/platformsupport/linuxaccessibility/constant_mappings_p.h16
-rw-r--r--src/platformsupport/linuxaccessibility/dbusconnection.cpp14
-rw-r--r--src/platformsupport/linuxaccessibility/dbusconnection_p.h14
-rw-r--r--src/platformsupport/linuxaccessibility/struct_marshallers.cpp16
-rw-r--r--src/platformsupport/linuxaccessibility/struct_marshallers_p.h16
-rw-r--r--src/platformsupport/platformcompositor/platformcompositor.pri7
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositor.cpp243
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositor_p.h107
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp (renamed from src/platformsupport/eglconvenience/qeglplatformbackingstore.cpp)117
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositorbackingstore_p.h (renamed from src/platformsupport/eglconvenience/qeglplatformbackingstore_p.h)34
-rw-r--r--src/platformsupport/platformsupport.pro5
-rw-r--r--src/platformsupport/services/genericunix/qgenericunixservices.cpp16
-rw-r--r--src/platformsupport/services/genericunix/qgenericunixservices_p.h20
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp107
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes_p.h37
133 files changed, 5774 insertions, 1652 deletions
diff --git a/src/platformsupport/accessibility/qaccessiblebridgeutils.cpp b/src/platformsupport/accessibility/qaccessiblebridgeutils.cpp
index 3021e84597..574decbf3f 100644
--- a/src/platformsupport/accessibility/qaccessiblebridgeutils.cpp
+++ b/src/platformsupport/accessibility/qaccessiblebridgeutils.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/accessibility/qaccessiblebridgeutils_p.h b/src/platformsupport/accessibility/qaccessiblebridgeutils_p.h
index bce2f90a09..fca3e16a68 100644
--- a/src/platformsupport/accessibility/qaccessiblebridgeutils_p.h
+++ b/src/platformsupport/accessibility/qaccessiblebridgeutils_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -34,11 +34,11 @@
#ifndef QACCESSIBLEBRIDGEUTILS_H
#define QACCESSIBLEBRIDGEUTILS_H
-#ifndef QT_NO_ACCESSIBILITY
-
#include <QtCore/qstringlist.h>
#include <QtGui/qaccessible.h>
+#ifndef QT_NO_ACCESSIBILITY
+
QT_BEGIN_NAMESPACE
namespace QAccessibleBridgeUtils {
diff --git a/src/platformsupport/cfsocketnotifier/qcfsocketnotifier.cpp b/src/platformsupport/cfsocketnotifier/qcfsocketnotifier.cpp
index e508f9728b..2b5723d827 100644
--- a/src/platformsupport/cfsocketnotifier/qcfsocketnotifier.cpp
+++ b/src/platformsupport/cfsocketnotifier/qcfsocketnotifier.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h b/src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h
index cf9f26b35d..af8122f753 100644
--- a/src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h
+++ b/src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm
index d0b0de8ae8..6b0a91e13f 100644
--- a/src/platformsupport/cglconvenience/cglconvenience.mm
+++ b/src/platformsupport/cglconvenience/cglconvenience.mm
@@ -1,45 +1,38 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** 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:LGPL$
+** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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.
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "cglconvenience_p.h"
+#include <QtCore/qglobal.h>
#include <QtCore/private/qcore_mac_p.h>
#include <Cocoa/Cocoa.h>
#include <QVector>
@@ -133,6 +126,14 @@ void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format)
attrs << NSOpenGLPFAStereo;
attrs << NSOpenGLPFAAllowOfflineRenderers;
+
+ QByteArray useLayer = qgetenv("QT_MAC_WANTS_LAYER");
+ if (!useLayer.isEmpty() && useLayer.toInt() > 0) {
+ // Disable the software rendering fallback. This makes compositing
+ // OpenGL and raster NSViews using Core Animation layers possible.
+ attrs << NSOpenGLPFANoRecovery;
+ }
+
attrs << 0;
NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs.constData()];
diff --git a/src/platformsupport/cglconvenience/cglconvenience_p.h b/src/platformsupport/cglconvenience/cglconvenience_p.h
index d24d7fb761..b0c7bb982e 100644
--- a/src/platformsupport/cglconvenience/cglconvenience_p.h
+++ b/src/platformsupport/cglconvenience/cglconvenience_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/clipboard/qmacmime.mm b/src/platformsupport/clipboard/qmacmime.mm
index 44580b017c..ffa548bf83 100644
--- a/src/platformsupport/clipboard/qmacmime.mm
+++ b/src/platformsupport/clipboard/qmacmime.mm
@@ -1,40 +1,32 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** 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:LGPL$
+** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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.
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/platformsupport/clipboard/qmacmime_p.h b/src/platformsupport/clipboard/qmacmime_p.h
index df5b771780..ceeec4e059 100644
--- a/src/platformsupport/clipboard/qmacmime_p.h
+++ b/src/platformsupport/clipboard/qmacmime_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/dbusmenu/dbusmenu.pri b/src/platformsupport/dbusmenu/dbusmenu.pri
new file mode 100644
index 0000000000..9ca1f13897
--- /dev/null
+++ b/src/platformsupport/dbusmenu/dbusmenu.pri
@@ -0,0 +1,15 @@
+QT_FOR_PRIVATE += dbus
+
+INCLUDEPATH += $$PWD $$PWD/../../gui/kernel
+
+HEADERS += \
+ $$PWD/qdbusmenuadaptor_p.h \
+ $$PWD/qdbusmenutypes_p.h \
+ $$PWD/qdbusmenuconnection_p.h \
+ $$PWD/qdbusplatformmenu_p.h \
+
+SOURCES += \
+ $$PWD/qdbusmenuadaptor.cpp \
+ $$PWD/qdbusmenutypes.cpp \
+ $$PWD/qdbusmenuconnection.cpp \
+ $$PWD/qdbusplatformmenu.cpp \
diff --git a/src/platformsupport/dbusmenu/qdbusmenuadaptor.cpp b/src/platformsupport/dbusmenu/qdbusmenuadaptor.cpp
new file mode 100644
index 0000000000..381caf77b3
--- /dev/null
+++ b/src/platformsupport/dbusmenu/qdbusmenuadaptor.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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$
+**
+****************************************************************************/
+
+/*
+ This file was originally created by qdbusxml2cpp version 0.8
+ Command line was:
+ qdbusxml2cpp -a dbusmenu ../../3rdparty/dbus-ifaces/dbus-menu.xml
+
+ However it is maintained manually.
+*/
+
+#include "qdbusmenuadaptor_p.h"
+#include "qdbusplatformmenu_p.h"
+#include <QtCore/QMetaObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+
+QT_BEGIN_NAMESPACE
+
+QDBusMenuAdaptor::QDBusMenuAdaptor(QObject *parent)
+ : QDBusAbstractAdaptor(parent)
+{
+ setAutoRelaySignals(true);
+}
+
+QDBusMenuAdaptor::~QDBusMenuAdaptor()
+{
+}
+
+QString QDBusMenuAdaptor::status() const
+{
+ qCDebug(qLcMenu);
+ return QLatin1String("normal");
+}
+
+QString QDBusMenuAdaptor::textDirection() const
+{
+ return QLocale().textDirection() == Qt::RightToLeft ? QLatin1String("rtl") : QLatin1String("ltr");
+}
+
+uint QDBusMenuAdaptor::version() const
+{
+ return 4;
+}
+
+bool QDBusMenuAdaptor::AboutToShow(int id)
+{
+ qCDebug(qLcMenu) << id;
+ return false;
+}
+
+QList<int> QDBusMenuAdaptor::AboutToShowGroup(const QList<int> &ids, QList<int> &idErrors)
+{
+ qCDebug(qLcMenu) << ids;
+ Q_UNUSED(idErrors)
+ idErrors.clear();
+ return QList<int>(); // updatesNeeded
+}
+
+void QDBusMenuAdaptor::Event(int id, const QString &eventId, const QDBusVariant &data, uint timestamp)
+{
+ Q_UNUSED(data)
+ Q_UNUSED(timestamp)
+ QDBusPlatformMenuItem *item = QDBusPlatformMenuItem::byId(id);
+ qCDebug(qLcMenu) << id << (item ? item->text() : QLatin1String("")) << eventId;
+ // Events occur on both menus and menuitems, but we only care if it's an item being clicked.
+ if (item && eventId == QLatin1String("clicked"))
+ item->trigger();
+}
+
+void QDBusMenuAdaptor::EventGroup(const QDBusMenuEventList &events)
+{
+ Q_FOREACH (const QDBusMenuEvent &ev, events)
+ Event(ev.m_id, ev.m_eventId, ev.m_data, ev.m_timestamp);
+}
+
+QDBusMenuItemList QDBusMenuAdaptor::GetGroupProperties(const QList<int> &ids, const QStringList &propertyNames)
+{
+ qCDebug(qLcMenu) << ids << propertyNames << "=>" << QDBusMenuItem::items(ids, propertyNames);
+ return QDBusMenuItem::items(ids, propertyNames);
+}
+
+uint QDBusMenuAdaptor::GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames, QDBusMenuLayoutItem &layout)
+{
+ uint ret = layout.populate(parentId, recursionDepth, propertyNames);
+ qCDebug(qLcMenu) << parentId << "depth" << recursionDepth << propertyNames << layout.m_id << layout.m_properties << "revision" << ret << layout;
+ return ret;
+}
+
+QDBusVariant QDBusMenuAdaptor::GetProperty(int id, const QString &name)
+{
+ qCDebug(qLcMenu) << id << name;
+ // handle method call com.canonical.dbusmenu.GetProperty
+ QDBusVariant value;
+ return value;
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/dbusmenu/qdbusmenuadaptor_p.h b/src/platformsupport/dbusmenu/qdbusmenuadaptor_p.h
new file mode 100644
index 0000000000..85b5bd8d49
--- /dev/null
+++ b/src/platformsupport/dbusmenu/qdbusmenuadaptor_p.h
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtDBus module 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$
+**
+****************************************************************************/
+
+/*
+ This file was originally created by qdbusxml2cpp version 0.8
+ Command line was:
+ qdbusxml2cpp -a dbusmenu ../../3rdparty/dbus-ifaces/dbus-menu.xml
+
+ However it is maintained manually.
+
+ It is also not part of the public API. This header file may change from
+ version to version without notice, or even be removed.
+*/
+
+#ifndef DBUSMENUADAPTOR_H
+#define DBUSMENUADAPTOR_H
+
+#include <QtCore/QObject>
+#include <QtDBus/QtDBus>
+#include "qdbusmenutypes_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*
+ * Adaptor class for interface com.canonical.dbusmenu
+ */
+class QDBusMenuAdaptor: public QDBusAbstractAdaptor
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "com.canonical.dbusmenu")
+ Q_CLASSINFO("D-Bus Introspection", ""
+" <interface name=\"com.canonical.dbusmenu\">\n"
+" <property access=\"read\" type=\"u\" name=\"Version\">\n"
+" </property>\n"
+" <property access=\"read\" type=\"s\" name=\"TextDirection\">\n"
+" </property>\n"
+" <property access=\"read\" type=\"s\" name=\"Status\">\n"
+" </property>\n"
+" <property access=\"read\" type=\"as\" name=\"IconThemePath\">\n"
+" </property>\n"
+" <method name=\"GetLayout\">\n"
+" <annotation value=\"QDBusMenuLayoutItem\" name=\"org.qtproject.QtDBus.QtTypeName.Out1\"/>\n"
+" <arg direction=\"in\" type=\"i\" name=\"parentId\"/>\n"
+" <arg direction=\"in\" type=\"i\" name=\"recursionDepth\"/>\n"
+" <arg direction=\"in\" type=\"as\" name=\"propertyNames\"/>\n"
+" <arg direction=\"out\" type=\"u\" name=\"revision\"/>\n"
+" <arg direction=\"out\" type=\"(ia{sv}av)\" name=\"layout\"/>\n"
+" </method>\n"
+" <method name=\"GetGroupProperties\">\n"
+" <annotation value=\"QList&lt;int&gt;\" name=\"org.qtproject.QtDBus.QtTypeName.In0\"/>\n"
+" <annotation value=\"QDBusMenuItemList\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+" <arg direction=\"in\" type=\"ai\" name=\"ids\"/>\n"
+" <arg direction=\"in\" type=\"as\" name=\"propertyNames\"/>\n"
+" <arg direction=\"out\" type=\"a(ia{sv})\" name=\"properties\"/>\n"
+" </method>\n"
+" <method name=\"GetProperty\">\n"
+" <arg direction=\"in\" type=\"i\" name=\"id\"/>\n"
+" <arg direction=\"in\" type=\"s\" name=\"name\"/>\n"
+" <arg direction=\"out\" type=\"v\" name=\"value\"/>\n"
+" </method>\n"
+" <method name=\"Event\">\n"
+" <arg direction=\"in\" type=\"i\" name=\"id\"/>\n"
+" <arg direction=\"in\" type=\"s\" name=\"eventId\"/>\n"
+" <arg direction=\"in\" type=\"v\" name=\"data\"/>\n"
+" <arg direction=\"in\" type=\"u\" name=\"timestamp\"/>\n"
+" </method>\n"
+" <method name=\"EventGroup\">\n"
+" <annotation value=\"QList&lt;QDBusMenuEvent&gt;\" name=\"org.qtproject.QtDBus.QtTypeName.In0\"/>\n"
+" <annotation value=\"QList&lt;int&gt;\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+" <arg direction=\"in\" type=\"a(isvu)\" name=\"events\"/>\n"
+" <arg direction=\"out\" type=\"ai\" name=\"idErrors\"/>\n"
+" </method>\n"
+" <method name=\"AboutToShow\">\n"
+" <arg direction=\"in\" type=\"i\" name=\"id\"/>\n"
+" <arg direction=\"out\" type=\"b\" name=\"needUpdate\"/>\n"
+" </method>\n"
+" <method name=\"AboutToShowGroup\">\n"
+" <annotation value=\"QList&lt;int&gt;\" name=\"org.qtproject.QtDBus.QtTypeName.In0\"/>\n"
+" <annotation value=\"QList&lt;int&gt;\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+" <annotation value=\"QList&lt;int&gt;\" name=\"org.qtproject.QtDBus.QtTypeName.Out1\"/>\n"
+" <arg direction=\"in\" type=\"ai\" name=\"ids\"/>\n"
+" <arg direction=\"out\" type=\"ai\" name=\"updatesNeeded\"/>\n"
+" <arg direction=\"out\" type=\"ai\" name=\"idErrors\"/>\n"
+" </method>\n"
+" <signal name=\"ItemsPropertiesUpdated\">\n"
+" <annotation value=\"QDBusMenuItemList\" name=\"org.qtproject.QtDBus.QtTypeName.In0\"/>\n"
+" <annotation value=\"QDBusMenuItemKeysList\" name=\"org.qtproject.QtDBus.QtTypeName.In1\"/>\n"
+" <arg direction=\"out\" type=\"a(ia{sv})\" name=\"updatedProps\"/>\n"
+" <arg direction=\"out\" type=\"a(ias)\" name=\"removedProps\"/>\n"
+" </signal>\n"
+" <signal name=\"LayoutUpdated\">\n"
+" <arg direction=\"out\" type=\"u\" name=\"revision\"/>\n"
+" <arg direction=\"out\" type=\"i\" name=\"parent\"/>\n"
+" </signal>\n"
+" <signal name=\"ItemActivationRequested\">\n"
+" <arg direction=\"out\" type=\"i\" name=\"id\"/>\n"
+" <arg direction=\"out\" type=\"u\" name=\"timestamp\"/>\n"
+" </signal>\n"
+" </interface>\n"
+ "")
+public:
+ QDBusMenuAdaptor(QObject *parent);
+ virtual ~QDBusMenuAdaptor();
+
+public: // PROPERTIES
+ Q_PROPERTY(QString Status READ status)
+ QString status() const;
+
+ Q_PROPERTY(QString TextDirection READ textDirection)
+ QString textDirection() const;
+
+ Q_PROPERTY(uint Version READ version)
+ uint version() const;
+
+public Q_SLOTS: // METHODS
+ bool AboutToShow(int id);
+ QList<int> AboutToShowGroup(const QList<int> &ids, QList<int> &idErrors);
+ void Event(int id, const QString &eventId, const QDBusVariant &data, uint timestamp);
+ void EventGroup(const QDBusMenuEventList &events);
+ QDBusMenuItemList GetGroupProperties(const QList<int> &ids, const QStringList &propertyNames);
+ uint GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames, QDBusMenuLayoutItem &layout);
+ QDBusVariant GetProperty(int id, const QString &name);
+
+Q_SIGNALS: // SIGNALS
+ void ItemActivationRequested(int id, uint timestamp);
+ void ItemsPropertiesUpdated(const QDBusMenuItemList &updatedProps, const QDBusMenuItemKeysList &removedProps);
+ void LayoutUpdated(uint revision, int parent);
+};
+
+QT_END_NAMESPACE
+
+#endif // DBUSMENUADAPTOR_H
diff --git a/src/platformsupport/dbusmenu/qdbusmenuconnection.cpp b/src/platformsupport/dbusmenu/qdbusmenuconnection.cpp
new file mode 100644
index 0000000000..73793d7497
--- /dev/null
+++ b/src/platformsupport/dbusmenu/qdbusmenuconnection.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 QT_NO_SYSTEMTRAYICON
+#include "qdbustrayicon_p.h"
+#endif
+#include "qdbusmenuconnection_p.h"
+#include "qdbusmenuadaptor_p.h"
+#include "qdbusplatformmenu_p.h"
+
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusServiceWatcher>
+#include <QtDBus/QDBusConnectionInterface>
+#include <qdebug.h>
+#include <qcoreapplication.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(qLcMenu)
+
+const QString StatusNotifierWatcherService = QLatin1String("org.kde.StatusNotifierWatcher");
+const QString StatusNotifierWatcherPath = QLatin1String("/StatusNotifierWatcher");
+const QString StatusNotifierItemPath = QLatin1String("/StatusNotifierItem");
+const QString MenuBarPath = QLatin1String("/MenuBar");
+
+/*!
+ \class QDBusMenuConnection
+ \internal
+ A D-Bus connection which is used for both menu and tray icon services.
+ Connects to the session bus and registers with the respective watcher services.
+*/
+QDBusMenuConnection::QDBusMenuConnection(QObject *parent)
+ : QObject(parent)
+ , m_connection(QDBusConnection::sessionBus())
+ , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+ , m_statusNotifierHostRegistered(false)
+{
+#ifndef QT_NO_SYSTEMTRAYICON
+ QDBusInterface systrayHost(StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService, m_connection);
+ if (systrayHost.isValid() && systrayHost.property("IsStatusNotifierHostRegistered").toBool())
+ m_statusNotifierHostRegistered = true;
+ else
+ qCDebug(qLcMenu) << "StatusNotifierHost is not registered";
+#endif
+}
+
+void QDBusMenuConnection::dbusError(const QDBusError &error)
+{
+ qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+}
+
+#ifndef QT_NO_SYSTEMTRAYICON
+bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+{
+ bool success = connection().registerService(item->instanceId());
+ if (!success) {
+ qWarning() << "failed to register service" << item->instanceId();
+ return false;
+ }
+
+ success = connection().registerObject(StatusNotifierItemPath, item);
+ if (!success) {
+ unregisterTrayIcon(item);
+ qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+ return false;
+ }
+
+ if (item->menu()) {
+ success = connection().registerObject(MenuBarPath, item->menu());
+ if (!success) {
+ unregisterTrayIcon(item);
+ qWarning() << "failed to register" << item->instanceId() << MenuBarPath;
+ return false;
+ }
+ }
+
+ QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+ StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+ QLatin1String("RegisterStatusNotifierItem"));
+ registerMethod.setArguments(QVariantList() << item->instanceId());
+ success = m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+
+ return success;
+}
+
+bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+{
+ connection().unregisterObject(MenuBarPath);
+ connection().unregisterObject(StatusNotifierItemPath);
+ bool success = connection().unregisterService(item->instanceId());
+ if (!success)
+ qWarning() << "failed to unregister service" << item->instanceId();
+ return success;
+}
+#endif // QT_NO_SYSTEMTRAYICON
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/dbusmenu/qdbusmenuconnection_p.h b/src/platformsupport/dbusmenu/qdbusmenuconnection_p.h
new file mode 100644
index 0000000000..8d230bd3bf
--- /dev/null
+++ b/src/platformsupport/dbusmenu/qdbusmenuconnection_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 DBUSCONNECTION_H
+#define DBUSCONNECTION_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/QString>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusVariant>
+
+QT_BEGIN_NAMESPACE
+
+class QDBusServiceWatcher;
+#ifndef QT_NO_SYSTEMTRAYICON
+class QDBusTrayIcon;
+#endif // QT_NO_SYSTEMTRAYICON
+
+class QDBusMenuConnection : public QObject
+{
+ Q_OBJECT
+
+public:
+ QDBusMenuConnection(QObject *parent = 0);
+ QDBusConnection connection() const { return m_connection; }
+ bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+#ifndef QT_NO_SYSTEMTRAYICON
+ bool registerTrayIcon(QDBusTrayIcon *item);
+ bool unregisterTrayIcon(QDBusTrayIcon *item);
+#endif // QT_NO_SYSTEMTRAYICON
+
+Q_SIGNALS:
+#ifndef QT_NO_SYSTEMTRAYICON
+ void trayIconRegistered();
+#endif // QT_NO_SYSTEMTRAYICON
+
+private Q_SLOTS:
+ void dbusError(const QDBusError &error);
+
+private:
+ QDBusConnection m_connection;
+ QDBusServiceWatcher *m_dbusWatcher;
+ bool m_statusNotifierHostRegistered;
+};
+
+QT_END_NAMESPACE
+
+#endif // DBUSCONNECTION_H
diff --git a/src/platformsupport/dbusmenu/qdbusmenutypes.cpp b/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
new file mode 100644
index 0000000000..cacc9817de
--- /dev/null
+++ b/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
@@ -0,0 +1,257 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 "qdbusmenutypes_p.h"
+
+#include <QDBusConnection>
+#include <QDBusMetaType>
+#include <QImage>
+#include <QIcon>
+#include <QImage>
+#include <QPixmap>
+#include <QDebug>
+#include <QtEndian>
+#include <QBuffer>
+#include <qpa/qplatformmenu.h>
+#include "qdbusplatformmenu_p.h"
+
+QT_BEGIN_NAMESPACE
+
+const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuItem &item)
+{
+ arg.beginStructure();
+ arg << item.m_id << item.m_properties;
+ arg.endStructure();
+ return arg;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuItem &item)
+{
+ arg.beginStructure();
+ arg >> item.m_id >> item.m_properties;
+ arg.endStructure();
+ return arg;
+}
+
+const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuItemKeys &keys)
+{
+ arg.beginStructure();
+ arg << keys.id << keys.properties;
+ arg.endStructure();
+ return arg;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuItemKeys &keys)
+{
+ arg.beginStructure();
+ arg >> keys.id >> keys.properties;
+ arg.endStructure();
+ return arg;
+}
+
+uint QDBusMenuLayoutItem::populate(int id, int depth, const QStringList &propertyNames)
+{
+ qCDebug(qLcMenu) << id << "depth" << depth << propertyNames;
+ m_id = id;
+ if (id == 0) {
+ m_properties.insert(QLatin1String("children-display"), QLatin1String("submenu"));
+ Q_FOREACH (const QDBusPlatformMenu *menu, QDBusPlatformMenu::topLevelMenus()) {
+ if (menu)
+ Q_FOREACH (const QDBusPlatformMenuItem *item, menu->items()) {
+ QDBusMenuLayoutItem child;
+ child.populate(item, depth - 1, propertyNames);
+ m_children << child;
+ }
+ }
+ } else {
+ // TODO insert menu properties (name-value pairs)
+ }
+ QDBusPlatformMenu *menu = QDBusPlatformMenu::byId(id);
+ if (depth != 0 && menu) {
+ Q_FOREACH (QDBusPlatformMenuItem *item, menu->items()) {
+ QDBusMenuLayoutItem child;
+ child.populate(item, depth - 1, propertyNames);
+ m_children << child;
+ }
+ }
+ if (menu)
+ return menu->revision();
+ return 1;
+}
+
+void QDBusMenuLayoutItem::populate(const QDBusPlatformMenuItem *item, int depth, const QStringList &propertyNames)
+{
+ Q_UNUSED(depth)
+ Q_UNUSED(propertyNames)
+ m_id = item->dbusID();
+ QDBusMenuItem proxy(item);
+ m_properties = proxy.m_properties;
+ // TODO populate m_children
+}
+
+const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuLayoutItem &item)
+{
+ arg.beginStructure();
+ arg << item.m_id << item.m_properties;
+ arg.beginArray(qMetaTypeId<QDBusVariant>());
+ foreach (const QDBusMenuLayoutItem& child, item.m_children)
+ arg << QDBusVariant(QVariant::fromValue<QDBusMenuLayoutItem>(child));
+ arg.endArray();
+ arg.endStructure();
+ return arg;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuLayoutItem &item)
+{
+ arg.beginStructure();
+ arg >> item.m_id >> item.m_properties;
+ arg.beginArray();
+ while (!arg.atEnd()) {
+ QDBusVariant dbusVariant;
+ arg >> dbusVariant;
+ QDBusArgument childArgument = dbusVariant.variant().value<QDBusArgument>();
+
+ QDBusMenuLayoutItem child;
+ childArgument >> child;
+ item.m_children.append(child);
+ }
+ arg.endArray();
+ arg.endStructure();
+ return arg;
+}
+
+void QDBusMenuItem::registerDBusTypes()
+{
+ qDBusRegisterMetaType<QDBusMenuItem>();
+ qDBusRegisterMetaType<QDBusMenuItemList>();
+ qDBusRegisterMetaType<QDBusMenuItemKeys>();
+ qDBusRegisterMetaType<QDBusMenuItemKeysList>();
+ qDBusRegisterMetaType<QDBusMenuLayoutItem>();
+ qDBusRegisterMetaType<QDBusMenuLayoutItemList>();
+ qDBusRegisterMetaType<QDBusMenuEvent>();
+ qDBusRegisterMetaType<QDBusMenuEventList>();
+}
+
+QDBusMenuItem::QDBusMenuItem(const QDBusPlatformMenuItem *item)
+ : m_id(item->dbusID())
+{
+ if (item->isSeparator()) {
+ m_properties.insert(QLatin1String("type"), QLatin1String("separator"));
+ } else {
+ m_properties.insert(QLatin1String("label"), convertMnemonic(item->text()));
+ if (item->menu())
+ m_properties.insert(QLatin1String("children-display"), QLatin1String("submenu"));
+ m_properties.insert(QLatin1String("enabled"), item->isEnabled());
+ if (item->isCheckable()) {
+ // dbusmenu supports "radio" too, but QPlatformMenuItem doesn't seem to
+ // (QAction would have an exclusive actionGroup)
+ m_properties.insert(QLatin1String("toggle-type"), QLatin1String("checkmark"));
+ m_properties.insert(QLatin1String("toggle-state"), item->isChecked() ? 1 : 0);
+ }
+ /* TODO support shortcuts
+ const QKeySequence &scut = item->shortcut();
+ if (!scut.isEmpty()) {
+ QDBusMenuShortcut shortcut(scut);
+ properties.insert(QLatin1String("shortcut"), QVariant::fromValue(shortcut));
+ }
+ */
+ const QIcon &icon = item->icon();
+ if (!icon.name().isEmpty()) {
+ m_properties.insert(QLatin1String("icon-name"), icon.name());
+ } else if (!icon.isNull()) {
+ QBuffer buf;
+ icon.pixmap(16).save(&buf, "PNG");
+ m_properties.insert(QLatin1String("icon-data"), buf.data());
+ }
+ }
+ if (!item->isVisible())
+ m_properties.insert(QLatin1String("visible"), false);
+}
+
+QDBusMenuItemList QDBusMenuItem::items(const QList<int> &ids, const QStringList &propertyNames)
+{
+ Q_UNUSED(propertyNames)
+ QDBusMenuItemList ret;
+ QList<const QDBusPlatformMenuItem *> items = QDBusPlatformMenuItem::byIds(ids);
+ Q_FOREACH (const QDBusPlatformMenuItem *item, items)
+ ret << QDBusMenuItem(item);
+ return ret;
+}
+
+QString QDBusMenuItem::convertMnemonic(const QString &label)
+{
+ // convert only the first occurrence of ampersand which is not at the end
+ // dbusmenu uses underscore instead of ampersand
+ int idx = label.indexOf(QLatin1Char('&'));
+ if (idx < 0 || idx == label.length() - 1)
+ return label;
+ QString ret(label);
+ ret[idx] = QLatin1Char('_');
+ return ret;
+}
+
+const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuEvent &ev)
+{
+ arg.beginStructure();
+ arg << ev.m_id << ev.m_eventId << ev.m_data << ev.m_timestamp;
+ arg.endStructure();
+ return arg;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuEvent &ev)
+{
+ arg.beginStructure();
+ arg >> ev.m_id >> ev.m_eventId >> ev.m_data >> ev.m_timestamp;
+ arg.endStructure();
+ return arg;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const QDBusMenuItem &item)
+{
+ QDebugStateSaver saver(d);
+ d.nospace();
+ d << "QDBusMenuItem(id=" << item.m_id << ", properties=" << item.m_properties << ")";
+ return d;
+}
+
+QDebug operator<<(QDebug d, const QDBusMenuLayoutItem &item)
+{
+ QDebugStateSaver saver(d);
+ d.nospace();
+ d << "QDBusMenuLayoutItem(id=" << item.m_id << ", properties=" << item.m_properties << ", " << item.m_children.count() << " children)";
+ return d;
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/dbusmenu/qdbusmenutypes_p.h b/src/platformsupport/dbusmenu/qdbusmenutypes_p.h
new file mode 100644
index 0000000000..c42aef0b69
--- /dev/null
+++ b/src/platformsupport/dbusmenu/qdbusmenutypes_p.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 QDBUSMENUTYPES_H
+#define QDBUSMENUTYPES_H
+
+#include <QObject>
+#include <QString>
+#include <QDBusArgument>
+#include <QDBusConnection>
+#include <QDBusObjectPath>
+#include <QPixmap>
+
+QT_BEGIN_NAMESPACE
+
+class QDBusPlatformMenu;
+class QDBusPlatformMenuItem;
+class QDBusMenuItem;
+typedef QList<QDBusMenuItem> QDBusMenuItemList;
+
+class QDBusMenuItem
+{
+public:
+ QDBusMenuItem() { }
+ QDBusMenuItem(const QDBusPlatformMenuItem *item);
+
+ static QDBusMenuItemList items(const QList<int> &ids, const QStringList &propertyNames);
+ static QString convertMnemonic(const QString &label);
+ static void registerDBusTypes();
+
+ int m_id;
+ QVariantMap m_properties;
+};
+
+const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuItem &item);
+const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuItem &item);
+
+class QDBusMenuItemKeys
+{
+public:
+
+ int id;
+ QStringList properties;
+};
+
+const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuItemKeys &keys);
+const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuItemKeys &keys);
+
+typedef QList<QDBusMenuItemKeys> QDBusMenuItemKeysList;
+
+class QDBusMenuLayoutItem
+{
+public:
+ uint populate(int id, int depth, const QStringList &propertyNames);
+ void populate(const QDBusPlatformMenuItem *item, int depth, const QStringList &propertyNames);
+
+ int m_id;
+ QVariantMap m_properties;
+ QList<QDBusMenuLayoutItem> m_children;
+};
+
+const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuLayoutItem &);
+const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuLayoutItem &item);
+
+typedef QList<QDBusMenuLayoutItem> QDBusMenuLayoutItemList;
+
+class QDBusMenuEvent
+{
+public:
+ int m_id;
+ QString m_eventId;
+ QDBusVariant m_data;
+ uint m_timestamp;
+};
+
+const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuEvent &ev);
+const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuEvent &ev);
+
+typedef QList<QDBusMenuEvent> QDBusMenuEventList;
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const QDBusMenuItem &item);
+QDebug operator<<(QDebug d, const QDBusMenuLayoutItem &item);
+#endif
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDBusMenuItem)
+Q_DECLARE_METATYPE(QDBusMenuItemList)
+Q_DECLARE_METATYPE(QDBusMenuItemKeys)
+Q_DECLARE_METATYPE(QDBusMenuItemKeysList)
+Q_DECLARE_METATYPE(QDBusMenuLayoutItem)
+Q_DECLARE_METATYPE(QDBusMenuLayoutItemList)
+Q_DECLARE_METATYPE(QDBusMenuEvent)
+Q_DECLARE_METATYPE(QDBusMenuEventList)
+
+#endif
diff --git a/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp b/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp
new file mode 100644
index 0000000000..581daf97ac
--- /dev/null
+++ b/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp
@@ -0,0 +1,249 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 "qdbusplatformmenu_p.h"
+
+#include <QDebug>
+#include <QWindow>
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(qLcMenu, "qt.qpa.menu")
+
+static int nextDBusID = 1;
+QHash<int, QDBusPlatformMenu *> menusByID;
+QHash<int, QDBusPlatformMenuItem *> menuItemsByID;
+
+QDBusPlatformMenuItem::QDBusPlatformMenuItem(quintptr tag)
+ : m_tag(tag ? tag : reinterpret_cast<quintptr>(this)) // QMenu will overwrite this later
+ , m_subMenu(Q_NULLPTR)
+ , m_role(NoRole)
+ , m_isEnabled(false)
+ , m_isVisible(true)
+ , m_isSeparator(false)
+ , m_isCheckable(false)
+ , m_isChecked(false)
+ , m_dbusID(nextDBusID++)
+{
+ menuItemsByID.insert(m_dbusID, this);
+}
+
+void QDBusPlatformMenuItem::setTag(quintptr tag)
+{
+ m_tag = tag;
+}
+
+void QDBusPlatformMenuItem::setText(const QString &text)
+{
+ qCDebug(qLcMenu) << m_dbusID << text;
+ m_text = text;
+}
+
+void QDBusPlatformMenuItem::setIcon(const QIcon &icon)
+{
+ m_icon = icon;
+}
+
+void QDBusPlatformMenuItem::setMenu(QPlatformMenu *menu)
+{
+ m_subMenu = static_cast<QDBusPlatformMenu *>(menu);
+}
+
+void QDBusPlatformMenuItem::setEnabled(bool enabled)
+{
+ m_isEnabled = enabled;
+}
+
+void QDBusPlatformMenuItem::setVisible(bool isVisible)
+{
+ m_isVisible = isVisible;
+}
+
+void QDBusPlatformMenuItem::setIsSeparator(bool isSeparator)
+{
+ m_isSeparator = isSeparator;
+}
+
+void QDBusPlatformMenuItem::setRole(QPlatformMenuItem::MenuRole role)
+{
+ m_role = role;
+}
+
+void QDBusPlatformMenuItem::setCheckable(bool checkable)
+{
+ m_isCheckable = checkable;
+}
+
+void QDBusPlatformMenuItem::setChecked(bool isChecked)
+{
+ m_isChecked = isChecked;
+}
+
+void QDBusPlatformMenuItem::setShortcut(const QKeySequence &shortcut)
+{
+ m_shortcut = shortcut;
+}
+
+void QDBusPlatformMenuItem::trigger()
+{
+ emit activated();
+}
+
+QDBusPlatformMenuItem *QDBusPlatformMenuItem::byId(int id)
+{
+ return menuItemsByID[id];
+}
+
+QList<const QDBusPlatformMenuItem *> QDBusPlatformMenuItem::byIds(const QList<int> &ids)
+{
+ QList<const QDBusPlatformMenuItem *> ret;
+ Q_FOREACH (int id, ids) {
+ if (menuItemsByID.contains(id))
+ ret << menuItemsByID[id];
+ }
+ return ret;
+}
+
+
+QDBusPlatformMenu::QDBusPlatformMenu(quintptr tag)
+ : m_tag(tag ? tag : reinterpret_cast<quintptr>(this))
+ , m_isEnabled(false)
+ , m_isVisible(true)
+ , m_isSeparator(false)
+ , m_dbusID(nextDBusID++)
+ , m_revision(0)
+{
+ menusByID.insert(m_dbusID, this);
+}
+
+QDBusPlatformMenu::~QDBusPlatformMenu()
+{
+ menusByID.remove(m_dbusID);
+}
+
+void QDBusPlatformMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before)
+{
+ QDBusPlatformMenuItem *item = static_cast<QDBusPlatformMenuItem *>(menuItem);
+ QDBusPlatformMenuItem *beforeItem = static_cast<QDBusPlatformMenuItem *>(before);
+ int idx = m_items.indexOf(beforeItem);
+ qCDebug(qLcMenu) << item->dbusID() << item->text();
+ if (idx < 0)
+ m_items.append(item);
+ else
+ m_items.insert(idx, item);
+ m_itemsByTag.insert(item->tag(), item);
+}
+
+void QDBusPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem)
+{
+ m_items.removeAll(static_cast<QDBusPlatformMenuItem *>(menuItem));
+ m_itemsByTag.remove(menuItem->tag());
+}
+
+void QDBusPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem)
+{
+ // TODO keep around copies of the QDBusMenuLayoutItems so they can be updated?
+ // or eliminate them by putting dbus streaming operators in this class instead?
+ // or somehow tell the dbusmenu client that something has changed, so it will ask for properties again
+ emitUpdated();
+ QDBusMenuItemList updated;
+ QDBusMenuItemKeysList removed;
+ updated << QDBusMenuItem(static_cast<QDBusPlatformMenuItem *>(menuItem));
+ qCDebug(qLcMenu) << updated;
+ emit propertiesUpdated(updated, removed);
+}
+
+QDBusPlatformMenu *QDBusPlatformMenu::byId(int id)
+{
+ return menusByID[id];
+}
+
+QList<QDBusPlatformMenu *> QDBusPlatformMenu::topLevelMenus()
+{
+ // TODO just the top-level menus, not all menus
+ return menusByID.values();
+}
+
+void QDBusPlatformMenu::emitUpdated()
+{
+ emit updated(++m_revision, m_dbusID);
+}
+
+void QDBusPlatformMenu::setTag(quintptr tag)
+{
+ m_tag = tag;
+}
+
+void QDBusPlatformMenu::setText(const QString &text)
+{
+ m_text = text;
+}
+
+void QDBusPlatformMenu::setIcon(const QIcon &icon)
+{
+ m_icon = icon;
+}
+
+void QDBusPlatformMenu::setEnabled(bool enabled)
+{
+ m_isEnabled = enabled;
+}
+
+void QDBusPlatformMenu::setVisible(bool isVisible)
+{
+ m_isVisible = isVisible;
+}
+
+QPlatformMenuItem *QDBusPlatformMenu::menuItemAt(int position) const
+{
+ return m_items.at(position);
+}
+
+QPlatformMenuItem *QDBusPlatformMenu::menuItemForTag(quintptr tag) const
+{
+ return m_itemsByTag[tag];
+}
+
+const QList<QDBusPlatformMenuItem *> QDBusPlatformMenu::items() const
+{
+ return m_items;
+}
+
+QPlatformMenuItem *QDBusPlatformMenu::createMenuItem() const
+{
+ QDBusPlatformMenuItem *ret = new QDBusPlatformMenuItem();
+ ret->setMenu(const_cast<QDBusPlatformMenu *>(this));
+ return ret;
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h b/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h
new file mode 100644
index 0000000000..c211a75419
--- /dev/null
+++ b/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h
@@ -0,0 +1,181 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 QDBUSPLATFORMMENU_H
+#define QDBUSPLATFORMMENU_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is part of the DBus menu support and is not meant to be used
+// in applications. Usage of this API may make your code
+// source and binary incompatible with future versions of Qt.
+//
+
+#include <qpa/qplatformmenu.h>
+#include <QLoggingCategory>
+#include "qdbusmenutypes_p.h"
+
+QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(qLcMenu)
+
+class QDBusPlatformMenu;
+
+class QDBusPlatformMenuItem : public QPlatformMenuItem
+{
+ Q_OBJECT
+
+public:
+ QDBusPlatformMenuItem(quintptr tag = 0LL);
+
+ quintptr tag()const Q_DECL_OVERRIDE { return m_tag; }
+ void setTag(quintptr tag) Q_DECL_OVERRIDE;
+
+ const QString text() const { return m_text; }
+ void setText(const QString &text) Q_DECL_OVERRIDE;
+ QIcon icon() const { return m_icon; }
+ void setIcon(const QIcon &icon) Q_DECL_OVERRIDE;
+ const QPlatformMenu *menu() const { return m_subMenu; }
+ void setMenu(QPlatformMenu *menu) Q_DECL_OVERRIDE;
+ bool isEnabled() const { return m_isEnabled; }
+ void setEnabled(bool enabled) Q_DECL_OVERRIDE;
+ bool isVisible() const { return m_isVisible; }
+ void setVisible(bool isVisible) Q_DECL_OVERRIDE;
+ bool isSeparator() const { return m_isSeparator; }
+ void setIsSeparator(bool isSeparator) Q_DECL_OVERRIDE;
+ void setFont(const QFont &font) Q_DECL_OVERRIDE { Q_UNUSED(font); }
+ void setRole(MenuRole role) Q_DECL_OVERRIDE;
+ bool isCheckable() const { return m_isCheckable; }
+ void setCheckable(bool checkable) Q_DECL_OVERRIDE;
+ bool isChecked() const { return m_isChecked; }
+ void setChecked(bool isChecked) Q_DECL_OVERRIDE;
+ QKeySequence shortcut() const { return m_shortcut; }
+ void setShortcut(const QKeySequence& shortcut) Q_DECL_OVERRIDE;
+ void setIconSize(int size) Q_DECL_OVERRIDE { Q_UNUSED(size); }
+ void setNativeContents(WId item) Q_DECL_OVERRIDE { Q_UNUSED(item); }
+
+ int dbusID() const { return m_dbusID; }
+
+ void trigger();
+
+ bool operator==(const QDBusPlatformMenuItem& other) { return m_tag == other.m_tag; }
+
+ static QDBusPlatformMenuItem *byId(int id);
+ static QList<const QDBusPlatformMenuItem *> byIds(const QList<int> &ids);
+
+private:
+ quintptr m_tag;
+ QString m_text;
+ QIcon m_icon;
+ QPlatformMenu *m_subMenu;
+ MenuRole m_role : 4;
+ bool m_isEnabled : 1;
+ bool m_isVisible : 1;
+ bool m_isSeparator : 1;
+ bool m_isCheckable : 1;
+ bool m_isChecked : 1;
+ int m_dbusID : 16;
+ int m_reserved : 7;
+ QKeySequence m_shortcut;
+};
+
+class QDBusPlatformMenu : public QPlatformMenu
+{
+ Q_OBJECT
+
+public:
+ QDBusPlatformMenu(quintptr tag = 0LL);
+ ~QDBusPlatformMenu();
+ void insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) Q_DECL_OVERRIDE;
+ void removeMenuItem(QPlatformMenuItem *menuItem) Q_DECL_OVERRIDE;
+ void syncMenuItem(QPlatformMenuItem *menuItem) Q_DECL_OVERRIDE;
+ void syncSeparatorsCollapsible(bool enable) Q_DECL_OVERRIDE { Q_UNUSED(enable); }
+
+ quintptr tag()const Q_DECL_OVERRIDE { return m_tag; }
+ void setTag(quintptr tag) Q_DECL_OVERRIDE;
+
+ const QString text() { return m_text; }
+ void setText(const QString &text) Q_DECL_OVERRIDE;
+ void setIcon(const QIcon &icon) Q_DECL_OVERRIDE;
+ void setEnabled(bool enabled) Q_DECL_OVERRIDE;
+ void setVisible(bool visible) Q_DECL_OVERRIDE;
+ void setMinimumWidth(int width) Q_DECL_OVERRIDE { Q_UNUSED(width); }
+ void setFont(const QFont &font) Q_DECL_OVERRIDE { Q_UNUSED(font); }
+ void setMenuType(MenuType type) Q_DECL_OVERRIDE { Q_UNUSED(type); }
+
+ void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) Q_DECL_OVERRIDE
+ {
+ Q_UNUSED(parentWindow);
+ Q_UNUSED(targetRect);
+ Q_UNUSED(item);
+ setVisible(true);
+ }
+
+ void dismiss() Q_DECL_OVERRIDE { } // Closes this and all its related menu popups
+
+ QPlatformMenuItem *menuItemAt(int position) const Q_DECL_OVERRIDE;
+ QPlatformMenuItem *menuItemForTag(quintptr tag) const Q_DECL_OVERRIDE;
+ const QList<QDBusPlatformMenuItem *> items() const;
+
+ QPlatformMenuItem *createMenuItem() const Q_DECL_OVERRIDE;
+
+ bool operator==(const QDBusPlatformMenu& other) { return m_tag == other.m_tag; }
+
+ static QDBusPlatformMenu* byId(int id);
+ static QList<QDBusPlatformMenu *> topLevelMenus();
+
+ uint revision() { return m_revision; }
+
+ void emitUpdated();
+
+signals:
+ void updated(uint revision, int dbusId);
+ void propertiesUpdated(QDBusMenuItemList updatedProps, QDBusMenuItemKeysList removedProps);
+
+private:
+ quintptr m_tag;
+ QString m_text;
+ QIcon m_icon;
+ bool m_isEnabled;
+ bool m_isVisible;
+ bool m_isSeparator;
+ int m_dbusID;
+ uint m_revision;
+ QHash<quintptr, QDBusPlatformMenuItem *> m_itemsByTag;
+ QList<QDBusPlatformMenuItem *> m_items;
+};
+
+QT_END_NAMESPACE
+
+#endif
+
diff --git a/src/platformsupport/dbustray/dbustray.pri b/src/platformsupport/dbustray/dbustray.pri
new file mode 100644
index 0000000000..734ee5fb40
--- /dev/null
+++ b/src/platformsupport/dbustray/dbustray.pri
@@ -0,0 +1,15 @@
+QT_FOR_PRIVATE += dbus
+
+INCLUDEPATH += $$PWD $$PWD/../../gui/kernel
+
+HEADERS += \
+ $$PWD/qdbustrayicon_p.h \
+ $$PWD/qdbustraytypes_p.h \
+ $$PWD/qstatusnotifieritemadaptor_p.h \
+ $$PWD/qxdgnotificationproxy_p.h \
+
+SOURCES += \
+ $$PWD/qdbustrayicon.cpp \
+ $$PWD/qdbustraytypes.cpp \
+ $$PWD/qstatusnotifieritemadaptor.cpp \
+ $$PWD/qxdgnotificationproxy.cpp \
diff --git a/src/platformsupport/dbustray/qdbustrayicon.cpp b/src/platformsupport/dbustray/qdbustrayicon.cpp
new file mode 100644
index 0000000000..61849024da
--- /dev/null
+++ b/src/platformsupport/dbustray/qdbustrayicon.cpp
@@ -0,0 +1,293 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 QT_NO_SYSTEMTRAYICON
+
+#include "qdbustrayicon_p.h"
+#include "qdbusmenuconnection_p.h"
+#include "qstatusnotifieritemadaptor_p.h"
+#include "qdbusmenuadaptor_p.h"
+#include "dbusmenu/qdbusplatformmenu_p.h"
+#include "qxdgnotificationproxy_p.h"
+
+#include <qplatformmenu.h>
+#include <qstring.h>
+#include <qdebug.h>
+#include <qrect.h>
+#include <qloggingcategory.h>
+#include <qplatformintegration.h>
+#include <qplatformservices.h>
+#include <private/qguiapplication_p.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+
+static const QString KDEItemFormat = QStringLiteral("org.kde.StatusNotifierItem-%1-%2");
+static const QString TempFileTemplate = QDir::tempPath() + QStringLiteral("/qt-trayicon-XXXXXX.png");
+static const QString XdgNotificationService = QStringLiteral("org.freedesktop.Notifications");
+static const QString XdgNotificationPath = QStringLiteral("/org/freedesktop/Notifications");
+static const QString DefaultAction = QStringLiteral("default");
+static int instanceCount = 0;
+
+/*!
+ \class QDBusTrayIcon
+ \internal
+*/
+
+QDBusTrayIcon::QDBusTrayIcon()
+ : m_dbusConnection(Q_NULLPTR)
+ , m_adaptor(new QStatusNotifierItemAdaptor(this))
+ , m_menuAdaptor(Q_NULLPTR)
+ , m_menu(Q_NULLPTR)
+ , m_notifier(Q_NULLPTR)
+ , m_instanceId(KDEItemFormat.arg(QCoreApplication::applicationPid()).arg(++instanceCount))
+ , m_category(QStringLiteral("ApplicationStatus"))
+ , m_defaultStatus(QStringLiteral("Active")) // be visible all the time. QSystemTrayIcon has no API to control this.
+ , m_status(m_defaultStatus)
+ , m_tempIcon(Q_NULLPTR)
+ , m_tempAttentionIcon(Q_NULLPTR)
+ , m_registered(false)
+{
+ qCDebug(qLcTray);
+ if (instanceCount == 1) {
+ QDBusMenuItem::registerDBusTypes();
+ qDBusRegisterMetaType<QXdgDBusImageStruct>();
+ qDBusRegisterMetaType<QXdgDBusImageVector>();
+ qDBusRegisterMetaType<QXdgDBusToolTipStruct>();
+ }
+ connect(this, SIGNAL(statusChanged(QString)), m_adaptor, SIGNAL(NewStatus(QString)));
+ connect(this, SIGNAL(tooltipChanged()), m_adaptor, SIGNAL(NewToolTip()));
+ connect(this, SIGNAL(iconChanged()), m_adaptor, SIGNAL(NewIcon()));
+ connect(this, SIGNAL(attention()), m_adaptor, SIGNAL(NewAttentionIcon()));
+ connect(this, SIGNAL(attention()), m_adaptor, SIGNAL(NewTitle()));
+ connect(&m_attentionTimer, SIGNAL(timeout()), this, SLOT(attentionTimerExpired()));
+ m_attentionTimer.setSingleShot(true);
+}
+
+QDBusTrayIcon::~QDBusTrayIcon()
+{
+}
+
+void QDBusTrayIcon::init()
+{
+ qCDebug(qLcTray) << "registering" << m_instanceId;
+ m_registered = dBusConnection()->registerTrayIcon(this);
+}
+
+void QDBusTrayIcon::cleanup()
+{
+ qCDebug(qLcTray) << "unregistering" << m_instanceId;
+ if (m_registered)
+ dBusConnection()->unregisterTrayIcon(this);
+ delete m_dbusConnection;
+ m_dbusConnection = Q_NULLPTR;
+ m_registered = false;
+}
+
+void QDBusTrayIcon::activate(int x, int y)
+{
+ qCDebug(qLcTray) << x << y;
+ setStatus(QStringLiteral("Active"));
+}
+
+void QDBusTrayIcon::attentionTimerExpired()
+{
+ m_messageTitle = QString();
+ m_message = QString();
+ m_attentionIcon = QIcon();
+ emit attention();
+ emit tooltipChanged();
+ setStatus(m_defaultStatus);
+}
+
+void QDBusTrayIcon::setStatus(const QString &status)
+{
+ qCDebug(qLcTray) << status;
+ if (m_status == status)
+ return;
+ m_status = status;
+ emit statusChanged(m_status);
+}
+
+QTemporaryFile *QDBusTrayIcon::tempIcon(const QIcon &icon)
+{
+ // Hack for Unity, which doesn't handle icons sent across D-Bus:
+ // save the icon to a temp file and set the icon name to that filename.
+ static bool necessary = (QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment().split(':').contains("UNITY"));
+ if (!necessary)
+ return Q_NULLPTR;
+ QTemporaryFile *ret = new QTemporaryFile(TempFileTemplate, this);
+ ret->open();
+ icon.pixmap(QSize(22, 22)).save(ret);
+ ret->close();
+ return ret;
+}
+
+QDBusMenuConnection * QDBusTrayIcon::dBusConnection()
+{
+ if (!m_dbusConnection) {
+ m_dbusConnection = new QDBusMenuConnection(this);
+ m_notifier = new QXdgNotificationInterface(XdgNotificationService,
+ XdgNotificationPath, m_dbusConnection->connection(), this);
+ connect(m_notifier, SIGNAL(NotificationClosed(uint,uint)), this, SLOT(notificationClosed(uint,uint)));
+ connect(m_notifier, SIGNAL(ActionInvoked(uint,QString)), this, SLOT(actionInvoked(uint,QString)));
+ }
+ return m_dbusConnection;
+}
+
+void QDBusTrayIcon::updateIcon(const QIcon &icon)
+{
+ m_iconName = icon.name();
+ m_icon = icon;
+ if (m_iconName.isEmpty()) {
+ if (m_tempIcon)
+ delete m_tempIcon;
+ m_tempIcon = tempIcon(icon);
+ if (m_tempIcon)
+ m_iconName = m_tempIcon->fileName();
+ }
+ qCDebug(qLcTray) << m_iconName << icon.availableSizes();
+ emit iconChanged();
+}
+
+void QDBusTrayIcon::updateToolTip(const QString &tooltip)
+{
+ qCDebug(qLcTray) << tooltip;
+ m_tooltip = tooltip;
+ emit tooltipChanged();
+}
+
+QPlatformMenu *QDBusTrayIcon::createMenu() const
+{
+ qCDebug(qLcTray);
+ if (!m_menu)
+ const_cast<QDBusTrayIcon *>(this)->m_menu = new QDBusPlatformMenu();
+ return m_menu;
+}
+
+void QDBusTrayIcon::updateMenu(QPlatformMenu * menu)
+{
+ qCDebug(qLcTray) << menu;
+ if (!m_menu)
+ m_menu = qobject_cast<QDBusPlatformMenu *>(menu);
+ if (!m_menuAdaptor) {
+ m_menuAdaptor = new QDBusMenuAdaptor(m_menu);
+ // TODO connect(m_menu, , m_menuAdaptor, SIGNAL(ItemActivationRequested(int,uint)));
+ connect(m_menu, SIGNAL(propertiesUpdated(QDBusMenuItemList,QDBusMenuItemKeysList)),
+ m_menuAdaptor, SIGNAL(ItemsPropertiesUpdated(QDBusMenuItemList,QDBusMenuItemKeysList)));
+ connect(m_menu, SIGNAL(updated(uint,int)),
+ m_menuAdaptor, SIGNAL(LayoutUpdated(uint,int)));
+ }
+ m_menu->emitUpdated();
+}
+
+void QDBusTrayIcon::contextMenu(int x, int y)
+{
+ qCDebug(qLcTray) << x << y;
+}
+
+void QDBusTrayIcon::showMessage(const QString &title, const QString &msg, const QIcon &icon,
+ QPlatformSystemTrayIcon::MessageIcon iconType, int msecs)
+{
+ m_messageTitle = title;
+ m_message = msg;
+ m_attentionIcon = icon;
+ QStringList notificationActions;
+ switch (iconType) {
+ case Information:
+ m_attentionIconName = QStringLiteral("dialog-information");
+ break;
+ case Warning:
+ m_attentionIconName = QStringLiteral("dialog-warning");
+ break;
+ case Critical:
+ m_attentionIconName = QStringLiteral("dialog-error");
+ // If there are actions, the desktop notification may appear as a message dialog
+ // with button(s), which will interrupt the user and require a response.
+ // That is an optional feature in implementations of org.freedesktop.Notifications
+ notificationActions << DefaultAction << tr("OK");
+ break;
+ default:
+ m_attentionIconName.clear();
+ break;
+ }
+ if (m_attentionIconName.isEmpty()) {
+ if (m_tempAttentionIcon)
+ delete m_tempAttentionIcon;
+ m_tempAttentionIcon = tempIcon(icon);
+ if (m_tempAttentionIcon)
+ m_attentionIconName = m_tempAttentionIcon->fileName();
+ }
+ qCDebug(qLcTray) << title << msg <<
+ QPlatformSystemTrayIcon::metaObject()->enumerator(
+ QPlatformSystemTrayIcon::staticMetaObject.indexOfEnumerator("MessageIcon")).valueToKey(iconType)
+ << m_attentionIconName << msecs;
+ setStatus(QStringLiteral("NeedsAttention"));
+ m_attentionTimer.start(msecs);
+ emit tooltipChanged();
+ emit attention();
+
+ // Desktop notification
+ QVariantMap hints;
+ // urgency levels according to https://developer.gnome.org/notification-spec/#urgency-levels
+ // 0 low, 1 normal, 2 critical
+ int urgency = static_cast<int>(iconType) - 1;
+ if (urgency < 0) // no icon
+ urgency = 0;
+ hints.insert(QLatin1String("urgency"), QVariant(urgency));
+ m_notifier->notify(QCoreApplication::applicationName(), 0,
+ m_attentionIconName, title, msg, notificationActions, hints, msecs);
+}
+
+void QDBusTrayIcon::actionInvoked(uint id, const QString &action)
+{
+ qCDebug(qLcTray) << id << action;
+ emit messageClicked();
+}
+
+void QDBusTrayIcon::notificationClosed(uint id, uint reason)
+{
+ qCDebug(qLcTray) << id << reason;
+}
+
+bool QDBusTrayIcon::isSystemTrayAvailable() const
+{
+ QDBusMenuConnection * conn = const_cast<QDBusTrayIcon *>(this)->dBusConnection();
+ qCDebug(qLcTray) << conn->isStatusNotifierHostRegistered();
+ return conn->isStatusNotifierHostRegistered();
+}
+
+QT_END_NAMESPACE
+#endif //QT_NO_SYSTEMTRAYICON
+
diff --git a/src/platformsupport/dbustray/qdbustrayicon_p.h b/src/platformsupport/dbustray/qdbustrayicon_p.h
new file mode 100644
index 0000000000..78dfae7c02
--- /dev/null
+++ b/src/platformsupport/dbustray/qdbustrayicon_p.h
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 QDBUSTRAYICON_H
+#define QDBUSTRAYICON_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.
+//
+
+#ifndef QT_NO_SYSTEMTRAYICON
+
+#include <QIcon>
+#include <QTemporaryFile>
+#include <QTimer>
+#include "QtGui/qpa/qplatformsystemtrayicon.h"
+#include "private/qdbusmenuconnection_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QStatusNotifierItemAdaptor;
+class QDBusMenuAdaptor;
+class QDBusPlatformMenu;
+class QXdgNotificationInterface;
+
+class QDBusTrayIcon: public QPlatformSystemTrayIcon
+{
+ Q_OBJECT
+ Q_PROPERTY(QString category READ category NOTIFY categoryChanged)
+ Q_PROPERTY(QString status READ status NOTIFY statusChanged)
+ Q_PROPERTY(QString tooltip READ tooltip NOTIFY tooltipChanged)
+ Q_PROPERTY(QString iconName READ iconName NOTIFY iconChanged)
+ Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
+ Q_PROPERTY(bool isRequestingAttention READ isRequestingAttention NOTIFY attention)
+ Q_PROPERTY(QString attentionTitle READ attentionTitle NOTIFY attention)
+ Q_PROPERTY(QString attentionMessage READ attentionMessage NOTIFY attention)
+ Q_PROPERTY(QString attentionIconName READ attentionIconName NOTIFY attention)
+ Q_PROPERTY(QIcon attentionIcon READ attentionIcon NOTIFY attention)
+ Q_PROPERTY(QDBusPlatformMenu *menu READ menu NOTIFY menuChanged)
+
+public:
+ QDBusTrayIcon();
+
+ virtual ~QDBusTrayIcon();
+
+ QDBusMenuConnection * dBusConnection();
+
+ void init() Q_DECL_OVERRIDE;
+ void cleanup() Q_DECL_OVERRIDE;
+ void updateIcon(const QIcon &icon) Q_DECL_OVERRIDE;
+ void updateToolTip(const QString &tooltip) Q_DECL_OVERRIDE;
+ void updateMenu(QPlatformMenu *menu) Q_DECL_OVERRIDE;
+ QPlatformMenu *createMenu() const Q_DECL_OVERRIDE;
+ void showMessage(const QString &title, const QString &msg,
+ const QIcon &icon, MessageIcon iconType, int msecs) Q_DECL_OVERRIDE;
+
+ bool isSystemTrayAvailable() const Q_DECL_OVERRIDE;
+ bool supportsMessages() const Q_DECL_OVERRIDE { return true; }
+ QRect geometry() const Q_DECL_OVERRIDE { return QRect(); }
+
+ QString category() const { return m_category; }
+ QString status() const { return m_status; }
+ QString tooltip() const { return m_tooltip; }
+
+ QString iconName() const { return m_iconName; }
+ const QIcon & icon() const { return m_icon; }
+
+ bool isRequestingAttention() const { return m_attentionTimer.isActive(); }
+ QString attentionTitle() const { return m_messageTitle; }
+ QString attentionMessage() const { return m_message; }
+ QString attentionIconName() const { return m_attentionIconName; }
+ const QIcon & attentionIcon() const { return m_attentionIcon; }
+
+ QString instanceId() const { return m_instanceId; }
+
+ QDBusPlatformMenu *menu() { return m_menu; }
+
+public Q_SLOTS:
+ void activate(int x, int y);
+ void contextMenu(int x, int y);
+
+signals:
+ void categoryChanged();
+ void statusChanged(QString arg);
+ void tooltipChanged();
+ void iconChanged();
+ void attention();
+ void menuChanged();
+
+private Q_SLOTS:
+ void attentionTimerExpired();
+ void actionInvoked(uint id, const QString &action);
+ void notificationClosed(uint id, uint reason);
+
+private:
+ void setStatus(const QString &status);
+ QTemporaryFile *tempIcon(const QIcon &icon);
+
+private:
+ QDBusMenuConnection* m_dbusConnection;
+ QStatusNotifierItemAdaptor *m_adaptor;
+ QDBusMenuAdaptor *m_menuAdaptor;
+ QDBusPlatformMenu *m_menu;
+ QXdgNotificationInterface *m_notifier;
+ QString m_instanceId;
+ QString m_category;
+ QString m_defaultStatus;
+ QString m_status;
+ QString m_tooltip;
+ QString m_messageTitle;
+ QString m_message;
+ QIcon m_icon;
+ QTemporaryFile *m_tempIcon;
+ QString m_iconName;
+ QIcon m_attentionIcon;
+ QTemporaryFile *m_tempAttentionIcon;
+ QString m_attentionIconName;
+ QTimer m_attentionTimer;
+ bool m_isRequestingAttention;
+ bool m_hasMenu;
+ bool m_registered;
+};
+
+QT_END_NAMESPACE
+#endif // QT_NO_SYSTEMTRAYICON
+
+#endif // QDBUSTRAYICON_H
diff --git a/src/platformsupport/dbustray/qdbustraytypes.cpp b/src/platformsupport/dbustray/qdbustraytypes.cpp
new file mode 100644
index 0000000000..7b7d31b7c3
--- /dev/null
+++ b/src/platformsupport/dbustray/qdbustraytypes.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Marco Martin <notmart@gmail.com>
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 QT_NO_SYSTEMTRAYICON
+
+#include "qdbustraytypes_p.h"
+
+#include <QDBusConnection>
+#include <QDBusMetaType>
+#include <QImage>
+#include <QIcon>
+#include <QImage>
+#include <QPixmap>
+#include <QDebug>
+#include <QtEndian>
+#include <QPainter>
+#include <QGuiApplication>
+#include <qpa/qplatformmenu.h>
+#include "qdbusplatformmenu_p.h"
+
+QT_BEGIN_NAMESPACE
+
+static const int IconSizeLimit = 64;
+static const int IconNormalSmallSize = 22;
+static const int IconNormalMediumSize = 64;
+
+QXdgDBusImageVector iconToQXdgDBusImageVector(const QIcon &icon)
+{
+ QXdgDBusImageVector ret;
+ QList<QSize> sizes = icon.availableSizes();
+
+ // Omit any size larger than 64 px, to save D-Bus bandwidth;
+ // ensure that 22px or smaller exists, because it's a common size;
+ // and ensure that something between 22px and 64px exists, for better scaling to other sizes.
+ bool hasSmallIcon = false;
+ bool hasMediumIcon = false;
+ qreal dpr = qGuiApp->devicePixelRatio();
+ QList<QSize> toRemove;
+ Q_FOREACH (const QSize &size, sizes) {
+ int maxSize = qMax(size.width(), size.height());
+ if (maxSize <= IconNormalSmallSize * dpr)
+ hasSmallIcon = true;
+ else if (maxSize <= IconNormalMediumSize * dpr)
+ hasMediumIcon = true;
+ else if (maxSize > IconSizeLimit * dpr)
+ toRemove << size;
+ }
+ Q_FOREACH (const QSize &size, toRemove)
+ sizes.removeOne(size);
+ if (!hasSmallIcon)
+ sizes.append(QSize(IconNormalSmallSize * dpr, IconNormalSmallSize * dpr));
+ if (!hasMediumIcon)
+ sizes.append(QSize(IconNormalMediumSize * dpr, IconNormalMediumSize * dpr));
+ foreach (QSize size, sizes) {
+ // Protocol specifies ARGB32 format in network byte order
+ QImage im = icon.pixmap(size).toImage().convertToFormat(QImage::Format_ARGB32);
+ // letterbox if necessary to make it square
+ if (im.height() != im.width()) {
+ int maxSize = qMax(im.width(), im.height());
+ QImage padded(maxSize, maxSize, QImage::Format_ARGB32);
+ padded.fill(Qt::transparent);
+ QPainter painter(&padded);
+ painter.drawImage((maxSize - im.width()) / 2, (maxSize - im.height()) / 2, im);
+ im = padded;
+ }
+ // copy and endian-convert
+ QXdgDBusImageStruct kim(im.width(), im.height());
+ const uchar *end = im.constBits() + im.byteCount();
+ uchar *dest = reinterpret_cast<uchar *>(kim.data.data());
+ for (const uchar *src = im.constBits(); src < end; src += 4, dest += 4)
+ qToUnaligned(qToBigEndian<quint32>(qFromUnaligned<quint32>(src)), dest);
+
+ ret << kim;
+ }
+ return ret;
+}
+
+// Marshall the ImageStruct data into a D-Bus argument
+const QDBusArgument &operator<<(QDBusArgument &argument, const QXdgDBusImageStruct &icon)
+{
+ argument.beginStructure();
+ argument << icon.width;
+ argument << icon.height;
+ argument << icon.data;
+ argument.endStructure();
+ return argument;
+}
+
+// Retrieve the ImageStruct data from the D-Bus argument
+const QDBusArgument &operator>>(const QDBusArgument &argument, QXdgDBusImageStruct &icon)
+{
+ qint32 width;
+ qint32 height;
+ QByteArray data;
+
+ argument.beginStructure();
+ argument >> width;
+ argument >> height;
+ argument >> data;
+ argument.endStructure();
+
+ icon.width = width;
+ icon.height = height;
+ icon.data = data;
+
+ return argument;
+}
+
+// Marshall the ImageVector data into a D-Bus argument
+const QDBusArgument &operator<<(QDBusArgument &argument, const QXdgDBusImageVector &iconVector)
+{
+ argument.beginArray(qMetaTypeId<QXdgDBusImageStruct>());
+ for (int i = 0; i < iconVector.size(); ++i) {
+ argument << iconVector[i];
+ }
+ argument.endArray();
+ return argument;
+}
+
+// Retrieve the ImageVector data from the D-Bus argument
+const QDBusArgument &operator>>(const QDBusArgument &argument, QXdgDBusImageVector &iconVector)
+{
+ argument.beginArray();
+ iconVector.clear();
+
+ while (!argument.atEnd()) {
+ QXdgDBusImageStruct element;
+ argument >> element;
+ iconVector.append(element);
+ }
+
+ argument.endArray();
+
+ return argument;
+}
+
+// Marshall the ToolTipStruct data into a D-Bus argument
+const QDBusArgument &operator<<(QDBusArgument &argument, const QXdgDBusToolTipStruct &toolTip)
+{
+ argument.beginStructure();
+ argument << toolTip.icon;
+ argument << toolTip.image;
+ argument << toolTip.title;
+ argument << toolTip.subTitle;
+ argument.endStructure();
+ return argument;
+}
+
+// Retrieve the ToolTipStruct data from the D-Bus argument
+const QDBusArgument &operator>>(const QDBusArgument &argument, QXdgDBusToolTipStruct &toolTip)
+{
+ QString icon;
+ QXdgDBusImageVector image;
+ QString title;
+ QString subTitle;
+
+ argument.beginStructure();
+ argument >> icon;
+ argument >> image;
+ argument >> title;
+ argument >> subTitle;
+ argument.endStructure();
+
+ toolTip.icon = icon;
+ toolTip.image = image;
+ toolTip.title = title;
+ toolTip.subTitle = subTitle;
+
+ return argument;
+}
+
+QT_END_NAMESPACE
+#endif // QT_NO_SYSTEMTRAYICON
diff --git a/src/platformsupport/dbustray/qdbustraytypes_p.h b/src/platformsupport/dbustray/qdbustraytypes_p.h
new file mode 100644
index 0000000000..4e7ae70a96
--- /dev/null
+++ b/src/platformsupport/dbustray/qdbustraytypes_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Marco Martin <notmart@gmail.com>
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 QDBUSTRAYTYPES_P_H
+#define QDBUSTRAYTYPES_P_H
+
+#ifndef QT_NO_SYSTEMTRAYICON
+
+#include <QObject>
+#include <QString>
+#include <QDBusArgument>
+#include <QDBusConnection>
+#include <QDBusObjectPath>
+#include <QPixmap>
+
+QT_BEGIN_NAMESPACE
+
+// Custom message type to send icons across D-Bus
+struct QXdgDBusImageStruct
+{
+ QXdgDBusImageStruct() { }
+ QXdgDBusImageStruct(int w, int h)
+ : width(w), height(h), data(width * height * 4, 0) { }
+ int width;
+ int height;
+ QByteArray data;
+};
+
+typedef QVector<QXdgDBusImageStruct> QXdgDBusImageVector;
+
+QXdgDBusImageVector iconToQXdgDBusImageVector(const QIcon &icon);
+
+// Custom message type to send tooltips across D-Bus
+struct QXdgDBusToolTipStruct
+{
+ QString icon;
+ QXdgDBusImageVector image;
+ QString title;
+ QString subTitle;
+};
+
+const QDBusArgument &operator<<(QDBusArgument &argument, const QXdgDBusImageStruct &icon);
+const QDBusArgument &operator>>(const QDBusArgument &argument, QXdgDBusImageStruct &icon);
+
+const QDBusArgument &operator<<(QDBusArgument &argument, const QXdgDBusImageVector &iconVector);
+const QDBusArgument &operator>>(const QDBusArgument &argument, QXdgDBusImageVector &iconVector);
+
+const QDBusArgument &operator<<(QDBusArgument &argument, const QXdgDBusToolTipStruct &toolTip);
+const QDBusArgument &operator>>(const QDBusArgument &argument, QXdgDBusToolTipStruct &toolTip);
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QXdgDBusImageStruct)
+Q_DECLARE_METATYPE(QXdgDBusImageVector)
+Q_DECLARE_METATYPE(QXdgDBusToolTipStruct)
+
+#endif // QT_NO_SYSTEMTRAYICON
+#endif // QDBUSTRAYTYPES_P_H
diff --git a/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp b/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp
new file mode 100644
index 0000000000..540e2f011d
--- /dev/null
+++ b/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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$
+**
+****************************************************************************/
+
+/*
+ This file was originally created by qdbusxml2cpp version 0.8
+ Command line was:
+ qdbusxml2cpp -a statusnotifieritem ../../3rdparty/dbus-ifaces/org.kde.StatusNotifierItem.xml
+
+ However it is maintained manually, because this adapter needs to do
+ significant interface adaptation, and can do it more efficiently using the
+ QDBusTrayIcon API directly rather than via QObject::property() and
+ QMetaObject::invokeMethod().
+*/
+
+#ifndef QT_NO_SYSTEMTRAYICON
+
+#include "qstatusnotifieritemadaptor_p.h"
+#include "qdbustrayicon_p.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(qLcMenu)
+
+QStatusNotifierItemAdaptor::QStatusNotifierItemAdaptor(QDBusTrayIcon *parent)
+ : QDBusAbstractAdaptor(parent), m_trayIcon(parent)
+{
+ setAutoRelaySignals(true);
+}
+
+QStatusNotifierItemAdaptor::~QStatusNotifierItemAdaptor()
+{
+}
+
+QString QStatusNotifierItemAdaptor::attentionIconName() const
+{
+ return m_trayIcon->attentionIconName();
+}
+
+QXdgDBusImageVector QStatusNotifierItemAdaptor::attentionIconPixmap() const
+{
+ return iconToQXdgDBusImageVector(m_trayIcon->attentionIcon());
+}
+
+QString QStatusNotifierItemAdaptor::attentionMovieName() const
+{
+ return QString();
+}
+
+QString QStatusNotifierItemAdaptor::category() const
+{
+ return m_trayIcon->category();
+}
+
+QString QStatusNotifierItemAdaptor::iconName() const
+{
+ return m_trayIcon->iconName();
+}
+
+QXdgDBusImageVector QStatusNotifierItemAdaptor::iconPixmap() const
+{
+ return iconToQXdgDBusImageVector(m_trayIcon->icon());
+}
+
+QString QStatusNotifierItemAdaptor::id() const
+{
+ // from the API docs: "a name that should be unique for this application and
+ // consistent between sessions, such as the application name itself"
+ return QCoreApplication::applicationName();
+}
+
+bool QStatusNotifierItemAdaptor::itemIsMenu() const
+{
+ // From KDE docs: if this is true, the item only supports the context menu,
+ // so the visualization should prefer sending ContextMenu() instead of Activate().
+ // But QSystemTrayIcon doesn't have such a setting: it will emit activated()
+ // and the application is free to use it or ignore it; we don't know whether it will.
+ return false;
+}
+
+QDBusObjectPath QStatusNotifierItemAdaptor::menu() const
+{
+ return QDBusObjectPath(m_trayIcon->menu() ? "/MenuBar" : "/NO_DBUSMENU");
+}
+
+QString QStatusNotifierItemAdaptor::overlayIconName() const
+{
+ return QString();
+}
+
+QXdgDBusImageVector QStatusNotifierItemAdaptor::overlayIconPixmap() const
+{
+ QXdgDBusImageVector ret; // empty vector
+ return ret;
+}
+
+QString QStatusNotifierItemAdaptor::status() const
+{
+ return m_trayIcon->status();
+}
+
+QString QStatusNotifierItemAdaptor::title() const
+{
+ // Shown e.g. when the icon is hidden, in the popup showing all hidden items.
+ // Since QSystemTrayIcon doesn't have this property, the application name
+ // is the best information we have available.
+ return QCoreApplication::applicationName();
+}
+
+QXdgDBusToolTipStruct QStatusNotifierItemAdaptor::toolTip() const
+{
+ QXdgDBusToolTipStruct ret;
+ if (m_trayIcon->isRequestingAttention()) {
+ ret.title = m_trayIcon->attentionTitle();
+ ret.subTitle = m_trayIcon->attentionMessage();
+ ret.icon = m_trayIcon->attentionIconName();
+ } else {
+ ret.title = m_trayIcon->tooltip();
+ }
+ return ret;
+}
+
+void QStatusNotifierItemAdaptor::Activate(int x, int y)
+{
+ m_trayIcon->activate(x, y);
+}
+
+void QStatusNotifierItemAdaptor::ContextMenu(int x, int y)
+{
+ m_trayIcon->contextMenu(x, y);
+}
+
+void QStatusNotifierItemAdaptor::Scroll(int, const QString &)
+{
+ // unsupported
+}
+
+void QStatusNotifierItemAdaptor::SecondaryActivate(int, int)
+{
+ // unsupported
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_SYSTEMTRAYICON
diff --git a/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h b/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h
new file mode 100644
index 0000000000..56fbb75d7a
--- /dev/null
+++ b/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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$
+**
+****************************************************************************/
+
+/*
+ This file was originally created by qdbusxml2cpp version 0.8
+ Command line was:
+ qdbusxml2cpp -a statusnotifieritem ../../3rdparty/dbus-ifaces/org.kde.StatusNotifierItem.xml
+
+ However it is maintained manually.
+
+ It is also not part of the public API. This header file may change from
+ version to version without notice, or even be removed.
+*/
+
+#ifndef QSTATUSNOTIFIERITEMADAPTER_P_H
+#define QSTATUSNOTIFIERITEMADAPTER_P_H
+
+#ifndef QT_NO_SYSTEMTRAYICON
+
+#include <QtCore/QObject>
+#include <QtDBus/QtDBus>
+
+#include "qdbustraytypes_p.h"
+
+QT_BEGIN_NAMESPACE
+class QDBusTrayIcon;
+
+/*
+ Adaptor class for interface org.kde.StatusNotifierItem
+ see http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/
+ (also http://www.notmart.org/misc/statusnotifieritem/)
+*/
+class QStatusNotifierItemAdaptor: public QDBusAbstractAdaptor
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.kde.StatusNotifierItem")
+ Q_CLASSINFO("D-Bus Introspection", ""
+" <interface name=\"org.kde.StatusNotifierItem\">\n"
+" <property access=\"read\" type=\"s\" name=\"Category\"/>\n"
+" <property access=\"read\" type=\"s\" name=\"Id\"/>\n"
+" <property access=\"read\" type=\"s\" name=\"Title\"/>\n"
+" <property access=\"read\" type=\"s\" name=\"Status\"/>\n"
+" <property access=\"read\" type=\"i\" name=\"WindowId\"/>\n"
+" <property access=\"read\" type=\"s\" name=\"IconThemePath\"/>\n"
+" <property access=\"read\" type=\"o\" name=\"Menu\"/>\n"
+" <property access=\"read\" type=\"b\" name=\"ItemIsMenu\"/>\n"
+" <property access=\"read\" type=\"s\" name=\"IconName\"/>\n"
+" <property access=\"read\" type=\"(iiay)\" name=\"IconPixmap\">\n"
+" <annotation value=\"QXdgDBusImageVector\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
+" </property>\n"
+" <property access=\"read\" type=\"s\" name=\"OverlayIconName\"/>\n"
+" <property access=\"read\" type=\"(iiay)\" name=\"OverlayIconPixmap\">\n"
+" <annotation value=\"QXdgDBusImageVector\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
+" </property>\n"
+" <property access=\"read\" type=\"s\" name=\"AttentionIconName\"/>\n"
+" <property access=\"read\" type=\"(iiay)\" name=\"AttentionIconPixmap\">\n"
+" <annotation value=\"QXdgDBusImageVector\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
+" </property>\n"
+" <property access=\"read\" type=\"s\" name=\"AttentionMovieName\"/>\n"
+" <property access=\"read\" type=\"(s(iiay)ss)\" name=\"ToolTip\">\n"
+" <annotation value=\"QXdgDBusToolTipStruct\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
+" </property>\n"
+" <method name=\"ContextMenu\">\n"
+" <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
+" <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
+" </method>\n"
+" <method name=\"Activate\">\n"
+" <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
+" <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
+" </method>\n"
+" <method name=\"SecondaryActivate\">\n"
+" <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
+" <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
+" </method>\n"
+" <method name=\"Scroll\">\n"
+" <arg direction=\"in\" type=\"i\" name=\"delta\"/>\n"
+" <arg direction=\"in\" type=\"s\" name=\"orientation\"/>\n"
+" </method>\n"
+" <signal name=\"NewTitle\"/>\n"
+" <signal name=\"NewIcon\"/>\n"
+" <signal name=\"NewAttentionIcon\"/>\n"
+" <signal name=\"NewOverlayIcon\"/>\n"
+" <signal name=\"NewToolTip\"/>\n"
+" <signal name=\"NewStatus\">\n"
+" <arg type=\"s\" name=\"status\"/>\n"
+" </signal>\n"
+" </interface>\n"
+ "")
+public:
+ QStatusNotifierItemAdaptor(QDBusTrayIcon *parent);
+ virtual ~QStatusNotifierItemAdaptor();
+
+public: // PROPERTIES
+ Q_PROPERTY(QString AttentionIconName READ attentionIconName)
+ QString attentionIconName() const;
+
+ Q_PROPERTY(QXdgDBusImageVector AttentionIconPixmap READ attentionIconPixmap)
+ QXdgDBusImageVector attentionIconPixmap() const;
+
+ Q_PROPERTY(QString AttentionMovieName READ attentionMovieName)
+ QString attentionMovieName() const;
+
+ Q_PROPERTY(QString Category READ category)
+ QString category() const;
+
+ Q_PROPERTY(QString IconName READ iconName)
+ QString iconName() const;
+
+ Q_PROPERTY(QXdgDBusImageVector IconPixmap READ iconPixmap)
+ QXdgDBusImageVector iconPixmap() const;
+
+ Q_PROPERTY(QString Id READ id)
+ QString id() const;
+
+ Q_PROPERTY(bool ItemIsMenu READ itemIsMenu)
+ bool itemIsMenu() const;
+
+ Q_PROPERTY(QDBusObjectPath Menu READ menu)
+ QDBusObjectPath menu() const;
+
+ Q_PROPERTY(QString OverlayIconName READ overlayIconName)
+ QString overlayIconName() const;
+
+ Q_PROPERTY(QXdgDBusImageVector OverlayIconPixmap READ overlayIconPixmap)
+ QXdgDBusImageVector overlayIconPixmap() const;
+
+ Q_PROPERTY(QString Status READ status)
+ QString status() const;
+
+ Q_PROPERTY(QString Title READ title)
+ QString title() const;
+
+ Q_PROPERTY(QXdgDBusToolTipStruct ToolTip READ toolTip)
+ QXdgDBusToolTipStruct toolTip() const;
+
+public Q_SLOTS: // METHODS
+ void Activate(int x, int y);
+ void ContextMenu(int x, int y);
+ void Scroll(int delta, const QString &orientation);
+ void SecondaryActivate(int x, int y);
+Q_SIGNALS: // SIGNALS
+ void NewAttentionIcon();
+ void NewIcon();
+ void NewOverlayIcon();
+ void NewStatus(const QString &status);
+ void NewTitle();
+ void NewToolTip();
+
+private:
+ QDBusTrayIcon *m_trayIcon;
+};
+
+QT_END_NAMESPACE
+#endif // QT_NO_SYSTEMTRAYICON
+#endif // QSTATUSNOTIFIERITEMADAPTER_P_H
diff --git a/src/platformsupport/dbustray/qxdgnotificationproxy.cpp b/src/platformsupport/dbustray/qxdgnotificationproxy.cpp
new file mode 100644
index 0000000000..10061fabcb
--- /dev/null
+++ b/src/platformsupport/dbustray/qxdgnotificationproxy.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 "qxdgnotificationproxy_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QXdgNotificationInterface::QXdgNotificationInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+QXdgNotificationInterface::~QXdgNotificationInterface()
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/dbustray/qxdgnotificationproxy_p.h b/src/platformsupport/dbustray/qxdgnotificationproxy_p.h
new file mode 100644
index 0000000000..3e573cb118
--- /dev/null
+++ b/src/platformsupport/dbustray/qxdgnotificationproxy_p.h
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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$
+**
+****************************************************************************/
+
+/*
+ This file was originally created by qdbusxml2cpp version 0.8
+ Command line was:
+ qdbusxml2cpp -p qxdgnotificationproxy ../../3rdparty/dbus-ifaces/org.freedesktop.Notifications.xml
+
+ However it is maintained manually.
+
+ It is also not part of the public API. This header file may change from
+ version to version without notice, or even be removed.
+*/
+
+#ifndef QXDGNOTIFICATIONPROXY_P_H
+#define QXDGNOTIFICATIONPROXY_P_H
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(qLcTray)
+
+/*
+ * Proxy class for interface org.freedesktop.Notifications
+ */
+class QXdgNotificationInterface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.freedesktop.Notifications"; }
+
+public:
+ QXdgNotificationInterface(const QString &service, const QString &path,
+ const QDBusConnection &connection, QObject *parent = 0);
+
+ ~QXdgNotificationInterface();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<> closeNotification(uint id)
+ {
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(id);
+ return asyncCallWithArgumentList(QStringLiteral("CloseNotification"), argumentList);
+ }
+
+ inline QDBusPendingReply<QStringList> getCapabilities()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QStringLiteral("GetCapabilities"), argumentList);
+ }
+
+ inline QDBusPendingReply<QString, QString, QString, QString> getServerInformation()
+ {
+ QList<QVariant> argumentList;
+ return asyncCallWithArgumentList(QStringLiteral("GetServerInformation"), argumentList);
+ }
+ inline QDBusReply<QString> getServerInformation(QString &vendor, QString &version, QString &specVersion)
+ {
+ QList<QVariant> argumentList;
+ QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetServerInformation"), argumentList);
+ if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 4) {
+ vendor = qdbus_cast<QString>(reply.arguments().at(1));
+ version = qdbus_cast<QString>(reply.arguments().at(2));
+ specVersion = qdbus_cast<QString>(reply.arguments().at(3));
+ }
+ return reply;
+ }
+
+ // see https://developer.gnome.org/notification-spec/#basic-design
+ inline QDBusPendingReply<uint> notify(const QString &appName, uint replacesId, const QString &appIcon,
+ const QString &summary, const QString &body, const QStringList &actions,
+ const QVariantMap &hints, int timeout)
+ {
+ qCDebug(qLcTray) << appName << replacesId << appIcon << summary << body << actions << hints << timeout;
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(appName) << QVariant::fromValue(replacesId) <<
+ QVariant::fromValue(appIcon) << QVariant::fromValue(summary) <<
+ QVariant::fromValue(body) << QVariant::fromValue(actions) <<
+ QVariant::fromValue(hints) << QVariant::fromValue(timeout);
+ return asyncCallWithArgumentList(QStringLiteral("Notify"), argumentList);
+ }
+
+Q_SIGNALS:
+ void ActionInvoked(uint id, const QString &action_key);
+ void NotificationClosed(uint id, uint reason);
+};
+
+namespace org {
+ namespace freedesktop {
+ typedef ::QXdgNotificationInterface Notifications;
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp
index 44c5f845dc..bbd97091f6 100644
--- a/src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp
+++ b/src/platformsupport/devicediscovery/qdevicediscovery_dummy.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h
index 93a676858d..e88c3d4160 100644
--- a/src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h
+++ b/src/platformsupport/devicediscovery/qdevicediscovery_dummy_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_p.h
index f3b0d19a7c..88b75ee439 100644
--- a/src/platformsupport/devicediscovery/qdevicediscovery_p.h
+++ b/src/platformsupport/devicediscovery/qdevicediscovery_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp
index 660d3760fb..160fb7f5c0 100644
--- a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp
+++ b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_static_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_static_p.h
index 6629a9a26c..16ded3fca3 100644
--- a/src/platformsupport/devicediscovery/qdevicediscovery_static_p.h
+++ b/src/platformsupport/devicediscovery/qdevicediscovery_static_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp
index 7645dc4544..358be828fa 100644
--- a/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp
+++ b/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h b/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h
index d31ba72c96..196d6df77c 100644
--- a/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h
+++ b/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/eglconvenience/eglconvenience.pri b/src/platformsupport/eglconvenience/eglconvenience.pri
index 8ada53d2c1..d102203d5e 100644
--- a/src/platformsupport/eglconvenience/eglconvenience.pri
+++ b/src/platformsupport/eglconvenience/eglconvenience.pri
@@ -16,16 +16,12 @@ contains(QT_CONFIG,egl) {
$$PWD/qeglplatformcursor_p.h \
$$PWD/qeglplatformwindow_p.h \
$$PWD/qeglplatformscreen_p.h \
- $$PWD/qeglcompositor_p.h \
- $$PWD/qeglplatformbackingstore_p.h \
$$PWD/qeglplatformintegration_p.h
SOURCES += \
$$PWD/qeglplatformcursor.cpp \
$$PWD/qeglplatformwindow.cpp \
$$PWD/qeglplatformscreen.cpp \
- $$PWD/qeglcompositor.cpp \
- $$PWD/qeglplatformbackingstore.cpp \
$$PWD/qeglplatformintegration.cpp
}
}
diff --git a/src/platformsupport/eglconvenience/qeglcompositor.cpp b/src/platformsupport/eglconvenience/qeglcompositor.cpp
deleted file mode 100644
index a46e5698de..0000000000
--- a/src/platformsupport/eglconvenience/qeglcompositor.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui/QOpenGLContext>
-#include <QtGui/QOpenGLShaderProgram>
-#include <QtGui/QOpenGLFramebufferObject>
-#include <QtGui/private/qopengltextureblitter_p.h>
-#include <qpa/qplatformbackingstore.h>
-
-#include "qeglcompositor_p.h"
-#include "qeglplatformwindow_p.h"
-#include "qeglplatformscreen_p.h"
-
-QT_BEGIN_NAMESPACE
-
-static QEGLCompositor *compositor = 0;
-
-QEGLCompositor::QEGLCompositor()
- : m_context(0),
- m_window(0),
- m_blitter(0)
-{
- Q_ASSERT(!compositor);
- m_updateTimer.setSingleShot(true);
- m_updateTimer.setInterval(0);
- connect(&m_updateTimer, SIGNAL(timeout()), SLOT(renderAll()));
-}
-
-QEGLCompositor::~QEGLCompositor()
-{
- Q_ASSERT(compositor == this);
- if (m_blitter) {
- m_blitter->destroy();
- delete m_blitter;
- }
- compositor = 0;
-}
-
-void QEGLCompositor::schedule(QOpenGLContext *context, QEGLPlatformWindow *window)
-{
- m_context = context;
- m_window = window;
- if (!m_updateTimer.isActive())
- m_updateTimer.start();
-}
-
-void QEGLCompositor::renderAll()
-{
- Q_ASSERT(m_context && m_window);
- m_context->makeCurrent(m_window->window());
-
- if (!m_blitter) {
- m_blitter = new QOpenGLTextureBlitter;
- m_blitter->create();
- }
- m_blitter->bind();
-
- QEGLPlatformScreen *screen = static_cast<QEGLPlatformScreen *>(m_window->screen());
- QList<QEGLPlatformWindow *> windows = screen->windows();
- for (int i = 0; i < windows.size(); ++i)
- render(windows.at(i));
-
- m_blitter->release();
- m_context->swapBuffers(m_window->window());
-
- for (int i = 0; i < windows.size(); ++i)
- windows.at(i)->composited();
-}
-
-struct BlendStateBinder
-{
- BlendStateBinder() : m_blend(false) {
- glDisable(GL_BLEND);
- }
- void set(bool blend) {
- if (blend != m_blend) {
- if (blend) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- } else {
- glDisable(GL_BLEND);
- }
- m_blend = blend;
- }
- }
- ~BlendStateBinder() {
- if (m_blend)
- glDisable(GL_BLEND);
- }
- bool m_blend;
-};
-
-void QEGLCompositor::render(QEGLPlatformWindow *window)
-{
- const QPlatformTextureList *textures = window->textures();
- if (!textures)
- return;
-
- const QRect targetWindowRect(QPoint(0, 0), window->screen()->geometry().size());
- glViewport(0, 0, targetWindowRect.width(), targetWindowRect.height());
-
- float currentOpacity = 1.0f;
- BlendStateBinder blend;
-
- for (int i = 0; i < textures->count(); ++i) {
- uint textureId = textures->textureId(i);
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i),
- targetWindowRect);
- const float opacity = window->window()->opacity();
- if (opacity != currentOpacity) {
- currentOpacity = opacity;
- m_blitter->setOpacity(currentOpacity);
- }
-
- if (textures->count() > 1 && i == textures->count() - 1) {
- // Backingstore for a widget with QOpenGLWidget subwidgets
- blend.set(true);
- m_blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
- } else if (textures->count() == 1) {
- // A regular QWidget window
- const bool translucent = window->window()->requestedFormat().alphaBufferSize() > 0;
- blend.set(translucent);
- m_blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
- } else if (!textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
- // Texture from an FBO belonging to a QOpenGLWidget
- blend.set(false);
- m_blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginBottomLeft);
- }
- }
-
- for (int i = 0; i < textures->count(); ++i) {
- if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
- blend.set(true);
- m_blitter->blit(textures->textureId(i), target, QOpenGLTextureBlitter::OriginBottomLeft);
- }
- }
-
- m_blitter->setOpacity(1.0f);
-}
-
-QEGLCompositor *QEGLCompositor::instance()
-{
- if (!compositor)
- compositor = new QEGLCompositor;
- return compositor;
-}
-
-void QEGLCompositor::destroy()
-{
- delete compositor;
- compositor = 0;
-}
-
-QT_END_NAMESPACE
diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp
index c1a491c80b..011e2c2961 100644
--- a/src/platformsupport/eglconvenience/qeglconvenience.cpp
+++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -303,7 +303,7 @@ EGLConfig QEglConfigChooser::chooseConfig()
} while (q_reduceConfigAttributes(&configureAttributes));
if (!cfg)
- qWarning("Cant find EGLConfig, returning null config");
+ qWarning("Cannot find EGLConfig, returning null config");
return cfg;
}
@@ -460,8 +460,8 @@ QSizeF q_physicalScreenSizeFromFb(int framebufferDevice, const QSize &screenSize
if (size.isEmpty()) {
// Note: in millimeters
- int width = qgetenv("QT_QPA_EGLFS_PHYSICAL_WIDTH").toInt();
- int height = qgetenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT").toInt();
+ int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH");
+ int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT");
if (width && height) {
size.setWidth(width);
@@ -513,8 +513,8 @@ QSize q_screenSizeFromFb(int framebufferDevice)
static QSize size;
if (size.isEmpty()) {
- int width = qgetenv("QT_QPA_EGLFS_WIDTH").toInt();
- int height = qgetenv("QT_QPA_EGLFS_HEIGHT").toInt();
+ int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_WIDTH");
+ int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_HEIGHT");
if (width && height) {
size.setWidth(width);
@@ -553,7 +553,7 @@ int q_screenDepthFromFb(int framebufferDevice)
Q_UNUSED(framebufferDevice)
#endif
const int defaultDepth = 32;
- static int depth = qgetenv("QT_QPA_EGLFS_DEPTH").toInt();
+ static int depth = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DEPTH");
if (depth == 0) {
#ifdef Q_OS_LINUX
diff --git a/src/platformsupport/eglconvenience/qeglconvenience_p.h b/src/platformsupport/eglconvenience/qeglconvenience_p.h
index 52c2b861f9..1d35545430 100644
--- a/src/platformsupport/eglconvenience/qeglconvenience_p.h
+++ b/src/platformsupport/eglconvenience/qeglconvenience_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/eglconvenience/qeglpbuffer.cpp b/src/platformsupport/eglconvenience/qeglpbuffer.cpp
index 2c6c332ac9..9cdf5a0931 100644
--- a/src/platformsupport/eglconvenience/qeglpbuffer.cpp
+++ b/src/platformsupport/eglconvenience/qeglpbuffer.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -55,6 +55,9 @@ QEGLPbuffer::QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffs
, m_display(display)
, m_pbuffer(EGL_NO_SURFACE)
{
+ if (q_hasEglExtension(display, "EGL_KHR_surfaceless_context"))
+ return;
+
EGLConfig config = q_configFromGLFormat(m_display, m_format, false, EGL_PBUFFER_BIT);
if (config) {
@@ -74,7 +77,8 @@ QEGLPbuffer::QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffs
QEGLPbuffer::~QEGLPbuffer()
{
- eglDestroySurface(m_display, m_pbuffer);
+ if (m_pbuffer != EGL_NO_SURFACE)
+ eglDestroySurface(m_display, m_pbuffer);
}
QT_END_NAMESPACE
diff --git a/src/platformsupport/eglconvenience/qeglpbuffer_p.h b/src/platformsupport/eglconvenience/qeglpbuffer_p.h
index 0995b6d443..3372c0735d 100644
--- a/src/platformsupport/eglconvenience/qeglpbuffer_p.h
+++ b/src/platformsupport/eglconvenience/qeglpbuffer_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -56,8 +56,8 @@ public:
QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface);
~QEGLPbuffer();
- QSurfaceFormat format() const { return m_format; }
- bool isValid() const { return m_pbuffer != EGL_NO_SURFACE; }
+ QSurfaceFormat format() const Q_DECL_OVERRIDE { return m_format; }
+ bool isValid() const Q_DECL_OVERRIDE { return m_pbuffer != EGL_NO_SURFACE; }
EGLSurface pbuffer() const { return m_pbuffer; }
diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
index 7cc330092e..6d9f9e4ae0 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -177,17 +177,17 @@ void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLCont
}
if (m_eglContext == EGL_NO_CONTEXT) {
- qWarning("QEGLPlatformContext::init: eglError: %x, this: %p \n", eglGetError(), this);
+ qWarning("QEGLPlatformContext: Failed to create context: %x", eglGetError());
return;
}
- static const bool printConfig = qgetenv("QT_QPA_EGLFS_DEBUG").toInt();
+ static const bool printConfig = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DEBUG");
if (printConfig) {
qDebug() << "Created context for format" << format << "with config:";
q_printEglConfig(m_eglDisplay, m_eglConfig);
}
- updateFormatFromGL();
+ // Cannot just call updateFormatFromGL() since it relies on virtuals. Defer it to initialize().
}
void QEGLPlatformContext::adopt(const QVariant &nativeHandle, QPlatformOpenGLContext *share)
@@ -238,18 +238,13 @@ void QEGLPlatformContext::adopt(const QVariant &nativeHandle, QPlatformOpenGLCon
updateFormatFromGL();
}
-void QEGLPlatformContext::updateFormatFromGL()
+void QEGLPlatformContext::initialize()
{
-#ifndef QT_NO_OPENGL
- // Have to save & restore to prevent QOpenGLContext::currentContext() from becoming
- // inconsistent after QOpenGLContext::create().
- EGLDisplay prevDisplay = eglGetCurrentDisplay();
- if (prevDisplay == EGL_NO_DISPLAY) // when no context is current
- prevDisplay = m_eglDisplay;
- EGLContext prevContext = eglGetCurrentContext();
- EGLSurface prevSurfaceDraw = eglGetCurrentSurface(EGL_DRAW);
- EGLSurface prevSurfaceRead = eglGetCurrentSurface(EGL_READ);
+ updateFormatFromGL();
+}
+EGLSurface QEGLPlatformContext::createTemporaryOffscreenSurface()
+{
// Make the context current to ensure the GL version query works. This needs a surface too.
const EGLint pbufferAttributes[] = {
EGL_WIDTH, 1,
@@ -257,15 +252,40 @@ void QEGLPlatformContext::updateFormatFromGL()
EGL_LARGEST_PBUFFER, EGL_FALSE,
EGL_NONE
};
+
// Cannot just pass m_eglConfig because it may not be suitable for pbuffers. Instead,
// do what QEGLPbuffer would do: request a config with the same attributes but with
// PBUFFER_BIT set.
EGLConfig config = q_configFromGLFormat(m_eglDisplay, m_format, false, EGL_PBUFFER_BIT);
- EGLSurface pbuffer = eglCreatePbufferSurface(m_eglDisplay, config, pbufferAttributes);
- if (pbuffer == EGL_NO_SURFACE)
- return;
- if (eglMakeCurrent(m_eglDisplay, pbuffer, pbuffer, m_eglContext)) {
+ return eglCreatePbufferSurface(m_eglDisplay, config, pbufferAttributes);
+}
+
+void QEGLPlatformContext::destroyTemporaryOffscreenSurface(EGLSurface surface)
+{
+ eglDestroySurface(m_eglDisplay, surface);
+}
+
+void QEGLPlatformContext::updateFormatFromGL()
+{
+#ifndef QT_NO_OPENGL
+ // Have to save & restore to prevent QOpenGLContext::currentContext() from becoming
+ // inconsistent after QOpenGLContext::create().
+ EGLDisplay prevDisplay = eglGetCurrentDisplay();
+ if (prevDisplay == EGL_NO_DISPLAY) // when no context is current
+ prevDisplay = m_eglDisplay;
+ EGLContext prevContext = eglGetCurrentContext();
+ EGLSurface prevSurfaceDraw = eglGetCurrentSurface(EGL_DRAW);
+ EGLSurface prevSurfaceRead = eglGetCurrentSurface(EGL_READ);
+
+ // Rely on the surfaceless extension, if available. This is beneficial since we can
+ // 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;
+ if (!q_hasEglExtension(m_eglDisplay, "EGL_KHR_surfaceless_context"))
+ tempSurface = createTemporaryOffscreenSurface();
+
+ if (eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, m_eglContext)) {
if (m_format.renderableType() == QSurfaceFormat::OpenGL
|| m_format.renderableType() == QSurfaceFormat::OpenGLES) {
const GLubyte *s = glGetString(GL_VERSION);
@@ -302,8 +322,11 @@ void QEGLPlatformContext::updateFormatFromGL()
}
}
eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext);
+ } else {
+ qWarning("QEGLPlatformContext: Failed to make temporary surface current, format not updated");
}
- eglDestroySurface(m_eglDisplay, pbuffer);
+ if (tempSurface != EGL_NO_SURFACE)
+ destroyTemporaryOffscreenSurface(tempSurface);
#endif // QT_NO_OPENGL
}
@@ -340,10 +363,11 @@ bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface)
: surface->format().swapInterval();
if (requestedSwapInterval >= 0 && m_swapInterval != requestedSwapInterval) {
m_swapInterval = requestedSwapInterval;
- eglSwapInterval(eglDisplay(), m_swapInterval);
+ if (eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
+ eglSwapInterval(eglDisplay(), m_swapInterval);
}
} else {
- qWarning("QEGLPlatformContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this);
+ qWarning("QEGLPlatformContext: eglMakeCurrent failed: %x", eglGetError());
}
return ok;
@@ -362,16 +386,18 @@ void QEGLPlatformContext::doneCurrent()
eglBindAPI(m_api);
bool ok = eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (!ok)
- qWarning("QEGLPlatformContext::doneCurrent(): eglError: %d, this: %p \n", eglGetError(), this);
+ qWarning("QEGLPlatformContext: eglMakeCurrent failed: %x", eglGetError());
}
void QEGLPlatformContext::swapBuffers(QPlatformSurface *surface)
{
eglBindAPI(m_api);
EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface);
- bool ok = eglSwapBuffers(m_eglDisplay, eglSurface);
- if (!ok)
- qWarning("QEGLPlatformContext::swapBuffers(): eglError: %d, this: %p \n", eglGetError(), this);
+ if (eglSurface != EGL_NO_SURFACE) { // skip if using surfaceless context
+ bool ok = eglSwapBuffers(m_eglDisplay, eglSurface);
+ if (!ok)
+ qWarning("QEGLPlatformContext: eglSwapBuffers failed: %x", eglGetError());
+ }
}
void (*QEGLPlatformContext::getProcAddress(const QByteArray &procName)) ()
diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h
index 0c10710304..50c264e1dc 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h
+++ b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -60,14 +60,15 @@ public:
EGLConfig *config = 0, const QVariant &nativeHandle = QVariant());
~QEGLPlatformContext();
- bool makeCurrent(QPlatformSurface *surface);
- void doneCurrent();
- void swapBuffers(QPlatformSurface *surface);
- void (*getProcAddress(const QByteArray &procName)) ();
+ void initialize() Q_DECL_OVERRIDE;
+ bool makeCurrent(QPlatformSurface *surface) Q_DECL_OVERRIDE;
+ void doneCurrent() Q_DECL_OVERRIDE;
+ void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
+ QFunctionPointer getProcAddress(const QByteArray &procName) Q_DECL_OVERRIDE;
- QSurfaceFormat format() const;
- bool isSharing() const { return m_shareContext != EGL_NO_CONTEXT; }
- bool isValid() const { return m_eglContext != EGL_NO_CONTEXT; }
+ QSurfaceFormat format() const Q_DECL_OVERRIDE;
+ bool isSharing() const Q_DECL_OVERRIDE { return m_shareContext != EGL_NO_CONTEXT; }
+ bool isValid() const Q_DECL_OVERRIDE { return m_eglContext != EGL_NO_CONTEXT; }
EGLContext eglContext() const;
EGLDisplay eglDisplay() const;
@@ -75,6 +76,8 @@ public:
protected:
virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) = 0;
+ virtual EGLSurface createTemporaryOffscreenSurface();
+ virtual void destroyTemporaryOffscreenSurface(EGLSurface surface);
private:
void init(const QSurfaceFormat &format, QPlatformOpenGLContext *share);
diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
index cf41bd2f1b..fc6e4bad8d 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -39,7 +39,7 @@
#include <QtCore/QJsonObject>
#include <QtDebug>
-#include <QtPlatformSupport/private/qdevicediscovery_p.h>
+#include <QtGui/private/qguiapplication_p.h>
#include "qeglplatformcursor_p.h"
#include "qeglplatformintegration_p.h"
@@ -79,6 +79,11 @@ QEGLPlatformCursor::QEGLPlatformCursor(QPlatformScreen *screen)
QCursor cursor(Qt::ArrowCursor);
setCurrentCursor(&cursor);
#endif
+
+ m_deviceListener = new QEGLPlatformCursorDeviceListener(this);
+ connect(QGuiApplicationPrivate::inputDeviceManager(), &QInputDeviceManager::deviceListChanged,
+ m_deviceListener, &QEGLPlatformCursorDeviceListener::onDeviceListChanged);
+ updateMouseStatus();
}
QEGLPlatformCursor::~QEGLPlatformCursor()
@@ -87,42 +92,20 @@ QEGLPlatformCursor::~QEGLPlatformCursor()
delete m_deviceListener;
}
-void QEGLPlatformCursor::setMouseDeviceDiscovery(QDeviceDiscovery *dd)
-{
- if (m_visible && dd) {
- m_deviceListener = new QEGLPlatformCursorDeviceListener(dd, this);
- updateMouseStatus();
- }
-}
-
void QEGLPlatformCursor::updateMouseStatus()
{
m_visible = m_deviceListener->hasMouse();
}
-QEGLPlatformCursorDeviceListener::QEGLPlatformCursorDeviceListener(QDeviceDiscovery *dd, QEGLPlatformCursor *cursor)
- : m_cursor(cursor)
-{
- m_mouseCount = dd->scanConnectedDevices().count();
- connect(dd, SIGNAL(deviceDetected(QString)), SLOT(onDeviceAdded()));
- connect(dd, SIGNAL(deviceRemoved(QString)), SLOT(onDeviceRemoved()));
-}
-
bool QEGLPlatformCursorDeviceListener::hasMouse() const
{
- return m_mouseCount > 0;
-}
-
-void QEGLPlatformCursorDeviceListener::onDeviceAdded()
-{
- ++m_mouseCount;
- m_cursor->updateMouseStatus();
+ return QGuiApplicationPrivate::inputDeviceManager()->deviceCount(QInputDeviceManager::DeviceTypePointer) > 0;
}
-void QEGLPlatformCursorDeviceListener::onDeviceRemoved()
+void QEGLPlatformCursorDeviceListener::onDeviceListChanged(QInputDeviceManager::DeviceType type)
{
- --m_mouseCount;
- m_cursor->updateMouseStatus();
+ if (type == QInputDeviceManager::DeviceTypePointer)
+ m_cursor->updateMouseStatus();
}
void QEGLPlatformCursor::resetResources()
@@ -380,6 +363,7 @@ void QEGLPlatformCursor::draw(const QRectF &r)
s2, t1
};
+ glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_cursor.texture);
glBindBuffer(GL_ARRAY_BUFFER, 0);
@@ -391,6 +375,8 @@ void QEGLPlatformCursor::draw(const QRectF &r)
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
diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
index 83204748c1..1c05a06b63 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
+++ b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -48,11 +48,11 @@
#include <qpa/qplatformcursor.h>
#include <qpa/qplatformscreen.h>
#include <QtGui/QOpenGLFunctions>
+#include <QtGui/private/qinputdevicemanager_p.h>
QT_BEGIN_NAMESPACE
class QOpenGLShaderProgram;
-class QDeviceDiscovery;
class QEGLPlatformCursor;
class QEGLPlatformCursorDeviceListener : public QObject
@@ -60,16 +60,14 @@ class QEGLPlatformCursorDeviceListener : public QObject
Q_OBJECT
public:
- QEGLPlatformCursorDeviceListener(QDeviceDiscovery *dd, QEGLPlatformCursor *cursor);
+ QEGLPlatformCursorDeviceListener(QEGLPlatformCursor *cursor) : m_cursor(cursor) { }
bool hasMouse() const;
-private slots:
- void onDeviceAdded();
- void onDeviceRemoved();
+public slots:
+ void onDeviceListChanged(QInputDeviceManager::DeviceType type);
private:
QEGLPlatformCursor *m_cursor;
- int m_mouseCount;
};
class QEGLPlatformCursorUpdater : public QObject
@@ -92,6 +90,7 @@ private:
class QEGLPlatformCursor : public QPlatformCursor, protected QOpenGLFunctions
{
+ Q_OBJECT
public:
QEGLPlatformCursor(QPlatformScreen *screen);
~QEGLPlatformCursor();
@@ -107,7 +106,6 @@ public:
void paintOnScreen();
void resetResources();
- void setMouseDeviceDiscovery(QDeviceDiscovery *dd);
void updateMouseStatus();
private:
diff --git a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp
index 7d05b54c15..200ded760c 100644
--- a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -43,6 +43,7 @@
#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>
@@ -50,12 +51,15 @@
#include <QtPlatformSupport/private/qevdevtouch_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 "qeglplatformbackingstore_p.h"
#include "qeglplatformscreen_p.h"
#include "qeglplatformcursor_p.h"
@@ -84,8 +88,7 @@ QT_BEGIN_NAMESPACE
*/
QEGLPlatformIntegration::QEGLPlatformIntegration()
- : m_screen(0),
- m_display(EGL_NO_DISPLAY),
+ : m_display(EGL_NO_DISPLAY),
m_inputContext(0),
m_fontDb(new QGenericUnixFontDatabase),
m_services(new QGenericUnixServices),
@@ -95,9 +98,6 @@ QEGLPlatformIntegration::QEGLPlatformIntegration()
QEGLPlatformIntegration::~QEGLPlatformIntegration()
{
- delete m_screen;
- if (m_display != EGL_NO_DISPLAY)
- eglTerminate(m_display);
}
void QEGLPlatformIntegration::initialize()
@@ -110,14 +110,20 @@ void QEGLPlatformIntegration::initialize()
if (!eglInitialize(m_display, &major, &minor))
qFatal("Could not initialize egl display");
- m_screen = createScreen();
- screenAdded(m_screen);
-
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();
@@ -135,7 +141,11 @@ QPlatformFontDatabase *QEGLPlatformIntegration::fontDatabase() const
QPlatformBackingStore *QEGLPlatformIntegration::createPlatformBackingStore(QWindow *window) const
{
- return new QEGLPlatformBackingStore(window);
+ 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
@@ -150,10 +160,9 @@ QPlatformWindow *QEGLPlatformIntegration::createPlatformWindow(QWindow *window)
QPlatformOpenGLContext *QEGLPlatformIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
- QEGLPlatformScreen *screen = static_cast<QEGLPlatformScreen *>(context->screen()->handle());
// If there is a "root" window into which raster and QOpenGLWidget content is
// composited, all other contexts must share with its context.
- QOpenGLContext *compositingContext = screen ? screen->compositingContext() : 0;
+ QOpenGLContext *compositingContext = QOpenGLCompositor::instance()->context();
QPlatformOpenGLContext *share = compositingContext ? compositingContext->handle() : context->shareHandle();
QVariant nativeHandle = context->nativeHandle();
QPlatformOpenGLContext *platformContext = createContext(context->format(),
@@ -219,7 +228,7 @@ void *QEGLPlatformIntegration::nativeResourceForIntegration(const QByteArray &re
switch (resourceType(resource)) {
case EglDisplay:
- result = m_screen->display();
+ result = display();
break;
case NativeDisplay:
result = reinterpret_cast<void*>(nativeDisplay());
@@ -257,7 +266,7 @@ void *QEGLPlatformIntegration::nativeResourceForWindow(const QByteArray &resourc
if (window && window->handle())
result = static_cast<QEGLPlatformScreen *>(window->handle()->screen())->display();
else
- result = m_screen->display();
+ result = display();
break;
case EglWindow:
if (window && window->handle())
@@ -343,13 +352,14 @@ 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);
- QEvdevMouseManager *mouseMgr = new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this);
- Q_FOREACH (QScreen *screen, QGuiApplication::screens()) {
- QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(screen->handle()->cursor());
- if (cursor)
- cursor->setMouseDeviceDiscovery(mouseMgr->deviceDiscovery());
- }
- new QEvdevTouchScreenHandlerThread(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 QEvdevTouchScreenHandlerThread(QString() /* spec */, this);
#endif
}
diff --git a/src/platformsupport/eglconvenience/qeglplatformintegration_p.h b/src/platformsupport/eglconvenience/qeglplatformintegration_p.h
index 2b5d5f50fb..3b6c862333 100644
--- a/src/platformsupport/eglconvenience/qeglplatformintegration_p.h
+++ b/src/platformsupport/eglconvenience/qeglplatformintegration_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -52,7 +52,6 @@
QT_BEGIN_NAMESPACE
-class QEGLPlatformScreen;
class QEGLPlatformWindow;
class QEGLPlatformContext;
class QFbVtHandler;
@@ -65,8 +64,8 @@ public:
~QEGLPlatformIntegration();
void initialize() Q_DECL_OVERRIDE;
+ void destroy() Q_DECL_OVERRIDE;
- QEGLPlatformScreen *screen() const { return m_screen; }
EGLDisplay display() const { return m_display; }
QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
@@ -92,7 +91,6 @@ public:
QFunctionPointer platformFunction(const QByteArray &function) const Q_DECL_OVERRIDE;
protected:
- virtual QEGLPlatformScreen *createScreen() const = 0;
virtual QEGLPlatformWindow *createWindow(QWindow *window) const = 0;
virtual QEGLPlatformContext *createContext(const QSurfaceFormat &format,
QPlatformOpenGLContext *shareContext,
@@ -109,7 +107,6 @@ protected:
private:
static void loadKeymapStatic(const QString &filename);
- QEGLPlatformScreen *m_screen;
EGLDisplay m_display;
QPlatformInputContext *m_inputContext;
QScopedPointer<QPlatformFontDatabase> m_fontDb;
diff --git a/src/platformsupport/eglconvenience/qeglplatformscreen.cpp b/src/platformsupport/eglconvenience/qeglplatformscreen.cpp
index fd577a48d7..dd4a97cdf5 100644
--- a/src/platformsupport/eglconvenience/qeglplatformscreen.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformscreen.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,16 +23,16 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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 "qeglcompositor_p.h"
#include "qeglplatformscreen_p.h"
+#include <QtPlatformSupport/private/qopenglcompositor_p.h>
QT_BEGIN_NAMESPACE
@@ -42,19 +42,6 @@ QT_BEGIN_NAMESPACE
\since 5.2
\internal
\ingroup qpa
-
- This class provides a lightweight base for QPlatformScreen
- implementations. It covers basic window stack management which is
- necessary when compositing multiple raster (widget-based) windows
- together into one single native surface.
-
- Reimplementing the virtuals are essential when using
- QEGLPlatformBackingStore. The context and the window returned from
- these are the ones that are used when compositing the textures
- generated from the raster (widget) based windows.
-
- \note It is up to the QEGLPlatformWindow subclasses to use the
- functions, like addWindow(), removeWindow(), etc., provided here.
*/
QEGLPlatformScreen::QEGLPlatformScreen(EGLDisplay dpy)
@@ -64,39 +51,7 @@ QEGLPlatformScreen::QEGLPlatformScreen(EGLDisplay dpy)
QEGLPlatformScreen::~QEGLPlatformScreen()
{
- QEGLCompositor::destroy();
-}
-
-void QEGLPlatformScreen::addWindow(QEGLPlatformWindow *window)
-{
- if (!m_windows.contains(window)) {
- m_windows.append(window);
- topWindowChanged(window);
- }
-}
-
-void QEGLPlatformScreen::removeWindow(QEGLPlatformWindow *window)
-{
- m_windows.removeOne(window);
- if (!m_windows.isEmpty())
- topWindowChanged(m_windows.last());
-}
-
-void QEGLPlatformScreen::moveToTop(QEGLPlatformWindow *window)
-{
- m_windows.removeOne(window);
- m_windows.append(window);
- topWindowChanged(window);
-}
-
-void QEGLPlatformScreen::changeWindowIndex(QEGLPlatformWindow *window, int newIdx)
-{
- int idx = m_windows.indexOf(window);
- if (idx != -1 && idx != newIdx) {
- m_windows.move(idx, newIdx);
- if (newIdx == m_windows.size() - 1)
- topWindowChanged(m_windows.last());
- }
+ QOpenGLCompositor::destroy();
}
QT_END_NAMESPACE
diff --git a/src/platformsupport/eglconvenience/qeglplatformscreen_p.h b/src/platformsupport/eglconvenience/qeglplatformscreen_p.h
index bb1d26d7d2..33528e61a7 100644
--- a/src/platformsupport/eglconvenience/qeglplatformscreen_p.h
+++ b/src/platformsupport/eglconvenience/qeglplatformscreen_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -46,6 +46,7 @@
//
#include <QtCore/QList>
+#include <QtCore/qtextstream.h>
#include <qpa/qplatformscreen.h>
#include <EGL/egl.h>
@@ -60,22 +61,9 @@ public:
QEGLPlatformScreen(EGLDisplay dpy);
~QEGLPlatformScreen();
- QList<QEGLPlatformWindow *> windows() const { return m_windows; }
-
- void addWindow(QEGLPlatformWindow *window);
- void removeWindow(QEGLPlatformWindow *window);
- void moveToTop(QEGLPlatformWindow *window);
- void changeWindowIndex(QEGLPlatformWindow *window, int newIdx);
-
- virtual void topWindowChanged(QEGLPlatformWindow *window) { Q_UNUSED(window); }
-
EGLDisplay display() const { return m_dpy; }
- virtual QEGLPlatformWindow *compositingWindow() = 0;
- virtual QOpenGLContext *compositingContext() = 0;
-
private:
- QList<QEGLPlatformWindow *> m_windows;
EGLDisplay m_dpy;
};
diff --git a/src/platformsupport/eglconvenience/qeglplatformwindow.cpp b/src/platformsupport/eglconvenience/qeglplatformwindow.cpp
index 39edec4811..35f38ac29a 100644
--- a/src/platformsupport/eglconvenience/qeglplatformwindow.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformwindow.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -32,9 +32,10 @@
****************************************************************************/
#include <qpa/qwindowsysteminterface.h>
+#include <QtPlatformSupport/private/qopenglcompositor_p.h>
+#include <QtPlatformSupport/private/qopenglcompositorbackingstore_p.h>
#include "qeglplatformwindow_p.h"
-#include "qeglplatformbackingstore_p.h"
#include "qeglplatformscreen_p.h"
QT_BEGIN_NAMESPACE
@@ -47,7 +48,7 @@ QT_BEGIN_NAMESPACE
\ingroup qpa
Lightweight class providing some basic platform window operations
- and interfacing with QEGLPlatformBackingStore.
+ and interfacing with QOpenGLCompositorBackingStore.
Almost no QPlatformWindow functions are implemented here. This is
intentional because different platform plugins may use different
@@ -57,13 +58,15 @@ QT_BEGIN_NAMESPACE
enforce anything for these functions.
\note Subclasses are responsible for invoking this class'
- implementation of create(). When using QEGLPlatformScreen, the
- subclasses of this class are expected to utilize the window stack
- management functions (addWindow() etc.) provided there.
+ 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)
{
}
@@ -100,6 +103,11 @@ 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)
@@ -108,10 +116,10 @@ const QPlatformTextureList *QEGLPlatformWindow::textures() const
return 0;
}
-void QEGLPlatformWindow::composited()
+void QEGLPlatformWindow::endCompositing()
{
if (m_backingStore)
- m_backingStore->composited();
+ m_backingStore->notifyComposited();
}
WId QEGLPlatformWindow::winId() const
@@ -122,7 +130,7 @@ WId QEGLPlatformWindow::winId() const
void QEGLPlatformWindow::setOpacity(qreal)
{
if (!isRaster())
- qWarning("eglfs: Cannot set opacity for non-raster windows");
+ qWarning("QEGLPlatformWindow: Cannot set opacity for non-raster windows");
// Nothing to do here. The opacity is stored in the QWindow.
}
diff --git a/src/platformsupport/eglconvenience/qeglplatformwindow_p.h b/src/platformsupport/eglconvenience/qeglplatformwindow_p.h
index 3a19301e5d..852d690c92 100644
--- a/src/platformsupport/eglconvenience/qeglplatformwindow_p.h
+++ b/src/platformsupport/eglconvenience/qeglplatformwindow_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -46,33 +46,36 @@
//
#include <qpa/qplatformwindow.h>
+#include <QtPlatformSupport/private/qopenglcompositor_p.h>
#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
-class QEGLPlatformBackingStore;
+class QOpenGLCompositorBackingStore;
class QPlatformTextureList;
-class QEGLPlatformWindow : public QPlatformWindow
+class QEGLPlatformWindow : public QPlatformWindow, public QOpenGLCompositorWindow
{
public:
QEGLPlatformWindow(QWindow *w);
virtual void create();
- QEGLPlatformBackingStore *backingStore() { return m_backingStore; }
- void setBackingStore(QEGLPlatformBackingStore *backingStore) { m_backingStore = backingStore; }
- const QPlatformTextureList *textures() const;
- void composited();
+ 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:
- QEGLPlatformBackingStore *m_backingStore;
+ QOpenGLCompositorBackingStore *m_backingStore;
bool m_raster;
WId m_winId;
};
diff --git a/src/platformsupport/eglconvenience/qxlibeglintegration.cpp b/src/platformsupport/eglconvenience/qxlibeglintegration.cpp
index eb6e01c585..b467b7721f 100644
--- a/src/platformsupport/eglconvenience/qxlibeglintegration.cpp
+++ b/src/platformsupport/eglconvenience/qxlibeglintegration.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,16 +23,19 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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 <QLoggingCategory>
#include "qxlibeglintegration_p.h"
+Q_LOGGING_CATEGORY(lcXlibEglDebug, "qt.egl.xlib.debug")
+
VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config)
{
VisualID visualId = 0;
@@ -87,31 +90,26 @@ VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay
// configs. In such a case we have to fall back to XGetVisualInfo.
if (!visualMatchesConfig) {
visualId = 0;
-#ifdef QT_DEBUG_X11_VISUAL_SELECTION
- qWarning("Warning: EGL suggested using X Visual ID %d (%d %d %d depth %d) for EGL config %d (%d %d %d %d), but this is incompatible",
- (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, chosenVisualInfo->depth,
- configId, configRedSize, configGreenSize, configBlueSize, configAlphaSize);
-#endif
+ qCDebug(lcXlibEglDebug,
+ "EGL suggested using X Visual ID %d (%d %d %d depth %d) for EGL config %d"
+ "(%d %d %d %d), but this is incompatible",
+ (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, chosenVisualInfo->depth,
+ configId, configRedSize, configGreenSize, configBlueSize, configAlphaSize);
}
} else {
- qWarning("Warning: EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID",
- (int)visualId, configId);
+ qCDebug(lcXlibEglDebug, "EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID",
+ (int)visualId, configId);
visualId = 0;
}
XFree(chosenVisualInfo);
}
-#ifdef QT_DEBUG_X11_VISUAL_SELECTION
else
- qDebug("EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId);
-#endif
+ qCDebug(lcXlibEglDebug, "EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId);
if (visualId) {
-#ifdef QT_DEBUG_X11_VISUAL_SELECTION
- if (configAlphaSize > 0)
- qDebug("Using ARGB Visual ID %d provided by EGL for config %d", (int)visualId, configId);
- else
- qDebug("Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId);
-#endif
+ qCDebug(lcXlibEglDebug, configAlphaSize > 0
+ ? "Using ARGB Visual ID %d provided by EGL for config %d"
+ : "Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId);
return visualId;
}
@@ -143,9 +141,7 @@ VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay
}
if (visualId) {
-#ifdef QT_DEBUG_X11_VISUAL_SELECTION
- qDebug("Using Visual ID %d provided by XGetVisualInfo for EGL config %d", (int)visualId, configId);
-#endif
+ qCDebug(lcXlibEglDebug, "Using Visual ID %d provided by XGetVisualInfo for EGL config %d", (int)visualId, configId);
return visualId;
}
diff --git a/src/platformsupport/eglconvenience/qxlibeglintegration_p.h b/src/platformsupport/eglconvenience/qxlibeglintegration_p.h
index 5649195362..e42090e9fc 100644
--- a/src/platformsupport/eglconvenience/qxlibeglintegration_p.h
+++ b/src/platformsupport/eglconvenience/qxlibeglintegration_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm b/src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm
index 5e311c99b1..bd0f89ba2f 100644
--- a/src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm
+++ b/src/platformsupport/eventdispatchers/qeventdispatcher_cf.mm
@@ -1,40 +1,32 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** 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:LGPL$
+** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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.
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_cf_p.h b/src/platformsupport/eventdispatchers/qeventdispatcher_cf_p.h
index 2d1b4749f7..1cd9ae4ebf 100644
--- a/src/platformsupport/eventdispatchers/qeventdispatcher_cf_p.h
+++ b/src/platformsupport/eventdispatchers/qeventdispatcher_cf_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp b/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp
index 028fe0ce78..6877399bb7 100644
--- a/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp
+++ b/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h b/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h
index a9402f920d..13b0a14b3a 100644
--- a/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h
+++ b/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -61,7 +61,7 @@ public:
explicit QPAEventDispatcherGlib(QObject *parent = 0);
~QPAEventDispatcherGlib();
- bool processEvents(QEventLoop::ProcessEventsFlags flags);
+ bool processEvents(QEventLoop::ProcessEventsFlags flags) Q_DECL_OVERRIDE;
QEventLoop::ProcessEventsFlags m_flags;
};
diff --git a/src/platformsupport/eventdispatchers/qgenericunixeventdispatcher.cpp b/src/platformsupport/eventdispatchers/qgenericunixeventdispatcher.cpp
index ed16ab48ad..3291d48d2e 100644
--- a/src/platformsupport/eventdispatchers/qgenericunixeventdispatcher.cpp
+++ b/src/platformsupport/eventdispatchers/qgenericunixeventdispatcher.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/eventdispatchers/qgenericunixeventdispatcher_p.h b/src/platformsupport/eventdispatchers/qgenericunixeventdispatcher_p.h
index 8ff92594da..780245253a 100644
--- a/src/platformsupport/eventdispatchers/qgenericunixeventdispatcher_p.h
+++ b/src/platformsupport/eventdispatchers/qgenericunixeventdispatcher_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp b/src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp
index 0b220e4f5f..50802be46d 100644
--- a/src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp
+++ b/src/platformsupport/eventdispatchers/qunixeventdispatcher.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/eventdispatchers/qunixeventdispatcher_qpa_p.h b/src/platformsupport/eventdispatchers/qunixeventdispatcher_qpa_p.h
index 250fd14be3..25a27ba653 100644
--- a/src/platformsupport/eventdispatchers/qunixeventdispatcher_qpa_p.h
+++ b/src/platformsupport/eventdispatchers/qunixeventdispatcher_qpa_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/fbconvenience/qfbbackingstore.cpp b/src/platformsupport/fbconvenience/qfbbackingstore.cpp
index 733235ff42..bf9beac894 100644
--- a/src/platformsupport/fbconvenience/qfbbackingstore.cpp
+++ b/src/platformsupport/fbconvenience/qfbbackingstore.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/fbconvenience/qfbbackingstore_p.h b/src/platformsupport/fbconvenience/qfbbackingstore_p.h
index a9917e1450..c725cbc6d7 100644
--- a/src/platformsupport/fbconvenience/qfbbackingstore_p.h
+++ b/src/platformsupport/fbconvenience/qfbbackingstore_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -60,10 +60,10 @@ public:
QFbBackingStore(QWindow *window);
~QFbBackingStore();
- virtual QPaintDevice *paintDevice() { return &mImage; }
- virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset);
+ virtual QPaintDevice *paintDevice() Q_DECL_OVERRIDE { return &mImage; }
+ virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
- virtual void resize(const QSize &size, const QRegion &region);
+ virtual void resize(const QSize &size, const QRegion &region) Q_DECL_OVERRIDE;
const QImage image();
diff --git a/src/platformsupport/fbconvenience/qfbcursor.cpp b/src/platformsupport/fbconvenience/qfbcursor.cpp
index 49bc88d854..963d315998 100644
--- a/src/platformsupport/fbconvenience/qfbcursor.cpp
+++ b/src/platformsupport/fbconvenience/qfbcursor.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -34,14 +34,47 @@
#include "qfbcursor_p.h"
#include "qfbscreen_p.h"
#include <QtGui/QPainter>
+#include <QtGui/private/qguiapplication_p.h>
QT_BEGIN_NAMESPACE
+bool QFbCursorDeviceListener::hasMouse() const
+{
+ return QGuiApplicationPrivate::inputDeviceManager()->deviceCount(QInputDeviceManager::DeviceTypePointer) > 0;
+}
+
+void QFbCursorDeviceListener::onDeviceListChanged(QInputDeviceManager::DeviceType type)
+{
+ if (type == QInputDeviceManager::DeviceTypePointer)
+ m_cursor->updateMouseStatus();
+}
+
QFbCursor::QFbCursor(QFbScreen *screen)
- : mScreen(screen), mDirty(false), mOnScreen(false)
+ : mVisible(true),
+ mScreen(screen),
+ mDirty(false),
+ mOnScreen(false),
+ mGraphic(0),
+ mDeviceListener(0)
{
+ QByteArray hideCursorVal = qgetenv("QT_QPA_FB_HIDECURSOR");
+ if (!hideCursorVal.isEmpty())
+ mVisible = hideCursorVal.toInt() == 0;
+ if (!mVisible)
+ return;
+
mGraphic = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
setCursor(Qt::ArrowCursor);
+
+ mDeviceListener = new QFbCursorDeviceListener(this);
+ connect(QGuiApplicationPrivate::inputDeviceManager(), &QInputDeviceManager::deviceListChanged,
+ mDeviceListener, &QFbCursorDeviceListener::onDeviceListChanged);
+ updateMouseStatus();
+}
+
+QFbCursor::~QFbCursor()
+{
+ delete mDeviceListener;
}
QRect QFbCursor::getCurrentRect()
@@ -68,6 +101,9 @@ void QFbCursor::pointerEvent(const QMouseEvent & e)
QRect QFbCursor::drawCursor(QPainter & painter)
{
+ if (!mVisible)
+ return QRect();
+
mDirty = false;
if (mCurrentRect.isNull())
return QRect();
@@ -131,10 +167,19 @@ void QFbCursor::changeCursor(QCursor * widgetCursor, QWindow *window)
void QFbCursor::setDirty()
{
+ if (!mVisible)
+ return;
+
if (!mDirty) {
mDirty = true;
mScreen->scheduleUpdate();
}
}
+void QFbCursor::updateMouseStatus()
+{
+ mVisible = mDeviceListener->hasMouse();
+ mScreen->setDirty(mVisible ? getCurrentRect() : lastPainted());
+}
+
QT_END_NAMESPACE
diff --git a/src/platformsupport/fbconvenience/qfbcursor_p.h b/src/platformsupport/fbconvenience/qfbcursor_p.h
index 0354989a8b..fe3aeada4c 100644
--- a/src/platformsupport/fbconvenience/qfbcursor_p.h
+++ b/src/platformsupport/fbconvenience/qfbcursor_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -46,24 +46,44 @@
//
#include <qpa/qplatformcursor.h>
+#include <QtGui/private/qinputdevicemanager_p.h>
QT_BEGIN_NAMESPACE
class QFbScreen;
+class QFbCursor;
+
+class QFbCursorDeviceListener : public QObject
+{
+ Q_OBJECT
+
+public:
+ QFbCursorDeviceListener(QFbCursor *cursor) : m_cursor(cursor) { }
+ bool hasMouse() const;
+
+public slots:
+ void onDeviceListChanged(QInputDeviceManager::DeviceType type);
+
+private:
+ QFbCursor *m_cursor;
+};
class QFbCursor : public QPlatformCursor
{
+ Q_OBJECT
+
public:
QFbCursor(QFbScreen *screen);
+ ~QFbCursor();
// output methods
QRect dirtyRect();
virtual QRect drawCursor(QPainter &painter);
// input methods
- virtual void pointerEvent(const QMouseEvent &event);
+ virtual void pointerEvent(const QMouseEvent &event) Q_DECL_OVERRIDE;
#ifndef QT_NO_CURSOR
- virtual void changeCursor(QCursor *widgetCursor, QWindow *window);
+ virtual void changeCursor(QCursor *widgetCursor, QWindow *window) Q_DECL_OVERRIDE;
#endif
virtual void setDirty();
@@ -71,18 +91,22 @@ public:
virtual bool isOnScreen() const { return mOnScreen; }
virtual QRect lastPainted() const { return mPrevRect; }
+ void updateMouseStatus();
+
private:
void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
void setCursor(Qt::CursorShape shape);
void setCursor(const QImage &image, int hotx, int hoty);
QRect getCurrentRect();
+ bool mVisible;
QFbScreen *mScreen;
QRect mCurrentRect; // next place to draw the cursor
QRect mPrevRect; // last place the cursor was drawn
bool mDirty;
bool mOnScreen;
QPlatformCursorImage *mGraphic;
+ QFbCursorDeviceListener *mDeviceListener;
};
QT_END_NAMESPACE
diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp
index 13341344d8..04aa9f2fae 100644
--- a/src/platformsupport/fbconvenience/qfbscreen.cpp
+++ b/src/platformsupport/fbconvenience/qfbscreen.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/fbconvenience/qfbscreen_p.h b/src/platformsupport/fbconvenience/qfbscreen_p.h
index 55aacab9bc..7f2db51b00 100644
--- a/src/platformsupport/fbconvenience/qfbscreen_p.h
+++ b/src/platformsupport/fbconvenience/qfbscreen_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/fbconvenience/qfbvthandler.cpp b/src/platformsupport/fbconvenience/qfbvthandler.cpp
index 511f723dd9..d534985129 100644
--- a/src/platformsupport/fbconvenience/qfbvthandler.cpp
+++ b/src/platformsupport/fbconvenience/qfbvthandler.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -68,7 +68,7 @@ QFbVtHandler::QFbVtHandler(QObject *parent)
m_tty = 0;
::ioctl(m_tty, KDGKBMODE, &m_oldKbdMode);
- if (!qgetenv("QT_QPA_ENABLE_TERMINAL_KEYBOARD").toInt()) {
+ if (!qEnvironmentVariableIntValue("QT_QPA_ENABLE_TERMINAL_KEYBOARD")) {
::ioctl(m_tty, KDSKBMODE, KBD_OFF_MODE);
QGuiApplicationPrivate *appd = QGuiApplicationPrivate::instance();
Q_ASSERT(appd);
diff --git a/src/platformsupport/fbconvenience/qfbvthandler_p.h b/src/platformsupport/fbconvenience/qfbvthandler_p.h
index eac7f82df8..53a39fd58b 100644
--- a/src/platformsupport/fbconvenience/qfbvthandler_p.h
+++ b/src/platformsupport/fbconvenience/qfbvthandler_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/fbconvenience/qfbwindow.cpp b/src/platformsupport/fbconvenience/qfbwindow.cpp
index 93fa00d819..44a04de1ea 100644
--- a/src/platformsupport/fbconvenience/qfbwindow.cpp
+++ b/src/platformsupport/fbconvenience/qfbwindow.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/fbconvenience/qfbwindow_p.h b/src/platformsupport/fbconvenience/qfbwindow_p.h
index f1630764b0..9d90d8f8bc 100644
--- a/src/platformsupport/fbconvenience/qfbwindow_p.h
+++ b/src/platformsupport/fbconvenience/qfbwindow_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/fontdatabases/basic/basic.pri b/src/platformsupport/fontdatabases/basic/basic.pri
index c2b882ed5a..568cdf8ee7 100644
--- a/src/platformsupport/fontdatabases/basic/basic.pri
+++ b/src/platformsupport/fontdatabases/basic/basic.pri
@@ -68,6 +68,9 @@ contains(QT_CONFIG, freetype) {
$$QT_FREETYPE_DIR/builds/unix
}
+ # disable warnings about "unsafe" methods in C code
+ msvc:QMAKE_CFLAGS_WARN_ON += -wd"4996"
+
INCLUDEPATH += \
$$QT_FREETYPE_DIR/src \
$$QT_FREETYPE_DIR/include
@@ -84,4 +87,3 @@ contains(QT_CONFIG, freetype) {
# pull in the proper freetype2 include directory
include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri)
}
-
diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
index 52505c570b..65cdabdf5b 100644
--- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
+++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -52,37 +52,6 @@
QT_BEGIN_NAMESPACE
-typedef struct {
- quint16 majorVersion;
- quint16 minorVersion;
- quint16 numTables;
- quint16 searchRange;
- quint16 entrySelector;
- quint16 rangeShift;
-} OFFSET_TABLE;
-
-typedef struct {
- quint32 tag;
- quint32 checkSum;
- quint32 offset;
- quint32 length;
-} TABLE_DIRECTORY;
-
-typedef struct {
- quint16 fontSelector;
- quint16 nrCount;
- quint16 storageOffset;
-} NAME_TABLE_HEADER;
-
-typedef struct {
- quint16 platformID;
- quint16 encodingID;
- quint16 languageID;
- quint16 nameID;
- quint16 stringLength;
- quint16 stringOffset;
-} NAME_RECORD;
-
void QBasicFontDatabase::populateFontDatabase()
{
QString fontpath = fontDir();
@@ -132,9 +101,19 @@ QFontEngine *QBasicFontDatabase::fontEngine(const QFontDef &fontDef, void *usrPt
fid.index = fontfile->indexValue;
bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias);
- QFontEngineFT::GlyphFormat format = antialias? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono;
-
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(fid, antialias, format) || engine->invalid()) {
delete engine;
engine = 0;
@@ -281,41 +260,26 @@ QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByt
if (supportedWritingSystems)
*supportedWritingSystems = writingSystems;
- if (os2->usWeightClass == 0)
- ;
- else if (os2->usWeightClass < 150)
- weight = qt_thinFontWeight;
- else if (os2->usWeightClass < 250)
- weight = qt_extralightFontWeight;
- else if (os2->usWeightClass < 350)
- weight = QFont::Light;
- else if (os2->usWeightClass < 450)
- weight = QFont::Normal;
- else if (os2->usWeightClass < 550)
- weight = qt_mediumFontWeight;
- else if (os2->usWeightClass < 650)
- weight = QFont::DemiBold;
- else if (os2->usWeightClass < 750)
- weight = QFont::Bold;
- else if (os2->usWeightClass < 1000)
- weight = QFont::Black;
-
- if (os2->panose[2] >= 2) {
+ if (os2->usWeightClass) {
+ weight = QPlatformFontDatabase::weightFromInteger(os2->usWeightClass);
+ } else if (os2->panose[2]) {
int w = os2->panose[2];
if (w <= 1)
- weight = qt_thinFontWeight;
+ weight = QFont::Thin;
else if (w <= 2)
- weight = qt_extralightFontWeight;
+ weight = QFont::ExtraLight;
else if (w <= 3)
weight = QFont::Light;
else if (w <= 5)
weight = QFont::Normal;
else if (w <= 6)
- weight = qt_mediumFontWeight;
+ weight = QFont::Medium;
else if (w <= 7)
weight = QFont::DemiBold;
else if (w <= 8)
weight = QFont::Bold;
+ else if (w <= 9)
+ weight = QFont::ExtraBold;
else if (w <= 10)
weight = QFont::Black;
}
@@ -338,92 +302,4 @@ QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByt
return families;
}
-QString QBasicFontDatabase::fontNameFromTTFile(const QString &filename)
-{
- QFile f(filename);
- QString retVal;
- qint64 bytesRead;
- qint64 bytesToRead;
-
- if (f.open(QIODevice::ReadOnly)) {
- OFFSET_TABLE ttOffsetTable;
- bytesToRead = sizeof(OFFSET_TABLE);
- bytesRead = f.read((char*)&ttOffsetTable, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- ttOffsetTable.numTables = qFromBigEndian(ttOffsetTable.numTables);
- ttOffsetTable.majorVersion = qFromBigEndian(ttOffsetTable.majorVersion);
- ttOffsetTable.minorVersion = qFromBigEndian(ttOffsetTable.minorVersion);
-
- if (ttOffsetTable.majorVersion != 1 || ttOffsetTable.minorVersion != 0)
- return retVal;
-
- TABLE_DIRECTORY tblDir;
- bool found = false;
-
- for (int i = 0; i < ttOffsetTable.numTables; i++) {
- bytesToRead = sizeof(TABLE_DIRECTORY);
- bytesRead = f.read((char*)&tblDir, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- if (qFromBigEndian(tblDir.tag) == MAKE_TAG('n', 'a', 'm', 'e')) {
- found = true;
- tblDir.length = qFromBigEndian(tblDir.length);
- tblDir.offset = qFromBigEndian(tblDir.offset);
- break;
- }
- }
-
- if (found) {
- f.seek(tblDir.offset);
- NAME_TABLE_HEADER ttNTHeader;
- bytesToRead = sizeof(NAME_TABLE_HEADER);
- bytesRead = f.read((char*)&ttNTHeader, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- ttNTHeader.nrCount = qFromBigEndian(ttNTHeader.nrCount);
- ttNTHeader.storageOffset = qFromBigEndian(ttNTHeader.storageOffset);
- NAME_RECORD ttRecord;
- found = false;
-
- for (int i = 0; i < ttNTHeader.nrCount; i++) {
- bytesToRead = sizeof(NAME_RECORD);
- bytesRead = f.read((char*)&ttRecord, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- ttRecord.nameID = qFromBigEndian(ttRecord.nameID);
- if (ttRecord.nameID == 1) {
- ttRecord.stringLength = qFromBigEndian(ttRecord.stringLength);
- ttRecord.stringOffset = qFromBigEndian(ttRecord.stringOffset);
- int nPos = f.pos();
- f.seek(tblDir.offset + ttRecord.stringOffset + ttNTHeader.storageOffset);
-
- QByteArray nameByteArray = f.read(ttRecord.stringLength);
- if (!nameByteArray.isEmpty()) {
- if (ttRecord.encodingID == 256 || ttRecord.encodingID == 768) {
- //This is UTF-16 in big endian
- int stringLength = ttRecord.stringLength / 2;
- retVal.resize(stringLength);
- QChar *data = retVal.data();
- const ushort *srcData = (const ushort *)nameByteArray.data();
- for (int i = 0; i < stringLength; ++i)
- data[i] = qFromBigEndian(srcData[i]);
- return retVal;
- } else if (ttRecord.encodingID == 0) {
- //This is Latin1
- retVal = QString::fromLatin1(nameByteArray);
- } else {
- qWarning("Could not retrieve Font name from file: %s", qPrintable(QDir::toNativeSeparators(filename)));
- }
- break;
- }
- f.seek(nPos);
- }
- }
- }
- f.close();
- }
- return retVal;
-}
-
QT_END_NAMESPACE
diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h
index a37bfb9f5c..3fe1a04b0f 100644
--- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h
+++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -60,15 +60,14 @@ struct FontFile
class QBasicFontDatabase : public QPlatformFontDatabase
{
public:
- void populateFontDatabase();
- QFontEngine *fontEngine(const QFontDef &fontDef, void *handle);
- QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference);
- QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const;
- QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
- void releaseHandle(void *handle);
+ void populateFontDatabase() Q_DECL_OVERRIDE;
+ QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) Q_DECL_OVERRIDE;
+ QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) Q_DECL_OVERRIDE;
+ QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const Q_DECL_OVERRIDE;
+ QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName) Q_DECL_OVERRIDE;
+ void releaseHandle(void *handle) Q_DECL_OVERRIDE;
static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file, QSupportedWritingSystems *supportedWritingSystems = 0);
- static QString fontNameFromTTFile(const QString &filename);
};
QT_END_NAMESPACE
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index e7b03e9651..bd22a8fce5 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -54,6 +54,13 @@
QT_BEGIN_NAMESPACE
+static const int maxWeight = 99;
+
+static inline int mapToQtWeightForRange(int fcweight, int fcLower, int fcUpper, int qtLower, int qtUpper)
+{
+ return qtLower + ((fcweight - fcLower) * (qtUpper - qtLower)) / (fcUpper - fcLower);
+}
+
static inline bool requiresOpenType(int writingSystem)
{
return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala)
@@ -68,26 +75,28 @@ static inline int weightFromFcWeight(int fcweight)
// mapping. This ensures that where there is a corresponding enum on both sides (for example
// FC_WEIGHT_DEMIBOLD and QFont::DemiBold) we map one to the other but other values map
// to intermediate Qt weights.
- const int maxWeight = 99;
- int qtweight;
- if (fcweight < 0)
- qtweight = 0;
- else if (fcweight <= FC_WEIGHT_LIGHT)
- qtweight = (fcweight * QFont::Light) / FC_WEIGHT_LIGHT;
- else if (fcweight <= FC_WEIGHT_NORMAL)
- qtweight = QFont::Light + ((fcweight - FC_WEIGHT_LIGHT) * (QFont::Normal - QFont::Light)) / (FC_WEIGHT_NORMAL - FC_WEIGHT_LIGHT);
- else if (fcweight <= FC_WEIGHT_DEMIBOLD)
- qtweight = QFont::Normal + ((fcweight - FC_WEIGHT_NORMAL) * (QFont::DemiBold - QFont::Normal)) / (FC_WEIGHT_DEMIBOLD - FC_WEIGHT_NORMAL);
- else if (fcweight <= FC_WEIGHT_BOLD)
- qtweight = QFont::DemiBold + ((fcweight - FC_WEIGHT_DEMIBOLD) * (QFont::Bold - QFont::DemiBold)) / (FC_WEIGHT_BOLD - FC_WEIGHT_DEMIBOLD);
- else if (fcweight <= FC_WEIGHT_BLACK)
- qtweight = QFont::Bold + ((fcweight - FC_WEIGHT_BOLD) * (QFont::Black - QFont::Bold)) / (FC_WEIGHT_BLACK - FC_WEIGHT_BOLD);
- else if (fcweight <= FC_WEIGHT_ULTRABLACK)
- qtweight = QFont::Black + ((fcweight - FC_WEIGHT_BLACK) * (maxWeight - QFont::Black)) / (FC_WEIGHT_ULTRABLACK - FC_WEIGHT_BLACK);
- else
- qtweight = maxWeight;
- return qtweight;
+ if (fcweight <= FC_WEIGHT_THIN)
+ return QFont::Thin;
+ if (fcweight <= FC_WEIGHT_ULTRALIGHT)
+ return mapToQtWeightForRange(fcweight, FC_WEIGHT_THIN, FC_WEIGHT_ULTRALIGHT, QFont::Thin, QFont::ExtraLight);
+ if (fcweight <= FC_WEIGHT_LIGHT)
+ return mapToQtWeightForRange(fcweight, FC_WEIGHT_ULTRALIGHT, FC_WEIGHT_LIGHT, QFont::ExtraLight, QFont::Light);
+ if (fcweight <= FC_WEIGHT_NORMAL)
+ return mapToQtWeightForRange(fcweight, FC_WEIGHT_LIGHT, FC_WEIGHT_NORMAL, QFont::Light, QFont::Normal);
+ if (fcweight <= FC_WEIGHT_MEDIUM)
+ return mapToQtWeightForRange(fcweight, FC_WEIGHT_NORMAL, FC_WEIGHT_MEDIUM, QFont::Normal, QFont::Medium);
+ if (fcweight <= FC_WEIGHT_DEMIBOLD)
+ return mapToQtWeightForRange(fcweight, FC_WEIGHT_MEDIUM, FC_WEIGHT_DEMIBOLD, QFont::Medium, QFont::DemiBold);
+ if (fcweight <= FC_WEIGHT_BOLD)
+ return mapToQtWeightForRange(fcweight, FC_WEIGHT_DEMIBOLD, FC_WEIGHT_BOLD, QFont::DemiBold, QFont::Bold);
+ if (fcweight <= FC_WEIGHT_ULTRABOLD)
+ return mapToQtWeightForRange(fcweight, FC_WEIGHT_BOLD, FC_WEIGHT_ULTRABOLD, QFont::Bold, QFont::ExtraBold);
+ if (fcweight <= FC_WEIGHT_BLACK)
+ return mapToQtWeightForRange(fcweight, FC_WEIGHT_ULTRABOLD, FC_WEIGHT_BLACK, QFont::ExtraBold, QFont::Black);
+ if (fcweight <= FC_WEIGHT_ULTRABLACK)
+ return mapToQtWeightForRange(fcweight, FC_WEIGHT_BLACK, FC_WEIGHT_ULTRABLACK, QFont::Black, maxWeight);
+ return maxWeight;
}
static inline int stretchFromFcWidth(int fcwidth)
@@ -270,7 +279,7 @@ static const char *openType[] = {
"deva", // Devanagari
"beng", // Bengali
"guru", // Gurmukhi
- "gurj", // Gujarati
+ "gujr", // Gujarati
"orya", // Oriya
"taml", // Tamil
"telu", // Telugu
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
index 745d12b825..2199f39614 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -55,14 +55,14 @@ class QFontEngineFT;
class QFontconfigDatabase : public QBasicFontDatabase
{
public:
- void populateFontDatabase();
- QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script);
- QFontEngine *fontEngine(const QFontDef &fontDef, void *handle);
- QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference);
- QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const;
- QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
- QString resolveFontFamilyAlias(const QString &family) const;
- QFont defaultFont() const;
+ void populateFontDatabase() Q_DECL_OVERRIDE;
+ QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script) Q_DECL_OVERRIDE;
+ QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) Q_DECL_OVERRIDE;
+ QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) Q_DECL_OVERRIDE;
+ QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const Q_DECL_OVERRIDE;
+ QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName) Q_DECL_OVERRIDE;
+ QString resolveFontFamilyAlias(const QString &family) const Q_DECL_OVERRIDE;
+ QFont defaultFont() const Q_DECL_OVERRIDE;
private:
void setupFontEngine(QFontEngineFT *engine, const QFontDef &fontDef) const;
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp
index 956cf68290..b9bf4ab985 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -38,7 +38,7 @@
QT_BEGIN_NAMESPACE
QFontEngineMultiFontConfig::QFontEngineMultiFontConfig(QFontEngine *fe, int script)
- : QFontEngineMultiBasicImpl(fe, script)
+ : QFontEngineMulti(fe, script)
{
}
@@ -67,8 +67,8 @@ bool QFontEngineMultiFontConfig::shouldLoadFontEngineForCharacter(int at, uint u
FcPattern * QFontEngineMultiFontConfig::getMatchPatternForFallback(int fallBackIndex) const
{
Q_ASSERT(fallBackIndex < fallbackFamilyCount());
- if (engines.size() - 1 > cachedMatchPatterns.size())
- cachedMatchPatterns.resize(engines.size() - 1);
+ if (fallbackFamilyCount() > cachedMatchPatterns.size())
+ cachedMatchPatterns.resize(fallbackFamilyCount());
FcPattern *ret = cachedMatchPatterns.at(fallBackIndex);
if (ret)
return ret;
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig_p.h b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig_p.h
index 115f8e6c16..55b3512749 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig_p.h
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -50,14 +50,14 @@
QT_BEGIN_NAMESPACE
-class QFontEngineMultiFontConfig : public QFontEngineMultiBasicImpl
+class QFontEngineMultiFontConfig : public QFontEngineMulti
{
public:
explicit QFontEngineMultiFontConfig(QFontEngine *fe, int script);
~QFontEngineMultiFontConfig();
- bool shouldLoadFontEngineForCharacter(int at, uint ucs4) const;
+ bool shouldLoadFontEngineForCharacter(int at, uint ucs4) const Q_DECL_OVERRIDE;
private:
FcPattern* getMatchPatternForFallback(int at) const;
diff --git a/src/platformsupport/fontdatabases/genericunix/qgenericunixfontdatabase_p.h b/src/platformsupport/fontdatabases/genericunix/qgenericunixfontdatabase_p.h
index aad94a06d1..e982680513 100644
--- a/src/platformsupport/fontdatabases/genericunix/qgenericunixfontdatabase_p.h
+++ b/src/platformsupport/fontdatabases/genericunix/qgenericunixfontdatabase_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index fe408305e0..a022587e11 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -1,40 +1,32 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** 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:LGPL$
+** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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.
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -56,6 +48,18 @@
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[] = {
@@ -288,25 +292,9 @@ static void getFontDescription(CTFontDescriptorRef font, FontDescription *fd)
if (styles) {
if (CFNumberRef weightValue = (CFNumberRef) CFDictionaryGetValue(styles, kCTFontWeightTrait)) {
- double normalizedWeight;
- if (CFNumberGetValue(weightValue, kCFNumberDoubleType, &normalizedWeight)) {
- if (normalizedWeight >= 0.62)
- fd->weight = QFont::Black;
- else if (normalizedWeight >= 0.4)
- fd->weight = QFont::Bold;
- else if (normalizedWeight >= 0.3)
- fd->weight = QFont::DemiBold;
- else if (normalizedWeight >= 0.2)
- fd->weight = qt_mediumFontWeight;
- else if (normalizedWeight == 0.0)
- fd->weight = QFont::Normal;
- else if (normalizedWeight <= -0.4)
- fd->weight = QFont::Light;
- else if (normalizedWeight <= -0.6)
- fd->weight = qt_extralightFontWeight;
- else if (normalizedWeight <= -0.8)
- fd->weight = qt_thinFontWeight;
- }
+ float normalizedWeight;
+ if (CFNumberGetValue(weightValue, kCFNumberFloatType, &normalizedWeight))
+ fd->weight = QCoreTextFontEngine::qtWeightFromCFWeight(normalizedWeight);
}
if (CFNumberRef italic = (CFNumberRef) CFDictionaryGetValue(styles, kCTFontSlantTrait)) {
double d;
@@ -463,6 +451,8 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
Q_UNUSED(style);
Q_UNUSED(script);
+ AutoReleasePool pool;
+
static QHash<QString, QStringList> fallbackLists;
if (!family.isEmpty()) {
@@ -851,6 +841,11 @@ QFont QCoreTextFontDatabase::defaultFont() const
return QFont(defaultFontName);
}
+bool QCoreTextFontDatabase::fontsAlwaysScalable() const
+{
+ return true;
+}
+
QList<int> QCoreTextFontDatabase::standardSizes() const
{
QList<int> ret;
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
index 044db2b03d..42c8701a71 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -87,6 +87,7 @@ public:
void releaseHandle(void *handle);
bool isPrivateFontFamily(const QString &family) const;
QFont defaultFont() const;
+ bool fontsAlwaysScalable() const Q_DECL_OVERRIDE;
QList<int> standardSizes() const;
// For iOS and OS X platform themes
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
index 23fe48b493..64de364bfb 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
@@ -1,54 +1,49 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL$
+** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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.
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qfontengine_coretext_p.h"
+#include <qpa/qplatformfontdatabase.h>
#include <QtCore/qendian.h>
#include <QtCore/qsettings.h>
#include <private/qimage_p.h>
+#include <cmath>
+
QT_BEGIN_NAMESPACE
-static float SYNTHETIC_ITALIC_SKEW = tanf(14 * acosf(0) / 90);
+static float SYNTHETIC_ITALIC_SKEW = std::tan(14.f * std::acos(0.f) / 90.f);
bool QCoreTextFontEngine::ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length)
{
@@ -66,6 +61,29 @@ bool QCoreTextFontEngine::ct_getSfntTable(void *user_data, uint tag, uchar *buff
return true;
}
+QFont::Weight QCoreTextFontEngine::qtWeightFromCFWeight(float value)
+{
+ if (value >= 0.62)
+ return QFont::Black;
+ if (value >= 0.5)
+ return QFont::ExtraBold;
+ if (value >= 0.4)
+ return QFont::Bold;
+ if (value >= 0.3)
+ return QFont::DemiBold;
+ if (value >= 0.2)
+ return QFont::Medium;
+ if (value == 0.0)
+ return QFont::Normal;
+ if (value <= -0.4)
+ return QFont::Light;
+ if (value <= -0.6)
+ return QFont::ExtraLight;
+ if (value <= -0.8)
+ return QFont::Thin;
+ return QFont::Normal;
+}
+
static void loadAdvancesForGlyphs(CTFontRef ctfont,
QVarLengthArray<CGGlyph> &cgGlyphs,
QGlyphLayout *glyphs, int len,
@@ -88,6 +106,16 @@ static void loadAdvancesForGlyphs(CTFontRef ctfont,
}
}
+static float getTraitValue(CFDictionaryRef allTraits, CFStringRef trait)
+{
+ if (CFDictionaryContainsKey(allTraits, trait)) {
+ CFNumberRef traitNum = (CFNumberRef) CFDictionaryGetValue(allTraits, trait);
+ float v = 0;
+ CFNumberGetValue(traitNum, kCFNumberFloatType, &v);
+ return v;
+ }
+ return 0;
+}
int QCoreTextFontEngine::antialiasingThreshold = 0;
QFontEngine::GlyphFormat QCoreTextFontEngine::defaultGlyphFormat = QFontEngine::Format_A32;
@@ -129,39 +157,15 @@ QCoreTextFontEngine::~QCoreTextFontEngine()
CFRelease(ctfont);
}
-static QFont::Weight weightFromInteger(int weight)
-{
- if (weight < 400)
- return QFont::Light;
- else if (weight < 600)
- return QFont::Normal;
- else if (weight < 700)
- return QFont::DemiBold;
- else if (weight < 800)
- return QFont::Bold;
- else
- return QFont::Black;
-}
-
-int getTraitValue(CFDictionaryRef allTraits, CFStringRef trait)
-{
- if (CFDictionaryContainsKey(allTraits, trait)) {
- CFNumberRef traitNum = (CFNumberRef) CFDictionaryGetValue(allTraits, trait);
- float v = 0;
- CFNumberGetValue(traitNum, kCFNumberFloatType, &v);
- // the value we get from CFNumberRef is from -1.0 to 1.0
- int value = v * 500 + 500;
- return value;
- }
-
- return 0;
-}
-
void QCoreTextFontEngine::init()
{
Q_ASSERT(ctfont != NULL);
Q_ASSERT(cgFont != NULL);
+ face_id.index = 0;
+ QCFString name = CTFontCopyName(ctfont, kCTFontUniqueNameKey);
+ face_id.filename = QCFString::toQString(name).toUtf8();
+
QCFString family = CTFontCopyFamilyName(ctfont);
fontDef.family = family;
@@ -182,8 +186,8 @@ void QCoreTextFontEngine::init()
fontDef.style = QFont::StyleItalic;
CFDictionaryRef allTraits = CTFontCopyTraits(ctfont);
- fontDef.weight = weightFromInteger(getTraitValue(allTraits, kCTFontWeightTrait));
- int slant = getTraitValue(allTraits, kCTFontSlantTrait);
+ fontDef.weight = QCoreTextFontEngine::qtWeightFromCFWeight(getTraitValue(allTraits, kCTFontWeightTrait));
+ int slant = static_cast<int>(getTraitValue(allTraits, kCTFontSlantTrait) * 500 + 500);
if (slant > 500 && !(traits & kCTFontItalicTrait))
fontDef.style = QFont::StyleOblique;
CFRelease(allTraits);
@@ -646,15 +650,11 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosit
QImage im = imageForGlyph(glyph, subPixelPosition, false, x);
- QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
- QVector<QRgb> colors(256);
- for (int i=0; i<256; ++i)
- colors[i] = qRgba(0, 0, 0, i);
- indexed.setColorTable(colors);
+ QImage alphaMap(im.width(), im.height(), QImage::Format_Alpha8);
for (int y=0; y<im.height(); ++y) {
uint *src = (uint*) im.scanLine(y);
- uchar *dst = indexed.scanLine(y);
+ uchar *dst = alphaMap.scanLine(y);
for (int x=0; x<im.width(); ++x) {
*dst = qGray(*src);
++dst;
@@ -662,7 +662,7 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosit
}
}
- return indexed;
+ return alphaMap;
}
QImage QCoreTextFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &x)
@@ -700,7 +700,7 @@ void QCoreTextFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::Shap
QFontEngine::FaceId QCoreTextFontEngine::faceId() const
{
- return QFontEngine::FaceId();
+ return face_id;
}
bool QCoreTextFontEngine::canRender(const QChar *string, int len) const
@@ -714,9 +714,26 @@ bool QCoreTextFontEngine::getSfntTableData(uint tag, uchar *buffer, uint *length
return ct_getSfntTable((void *)&ctfont, tag, buffer, length);
}
-void QCoreTextFontEngine::getUnscaledGlyph(glyph_t, QPainterPath *, glyph_metrics_t *)
+void QCoreTextFontEngine::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metric)
{
- // ###
+ CGAffineTransform cgMatrix = CGAffineTransformIdentity;
+
+ qreal emSquare = CTFontGetUnitsPerEm(ctfont);
+ qreal scale = emSquare / CTFontGetSize(ctfont);
+ cgMatrix = CGAffineTransformScale(cgMatrix, scale, -scale);
+
+ QCFType<CGPathRef> cgpath = CTFontCreatePathForGlyph(ctfont, (CGGlyph) glyph, &cgMatrix);
+ ConvertPathInfo info(path, QPointF(0,0));
+ CGPathApply(cgpath, &info, convertCGPathToQPainterPath);
+
+ *metric = boundingBox(glyph);
+ // scale the metrics too
+ metric->width = QFixed::fromReal(metric->width.toReal() * scale);
+ metric->height = QFixed::fromReal(metric->height.toReal() * scale);
+ metric->x = QFixed::fromReal(metric->x.toReal() * scale);
+ metric->y = QFixed::fromReal(metric->y.toReal() * scale);
+ metric->xoff = QFixed::fromReal(metric->xoff.toReal() * scale);
+ metric->yoff = QFixed::fromReal(metric->yoff.toReal() * scale);
}
QFixed QCoreTextFontEngine::emSquareSize() const
@@ -744,4 +761,43 @@ bool QCoreTextFontEngine::supportsTransformation(const QTransform &transform) co
return false;
}
+QFontEngine::Properties QCoreTextFontEngine::properties() const
+{
+ Properties result;
+
+ QCFString psName, copyright;
+ psName = CTFontCopyPostScriptName(ctfont);
+ copyright = CTFontCopyName(ctfont, kCTFontCopyrightNameKey);
+ result.postscriptName = QCFString::toQString(psName).toUtf8();
+ result.copyright = QCFString::toQString(copyright).toUtf8();
+
+ qreal emSquare = CTFontGetUnitsPerEm(ctfont);
+ qreal scale = emSquare / CTFontGetSize(ctfont);
+
+ CGRect cgRect = CTFontGetBoundingBox(ctfont);
+ result.boundingBox = QRectF(cgRect.origin.x * scale,
+ -CTFontGetAscent(ctfont) * scale,
+ cgRect.size.width * scale,
+ cgRect.size.height * scale);
+
+ result.emSquare = emSquareSize();
+ result.ascent = QFixed::fromReal(CTFontGetAscent(ctfont) * scale);
+ result.descent = QFixed::fromReal(CTFontGetDescent(ctfont) * scale);
+ result.leading = QFixed::fromReal(CTFontGetLeading(ctfont) * scale);
+ result.italicAngle = QFixed::fromReal(CTFontGetSlantAngle(ctfont));
+ result.capHeight = QFixed::fromReal(CTFontGetCapHeight(ctfont) * scale);
+ result.lineWidth = QFixed::fromReal(CTFontGetUnderlineThickness(ctfont) * scale);
+
+ if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
+ result.ascent = result.ascent.round();
+ result.descent = result.descent.round();
+ result.leading = result.leading.round();
+ result.italicAngle = result.italicAngle.round();
+ result.capHeight = result.capHeight.round();
+ result.lineWidth = result.lineWidth.round();
+ }
+
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
index 998a6abb18..88ce2c726d 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -57,7 +57,6 @@
QT_BEGIN_NAMESPACE
-class QRawFontPrivate;
class QCoreTextFontEngine : public QFontEngine
{
public:
@@ -106,6 +105,8 @@ public:
virtual QFontEngine *cloneWithSize(qreal pixelSize) const;
virtual int glyphMargin(QFontEngine::GlyphFormat format) { Q_UNUSED(format); return 0; }
+ virtual QFontEngine::Properties properties() const;
+
static bool supportsColorGlyphs()
{
#if defined(Q_OS_IOS)
@@ -122,13 +123,11 @@ public:
}
static bool ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length);
+ static QFont::Weight qtWeightFromCFWeight(float value);
static int antialiasingThreshold;
static QFontEngine::GlyphFormat defaultGlyphFormat;
-
private:
- friend class QRawFontPrivate;
-
void init();
QImage imageForGlyph(glyph_t glyph, QFixed subPixelPosition, bool colorful, const QTransform &m);
CTFontRef ctfont;
@@ -136,6 +135,7 @@ private:
int synthesisFlags;
CGAffineTransform transform;
QFixed avgCharWidth;
+ QFontEngine::FaceId face_id;
};
CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef);
diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp
index 3a7577badf..f809f6e34d 100644
--- a/src/platformsupport/glxconvenience/qglxconvenience.cpp
+++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/glxconvenience/qglxconvenience_p.h b/src/platformsupport/glxconvenience/qglxconvenience_p.h
index 5bd05c695d..bee0d099ab 100644
--- a/src/platformsupport/glxconvenience/qglxconvenience_p.h
+++ b/src/platformsupport/glxconvenience/qglxconvenience_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h
index b596d8d2f9..34f20f462c 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboard_defaultmap_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
index 27d15dfafa..16cb94dded 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -37,20 +37,18 @@
#include <QSocketNotifier>
#include <QStringList>
-#include <qpa/qwindowsysteminterface.h>
#include <QCoreApplication>
+#include <QLoggingCategory>
+#include <qpa/qwindowsysteminterface.h>
#include <private/qcore_unix_p.h>
#include <linux/input.h>
-//#define QT_QPA_KEYMAP_DEBUG
-
-#ifdef QT_QPA_KEYMAP_DEBUG
-#include <qdebug.h>
-#endif
-
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(qLcEvdevKey, "qt.qpa.input")
+Q_LOGGING_CATEGORY(qLcEvdevKeyMap, "qt.qpa.input.keymap")
+
// simple builtin US keymap
#include "qevdevkeyboard_defaultmap_p.h"
@@ -60,9 +58,7 @@ QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, int fd, bool
m_no_zap(disableZap), m_do_compose(enableCompose),
m_keymap(0), m_keymap_size(0), m_keycompose(0), m_keycompose_size(0)
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Create keyboard handler with for device" << device;
-#endif
+ qCDebug(qLcEvdevKey) << "Create keyboard handler with for device" << device;
setObjectName(QLatin1String("LinuxInput Keyboard Handler"));
@@ -89,9 +85,7 @@ QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device,
const QString &specification,
const QString &defaultKeymapFile)
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Try to create keyboard handler for" << device << specification;
-#endif
+ qCDebug(qLcEvdevKey) << "Try to create keyboard handler for" << device << specification;
QString keymapFile = defaultKeymapFile;
int repeatDelay = 400;
@@ -116,9 +110,7 @@ QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device,
grab = arg.mid(5).toInt();
}
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Opening keyboard at" << device;
-#endif
+ qCDebug(qLcEvdevKey) << "Opening keyboard at" << device;
int fd;
fd = qt_safe_open(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
@@ -138,9 +130,7 @@ QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device,
void QEvdevKeyboardHandler::switchLed(int led, bool state)
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "switchLed" << led << state;
-#endif
+ qCDebug(qLcEvdevKey) << "switchLed" << led << state;
struct ::input_event led_ie;
::gettimeofday(&led_ie.time, 0);
@@ -153,10 +143,6 @@ void QEvdevKeyboardHandler::switchLed(int led, bool state)
void QEvdevKeyboardHandler::readKeycode()
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Read new keycode on" << m_device;
-#endif
-
struct ::input_event buffer[32];
int n = 0;
@@ -164,11 +150,11 @@ void QEvdevKeyboardHandler::readKeycode()
int result = qt_safe_read(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
if (result == 0) {
- qWarning("Got EOF from the input device.");
+ qWarning("evdevkeyboard: Got EOF from the input device");
return;
} else if (result < 0) {
if (errno != EINTR && errno != EAGAIN) {
- qWarning("Could not read from input device: %s", strerror(errno));
+ qErrnoWarning(errno, "evdevkeyboard: Could not read from input device");
return;
}
} else {
@@ -249,21 +235,17 @@ QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint
if (m_locks[0] /*CapsLock*/ && map_withmod && (map_withmod->flags & QEvdevKeyboardMap::IsLetter))
modifiers ^= QEvdevKeyboardMap::ModShift;
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", \
- keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, \
- map_plain ? map_plain - m_keymap : -1, \
- map_withmod ? map_withmod - m_keymap : -1, \
- m_keymap_size);
-#endif
+ qCDebug(qLcEvdevKeyMap, "Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d",
+ keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0,
+ int(map_plain ? map_plain - m_keymap : -1),
+ int(map_withmod ? map_withmod - m_keymap : -1),
+ m_keymap_size);
const QEvdevKeyboardMap::Mapping *it = map_withmod ? map_withmod : map_plain;
if (!it) {
-#ifdef QT_QPA_KEYMAP_DEBUG
// we couldn't even find a plain mapping
- qWarning("Could not find a suitable mapping for keycode: %3d, modifiers: %02x", keycode, modifiers);
-#endif
+ qCDebug(qLcEvdevKeyMap, "Could not find a suitable mapping for keycode: %3d, modifiers: %02x", keycode, modifiers);
return result;
}
@@ -397,9 +379,7 @@ QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint
}
if (!skip) {
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning("Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode & ~modmask, (qtcode & modmask));
-#endif
+ qCDebug(qLcEvdevKeyMap, "Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode & ~modmask, (qtcode & modmask));
//If NumLockOff and keypad key pressed remap event sent
if (!m_locks[1] &&
(qtcode & Qt::KeypadModifier) &&
@@ -457,9 +437,7 @@ QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint
void QEvdevKeyboardHandler::unloadKeymap()
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Unload current keymap and restore built-in";
-#endif
+ qCDebug(qLcEvdevKey) << "Unload current keymap and restore built-in";
if (m_keymap && m_keymap != s_keymap_default)
delete [] m_keymap;
@@ -481,7 +459,7 @@ void QEvdevKeyboardHandler::unloadKeymap()
quint16 ledbits[1];
memset(ledbits, 0, sizeof(ledbits));
if (::ioctl(m_fd, EVIOCGLED(sizeof(ledbits)), ledbits) < 0) {
- qWarning("Failed to query led states. Settings numlock & capslock off");
+ qWarning("evdevkeyboard: Failed to query led states");
switchLed(LED_NUML,false);
switchLed(LED_CAPSL, false);
switchLed(LED_SCROLLL,false);
@@ -495,17 +473,13 @@ void QEvdevKeyboardHandler::unloadKeymap()
//Scrollock
if ((ledbits[0]&0x04) > 0)
m_locks[2] = 1;
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning("numlock=%d , capslock=%d, scrolllock=%d",m_locks[1],m_locks[0],m_locks[2]);
-#endif
+ qCDebug(qLcEvdevKey, "numlock=%d , capslock=%d, scrolllock=%d", m_locks[1], m_locks[0], m_locks[2]);
}
}
bool QEvdevKeyboardHandler::loadKeymap(const QString &file)
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Load keymap" << file;
-#endif
+ qCDebug(qLcEvdevKey) << "Loading keymap" << file;
QFile f(file);
@@ -529,7 +503,7 @@ bool QEvdevKeyboardHandler::loadKeymap(const QString &file)
ds >> qmap_magic >> qmap_version >> qmap_keymap_size >> qmap_keycompose_size;
if (ds.status() != QDataStream::Ok || qmap_magic != QEvdevKeyboardMap::FileMagic || qmap_version != 1 || qmap_keymap_size == 0) {
- qWarning("'%s' is ot a valid.qmap keymap file.", qPrintable(file));
+ qWarning("'%s' is not a valid .qmap keymap file", qPrintable(file));
return false;
}
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h
index 3e3866c97b..90142c6837 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp
index 3f8eb1bcd5..437e6a125a 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -35,15 +35,15 @@
#include <QStringList>
#include <QCoreApplication>
+#include <QLoggingCategory>
-//#define QT_QPA_KEYMAP_DEBUG
-
-#ifdef QT_QPA_KEYMAP_DEBUG
-#include <QDebug>
-#endif
+#include <private/qguiapplication_p.h>
+#include <private/qinputdevicemanager_p_p.h>
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(qLcEvdevKey)
+
QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString &specification, QObject *parent)
: QObject(parent)
{
@@ -74,10 +74,7 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString &
addKeyboard(device);
if (devices.isEmpty()) {
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Use device discovery";
-#endif
-
+ qCDebug(qLcEvdevKey) << "evdevkeyboard: Using device discovery";
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Keyboard, this);
if (m_deviceDiscovery) {
// scan and add already connected keyboards
@@ -100,26 +97,26 @@ QEvdevKeyboardManager::~QEvdevKeyboardManager()
void QEvdevKeyboardManager::addKeyboard(const QString &deviceNode)
{
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Adding keyboard at" << deviceNode;
-#endif
-
+ qCDebug(qLcEvdevKey) << "Adding keyboard at" << deviceNode;
QEvdevKeyboardHandler *keyboard;
keyboard = QEvdevKeyboardHandler::create(deviceNode, m_spec, m_defaultKeymapFile);
- if (keyboard)
+ if (keyboard) {
m_keyboards.insert(deviceNode, keyboard);
- else
- qWarning("Failed to open keyboard");
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypeKeyboard, m_keyboards.count());
+ } else {
+ qWarning("Failed to open keyboard device %s", qPrintable(deviceNode));
+ }
}
void QEvdevKeyboardManager::removeKeyboard(const QString &deviceNode)
{
if (m_keyboards.contains(deviceNode)) {
-#ifdef QT_QPA_KEYMAP_DEBUG
- qWarning() << "Removing keyboard at" << deviceNode;
-#endif
+ qCDebug(qLcEvdevKey) << "Removing keyboard at" << deviceNode;
QEvdevKeyboardHandler *keyboard = m_keyboards.value(deviceNode);
m_keyboards.remove(deviceNode);
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypeKeyboard, m_keyboards.count());
delete keyboard;
}
}
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h
index 5f6c4c4b09..c0d4502940 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
index 11db06680a..2e9723329e 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
+++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -38,6 +38,7 @@
#include <QPoint>
#include <QGuiApplication>
#include <QScreen>
+#include <QLoggingCategory>
#include <qpa/qwindowsysteminterface.h>
#include <qplatformdefs.h>
@@ -48,19 +49,15 @@
#include <linux/kd.h>
#include <linux/input.h>
-#include <qdebug.h>
-
-//#define QT_QPA_MOUSE_HANDLER_DEBUG
-
#define TEST_BIT(array, bit) (array[bit/8] & (1<<(bit%8)))
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(qLcEvdevMouse, "qt.qpa.input")
+
QEvdevMouseHandler *QEvdevMouseHandler::create(const QString &device, const QString &specification)
{
-#ifdef QT_QPA_MOUSE_HANDLER_DEBUG
- qWarning() << "Try to create mouse handler for" << device << specification;
-#endif
+ qCDebug(qLcEvdevMouse) << "create mouse handler for" << device << specification;
bool compression = true;
int jitterLimit = 0;
@@ -85,7 +82,7 @@ QEvdevMouseHandler *QEvdevMouseHandler::create(const QString &device, const QStr
::ioctl(fd, EVIOCGRAB, grab);
return new QEvdevMouseHandler(device, fd, abs, compression, jitterLimit);
} else {
- qWarning("Cannot open mouse input device '%s': %s", qPrintable(device), strerror(errno));
+ qErrnoWarning(errno, "Cannot open mouse input device %s", qPrintable(device));
return 0;
}
}
@@ -148,12 +145,10 @@ bool QEvdevMouseHandler::getHardwareMaximum()
m_hardwareScalerX = static_cast<qreal>(m_hardwareWidth) / (g.right() - g.left());
m_hardwareScalerY = static_cast<qreal>(m_hardwareHeight) / (g.bottom() - g.top());
-#ifdef QT_QPA_MOUSE_HANDLER_DEBUG
- qDebug() << "Absolute pointing device";
- qDebug() << "hardware max x" << m_hardwareWidth;
- qDebug() << "hardware max y" << m_hardwareHeight;
- qDebug() << "hardware scalers x" << m_hardwareScalerX << "y" << m_hardwareScalerY;
-#endif
+ qCDebug(qLcEvdevMouse) << "Absolute pointing device"
+ << "hardware max x" << m_hardwareWidth
+ << "hardware max y" << m_hardwareHeight
+ << "hardware scalers x" << m_hardwareScalerX << "y" << m_hardwareScalerY;
return true;
}
@@ -194,11 +189,11 @@ void QEvdevMouseHandler::readMouseData()
int result = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
if (result == 0) {
- qWarning("Got EOF from the input device.");
+ qWarning("evdevmouse: Got EOF from the input device");
return;
} else if (result < 0) {
if (errno != EINTR && errno != EAGAIN) {
- qWarning("Could not read from input device: %s", strerror(errno));
+ qErrnoWarning(errno, "evdevmouse: Could not read from input device");
return;
}
} else {
@@ -212,7 +207,6 @@ void QEvdevMouseHandler::readMouseData()
for (int i = 0; i < n; ++i) {
struct ::input_event *data = &buffer[i];
- //qDebug() << ">>" << hex << data->type << data->code << dec << data->value;
if (data->type == EV_ABS) {
// Touchpads: store the absolute position for now, will calculate a relative one later.
if (data->code == ABS_X && m_x != data->value) {
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h
index cf483c9a91..172136bcc9 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h
+++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
index 2b52c4e995..6eb1fccba0 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
+++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -36,16 +36,16 @@
#include <QStringList>
#include <QGuiApplication>
#include <QScreen>
+#include <QLoggingCategory>
#include <qpa/qwindowsysteminterface.h>
-
-//#define QT_QPA_MOUSEMANAGER_DEBUG
-
-#ifdef QT_QPA_MOUSEMANAGER_DEBUG
-#include <QDebug>
-#endif
+#include <QtPlatformSupport/private/qdevicediscovery_p.h>
+#include <private/qguiapplication_p.h>
+#include <private/qinputdevicemanager_p_p.h>
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(qLcEvdevMouse)
+
QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent)
: QObject(parent), m_x(0), m_y(0), m_xoffset(0), m_yoffset(0)
{
@@ -79,10 +79,7 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif
addMouse(device);
if (devices.isEmpty()) {
-#ifdef QT_QPA_MOUSEMANAGER_DEBUG
- qWarning() << "Use device discovery";
-#endif
-
+ qCDebug(qLcEvdevMouse) << "evdevmouse: Using device discovery";
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse | QDeviceDiscovery::Device_Touchpad, this);
if (m_deviceDiscovery) {
// scan and add already connected keyboards
@@ -130,47 +127,38 @@ void QEvdevMouseManager::handleMouseEvent(int x, int y, bool abs, Qt::MouseButto
// Cannot track the keyboard modifiers ourselves here. Instead, report the
// modifiers from the last key event that has been seen by QGuiApplication.
QWindowSystemInterface::handleMouseEvent(0, pos, pos, buttons, QGuiApplication::keyboardModifiers());
-
-#ifdef QT_QPA_MOUSEMANAGER_DEBUG
- qDebug("mouse event %d %d %d", pos.x(), pos.y(), int(buttons));
-#endif
}
void QEvdevMouseManager::handleWheelEvent(int delta, Qt::Orientation orientation)
{
QPoint pos(m_x + m_xoffset, m_y + m_yoffset);
QWindowSystemInterface::handleWheelEvent(0, pos, pos, delta, orientation, QGuiApplication::keyboardModifiers());
-
-#ifdef QT_QPA_MOUSEMANAGER_DEBUG
- qDebug("mouse wheel event %dx%d %d %d", pos.x(), pos.y(), delta, int(orientation));
-#endif
}
void QEvdevMouseManager::addMouse(const QString &deviceNode)
{
-#ifdef QT_QPA_MOUSEMANAGER_DEBUG
- qWarning() << "Adding mouse at" << deviceNode;
-#endif
-
+ qCDebug(qLcEvdevMouse) << "Adding mouse at" << deviceNode;
QEvdevMouseHandler *handler;
handler = QEvdevMouseHandler::create(deviceNode, m_spec);
if (handler) {
connect(handler, SIGNAL(handleMouseEvent(int,int,bool,Qt::MouseButtons)), this, SLOT(handleMouseEvent(int,int,bool,Qt::MouseButtons)));
connect(handler, SIGNAL(handleWheelEvent(int,Qt::Orientation)), this, SLOT(handleWheelEvent(int,Qt::Orientation)));
m_mice.insert(deviceNode, handler);
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypePointer, m_mice.count());
} else {
- qWarning("Failed to open mouse");
+ qWarning("evdevmouse: Failed to open mouse device %s", qPrintable(deviceNode));
}
}
void QEvdevMouseManager::removeMouse(const QString &deviceNode)
{
if (m_mice.contains(deviceNode)) {
-#ifdef QT_QPA_MOUSEMANAGER_DEBUG
- qWarning() << "Removing mouse at" << deviceNode;
-#endif
+ qCDebug(qLcEvdevMouse) << "Removing mouse at" << deviceNode;
QEvdevMouseHandler *handler = m_mice.value(deviceNode);
m_mice.remove(deviceNode);
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypePointer, m_mice.count());
delete handler;
}
}
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h
index 14aa6a8fd2..944effd80b 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h
+++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -47,14 +47,14 @@
#include "qevdevmousehandler_p.h"
-#include <QtPlatformSupport/private/qdevicediscovery_p.h>
-
#include <QObject>
#include <QHash>
#include <QSocketNotifier>
QT_BEGIN_NAMESPACE
+class QDeviceDiscovery;
+
class QEvdevMouseManager : public QObject
{
Q_OBJECT
@@ -62,8 +62,6 @@ public:
QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent = 0);
~QEvdevMouseManager();
- QDeviceDiscovery *deviceDiscovery() { return m_deviceDiscovery; }
-
public slots:
void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons);
void handleWheelEvent(int delta, Qt::Orientation orientation);
diff --git a/src/platformsupport/input/evdevtablet/qevdevtablet.cpp b/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
index 8d91c49488..c59f0f390a 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
+++ b/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -36,13 +36,15 @@
#include <QStringList>
#include <QSocketNotifier>
#include <QGuiApplication>
-#include <QDebug>
+#include <QLoggingCategory>
#include <QtCore/private/qcore_unix_p.h>
#include <QtPlatformSupport/private/qdevicediscovery_p.h>
#include <linux/input.h>
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(qLcEvdevTablet, "qt.qpa.input")
+
class QEvdevTabletData
{
public:
@@ -87,28 +89,28 @@ bool QEvdevTabletData::queryLimits()
if (ok) {
minValues.x = absInfo.minimum;
maxValues.x = absInfo.maximum;
- qDebug("evdevtablet: min X: %d max X: %d", minValues.x, maxValues.x);
+ qCDebug(qLcEvdevTablet, "evdevtablet: min X: %d max X: %d", minValues.x, maxValues.x);
}
ok &= ioctl(fd, EVIOCGABS(ABS_Y), &absInfo) >= 0;
if (ok) {
minValues.y = absInfo.minimum;
maxValues.y = absInfo.maximum;
- qDebug("evdevtablet: min Y: %d max Y: %d", minValues.y, maxValues.y);
+ qCDebug(qLcEvdevTablet, "evdevtablet: min Y: %d max Y: %d", minValues.y, maxValues.y);
}
if (ioctl(fd, EVIOCGABS(ABS_PRESSURE), &absInfo) >= 0) {
minValues.p = absInfo.minimum;
maxValues.p = absInfo.maximum;
- qDebug("evdevtablet: min pressure: %d max pressure: %d", minValues.p, maxValues.p);
+ qCDebug(qLcEvdevTablet, "evdevtablet: min pressure: %d max pressure: %d", minValues.p, maxValues.p);
}
if (ioctl(fd, EVIOCGABS(ABS_DISTANCE), &absInfo) >= 0) {
minValues.d = absInfo.minimum;
maxValues.d = absInfo.maximum;
- qDebug("evdevtablet: min distance: %d max distance: %d", minValues.d, maxValues.d);
+ qCDebug(qLcEvdevTablet, "evdevtablet: min distance: %d max distance: %d", minValues.d, maxValues.d);
}
char name[128];
if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), name) >= 0) {
devName = QString::fromLocal8Bit(name);
- qDebug("evdevtablet: device name: %s", name);
+ qCDebug(qLcEvdevTablet, "evdevtablet: device name: %s", name);
}
return ok;
}
@@ -232,7 +234,7 @@ QEvdevTabletHandler::QEvdevTabletHandler(const QString &spec, QObject *parent)
}
}
if (!dev.isEmpty()) {
- qDebug("evdevtablet: using %s", qPrintable(dev));
+ qCDebug(qLcEvdevTablet, "evdevtablet: using %s", qPrintable(dev));
d->fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
if (d->fd >= 0) {
d->testGrab();
diff --git a/src/platformsupport/input/evdevtablet/qevdevtablet_p.h b/src/platformsupport/input/evdevtablet/qevdevtablet_p.h
index c20ddec787..f9682290d9 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtablet_p.h
+++ b/src/platformsupport/input/evdevtablet/qevdevtablet_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -73,7 +73,7 @@ class QEvdevTabletHandlerThread : public QThread
public:
explicit QEvdevTabletHandlerThread(const QString &spec, QObject *parent = 0);
~QEvdevTabletHandlerThread();
- void run();
+ void run() Q_DECL_OVERRIDE;
QEvdevTabletHandler *handler() { return m_handler; }
private:
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp
index d0d8b783a4..5215f7da0a 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -36,9 +36,11 @@
#include <QHash>
#include <QSocketNotifier>
#include <QGuiApplication>
-#include <QDebug>
+#include <QLoggingCategory>
#include <QtCore/private/qcore_unix_p.h>
#include <QtPlatformSupport/private/qdevicediscovery_p.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/private/qinputdevicemanager_p_p.h>
#include <linux/input.h>
#if !defined(QT_NO_MTDEV)
@@ -49,6 +51,8 @@ extern "C" {
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(qLcEvdevTouch, "qt.qpa.input")
+
/* android (and perhaps some other linux-derived stuff) don't define everything
* in linux/input.h, so we'll need to do that ourselves.
*/
@@ -144,6 +148,12 @@ void QEvdevTouchScreenData::registerDevice()
m_device->setCapabilities(m_device->capabilities() | QTouchDevice::Pressure);
QWindowSystemInterface::registerTouchDevice(m_device);
+
+ // No monitoring of added/removed devices is done here, so for now just
+ // increase the number of touch devices.
+ QInputDeviceManager *imgr = QGuiApplicationPrivate::inputDeviceManager();
+ QInputDeviceManagerPrivate::get(imgr)->setDeviceCount(QInputDeviceManager::DeviceTypeTouch,
+ imgr->deviceCount(QInputDeviceManager::DeviceTypeTouch) + 1);
}
#define LONG_BITS (sizeof(long) << 3)
@@ -164,7 +174,8 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
{
setObjectName(QLatin1String("Evdev Touch Handler"));
- bool printDeviceInfo = qgetenv("QT_QPA_EVDEV_DEBUG").toInt();
+ if (qEnvironmentVariableIsSet("QT_QPA_EVDEV_DEBUG"))
+ ((QLoggingCategory &) qLcEvdevTouch()).setEnabled(QtDebugMsg, true);
// only the first device argument is used for now
QString spec = QString::fromLocal8Bit(qgetenv("QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS"));
@@ -215,13 +226,11 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
}
if (dev.isEmpty()) {
- if (printDeviceInfo)
- qDebug("evdevtouch: No touch devices found");
+ qCDebug(qLcEvdevTouch, "evdevtouch: No touch devices found");
return;
}
- if (printDeviceInfo)
- qDebug("evdevtouch: Using device %s", qPrintable(dev));
+ qCDebug(qLcEvdevTouch, "evdevtouch: Using device %s", qPrintable(dev));
m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
@@ -257,25 +266,22 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
}
#endif
- if (printDeviceInfo)
- qDebug("evdevtouch: Protocol type %c %s (%s)", d->m_typeB ? 'B' : 'A',
- mtdevStr, d->m_singleTouch ? "single" : "multi");
+ qCDebug(qLcEvdevTouch, "evdevtouch: Protocol type %c %s (%s)", d->m_typeB ? 'B' : 'A',
+ mtdevStr, d->m_singleTouch ? "single" : "multi");
input_absinfo absInfo;
memset(&absInfo, 0, sizeof(input_absinfo));
bool has_x_range = false, has_y_range = false;
if (ioctl(m_fd, EVIOCGABS((d->m_singleTouch ? ABS_X : ABS_MT_POSITION_X)), &absInfo) >= 0) {
- if (printDeviceInfo)
- qDebug("evdevtouch: min X: %d max X: %d", absInfo.minimum, absInfo.maximum);
+ qCDebug(qLcEvdevTouch, "evdevtouch: min X: %d max X: %d", absInfo.minimum, absInfo.maximum);
d->hw_range_x_min = absInfo.minimum;
d->hw_range_x_max = absInfo.maximum;
has_x_range = true;
}
if (ioctl(m_fd, EVIOCGABS((d->m_singleTouch ? ABS_Y : ABS_MT_POSITION_Y)), &absInfo) >= 0) {
- if (printDeviceInfo)
- qDebug("evdevtouch: min Y: %d max Y: %d", absInfo.minimum, absInfo.maximum);
+ qCDebug(qLcEvdevTouch, "evdevtouch: min Y: %d max Y: %d", absInfo.minimum, absInfo.maximum);
d->hw_range_y_min = absInfo.minimum;
d->hw_range_y_max = absInfo.maximum;
has_y_range = true;
@@ -285,8 +291,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
qWarning("evdevtouch: Invalid ABS limits, behavior unspecified");
if (ioctl(m_fd, EVIOCGABS(ABS_PRESSURE), &absInfo) >= 0) {
- if (printDeviceInfo)
- qDebug("evdevtouch: min pressure: %d max pressure: %d", absInfo.minimum, absInfo.maximum);
+ qCDebug(qLcEvdevTouch, "evdevtouch: min pressure: %d max pressure: %d", absInfo.minimum, absInfo.maximum);
if (absInfo.maximum > absInfo.minimum) {
d->hw_pressure_min = absInfo.minimum;
d->hw_pressure_max = absInfo.maximum;
@@ -296,8 +301,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
char name[1024];
if (ioctl(m_fd, EVIOCGNAME(sizeof(name) - 1), name) >= 0) {
d->hw_name = QString::fromLocal8Bit(name);
- if (printDeviceInfo)
- qDebug("evdevtouch: device name: %s", name);
+ qCDebug(qLcEvdevTouch, "evdevtouch: device name: %s", name);
}
// Fix up the coordinate ranges for am335x in case the kernel driver does not have them fixed.
@@ -310,9 +314,8 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
d->hw_range_y_min = 220;
d->hw_range_y_max = 3907;
}
- if (printDeviceInfo)
- qDebug("evdevtouch: found ti-tsc, overriding: min X: %d max X: %d min Y: %d max Y: %d",
- d->hw_range_x_min, d->hw_range_x_max, d->hw_range_y_min, d->hw_range_y_max);
+ qCDebug(qLcEvdevTouch, "evdevtouch: found ti-tsc, overriding: min X: %d max X: %d min Y: %d max Y: %d",
+ d->hw_range_x_min, d->hw_range_x_max, d->hw_range_y_min, d->hw_range_y_max);
}
bool grabSuccess = !ioctl(m_fd, EVIOCGRAB, (void *) 1);
@@ -551,6 +554,10 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data)
while (it.hasNext()) {
it.next();
Contact &contact(it.value());
+
+ if (!contact.state)
+ continue;
+
if (contact.state == Qt::TouchPointReleased) {
if (m_typeB)
contact.state = static_cast<Qt::TouchPointState>(0);
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouch_p.h b/src/platformsupport/input/evdevtouch/qevdevtouch_p.h
index 31b2d86834..eca1bf465c 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouch_p.h
+++ b/src/platformsupport/input/evdevtouch/qevdevtouch_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -85,7 +85,7 @@ class QEvdevTouchScreenHandlerThread : public QThread
public:
explicit QEvdevTouchScreenHandlerThread(const QString &spec, QObject *parent = 0);
~QEvdevTouchScreenHandlerThread();
- void run();
+ void run() Q_DECL_OVERRIDE;
QEvdevTouchScreenHandler *handler() { return m_handler; }
private:
diff --git a/src/platformsupport/input/input.pri b/src/platformsupport/input/input.pri
index 1524eb454e..3b9593eb31 100644
--- a/src/platformsupport/input/input.pri
+++ b/src/platformsupport/input/input.pri
@@ -4,3 +4,11 @@ contains(QT_CONFIG, evdev) {
include($$PWD/evdevtouch/evdevtouch.pri)
include($$PWD/evdevtablet/evdevtablet.pri)
}
+
+contains(QT_CONFIG, tslib) {
+ include($$PWD/tslib/tslib.pri)
+}
+
+contains(QT_CONFIG, libinput) {
+ include($$PWD/libinput/libinput.pri)
+}
diff --git a/src/platformsupport/input/libinput/libinput.pri b/src/platformsupport/input/libinput/libinput.pri
new file mode 100644
index 0000000000..35d962ff3c
--- /dev/null
+++ b/src/platformsupport/input/libinput/libinput.pri
@@ -0,0 +1,23 @@
+HEADERS += \
+ $$PWD/qlibinputhandler_p.h \
+ $$PWD/qlibinputpointer_p.h \
+ $$PWD/qlibinputkeyboard_p.h \
+ $$PWD/qlibinputtouch_p.h
+
+SOURCES += \
+ $$PWD/qlibinputhandler.cpp \
+ $$PWD/qlibinputpointer.cpp \
+ $$PWD/qlibinputkeyboard.cpp \
+ $$PWD/qlibinputtouch.cpp
+
+INCLUDEPATH += $$QMAKE_INCDIR_LIBUDEV $$QMAKE_INCDIR_LIBINPUT
+LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV $$QMAKE_LIBS_LIBINPUT
+
+contains(QT_CONFIG, xkbcommon-evdev) {
+ INCLUDEPATH += $$QMAKE_INCDIR_XKBCOMMON_EVDEV
+ LIBS_PRIVATE += $$QMAKE_LIBS_XKBCOMMON_EVDEV
+} else {
+ DEFINES += QT_NO_XKBCOMMON_EVDEV
+}
+
+DEFINES += QT_LIBINPUT_VERSION_MAJOR=$$QMAKE_LIBINPUT_VERSION_MAJOR QT_LIBINPUT_VERSION_MINOR=$$QMAKE_LIBINPUT_VERSION_MINOR
diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp
new file mode 100644
index 0000000000..22b08960df
--- /dev/null
+++ b/src/platformsupport/input/libinput/qlibinputhandler.cpp
@@ -0,0 +1,230 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins module 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 "qlibinputhandler_p.h"
+#include "qlibinputpointer_p.h"
+#include "qlibinputkeyboard_p.h"
+#include "qlibinputtouch_p.h"
+
+#include <libudev.h>
+#include <libinput.h>
+#include <QtCore/QLoggingCategory>
+#include <QtCore/QSocketNotifier>
+#include <QtCore/private/qcore_unix_p.h>
+#include <private/qguiapplication_p.h>
+#include <private/qinputdevicemanager_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(qLcInput, "qt.qpa.input")
+
+static int liOpen(const char *path, int flags, void *user_data)
+{
+ Q_UNUSED(user_data);
+ return qt_safe_open(path, flags);
+}
+
+static void liClose(int fd, void *user_data)
+{
+ Q_UNUSED(user_data);
+ qt_safe_close(fd);
+}
+
+static const struct libinput_interface liInterface = {
+ liOpen,
+ liClose
+};
+
+static void liLogHandler(libinput *libinput, libinput_log_priority priority, const char *format, va_list args)
+{
+ Q_UNUSED(libinput);
+ Q_UNUSED(priority);
+
+ char buf[512];
+ int n = vsnprintf(buf, sizeof(buf), format, args);
+ if (n > 0) {
+ if (buf[n - 1] == '\n')
+ buf[n - 1] = '\0';
+ qCDebug(qLcInput, "libinput: %s", buf);
+ }
+}
+
+QLibInputHandler::QLibInputHandler(const QString &key, const QString &spec)
+{
+ Q_UNUSED(key);
+ Q_UNUSED(spec);
+
+ m_udev = udev_new();
+ if (!m_udev)
+ qFatal("Failed to get udev context for libinput");
+
+ m_li = libinput_udev_create_context(&liInterface, Q_NULLPTR, m_udev);
+ if (!m_li)
+ qFatal("Failed to get libinput context");
+
+ libinput_log_set_handler(m_li, liLogHandler);
+ if (qLcInput().isDebugEnabled())
+ libinput_log_set_priority(m_li, LIBINPUT_LOG_PRIORITY_DEBUG);
+
+ if (libinput_udev_assign_seat(m_li, "seat0"))
+ qFatal("Failed to assign seat");
+
+ m_liFd = libinput_get_fd(m_li);
+ m_notifier.reset(new QSocketNotifier(m_liFd, QSocketNotifier::Read));
+ connect(m_notifier.data(), SIGNAL(activated(int)), SLOT(onReadyRead()));
+
+ m_pointer.reset(new QLibInputPointer);
+ m_keyboard.reset(new QLibInputKeyboard);
+ m_touch.reset(new QLibInputTouch);
+
+ // Process the initial burst of DEVICE_ADDED events.
+ onReadyRead();
+}
+
+QLibInputHandler::~QLibInputHandler()
+{
+ if (m_li)
+ libinput_unref(m_li);
+
+ if (m_udev)
+ udev_unref(m_udev);
+}
+
+void QLibInputHandler::onReadyRead()
+{
+ if (libinput_dispatch(m_li)) {
+ qWarning("libinput_dispatch failed");
+ return;
+ }
+
+ libinput_event *ev;
+ while ((ev = libinput_get_event(m_li)) != Q_NULLPTR) {
+ processEvent(ev);
+ libinput_event_destroy(ev);
+ }
+}
+
+void QLibInputHandler::processEvent(libinput_event *ev)
+{
+ libinput_event_type type = libinput_event_get_type(ev);
+ libinput_device *dev = libinput_event_get_device(ev);
+
+ switch (type) {
+ case LIBINPUT_EVENT_DEVICE_ADDED:
+ {
+ // This is not just for hotplugging, it is also called for each input
+ // device libinput reads from on startup. Hence it is suitable for doing
+ // touch device registration.
+ const char *sysname = libinput_device_get_sysname(dev); // node name without path
+ const char *name = libinput_device_get_name(dev);
+ emit deviceAdded(QString::fromUtf8(sysname), QString::fromUtf8(name));
+
+ QInputDeviceManagerPrivate *inputManagerPriv = QInputDeviceManagerPrivate::get(
+ QGuiApplicationPrivate::inputDeviceManager());
+ if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) {
+ m_touch->registerDevice(dev);
+ int &count(m_devCount[QInputDeviceManager::DeviceTypeTouch]);
+ ++count;
+ inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypeTouch, count);
+ }
+ if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_POINTER)) {
+ int &count(m_devCount[QInputDeviceManager::DeviceTypePointer]);
+ ++count;
+ inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypePointer, count);
+ }
+ if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) {
+ int &count(m_devCount[QInputDeviceManager::DeviceTypeKeyboard]);
+ ++count;
+ inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypeKeyboard, count);
+ }
+ break;
+ }
+ case LIBINPUT_EVENT_DEVICE_REMOVED:
+ {
+ const char *sysname = libinput_device_get_sysname(dev);
+ const char *name = libinput_device_get_name(dev);
+ emit deviceRemoved(QString::fromUtf8(sysname), QString::fromUtf8(name));
+
+ QInputDeviceManagerPrivate *inputManagerPriv = QInputDeviceManagerPrivate::get(
+ QGuiApplicationPrivate::inputDeviceManager());
+ if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) {
+ m_touch->unregisterDevice(dev);
+ int &count(m_devCount[QInputDeviceManager::DeviceTypeTouch]);
+ --count;
+ inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypeTouch, count);
+ }
+ if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_POINTER)) {
+ int &count(m_devCount[QInputDeviceManager::DeviceTypePointer]);
+ --count;
+ inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypePointer, count);
+ }
+ if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) {
+ int &count(m_devCount[QInputDeviceManager::DeviceTypeKeyboard]);
+ --count;
+ inputManagerPriv->setDeviceCount(QInputDeviceManager::DeviceTypeKeyboard, count);
+ }
+ break;
+ }
+ case LIBINPUT_EVENT_POINTER_BUTTON:
+ m_pointer->processButton(libinput_event_get_pointer_event(ev));
+ break;
+ case LIBINPUT_EVENT_POINTER_MOTION:
+ m_pointer->processMotion(libinput_event_get_pointer_event(ev));
+ break;
+ case LIBINPUT_EVENT_POINTER_AXIS:
+ m_pointer->processAxis(libinput_event_get_pointer_event(ev));
+ break;
+ case LIBINPUT_EVENT_KEYBOARD_KEY:
+ m_keyboard->processKey(libinput_event_get_keyboard_event(ev));
+ break;
+ case LIBINPUT_EVENT_TOUCH_DOWN:
+ m_touch->processTouchDown(libinput_event_get_touch_event(ev));
+ break;
+ case LIBINPUT_EVENT_TOUCH_MOTION:
+ m_touch->processTouchMotion(libinput_event_get_touch_event(ev));
+ break;
+ case LIBINPUT_EVENT_TOUCH_UP:
+ m_touch->processTouchUp(libinput_event_get_touch_event(ev));
+ break;
+ case LIBINPUT_EVENT_TOUCH_CANCEL:
+ m_touch->processTouchCancel(libinput_event_get_touch_event(ev));
+ break;
+ case LIBINPUT_EVENT_TOUCH_FRAME:
+ m_touch->processTouchFrame(libinput_event_get_touch_event(ev));
+ break;
+ default:
+ break;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/input/libinput/qlibinputhandler_p.h b/src/platformsupport/input/libinput/qlibinputhandler_p.h
new file mode 100644
index 0000000000..5d54f984de
--- /dev/null
+++ b/src/platformsupport/input/libinput/qlibinputhandler_p.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins module 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 QLIBINPUTHANDLER_P_H
+#define QLIBINPUTHANDLER_P_H
+
+#include <QtCore/QObject>
+#include <QtCore/QScopedPointer>
+#include <QtCore/QMap>
+
+//
+// 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.
+//
+
+struct udev;
+struct libinput;
+struct libinput_event;
+
+QT_BEGIN_NAMESPACE
+
+class QSocketNotifier;
+class QLibInputPointer;
+class QLibInputKeyboard;
+class QLibInputTouch;
+
+class QLibInputHandler : public QObject
+{
+ Q_OBJECT
+
+public:
+ QLibInputHandler(const QString &key, const QString &spec);
+ ~QLibInputHandler();
+
+signals:
+ void deviceAdded(const QString &sysname, const QString &name);
+ void deviceRemoved(const QString &sysname, const QString &name);
+
+private slots:
+ void onReadyRead();
+
+private:
+ void processEvent(libinput_event *ev);
+
+ udev *m_udev;
+ libinput *m_li;
+ int m_liFd;
+ QScopedPointer<QSocketNotifier> m_notifier;
+ QScopedPointer<QLibInputPointer> m_pointer;
+ QScopedPointer<QLibInputKeyboard> m_keyboard;
+ QScopedPointer<QLibInputTouch> m_touch;
+ QMap<int, int> m_devCount;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
new file mode 100644
index 0000000000..5f1bc550b4
--- /dev/null
+++ b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp
@@ -0,0 +1,279 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins module 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 "qlibinputkeyboard_p.h"
+#include <QtCore/QTextCodec>
+#include <qpa/qwindowsysteminterface.h>
+#include <libinput.h>
+#ifndef QT_NO_XKBCOMMON_EVDEV
+#include <xkbcommon/xkbcommon-keysyms.h>
+#include <xkbcommon/xkbcommon-names.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+const int REPEAT_DELAY = 500;
+const int REPEAT_RATE = 100;
+
+#ifndef QT_NO_XKBCOMMON_EVDEV
+struct KeyTabEntry {
+ int xkbkey;
+ int qtkey;
+};
+
+static inline bool operator==(const KeyTabEntry &a, const KeyTabEntry &b)
+{
+ return a.xkbkey == b.xkbkey;
+}
+
+static const KeyTabEntry keyTab[] = {
+ { XKB_KEY_Escape, Qt::Key_Escape },
+ { XKB_KEY_Tab, Qt::Key_Tab },
+ { XKB_KEY_ISO_Left_Tab, Qt::Key_Backtab },
+ { XKB_KEY_BackSpace, Qt::Key_Backspace },
+ { XKB_KEY_Return, Qt::Key_Return },
+ { XKB_KEY_Insert, Qt::Key_Insert },
+ { XKB_KEY_Delete, Qt::Key_Delete },
+ { XKB_KEY_Clear, Qt::Key_Delete },
+ { XKB_KEY_Pause, Qt::Key_Pause },
+ { XKB_KEY_Print, Qt::Key_Print },
+
+ { XKB_KEY_Home, Qt::Key_Home },
+ { XKB_KEY_End, Qt::Key_End },
+ { XKB_KEY_Left, Qt::Key_Left },
+ { XKB_KEY_Up, Qt::Key_Up },
+ { XKB_KEY_Right, Qt::Key_Right },
+ { XKB_KEY_Down, Qt::Key_Down },
+ { XKB_KEY_Prior, Qt::Key_PageUp },
+ { XKB_KEY_Next, Qt::Key_PageDown },
+
+ { XKB_KEY_Shift_L, Qt::Key_Shift },
+ { XKB_KEY_Shift_R, Qt::Key_Shift },
+ { XKB_KEY_Shift_Lock, Qt::Key_Shift },
+ { XKB_KEY_Control_L, Qt::Key_Control },
+ { XKB_KEY_Control_R, Qt::Key_Control },
+ { XKB_KEY_Meta_L, Qt::Key_Meta },
+ { XKB_KEY_Meta_R, Qt::Key_Meta },
+ { XKB_KEY_Alt_L, Qt::Key_Alt },
+ { XKB_KEY_Alt_R, Qt::Key_Alt },
+ { XKB_KEY_Caps_Lock, Qt::Key_CapsLock },
+ { XKB_KEY_Num_Lock, Qt::Key_NumLock },
+ { XKB_KEY_Scroll_Lock, Qt::Key_ScrollLock },
+ { XKB_KEY_Super_L, Qt::Key_Super_L },
+ { XKB_KEY_Super_R, Qt::Key_Super_R },
+ { XKB_KEY_Menu, Qt::Key_Menu },
+ { XKB_KEY_Hyper_L, Qt::Key_Hyper_L },
+ { XKB_KEY_Hyper_R, Qt::Key_Hyper_R },
+ { XKB_KEY_Help, Qt::Key_Help },
+
+ { XKB_KEY_KP_Space, Qt::Key_Space },
+ { XKB_KEY_KP_Tab, Qt::Key_Tab },
+ { XKB_KEY_KP_Enter, Qt::Key_Enter },
+ { XKB_KEY_KP_Home, Qt::Key_Home },
+ { XKB_KEY_KP_Left, Qt::Key_Left },
+ { XKB_KEY_KP_Up, Qt::Key_Up },
+ { XKB_KEY_KP_Right, Qt::Key_Right },
+ { XKB_KEY_KP_Down, Qt::Key_Down },
+ { XKB_KEY_KP_Prior, Qt::Key_PageUp },
+ { XKB_KEY_KP_Next, Qt::Key_PageDown },
+ { XKB_KEY_KP_End, Qt::Key_End },
+ { XKB_KEY_KP_Begin, Qt::Key_Clear },
+ { XKB_KEY_KP_Insert, Qt::Key_Insert },
+ { XKB_KEY_KP_Delete, Qt::Key_Delete },
+ { XKB_KEY_KP_Equal, Qt::Key_Equal },
+ { XKB_KEY_KP_Multiply, Qt::Key_Asterisk },
+ { XKB_KEY_KP_Add, Qt::Key_Plus },
+ { XKB_KEY_KP_Separator, Qt::Key_Comma },
+ { XKB_KEY_KP_Subtract, Qt::Key_Minus },
+ { XKB_KEY_KP_Decimal, Qt::Key_Period },
+ { XKB_KEY_KP_Divide, Qt::Key_Slash },
+};
+#endif
+
+QLibInputKeyboard::QLibInputKeyboard()
+#ifndef QT_NO_XKBCOMMON_EVDEV
+ : m_ctx(0),
+ m_keymap(0),
+ m_state(0)
+#endif
+{
+#ifndef QT_NO_XKBCOMMON_EVDEV
+ m_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
+ if (!m_ctx) {
+ qWarning("Failed to create xkb context");
+ return;
+ }
+ m_keymap = xkb_keymap_new_from_names(m_ctx, Q_NULLPTR, XKB_KEYMAP_COMPILE_NO_FLAGS);
+ if (!m_keymap) {
+ qWarning("Failed to compile keymap");
+ return;
+ }
+ m_state = xkb_state_new(m_keymap);
+ if (!m_state) {
+ qWarning("Failed to create xkb state");
+ return;
+ }
+ m_modindex[0] = xkb_keymap_mod_get_index(m_keymap, XKB_MOD_NAME_CTRL);
+ m_modindex[1] = xkb_keymap_mod_get_index(m_keymap, XKB_MOD_NAME_ALT);
+ m_modindex[2] = xkb_keymap_mod_get_index(m_keymap, XKB_MOD_NAME_SHIFT);
+ m_modindex[3] = xkb_keymap_mod_get_index(m_keymap, XKB_MOD_NAME_LOGO);
+
+ m_repeatTimer.setSingleShot(true);
+ connect(&m_repeatTimer, &QTimer::timeout, this, &QLibInputKeyboard::handleRepeat);
+#endif
+}
+
+QLibInputKeyboard::~QLibInputKeyboard()
+{
+#ifndef QT_NO_XKBCOMMON_EVDEV
+ if (m_state)
+ xkb_state_unref(m_state);
+ if (m_keymap)
+ xkb_keymap_unref(m_keymap);
+ if (m_ctx)
+ xkb_context_unref(m_ctx);
+#endif
+}
+
+void QLibInputKeyboard::processKey(libinput_event_keyboard *e)
+{
+#ifndef QT_NO_XKBCOMMON_EVDEV
+ if (!m_ctx || !m_keymap || !m_state)
+ return;
+
+ 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);
+
+ const xkb_keysym_t sym = xkb_state_key_get_one_sym(m_state, k);
+
+ Qt::KeyboardModifiers mods = Qt::NoModifier;
+ const int qtkey = keysymToQtKey(sym, &mods, text);
+
+ xkb_state_component modtype = xkb_state_component(XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED);
+ if (xkb_state_mod_index_is_active(m_state, m_modindex[0], modtype) && (qtkey != Qt::Key_Control || !pressed))
+ mods |= Qt::ControlModifier;
+ if (xkb_state_mod_index_is_active(m_state, m_modindex[1], modtype) && (qtkey != Qt::Key_Alt || !pressed))
+ mods |= Qt::AltModifier;
+ if (xkb_state_mod_index_is_active(m_state, m_modindex[2], modtype) && (qtkey != Qt::Key_Shift || !pressed))
+ mods |= Qt::ShiftModifier;
+ if (xkb_state_mod_index_is_active(m_state, m_modindex[3], modtype) && (qtkey != Qt::Key_Meta || !pressed))
+ mods |= Qt::MetaModifier;
+
+ xkb_state_update_key(m_state, k, pressed ? XKB_KEY_DOWN : XKB_KEY_UP);
+
+ QWindowSystemInterface::handleExtendedKeyEvent(Q_NULLPTR,
+ pressed ? QEvent::KeyPress : QEvent::KeyRelease,
+ qtkey, mods, k, sym, mods, text);
+
+ if (pressed && xkb_keymap_key_repeats(m_keymap, k)) {
+ m_repeatData.qtkey = qtkey;
+ m_repeatData.mods = mods;
+ m_repeatData.nativeScanCode = k;
+ m_repeatData.virtualKey = sym;
+ m_repeatData.nativeMods = mods;
+ m_repeatData.unicodeText = text;
+ m_repeatData.repeatCount = 1;
+ m_repeatTimer.setInterval(REPEAT_DELAY);
+ m_repeatTimer.start();
+ } else if (m_repeatTimer.isActive()) {
+ m_repeatTimer.stop();
+ }
+
+#else
+ Q_UNUSED(e);
+#endif
+}
+
+#ifndef QT_NO_XKBCOMMON_EVDEV
+void QLibInputKeyboard::handleRepeat()
+{
+ QWindowSystemInterface::handleExtendedKeyEvent(Q_NULLPTR, QEvent::KeyPress,
+ m_repeatData.qtkey, m_repeatData.mods,
+ m_repeatData.nativeScanCode, m_repeatData.virtualKey, m_repeatData.nativeMods,
+ m_repeatData.unicodeText, true, m_repeatData.repeatCount);
+ m_repeatData.repeatCount += 1;
+ m_repeatTimer.setInterval(REPEAT_RATE);
+ m_repeatTimer.start();
+}
+
+int QLibInputKeyboard::keysymToQtKey(xkb_keysym_t key) const
+{
+ const size_t elemCount = sizeof(keyTab) / sizeof(KeyTabEntry);
+ KeyTabEntry e;
+ e.xkbkey = key;
+ const KeyTabEntry *result = std::find(keyTab, keyTab + elemCount, e);
+ return result != keyTab + elemCount ? result->qtkey : 0;
+}
+
+int QLibInputKeyboard::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers *modifiers, const QString &text) const
+{
+ int code = 0;
+#ifndef QT_NO_TEXTCODEC
+ QTextCodec *systemCodec = QTextCodec::codecForLocale();
+#endif
+ if (keysym < 128 || (keysym < 256
+#ifndef QT_NO_TEXTCODEC
+ && systemCodec->mibEnum() == 4
+#endif
+ )) {
+ // upper-case key, if known
+ code = isprint((int)keysym) ? toupper((int)keysym) : 0;
+ } else if (keysym >= XKB_KEY_F1 && keysym <= XKB_KEY_F35) {
+ // function keys
+ code = Qt::Key_F1 + ((int)keysym - XKB_KEY_F1);
+ } else if (keysym >= XKB_KEY_KP_Space && keysym <= XKB_KEY_KP_9) {
+ if (keysym >= XKB_KEY_KP_0) {
+ // numeric keypad keys
+ code = Qt::Key_0 + ((int)keysym - XKB_KEY_KP_0);
+ } else {
+ code = keysymToQtKey(keysym);
+ }
+ *modifiers |= Qt::KeypadModifier;
+ } else if (text.length() == 1 && text.unicode()->unicode() > 0x1f
+ && text.unicode()->unicode() != 0x7f
+ && !(keysym >= XKB_KEY_dead_grave && keysym <= XKB_KEY_dead_currency)) {
+ code = text.unicode()->toUpper().unicode();
+ } else {
+ // any other keys
+ code = keysymToQtKey(keysym);
+ }
+ return code;
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h
new file mode 100644
index 0000000000..0a04f34e05
--- /dev/null
+++ b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins module 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 QLIBINPUTKEYBOARD_P_H
+#define QLIBINPUTKEYBOARD_P_H
+
+#include <QtCore/QPoint>
+#include <QtCore/QTimer>
+
+#ifndef QT_NO_XKBCOMMON_EVDEV
+#include <xkbcommon/xkbcommon.h>
+#endif
+
+//
+// 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.
+//
+
+struct libinput_event_keyboard;
+
+QT_BEGIN_NAMESPACE
+
+class QLibInputKeyboard : public QObject
+{
+ Q_OBJECT
+
+public:
+ QLibInputKeyboard();
+ ~QLibInputKeyboard();
+
+ void processKey(libinput_event_keyboard *e);
+
+#ifndef QT_NO_XKBCOMMON_EVDEV
+private slots:
+ void handleRepeat();
+
+private:
+ int keysymToQtKey(xkb_keysym_t key) const;
+ int keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers *modifiers, const QString &text) const;
+
+ xkb_context *m_ctx;
+ xkb_keymap *m_keymap;
+ xkb_state *m_state;
+ xkb_mod_index_t m_modindex[4];
+
+ QTimer m_repeatTimer;
+
+ struct {
+ int qtkey;
+ Qt::KeyboardModifiers mods;
+ int nativeScanCode;
+ int virtualKey;
+ int nativeMods;
+ QString unicodeText;
+ int repeatCount;
+ } m_repeatData;
+#endif
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp
new file mode 100644
index 0000000000..794ac54e8e
--- /dev/null
+++ b/src/platformsupport/input/libinput/qlibinputpointer.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins module 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 "qlibinputpointer_p.h"
+#include <libinput.h>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QScreen>
+#include <qpa/qwindowsysteminterface.h>
+
+QT_BEGIN_NAMESPACE
+
+QLibInputPointer::QLibInputPointer()
+ : m_buttons(Qt::NoButton)
+{
+}
+
+void QLibInputPointer::processButton(libinput_event_pointer *e)
+{
+ const uint32_t b = libinput_event_pointer_get_button(e);
+ const bool pressed = libinput_event_pointer_get_button_state(e) == LIBINPUT_BUTTON_STATE_PRESSED;
+
+ Qt::MouseButton button = Qt::NoButton;
+ switch (b) {
+ case 0x110: button = Qt::LeftButton; break; // BTN_LEFT
+ case 0x111: button = Qt::RightButton; break;
+ case 0x112: button = Qt::MiddleButton; break;
+ case 0x113: button = Qt::ExtraButton1; break; // AKA Qt::BackButton
+ case 0x114: button = Qt::ExtraButton2; break; // AKA Qt::ForwardButton
+ case 0x115: button = Qt::ExtraButton3; break; // AKA Qt::TaskButton
+ case 0x116: button = Qt::ExtraButton4; break;
+ case 0x117: button = Qt::ExtraButton5; break;
+ case 0x118: button = Qt::ExtraButton6; break;
+ case 0x119: button = Qt::ExtraButton7; break;
+ case 0x11a: button = Qt::ExtraButton8; break;
+ case 0x11b: button = Qt::ExtraButton9; break;
+ case 0x11c: button = Qt::ExtraButton10; break;
+ case 0x11d: button = Qt::ExtraButton11; break;
+ case 0x11e: button = Qt::ExtraButton12; break;
+ case 0x11f: button = Qt::ExtraButton13; break;
+ }
+
+ if (pressed)
+ m_buttons |= button;
+ else
+ m_buttons &= ~button;
+
+ QWindowSystemInterface::handleMouseEvent(Q_NULLPTR, m_pos, m_pos, m_buttons, QGuiApplication::keyboardModifiers());
+}
+
+void QLibInputPointer::processMotion(libinput_event_pointer *e)
+{
+ const double dx = libinput_event_pointer_get_dx(e);
+ const double dy = libinput_event_pointer_get_dy(e);
+ const QRect g = QGuiApplication::primaryScreen()->virtualGeometry();
+
+ m_pos.setX(qBound(g.left(), qRound(m_pos.x() + dx), g.right()));
+ m_pos.setY(qBound(g.top(), qRound(m_pos.y() + dy), g.bottom()));
+
+ QWindowSystemInterface::handleMouseEvent(Q_NULLPTR, m_pos, m_pos, m_buttons, QGuiApplication::keyboardModifiers());
+}
+
+void QLibInputPointer::processAxis(libinput_event_pointer *e)
+{
+#if QT_LIBINPUT_VERSION_MAJOR == 0 && QT_LIBINPUT_VERSION_MINOR <= 7
+ const double v = libinput_event_pointer_get_axis_value(e) * 120;
+ const Qt::Orientation ori = libinput_event_pointer_get_axis(e) == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL
+ ? Qt::Vertical : Qt::Horizontal;
+ QWindowSystemInterface::handleWheelEvent(Q_NULLPTR, m_pos, m_pos, qRound(-v), ori, QGuiApplication::keyboardModifiers());
+#else
+ if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) {
+ const double v = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL) * 120;
+ QWindowSystemInterface::handleWheelEvent(Q_NULLPTR, m_pos, m_pos, qRound(-v), Qt::Vertical, QGuiApplication::keyboardModifiers());
+ }
+ if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) {
+ const double v = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL) * 120;
+ QWindowSystemInterface::handleWheelEvent(Q_NULLPTR, m_pos, m_pos, qRound(-v), Qt::Horizontal, QGuiApplication::keyboardModifiers());
+ }
+#endif
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/eglconvenience/qeglcompositor_p.h b/src/platformsupport/input/libinput/qlibinputpointer_p.h
index 1401fbdd55..3b0c5df1c6 100644
--- a/src/platformsupport/eglconvenience/qeglcompositor_p.h
+++ b/src/platformsupport/input/libinput/qlibinputpointer_p.h
@@ -1,18 +1,18 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the plugins module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,16 +23,18 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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 QEGLCOMPOSITOR_H
-#define QEGLCOMPOSITOR_H
+#ifndef QLIBINPUTPOINTER_P_H
+#define QLIBINPUTPOINTER_P_H
+
+#include <QtCore/QPoint>
//
// W A R N I N G
@@ -45,39 +47,24 @@
// We mean it.
//
-#include <QtCore/QTimer>
+struct libinput_event_pointer;
QT_BEGIN_NAMESPACE
-class QOpenGLContext;
-class QOpenGLTextureBlitter;
-class QEGLPlatformWindow;
-
-class QEGLCompositor : public QObject
+class QLibInputPointer
{
- Q_OBJECT
-
public:
- void schedule(QOpenGLContext *context, QEGLPlatformWindow *window);
+ QLibInputPointer();
- static QEGLCompositor *instance();
- static void destroy();
-
-private slots:
- void renderAll();
+ void processButton(libinput_event_pointer *e);
+ void processMotion(libinput_event_pointer *e);
+ void processAxis(libinput_event_pointer *e);
private:
- QEGLCompositor();
- ~QEGLCompositor();
-
- void render(QEGLPlatformWindow *window);
-
- QOpenGLContext *m_context;
- QEGLPlatformWindow *m_window;
- QTimer m_updateTimer;
- QOpenGLTextureBlitter *m_blitter;
+ QPoint m_pos;
+ Qt::MouseButtons m_buttons;
};
QT_END_NAMESPACE
-#endif // QEGLCOMPOSITOR_H
+#endif
diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp
new file mode 100644
index 0000000000..72cafb0ff7
--- /dev/null
+++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins module 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 "qlibinputtouch_p.h"
+#include <libinput.h>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QScreen>
+
+QT_BEGIN_NAMESPACE
+
+QWindowSystemInterface::TouchPoint *QLibInputTouch::DeviceState::point(int32_t slot)
+{
+ const int id = qMax(0, slot);
+
+ for (int i = 0; i < m_points.count(); ++i)
+ if (m_points.at(i).id == id)
+ return &m_points[i];
+
+ return Q_NULLPTR;
+}
+
+QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e)
+{
+ libinput_device *dev = libinput_event_get_device(libinput_event_touch_get_base_event(e));
+ return &m_devState[dev];
+}
+
+static inline QPointF getPos(libinput_event_touch *e)
+{
+ const QSize screenSize = QGuiApplication::primaryScreen()->geometry().size();
+ const double x = libinput_event_touch_get_x_transformed(e, screenSize.width());
+ const double y = libinput_event_touch_get_y_transformed(e, screenSize.height());
+ return QPointF(x, y);
+}
+
+void QLibInputTouch::registerDevice(libinput_device *dev)
+{
+ QTouchDevice *&td = m_devState[dev].m_touchDevice;
+ td = new QTouchDevice;
+ td->setName(QString::fromUtf8(libinput_device_get_name(dev)));
+ td->setType(QTouchDevice::TouchScreen);
+ td->setCapabilities(QTouchDevice::Position | QTouchDevice::Area);
+ QWindowSystemInterface::registerTouchDevice(td);
+}
+
+void QLibInputTouch::unregisterDevice(libinput_device *dev)
+{
+ Q_UNUSED(dev);
+ // There is no way to remove a QTouchDevice.
+}
+
+void QLibInputTouch::processTouchDown(libinput_event_touch *e)
+{
+ int slot = libinput_event_touch_get_slot(e);
+ DeviceState *state = deviceState(e);
+ QWindowSystemInterface::TouchPoint *tp = state->point(slot);
+ if (tp) {
+ qWarning("Incorrect touch state");
+ } else {
+ QWindowSystemInterface::TouchPoint newTp;
+ newTp.id = qMax(0, slot);
+ newTp.state = Qt::TouchPointPressed;
+ newTp.area = QRect(0, 0, 8, 8);
+ newTp.area.moveCenter(getPos(e));
+ state->m_points.append(newTp);
+ }
+}
+
+void QLibInputTouch::processTouchMotion(libinput_event_touch *e)
+{
+ int slot = libinput_event_touch_get_slot(e);
+ DeviceState *state = deviceState(e);
+ QWindowSystemInterface::TouchPoint *tp = state->point(slot);
+ if (tp) {
+ const QPointF p = getPos(e);
+ if (tp->area.center() != p) {
+ tp->area.moveCenter(p);
+ // 'down' may be followed by 'motion' within the same "frame".
+ // Handle this by compressing and keeping the Pressed state until the 'frame'.
+ if (tp->state != Qt::TouchPointPressed)
+ tp->state = Qt::TouchPointMoved;
+ } else {
+ tp->state = Qt::TouchPointStationary;
+ }
+ } else {
+ qWarning("Inconsistent touch state (got 'motion' without 'down')");
+ }
+}
+
+void QLibInputTouch::processTouchUp(libinput_event_touch *e)
+{
+ int slot = libinput_event_touch_get_slot(e);
+ DeviceState *state = deviceState(e);
+ QWindowSystemInterface::TouchPoint *tp = state->point(slot);
+ if (tp) {
+ tp->state = Qt::TouchPointReleased;
+ // There may not be a Frame event after the last Up. Work this around.
+ Qt::TouchPointStates s = 0;
+ for (int i = 0; i < state->m_points.count(); ++i)
+ s |= state->m_points.at(i).state;
+ if (s == Qt::TouchPointReleased)
+ processTouchFrame(e);
+ } else {
+ qWarning("Inconsistent touch state (got 'up' without 'down')");
+ }
+}
+
+void QLibInputTouch::processTouchCancel(libinput_event_touch *e)
+{
+ DeviceState *state = deviceState(e);
+ if (state->m_touchDevice)
+ QWindowSystemInterface::handleTouchCancelEvent(Q_NULLPTR, state->m_touchDevice, QGuiApplication::keyboardModifiers());
+ else
+ qWarning("TouchCancel without registered device");
+}
+
+void QLibInputTouch::processTouchFrame(libinput_event_touch *e)
+{
+ DeviceState *state = deviceState(e);
+ if (state->m_touchDevice && !state->m_points.isEmpty()) {
+ QWindowSystemInterface::handleTouchEvent(Q_NULLPTR, state->m_touchDevice, state->m_points,
+ QGuiApplication::keyboardModifiers());
+ for (int i = 0; i < state->m_points.count(); ++i) {
+ QWindowSystemInterface::TouchPoint &tp(state->m_points[i]);
+ if (tp.state == Qt::TouchPointReleased)
+ state->m_points.removeAt(i--);
+ else if (tp.state == Qt::TouchPointPressed)
+ tp.state = Qt::TouchPointStationary;
+ }
+ } else {
+ qWarning("TouchFrame without registered device");
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/input/libinput/qlibinputtouch_p.h b/src/platformsupport/input/libinput/qlibinputtouch_p.h
new file mode 100644
index 0000000000..03b6dbd117
--- /dev/null
+++ b/src/platformsupport/input/libinput/qlibinputtouch_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins module 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 QLIBINPUTTOUCH_P_H
+#define QLIBINPUTTOUCH_P_H
+
+#include <QtCore/QHash>
+#include <QtCore/QList>
+#include <qpa/qwindowsysteminterface.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.
+//
+
+struct libinput_event_touch;
+struct libinput_device;
+
+QT_BEGIN_NAMESPACE
+
+class QLibInputTouch
+{
+public:
+ void registerDevice(libinput_device *dev);
+ void unregisterDevice(libinput_device *dev);
+ void processTouchDown(libinput_event_touch *e);
+ void processTouchMotion(libinput_event_touch *e);
+ void processTouchUp(libinput_event_touch *e);
+ void processTouchCancel(libinput_event_touch *e);
+ void processTouchFrame(libinput_event_touch *e);
+
+private:
+ struct DeviceState {
+ DeviceState() : m_touchDevice(0) { }
+ QWindowSystemInterface::TouchPoint *point(int32_t slot);
+ QList<QWindowSystemInterface::TouchPoint> m_points;
+ QTouchDevice *m_touchDevice;
+ };
+
+ DeviceState *deviceState(libinput_event_touch *e);
+
+ QHash<libinput_device *, DeviceState> m_devState;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/platformsupport/input/tslib/qtslib.cpp b/src/platformsupport/input/tslib/qtslib.cpp
new file mode 100644
index 0000000000..e47d52ed2a
--- /dev/null
+++ b/src/platformsupport/input/tslib/qtslib.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins module 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 "qtslib_p.h"
+
+#include <QSocketNotifier>
+#include <QStringList>
+#include <QPoint>
+#include <QLoggingCategory>
+
+#include <qpa/qwindowsysteminterface.h>
+
+#include <errno.h>
+#include <tslib.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(qLcTsLib, "qt.qpa.input")
+
+QTsLibMouseHandler::QTsLibMouseHandler(const QString &key,
+ const QString &specification,
+ QObject *parent)
+ : QObject(parent),
+ m_notify(0), m_x(0), m_y(0), m_pressed(0), m_rawMode(false)
+{
+ qCDebug(qLcTsLib) << "Initializing tslib plugin" << key << specification;
+ setObjectName(QLatin1String("TSLib Mouse Handler"));
+
+ QByteArray device = qgetenv("TSLIB_TSDEVICE");
+
+ if (specification.startsWith(QStringLiteral("/dev/")))
+ device = specification.toLocal8Bit();
+
+ if (device.isEmpty())
+ device = QByteArrayLiteral("/dev/input/event1");
+
+ m_dev = ts_open(device.constData(), 1);
+ if (!m_dev) {
+ qErrnoWarning(errno, "ts_open() failed");
+ return;
+ }
+
+ if (ts_config(m_dev))
+ qErrnoWarning(errno, "ts_config() failed");
+
+ m_rawMode = !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive);
+
+ int fd = ts_fd(m_dev);
+ if (fd >= 0) {
+ qCDebug(qLcTsLib) << "tslib device is" << device;
+ m_notify = new QSocketNotifier(fd, QSocketNotifier::Read, this);
+ connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData()));
+ } else {
+ qErrnoWarning(errno, "tslib: Cannot open input device %s", device.constData());
+ }
+}
+
+QTsLibMouseHandler::~QTsLibMouseHandler()
+{
+ if (m_dev)
+ ts_close(m_dev);
+}
+
+static bool get_sample(struct tsdev *dev, struct ts_sample *sample, bool rawMode)
+{
+ if (rawMode)
+ return (ts_read_raw(dev, sample, 1) == 1);
+ else
+ return (ts_read(dev, sample, 1) == 1);
+}
+
+void QTsLibMouseHandler::readMouseData()
+{
+ ts_sample sample;
+
+ while (get_sample(m_dev, &sample, m_rawMode)) {
+ bool pressed = sample.pressure;
+ int x = sample.x;
+ int y = sample.y;
+
+ // work around missing coordinates on mouse release
+ if (sample.pressure == 0 && sample.x == 0 && sample.y == 0) {
+ x = m_x;
+ y = m_y;
+ }
+
+ if (!m_rawMode) {
+ //filtering: ignore movements of 2 pixels or less
+ int dx = x - m_x;
+ int dy = y - m_y;
+ if (dx*dx <= 4 && dy*dy <= 4 && pressed == m_pressed)
+ continue;
+ }
+ QPoint pos(x, y);
+
+ QWindowSystemInterface::handleMouseEvent(0, pos, pos, pressed ? Qt::LeftButton : Qt::NoButton);
+
+ m_x = x;
+ m_y = y;
+ m_pressed = pressed;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/input/tslib/qtslib_p.h b/src/platformsupport/input/tslib/qtslib_p.h
new file mode 100644
index 0000000000..c3ee6697fa
--- /dev/null
+++ b/src/platformsupport/input/tslib/qtslib_p.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins module 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 QTSLIB_H
+#define QTSLIB_H
+
+#include <QObject>
+
+struct tsdev;
+
+QT_BEGIN_NAMESPACE
+
+class QSocketNotifier;
+
+class QTsLibMouseHandler : public QObject
+{
+ Q_OBJECT
+
+public:
+ QTsLibMouseHandler(const QString &key, const QString &specification, QObject *parent = 0);
+ ~QTsLibMouseHandler();
+
+private slots:
+ void readMouseData();
+
+private:
+ QSocketNotifier * m_notify;
+ tsdev *m_dev;
+ int m_x, m_y;
+ bool m_pressed;
+ bool m_rawMode;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTSLIB_H
diff --git a/src/platformsupport/input/tslib/tslib.pri b/src/platformsupport/input/tslib/tslib.pri
new file mode 100644
index 0000000000..c9fef1ca8f
--- /dev/null
+++ b/src/platformsupport/input/tslib/tslib.pri
@@ -0,0 +1,7 @@
+HEADERS += \
+ $$PWD/qtslib_p.h
+
+SOURCES += \
+ $$PWD/qtslib.cpp
+
+LIBS += -lts
diff --git a/src/platformsupport/linuxaccessibility/application.cpp b/src/platformsupport/linuxaccessibility/application.cpp
index 2ee6b0a203..1166cf754a 100644
--- a/src/platformsupport/linuxaccessibility/application.cpp
+++ b/src/platformsupport/linuxaccessibility/application.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -38,6 +38,7 @@
#include <QtDBus/qdbuspendingreply.h>
#include <qdebug.h>
+#ifndef QT_NO_ACCESSIBILITY
#include "deviceeventcontroller_adaptor.h"
#include "atspi/atspi-constants.h"
@@ -229,3 +230,5 @@ void QSpiApplicationAdaptor::notifyKeyboardListenerError(const QDBusError& error
}
QT_END_NAMESPACE
+
+#endif //QT_NO_ACCESSIBILITY
diff --git a/src/platformsupport/linuxaccessibility/application_p.h b/src/platformsupport/linuxaccessibility/application_p.h
index d42f6e3ab0..5123eec03b 100644
--- a/src/platformsupport/linuxaccessibility/application_p.h
+++ b/src/platformsupport/linuxaccessibility/application_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -50,6 +50,8 @@
#include <QtDBus/QDBusConnection>
#include <QtGui/QAccessibleInterface>
+#ifndef QT_NO_ACCESSIBILITY
+
QT_BEGIN_NAMESPACE
/*
@@ -86,4 +88,6 @@ private:
QT_END_NAMESPACE
+#endif //QT_NO_ACCESSIBILITY
+
#endif
diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
index c5de6ee533..345fb5e2fa 100644
--- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -41,6 +41,7 @@
#include <qdebug.h>
+#ifndef QT_NO_ACCESSIBILITY
#include "socket_interface.h"
#include "constant_mappings_p.h"
#include "../accessibility/qaccessiblebridgeutils_p.h"
@@ -2356,3 +2357,4 @@ bool AtSpiAdaptor::tableInterface(QAccessibleInterface *interface, const QString
}
QT_END_NAMESPACE
+#endif //QT_NO_ACCESSIBILITY
diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor_p.h b/src/platformsupport/linuxaccessibility/atspiadaptor_p.h
index fa3f616c91..66e2c49c22 100644
--- a/src/platformsupport/linuxaccessibility/atspiadaptor_p.h
+++ b/src/platformsupport/linuxaccessibility/atspiadaptor_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -55,6 +55,7 @@
#include "dbusconnection_p.h"
#include "struct_marshallers_p.h"
+#ifndef QT_NO_ACCESSIBILITY
QT_BEGIN_NAMESPACE
class QAccessibleInterface;
@@ -215,5 +216,6 @@ private:
};
QT_END_NAMESPACE
+#endif //QT_NO_ACCESSIBILITY
#endif
diff --git a/src/platformsupport/linuxaccessibility/bridge.cpp b/src/platformsupport/linuxaccessibility/bridge.cpp
index 6211aa6e5a..55ef7161d1 100644
--- a/src/platformsupport/linuxaccessibility/bridge.cpp
+++ b/src/platformsupport/linuxaccessibility/bridge.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -44,6 +44,7 @@
#include "dbusconnection_p.h"
#include "struct_marshallers_p.h"
+#ifndef QT_NO_ACCESSIBILITY
#include "deviceeventcontroller_adaptor.h"
QT_BEGIN_NAMESPACE
@@ -264,3 +265,4 @@ void QSpiAccessibleBridge::initializeConstantMappings()
}
QT_END_NAMESPACE
+#endif //QT_NO_ACCESSIBILITY
diff --git a/src/platformsupport/linuxaccessibility/bridge_p.h b/src/platformsupport/linuxaccessibility/bridge_p.h
index 1daaaf92d2..802b1e4725 100644
--- a/src/platformsupport/linuxaccessibility/bridge_p.h
+++ b/src/platformsupport/linuxaccessibility/bridge_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -51,6 +51,7 @@
class DeviceEventControllerAdaptor;
+#ifndef QT_NO_ACCESSIBILITY
QT_BEGIN_NAMESPACE
class DBusConnection;
@@ -65,7 +66,7 @@ public:
virtual ~QSpiAccessibleBridge();
- virtual void notifyAccessibilityUpdate(QAccessibleEvent *event);
+ virtual void notifyAccessibilityUpdate(QAccessibleEvent *event) Q_DECL_OVERRIDE;
QDBusConnection dBusConnection() const;
public Q_SLOTS:
@@ -82,5 +83,6 @@ private:
};
QT_END_NAMESPACE
+#endif //QT_NO_ACCESSIBILITY
#endif
diff --git a/src/platformsupport/linuxaccessibility/cache.cpp b/src/platformsupport/linuxaccessibility/cache.cpp
index 296858c391..2ece905fdf 100644
--- a/src/platformsupport/linuxaccessibility/cache.cpp
+++ b/src/platformsupport/linuxaccessibility/cache.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -33,10 +33,11 @@
#include "cache_p.h"
-#include "cache_adaptor.h"
-
#include "bridge_p.h"
+#ifndef QT_NO_ACCESSIBILITY
+#include "cache_adaptor.h"
+
#define QSPI_OBJECT_PATH_CACHE "/org/a11y/atspi/cache"
QT_BEGIN_NAMESPACE
@@ -82,3 +83,4 @@ QSpiAccessibleCacheArray QSpiDBusCache::GetItems()
}
QT_END_NAMESPACE
+#endif //QT_NO_ACCESSIBILITY
diff --git a/src/platformsupport/linuxaccessibility/cache_p.h b/src/platformsupport/linuxaccessibility/cache_p.h
index 300084c493..0cd256a981 100644
--- a/src/platformsupport/linuxaccessibility/cache_p.h
+++ b/src/platformsupport/linuxaccessibility/cache_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -49,6 +49,7 @@
#include <QtCore/QObject>
#include "struct_marshallers_p.h"
+#ifndef QT_NO_ACCESSIBILITY
QT_BEGIN_NAMESPACE
class QSpiDBusCache : public QObject
@@ -69,5 +70,6 @@ public Q_SLOTS:
};
QT_END_NAMESPACE
+#endif //QT_NO_ACCESSIBILITY
#endif /* Q_SPI_CACHE_H */
diff --git a/src/platformsupport/linuxaccessibility/constant_mappings.cpp b/src/platformsupport/linuxaccessibility/constant_mappings.cpp
index 78f18124e5..79e08ecc25 100644
--- a/src/platformsupport/linuxaccessibility/constant_mappings.cpp
+++ b/src/platformsupport/linuxaccessibility/constant_mappings.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -45,6 +45,7 @@
// "ruler" "autocomplete" "edit bar" "embedded component" "entry" "caption"
// "heading" "page" "section" "redundant object" "form" "input method window" "menu"
+#ifndef QT_NO_ACCESSIBILITY
QT_BEGIN_NAMESPACE
QHash <QAccessible::Role, RoleNames> qSpiRoleMapping;
@@ -142,3 +143,4 @@ AtspiRelationType qAccessibleRelationToAtSpiRelation(QAccessible::Relation relat
}
QT_END_NAMESPACE
+#endif //QT_NO_ACCESSIBILITY
diff --git a/src/platformsupport/linuxaccessibility/constant_mappings_p.h b/src/platformsupport/linuxaccessibility/constant_mappings_p.h
index f616b56c3a..632c491614 100644
--- a/src/platformsupport/linuxaccessibility/constant_mappings_p.h
+++ b/src/platformsupport/linuxaccessibility/constant_mappings_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -55,6 +55,7 @@
#include <QtGui/QAccessible>
#include <atspi/atspi-constants.h>
+#ifndef QT_NO_ACCESSIBILITY
// interface names from at-spi2-core/atspi/atspi-misc-private.h
#define ATSPI_DBUS_NAME_REGISTRY "org.a11y.atspi.Registry"
@@ -134,5 +135,6 @@ QSpiUIntList spiStateSetFromSpiStates(quint64 states);
AtspiRelationType qAccessibleRelationToAtSpiRelation(QAccessible::Relation relation);
QT_END_NAMESPACE
+#endif //QT_NO_ACCESSIBILITY
#endif /* Q_SPI_CONSTANT_MAPPINGS_H */
diff --git a/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/src/platformsupport/linuxaccessibility/dbusconnection.cpp
index d103f9d097..45729fa065 100644
--- a/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+++ b/src/platformsupport/linuxaccessibility/dbusconnection.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/linuxaccessibility/dbusconnection_p.h b/src/platformsupport/linuxaccessibility/dbusconnection_p.h
index 0dbb964c2f..a0bd6450bf 100644
--- a/src/platformsupport/linuxaccessibility/dbusconnection_p.h
+++ b/src/platformsupport/linuxaccessibility/dbusconnection_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
diff --git a/src/platformsupport/linuxaccessibility/struct_marshallers.cpp b/src/platformsupport/linuxaccessibility/struct_marshallers.cpp
index 4b3bee8bdb..7c2ca0ad38 100644
--- a/src/platformsupport/linuxaccessibility/struct_marshallers.cpp
+++ b/src/platformsupport/linuxaccessibility/struct_marshallers.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -40,6 +40,7 @@
#include "bridge_p.h"
+#ifndef QT_NO_ACCESSIBILITY
QT_BEGIN_NAMESPACE
QSpiObjectReference::QSpiObjectReference()
@@ -227,3 +228,4 @@ void qSpiInitializeStructTypes()
}
QT_END_NAMESPACE
+#endif //QT_NO_ACCESSIBILITY
diff --git a/src/platformsupport/linuxaccessibility/struct_marshallers_p.h b/src/platformsupport/linuxaccessibility/struct_marshallers_p.h
index 21e2fdefa5..7788ceb7cc 100644
--- a/src/platformsupport/linuxaccessibility/struct_marshallers_p.h
+++ b/src/platformsupport/linuxaccessibility/struct_marshallers_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -52,6 +52,7 @@
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusObjectPath>
+#ifndef QT_NO_ACCESSIBILITY
QT_BEGIN_NAMESPACE
typedef QList <int> QSpiIntList;
@@ -175,4 +176,5 @@ Q_DECLARE_METATYPE(QSpiAttributeSet)
Q_DECLARE_METATYPE(QSpiAppUpdate)
Q_DECLARE_METATYPE(QSpiDeviceEvent)
+#endif //QT_NO_ACCESSIBILITY
#endif /* Q_SPI_STRUCT_MARSHALLERS_H */
diff --git a/src/platformsupport/platformcompositor/platformcompositor.pri b/src/platformsupport/platformcompositor/platformcompositor.pri
new file mode 100644
index 0000000000..923d7225da
--- /dev/null
+++ b/src/platformsupport/platformcompositor/platformcompositor.pri
@@ -0,0 +1,7 @@
+contains(QT_CONFIG, opengl) {
+ SOURCES += $$PWD/qopenglcompositor.cpp \
+ $$PWD/qopenglcompositorbackingstore.cpp
+
+ HEADERS += $$PWD/qopenglcompositor_p.h \
+ $$PWD/qopenglcompositorbackingstore_p.h
+}
diff --git a/src/platformsupport/platformcompositor/qopenglcompositor.cpp b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
new file mode 100644
index 0000000000..3048b2b777
--- /dev/null
+++ b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
@@ -0,0 +1,243 @@
+/****************************************************************************
+**
+** 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/QOpenGLContext>
+#include <QtGui/QWindow>
+#include <QtGui/QMatrix4x4>
+#include <qpa/qplatformbackingstore.h>
+
+#include "qopenglcompositor_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QOpenGLCompositor
+ \brief A generic OpenGL-based compositor
+ \since 5.4
+ \internal
+ \ingroup qpa
+
+ This class provides a lightweight compositor that maintains the
+ basic stacking order of windows and composites them by drawing
+ textured quads via OpenGL.
+
+ It it meant to be used by platform plugins that run without a
+ windowing system.
+
+ It is up to the platform plugin to manage the lifetime of the
+ compositor (instance(), destroy()), set the correct destination
+ context and window as early as possible (setTargetWindow()),
+ register the composited windows as they are shown, activated,
+ raised and lowered (addWindow(), moveToTop(), etc.), and to
+ schedule repaints (update()).
+
+ \note To get support for QWidget-based windows, just use
+ QOpenGLCompositorBackingStore. It will automatically create
+ textures from the raster-rendered content and trigger the
+ necessary repaints.
+ */
+
+static QOpenGLCompositor *compositor = 0;
+
+QOpenGLCompositor::QOpenGLCompositor()
+ : m_context(0),
+ m_targetWindow(0)
+{
+ Q_ASSERT(!compositor);
+ m_updateTimer.setSingleShot(true);
+ m_updateTimer.setInterval(0);
+ connect(&m_updateTimer, SIGNAL(timeout()), SLOT(renderAll()));
+}
+
+QOpenGLCompositor::~QOpenGLCompositor()
+{
+ Q_ASSERT(compositor == this);
+ m_blitter.destroy();
+ compositor = 0;
+}
+
+void QOpenGLCompositor::setTarget(QOpenGLContext *context, QWindow *targetWindow)
+{
+ m_context = context;
+ m_targetWindow = targetWindow;
+}
+
+void QOpenGLCompositor::update()
+{
+ if (!m_updateTimer.isActive())
+ m_updateTimer.start();
+}
+
+void QOpenGLCompositor::renderAll()
+{
+ Q_ASSERT(m_context && m_targetWindow);
+ m_context->makeCurrent(m_targetWindow);
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+ const QRect targetWindowRect(QPoint(0, 0), m_targetWindow->geometry().size());
+ glViewport(0, 0, targetWindowRect.width(), targetWindowRect.height());
+
+ if (!m_blitter.isCreated())
+ m_blitter.create();
+
+ m_blitter.bind();
+
+ for (int i = 0; i < m_windows.size(); ++i)
+ m_windows.at(i)->beginCompositing();
+
+ for (int i = 0; i < m_windows.size(); ++i)
+ render(m_windows.at(i));
+
+ m_blitter.release();
+ m_context->swapBuffers(m_targetWindow);
+
+ for (int i = 0; i < m_windows.size(); ++i)
+ m_windows.at(i)->endCompositing();
+}
+
+struct BlendStateBinder
+{
+ BlendStateBinder() : m_blend(false) {
+ glDisable(GL_BLEND);
+ }
+ void set(bool blend) {
+ if (blend != m_blend) {
+ if (blend) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ } else {
+ glDisable(GL_BLEND);
+ }
+ m_blend = blend;
+ }
+ }
+ ~BlendStateBinder() {
+ if (m_blend)
+ glDisable(GL_BLEND);
+ }
+ bool m_blend;
+};
+
+void QOpenGLCompositor::render(QOpenGLCompositorWindow *window)
+{
+ const QPlatformTextureList *textures = window->textures();
+ if (!textures)
+ return;
+
+ const QRect targetWindowRect(QPoint(0, 0), m_targetWindow->geometry().size());
+ float currentOpacity = 1.0f;
+ BlendStateBinder blend;
+
+ for (int i = 0; i < textures->count(); ++i) {
+ uint textureId = textures->textureId(i);
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+ const float opacity = window->sourceWindow()->opacity();
+ if (opacity != currentOpacity) {
+ currentOpacity = opacity;
+ m_blitter.setOpacity(currentOpacity);
+ }
+
+ if (textures->count() > 1 && i == textures->count() - 1) {
+ // Backingstore for a widget with QOpenGLWidget subwidgets
+ blend.set(true);
+ m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
+ } else if (textures->count() == 1) {
+ // A regular QWidget window
+ const bool translucent = window->sourceWindow()->requestedFormat().alphaBufferSize() > 0;
+ blend.set(translucent);
+ m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
+ } else if (!textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
+ // Texture from an FBO belonging to a QOpenGLWidget
+ blend.set(false);
+ m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginBottomLeft);
+ }
+ }
+
+ for (int i = 0; i < textures->count(); ++i) {
+ if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+ blend.set(true);
+ m_blitter.blit(textures->textureId(i), target, QOpenGLTextureBlitter::OriginBottomLeft);
+ }
+ }
+
+ m_blitter.setOpacity(1.0f);
+}
+
+QOpenGLCompositor *QOpenGLCompositor::instance()
+{
+ if (!compositor)
+ compositor = new QOpenGLCompositor;
+ return compositor;
+}
+
+void QOpenGLCompositor::destroy()
+{
+ delete compositor;
+ compositor = 0;
+}
+
+void QOpenGLCompositor::addWindow(QOpenGLCompositorWindow *window)
+{
+ if (!m_windows.contains(window)) {
+ m_windows.append(window);
+ emit topWindowChanged(window);
+ }
+}
+
+void QOpenGLCompositor::removeWindow(QOpenGLCompositorWindow *window)
+{
+ m_windows.removeOne(window);
+ if (!m_windows.isEmpty())
+ emit topWindowChanged(m_windows.last());
+}
+
+void QOpenGLCompositor::moveToTop(QOpenGLCompositorWindow *window)
+{
+ m_windows.removeOne(window);
+ m_windows.append(window);
+ emit topWindowChanged(window);
+}
+
+void QOpenGLCompositor::changeWindowIndex(QOpenGLCompositorWindow *window, int newIdx)
+{
+ int idx = m_windows.indexOf(window);
+ if (idx != -1 && idx != newIdx) {
+ m_windows.move(idx, newIdx);
+ if (newIdx == m_windows.size() - 1)
+ emit topWindowChanged(m_windows.last());
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/platformcompositor/qopenglcompositor_p.h b/src/platformsupport/platformcompositor/qopenglcompositor_p.h
new file mode 100644
index 0000000000..257bbf2531
--- /dev/null
+++ b/src/platformsupport/platformcompositor/qopenglcompositor_p.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** 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 QOPENGLCOMPOSITOR_H
+#define QOPENGLCOMPOSITOR_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/QTimer>
+#include <QtGui/private/qopengltextureblitter_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QOpenGLContext;
+class QWindow;
+class QPlatformTextureList;
+
+class QOpenGLCompositorWindow
+{
+public:
+ virtual QWindow *sourceWindow() const = 0;
+ virtual const QPlatformTextureList *textures() const = 0;
+ virtual void beginCompositing() { }
+ virtual void endCompositing() { }
+};
+
+class QOpenGLCompositor : public QObject
+{
+ Q_OBJECT
+
+public:
+ static QOpenGLCompositor *instance();
+ static void destroy();
+
+ void setTarget(QOpenGLContext *context, QWindow *window);
+ QOpenGLContext *context() const { return m_context; }
+ QWindow *targetWindow() const { return m_targetWindow; }
+
+ void update();
+
+ QList<QOpenGLCompositorWindow *> windows() const { return m_windows; }
+ void addWindow(QOpenGLCompositorWindow *window);
+ void removeWindow(QOpenGLCompositorWindow *window);
+ void moveToTop(QOpenGLCompositorWindow *window);
+ void changeWindowIndex(QOpenGLCompositorWindow *window, int newIdx);
+
+signals:
+ void topWindowChanged(QOpenGLCompositorWindow *window);
+
+private slots:
+ void renderAll();
+
+private:
+ QOpenGLCompositor();
+ ~QOpenGLCompositor();
+
+ void render(QOpenGLCompositorWindow *window);
+
+ QOpenGLContext *m_context;
+ QWindow *m_targetWindow;
+ QTimer m_updateTimer;
+ QOpenGLTextureBlitter m_blitter;
+ QList<QOpenGLCompositorWindow *> m_windows;
+};
+
+QT_END_NAMESPACE
+
+#endif // QOPENGLCOMPOSITOR_H
diff --git a/src/platformsupport/eglconvenience/qeglplatformbackingstore.cpp b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
index d7d95ea97d..3caec468a6 100644
--- a/src/platformsupport/eglconvenience/qeglplatformbackingstore.cpp
+++ b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,70 +23,66 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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/QOpenGLShaderProgram>
#include <QtGui/QOpenGLContext>
+#include <QtGui/QWindow>
#include <QtGui/QPainter>
+#include <qpa/qplatformbackingstore.h>
-#include "qeglplatformbackingstore_p.h"
-#include "qeglcompositor_p.h"
-#include "qeglplatformwindow_p.h"
-#include "qeglplatformscreen_p.h"
+#include "qopenglcompositorbackingstore_p.h"
+#include "qopenglcompositor_p.h"
QT_BEGIN_NAMESPACE
/*!
- \class QEGLPlatformBackingStore
- \brief A backing store implementation for EGL and GLES.
- \since 5.2
+ \class QOpenGLCompositorBackingStore
+ \brief A backing store implementation for OpenGL
+ \since 5.4
\internal
\ingroup qpa
This implementation uploads raster-rendered widget windows into
- textures and composites them onto a single native window using
- QEGLCompositor. This means that multiple top-level widgets are
- supported without creating actual native windows for each of them.
-
- The class is ready to be used as-is, the default
- QEGLPlatformIntegration::createPlatformBackingStore()
- implementation creates an instance which is ready to be used
- without further customization.
-
- If QEGLCompositor is not suitable, this backing store
- implementation can also be used without it. In this case a
- subclass must reimplement composite() and schedule an update in
- its custom compositor when this function is called. The textures
- are accessible via QEGLPlatformWindow::texture().
+ textures. It is meant to be used with QOpenGLCompositor that
+ composites the textures onto a single native window using OpenGL.
+ This means that multiple top-level widgets are supported without
+ creating actual native windows for each of them.
+
+ \note It is important to call notifyComposited() from the
+ corresponding platform window's endCompositing() callback
+ (inherited from QOpenGLCompositorWindow).
+
+ \note When implementing QOpenGLCompositorWindow::textures() for
+ windows of type RasterSurface or RasterGLSurface, simply return
+ the list provided by this class' textures().
*/
-QEGLPlatformBackingStore::QEGLPlatformBackingStore(QWindow *window)
+QOpenGLCompositorBackingStore::QOpenGLCompositorBackingStore(QWindow *window)
: QPlatformBackingStore(window),
- m_window(static_cast<QEGLPlatformWindow *>(window->handle())),
+ m_window(window),
m_bsTexture(0),
m_textures(new QPlatformTextureList),
m_lockedWidgetTextures(0)
{
- m_window->setBackingStore(this);
}
-QEGLPlatformBackingStore::~QEGLPlatformBackingStore()
+QOpenGLCompositorBackingStore::~QOpenGLCompositorBackingStore()
{
delete m_textures;
}
-QPaintDevice *QEGLPlatformBackingStore::paintDevice()
+QPaintDevice *QOpenGLCompositorBackingStore::paintDevice()
{
return &m_image;
}
-void QEGLPlatformBackingStore::updateTexture()
+void QOpenGLCompositorBackingStore::updateTexture()
{
if (!m_bsTexture) {
glGenTextures(1, &m_bsTexture);
@@ -134,7 +130,7 @@ void QEGLPlatformBackingStore::updateTexture()
}
}
-void QEGLPlatformBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
+void QOpenGLCompositorBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
// Called for ordinary raster windows. This is rare since RasterGLSurface
// support is claimed which leads to having all QWidget windows marked as
@@ -144,35 +140,38 @@ void QEGLPlatformBackingStore::flush(QWindow *window, const QRegion &region, con
Q_UNUSED(region);
Q_UNUSED(offset);
- QEGLPlatformScreen *screen = static_cast<QEGLPlatformScreen *>(m_window->screen());
- QEGLPlatformWindow *dstWin = screen->compositingWindow();
- if (!dstWin || !dstWin->isRaster())
+ QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
+ QOpenGLContext *dstCtx = compositor->context();
+ QWindow *dstWin = compositor->targetWindow();
+ if (!dstWin)
return;
- screen->compositingContext()->makeCurrent(dstWin->window());
+ dstCtx->makeCurrent(dstWin);
updateTexture();
m_textures->clear();
m_textures->appendTexture(Q_NULLPTR, m_bsTexture, window->geometry());
- composite(screen->compositingContext(), dstWin);
+
+ compositor->update();
}
-void QEGLPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
+void QOpenGLCompositorBackingStore::composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
QPlatformTextureList *textures, QOpenGLContext *context,
bool translucentBackground)
{
- // QOpenGLWidget content provided as textures. The raster content should go on top.
+ // QOpenGLWidget/QQuickWidget content provided as textures. The raster content should go on top.
Q_UNUSED(region);
Q_UNUSED(offset);
Q_UNUSED(context);
Q_UNUSED(translucentBackground);
- QEGLPlatformScreen *screen = static_cast<QEGLPlatformScreen *>(m_window->screen());
- QEGLPlatformWindow *dstWin = screen->compositingWindow();
- if (!dstWin || !dstWin->isRaster())
+ QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
+ QOpenGLContext *dstCtx = compositor->context();
+ QWindow *dstWin = compositor->targetWindow();
+ if (!dstWin)
return;
- screen->compositingContext()->makeCurrent(dstWin->window());
+ dstCtx->makeCurrent(dstWin);
m_textures->clear();
for (int i = 0; i < textures->count(); ++i)
@@ -184,15 +183,10 @@ void QEGLPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &r
textures->lock(true);
m_lockedWidgetTextures = textures;
- composite(screen->compositingContext(), dstWin);
-}
-
-void QEGLPlatformBackingStore::composite(QOpenGLContext *context, QEGLPlatformWindow *window)
-{
- QEGLCompositor::instance()->schedule(context, window);
+ compositor->update();
}
-void QEGLPlatformBackingStore::composited()
+void QOpenGLCompositorBackingStore::notifyComposited()
{
if (m_lockedWidgetTextures) {
QPlatformTextureList *textureList = m_lockedWidgetTextures;
@@ -201,7 +195,7 @@ void QEGLPlatformBackingStore::composited()
}
}
-void QEGLPlatformBackingStore::beginPaint(const QRegion &region)
+void QOpenGLCompositorBackingStore::beginPaint(const QRegion &region)
{
m_dirty |= region;
@@ -213,27 +207,28 @@ void QEGLPlatformBackingStore::beginPaint(const QRegion &region)
}
}
-void QEGLPlatformBackingStore::resize(const QSize &size, const QRegion &staticContents)
+void QOpenGLCompositorBackingStore::resize(const QSize &size, const QRegion &staticContents)
{
Q_UNUSED(staticContents);
- QEGLPlatformScreen *screen = static_cast<QEGLPlatformScreen *>(m_window->screen());
- QEGLPlatformWindow *dstWin = screen->compositingWindow();
- if (!dstWin || (!dstWin->isRaster() && dstWin->window()->surfaceType() != QSurface::RasterGLSurface))
+ QOpenGLCompositor *compositor = QOpenGLCompositor::instance();
+ QOpenGLContext *dstCtx = compositor->context();
+ QWindow *dstWin = compositor->targetWindow();
+ if (!dstWin)
return;
m_image = QImage(size, QImage::Format_RGBA8888);
m_window->create();
- screen->compositingContext()->makeCurrent(dstWin->window());
+ dstCtx->makeCurrent(dstWin);
if (m_bsTexture) {
glDeleteTextures(1, &m_bsTexture);
m_bsTexture = 0;
}
}
-QImage QEGLPlatformBackingStore::toImage() const
+QImage QOpenGLCompositorBackingStore::toImage() const
{
return m_image;
}
diff --git a/src/platformsupport/eglconvenience/qeglplatformbackingstore_p.h b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore_p.h
index 502ca5a639..49d8bfd6e7 100644
--- a/src/platformsupport/eglconvenience/qeglplatformbackingstore_p.h
+++ b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,16 +23,16 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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 QEGLPLATFORMBACKINGSTORE_H
-#define QEGLPLATFORMBACKINGSTORE_H
+#ifndef QOPENGLCOMPOSITORBACKINGSTORE_H
+#define QOPENGLCOMPOSITORBACKINGSTORE_H
//
// W A R N I N G
@@ -46,7 +46,6 @@
//
#include <qpa/qplatformbackingstore.h>
-
#include <QImage>
#include <QRegion>
@@ -54,13 +53,12 @@ QT_BEGIN_NAMESPACE
class QOpenGLContext;
class QPlatformTextureList;
-class QEGLPlatformWindow;
-class QEGLPlatformBackingStore : public QPlatformBackingStore
+class QOpenGLCompositorBackingStore : public QPlatformBackingStore
{
public:
- QEGLPlatformBackingStore(QWindow *window);
- ~QEGLPlatformBackingStore();
+ QOpenGLCompositorBackingStore(QWindow *window);
+ ~QOpenGLCompositorBackingStore();
QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
@@ -76,14 +74,12 @@ public:
const QPlatformTextureList *textures() const { return m_textures; }
- virtual void composite(QOpenGLContext *context, QEGLPlatformWindow *window);
-
- void composited();
+ void notifyComposited();
private:
void updateTexture();
- QEGLPlatformWindow *m_window;
+ QWindow *m_window;
QImage m_image;
QRegion m_dirty;
uint m_bsTexture;
@@ -93,4 +89,4 @@ private:
QT_END_NAMESPACE
-#endif // QEGLPLATFORMBACKINGSTORE_H
+#endif // QOPENGLCOMPOSITORBACKINGSTORE_H
diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro
index 32ce2e3887..34e2ed3c9b 100644
--- a/src/platformsupport/platformsupport.pro
+++ b/src/platformsupport/platformsupport.pro
@@ -21,5 +21,10 @@ include(themes/themes.pri)
include(accessibility/accessibility.pri)
include(linuxaccessibility/linuxaccessibility.pri)
include(clipboard/clipboard.pri)
+include(platformcompositor/platformcompositor.pri)
+contains(QT_CONFIG, dbus) {
+ include(dbusmenu/dbusmenu.pri)
+ include(dbustray/dbustray.pri)
+}
load(qt_module)
diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp
index e8dd190b52..b59ae431f4 100644
--- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -72,7 +72,7 @@ static inline bool checkExecutable(const QString &candidate, QString *result)
return !result->isEmpty();
}
-static inline bool detectWebBrowser(QByteArray desktop,
+static inline bool detectWebBrowser(const QByteArray &desktop,
bool checkBrowserVariable,
QString *browser)
{
diff --git a/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/src/platformsupport/services/genericunix/qgenericunixservices_p.h
index f24912278b..0c15d62165 100644
--- a/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+++ b/src/platformsupport/services/genericunix/qgenericunixservices_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -55,10 +55,10 @@ class QGenericUnixServices : public QPlatformServices
public:
QGenericUnixServices() {}
- QByteArray desktopEnvironment() const;
+ QByteArray desktopEnvironment() const Q_DECL_OVERRIDE;
- virtual bool openUrl(const QUrl &url);
- virtual bool openDocument(const QUrl &url);
+ virtual bool openUrl(const QUrl &url) Q_DECL_OVERRIDE;
+ virtual bool openDocument(const QUrl &url) Q_DECL_OVERRIDE;
private:
QString m_webBrowser;
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index e66fdeb7c3..ba328bfb41 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -44,6 +44,7 @@
#include <QtCore/QFile>
#include <QtCore/QDebug>
#include <QtCore/QHash>
+#include <QtCore/QLoggingCategory>
#include <QtCore/QSettings>
#include <QtCore/QVariant>
#include <QtCore/QStringList>
@@ -51,11 +52,17 @@
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformservices.h>
#include <qpa/qplatformdialoghelper.h>
+#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
+#include "QtPlatformSupport/private/qdbustrayicon_p.h"
+#include "QtPlatformSupport/private/qdbusplatformmenu_p.h"
+#endif
#include <algorithm>
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(qLcTray)
+
ResourceHelper::ResourceHelper()
{
std::fill(palettes, palettes + QPlatformTheme::NPalettes, static_cast<QPalette *>(0));
@@ -85,6 +92,21 @@ const char *QGenericUnixTheme::name = "generic";
static const char defaultSystemFontNameC[] = "Sans Serif";
enum { defaultSystemFontSize = 9 };
+#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
+static bool isDBusTrayAvailable() {
+ static bool dbusTrayAvailable = false;
+ static bool dbusTrayAvailableKnown = false;
+ if (!dbusTrayAvailableKnown) {
+ QDBusMenuConnection conn;
+ if (conn.isStatusNotifierHostRegistered())
+ dbusTrayAvailable = true;
+ dbusTrayAvailableKnown = true;
+ qCDebug(qLcTray) << "D-Bus tray available:" << dbusTrayAvailable;
+ }
+ return dbusTrayAvailable;
+}
+#endif
+
class QGenericUnixThemePrivate : public QPlatformThemePrivate
{
public:
@@ -135,9 +157,23 @@ QStringList QGenericUnixTheme::xdgIconThemePaths()
if (xdgIconsDir.isDir())
paths.append(xdgIconsDir.absoluteFilePath());
}
+
+ const QFileInfo pixmapsIconsDir(QStringLiteral("/usr/share/pixmaps"));
+ if (pixmapsIconsDir.isDir())
+ paths.append(pixmapsIconsDir.absoluteFilePath());
+
return paths;
}
+#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
+QPlatformSystemTrayIcon *QGenericUnixTheme::createPlatformSystemTrayIcon() const
+{
+ if (isDBusTrayAvailable())
+ return new QDBusTrayIcon();
+ return Q_NULLPTR;
+}
+#endif
+
QVariant QGenericUnixTheme::themeHint(ThemeHint hint) const
{
switch (hint) {
@@ -170,6 +206,7 @@ public:
, toolButtonStyle(Qt::ToolButtonTextBesideIcon)
, toolBarIconSize(0)
, singleClick(true)
+ , wheelScrollLines(3)
{ }
static QString kdeGlobals(const QString &kdeDir)
@@ -193,6 +230,7 @@ public:
int toolButtonStyle;
int toolBarIconSize;
bool singleClick;
+ int wheelScrollLines;
};
void QKdeThemePrivate::refresh()
@@ -242,6 +280,10 @@ void QKdeThemePrivate::refresh()
toolButtonStyle = Qt::ToolButtonTextUnderIcon;
}
+ const QVariant wheelScrollLinesValue = readKdeSetting(QStringLiteral("KDE/WheelScrollLines"), kdeDirs, kdeSettings);
+ if (wheelScrollLinesValue.isValid())
+ wheelScrollLines = wheelScrollLinesValue.toInt();
+
// Read system font, ignore 'smallestReadableFont'
if (QFont *systemFont = kdeFont(readKdeSetting(QStringLiteral("font"), kdeDirs, kdeSettings)))
resources.fonts[QPlatformTheme::SystemFont] = systemFont;
@@ -428,6 +470,8 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QVariant(int(KdeKeyboardScheme));
case QPlatformTheme::ItemViewActivateItemOnSingleClick:
return QVariant(d->singleClick);
+ case QPlatformTheme::WheelScrollLines:
+ return QVariant(d->wheelScrollLines);
default:
break;
}
@@ -496,6 +540,15 @@ QPlatformTheme *QKdeTheme::createKdeTheme()
return new QKdeTheme(kdeDirs, kdeVersion);
}
+#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
+QPlatformSystemTrayIcon *QKdeTheme::createPlatformSystemTrayIcon() const
+{
+ if (isDBusTrayAvailable())
+ return new QDBusTrayIcon();
+ return Q_NULLPTR;
+}
+#endif
+
#endif // QT_NO_SETTINGS
/*!
@@ -512,7 +565,7 @@ class QGnomeThemePrivate : public QPlatformThemePrivate
{
public:
QGnomeThemePrivate() : fontsConfigured(false) { }
- void configureFonts(QString gtkFontName) const
+ void configureFonts(const QString &gtkFontName) const
{
Q_ASSERT(!fontsConfigured);
const int split = gtkFontName.lastIndexOf(QChar::Space);
@@ -582,6 +635,15 @@ QString QGnomeTheme::gtkFontName() const
return QStringLiteral("%1 %2").arg(QLatin1String(defaultSystemFontNameC)).arg(defaultSystemFontSize);
}
+#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
+QPlatformSystemTrayIcon *QGnomeTheme::createPlatformSystemTrayIcon() const
+{
+ if (isDBusTrayAvailable())
+ return new QDBusTrayIcon();
+ return Q_NULLPTR;
+}
+#endif
+
QString QGnomeTheme::standardButtonText(int button) const
{
switch (button) {
@@ -624,20 +686,25 @@ QStringList QGenericUnixTheme::themeNames()
QStringList result;
if (QGuiApplication::desktopSettingsAware()) {
const QByteArray desktopEnvironment = QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment();
- if (desktopEnvironment == "KDE") {
+ QList<QByteArray> gtkBasedEnvironments;
+ gtkBasedEnvironments << "GNOME"
+ << "X-CINNAMON"
+ << "UNITY"
+ << "MATE"
+ << "XFCE"
+ << "LXDE";
+ QList<QByteArray> desktopNames = desktopEnvironment.split(':');
+ Q_FOREACH (const QByteArray &desktopName, desktopNames) {
+ if (desktopEnvironment == "KDE") {
#ifndef QT_NO_SETTINGS
- result.push_back(QLatin1String(QKdeTheme::name));
+ result.push_back(QLatin1String(QKdeTheme::name));
#endif
- } else if (desktopEnvironment == "GNOME" ||
- desktopEnvironment == "X-CINNAMON" ||
- desktopEnvironment == "UNITY" ||
- desktopEnvironment == "MATE" ||
- desktopEnvironment == "XFCE" ||
- desktopEnvironment == "LXDE") { // Gtk-based desktops
- // prefer the GTK2 theme implementation with native dialogs etc.
- result.push_back(QStringLiteral("gtk2"));
- // fallback to the generic Gnome theme if loading the GTK2 theme fails
- result.push_back(QLatin1String(QGnomeTheme::name));
+ } else if (gtkBasedEnvironments.contains(desktopName)) {
+ // prefer the GTK2 theme implementation with native dialogs etc.
+ result.push_back(QStringLiteral("gtk2"));
+ // fallback to the generic Gnome theme if loading the GTK2 theme fails
+ result.push_back(QLatin1String(QGnomeTheme::name));
+ }
}
const QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION"));
if (!session.isEmpty() && session != QLatin1String("default") && !result.contains(session))
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
index 87df37dfd7..115b9d9f91 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** 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
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** 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$
@@ -75,10 +75,13 @@ public:
static QPlatformTheme *createUnixTheme(const QString &name);
static QStringList themeNames();
- virtual const QFont *font(Font type) const;
- virtual QVariant themeHint(ThemeHint hint) const;
+ virtual const QFont *font(Font type) const Q_DECL_OVERRIDE;
+ virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
static QStringList xdgIconThemePaths();
+#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
+ QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const Q_DECL_OVERRIDE;
+#endif
static const char *name;
};
@@ -93,11 +96,14 @@ public:
QKdeTheme(const QStringList& kdeDirs, int kdeVersion);
static QPlatformTheme *createKdeTheme();
- virtual QVariant themeHint(ThemeHint hint) const;
+ virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
- virtual const QPalette *palette(Palette type = SystemPalette) const;
+ virtual const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE;
- virtual const QFont *font(Font type) const;
+ virtual const QFont *font(Font type) const Q_DECL_OVERRIDE;
+#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
+ QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const Q_DECL_OVERRIDE;
+#endif
static const char *name;
};
@@ -110,11 +116,14 @@ class QGnomeTheme : public QPlatformTheme
Q_DECLARE_PRIVATE(QGnomeTheme)
public:
QGnomeTheme();
- virtual QVariant themeHint(ThemeHint hint) const;
- virtual const QFont *font(Font type) const;
+ virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
+ virtual const QFont *font(Font type) const Q_DECL_OVERRIDE;
QString standardButtonText(int button) const Q_DECL_OVERRIDE;
virtual QString gtkFontName() const;
+#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
+ QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const Q_DECL_OVERRIDE;
+#endif
static const char *name;
};