summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-03-18 18:59:17 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-03-18 18:59:17 (GMT)
commit9e937ab81ca069d18d04b3192bc48b22a8cc5308 (patch)
tree23abb182a8d02ea3451df464fda879b7f0d226df
parent8ec9e1c261a9992a8df0a0e2ec04ecf4c22575af (diff)
parentc2317645b94f9a3004d76dda558c4a2b853a1489 (diff)
downloadQt-9e937ab81ca069d18d04b3192bc48b22a8cc5308.zip
Qt-9e937ab81ca069d18d04b3192bc48b22a8cc5308.tar.gz
Qt-9e937ab81ca069d18d04b3192bc48b22a8cc5308.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Added setSwitchPolicy to MeeGo graphicssystem helper API.
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.cpp19
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.h6
-rw-r--r--tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp5
-rw-r--r--tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h19
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoruntime.cpp13
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoruntime.h3
6 files changed, 58 insertions, 7 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
diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp
index 3f39bda..6778bd5 100644
--- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp
+++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp
@@ -136,6 +136,11 @@ void QMeeGoGraphicsSystemHelper::setSwapBehavior(SwapMode mode)
QGLWindowSurface::swapBehavior = QGLWindowSurface::KillSwap;
}
+void QMeeGoGraphicsSystemHelper::setSwitchPolicy(SwitchPolicy policy)
+{
+ QMeeGoRuntime::setSwitchPolicy(policy);
+}
+
void QMeeGoGraphicsSystemHelper::enableSwitchEvents()
{
QMeeGoRuntime::enableSwitchEvents();
diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h
index 9e50652..4612190 100644
--- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h
+++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h
@@ -112,6 +112,7 @@ public:
If switch events are enabled, two events will be emitted for each switch --
one before the switch (QMeeGoSwitchEvent::WillSwitch) and one after the
switch (QMeeGoSwitchEvent::DidSwitch).
+ If the switch policy is set to NoSwitch, this function has no effect.
*/
static void switchToMeeGo();
@@ -124,9 +125,27 @@ public:
Calling this function will emit QMeeGoSwitchEvent to the top level widgets. If switch
events are enabled, two events will be emitted for each switch -- one before the
switch (QMeeGoSwitchEvent::WillSwitch) and one after the switch (QMeeGoSwitchEvent::DidSwitch).
+ If the switch policy is set to NoSwitch, this function has no effect.
*/
static void switchToRaster();
+ //! Used to specify the policy for graphics system switching.
+ enum SwitchPolicy {
+ AutomaticSwitch, /**< Automatic switching */
+ ManualSwitch, /**< Switching is controleld by the application */
+ NoSwitch /**< Switching is disabled completely */
+ };
+
+ //! Sets the policy of graphicssystem switching
+ /*!
+ By default, the switch to raster happens automatically when all windows are either
+ minimized or when the last window is destroyed. This function lets the application
+ change the graphicssystem switching policy to prevent the switching from happening
+ automatically (that is if the application doesn't want switching at all or wishes
+ to control the switching manually).
+ */
+ static void setSwitchPolicy(SwitchPolicy policy);
+
//! Returns the name of the active graphics system
/*!
Returns the name of the currently active system. If running with 'runtime' graphics
diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
index 15f9cdf..928d01a 100644
--- a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
+++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
@@ -75,6 +75,7 @@ typedef void (*QMeeGoInvalidateLiveSurfacesFunc) (void);
typedef void (*QMeeGoSwitchToRasterFunc) (void);
typedef void (*QMeeGoSwitchToMeeGoFunc) (void);
typedef void (*QMeeGoRegisterSwitchCallbackFunc) (void (*callback)(int type, const char *name));
+typedef void (*QMeeGoSetSwitchPolicyFunc) (int policy);
static QMeeGoImageToEglSharedImageFunc qt_meego_image_to_egl_shared_image = NULL;
static QMeeGoPixmapDataFromEglSharedImageFunc qt_meego_pixmapdata_from_egl_shared_image = NULL;
@@ -95,6 +96,7 @@ static QMeeGoInvalidateLiveSurfacesFunc qt_meego_invalidate_live_surfaces = NULL
static QMeeGoSwitchToRasterFunc qt_meego_switch_to_raster = NULL;
static QMeeGoSwitchToMeeGoFunc qt_meego_switch_to_meego = NULL;
static QMeeGoRegisterSwitchCallbackFunc qt_meego_register_switch_callback = NULL;
+static QMeeGoSetSwitchPolicyFunc qt_meego_set_switch_policy = NULL;
extern "C" void handleSwitch(int type, const char *name)
{
@@ -134,6 +136,7 @@ void QMeeGoRuntime::initialize()
qt_meego_switch_to_raster = (QMeeGoSwitchToRasterFunc) library.resolve("qt_meego_switch_to_raster");
qt_meego_switch_to_meego = (QMeeGoSwitchToMeeGoFunc) library.resolve("qt_meego_switch_to_meego");
qt_meego_register_switch_callback = (QMeeGoRegisterSwitchCallbackFunc) library.resolve("qt_meego_register_switch_callback");
+ qt_meego_set_switch_policy = (QMeeGoSetSwitchPolicyFunc) library.resolve("qt_meego_set_switch_policy");
if (qt_meego_image_to_egl_shared_image && qt_meego_pixmapdata_from_egl_shared_image &&
qt_meego_pixmapdata_with_gl_texture && qt_meego_destroy_egl_shared_image && qt_meego_update_egl_shared_image_pixmap &&
@@ -141,7 +144,8 @@ void QMeeGoRuntime::initialize()
qt_meego_pixmapdata_with_new_live_texture && qt_meego_pixmapdata_from_live_texture_handle &&
qt_meego_live_texture_lock && qt_meego_live_texture_release && qt_meego_live_texture_get_handle &&
qt_meego_create_fence_sync && qt_meego_destroy_fence_sync && qt_meego_invalidate_live_surfaces &&
- qt_meego_switch_to_raster && qt_meego_switch_to_meego && qt_meego_register_switch_callback)
+ qt_meego_switch_to_raster && qt_meego_switch_to_meego && qt_meego_register_switch_callback &&
+ qt_meego_set_switch_policy)
{
qDebug("Successfully resolved MeeGo graphics system: %s %s\n", qPrintable(libraryPrivate->fileName), qPrintable(libraryPrivate->fullVersion));
} else {
@@ -289,3 +293,10 @@ void QMeeGoRuntime::enableSwitchEvents()
switchEventsEnabled = true;
}
}
+
+void QMeeGoRuntime::setSwitchPolicy(QMeeGoGraphicsSystemHelper::SwitchPolicy policy)
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_set_switch_policy);
+ qt_meego_set_switch_policy(int(policy));
+}
diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h
index 6279b4c..b898699 100644
--- a/tools/qmeegographicssystemhelper/qmeegoruntime.h
+++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h
@@ -42,6 +42,8 @@
#include <QPixmap>
#include <QImage>
+#include "qmeegographicssystemhelper.h"
+
class QMeeGoRuntime
{
public:
@@ -66,6 +68,7 @@ public:
static void switchToRaster();
static void switchToMeeGo();
static void enableSwitchEvents();
+ static void setSwitchPolicy(QMeeGoGraphicsSystemHelper::SwitchPolicy policy);
private:
static bool initialized;