summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2011-03-31 14:05:42 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2011-04-06 09:47:52 (GMT)
commit8fe7b21fbd55e3121925e6f5a51be8d14081957f (patch)
treeccf0a2fc4249214e62b08f5cba1fafa294705543 /src/plugins
parent9086024565cac2fd9ebc7eeb8abd6449ecf960d0 (diff)
downloadQt-8fe7b21fbd55e3121925e6f5a51be8d14081957f.zip
Qt-8fe7b21fbd55e3121925e6f5a51be8d14081957f.tar.gz
Qt-8fe7b21fbd55e3121925e6f5a51be8d14081957f.tar.bz2
Lighthouse: Native interface for xlib
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/xlib/qxlibintegration.cpp8
-rw-r--r--src/plugins/platforms/xlib/qxlibintegration.h4
-rw-r--r--src/plugins/platforms/xlib/qxlibnativeinterface.cpp133
-rw-r--r--src/plugins/platforms/xlib/qxlibnativeinterface.h75
-rw-r--r--src/plugins/platforms/xlib/xlib.pro6
5 files changed, 223 insertions, 3 deletions
diff --git a/src/plugins/platforms/xlib/qxlibintegration.cpp b/src/plugins/platforms/xlib/qxlibintegration.cpp
index 63197b0..8deb2f3 100644
--- a/src/plugins/platforms/xlib/qxlibintegration.cpp
+++ b/src/plugins/platforms/xlib/qxlibintegration.cpp
@@ -49,6 +49,7 @@
#include "qxlibscreen.h"
#include "qxlibclipboard.h"
#include "qxlibdisplay.h"
+#include "qxlibnativeinterface.h"
#if !defined(QT_NO_OPENGL)
#if !defined(QT_OPENGL_ES_2)
@@ -66,6 +67,7 @@ QXlibIntegration::QXlibIntegration(bool useOpenGL)
: mUseOpenGL(useOpenGL)
, mFontDb(new QGenericUnixFontDatabase())
, mClipboard(0)
+ , mNativeInterface(new QXlibNativeInterface)
{
mPrimaryScreen = new QXlibScreen();
mScreens.append(mPrimaryScreen);
@@ -130,6 +132,11 @@ QPlatformClipboard * QXlibIntegration::clipboard() const
return mClipboard;
}
+QPlatformNativeInterface * QXlibIntegration::nativeInterface() const
+{
+ return mNativeInterface;
+}
+
bool QXlibIntegration::hasOpenGL() const
{
#if !defined(QT_NO_OPENGL)
@@ -154,5 +161,4 @@ bool QXlibIntegration::hasOpenGL() const
return false;
}
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xlib/qxlibintegration.h b/src/plugins/platforms/xlib/qxlibintegration.h
index 3bbf897..f8efae0 100644
--- a/src/plugins/platforms/xlib/qxlibintegration.h
+++ b/src/plugins/platforms/xlib/qxlibintegration.h
@@ -47,6 +47,7 @@
#include <QtGui/QPlatformIntegration>
#include <QtGui/QPlatformScreen>
+#include <QtGui/QPlatformNativeInterface>
#include "qxlibstatic.h"
@@ -70,6 +71,8 @@ public:
QPlatformFontDatabase *fontDatabase() const;
QPlatformClipboard *clipboard() const;
+ QPlatformNativeInterface *nativeInterface() const;
+
bool hasOpenGL() const;
private:
@@ -78,6 +81,7 @@ private:
QList<QPlatformScreen *> mScreens;
QPlatformFontDatabase *mFontDb;
QPlatformClipboard *mClipboard;
+ QPlatformNativeInterface *mNativeInterface;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xlib/qxlibnativeinterface.cpp b/src/plugins/platforms/xlib/qxlibnativeinterface.cpp
new file mode 100644
index 0000000..4e950ff
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibnativeinterface.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxlibnativeinterface.h"
+
+#include "qxlibdisplay.h"
+#include <QtGui/private/qapplication_p.h>
+
+class QXlibResourceMap : public QMap<QByteArray, QXlibNativeInterface::ResourceType>
+{
+public:
+ QXlibResourceMap()
+ :QMap<QByteArray, QXlibNativeInterface::ResourceType>()
+ {
+ insert("display",QXlibNativeInterface::Display);
+ insert("egldisplay",QXlibNativeInterface::EglDisplay);
+ insert("connection",QXlibNativeInterface::Connection);
+ insert("screen",QXlibNativeInterface::Screen);
+ insert("graphicsdevice",QXlibNativeInterface::GraphicsDevice);
+ insert("eglcontext",QXlibNativeInterface::EglContext);
+ }
+};
+
+Q_GLOBAL_STATIC(QXlibResourceMap, qXlibResourceMap)
+
+
+void * QXlibNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget)
+{
+ QByteArray lowerCaseResource = resourceString.toLower();
+ ResourceType resource = qXlibResourceMap()->value(lowerCaseResource);
+ void *result = 0;
+ switch(resource) {
+ case Display:
+ result = displayForWidget(widget);
+ break;
+ case EglDisplay:
+ result = eglDisplayForWidget(widget);
+ break;
+ case Connection:
+ result = connectionForWidget(widget);
+ break;
+ case Screen:
+ result = reinterpret_cast<void *>(qPlatformScreenForWidget(widget)->xScreenNumber());
+ break;
+ case GraphicsDevice:
+ result = graphicsDeviceForWidget(widget);
+ break;
+ case EglContext:
+ result = eglContextForWidget(widget);
+ break;
+ default:
+ result = 0;
+ }
+ return result;
+}
+
+void * QXlibNativeInterface::displayForWidget(QWidget *widget)
+{
+ return qPlatformScreenForWidget(widget)->display()->nativeDisplay();
+}
+
+void * QXlibNativeInterface::eglDisplayForWidget(QWidget *widget)
+{
+ Q_UNUSED(widget);
+ return 0;
+}
+
+void * QXlibNativeInterface::screenForWidget(QWidget *widget)
+{
+ Q_UNUSED(widget);
+ return 0;
+}
+
+void * QXlibNativeInterface::graphicsDeviceForWidget(QWidget *widget)
+{
+ Q_UNUSED(widget);
+ return 0;
+}
+
+void * QXlibNativeInterface::eglContextForWidget(QWidget *widget)
+{
+ Q_UNUSED(widget);
+ return 0;
+}
+
+QXlibScreen * QXlibNativeInterface::qPlatformScreenForWidget(QWidget *widget)
+{
+ QXlibScreen *screen;
+ if (widget) {
+ screen = static_cast<QXlibScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ }else {
+ screen = static_cast<QXlibScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
+ }
+ return screen;
+}
diff --git a/src/plugins/platforms/xlib/qxlibnativeinterface.h b/src/plugins/platforms/xlib/qxlibnativeinterface.h
new file mode 100644
index 0000000..5ba0768
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibnativeinterface.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXLIBNATIVEINTERFACE_H
+#define QXLIBNATIVEINTERFACE_H
+
+#include "qxlibscreen.h"
+
+#include <QtGui/QPlatformNativeInterface>
+
+class QXlibNativeInterface : public QPlatformNativeInterface
+{
+public:
+ enum ResourceType {
+ Display,
+ EglDisplay,
+ Connection,
+ Screen,
+ GraphicsDevice,
+ EglContext
+ };
+
+ void *nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget);
+
+ void *displayForWidget(QWidget *widget);
+ void *eglDisplayForWidget(QWidget *widget);
+ void *connectionForWidget(QWidget *widget);
+ void *screenForWidget(QWidget *widget);
+ void *graphicsDeviceForWidget(QWidget *widget);
+ void *eglContextForWidget(QWidget *widget);
+
+private:
+ static QXlibScreen *qPlatformScreenForWidget(QWidget *widget);
+};
+
+
+#endif // QXLIBNATIVEINTERFACE_H
diff --git a/src/plugins/platforms/xlib/xlib.pro b/src/plugins/platforms/xlib/xlib.pro
index 4cda1a7..ea77a29 100644
--- a/src/plugins/platforms/xlib/xlib.pro
+++ b/src/plugins/platforms/xlib/xlib.pro
@@ -14,7 +14,8 @@ SOURCES = \
qxlibclipboard.cpp \
qxlibmime.cpp \
qxlibstatic.cpp \
- qxlibdisplay.cpp
+ qxlibdisplay.cpp \
+ qxlibnativeinterface.cpp
HEADERS = \
qxlibintegration.h \
@@ -26,7 +27,8 @@ HEADERS = \
qxlibclipboard.h \
qxlibmime.h \
qxlibstatic.h \
- qxlibdisplay.h
+ qxlibdisplay.h \
+ qxlibnativeinterface.h
LIBS += -lX11 -lXext