diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2011-03-01 09:11:36 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2011-03-01 09:31:50 (GMT) |
commit | 4d803a3493d15fdf7374689b774d02662dbd43b3 (patch) | |
tree | 6bfa40651df8aabb3a92f1ce9285276916f5593b /src/plugins/platforms | |
parent | 044e06d5a40e3f8d5ae6861341b1f5449e3c0afe (diff) | |
download | Qt-4d803a3493d15fdf7374689b774d02662dbd43b3.zip Qt-4d803a3493d15fdf7374689b774d02662dbd43b3.tar.gz Qt-4d803a3493d15fdf7374689b774d02662dbd43b3.tar.bz2 |
Lighthouse: Xcb, implement native interface
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbintegration.cpp | 5 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbintegration.h | 3 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 50 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbnativeinterface.h | 20 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/xcb.pro | 6 |
5 files changed, 82 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 7f6d4c5..b6df550 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -44,6 +44,7 @@ #include "qxcbscreen.h" #include "qxcbwindow.h" #include "qxcbwindowsurface.h" +#include "qxcbnativeinterface.h" #include <xcb/xcb.h> @@ -64,6 +65,7 @@ QXcbIntegration::QXcbIntegration() m_screens << screen; m_fontDatabase = new QGenericUnixFontDatabase(); + m_nativeInterface = new QXcbNativeInterface; } QXcbIntegration::~QXcbIntegration() @@ -144,4 +146,7 @@ bool QXcbIntegration::hasOpenGL() const return false; } +QPlatformNativeInterface * QXcbIntegration::nativeInterface() const +{ + return m_nativeInterface; } diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h index 80f70fb..eab6949 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.h +++ b/src/plugins/platforms/xcb/qxcbintegration.h @@ -67,11 +67,14 @@ public: QPlatformFontDatabase *fontDatabase() const; bool hasOpenGL() const; + QPlatformNativeInterface *nativeInterface()const; + private: QList<QPlatformScreen *> m_screens; QXcbConnection *m_connection; QPlatformFontDatabase *m_fontDatabase; + QPlatformNativeInterface *m_nativeInterface; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp new file mode 100644 index 0000000..859b6c3 --- /dev/null +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -0,0 +1,50 @@ +#include "qxcbnativeinterface.h" + +#include "qxcbscreen.h" + +#include <QtGui/private/qapplication_p.h> + +QXcbScreen *QXcbNativeInterface::screenForWidget(QWidget *widget) +{ + QXcbScreen *screen; + if (widget) { + screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget)); + }else { + screen = static_cast<QXcbScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]); + } + return screen; +} + +void * QXcbNativeInterface::nativeDisplayForWidget(QWidget *widget) +{ +#if defined(XCB_USE_XLIB) + QXcbScreen *screen = screenForWidget(widget); + return screen->connection()->xlib_display(); +#else + Q_UNUSED(widget); + return 0; +#endif +} + +void * QXcbNativeInterface::eglDisplayForWidget(QWidget *widget) +{ +#if defined(XCB_USE_DRI2) + QXcbScreen *screen = screenForWidget(widget); + return screen->connection()->egl_display(); +#else + Q_UNUSED(widget) + return 0; +#endif +} + +void * QXcbNativeInterface::nativeConnectionForWidget(QWidget *widget) +{ + QXcbScreen *screen = screenForWidget(widget); + return screen->xcb_connection(); +} + +void * QXcbNativeInterface::nativeScreenForWidget(QWidget *widget) +{ + QXcbScreen *screen = screenForWidget(widget); + return screen->screen(); +} diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h new file mode 100644 index 0000000..fb48833 --- /dev/null +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -0,0 +1,20 @@ +#ifndef QXCBNATIVEINTERFACE_H +#define QXCBNATIVEINTERFACE_H + +#include <QtGui/QPlatformNativeInterface> + +class QWidget; +class QXcbScreen; + +class QXcbNativeInterface : public QPlatformNativeInterface +{ + void * nativeDisplayForWidget(QWidget *widget); + void * eglDisplayForWidget(QWidget *widget); + void * nativeConnectionForWidget(QWidget *widget); + void * nativeScreenForWidget(QWidget *widget); + +private: + static QXcbScreen *screenForWidget(QWidget *widget); +}; + +#endif // QXCBNATIVEINTERFACE_H diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index 9a3f735..2237cee 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -10,7 +10,8 @@ SOURCES = \ qxcbscreen.cpp \ qxcbwindow.cpp \ qxcbwindowsurface.cpp \ - main.cpp + main.cpp \ + qxcbnativeinterface.cpp HEADERS = \ qxcbconnection.h \ @@ -19,7 +20,8 @@ HEADERS = \ qxcbobject.h \ qxcbscreen.h \ qxcbwindow.h \ - qxcbwindowsurface.h + qxcbwindowsurface.h \ + qxcbnativeinterface.h contains(QT_CONFIG, opengl) { QT += opengl |