summaryrefslogtreecommitdiffstats
path: root/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp')
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp77
1 files changed, 70 insertions, 7 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index 0f7a6de..449bc0d 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -99,8 +99,11 @@ public:
qint64 cursorImageKey;
QDirectFBScreen *q;
+ static QDirectFBScreen *instance;
};
+QDirectFBScreen *QDirectFBScreenPrivate::instance = 0;
+
QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr)
: QWSGraphicsSystem(qptr), dfb(0), flipFlags(DSFLIP_NONE),
directFBFlags(QDirectFBScreen::NoFlags), alphaPixmapFormat(QImage::Format_Invalid),
@@ -802,13 +805,21 @@ void QDirectFBScreenCursor::set(const QImage &image, int hotx, int hoty)
QDirectFBScreen::QDirectFBScreen(int display_id)
: QScreen(display_id, DirectFBClass), d_ptr(new QDirectFBScreenPrivate(this))
{
+ QDirectFBScreenPrivate::instance = this;
}
QDirectFBScreen::~QDirectFBScreen()
{
+ if (QDirectFBScreenPrivate::instance == this)
+ QDirectFBScreenPrivate::instance = 0;
delete d_ptr;
}
+QDirectFBScreen *QDirectFBScreen::instance()
+{
+ return QDirectFBScreenPrivate::instance;
+}
+
int QDirectFBScreen::depth(DFBSurfacePixelFormat format)
{
switch (format) {
@@ -1050,6 +1061,26 @@ static inline bool setIntOption(const QStringList &arguments, const QString &var
return false;
}
+static inline QColor colorFromName(const QString &name)
+{
+ QRegExp rx("#([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])");
+ rx.setCaseSensitivity(Qt::CaseInsensitive);
+ if (rx.exactMatch(name)) {
+ Q_ASSERT(rx.numCaptures() == 4);
+ int ints[4];
+ int i;
+ for (i=0; i<4; ++i) {
+ bool ok;
+ ints[i] = rx.cap(i + 1).toUInt(&ok, 16);
+ if (!ok || ints[i] > 255)
+ break;
+ }
+ if (i == 4)
+ return QColor(ints[0], ints[1], ints[2], ints[3]);
+ }
+ return QColor(name);
+}
+
bool QDirectFBScreen::connect(const QString &displaySpec)
{
DFBResult result = DFB_OK;
@@ -1282,18 +1313,50 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
#endif
#ifdef QT_DIRECTFB_WM
surface->Release(surface);
+ QColor backgroundColor;
#else
- QRegExp backgroundColorRegExp(QLatin1String("bgcolor=?(.+)"));
+ QColor &backgroundColor = d_ptr->backgroundColor;
+#endif
+
+ QRegExp backgroundColorRegExp(QLatin1String("bgcolor=(.+)"));
backgroundColorRegExp.setCaseSensitivity(Qt::CaseInsensitive);
if (displayArgs.indexOf(backgroundColorRegExp) != -1) {
- d_ptr->backgroundColor.setNamedColor(backgroundColorRegExp.cap(1));
+ backgroundColor = colorFromName(backgroundColorRegExp.cap(1));
}
- if (!d_ptr->backgroundColor.isValid())
- d_ptr->backgroundColor = Qt::green;
- d_ptr->primarySurface->Clear(d_ptr->primarySurface, d_ptr->backgroundColor.red(),
- d_ptr->backgroundColor.green(), d_ptr->backgroundColor.blue(),
- d_ptr->backgroundColor.alpha());
+#ifdef QT_NO_DIRECTFB_WM
+ if (!backgroundColor.isValid())
+ backgroundColor = Qt::green;
+ d_ptr->primarySurface->Clear(d_ptr->primarySurface, backgroundColor.red(),
+ backgroundColor.green(), backgroundColor.blue(),
+ backgroundColor.alpha());
d_ptr->primarySurface->Flip(d_ptr->primarySurface, 0, d_ptr->flipFlags);
+#else
+ if (backgroundColor.isValid()) {
+ DFBResult result = d_ptr->dfbLayer->SetCooperativeLevel(d_ptr->dfbLayer, DLSCL_ADMINISTRATIVE);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBScreen::connect "
+ "Unable to set cooperative level", result);
+ }
+ result = d_ptr->dfbLayer->SetBackgroundColor(d_ptr->dfbLayer, backgroundColor.red(), backgroundColor.green(),
+ backgroundColor.blue(), backgroundColor.alpha());
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBScreenCursor::connect: "
+ "Unable to set background color", result);
+ }
+
+ result = d_ptr->dfbLayer->SetBackgroundMode(d_ptr->dfbLayer, DLBM_COLOR);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBScreenCursor::connect: "
+ "Unable to set background mode", result);
+ }
+
+ result = d_ptr->dfbLayer->SetCooperativeLevel(d_ptr->dfbLayer, DLSCL_SHARED);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBScreen::connect "
+ "Unable to set cooperative level", result);
+ }
+
+ }
#endif
return true;