diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-03-18 13:24:03 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-03-18 15:47:45 (GMT) |
commit | c2317645b94f9a3004d76dda558c4a2b853a1489 (patch) | |
tree | 38cfda93c35b2570f0fa323d1a586cddbf5a128d /src/plugins | |
parent | 3fb5fce61b6f64534ad292a78250e4256a6514b6 (diff) | |
download | Qt-c2317645b94f9a3004d76dda558c4a2b853a1489.zip Qt-c2317645b94f9a3004d76dda558c4a2b853a1489.tar.gz Qt-c2317645b94f9a3004d76dda558c4a2b853a1489.tar.bz2 |
Added setSwitchPolicy to MeeGo graphicssystem helper API.
This lets the application control whether or not automatic switching
should be used, and also to completely disable switching if desired.
Reviewed-by: Armin Berres
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/graphicssystems/meego/qmeegographicssystem.cpp | 19 | ||||
-rw-r--r-- | src/plugins/graphicssystems/meego/qmeegographicssystem.h | 6 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp index cb66695..c904c3c 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -67,6 +67,8 @@ QHash <Qt::HANDLE, QPixmap*> QMeeGoGraphicsSystem::liveTexturePixmaps; QList<QMeeGoSwitchCallback> QMeeGoGraphicsSystem::switchCallbacks; +QMeeGoGraphicsSystem::SwitchPolicy QMeeGoGraphicsSystem::switchPolicy = QMeeGoGraphicsSystem::AutomaticSwitch; + QMeeGoGraphicsSystem::QMeeGoGraphicsSystem() { qDebug("Using the meego graphics system"); @@ -122,14 +124,14 @@ void QMeeGoGraphicsSystemSwitchHandler::addWidget(QWidget *widget) void QMeeGoGraphicsSystemSwitchHandler::handleMapNotify() { - if (m_widgets.isEmpty()) + if (m_widgets.isEmpty() && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch) QTimer::singleShot(0, this, SLOT(switchToMeeGo())); } void QMeeGoGraphicsSystemSwitchHandler::removeWidget(QObject *object) { m_widgets.removeOne(static_cast<QWidget *>(object)); - if (m_widgets.isEmpty()) + if (m_widgets.isEmpty() && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch) QTimer::singleShot(0, this, SLOT(switchToRaster())); } @@ -153,7 +155,9 @@ int QMeeGoGraphicsSystemSwitchHandler::visibleWidgets() const bool QMeeGoGraphicsSystemSwitchHandler::eventFilter(QObject *object, QEvent *event) { - if (event->type() == QEvent::WindowStateChange) { + if (event->type() == QEvent::WindowStateChange + && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch) + { QWindowStateChangeEvent *change = static_cast<QWindowStateChangeEvent *>(event); QWidget *widget = static_cast<QWidget *>(object); @@ -380,7 +384,7 @@ QString QMeeGoGraphicsSystem::runningGraphicsSystemName() void QMeeGoGraphicsSystem::switchToMeeGo() { - if (meeGoRunning()) + if (switchPolicy == NoSwitch || meeGoRunning()) return; if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime")) @@ -397,7 +401,7 @@ void QMeeGoGraphicsSystem::switchToMeeGo() void QMeeGoGraphicsSystem::switchToRaster() { - if (runningGraphicsSystemName() == QLatin1String("raster")) + if (switchPolicy == NoSwitch || runningGraphicsSystemName() == QLatin1String("raster")) return; if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime")) @@ -522,4 +526,9 @@ void qt_meego_register_switch_callback(QMeeGoSwitchCallback callback) QMeeGoGraphicsSystem::registerSwitchCallback(callback); } +void qt_meego_set_switch_policy(int policy) +{ + QMeeGoGraphicsSystem::switchPolicy = QMeeGoGraphicsSystem::SwitchPolicy(policy); +} + #include "qmeegographicssystem.moc" diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h index ecc85b2..3528425 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h @@ -52,6 +52,8 @@ extern "C" typedef void (*QMeeGoSwitchCallback)(int type, const char *name); class QMeeGoGraphicsSystem : public QGraphicsSystem { public: + enum SwitchPolicy { AutomaticSwitch, ManualSwitch, NoSwitch }; + QMeeGoGraphicsSystem(); ~QMeeGoGraphicsSystem(); @@ -84,6 +86,8 @@ public: static void registerSwitchCallback(QMeeGoSwitchCallback callback); + static SwitchPolicy switchPolicy; + private: static bool meeGoRunning(); static EGLSurface getSurfaceForLiveTexturePixmap(QPixmap *pixmap); @@ -93,7 +97,6 @@ private: static bool surfaceWasCreated; static QHash<Qt::HANDLE, QPixmap*> liveTexturePixmaps; static QList<QMeeGoSwitchCallback> switchCallbacks; - }; /* C api */ @@ -118,6 +121,7 @@ extern "C" { Q_DECL_EXPORT void qt_meego_switch_to_raster(void); Q_DECL_EXPORT void qt_meego_switch_to_meego(void); Q_DECL_EXPORT void qt_meego_register_switch_callback(QMeeGoSwitchCallback callback); + Q_DECL_EXPORT void qt_meego_set_switch_policy(int policy); } #endif |