diff options
author | Thomas McGuire <thomas.mcguire@kdab.com> | 2012-03-27 15:41:00 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-03 13:08:44 (GMT) |
commit | 3bb80da20a985ccdef5e946a88d57146849bdadf (patch) | |
tree | d936beec0fd6de5ab90d955a1af9113dcacce9d4 /src/plugins/platforms | |
parent | 45c6fc890c226c9021d41373c7718d596eb888d1 (diff) | |
download | Qt-3bb80da20a985ccdef5e946a88d57146849bdadf.zip Qt-3bb80da20a985ccdef5e946a88d57146849bdadf.tar.gz Qt-3bb80da20a985ccdef5e946a88d57146849bdadf.tar.bz2 |
Add a native interface with the ability to query the window group
The window group is needed by QtMobility, as the BB multimedia
API requires the window group when creating a video overlay
window
Change-Id: Ifc029c31b5a1750631a6b397f7c33aa31e483c81
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'src/plugins/platforms')
5 files changed, 168 insertions, 3 deletions
diff --git a/src/plugins/platforms/blackberry/blackberry.pro b/src/plugins/platforms/blackberry/blackberry.pro index 7f6da24..7ffb7f4 100644 --- a/src/plugins/platforms/blackberry/blackberry.pro +++ b/src/plugins/platforms/blackberry/blackberry.pro @@ -20,7 +20,8 @@ SOURCES = main.cpp \ qbblocalethread.cpp \ qbbrootwindow.cpp \ qbbscreeneventhandler.cpp \ - qbbabstractvirtualkeyboard.cpp + qbbabstractvirtualkeyboard.cpp \ + qbbnativeinterface.cpp HEADERS = qbbbuffer.h \ qbbeventthread.h \ @@ -37,7 +38,8 @@ HEADERS = qbbbuffer.h \ qbblocalethread.h \ qbbrootwindow.h \ qbbscreeneventhandler.h \ - qbbabstractvirtualkeyboard.h + qbbabstractvirtualkeyboard.h \ + qbbnativeinterface.h QMAKE_CXXFLAGS += -I./private diff --git a/src/plugins/platforms/blackberry/qbbintegration.cpp b/src/plugins/platforms/blackberry/qbbintegration.cpp index 5ca3833..76a47dc 100644 --- a/src/plugins/platforms/blackberry/qbbintegration.cpp +++ b/src/plugins/platforms/blackberry/qbbintegration.cpp @@ -54,6 +54,7 @@ #include "qbbclipboard.h" #include "qbbglcontext.h" #include "qbblocalethread.h" +#include "qbbnativeinterface.h" #include "qapplication.h" #include <QtGui/private/qpixmap_raster_p.h> @@ -76,7 +77,8 @@ QBBIntegration::QBBIntegration() : mFontDb(new QGenericUnixFontDatabase()), mScreenEventHandler(new QBBScreenEventHandler()), mPaintUsingOpenGL(getenv("QBB_USE_OPENGL") != NULL), - mVirtualKeyboard(0) + mVirtualKeyboard(0), + mNativeInterface(new QBBNativeInterface(this)) { qRegisterMetaType<screen_window_t>(); @@ -146,6 +148,8 @@ QBBIntegration::~QBBIntegration() #endif + delete mNativeInterface; + // destroy the keyboard class. delete mVirtualKeyboard; @@ -215,6 +219,11 @@ QWindowSurface *QBBIntegration::createWindowSurface(QWidget *widget, WId winId) return new QBBRasterWindowSurface(widget); } +QPlatformNativeInterface *QBBIntegration::nativeInterface() const +{ + return mNativeInterface; +} + void QBBIntegration::moveToScreen(QWidget *window, int screen) { #if defined(QBBINTEGRATION_DEBUG) @@ -249,6 +258,24 @@ QPlatformClipboard *QBBIntegration::clipboard() const } #endif + +QBBScreen *QBBIntegration::screenForWindow(screen_window_t window) const +{ + screen_display_t display = 0; + if (screen_get_window_property_pv(window, SCREEN_PROPERTY_DISPLAY, (void**)&display) != 0) { + qWarning("QBBIntegration: Failed to get screen for window, errno=%d", errno); + return 0; + } + + Q_FOREACH (QPlatformScreen *screen, mScreens) { + QBBScreen * const bbScreen = static_cast<QBBScreen*>(screen); + if (bbScreen->nativeDisplay() == display) + return bbScreen; + } + + return 0; +} + QBBScreen *QBBIntegration::primaryDisplay() const { return static_cast<QBBScreen*>(mScreens.first()); diff --git a/src/plugins/platforms/blackberry/qbbintegration.h b/src/plugins/platforms/blackberry/qbbintegration.h index 2d81184..4b52fcc 100644 --- a/src/plugins/platforms/blackberry/qbbintegration.h +++ b/src/plugins/platforms/blackberry/qbbintegration.h @@ -52,6 +52,7 @@ class QBBLocaleThread; class QBBAbstractVirtualKeyboard; class QBBScreen; class QBBScreenEventHandler; +class QBBNativeInterface; class QBBIntegration : public QPlatformIntegration { @@ -64,6 +65,7 @@ public: virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const; virtual QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; virtual QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + virtual QPlatformNativeInterface *nativeInterface() const; virtual QList<QPlatformScreen *> screens() const; virtual void moveToScreen(QWidget *window, int screen); @@ -77,6 +79,8 @@ public: bool paintUsingOpenGL() const { return mPaintUsingOpenGL; } + QBBScreen *screenForWindow(screen_window_t window) const; + private: QBBScreen *primaryDisplay() const; void createDisplays(); @@ -91,6 +95,7 @@ private: QBBScreenEventHandler *mScreenEventHandler; bool mPaintUsingOpenGL; QBBAbstractVirtualKeyboard *mVirtualKeyboard; + QBBNativeInterface *mNativeInterface; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/blackberry/qbbnativeinterface.cpp b/src/plugins/platforms/blackberry/qbbnativeinterface.cpp new file mode 100644 index 0000000..8cd931b --- /dev/null +++ b/src/plugins/platforms/blackberry/qbbnativeinterface.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Research In Motion +** +** Contact: Research In Motion <blackberry-qt@qnx.com> +** Contact: Klarälvdalens Datakonsult AB <info@kdab.com> +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** 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 "qbbnativeinterface.h" + +#include "qbbintegration.h" +#include "qbbscreen.h" +#include <QtGui/QWidget> +#include <screen/screen.h> + +QT_BEGIN_NAMESPACE + +QBBNativeInterface::QBBNativeInterface(QBBIntegration *integration) + : mIntegration(integration) +{ +} + +void *QBBNativeInterface::nativeResourceForWidget(const QByteArray &resource, QWidget *widget) +{ + if (resource == "windowGroup" && widget) { + const QWidget * const nativeWidget = widget->nativeParentWidget(); + const screen_window_t window = reinterpret_cast<screen_window_t>(nativeWidget->winId()); + const QBBScreen * const screen = mIntegration->screenForWindow(window); + if (screen) { + // We can't just call data() instead of constData() here, since that would detach + // and the lifetime of the char * would not be long enough. Therefore the const_cast. + return const_cast<char *>(screen->rootWindow()->groupName().constData()); + } + } + + return 0; +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/blackberry/qbbnativeinterface.h b/src/plugins/platforms/blackberry/qbbnativeinterface.h new file mode 100644 index 0000000..5a7a865 --- /dev/null +++ b/src/plugins/platforms/blackberry/qbbnativeinterface.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Research In Motion +** +** Contact: Research In Motion <blackberry-qt@qnx.com> +** Contact: Klarälvdalens Datakonsult AB <info@kdab.com> +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBBNATIVEINTERFACE_H +#define QBBNATIVEINTERFACE_H + +#include <QtGui/QPlatformNativeInterface> + +QT_BEGIN_NAMESPACE + +class QBBIntegration; + +class QBBNativeInterface : public QPlatformNativeInterface +{ +public: + explicit QBBNativeInterface(QBBIntegration *integration); + virtual void *nativeResourceForWidget(const QByteArray &resource, QWidget *widget); + +private: + QBBIntegration *mIntegration; +}; + +QT_END_NAMESPACE + +#endif |