diff options
author | Robin Burchell <robin+qt@viroteck.net> | 2012-02-23 15:03:57 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-25 01:00:37 (GMT) |
commit | 4404345eaacf6be412312c57a450ba7223db8bb3 (patch) | |
tree | cf0b3fa5466c7a98ca4822b1e01d54dc80f03fb3 /src/plugins/platforms | |
parent | a0e68b2eecbe7d5aa020cfbc31ba94b949d4bb01 (diff) | |
download | Qt-4404345eaacf6be412312c57a450ba7223db8bb3.zip Qt-4404345eaacf6be412312c57a450ba7223db8bb3.tar.gz Qt-4404345eaacf6be412312c57a450ba7223db8bb3.tar.bz2 |
Port QBBRootWindow from the Qt 5 QPA plugin.
This lessens unnecessary delta between the two.
Change-Id: I3bb33d977573e3404dd08c2f4e396d18dd63ddc7
Reviewed-by: Sean Harmer <sh@theharmers.co.uk>
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/blackberry/blackberry.pro | 6 | ||||
-rw-r--r-- | src/plugins/platforms/blackberry/qbbrootwindow.cpp | 259 | ||||
-rw-r--r-- | src/plugins/platforms/blackberry/qbbrootwindow.h | 83 | ||||
-rw-r--r-- | src/plugins/platforms/blackberry/qbbscreen.cpp | 237 | ||||
-rw-r--r-- | src/plugins/platforms/blackberry/qbbscreen.h | 12 |
5 files changed, 375 insertions, 222 deletions
diff --git a/src/plugins/platforms/blackberry/blackberry.pro b/src/plugins/platforms/blackberry/blackberry.pro index 0d3cf43..9978945 100644 --- a/src/plugins/platforms/blackberry/blackberry.pro +++ b/src/plugins/platforms/blackberry/blackberry.pro @@ -17,7 +17,8 @@ SOURCES = main.cpp \ qbbrasterwindowsurface.cpp \ qbbvirtualkeyboard.cpp \ qbbclipboard.cpp \ - qbblocalethread.cpp + qbblocalethread.cpp \ + qbbrootwindow.cpp HEADERS = qbbbuffer.h \ qbbeventthread.h \ @@ -31,7 +32,8 @@ HEADERS = qbbbuffer.h \ qbbrasterwindowsurface.h \ qbbvirtualkeyboard.h \ qbbclipboard.h \ - qbblocalethread.h + qbblocalethread.h \ + qbbrootwindow.h QMAKE_CXXFLAGS += -I./private diff --git a/src/plugins/platforms/blackberry/qbbrootwindow.cpp b/src/plugins/platforms/blackberry/qbbrootwindow.cpp new file mode 100644 index 0000000..61ab9aa --- /dev/null +++ b/src/plugins/platforms/blackberry/qbbrootwindow.cpp @@ -0,0 +1,259 @@ +/*************************************************************************** +** +** Copyright (C) 2011 - 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 plugins 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbbrootwindow.h" + +#include "qbbscreen.h" + +#include <QtCore/QUuid> + +#if defined(QBBROOTWINDOW_DEBUG) +#include <QtCore/QDebug> +#endif + +#include <errno.h> +#include <unistd.h> + +static const int MAGIC_ZORDER_FOR_NO_NAV = 10; + +QBBRootWindow::QBBRootWindow(QBBScreen *screen) + : m_screen(screen), + m_window(0), + m_windowGroupName() +{ +#if defined(QBBROOTWINDOW_DEBUG) + qDebug() << Q_FUNC_INFO; +#endif + // Create one top-level QNX window to act as a container for child windows + // since navigator only supports one application window + errno = 0; + int result = screen_create_window(&m_window, m_screen->nativeContext()); + int val[2]; + if (result != 0) { + qFatal("QBBRootWindow: failed to create window, errno=%d", errno); + } + + // Move window to proper display + errno = 0; + screen_display_t display = m_screen->nativeDisplay(); + result = screen_set_window_property_pv(m_window, SCREEN_PROPERTY_DISPLAY, (void **)&display); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window display, errno=%d", errno); + } + + // Make sure window is above navigator but below keyboard if running as root + // since navigator won't automatically set our z-order in this case + if (getuid() == 0) { + errno = 0; + val[0] = MAGIC_ZORDER_FOR_NO_NAV; + result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ZORDER, val); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window z-order, errno=%d", errno); + } + } + + // Window won't be visible unless it has some buffers so make one dummy buffer that is 1x1 + errno = 0; + val[0] = SCREEN_USAGE_NATIVE; + result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_USAGE, val); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window buffer usage, errno=%d", errno); + } + + errno = 0; + val[0] = m_screen->nativeFormat(); + result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, val); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window pixel format, errno=%d", errno); + } + + errno = 0; + val[0] = 1; + val[1] = 1; + result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window buffer size, errno=%d", errno); + } + + errno = 0; + result = screen_create_window_buffers(m_window, 1); + if (result != 0) { + qFatal("QBB: failed to create window buffer, errno=%d", errno); + } + + // Window is always the size of the display + errno = 0; + QRect geometry = m_screen->geometry(); + val[0] = geometry.width(); + val[1] = geometry.height(); + result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window size, errno=%d", errno); + } + + // Fill the window with solid black + errno = 0; + val[0] = 0; + result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_COLOR, val); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window colour, errno=%d", errno); + } + + // Make the window opaque + errno = 0; + val[0] = SCREEN_TRANSPARENCY_NONE; + result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, val); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window transparency, errno=%d", errno); + } + + // Set the swap interval to 1 + errno = 0; + val[0] = 1; + result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SWAP_INTERVAL, val); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window swap interval, errno=%d", errno); + } + + // Set viewport size equal to window size but move outside buffer so the fill colour is used exclusively + errno = 0; + val[0] = geometry.width(); + val[1] = geometry.height(); + result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window source size, errno=%d", errno); + } + + errno = 0; + val[0] = 1; + val[1] = 0; + result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_POSITION, val); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window source position, errno=%d", errno); + } + + createWindowGroup(); + post(); +} + +QBBRootWindow::~QBBRootWindow() +{ + // Cleanup top-level QNX window + screen_destroy_window(m_window); +} + +void QBBRootWindow::post() const +{ +#if defined(QBBROOTWINDOW_DEBUG) + qDebug() << Q_FUNC_INFO; +#endif + errno = 0; + screen_buffer_t buffer; + int result = screen_get_window_property_pv(m_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&buffer); + if (result != 0) { + qFatal("QBBRootWindow: failed to query window buffer, errno=%d", errno); + } + + errno = 0; + int dirtyRect[] = {0, 0, 1, 1}; + result = screen_post_window(m_window, buffer, 1, dirtyRect, 0); + if (result != 0) { + qFatal("QBB: failed to post window buffer, errno=%d", errno); + } +} + +void QBBRootWindow::flush() const +{ +#if defined(QBBROOTWINDOW_DEBUG) + qDebug() << Q_FUNC_INFO; +#endif + // Force immediate display update + errno = 0; + int result = screen_flush_context(m_screen->nativeContext(), 0); + if (result != 0) { + qFatal("QBBRootWindow: failed to flush context, errno=%d", errno); + } +} + +void QBBRootWindow::setRotation(int rotation) +{ +#if defined(QBBROOTWINDOW_DEBUG) + qDebug() << Q_FUNC_INFO << "angle =" << rotation; +#endif + errno = 0; + int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ROTATION, &rotation); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window rotation, errno=%d", errno); + } +} + +void QBBRootWindow::resize(const QSize &size) +{ + errno = 0; + int val[] = {size.width(), size.height()}; + int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window size, errno=%d", errno); + } + + errno = 0; + result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val); + if (result != 0) { + qFatal("QBBRootWindow: failed to set window source size, errno=%d", errno); + } + + // NOTE: display will update when child windows relayout and repaint +} + +void QBBRootWindow::createWindowGroup() +{ + // Generate a random window group name + m_windowGroupName = QUuid::createUuid().toString().toAscii(); + + // Create window group so child windows can be parented by container window + errno = 0; + int result = screen_create_window_group(m_window, m_windowGroupName.constData()); + if (result != 0) { + qFatal("QBBRootWindow: failed to create app window group, errno=%d", errno); + } +} diff --git a/src/plugins/platforms/blackberry/qbbrootwindow.h b/src/plugins/platforms/blackberry/qbbrootwindow.h new file mode 100644 index 0000000..9e81449 --- /dev/null +++ b/src/plugins/platforms/blackberry/qbbrootwindow.h @@ -0,0 +1,83 @@ +/*************************************************************************** +** +** Copyright (C) 2011 - 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 plugins 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBBROOTWINDOW_H +#define QBBROOTWINDOW_H + +#include <QtCore/QByteArray> +#include <QtCore/QRect> + +#include <screen/screen.h> + +QT_BEGIN_NAMESPACE + +class QBBScreen; + +class QBBRootWindow +{ +public: + QBBRootWindow(QBBScreen *screen); + ~QBBRootWindow(); + + screen_window_t nativeHandle() const { return m_window; } + + void post() const; + void flush() const; + + void setRotation(int rotation); + + void resize(const QSize &size); + + QByteArray groupName() const { return m_windowGroupName; } + +private: + void createWindowGroup(); + + QBBScreen *m_screen; + screen_window_t m_window; + QByteArray m_windowGroupName; +}; + +QT_END_NAMESPACE + +#endif // QBBROOTWINDOW_H diff --git a/src/plugins/platforms/blackberry/qbbscreen.cpp b/src/plugins/platforms/blackberry/qbbscreen.cpp index 31e3f43..b2a1c8d 100644 --- a/src/plugins/platforms/blackberry/qbbscreen.cpp +++ b/src/plugins/platforms/blackberry/qbbscreen.cpp @@ -41,6 +41,7 @@ #include "qbbscreen.h" #include "qbbvirtualkeyboard.h" +#include "qbbrootwindow.h" #include "qbbwindow.h" #include <QUuid> @@ -59,7 +60,6 @@ QList<QBBWindow*> QBBScreen::sChildren; QBBScreen::QBBScreen(screen_context_t context, screen_display_t display, bool primary) : mContext(context), mDisplay(display), - mAppWindow(0), mPosted(false), mUsingOpenGL(false), mPrimaryDisplay(primary) @@ -109,7 +109,7 @@ QBBScreen::QBBScreen(screen_context_t context, screen_display_t display, bool pr // We only create the root window if we are not the primary display. if (mPrimaryDisplay) - createRootWindow(); + mRootWindow = QSharedPointer<QBBRootWindow>(new QBBRootWindow(this)); } QBBScreen::~QBBScreen() @@ -117,8 +117,6 @@ QBBScreen::~QBBScreen() #if defined(QBBSCREEN_DEBUG) qDebug() << "QBBScreen::~QBBScreen"; #endif - - destroyRootWindow(); } /* static */ @@ -178,157 +176,8 @@ int QBBScreen::defaultDepth() void QBBScreen::ensureDisplayCreated() { - if (!mAppWindow) - createRootWindow(); -} - -void QBBScreen::createRootWindow() -{ - // create one top-level QNX window to act as a container for child windows - // since navigator only supports one application window - errno = 0; - int result = screen_create_window(&mAppWindow, mContext); - int val[2]; - if (result != 0) { - qFatal("QBBScreen: failed to create window, errno=%d", errno); - } - - // move window to proper display - errno = 0; - result = screen_set_window_property_pv(mAppWindow, SCREEN_PROPERTY_DISPLAY, (void **)&mDisplay); - if (result != 0) { - qFatal("QBBScreen: failed to set window display, errno=%d", errno); - } - - // make sure window is above navigator but below keyboard if running as root - // since navigator won't automatically set our z-order in this case - if (getuid() == 0) { - errno = 0; - val[0] = MAGIC_ZORDER_FOR_NO_NAV; - result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_ZORDER, val); - if (result != 0) { - qFatal("QBBScreen: failed to set window z-order, errno=%d", errno); - } - } - - // window won't be visible unless it has some buffers so make one dummy buffer - // that is 1x1 - errno = 0; - - val[0] = SCREEN_USAGE_NATIVE; - - result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_USAGE, val); - if (result != 0) { - qFatal("QBBScreen: failed to set window buffer usage, errno=%d", errno); - } - - errno = 0; - val[0] = nativeFormat(); - result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_FORMAT, val); - if (result != 0) { - qFatal("QBBScreen: failed to set window pixel format, errno=%d", errno); - } - - errno = 0; - val[0] = 1; - val[1] = 1; - result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_BUFFER_SIZE, val); - if (result != 0) { - qFatal("QBBScreen: failed to set window buffer size, errno=%d", errno); - } - - errno = 0; - result = screen_create_window_buffers(mAppWindow, 1); - if (result != 0) { - qFatal("QBB: failed to create window buffer, errno=%d", errno); - } - - // window is always the size of the display - errno = 0; - val[0] = mCurrentGeometry.width(); - val[1] = mCurrentGeometry.height(); - result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_SIZE, val); - if (result != 0) { - qFatal("QBBScreen: failed to set window size, errno=%d", errno); - } - - // fill the window with solid black - errno = 0; - val[0] = 0; - result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_COLOR, val); - if (result != 0) { - qFatal("QBBScreen: failed to set window colour, errno=%d", errno); - } - - // make the window opaque - errno = 0; - val[0] = SCREEN_TRANSPARENCY_NONE; - result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_TRANSPARENCY, val); - if (result != 0) { - qFatal("QBBScreen: failed to set window transparency, errno=%d", errno); - } - - // set the swap interval to 1 - errno = 0; - val[0] = 1; - result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_SWAP_INTERVAL, val); - if (result != 0) { - qFatal("QBBScreen: failed to set window swap interval, errno=%d", errno); - } - - // set viewport size equal to window size but move outside buffer so the fill - // colour is used exclusively - errno = 0; - val[0] = mCurrentGeometry.width(); - val[1] = mCurrentGeometry.height(); - result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_SOURCE_SIZE, val); - if (result != 0) { - qFatal("QBBScreen: failed to set window source size, errno=%d", errno); - } - - errno = 0; - val[0] = 1; - val[1] = 0; - result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_SOURCE_POSITION, val); - if (result != 0) { - qFatal("QBBScreen: failed to set window source position, errno=%d", errno); - } - - // generate a random window group name - QUuid uuid; - mWindowGroupName = QUuid::createUuid().toString().toAscii(); - - // create window group so child windows can be parented by container window - errno = 0; - result = screen_create_window_group(mAppWindow, windowGroupName()); - if (result != 0) { - qFatal("QBBScreen: failed to create app window group, errno=%d", errno); - } - - errno = 0; - screen_buffer_t buffer; - result = screen_get_window_property_pv(mAppWindow, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&buffer); - if (result != 0) { - qFatal("QBBScreen: failed to query window buffer, errno=%d", errno); - } - - errno = 0; - int dirtyRect[] = {0, 0, 1, 1}; - result = screen_post_window(mAppWindow, buffer, 1, dirtyRect, 0); - if (result != 0) { - qFatal("QBB: failed to post window buffer, errno=%d", errno); - } -} - -void QBBScreen::destroyRootWindow() -{ - if (!mAppWindow) - return; - - // cleanup top-level QNX window - screen_destroy_window(mAppWindow); - mAppWindow = 0; - mWindowGroupName = QByteArray(); + if (!mRootWindow) + mRootWindow = QSharedPointer<QBBRootWindow>(new QBBRootWindow(this)); } QRect QBBScreen::availableGeometry() const @@ -339,6 +188,14 @@ QRect QBBScreen::availableGeometry() const mCurrentGeometry.width(), mCurrentGeometry.height() - keyboardHeight); } +/*! + Check if the supplied angles are perpendicular to each other. +*/ +static bool isOrthogonal(int angle1, int angle2) +{ + return ((angle1 - angle2) % 180) != 0; +} + void QBBScreen::setRotation(int rotation) { #if defined(QBBSCREEN_DEBUG) @@ -347,16 +204,12 @@ void QBBScreen::setRotation(int rotation) // check if rotation changed if (mCurrentRotation != rotation) { - - // update rotation of app window - errno = 0; - int result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_ROTATION, &rotation); - if (result != 0) { - qFatal("QBBScreen: failed to set window rotation, errno=%d", errno); - } + // update rotation of root window + if (mRootWindow) + mRootWindow->setRotation(rotation); // swap dimensions if we've rotated 90 or 270 from initial orientation - if (orthogonal(mStartRotation, rotation)) { + if (isOrthogonal(mStartRotation, rotation)) { mCurrentGeometry = QRect(0, 0, mStartGeometry.height(), mStartGeometry.width()); mCurrentPhysicalSize = QSize(mStartPhysicalSize.height(), mStartPhysicalSize.width()); } else { @@ -365,38 +218,21 @@ void QBBScreen::setRotation(int rotation) } // resize app window if we've rotated 90 or 270 from previous orientation - if (orthogonal(mCurrentRotation, rotation)) { + if (isOrthogonal(mCurrentRotation, rotation)) { #if defined(QBBSCREEN_DEBUG) qDebug() << "QBBScreen::setRotation - resize, s=" << mCurrentGeometry.size(); #endif - errno = 0; - int val[] = {mCurrentGeometry.width(), mCurrentGeometry.height()}; - result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_SIZE, val); - if (result != 0) { - qFatal("QBBScreen: failed to set window size, errno=%d", errno); - } - - errno = 0; - result = screen_set_window_property_iv(mAppWindow, SCREEN_PROPERTY_SOURCE_SIZE, val); - if (result != 0) { - qFatal("QBBScreen: failed to set window source size, errno=%d", errno); - } - - // NOTE: display will update when child windows relayout and repaint - + if (mRootWindow) + mRootWindow->resize(mCurrentGeometry.size()); } else { - // TODO: find one global place to flush display updates #if defined(QBBSCREEN_DEBUG) qDebug() << "QBBScreen::setRotation - flush"; #endif // force immediate display update if no geometry changes required - errno = 0; - int result = screen_flush_context(mContext, 0); - if (result != 0) { - qFatal("QBBScreen: failed to flush context, errno=%d", errno); - } + if (mRootWindow) + mRootWindow->flush(); } // save new rotation @@ -404,14 +240,6 @@ void QBBScreen::setRotation(int rotation) } } -/*! - Check if the supplied angles are perpendicular to each other. -*/ -bool QBBScreen::orthogonal(int rotation1, int rotation2) -{ - return ((rotation1 - rotation2) % 180) != 0; -} - void QBBScreen::addWindow(QBBWindow* window) { #if defined(QBBSCREEN_DEBUG) @@ -476,11 +304,6 @@ void QBBScreen::updateHierarchy() map[static_cast<QBBScreen*>((*it)->screen())] = 1; } - // Check to see if any root windows need destruction - for (sit = sScreens.begin(); sit != sScreens.end(); sit++) - if (!static_cast<QBBScreen*>(*sit)->isPrimaryDisplay() && map[*sit] == 0) - static_cast<QBBScreen*>(*sit)->destroyRootWindow(); - // After a hierarchy update, we need to force a flush on all screens. // Right now, all screens share a context. screen_flush_context( primaryDisplay()->mContext, 0 ); @@ -493,22 +316,8 @@ void QBBScreen::onWindowPost(QBBWindow* window) // post app window (so navigator will show it) after first child window // has posted; this only needs to happen once as the app window's content // never changes - if (!mPosted) { - - errno = 0; - screen_buffer_t buffer; - int result = screen_get_window_property_pv(mAppWindow, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&buffer); - if (result != 0) { - qFatal("QBB: failed to query window buffer, errno=%d", errno); - } - - errno = 0; - int dirtyRect[] = {0, 0, 1, 1}; - result = screen_post_window(mAppWindow, buffer, 1, dirtyRect, 0); - if (result != 0) { - qFatal("QBB: failed to post window buffer, errno=%d", errno); - } - + if (!mPosted && mRootWindow) { + mRootWindow->post(); mPosted = true; } } diff --git a/src/plugins/platforms/blackberry/qbbscreen.h b/src/plugins/platforms/blackberry/qbbscreen.h index a061811..cb71b78 100644 --- a/src/plugins/platforms/blackberry/qbbscreen.h +++ b/src/plugins/platforms/blackberry/qbbscreen.h @@ -43,6 +43,8 @@ #include <QtGui/QPlatformScreen> #include <QByteArray> +#include "qbbrootwindow.h" + #include <screen/screen.h> QT_BEGIN_NAMESPACE @@ -70,7 +72,7 @@ public: int nativeFormat() const { return (depth() == 32) ? SCREEN_FORMAT_RGBA8888 : SCREEN_FORMAT_RGB565; } screen_display_t nativeDisplay() const { return mDisplay; } screen_context_t nativeContext() const { return mContext; } - const char *windowGroupName() const { return mWindowGroupName.constData(); } + const char *windowGroupName() const { return mRootWindow->groupName().constData(); } /* Window hierarchy management */ static void addWindow(QBBWindow* child); @@ -82,11 +84,12 @@ public: void onWindowPost(QBBWindow* window); void ensureDisplayCreated(); + QSharedPointer<QBBRootWindow> rootWindow() const { return mRootWindow; } + private: screen_context_t mContext; screen_display_t mDisplay; - screen_window_t mAppWindow; - QByteArray mWindowGroupName; + QSharedPointer<QBBRootWindow> mRootWindow; bool mPosted; bool mUsingOpenGL; bool mPrimaryDisplay; @@ -104,9 +107,6 @@ private: QBBScreen(screen_context_t context, screen_display_t display, bool primary); virtual ~QBBScreen(); - static bool orthogonal(int rotation1, int rotation2); - void createRootWindow(); - void destroyRootWindow(); bool isPrimaryDisplay() { return mPrimaryDisplay; } }; |