From d0f2051a8fe7cb44a04b0a540baafd1aeed06092 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Thu, 2 Apr 2009 22:44:54 +0200 Subject: Make QWS a bit more OS independent. Some patches needed to support QWS on non-Linux platforms. Reviewed-by: Paul Olav Tvete Reviewed-by: Harald Fernengel --- src/gui/embedded/qkbdum_qws.cpp | 9 +++++---- src/gui/embedded/qscreen_qws.cpp | 8 +++++--- src/gui/embedded/qwscommand_qws.cpp | 1 - src/gui/embedded/qwssignalhandler.cpp | 6 ++++-- src/gui/kernel/qapplication_qws.cpp | 9 +++++---- src/gui/text/qfontdatabase_qws.cpp | 5 +++-- src/gui/text/qfontengine_qpf.cpp | 12 ++++++------ src/gui/text/qfontengine_qws.cpp | 2 +- 8 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/gui/embedded/qkbdum_qws.cpp b/src/gui/embedded/qkbdum_qws.cpp index d525c66..fa05d6c 100644 --- a/src/gui/embedded/qkbdum_qws.cpp +++ b/src/gui/embedded/qkbdum_qws.cpp @@ -54,6 +54,7 @@ #include #include #include +#include "qplatformdefs.h" QT_BEGIN_NAMESPACE @@ -81,13 +82,13 @@ QWSUmKeyboardHandlerPrivate::QWSUmKeyboardHandlerPrivate(const QString &device) { kbdBuffer = new unsigned char [kbdBufferLen]; - if ((kbdFD = open((const char *)device.toLocal8Bit(), O_RDONLY | O_NDELAY)) < 0) { + if ((kbdFD = QT_OPEN((const char *)device.toLocal8Bit(), O_RDONLY | O_NDELAY, 0)) < 0) { qDebug("Cannot open %s (%s)", (const char *)device.toLocal8Bit(), strerror(errno)); } else { // Clear pending input char buf[2]; - while (read(kbdFD, buf, 1) > 0) { } + while (QT_READ(kbdFD, buf, 1) > 0) { } notifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this); connect(notifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData())); @@ -97,7 +98,7 @@ QWSUmKeyboardHandlerPrivate::QWSUmKeyboardHandlerPrivate(const QString &device) QWSUmKeyboardHandlerPrivate::~QWSUmKeyboardHandlerPrivate() { if (kbdFD >= 0) - close(kbdFD); + QT_CLOSE(kbdFD); delete [] kbdBuffer; } @@ -106,7 +107,7 @@ void QWSUmKeyboardHandlerPrivate::readKeyboardData() { int n; do { - n = read(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx); + n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx); if (n > 0) kbdIdx += n; } while (n > 0); diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp index 6741f2c..ff48403 100644 --- a/src/gui/embedded/qscreen_qws.cpp +++ b/src/gui/embedded/qscreen_qws.cpp @@ -198,10 +198,12 @@ void QScreenCursor::set(const QImage &image, int hotx, int hoty) */ void QScreenCursor::move(int x, int y) { - const QRegion r = boundingRect(); + QRegion r = boundingRect(); pos = QPoint(x,y); - if (enable && !hwaccel) - qt_screen->exposeRegion(r | boundingRect(), 0); + if (enable && !hwaccel) { + r |= boundingRect(); + qt_screen->exposeRegion(r, 0); + } } diff --git a/src/gui/embedded/qwscommand_qws.cpp b/src/gui/embedded/qwscommand_qws.cpp index 88e33a3..b0fd78b 100644 --- a/src/gui/embedded/qwscommand_qws.cpp +++ b/src/gui/embedded/qwscommand_qws.cpp @@ -43,7 +43,6 @@ #include "qtransportauth_qws.h" #include "qtransportauth_qws_p.h" -#include #include // #define QWSCOMMAND_DEBUG 1 // Uncomment to debug client/server communication diff --git a/src/gui/embedded/qwssignalhandler.cpp b/src/gui/embedded/qwssignalhandler.cpp index 0946fb6..e85bd36 100644 --- a/src/gui/embedded/qwssignalhandler.cpp +++ b/src/gui/embedded/qwssignalhandler.cpp @@ -44,8 +44,10 @@ #ifndef QT_NO_QWS_SIGNALHANDLER #include -#include -#include +#ifndef QT_NO_QWS_MULTIPROCESS +# include +# include +#endif #include QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp index 2deda8e..fcfd2a4 100644 --- a/src/gui/kernel/qapplication_qws.cpp +++ b/src/gui/kernel/qapplication_qws.cpp @@ -195,14 +195,14 @@ QString qws_dataDir() if (!result.isEmpty()) return result; QByteArray dataDir = QString(QLatin1String("/tmp/qtembedded-%1")).arg(qws_display_id).toLocal8Bit(); - if (mkdir(dataDir, 0700)) { + if (QT_MKDIR(dataDir, 0700)) { if (errno != EEXIST) { qFatal("Cannot create Qt for Embedded Linux data directory: %s", dataDir.constData()); } } - struct stat buf; - if (lstat(dataDir, &buf)) + QT_STATBUF buf; + if (QT_LSTAT(dataDir, &buf)) qFatal("stat failed for Qt for Embedded Linux data directory: %s", dataDir.constData()); if (!S_ISDIR(buf.st_mode)) @@ -2280,7 +2280,8 @@ void qt_init(QApplicationPrivate *priv, int type) qt_appType = QApplication::Type(type); qws_single_process = true; QWSServer::startup(flags); - setenv("QWS_DISPLAY", qws_display_spec.constData(), 0); + if (!display) // if not already set + qputenv("QWS_DISPLAY", qws_display_spec); } if(qt_is_gui_used) { diff --git a/src/gui/text/qfontdatabase_qws.cpp b/src/gui/text/qfontdatabase_qws.cpp index eb8a0cf..f62a6d1 100644 --- a/src/gui/text/qfontdatabase_qws.cpp +++ b/src/gui/text/qfontdatabase_qws.cpp @@ -58,6 +58,7 @@ #include "qabstractfontengine_qws.h" #include "qabstractfontengine_p.h" #include +#include "qplatformdefs.h" // for mmap #include @@ -127,7 +128,7 @@ void QFontDatabasePrivate::addQPF2File(const QByteArray &file) struct stat st; if (stat(file.constData(), &st)) return; - int f = ::open(file, O_RDONLY); + int f = ::open(file, O_RDONLY, 0); if (f < 0) return; const uchar *data = (const uchar *)mmap(0, st.st_size, PROT_READ, MAP_SHARED, f, 0); @@ -675,7 +676,7 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp, qDebug() << "Resource not valid" << size->fileName; } #else - int f = ::open(size->fileName, O_RDONLY); + int f = ::open(size->fileName, O_RDONLY, 0); if (f >= 0) { QFontEngineQPF *fe = new QFontEngineQPF(request, f); if (fe->isValid()) diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp index e9fcac4..b7d1c59 100644 --- a/src/gui/text/qfontengine_qpf.cpp +++ b/src/gui/text/qfontengine_qpf.cpp @@ -252,7 +252,7 @@ QList QFontEngineQPF::cleanUpAfterClientCrash(const QList &cras for (int i = 0; i < int(dir.count()); ++i) { const QByteArray fileName = QFile::encodeName(dir.absoluteFilePath(dir[i])); - int fd = ::open(fileName.constData(), O_RDONLY); + int fd = ::open(fileName.constData(), O_RDONLY, 0); if (fd >= 0) { void *header = ::mmap(0, sizeof(QFontEngineQPF::Header), PROT_READ, MAP_SHARED, fd, 0); if (header && header != MAP_FAILED) { @@ -331,9 +331,9 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng qDebug() << "found existing qpf:" << fileName; #endif if (::access(encodedName, W_OK | R_OK) == 0) - fd = ::open(encodedName, O_RDWR); + fd = ::open(encodedName, O_RDWR, 0); else if (::access(encodedName, R_OK) == 0) - fd = ::open(encodedName, O_RDONLY); + fd = ::open(encodedName, O_RDONLY, 0); } else { #if defined(DEBUG_FONTENGINE) qDebug() << "creating qpf on the fly:" << fileName; @@ -347,7 +347,7 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng generator.generate(); buffer.close(); const QByteArray &data = buffer.data(); - ::write(fd, data.constData(), data.size()); + QT_WRITE(fd, data.constData(), data.size()); } } } @@ -893,8 +893,8 @@ void QFontEngineQPF::loadGlyph(glyph_t glyph) g.y = qRound(metrics.y); g.advance = qRound(metrics.xoff); - ::write(fd, &g, sizeof(g)); - ::write(fd, img.bits(), img.numBytes()); + QT_WRITE(fd, &g, sizeof(g)); + QT_WRITE(fd, img.bits(), img.numBytes()); glyphPos = oldSize - glyphDataOffset; #if 0 && defined(DEBUG_FONTENGINE) diff --git a/src/gui/text/qfontengine_qws.cpp b/src/gui/text/qfontengine_qws.cpp index d776329..10aef4c 100644 --- a/src/gui/text/qfontengine_qws.cpp +++ b/src/gui/text/qfontengine_qws.cpp @@ -387,7 +387,7 @@ QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn) { cache_cost = 1; - int f = ::open( QFile::encodeName(fn), O_RDONLY ); + int f = ::open( QFile::encodeName(fn), O_RDONLY, 0); Q_ASSERT(f>=0); QT_STATBUF st; if ( QT_FSTAT( f, &st ) ) -- cgit v0.12