diff options
author | David Boddie <dboddie@trolltech.com> | 2009-07-23 17:43:32 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2009-07-23 17:43:32 (GMT) |
commit | 9ec431c161202d9f06f3a7c59181cb0ab523958a (patch) | |
tree | cbf1b4a23c14821f1c6fb26b64b5950f32279409 /src | |
parent | 1368c210ef9976f68eb9fb1c3e4dc14f4fa4edd2 (diff) | |
parent | 2410f261eaa13442baa46537202d31ad26d797e7 (diff) | |
download | Qt-9ec431c161202d9f06f3a7c59181cb0ab523958a.zip Qt-9ec431c161202d9f06f3a7c59181cb0ab523958a.tar.gz Qt-9ec431c161202d9f06f3a7c59181cb0ab523958a.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'src')
48 files changed, 952 insertions, 2955 deletions
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 5033b21..bd41f5e 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -65,7 +65,10 @@ win32 { SOURCES += io/qfsfileengine_unix.cpp SOURCES += io/qfsfileengine_iterator_unix.cpp SOURCES += io/qprocess_unix.cpp - mac:SOURCES += io/qsettings_mac.cpp + macx-*: { + HEADERS += io/qfilesystemwatcher_fsevents_p.h + SOURCES += io/qsettings_mac.cpp io/qfilesystemwatcher_fsevents.cpp + } linux-*:{ SOURCES += \ diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index b321644..902e240 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -58,6 +58,9 @@ # include "qfilesystemwatcher_inotify_p.h" # include "qfilesystemwatcher_dnotify_p.h" #elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) +# if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) +# include "qfilesystemwatcher_fsevents_p.h" +# endif //MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) # include "qfilesystemwatcher_kqueue_p.h" #endif @@ -243,7 +246,12 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine() eng = QDnotifyFileSystemWatcherEngine::create(); return eng; #elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) - return QKqueueFileSystemWatcherEngine::create(); +# if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) + return QFSEventsFileSystemWatcherEngine::create(); + else +# endif + return QKqueueFileSystemWatcherEngine::create(); #else return 0; #endif diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.cpp b/src/corelib/io/qfilesystemwatcher_fsevents.cpp new file mode 100644 index 0000000..3e0aee8 --- /dev/null +++ b/src/corelib/io/qfilesystemwatcher_fsevents.cpp @@ -0,0 +1,467 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <qplatformdefs.h> + +#include "qfilesystemwatcher.h" +#include "qfilesystemwatcher_fsevents_p.h" + +#include <qdebug.h> +#include <qfile.h> +#include <qdatetime.h> +#include <qfileinfo.h> +#include <qvarlengtharray.h> + +#include <mach/mach.h> +#include <sys/types.h> +#include <CoreFoundation/CFRunLoop.h> +#include <CoreFoundation/CFUUID.h> +#include <CoreServices/CoreServices.h> +#include <AvailabilityMacros.h> +#include <private/qcore_mac_p.h> + +QT_BEGIN_NAMESPACE + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +// Static operator overloading so for the sake of some convieniece. +// They only live in this compilation unit to avoid polluting Qt in general. +static bool operator==(const struct ::timespec &left, const struct ::timespec &right) +{ + return left.tv_sec == right.tv_sec + && left.tv_nsec == right.tv_nsec; +} + +static bool operator==(const struct ::stat64 &left, const struct ::stat64 &right) +{ + return left.st_dev == right.st_dev + && left.st_mode == right.st_mode + && left.st_size == right.st_size + && left.st_ino == right.st_ino + && left.st_uid == right.st_uid + && left.st_gid == right.st_gid + && left.st_mtimespec == right.st_mtimespec + && left.st_ctimespec == right.st_ctimespec + && left.st_flags == right.st_flags; +} + +static bool operator!=(const struct ::stat64 &left, const struct ::stat64 &right) +{ + return !(operator==(left, right)); +} + + +static void addPathToHash(PathHash &pathHash, const QString &key, const QFileInfo &fileInfo, + const QString &path) +{ + PathInfoList &list = pathHash[key]; + list.push_back(PathInfo(path, + fileInfo.absoluteFilePath().normalized(QString::NormalizationForm_D).toUtf8())); + pathHash.insert(key, list); +} + +static void removePathFromHash(PathHash &pathHash, const QString &key, const QString &path) +{ + PathInfoList &list = pathHash[key]; + // We make the assumption that the list contains unique paths + PathInfoList::iterator End = list.end(); + PathInfoList::iterator it = list.begin(); + while (it != End) { + if (it->originalPath == path) { + list.erase(it); + break; + } + ++it; + } + if (list.isEmpty()) + pathHash.remove(key); +} + +static void stopFSStream(FSEventStreamRef stream) +{ + if (stream) { + FSEventStreamStop(stream); + FSEventStreamInvalidate(stream); + } +} + +static QString createFSStreamPath(const QString &absolutePath) +{ + // The path returned has a trailing slash, so ensure that here. + QString string = absolutePath; + string.reserve(string.size() + 1); + string.append(QLatin1Char('/')); + return string; +} + +static void cleanupFSStream(FSEventStreamRef stream) +{ + if (stream) + FSEventStreamRelease(stream); +} + +const FSEventStreamCreateFlags QtFSEventFlags = (kFSEventStreamCreateFlagUseCFTypes | kFSEventStreamCreateFlagNoDefer /* | kFSEventStreamCreateFlagWatchRoot*/); + +const CFTimeInterval Latency = 0.033; // This will do updates 30 times a second which is probably more than you need. +#endif + +QFSEventsFileSystemWatcherEngine::QFSEventsFileSystemWatcherEngine() + : fsStream(0), pathsToWatch(0), threadsRunLoop(0) +{ +} + +QFSEventsFileSystemWatcherEngine::~QFSEventsFileSystemWatcherEngine() +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + // I assume that at this point, QFileSystemWatcher has already called stop + // on me, so I don't need to invalidate or stop my stream, simply + // release it. + cleanupFSStream(fsStream); + if (pathsToWatch) + CFRelease(pathsToWatch); +#endif +} + +QFSEventsFileSystemWatcherEngine *QFSEventsFileSystemWatcherEngine::create() +{ + return new QFSEventsFileSystemWatcherEngine(); +} + +QStringList QFSEventsFileSystemWatcherEngine::addPaths(const QStringList &paths, + QStringList *files, + QStringList *directories) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + stop(); + QMutexLocker locker(&mutex); + QStringList failedToAdd; + // if we have a running FSStreamEvent, we have to kill it, we'll re-add the stream soon. + FSEventStreamEventId idToCheck; + if (fsStream) { + idToCheck = FSEventStreamGetLatestEventId(fsStream); + cleanupFSStream(fsStream); + } else { + idToCheck = kFSEventStreamEventIdSinceNow; + } + + // Brain-dead approach, but works. FSEvents actually can already read sub-trees, but since it's + // work to figure out if we are doing a double register, we just register it twice as FSEvents + // seems smart enough to only deliver one event. We also duplicate directory entries in here + // (e.g., if you watch five files in the same directory, you get that directory included in the + // array 5 times). This stupidity also makes remove work correctly though. I'll freely admit + // that we could make this a bit smarter. If you do, check the auto-tests, they should catch at + // least a couple of the issues. + QCFType<CFMutableArrayRef> tmpArray = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); + for (int i = 0; i < paths.size(); ++i) { + const QString &path = paths.at(i); + + QFileInfo fileInfo(path); + if (!fileInfo.exists()) { + failedToAdd.append(path); + continue; + } + + if (fileInfo.isDir()) { + if (directories->contains(path)) { + failedToAdd.append(path); + continue; + } else { + directories->append(path); + // Full file path for dirs. + QCFString cfpath(createFSStreamPath(fileInfo.absoluteFilePath())); + addPathToHash(dirPathInfoHash, cfpath, fileInfo, path); + CFArrayAppendValue(tmpArray, cfpath); + } + } else { + if (files->contains(path)) { + failedToAdd.append(path); + continue; + } else { + // Just the absolute path (minus it's filename) for files. + QCFString cfpath(createFSStreamPath(fileInfo.absolutePath())); + files->append(path); + addPathToHash(filePathInfoHash, cfpath, fileInfo, path); + CFArrayAppendValue(tmpArray, cfpath); + } + } + } + if (CFArrayGetCount(tmpArray) > 0) { + if (pathsToWatch) { + CFArrayAppendArray(tmpArray, pathsToWatch, CFRangeMake(0, CFArrayGetCount(pathsToWatch))); + CFRelease(pathsToWatch); + } + pathsToWatch = CFArrayCreateCopy(kCFAllocatorDefault, tmpArray); + } + FSEventStreamContext context = { 0, this, 0, 0, 0 }; + fsStream = FSEventStreamCreate(kCFAllocatorDefault, + QFSEventsFileSystemWatcherEngine::fseventsCallback, + &context, pathsToWatch, + idToCheck, Latency, QtFSEventFlags); + warmUpFSEvents(); + + return failedToAdd; +#else + Q_UNUSED(paths); + Q_UNUSED(files); + Q_UNUSED(directories); + return QStringList(); +#endif +} + +void QFSEventsFileSystemWatcherEngine::warmUpFSEvents() +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + // This function assumes that the mutex has already been grabbed before calling it. + // It exits with the mutex still locked (Q_ASSERT(mutex.isLocked()) ;-). + start(); + waitCondition.wait(&mutex); +#endif +} + +QStringList QFSEventsFileSystemWatcherEngine::removePaths(const QStringList &paths, + QStringList *files, + QStringList *directories) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + stop(); + QMutexLocker locker(&mutex); + // short circuit for smarties that call remove before add and we have nothing. + if (pathsToWatch == 0) + return paths; + QStringList failedToRemove; + // if we have a running FSStreamEvent, we have to stop it, we'll re-add the stream soon. + FSEventStreamEventId idToCheck; + if (fsStream) { + idToCheck = FSEventStreamGetLatestEventId(fsStream); + cleanupFSStream(fsStream); + fsStream = 0; + } else { + idToCheck = kFSEventStreamEventIdSinceNow; + } + + CFIndex itemCount = CFArrayGetCount(pathsToWatch); + QCFType<CFMutableArrayRef> tmpArray = CFArrayCreateMutableCopy(kCFAllocatorDefault, itemCount, + pathsToWatch); + CFRelease(pathsToWatch); + pathsToWatch = 0; + for (int i = 0; i < paths.size(); ++i) { + // Get the itemCount at the beginning to avoid any overruns during the iteration. + itemCount = CFArrayGetCount(tmpArray); + const QString &path = paths.at(i); + QFileInfo fi(path); + QCFString cfpath(createFSStreamPath(fi.absolutePath())); + + CFIndex index = CFArrayGetFirstIndexOfValue(tmpArray, CFRangeMake(0, itemCount), cfpath); + if (index != -1) { + CFArrayRemoveValueAtIndex(tmpArray, index); + files->removeAll(path); + removePathFromHash(filePathInfoHash, cfpath, path); + } else { + // Could be a directory we are watching instead. + QCFString cfdirpath(createFSStreamPath(fi.absoluteFilePath())); + index = CFArrayGetFirstIndexOfValue(tmpArray, CFRangeMake(0, itemCount), cfdirpath); + if (index != -1) { + CFArrayRemoveValueAtIndex(tmpArray, index); + directories->removeAll(path); + removePathFromHash(dirPathInfoHash, cfpath, path); + } else { + failedToRemove.append(path); + } + } + } + itemCount = CFArrayGetCount(tmpArray); + if (itemCount != 0) { + pathsToWatch = CFArrayCreateCopy(kCFAllocatorDefault, tmpArray); + + FSEventStreamContext context = { 0, this, 0, 0, 0 }; + fsStream = FSEventStreamCreate(kCFAllocatorDefault, + QFSEventsFileSystemWatcherEngine::fseventsCallback, + &context, pathsToWatch, idToCheck, Latency, QtFSEventFlags); + warmUpFSEvents(); + } + return failedToRemove; +#else + Q_UNUSED(paths); + Q_UNUSED(files); + Q_UNUSED(directories); + return QStringList(); +#endif +} + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +void QFSEventsFileSystemWatcherEngine::updateList(PathInfoList &list, bool directory, bool emitSignals) +{ + PathInfoList::iterator End = list.end(); + PathInfoList::iterator it = list.begin(); + while (it != End) { + struct ::stat64 newInfo; + if (::stat64(it->absolutePath, &newInfo) == 0) { + if (emitSignals) { + if (newInfo != it->savedInfo) { + it->savedInfo = newInfo; + if (directory) + emit directoryChanged(it->originalPath, false); + else + emit fileChanged(it->originalPath, false); + } + } else { + it->savedInfo = newInfo; + } + } else { + if (errno == ENOENT) { + if (emitSignals) { + if (directory) + emit directoryChanged(it->originalPath, true); + else + emit fileChanged(it->originalPath, true); + } + it = list.erase(it); + continue; + } else { + qWarning("%s:%d:QFSEventsFileSystemWatcherEngine: stat error on %s:%s", + __FILE__, __LINE__, qPrintable(it->originalPath), strerror(errno)); + + } + } + ++it; + } +} + +void QFSEventsFileSystemWatcherEngine::updateHash(PathHash &pathHash) +{ + PathHash::iterator HashEnd = pathHash.end(); + PathHash::iterator it = pathHash.begin(); + const bool IsDirectory = (&pathHash == &dirPathInfoHash); + while (it != HashEnd) { + updateList(it.value(), IsDirectory, false); + if (it.value().isEmpty()) + it = pathHash.erase(it); + else + ++it; + } +} +#endif + +void QFSEventsFileSystemWatcherEngine::fseventsCallback(ConstFSEventStreamRef , + void *clientCallBackInfo, size_t numEvents, + void *eventPaths, + const FSEventStreamEventFlags eventFlags[], + const FSEventStreamEventId []) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + QFSEventsFileSystemWatcherEngine *watcher = static_cast<QFSEventsFileSystemWatcherEngine *>(clientCallBackInfo); + QMutexLocker locker(&watcher->mutex); + CFArrayRef paths = static_cast<CFArrayRef>(eventPaths); + for (size_t i = 0; i < numEvents; ++i) { + const QString path = QCFString::toQString( + static_cast<CFStringRef>(CFArrayGetValueAtIndex(paths, i))); + const FSEventStreamEventFlags pathFlags = eventFlags[i]; + // There are several flags that may be passed, but we really don't care about them ATM. + // Here they are and why we don't care. + // kFSEventStreamEventFlagHistoryDone--(very unlikely to be gotten, but even then, not much changes). + // kFSEventStreamEventFlagMustScanSubDirs--Likely means the data is very much out of date, we + // aren't coalescing our directories, so again not so much of an issue + // kFSEventStreamEventFlagRootChanged | kFSEventStreamEventFlagMount | kFSEventStreamEventFlagUnmount-- + // These three flags indicate something has changed, but the stat will likely show this, so + // there's not really much to worry about. + // (btw, FSEvents is not the correct way of checking for mounts/unmounts, + // there are real CarbonCore events for that.) + Q_UNUSED(pathFlags); + if (watcher->filePathInfoHash.contains(path)) + watcher->updateList(watcher->filePathInfoHash[path], false, true); + + if (watcher->dirPathInfoHash.contains(path)) + watcher->updateList(watcher->dirPathInfoHash[path], true, true); + } +#else + Q_UNUSED(clientCallBackInfo); + Q_UNUSED(numEvents); + Q_UNUSED(eventPaths); + Q_UNUSED(eventFlags); +#endif +} + +void QFSEventsFileSystemWatcherEngine::stop() +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + stopFSStream(fsStream); + if (threadsRunLoop) + CFRunLoopStop(threadsRunLoop); +#endif +} + +void QFSEventsFileSystemWatcherEngine::updateFiles() +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + QMutexLocker locker(&mutex); + updateHash(filePathInfoHash); + updateHash(dirPathInfoHash); + if (filePathInfoHash.isEmpty() && dirPathInfoHash.isEmpty()) { + // Everything disappeared before we got to start, don't bother. + stop(); + cleanupFSStream(fsStream); + } + waitCondition.wakeAll(); +#endif +} + +void QFSEventsFileSystemWatcherEngine::run() +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + threadsRunLoop = CFRunLoopGetCurrent(); + FSEventStreamScheduleWithRunLoop(fsStream, threadsRunLoop, kCFRunLoopDefaultMode); + bool startedOK = FSEventStreamStart(fsStream); + // It's recommended by Apple that you only update the files after you've started + // the stream, because otherwise you might miss an update in between starting it. + updateFiles(); +#ifdef QT_NO_DEBUG + Q_UNUSED(startedOK); +#else + Q_ASSERT(startedOK); +#endif + // If for some reason we called stop up above (and invalidated our stream), this call will return + // immediately. + CFRunLoopRun(); + threadsRunLoop = 0; +#endif +} + +QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemwatcher_fsevents_p.h b/src/corelib/io/qfilesystemwatcher_fsevents_p.h new file mode 100644 index 0000000..2e8b788 --- /dev/null +++ b/src/corelib/io/qfilesystemwatcher_fsevents_p.h @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef FILEWATCHER_FSEVENTS_P_H +#define FILEWATCHER_FSEVENTS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include "qfilesystemwatcher_p.h" + +#include <QtCore/qmutex.h> +#include <QtCore/qwaitcondition.h> +#include <QtCore/qthread.h> +#include <QtCore/QHash> +#include <QtCore/QLinkedList> +#include <private/qcore_mac_p.h> +#include <sys/stat.h> + +typedef struct __FSEventStream *FSEventStreamRef; +typedef const struct __FSEventStream *ConstFSEventStreamRef; +typedef const struct __CFArray *CFArrayRef; +typedef uint FSEventStreamEventFlags; +typedef uint64_t FSEventStreamEventId; + +QT_BEGIN_NAMESPACE + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +// Yes, I use a stat64 element here. QFileInfo requires too much knowledge about implementation +// details to be used as a long-standing record. Since I'm going to have to store this information, I can +// do the stat myself too. +struct PathInfo { + PathInfo(const QString &path, const QByteArray &absPath) + : originalPath(path), absolutePath(absPath) {} + QString originalPath; // The path we need to emit + QByteArray absolutePath; // The path we need to stat. + struct ::stat64 savedInfo; // All the info for the path so we can compare it. +}; +typedef QLinkedList<PathInfo> PathInfoList; +typedef QHash<QString, PathInfoList> PathHash; +#endif + +class QFSEventsFileSystemWatcherEngine : public QFileSystemWatcherEngine +{ + Q_OBJECT +public: + ~QFSEventsFileSystemWatcherEngine(); + + static QFSEventsFileSystemWatcherEngine *create(); + + QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories); + QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories); + + void stop(); + +private: + QFSEventsFileSystemWatcherEngine(); + void warmUpFSEvents(); + void updateFiles(); + + static void fseventsCallback(ConstFSEventStreamRef streamRef, void *clientCallBackInfo, size_t numEvents, + void *eventPaths, const FSEventStreamEventFlags eventFlags[], + const FSEventStreamEventId eventIds[]); + void run(); + FSEventStreamRef fsStream; + CFArrayRef pathsToWatch; + CFRunLoopRef threadsRunLoop; + QMutex mutex; + QWaitCondition waitCondition; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + PathHash filePathInfoHash; + PathHash dirPathInfoHash; + void updateHash(PathHash &pathHash); + void updateList(PathInfoList &list, bool directory, bool emitSignals); +#endif +}; + +#endif + +QT_END_NAMESPACE diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index fac8a28..2139545 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -67,6 +67,25 @@ QT_BEGIN_NAMESPACE Q_CORE_EXPORT bool qt_disable_lowpriority_timers=false; +// check for _POSIX_MONOTONIC_CLOCK support +static bool supportsMonotonicClock() +{ + bool returnValue; + +#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) + returnValue = false; +# if (_POSIX_MONOTONIC_CLOCK == 0) + // detect if the system support monotonic timers + long x = sysconf(_SC_MONOTONIC_CLOCK); + returnValue = x >= 200112L; +# endif +#else + returnValue = true; +#endif + + return returnValue; +} + /***************************************************************************** UNIX signal handling *****************************************************************************/ @@ -262,18 +281,11 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags, */ QTimerInfoList::QTimerInfoList() + : useMonotonicTimers(supportsMonotonicClock()) { -#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) - useMonotonicTimers = false; - -# if (_POSIX_MONOTONIC_CLOCK == 0) - // detect if the system support monotonic timers - long x = sysconf(_SC_MONOTONIC_CLOCK); - useMonotonicTimers = x != -1; -# endif - getTime(currentTime); +#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) if (!useMonotonicTimers) { // not using monotonic timers, initialize the timeChanged() machinery previousTime = currentTime; @@ -290,9 +302,6 @@ QTimerInfoList::QTimerInfoList() ticksPerSecond = 0; msPerTick = 0; } -#else - // using monotonic timers unconditionally - getTime(currentTime); #endif firstTimerInfo = currentTimerInfo = 0; @@ -306,6 +315,20 @@ timeval QTimerInfoList::updateCurrentTime() #if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)) || defined(QT_BOOTSTRAPPED) +template <> +timeval qAbs(const timeval &t) +{ + timeval tmp = t; + if (tmp.tv_sec < 0) { + tmp.tv_sec = -tmp.tv_sec - 1; + tmp.tv_usec -= 1000000; + } + if (tmp.tv_sec == 0 && tmp.tv_usec < 0) { + tmp.tv_usec = -tmp.tv_usec; + } + return normalizedTimeval(tmp); +} + /* Returns true if the real time clock has changed by more than 10% relative to the processor time since the last time this function was @@ -318,23 +341,27 @@ bool QTimerInfoList::timeChanged(timeval *delta) tms unused; clock_t currentTicks = times(&unused); - int elapsedTicks = currentTicks - previousTicks; + clock_t elapsedTicks = currentTicks - previousTicks; timeval elapsedTime = currentTime - previousTime; - int elapsedMsecTicks = (elapsedTicks * 1000) / ticksPerSecond; - int deltaMsecs = (elapsedTime.tv_sec * 1000 + elapsedTime.tv_usec / 1000) - - elapsedMsecTicks; - if (delta) { - delta->tv_sec = deltaMsecs / 1000; - delta->tv_usec = (deltaMsecs % 1000) * 1000; - } + timeval elapsedTimeTicks; + elapsedTimeTicks.tv_sec = elapsedTicks / ticksPerSecond; + elapsedTimeTicks.tv_usec = (((elapsedTicks * 1000) / ticksPerSecond) % 1000) * 1000; + + timeval dummy; + if (!delta) + delta = &dummy; + *delta = elapsedTime - elapsedTimeTicks; + previousTicks = currentTicks; previousTime = currentTime; // If tick drift is more than 10% off compared to realtime, we assume that the clock has // been set. Of course, we have to allow for the tick granularity as well. - - return (qAbs(deltaMsecs) - msPerTick) * 10 > elapsedMsecTicks; + timeval tickGranularity; + tickGranularity.tv_sec = 0; + tickGranularity.tv_usec = msPerTick * 1000; + return elapsedTimeTicks < ((qAbs(*delta) - tickGranularity) * 10); } void QTimerInfoList::getTime(timeval &t) @@ -424,7 +451,7 @@ void QTimerInfoList::timerRepair(const timeval &diff) // repair all timers for (int i = 0; i < size(); ++i) { register QTimerInfo *t = at(i); - t->timeout = t->timeout - diff; + t->timeout = t->timeout + diff; } } @@ -622,7 +649,7 @@ int QEventDispatcherUNIX::select(int nfds, fd_set *readfds, fd_set *writefds, fd timeval *timeout) { Q_D(QEventDispatcherUNIX); - if (timeout) { + if (timeout && d->timerList.useMonotonicTimers) { // handle the case where select returns with a timeout, too // soon. timeval tvStart = d->timerList.currentTime; diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index ebba21b..28e7f9b 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -71,6 +71,18 @@ QT_BEGIN_NAMESPACE #endif // Internal operator functions for timevals +inline timeval &normalizedTimeval(timeval &t) +{ + while (t.tv_usec > 1000000l) { + ++t.tv_sec; + t.tv_usec -= 1000000l; + } + while (t.tv_usec < 0l) { + --t.tv_sec; + t.tv_usec += 1000000l; + } + return t; +} inline bool operator<(const timeval &t1, const timeval &t2) { return t1.tv_sec < t2.tv_sec || (t1.tv_sec == t2.tv_sec && t1.tv_usec < t2.tv_usec); } inline bool operator==(const timeval &t1, const timeval &t2) @@ -78,31 +90,29 @@ inline bool operator==(const timeval &t1, const timeval &t2) inline timeval &operator+=(timeval &t1, const timeval &t2) { t1.tv_sec += t2.tv_sec; - if ((t1.tv_usec += t2.tv_usec) >= 1000000l) { - ++t1.tv_sec; - t1.tv_usec -= 1000000l; - } - return t1; + t1.tv_usec += t2.tv_usec; + return normalizedTimeval(t1); } inline timeval operator+(const timeval &t1, const timeval &t2) { timeval tmp; tmp.tv_sec = t1.tv_sec + t2.tv_sec; - if ((tmp.tv_usec = t1.tv_usec + t2.tv_usec) >= 1000000l) { - ++tmp.tv_sec; - tmp.tv_usec -= 1000000l; - } - return tmp; + tmp.tv_usec = t1.tv_usec + t2.tv_usec; + return normalizedTimeval(tmp); } inline timeval operator-(const timeval &t1, const timeval &t2) { timeval tmp; - tmp.tv_sec = t1.tv_sec - t2.tv_sec; - if ((tmp.tv_usec = t1.tv_usec - t2.tv_usec) < 0l) { - --tmp.tv_sec; - tmp.tv_usec += 1000000l; - } - return tmp; + tmp.tv_sec = t1.tv_sec - (t2.tv_sec - 1); + tmp.tv_usec = t1.tv_usec - (t2.tv_usec + 1000000); + return normalizedTimeval(tmp); +} +inline timeval operator*(const timeval &t1, int mul) +{ + timeval tmp; + tmp.tv_sec = t1.tv_sec * mul; + tmp.tv_usec = t1.tv_usec * mul; + return normalizedTimeval(tmp); } // internal timer info @@ -117,8 +127,6 @@ struct QTimerInfo { class QTimerInfoList : public QList<QTimerInfo*> { #if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)) || defined(QT_BOOTSTRAPPED) - bool useMonotonicTimers; - timeval previousTime; clock_t previousTicks; int ticksPerSecond; @@ -133,6 +141,8 @@ class QTimerInfoList : public QList<QTimerInfo*> public: QTimerInfoList(); + const bool useMonotonicTimers; + void getTime(timeval &t); timeval currentTime; diff --git a/src/gui/embedded/embedded.pri b/src/gui/embedded/embedded.pri index 4a9aa3f..53a2512 100644 --- a/src/gui/embedded/embedded.pri +++ b/src/gui/embedded/embedded.pri @@ -141,15 +141,7 @@ embedded { !contains( kbd-drivers, qvfb ) { kbd-drivers += qvfb } - } - - contains( kbd-drivers, sl5000 ) { - HEADERS +=embedded/qkbdsl5000_qws.h - SOURCES +=embedded/qkbdsl5000_qws.cpp - !contains( kbd-drivers, tty ) { - kbd-drivers += tty - } - } + } contains( kbd-drivers, tty ) { HEADERS +=embedded/qkbdtty_qws.h @@ -166,16 +158,6 @@ embedded { SOURCES +=embedded/qkbdum_qws.cpp } - contains( kbd-drivers, yopy ) { - HEADERS +=embedded/qkbdyopy_qws.h - SOURCES +=embedded/qkbdyopy_qws.cpp - } - - contains( kbd-drivers, vr41xx ) { - HEADERS +=embedded/qkbdvr41xx_qws.h - SOURCES +=embedded/qkbdvr41xx_qws.cpp - } - # # Mouse drivers # @@ -189,29 +171,19 @@ embedded { SOURCES +=embedded/qmousepc_qws.cpp } - contains( mouse-drivers, bus ) { - HEADERS +=embedded/qmousebus_qws.h - SOURCES +=embedded/qmousebus_qws.cpp - } - contains( mouse-drivers, linuxtp ) { HEADERS +=embedded/qmouselinuxtp_qws.h SOURCES +=embedded/qmouselinuxtp_qws.cpp } - contains( mouse-drivers, vr41xx ) { - HEADERS +=embedded/qmousevr41xx_qws.h - SOURCES +=embedded/qmousevr41xx_qws.cpp - } - - contains( mouse-drivers, yopy ) { - HEADERS +=embedded/qmouseyopy_qws.h - SOURCES +=embedded/qmouseyopy_qws.cpp - } - contains( mouse-drivers, tslib ) { LIBS += -lts HEADERS +=embedded/qmousetslib_qws.h SOURCES +=embedded/qmousetslib_qws.cpp } + + contains( mouse-drivers, linuxinput ) { + HEADERS +=embedded/qmouselinuxinput_qws.h + SOURCES +=embedded/qmouselinuxinput_qws.cpp + } } diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp index 7799339..756a398 100644 --- a/src/gui/embedded/qkbd_qws.cpp +++ b/src/gui/embedded/qkbd_qws.cpp @@ -453,8 +453,9 @@ void QWSKeyboardHandler::endAutoRepeat() Maps \a keycode according to a keymap and sends that key event to the \l{Qt for Embedded Linux} server application. - Please see the QWS_KEYBOARD documentation for a description on how to - create and use keymap files. + Please see the \l{Qt for Embedded Linux Character Input} and the \l + {kmap2qmap} documentations for a description on how to create and use + keymap files. The key event is identified by its \a keycode value and the \a isPress and \a autoRepeat parameters. @@ -475,9 +476,6 @@ void QWSKeyboardHandler::endAutoRepeat() implementation needs to take care of a special action, like console switching or LED handling. - Standard Linux console keymaps can be found at the - \l {http://lct.sourceforege.net}{LCT project} - If standard Linux console keymaps are used, \a keycode must be one of the standardized values defined in \c /usr/include/linux/input.h diff --git a/src/gui/embedded/qkbddriverfactory_qws.cpp b/src/gui/embedded/qkbddriverfactory_qws.cpp index c599396..b77eb72 100644 --- a/src/gui/embedded/qkbddriverfactory_qws.cpp +++ b/src/gui/embedded/qkbddriverfactory_qws.cpp @@ -47,10 +47,7 @@ #include "qkbdtty_qws.h" #include "qkbdlinuxinput_qws.h" #include "qkbdum_qws.h" -#include "qkbdsl5000_qws.h" #include "qkbdvfb_qws.h" -#include "qkbdyopy_qws.h" -#include "qkbdvr41xx_qws.h" #include <stdlib.h> #include "private/qfactoryloader_p.h" #include "qkbddriverplugin_qws.h" @@ -104,18 +101,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, QWSKeyboardHandler *QKbdDriverFactory::create(const QString& key, const QString& device) { QString driver = key.toLower(); -#ifndef QT_NO_QWS_KBD_SL5000 - if (driver == QLatin1String("sl5000") || driver.isEmpty()) - return new QWSSL5000KeyboardHandler(device); -#endif -#ifndef QT_NO_QWS_KBD_YOPY - if (driver == QLatin1String("yopy") || driver.isEmpty()) - return new QWSYopyKeyboardHandler(device); -#endif -#ifndef QT_NO_QWS_KBD_VR41XX - if (driver == QLatin1String("vr41xx") || driver.isEmpty()) - return new QWSVr41xxKeyboardHandler(device); -#endif #ifndef QT_NO_QWS_KEYBOARD # ifndef QT_NO_QWS_KBD_TTY if (driver == QLatin1String("tty") || driver.isEmpty()) @@ -158,15 +143,6 @@ QStringList QKbdDriverFactory::keys() { QStringList list; -#ifndef QT_NO_QWS_KBD_SL5000 - list << QLatin1String("SL5000"); -#endif -#ifndef QT_NO_QWS_KBD_YOPY - list << QLatin1String("YOPY"); -#endif -#ifndef QT_NO_QWS_KBD_VR41XX - list << QLatin1String("VR41xx"); -#endif #ifndef QT_NO_QWS_KBD_TTY list << QLatin1String("TTY"); #endif diff --git a/src/gui/embedded/qkbdlinuxinput_qws.cpp b/src/gui/embedded/qkbdlinuxinput_qws.cpp index e552731..6aa6633 100644 --- a/src/gui/embedded/qkbdlinuxinput_qws.cpp +++ b/src/gui/embedded/qkbdlinuxinput_qws.cpp @@ -76,6 +76,7 @@ private: int m_fd; int m_tty_fd; struct termios m_tty_attr; + int m_orig_kbmode; }; QWSLinuxInputKeyboardHandler::QWSLinuxInputKeyboardHandler(const QString &device) @@ -95,8 +96,7 @@ bool QWSLinuxInputKeyboardHandler::filterInputEvent(quint16 &, qint32 &) } QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h, const QString &device) - : m_handler(h), m_fd(-1), m_tty_fd(-1) - + : m_handler(h), m_fd(-1), m_tty_fd(-1), m_orig_kbmode(K_XLATE) { setObjectName(QLatin1String("LinuxInputSubsystem Keyboard Handler")); @@ -135,7 +135,10 @@ QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h, struct ::termios termdata; tcgetattr(m_tty_fd, &termdata); - // setting this tranlation mode is also needed in INPUT mode to prevent + // record the original mode so we can restore it again in the destructor. + ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode); + + // setting this tranlation mode is even needed in INPUT mode to prevent // the shell from also interpreting codes, if the process has a tty // attached: e.g. Ctrl+C wouldn't copy, but kill the application. ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW); @@ -152,7 +155,7 @@ QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h, tcsetattr(m_tty_fd, TCSANOW, &termdata); } } else { - qWarning("Cannot open input device '%s': %s", qPrintable(dev), strerror(errno)); + qWarning("Cannot open keyboard input device '%s': %s", qPrintable(dev), strerror(errno)); return; } } @@ -160,7 +163,7 @@ QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h, QWSLinuxInputKbPrivate::~QWSLinuxInputKbPrivate() { if (m_tty_fd >= 0) { - ::ioctl(m_tty_fd, KDSKBMODE, K_XLATE); + ::ioctl(m_tty_fd, KDSKBMODE, m_orig_kbmode); tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr); } if (m_fd >= 0) diff --git a/src/gui/embedded/qkbdsl5000_qws.cpp b/src/gui/embedded/qkbdsl5000_qws.cpp deleted file mode 100644 index cf82c10..0000000 --- a/src/gui/embedded/qkbdsl5000_qws.cpp +++ /dev/null @@ -1,367 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qkbdsl5000_qws.h" - -#ifndef QT_NO_QWS_KBD_SL5000 - -#include "qwindowsystem_qws.h" -#include "qwsutils_qws.h" -#include "qscreen_qws.h" - -#include "qapplication.h" -#include "qnamespace.h" -#include "qtimer.h" - -#include <private/qcore_unix_p.h> // overrides QT_OPEN - -#include <unistd.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <errno.h> -#include <signal.h> - -#include <asm/sharp_char.h> - -#include <string.h> - -QT_BEGIN_NAMESPACE - -static const QWSKeyMap sl5000KeyMap[] = { - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 00 - { Qt::Key_A, 'a' , 'A' , 'A'-64 }, // 01 - { Qt::Key_B, 'b' , 'B' , 'B'-64 }, // 02 - { Qt::Key_C, 'c' , 'C' , 'C'-64 }, // 03 - { Qt::Key_D, 'd' , 'D' , 'D'-64 }, // 04 - { Qt::Key_E, 'e' , 'E' , 'E'-64 }, // 05 - { Qt::Key_F, 'f' , 'F' , 'F'-64 }, // 06 - { Qt::Key_G, 'g' , 'G' , 'G'-64 }, // 07 - { Qt::Key_H, 'h' , 'H' , 'H'-64 }, // 08 - { Qt::Key_I, 'i' , 'I' , 'I'-64 }, // 09 - { Qt::Key_J, 'j' , 'J' , 'J'-64 }, // 0a 10 - { Qt::Key_K, 'k' , 'K' , 'K'-64 }, // 0b - { Qt::Key_L, 'l' , 'L' , 'L'-64 }, // 0c - { Qt::Key_M, 'm' , 'M' , 'M'-64 }, // 0d - { Qt::Key_N, 'n' , 'N' , 'N'-64 }, // 0e - { Qt::Key_O, 'o' , 'O' , 'O'-64 }, // 0f - { Qt::Key_P, 'p' , 'P' , 'P'-64 }, // 10 - { Qt::Key_Q, 'q' , 'Q' , 'Q'-64 }, // 11 - { Qt::Key_R, 'r' , 'R' , 'R'-64 }, // 12 - { Qt::Key_S, 's' , 'S' , 'S'-64 }, // 13 - { Qt::Key_T, 't' , 'T' , 'T'-64 }, // 14 20 - { Qt::Key_U, 'u' , 'U' , 'U'-64 }, // 15 - { Qt::Key_V, 'v' , 'V' , 'V'-64 }, // 16 - { Qt::Key_W, 'w' , 'W' , 'W'-64 }, // 17 - { Qt::Key_X, 'x' , 'X' , 'X'-64 }, // 18 - { Qt::Key_Y, 'y' , 'Y' , 'Y'-64 }, // 19 - { Qt::Key_Z, 'z' , 'Z' , 'Z'-64 }, // 1a - { Qt::Key_Shift, 0xffff , 0xffff , 0xffff }, // 1b - { Qt::Key_Return, 13 , 13 , 0xffff }, // 1c - { Qt::Key_F11, 0xffff , 0xffff , 0xffff }, // 1d todo - { Qt::Key_F22, 0xffff , 0xffff , 0xffff }, // 1e 30 - { Qt::Key_Backspace, 8 , 8 , 0xffff }, // 1f - { Qt::Key_F31, 0xffff , 0xffff , 0xffff }, // 20 - { Qt::Key_F35, 0xffff , 0xffff , 0xffff }, // 21 light - { Qt::Key_Escape, 0xffff , 0xffff , 0xffff }, // 22 - - // Direction key code are for *UNROTATED* display. - { Qt::Key_Up, 0xffff , 0xffff , 0xffff }, // 23 - { Qt::Key_Right, 0xffff , 0xffff , 0xffff }, // 24 - { Qt::Key_Left, 0xffff , 0xffff , 0xffff }, // 25 - { Qt::Key_Down, 0xffff , 0xffff , 0xffff }, // 26 - - { Qt::Key_F33, 0xffff , 0xffff , 0xffff }, // 27 OK - { Qt::Key_F12, 0xffff , 0xffff , 0xffff }, // 28 40 home - { Qt::Key_1, '1' , 'q' , 'Q'-64 }, // 29 - { Qt::Key_2, '2' , 'w' , 'W'-64 }, // 2a - { Qt::Key_3, '3' , 'e' , 'E'-64 }, // 2b - { Qt::Key_4, '4' , 'r' , 'R'-64 }, // 2c - { Qt::Key_5, '5' , 't' , 'T'-64 }, // 2d - { Qt::Key_6, '6' , 'y' , 'Y'-64 }, // 2e - { Qt::Key_7, '7' , 'u' , 'U'-64 }, // 2f - { Qt::Key_8, '8' , 'i' , 'I'-64 }, // 30 - { Qt::Key_9, '9' , 'o' , 'O'-64 }, // 31 - { Qt::Key_0, '0' , 'p' , 'P'-64 }, // 32 50 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 33 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 34 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 35 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 36 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 37 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 38 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 39 - { Qt::Key_Minus, '-' , 'b' , 'B'-64 }, // 3a - { Qt::Key_Plus, '+' , 'n' , 'N'-64 }, // 3b - { Qt::Key_CapsLock, 0xffff , 0xffff , 0xffff }, // 3c 60 - { Qt::Key_At, '@' , 's' , 'S'-64 }, // 3d - { Qt::Key_Question, '?' , '?' , 0xffff }, // 3e - { Qt::Key_Comma, ',' , ',' , 0xffff }, // 3f - { Qt::Key_Period, '.' , '.' , 0xffff }, // 40 - { Qt::Key_Tab, 9 , '\\' , 0xffff }, // 41 - { Qt::Key_X, 0xffff , 'x' , 'X'-64 }, // 42 - { Qt::Key_C, 0xffff , 'c' , 'C'-64 }, // 43 - { Qt::Key_V, 0xffff , 'v' , 'V'-64 }, // 44 - { Qt::Key_Slash, '/' , '/' , 0xffff }, // 45 - { Qt::Key_Apostrophe, '\'' , '\'' , 0xffff }, // 46 70 - { Qt::Key_Semicolon, ';' , ';' , 0xffff }, // 47 - { Qt::Key_QuoteDbl, '\"' , '\"' , 0xffff }, // 48 - { Qt::Key_Colon, ':' , ':' , 0xffff }, // 49 - { Qt::Key_NumberSign, '#' , 'd' , 'D'-64 }, // 4a - { Qt::Key_Dollar, '$' , 'f' , 'F'-64 }, // 4b - { Qt::Key_Percent, '%' , 'g' , 'G'-64 }, // 4c - { Qt::Key_Underscore, '_' , 'h' , 'H'-64 }, // 4d - { Qt::Key_Ampersand, '&' , 'j' , 'J'-64 }, // 4e - { Qt::Key_Asterisk, '*' , 'k' , 'K'-64 }, // 4f - { Qt::Key_ParenLeft, '(' , 'l' , 'L'-64 }, // 50 80 - { Qt::Key_Delete, '[' , '[' , '[' }, // 51 - { Qt::Key_Z, 0xffff , 'z' , 'Z'-64 }, // 52 - { Qt::Key_Equal, '=' , 'm' , 'M'-64 }, // 53 - { Qt::Key_ParenRight, ')' , ']' , ']' }, // 54 - { Qt::Key_AsciiTilde, '~' , '^' , '^' }, // 55 - { Qt::Key_Less, '<' , '{' , '{' }, // 56 - { Qt::Key_Greater, '>' , '}' , '}' }, // 57 - { Qt::Key_F9, 0xffff , 0xffff , 0xffff }, // 58 datebook - { Qt::Key_F10, 0xffff , 0xffff , 0xffff }, // 59 address - { Qt::Key_F13, 0xffff , 0xffff , 0xffff }, // 5a 90 email - { Qt::Key_F30, ' ' , ' ' , 0xffff }, // 5b select - { Qt::Key_Space, ' ' , '|' , '`' }, // 5c - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 5d - { Qt::Key_Exclam, '!' , 'a' , 'A'-64 }, // 5e - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 5f - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 60 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 61 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 62 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 63 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 64 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 65 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 66 - { Qt::Key_Meta, 0xffff , 0xffff , 0xffff }, // 67 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 68 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 69 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 6a - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 6b - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 6c - { Qt::Key_F34, 0xffff , 0xffff , 0xffff }, // 6d power - { Qt::Key_F13, 0xffff , 0xffff , 0xffff }, // 6e mail long - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 6f - { Qt::Key_NumLock, 0xffff , 0xffff , 0xffff }, // 70 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 71 - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 72 - { 0x20ac, 0xffff , 0x20ac , 0x20ac }, // 73 Euro sign - { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 74 - { Qt::Key_F32, 0xffff , 0xffff , 0xffff }, // 75 Sync - { 0, 0xffff , 0xffff , 0xffff } -}; - -static const int keyMSize = sizeof(sl5000KeyMap)/sizeof(QWSKeyMap)-1; - -QWSSL5000KeyboardHandler::QWSSL5000KeyboardHandler(const QString &device) - : QWSTtyKeyboardHandler(device) -{ - shift = false; - alt = false; - ctrl = false; - extended = 0; - prevuni = 0; - prevkey = 0; - caps = false; - meta = false; - fn = false; - numLock = false; - - sharp_kbdctl_modifstat st; - int dev = QT_OPEN(device.isEmpty()?"/dev/sharp_kbdctl":device.toLocal8Bit().constData(), O_RDWR); - if (dev >= 0) { - memset(&st, 0, sizeof(st)); - st.which = 3; - int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); - if(!ret) - numLock = (bool)st.stat; - QT_CLOSE(dev); - } -} - -QWSSL5000KeyboardHandler::~QWSSL5000KeyboardHandler() -{ -} - -const QWSKeyMap *QWSSL5000KeyboardHandler::keyMap() const -{ - return sl5000KeyMap; -} - -bool QWSSL5000KeyboardHandler::filterKeycode(char &code) -{ - int keyCode = Qt::Key_unknown; - bool release = false; - - if (code & 0x80) { - release = true; - code &= 0x7f; - } - - if (fn && !meta && (code >= 0x42 && code <= 0x52)) { - ushort unicode=0; - int scan=0; - if (code == 0x42) { unicode='X'-'@'; scan=Qt::Key_X; } // Cut - else if (code == 0x43) { unicode='C'-'@'; scan=Qt::Key_C; } // Copy - else if (code == 0x44) { unicode='V'-'@'; scan=Qt::Key_V; } // Paste - else if (code == 0x52) { unicode='Z'-'@'; scan=Qt::Key_Z; } // Undo - if (scan) { - processKeyEvent(unicode, scan, Qt::ControlModifier, !release, false); - return true; - } - } - - if (code < keyMSize) { - keyCode = keyMap()[int(code)].key_code; - } - - bool repeatable = true; - - if (release && (keyCode == Qt::Key_F34 || keyCode == Qt::Key_F35)) - return true; // no release for power and light keys - if ((keyCode >= Qt::Key_F1 && keyCode <= Qt::Key_F35) - || keyCode == Qt::Key_Escape || keyCode == Qt::Key_Home - || keyCode == Qt::Key_Shift || keyCode == Qt::Key_Meta) - repeatable = false; - - if (qt_screen->isTransformed() - && keyCode >= Qt::Key_Left && keyCode <= Qt::Key_Down) - { - keyCode = transformDirKey(keyCode); - } - - // Ctrl-Alt-Delete exits qws - if (ctrl && alt && keyCode == Qt::Key_Delete) { - qApp->quit(); - } - - if (keyCode == Qt::Key_F22) { /* Fn key */ - fn = !release; - } else if (keyCode == Qt::Key_NumLock) { - if (release) - numLock = !numLock; - } else if (keyCode == Qt::AltModifier) { - alt = !release; - } else if (keyCode == Qt::ControlModifier) { - ctrl = !release; - } else if (keyCode == Qt::ShiftModifier) { - shift = !release; - } else if (keyCode == Qt::MetaModifier) { - meta = !release; - } else if (keyCode == Qt::Key_CapsLock && release) { - caps = !caps; - } - if (keyCode != Qt::Key_unknown) { - bool bAlt = alt; - bool bCtrl = ctrl; - bool bShift = shift; - int unicode = 0; - if (code < keyMSize) { - bool bCaps = caps ^ shift; - if (fn) { - if (shift) { - bCaps = bShift = false; - bCtrl = true; - } - if (meta) { - bCaps = bShift = true; - bAlt = true; - } - } else if (meta) { - bCaps = bShift = true; - } - if (code > 40 && caps) { - // fn-keys should only react to shift, not caps - bCaps = bShift = shift; - } - if (numLock) { - if (keyCode != Qt::Key_Space && keyCode != Qt::Key_Tab) - bCaps = bShift = false; - } - if (keyCode == Qt::Key_Delete && (bAlt || bCtrl)) { - keyCode = Qt::Key_BraceLeft; - unicode = '['; - bCaps = bShift = bAlt = bCtrl = false; - } else if (keyCode == Qt::Key_F31 && bCtrl) { - keyCode = Qt::Key_QuoteLeft; - unicode = '`'; - } else if (bCtrl) - unicode = keyMap()[int(code)].ctrl_unicode ? keyMap()[int(code)].ctrl_unicode : 0xffff; - else if (bCaps) - unicode = keyMap()[int(code)].shift_unicode ? keyMap()[int(code)].shift_unicode : 0xffff; - else - unicode = keyMap()[int(code)].unicode ? keyMap()[int(code)].unicode : 0xffff; - } - - modifiers = 0; - if (bAlt) modifiers |= Qt::AltModifier; - if (bCtrl) modifiers |= Qt::ControlModifier; - if (bShift) modifiers |= Qt::ShiftModifier; - - // looks wrong -- WWA - bool repeat = false; - if (prevuni == unicode && prevkey == keyCode && !release) - repeat = true; - - processKeyEvent(unicode, keyCode, modifiers, !release, repeat); - - if (!release) { - prevuni = unicode; - prevkey = keyCode; - } else { - prevkey = prevuni = 0; - } - } - - if (repeatable && !release) - beginAutoRepeat(prevuni, prevkey, modifiers); - else - endAutoRepeat(); - - return true; -} - -QT_END_NAMESPACE - -#endif // QT_NO_QWS_KBD_SL5000 diff --git a/src/gui/embedded/qkbdsl5000_qws.h b/src/gui/embedded/qkbdsl5000_qws.h deleted file mode 100644 index 42afbe1..0000000 --- a/src/gui/embedded/qkbdsl5000_qws.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QKBDSL5000_QWS_H -#define QKBDSL5000_QWS_H - -#include <QtGui/qkbdtty_qws.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#ifndef QT_NO_QWS_KBD_SL5000 - -struct QWSKeyMap { - uint key_code; - ushort unicode; - ushort shift_unicode; - ushort ctrl_unicode; -}; - - -class QWSSL5000KeyboardHandler : public QWSTtyKeyboardHandler -{ -public: - explicit QWSSL5000KeyboardHandler(const QString&); - virtual ~QWSSL5000KeyboardHandler(); - - bool filterKeycode(char &keycode); - virtual const QWSKeyMap *keyMap() const; - -private: - bool shift; - bool alt; - bool ctrl; - bool caps; - uint extended:2; - Qt::KeyboardModifiers modifiers; - int prevuni; - int prevkey; - bool meta; - bool fn; - bool numLock; -}; - -#endif // QT_NO_QWS_KBD_SL5000 - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QKBDSL5000_QWS_H diff --git a/src/gui/embedded/qkbdtty_qws.cpp b/src/gui/embedded/qkbdtty_qws.cpp index 8c1e79b..f107567 100644 --- a/src/gui/embedded/qkbdtty_qws.cpp +++ b/src/gui/embedded/qkbdtty_qws.cpp @@ -90,7 +90,7 @@ private: struct termios m_tty_attr; char m_last_keycode; int m_vt_qws; - int m_originalKbdMode; + int m_orig_kbmode; }; @@ -111,7 +111,7 @@ bool QWSTtyKeyboardHandler::filterKeycode(char &) } QWSTtyKbPrivate::QWSTtyKbPrivate(QWSTtyKeyboardHandler *h, const QString &device) - : m_handler(h), m_tty_fd(-1), m_last_keycode(0), m_vt_qws(0) + : m_handler(h), m_tty_fd(-1), m_last_keycode(0), m_vt_qws(0), m_orig_kbmode(K_XLATE) { setObjectName(QLatin1String("TTY Keyboard Handler")); #ifndef QT_NO_QWS_SIGNALHANDLER @@ -152,15 +152,15 @@ QWSTtyKbPrivate::QWSTtyKbPrivate(QWSTtyKeyboardHandler *h, const QString &device tcgetattr(m_tty_fd, &termdata); #if defined(Q_OS_LINUX) - // record the original mode so we can restore it again in the constructor - ::ioctl(m_tty_fd, KDGKBMODE, m_originalKbdMode); + // record the original mode so we can restore it again in the destructor. + ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode); // PLEASE NOTE: - // The tty keycode interface can only report keycodes 0x01 .. 0x7f + // the tty keycode interface can only report keycodes 0x01 .. 0x7f // KEY_MAX is however defined to 0x1ff. In practice this is sufficient // for a PC style keyboard though. - // we don't support K_RAW anymore - if you need, you habe to add a - // scan- to keycode converter. + // we don't support K_RAW anymore - if you need that, you have to add + // a scan- to keycode converter yourself. ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW); #endif @@ -211,12 +211,10 @@ QWSTtyKbPrivate::~QWSTtyKbPrivate() { if (m_tty_fd >= 0) { #if defined(Q_OS_LINUX) - ::ioctl(m_tty_fd, KDSKBMODE, m_originalKbdMode); + ::ioctl(m_tty_fd, KDSKBMODE, m_orig_kbmode); #endif tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr); - - // we're leaking m_tty_fd here? - //QT_CLOSE(m_tty_fd); + QT_CLOSE(m_tty_fd); } } diff --git a/src/gui/embedded/qkbdvr41xx_qws.cpp b/src/gui/embedded/qkbdvr41xx_qws.cpp deleted file mode 100644 index 6d8299b..0000000 --- a/src/gui/embedded/qkbdvr41xx_qws.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qkbdvr41xx_qws.h" - -#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_VR41XX) - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <termios.h> -#include <unistd.h> -#include <errno.h> - -#include <qsocketnotifier.h> -#include <private/qcore_unix_p.h> // overrides QT_OPEN - -QT_BEGIN_NAMESPACE - -class QWSVr41xxKbPrivate : public QObject -{ - Q_OBJECT -public: - QWSVr41xxKbPrivate(QWSVr41xxKeyboardHandler *h, const QString&); - virtual ~QWSVr41xxKbPrivate(); - - bool isOpen() { return buttonFD > 0; } - -private slots: - void readKeyboardData(); - -private: - QString terminalName; - int buttonFD; - int kbdIdx; - int kbdBufferLen; - unsigned char *kbdBuffer; - QSocketNotifier *notifier; - QWSVr41xxKeyboardHandler *handler; -}; - -QWSVr41xxKeyboardHandler::QWSVr41xxKeyboardHandler(const QString &device) -{ - d = new QWSVr41xxKbPrivate(this, device); -} - -QWSVr41xxKeyboardHandler::~QWSVr41xxKeyboardHandler() -{ - delete d; -} - -QWSVr41xxKbPrivate::QWSVr41xxKbPrivate(QWSVr41xxKeyboardHandler *h, const QString &device) : handler(h) -{ - terminalName = device; - if (terminalName.isEmpty()) - terminalName = QLatin1String("/dev/buttons"); - buttonFD = -1; - notifier = 0; - - buttonFD = QT_OPEN(terminalName.toLatin1().constData(), O_RDWR | O_NDELAY, 0);; - if (buttonFD < 0) { - qWarning("Cannot open %s\n", qPrintable(terminalName)); - return; - } - - if (buttonFD >= 0) { - notifier = new QSocketNotifier(buttonFD, QSocketNotifier::Read, this); - connect(notifier, SIGNAL(activated(int)),this, - SLOT(readKeyboardData())); - } - - kbdBufferLen = 80; - kbdBuffer = new unsigned char [kbdBufferLen]; - kbdIdx = 0; -} - -QWSVr41xxKbPrivate::~QWSVr41xxKbPrivate() -{ - if (buttonFD > 0) { - QT_CLOSE(buttonFD); - buttonFD = -1; - } - delete notifier; - notifier = 0; - delete [] kbdBuffer; -} - -void QWSVr41xxKbPrivate::readKeyboardData() -{ - int n = 0; - do { - n = QT_READ(buttonFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx); - if (n > 0) - kbdIdx += n; - } while (n > 0); - - int idx = 0; - while (kbdIdx - idx >= 2) { - unsigned char *next = kbdBuffer + idx; - unsigned short *code = (unsigned short *)next; - int keycode = Qt::Key_unknown; - switch ((*code) & 0x0fff) { - case 0x7: - keycode = Qt::Key_Up; - break; - case 0x9: - keycode = Qt::Key_Right; - break; - case 0x8: - keycode = Qt::Key_Down; - break; - case 0xa: - keycode = Qt::Key_Left; - break; - case 0x3: - keycode = Qt::Key_Up; - break; - case 0x4: - keycode = Qt::Key_Down; - break; - case 0x1: - keycode = Qt::Key_Return; - break; - case 0x2: - keycode = Qt::Key_F4; - break; - default: - qDebug("Unrecognised key sequence %d", *code); - } - if ((*code) & 0x8000) - handler->processKeyEvent(0, keycode, 0, false, false); - else - handler->processKeyEvent(0, keycode, 0, true, false); - idx += 2; - } - - int surplus = kbdIdx - idx; - for (int i = 0; i < surplus; i++) - kbdBuffer[i] = kbdBuffer[idx+i]; - kbdIdx = surplus; -} - -QT_END_NAMESPACE - -#include "qkbdvr41xx_qws.moc" - -#endif // QT_NO_QWS_KBD_VR41XX diff --git a/src/gui/embedded/qkbdvr41xx_qws.h b/src/gui/embedded/qkbdvr41xx_qws.h deleted file mode 100644 index 1a657b9..0000000 --- a/src/gui/embedded/qkbdvr41xx_qws.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QKBDVR41XX_QWS_H -#define QKBDVR41XX_QWS_H - -#include <QtGui/qkbd_qws.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_VR41XX) - -class QWSVr41xxKbPrivate; - -class QWSVr41xxKeyboardHandler : public QWSKeyboardHandler -{ -public: - explicit QWSVr41xxKeyboardHandler(const QString&); - virtual ~QWSVr41xxKeyboardHandler(); - -private: - QWSVr41xxKbPrivate *d; -}; - -#endif // QT_NO_QWS_KBD_VR41XX - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QKBDVR41XX_QWS_H diff --git a/src/gui/embedded/qkbdyopy_qws.cpp b/src/gui/embedded/qkbdyopy_qws.cpp deleted file mode 100644 index edb732c..0000000 --- a/src/gui/embedded/qkbdyopy_qws.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - * YOPY buttons driver - * Contributed by Ron Victorelli (victorrj at icubed.com) - */ - -#include "qkbdyopy_qws.h" - -#ifndef QT_NO_QWS_KBD_YOPY - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <termios.h> -#include <unistd.h> -#include <errno.h> - -#include <linux/kd.h> -#include <linux/fb.h> -#include <linux/yopy_button.h> - -#include <private/qcore_unix_p.h> // overrides QT_OPEN - -extern "C" { - int getpgid(int); -} - -#include <qwidget.h> -#include <qsocketnotifier.h> - -QT_BEGIN_NAMESPACE - -class QWSYopyKbPrivate : public QObject -{ - Q_OBJECT -public: - QWSYopyKbPrivate(QWSYopyKeyboardHandler *h, const QString&); - virtual ~QWSYopyKbPrivate(); - - bool isOpen() { return buttonFD > 0; } - -private slots: - void readKeyboardData(); - -private: - QString terminalName; - int buttonFD; - struct termios newT, oldT; - QSocketNotifier *notifier; - QWSYopyKeyboardHandler *handler; -}; - -QWSYopyKeyboardHandler::QWSYopyKeyboardHandler(const QString &device) -{ - d = new QWSYopyKbPrivate(this, device); -} - -QWSYopyKeyboardHandler::~QWSYopyKeyboardHandler() -{ - delete d; -} - -QWSYopyKbPrivate::QWSYopyKbPrivate(QWSYopyKeyboardHandler *h, const QString &device) : handler(h) -{ - terminalName = device.isEmpty()?"/dev/tty1":device.toLatin1().constData(); - buttonFD = -1; - notifier = 0; - - buttonFD = QT_OPEN(terminalName.toLatin1().constData(), O_RDWR | O_NDELAY, 0); - if (buttonFD < 0) { - qWarning("Cannot open %s\n", qPrintable(terminalName)); - return; - } else { - - tcsetpgrp(buttonFD, getpgid(0)); - - /* put tty into "straight through" mode. - */ - if (tcgetattr(buttonFD, &oldT) < 0) { - qFatal("Linux-kbd: tcgetattr failed"); - } - - newT = oldT; - newT.c_lflag &= ~(ICANON | ECHO | ISIG); - newT.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); - newT.c_iflag |= IGNBRK; - newT.c_cc[VMIN] = 0; - newT.c_cc[VTIME] = 0; - - - if (tcsetattr(buttonFD, TCSANOW, &newT) < 0) { - qFatal("Linux-kbd: TCSANOW tcsetattr failed"); - } - - if (ioctl(buttonFD, KDSKBMODE, K_MEDIUMRAW) < 0) { - qFatal("Linux-kbd: KDSKBMODE tcsetattr failed"); - } - - notifier = new QSocketNotifier(buttonFD, QSocketNotifier::Read, this); - connect(notifier, SIGNAL(activated(int)),this, - SLOT(readKeyboardData())); - } -} - -QWSYopyKbPrivate::~QWSYopyKbPrivate() -{ - if (buttonFD > 0) { - ::close(buttonFD); - buttonFD = -1; - } -} - -void QWSYopyKbPrivate::readKeyboardData() -{ - uchar buf[1]; - char c='1'; - int fd; - - int n=read(buttonFD,buf,1); - if (n<0) { - qDebug("Keyboard read error %s",strerror(errno)); - } else { - uint code = buf[0]&YPBUTTON_CODE_MASK; - bool press = !(buf[0]&0x80); - // printf("Key=%d/%d/%d\n",buf[1],code,press); - int k=(-1); - switch(code) { - case 39: k=Qt::Key_Up; break; - case 44: k=Qt::Key_Down; break; - case 41: k=Qt::Key_Left; break; - case 42: k=Qt::Key_Right; break; - case 56: k=Qt::Key_F1; break; //windows - case 29: k=Qt::Key_F2; break; //cycle - case 24: k=Qt::Key_F3; break; //record - case 23: k=Qt::Key_F4; break; //mp3 - case 4: k=Qt::Key_F5; break; // PIMS - case 1: k=Qt::Key_Escape; break; // Escape - case 40: k=Qt::Key_Up; break; // prev - case 45: k=Qt::Key_Down; break; // next - case 35: if(!press) { - fd = QT_OPEN("/proc/sys/pm/sleep",O_RDWR,0); - if(fd >= 0) { - QT_WRITE(fd,&c,sizeof(c)); - QT_CLOSE(fd); - // - // Updates all widgets. - // - QWidgetList list = QApplication::allWidgets(); - for (int i = 0; i < list.size(); ++i) { - QWidget *w = list.at(i); - w->update(); - } - } - } - break; - - default: k=(-1); break; - } - - if (k >= 0) { - handler->processKeyEvent(0, k, 0, press, false); - } - } -} - -QT_END_NAMESPACE - -#include "qkbdyopy_qws.moc" - -#endif // QT_NO_QWS_KBD_YOPY diff --git a/src/gui/embedded/qkbdyopy_qws.h b/src/gui/embedded/qkbdyopy_qws.h deleted file mode 100644 index b4e45bd..0000000 --- a/src/gui/embedded/qkbdyopy_qws.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QKBDYOPY_QWS_H -#define QKBDYOPY_QWS_H - -#include <QtGui/qkbd_qws.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#ifndef QT_NO_QWS_KBD_YOPY - -class QWSYopyKbPrivate; - -class QWSYopyKeyboardHandler : public QWSKeyboardHandler -{ -public: - explicit QWSYopyKeyboardHandler(const QString&); - virtual ~QWSYopyKeyboardHandler(); - -private: - QWSYopyKbPrivate *d; -}; - -#endif // QT_NO_QWS_KBD_YOPY - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QKBDYOPY_QWS_H diff --git a/src/gui/embedded/qmousebus_qws.cpp b/src/gui/embedded/qmousebus_qws.cpp deleted file mode 100644 index 0b674b6..0000000 --- a/src/gui/embedded/qmousebus_qws.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmousebus_qws.h" - -#ifndef QT_NO_QWS_MOUSE_BUS - -#include "qwindowsystem_qws.h" -#include "qsocketnotifier.h" - -#include "qapplication.h" -#include <private/qcore_unix_p.h> // overrides QT_OPEN - -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <errno.h> -#include <termios.h> - -QT_BEGIN_NAMESPACE - -/* - * bus mouse driver (a.k.a. Logitech busmouse) - */ - -class QWSBusMouseHandlerPrivate : public QObject -{ - Q_OBJECT -public: - QWSBusMouseHandlerPrivate(QWSBusMouseHandler *h, const QString &driver, const QString &device); - ~QWSBusMouseHandlerPrivate(); - - void suspend(); - void resume(); - -private slots: - void readMouseData(); - -protected: - enum { mouseBufSize = 128 }; - QWSBusMouseHandler *handler; - QSocketNotifier *mouseNotifier; - int mouseFD; - int mouseIdx; - int obstate; - uchar mouseBuf[mouseBufSize]; -}; - -QWSBusMouseHandler::QWSBusMouseHandler(const QString &driver, const QString &device) - : QWSMouseHandler(driver, device) -{ - d = new QWSBusMouseHandlerPrivate(this, driver, device); -} - -QWSBusMouseHandler::~QWSBusMouseHandler() -{ - delete d; -} - -void QWSBusMouseHandler::suspend() -{ - d->suspend(); -} - -void QWSBusMouseHandler::resume() -{ - d->resume(); -} - - -QWSBusMouseHandlerPrivate::QWSBusMouseHandlerPrivate(QWSBusMouseHandler *h, - const QString &, const QString &device) - : handler(h) - -{ - QString mouseDev = device; - if (mouseDev.isEmpty()) - mouseDev = QLatin1String("/dev/mouse"); - obstate = -1; - mouseFD = -1; - mouseFD = QT_OPEN(mouseDev.toLocal8Bit(), O_RDWR | O_NDELAY); - if (mouseFD < 0) - mouseFD = QT_OPEN(mouseDev.toLocal8Bit(), O_RDONLY | O_NDELAY); - if (mouseFD < 0) - qDebug("Cannot open %s (%s)", qPrintable(mouseDev), strerror(errno)); - - // Clear pending input - tcflush(mouseFD,TCIFLUSH); - usleep(50000); - - char buf[100]; // busmouse driver will not read if bufsize < 3, YYD - while (QT_READ(mouseFD, buf, 100) > 0) { } // eat unwanted replies - - mouseIdx = 0; - - mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this); - connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData())); -} - -QWSBusMouseHandlerPrivate::~QWSBusMouseHandlerPrivate() -{ - if (mouseFD >= 0) { - tcflush(mouseFD,TCIFLUSH); // yyd. - QT_CLOSE(mouseFD); - } -} - - -void QWSBusMouseHandlerPrivate::suspend() -{ - mouseNotifier->setEnabled(false); -} - - -void QWSBusMouseHandlerPrivate::resume() -{ - mouseIdx = 0; - obstate = -1; - mouseNotifier->setEnabled(true); -} - -void QWSBusMouseHandlerPrivate::readMouseData() -{ - int n; - // It'll only read 3 bytes a time and return all other buffer zeroed, thus cause protocol errors - for (;;) { - if (mouseBufSize - mouseIdx < 3) - break; - n = QT_READ(mouseFD, mouseBuf+mouseIdx, 3); - if (n != 3) - break; - mouseIdx += 3; - } - - static const int accel_limit = 5; - static const int accel = 2; - - int idx = 0; - int bstate = 0; - int dx = 0, dy = 0; - bool sendEvent = false; - int tdx = 0, tdy = 0; - - while (mouseIdx-idx >= 3) { -#if 0 // debug - qDebug("Got mouse data"); -#endif - uchar *mb = mouseBuf+idx; - bstate = 0; - dx = 0; - dy = 0; - sendEvent = false; - if (((mb[0] & 0x04))) - bstate |= Qt::LeftButton; - if (((mb[0] & 0x01))) - bstate |= Qt::RightButton; - - dx=(signed char)mb[1]; - dy=(signed char)mb[2]; - sendEvent=true; - - if (sendEvent) { - if (qAbs(dx) > accel_limit || qAbs(dy) > accel_limit) { - dx *= accel; - dy *= accel; - } - tdx += dx; - tdy += dy; - if (bstate != obstate) { - QPoint pos = handler->pos() + QPoint(tdx,-tdy); - handler->limitToScreen(pos); - handler->mouseChanged(pos,bstate); - sendEvent = false; - tdx = 0; - tdy = 0; - obstate = bstate; - } - } - idx += 3; - } - if (sendEvent) { - QPoint pos = handler->pos() + QPoint(tdx,-tdy); - handler->limitToScreen(pos); - handler->mouseChanged(pos,bstate); - } - - int surplus = mouseIdx - idx; - for (int i = 0; i < surplus; i++) - mouseBuf[i] = mouseBuf[idx+i]; - mouseIdx = surplus; -} - -QT_END_NAMESPACE - -#include "qmousebus_qws.moc" - -#endif // QT_NO_QWS_MOUSE_BUS diff --git a/src/gui/embedded/qmousedriverfactory_qws.cpp b/src/gui/embedded/qmousedriverfactory_qws.cpp index 7e51818..46898ae 100644 --- a/src/gui/embedded/qmousedriverfactory_qws.cpp +++ b/src/gui/embedded/qmousedriverfactory_qws.cpp @@ -43,10 +43,8 @@ #include "qapplication.h" #include "qmousepc_qws.h" -#include "qmousebus_qws.h" -#include "qmousevr41xx_qws.h" -#include "qmouseyopy_qws.h" #include "qmouselinuxtp_qws.h" +#include "qmouselinuxinput_qws.h" #include "qmousevfb_qws.h" #include "qmousetslib_qws.h" #include <stdlib.h> @@ -108,14 +106,6 @@ QWSMouseHandler *QMouseDriverFactory::create(const QString& key, const QString & if (driver == QLatin1String("linuxtp") || driver.isEmpty()) return new QWSLinuxTPMouseHandler(key, device); #endif -#ifndef QT_NO_QWS_MOUSE_YOPY - if (driver == QLatin1String("yopy") || driver.isEmpty()) - return new QWSYopyMouseHandler(key, device); -#endif -#ifndef QT_NO_QWS_MOUSE_VR41XX - if (driver == QLatin1String("vr41xx") || driver.isEmpty()) - return new QWSVr41xxMouseHandler(key, device); -#endif #ifndef QT_NO_QWS_MOUSE_PC if (driver == QLatin1String("auto") || driver == QLatin1String("intellimouse") @@ -126,14 +116,16 @@ QWSMouseHandler *QMouseDriverFactory::create(const QString& key, const QString & return new QWSPcMouseHandler(key, device); } #endif -#ifndef QT_NO_QWS_MOUSE_BUS - if (driver == QLatin1String("bus")) - return new QWSBusMouseHandler(key, device); -#endif #ifndef QT_NO_QWS_MOUSE_TSLIB if (driver == QLatin1String("tslib") || driver.isEmpty()) return new QWSTslibMouseHandler(key, device); #endif +# ifndef QT_NO_QWS_MOUSE_LINUXINPUT + if (driver == QLatin1String("linuxinput") || \ + driver == QLatin1String("usb") || \ + driver == QLatin1String("linuxis")) + return new QWSLinuxInputMouseHandler(device); +# endif #ifndef QT_NO_QWS_MOUSE_QVFB if (driver == QLatin1String("qvfbmouse") || driver == QLatin1String("qvfb")) return new QVFbMouseHandler(key, device); @@ -160,12 +152,6 @@ QStringList QMouseDriverFactory::keys() #ifndef QT_NO_QWS_MOUSE_LINUXTP list << QLatin1String("LinuxTP"); #endif -#ifndef QT_NO_QWS_MOUSE_YOPY - list << QLatin1String("Yopy"); -#endif -#ifndef QT_NO_QWS_MOUSE_VR41XX - list << QLatin1String("VR41xx"); -#endif #ifndef QT_NO_QWS_MOUSE_PC list << QLatin1String("Auto") << QLatin1String("IntelliMouse") @@ -173,12 +159,12 @@ QStringList QMouseDriverFactory::keys() << QLatin1String("MouseSystems") << QLatin1String("MouseMan"); #endif -#ifndef QT_NO_QWS_MOUSE_BUS - list << QLatin1String("Bus"); -#endif #ifndef QT_NO_QWS_MOUSE_TSLIB list << QLatin1String("Tslib"); #endif +#ifndef QT_NO_QWS_MOUSE_LINUXINPUT + list << QLatin1String("LinuxInput"); +#endif #if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL) #ifndef QT_NO_LIBRARY diff --git a/src/gui/embedded/qmouselinuxinput_qws.cpp b/src/gui/embedded/qmouselinuxinput_qws.cpp new file mode 100644 index 0000000..6ea8807 --- /dev/null +++ b/src/gui/embedded/qmouselinuxinput_qws.cpp @@ -0,0 +1,205 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmouselinuxinput_qws.h" + +#include <QScreen> +#include <QSocketNotifier> + +#include <qplatformdefs.h> +#include <private/qcore_unix_p.h> // overrides QT_OPEN + +#include <errno.h> + +#include <linux/input.h> + +QT_BEGIN_NAMESPACE + + +class QWSLinuxInputMousePrivate : public QObject +{ + Q_OBJECT +public: + QWSLinuxInputMousePrivate(QWSLinuxInputMouseHandler *, const QString &); + ~QWSLinuxInputMousePrivate(); + + void enable(bool on); + +private Q_SLOTS: + void readMouseData(); + +private: + QWSLinuxInputMouseHandler *m_handler; + QSocketNotifier * m_notify; + int m_fd; + int m_x, m_y; + int m_buttons; +}; + +QWSLinuxInputMouseHandler::QWSLinuxInputMouseHandler(const QString &device) + : QWSCalibratedMouseHandler(device) +{ + d = new QWSLinuxInputMousePrivate(this, device); +} + +QWSLinuxInputMouseHandler::~QWSLinuxInputMouseHandler() +{ + delete d; +} + +void QWSLinuxInputMouseHandler::suspend() +{ + d->enable(false); +} + +void QWSLinuxInputMouseHandler::resume() +{ + d->enable(true); +} + +QWSLinuxInputMousePrivate::QWSLinuxInputMousePrivate(QWSLinuxInputMouseHandler *h, const QString &device) + : m_handler(h), m_notify(0), m_x(0), m_y(0), m_buttons(0) +{ + setObjectName(QLatin1String("LinuxInputSubsystem Mouse Handler")); + + QString dev = QLatin1String("/dev/input/event0"); + if (device.startsWith(QLatin1String("/dev/"))) + dev = device; + + m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0); + if (m_fd >= 0) { + m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); + connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData())); + } else { + qWarning("Cannot open mouse input device '%s': %s", qPrintable(dev), strerror(errno)); + return; + } +} + +QWSLinuxInputMousePrivate::~QWSLinuxInputMousePrivate() +{ + if (m_fd >= 0) + QT_CLOSE(m_fd); +} + +void QWSLinuxInputMousePrivate::enable(bool on) +{ + if (m_notify) + m_notify->setEnabled(on); +} + +void QWSLinuxInputMousePrivate::readMouseData() +{ + if (!qt_screen) + return; + + struct ::input_event buffer[32]; + int n = 0; + + forever { + n = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n); + + if (n == 0) { + qWarning("Got EOF from the input device."); + return; + } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) { + qWarning("Could not read from input device: %s", strerror(errno)); + return; + } else if (n % sizeof(buffer[0]) == 0) { + break; + } + } + + n /= sizeof(buffer[0]); + + for (int i = 0; i < n; ++i) { + struct ::input_event *data = &buffer[i]; + + bool unknown = false; + if (data->type == EV_ABS) { + if (data->code == ABS_X) { + m_x = data->value; + } else if (data->code == ABS_Y) { + m_y = data->value; + } else { + unknown = true; + } + } else if (data->type == EV_REL) { + if (data->code == REL_X) { + m_x += data->value; + } else if (data->code == REL_Y) { + m_y += data->value; + } else { + unknown = true; + } + } else if (data->type == EV_KEY && data->code == BTN_TOUCH) { + m_buttons = data->value ? Qt::LeftButton : 0; + } else if (data->type == EV_KEY) { + int button = 0; + switch (data->code) { + case BTN_LEFT: button = Qt::LeftButton; break; + case BTN_MIDDLE: button = Qt::MidButton; break; + case BTN_RIGHT: button = Qt::RightButton; break; + } + if (data->value) + m_buttons |= button; + else + m_buttons &= ~button; + } else if (data->type == EV_SYN && data->code == SYN_REPORT) { + QPoint pos(m_x, m_y); + pos = m_handler->transform(pos); + m_handler->limitToScreen(pos); + m_handler->mouseChanged(pos, m_buttons); + } else if (data->type == EV_MSC && data->code == MSC_SCAN) { + // kernel encountered an unmapped key - just ignore it + continue; + } else { + unknown = true; + } + if (unknown) { + qWarning("unknown mouse event type=%x, code=%x, value=%x", data->type, data->code, data->value); + } + } +} + +QT_END_NAMESPACE + +#include "qmouselinuxinput_qws.moc" diff --git a/src/gui/embedded/qmousebus_qws.h b/src/gui/embedded/qmouselinuxinput_qws.h index 407da98..25e351f 100644 --- a/src/gui/embedded/qmousebus_qws.h +++ b/src/gui/embedded/qmouselinuxinput_qws.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,10 +39,10 @@ ** ****************************************************************************/ -#ifndef QMOUSEBUS_QWS_H -#define QMOUSEBUS_QWS_H +#ifndef QMOUSELINUXINPUT_QWS_H +#define QMOUSELINUXINPUT_QWS_H -#include <QtGui/qmouse_qws.h> +#include <QtGui/QWSCalibratedMouseHandler> QT_BEGIN_HEADER @@ -50,27 +50,29 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) -#ifndef QT_NO_QWS_MOUSE_BUS +#ifndef QT_NO_QWS_MOUSE_LINUXINPUT -class QWSBusMouseHandlerPrivate; +class QWSLinuxInputMousePrivate; -class QWSBusMouseHandler : public QWSMouseHandler +class QWSLinuxInputMouseHandler : public QWSCalibratedMouseHandler { public: - explicit QWSBusMouseHandler(const QString & = QString(), - const QString & = QString()); - ~QWSBusMouseHandler(); + QWSLinuxInputMouseHandler(const QString &); + ~QWSLinuxInputMouseHandler(); void suspend(); void resume(); -protected: - QWSBusMouseHandlerPrivate *d; + +private: + QWSLinuxInputMousePrivate *d; + + friend class QWSLinuxInputMousePrivate; }; -#endif // QT_NO_QWS_MOUSE_BUS +#endif // QT_NO_QWS_MOUSE_LINUXINPUT QT_END_NAMESPACE QT_END_HEADER -#endif // QMOUSEBUS_QWS_H +#endif // QMOUSELINUXINPUT_QWS_H diff --git a/src/gui/embedded/qmousevr41xx_qws.cpp b/src/gui/embedded/qmousevr41xx_qws.cpp deleted file mode 100644 index b7491d9..0000000 --- a/src/gui/embedded/qmousevr41xx_qws.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmousevr41xx_qws.h" - -#ifndef QT_NO_QWS_MOUSE_VR41XX -#include "qwindowsystem_qws.h" -#include "qsocketnotifier.h" -#include "qtimer.h" -#include "qapplication.h" -#include "qscreen_qws.h" -#include <qstringlist.h> -#include <qvarlengtharray.h> -#include <private/qcore_unix_p.h> // overrides QT_OPEN - -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <errno.h> -#include <termios.h> - -QT_BEGIN_NAMESPACE - -static const int defaultFilterSize = 3; - -class QWSVr41xxMouseHandlerPrivate : public QObject -{ - Q_OBJECT -public: - QWSVr41xxMouseHandlerPrivate(QWSVr41xxMouseHandler *, const QString &, const QString &); - ~QWSVr41xxMouseHandlerPrivate(); - - void resume(); - void suspend(); - -private slots: - void sendRelease(); - void readMouseData(); - -private: - bool getSample(); - ushort currSample[6]; - uint currLength; - - int mouseFD; - int mouseIdx; - QTimer *rtimer; - QSocketNotifier *mouseNotifier; - QWSVr41xxMouseHandler *handler; - QPoint lastPos; - bool isPressed; - int filterSize; - int pressLimit; -}; - -QWSVr41xxMouseHandler::QWSVr41xxMouseHandler(const QString &drv, const QString &dev) - : QWSCalibratedMouseHandler(drv, dev) -{ - d = new QWSVr41xxMouseHandlerPrivate(this, drv, dev); -} - -QWSVr41xxMouseHandler::~QWSVr41xxMouseHandler() -{ - delete d; -} - -void QWSVr41xxMouseHandler::resume() -{ - d->resume(); -} - -void QWSVr41xxMouseHandler::suspend() -{ - d->suspend(); -} - -QWSVr41xxMouseHandlerPrivate::QWSVr41xxMouseHandlerPrivate(QWSVr41xxMouseHandler *h, const QString &, const QString &device) - : currLength(0), handler(h) -{ - QStringList options = device.split(QLatin1String(":")); - int index = -1; - - filterSize = defaultFilterSize; - QRegExp filterRegExp(QLatin1String("filter=(\\d+)")); - index = options.indexOf(filterRegExp); - if (index != -1) { - filterSize = qMax(1, filterRegExp.cap(1).toInt()); - options.removeAt(index); - } - handler->setFilterSize(filterSize); - - pressLimit = 750; - QRegExp pressRegExp(QLatin1String("press=(\\d+)")); - index = options.indexOf(pressRegExp); - if (index != -1) { - pressLimit = filterRegExp.cap(1).toInt(); - options.removeAt(index); - } - - QString dev; - if (options.isEmpty()) - dev = QLatin1String("/dev/vrtpanel"); - else - dev = options.first(); - - if ((mouseFD = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY)) < 0) { - qWarning("Cannot open %s (%s)", qPrintable(dev), strerror(errno)); - return; - } - sleep(1); - - if (fcntl(mouseFD, F_SETFL, O_NONBLOCK) < 0) { - qWarning("Error initializing touch panel."); - return; - } - - mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this); - connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData())); - - rtimer = new QTimer(this); - rtimer->setSingleShot(true); - connect(rtimer, SIGNAL(timeout()), this, SLOT(sendRelease())); - mouseIdx = 0; -} - -QWSVr41xxMouseHandlerPrivate::~QWSVr41xxMouseHandlerPrivate() -{ - if (mouseFD >= 0) - QT_CLOSE(mouseFD); -} - -void QWSVr41xxMouseHandlerPrivate::suspend() -{ - mouseNotifier->setEnabled(false); -} - - -void QWSVr41xxMouseHandlerPrivate::resume() -{ - mouseIdx = 0; - mouseNotifier->setEnabled(true); -} - -void QWSVr41xxMouseHandlerPrivate::sendRelease() -{ - handler->sendFiltered(lastPos, Qt::NoButton); - isPressed = false; -} - -bool QWSVr41xxMouseHandlerPrivate::getSample() -{ - const int n = QT_READ(mouseFD, - reinterpret_cast<uchar*>(currSample) + currLength, - sizeof(currSample) - currLength); - - if (n > 0) - currLength += n; - - if (currLength < sizeof(currSample)) - return false; - - currLength = 0; - return true; -} - -void QWSVr41xxMouseHandlerPrivate::readMouseData() -{ - const int sampleLength = sizeof(currSample) / sizeof(ushort); - QVarLengthArray<ushort, sampleLength * defaultFilterSize> samples(sampleLength * filterSize); - - // Only return last 'filterSize' samples - int head = 0; - int tail = 0; - int nSamples = 0; - while (getSample()) { - if (!(currSample[0] & 0x8000) || (currSample[5] < pressLimit)) - continue; - - ushort *data = samples.data() + head * sampleLength; - memcpy(data, currSample, sizeof(currSample)); - ++nSamples; - head = (head + 1) % filterSize; - if (nSamples >= filterSize) - tail = (tail + 1) % filterSize; - } - - if (nSamples == 0) - return; - - // send mouse events - while (tail != head || filterSize == 1) { - const ushort *data = samples.data() + tail * sampleLength; - lastPos = QPoint(data[3] - data[4], data[2] - data[1]); - handler->sendFiltered(lastPos, Qt::LeftButton); - isPressed = true; - tail = (tail + 1) % filterSize; - if (filterSize == 1) - break; - } - - if (isPressed) - rtimer->start(50); // release unreliable -} - -QT_END_NAMESPACE - -#include "qmousevr41xx_qws.moc" - -#endif //QT_NO_QWS_MOUSE_VR41 diff --git a/src/gui/embedded/qmousevr41xx_qws.h b/src/gui/embedded/qmousevr41xx_qws.h deleted file mode 100644 index 46d07e0..0000000 --- a/src/gui/embedded/qmousevr41xx_qws.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMOUSEVR41XX_QWS_H -#define QMOUSEVR41XX_QWS_H - -#include <QtGui/qmouse_qws.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#ifndef QT_NO_QWS_MOUSE_VR41XX - -class QWSVr41xxMouseHandlerPrivate; - -class QWSVr41xxMouseHandler : public QWSCalibratedMouseHandler -{ -public: - explicit QWSVr41xxMouseHandler(const QString & = QString(), - const QString & = QString()); - ~QWSVr41xxMouseHandler(); - - void resume(); - void suspend(); - -protected: - QWSVr41xxMouseHandlerPrivate *d; - -private: - friend class QWSVr41xxMouseHandlerPrivate; -}; - -#endif // QT_NO_QWS_MOUSE_VR41XX - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMOUSEVR41XX_QWS_H diff --git a/src/gui/embedded/qmouseyopy_qws.cpp b/src/gui/embedded/qmouseyopy_qws.cpp deleted file mode 100644 index 3a541d3..0000000 --- a/src/gui/embedded/qmouseyopy_qws.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qmouseyopy_qws.h" - -#ifndef QT_NO_QWS_MOUSE_YOPY -#include "qwindowsystem_qws.h" -#include "qsocketnotifier.h" -#include "qapplication.h" -#include "qscreen_qws.h" -#include <private/qcore_unix_p.h> // overrides QT_OPEN - -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <errno.h> -#include <termios.h> - -QT_BEGIN_NAMESPACE - -class QWSYopyMouseHandlerPrivate : public QObject -{ - Q_OBJECT -public: - QWSYopyMouseHandlerPrivate(QWSYopyMouseHandler *h); - ~QWSYopyMouseHandlerPrivate(); - - void suspend(); - void resume(); - -private slots: - void readMouseData(); - -private: - int mouseFD; - int prevstate; - QSocketNotifier *mouseNotifier; - QWSYopyMouseHandler *handler; -}; - -QWSYopyMouseHandler::QWSYopyMouseHandler(const QString &driver, const QString &device) - : QWSMouseHandler(driver, device) -{ - d = new QWSYopyMouseHandlerPrivate(this); -} - -QWSYopyMouseHandler::~QWSYopyMouseHandler() -{ - delete d; -} - -void QWSYopyMouseHandler::resume() -{ - d->resume(); -} - -void QWSYopyMouseHandler::suspend() -{ - d->suspend(); -} - -QWSYopyMouseHandlerPrivate::QWSYopyMouseHandlerPrivate(QWSYopyMouseHandler *h) - : handler(h) -{ - if ((mouseFD = QT_OPEN("/dev/ts", O_RDONLY)) < 0) { - qWarning("Cannot open /dev/ts (%s)", strerror(errno)); - return; - } else { - sleep(1); - } - prevstate=0; - mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, - this); - connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData())); -} - -QWSYopyMouseHandlerPrivate::~QWSYopyMouseHandlerPrivate() -{ - if (mouseFD >= 0) - QT_CLOSE(mouseFD); -} - -#define YOPY_XPOS(d) (d[1]&0x3FF) -#define YOPY_YPOS(d) (d[2]&0x3FF) -#define YOPY_PRES(d) (d[0]&0xFF) -#define YOPY_STAT(d) (d[3]&0x01) - -struct YopyTPdata { - - unsigned char status; - unsigned short xpos; - unsigned short ypos; - -}; - -void QWSYopyMouseHandlerPrivate::suspend() -{ - mouseNotifier->setEnabled(false); -} - - -void QWSYopyMouseHandlerPrivate::resume() -{ - prevstate = 0; - mouseNotifier->setEnabled(true); -} - -void QWSYopyMouseHandlerPrivate::readMouseData() -{ - if(!qt_screen) - return; - YopyTPdata data; - - unsigned int yopDat[4]; - - int ret; - - ret=QT_READ(mouseFD,&yopDat,sizeof(yopDat)); - - if(ret) { - data.status= (YOPY_PRES(yopDat)) ? 1 : 0; - data.xpos=YOPY_XPOS(yopDat); - data.ypos=YOPY_YPOS(yopDat); - QPoint q; - q.setX(data.xpos); - q.setY(data.ypos); - if (data.status && !prevstate) { - handler->mouseChanged(q,Qt::LeftButton); - } else if(!data.status && prevstate) { - handler->mouseChanged(q,0); - } - prevstate = data.status; - } - if(ret<0) { - qDebug("Error %s",strerror(errno)); - } -} - -QT_END_NAMESPACE - -#include "qmouseyopy_qws.moc" - -#endif //QT_NO_QWS_MOUSE_YOPY diff --git a/src/gui/embedded/qmouseyopy_qws.h b/src/gui/embedded/qmouseyopy_qws.h deleted file mode 100644 index 0d24a8f..0000000 --- a/src/gui/embedded/qmouseyopy_qws.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMOUSEYOPY_QWS_H -#define QMOUSEYOPY_QWS_H - -#include <QtGui/qmouse_qws.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#ifndef QT_NO_QWS_MOUSE_YOPY - -// YOPY touch panel support based on changes contributed by Ron Victorelli -// (victorrj at icubed.com) to Custom TP driver. - -class QWSYopyMouseHandlerPrivate; - -class QWSYopyMouseHandler : public QWSMouseHandler -{ -public: - explicit QWSYopyMouseHandler(const QString & = QString(), - const QString & = QString()); - ~QWSYopyMouseHandler(); - - void resume(); - void suspend(); - -protected: - QWSYopyMouseHandlerPrivate *d; -}; - -#endif // QT_NO_QWS_MOUSE_YOPY - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMOUSEYOPY_QWS_H diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp index 017c13c..8eee665 100644 --- a/src/gui/kernel/qkeymapper_mac.cpp +++ b/src/gui/kernel/qkeymapper_mac.cpp @@ -729,8 +729,10 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e QString text(ourChar); /* This is actually wrong - but unfortunatly it is the best that can be done for now because of the Control/Meta mapping problems */ - if (modifiers & (Qt::ControlModifier | Qt::MetaModifier)) + if (modifiers & (Qt::ControlModifier | Qt::MetaModifier) + && !qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) { text = QString(); + } if (widget) { diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 308a0b8..ba28e75 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -2960,6 +2960,9 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, horizontalShift *= -1; verticalShift *= -1; } + if (tab->shape == QTabBar::RoundedWest || tab->shape == QTabBar::TriangularWest) + horizontalShift = -horizontalShift; + tr.adjust(0, 0, horizontalShift, verticalShift); if (selected) { diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 2a590fd..b2ad686 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -1245,8 +1245,7 @@ void QTextControlPrivate::keyPressEvent(QKeyEvent *e) process: { QString text = e->text(); - if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t')) && - ((e->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier)) == Qt::NoModifier)) { + if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) { if (overwriteMode // no need to call deleteChar() if we have a selection, insertText // does it already diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index d1067a8..c7f3e97 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -2169,8 +2169,7 @@ void QLineEdit::keyPressEvent(QKeyEvent *event) if (unknown && !d->readOnly) { QString t = event->text(); - if (!t.isEmpty() && t.at(0).isPrint() && - ((event->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier)) == Qt::NoModifier)) { + if (!t.isEmpty() && t.at(0).isPrint()) { insert(t); #ifndef QT_NO_COMPLETER d->complete(event->key()); diff --git a/src/plugins/kbddrivers/kbddrivers.pro b/src/plugins/kbddrivers/kbddrivers.pro index a34b780..dbab47b 100644 --- a/src/plugins/kbddrivers/kbddrivers.pro +++ b/src/plugins/kbddrivers/kbddrivers.pro @@ -1,5 +1,2 @@ TEMPLATE = subdirs contains(kbd-plugins, linuxinput): SUBDIRS += linuxinput -contains(kbd-plugins, sl5000): SUBDIRS += sl5000 -contains(kbd-plugins, vr41xx): SUBDIRS += vr41xx -contains(kbd-plugins, yopy): SUBDIRS += yopy diff --git a/src/plugins/kbddrivers/sl5000/main.cpp b/src/plugins/kbddrivers/sl5000/main.cpp deleted file mode 100644 index cc68747..0000000 --- a/src/plugins/kbddrivers/sl5000/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qkbddriverplugin_qws.h> -#include <qkbdsl5000_qws.h> - -QT_BEGIN_NAMESPACE - -class QSL5000KbdDriver : public QKbdDriverPlugin -{ -public: - QSL5000KbdDriver(); - - QStringList keys() const; - QWSKeyboardHandler* create(const QString &driver, const QString &device); -}; - -QSL5000KbdDriver::QSL5000KbdDriver() - : QKbdDriverPlugin() -{ -} - -QStringList QSL5000KbdDriver::keys() const -{ - return (QStringList() << QLatin1String("SL5000")); -} - -QWSKeyboardHandler* QSL5000KbdDriver::create(const QString &driver, - const QString &device) -{ - if (driver.compare(QLatin1String("SL5000"), Qt::CaseInsensitive)) - return 0; - return new QWSSL5000KeyboardHandler(device); -} - -Q_EXPORT_PLUGIN2(qwssl5000kbddriver, QSL5000KbdDriver) - -QT_END_NAMESPACE diff --git a/src/plugins/kbddrivers/sl5000/sl5000.pro b/src/plugins/kbddrivers/sl5000/sl5000.pro deleted file mode 100644 index e52cf0d..0000000 --- a/src/plugins/kbddrivers/sl5000/sl5000.pro +++ /dev/null @@ -1,16 +0,0 @@ -TARGET = qsl5000kbddriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers -target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers -INSTALLS += target - -DEFINES += QT_QWS_KBD_SL5000 QT_QWS_KBD_TTY - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdsl5000_qws.h \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdtty_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdsl5000_qws.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdtty_qws.cpp - diff --git a/src/plugins/kbddrivers/vr41xx/main.cpp b/src/plugins/kbddrivers/vr41xx/main.cpp deleted file mode 100644 index c9ba4d7..0000000 --- a/src/plugins/kbddrivers/vr41xx/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qkbddriverplugin_qws.h> -#include <qkbdvr41xx_qws.h> - -QT_BEGIN_NAMESPACE - -class QVr41xxKbdDriver : public QKbdDriverPlugin -{ -public: - QVr41xxKbdDriver(); - - QStringList keys() const; - QWSKeyboardHandler* create(const QString &driver, const QString &device); -}; - -QVr41xxKbdDriver::QVr41xxKbdDriver() - : QKbdDriverPlugin() -{ -} - -QStringList QVr41xxKbdDriver::keys() const -{ - return (QStringList() << QLatin1String("VR41xx")); -} - -QWSKeyboardHandler* QVr41xxKbdDriver::create(const QString &driver, - const QString &device) -{ - if (driver.compare(QLatin1String("VR41xx"), Qt::CaseInsensitive)) - return 0; - return new QWSVr41xxKeyboardHandler(device); -} - -Q_EXPORT_PLUGIN2(qwsvr41xxkbddriver, QVr41xxKbdDriver) - -QT_END_NAMESPACE diff --git a/src/plugins/kbddrivers/vr41xx/vr41xx.pro b/src/plugins/kbddrivers/vr41xx/vr41xx.pro deleted file mode 100644 index f9f103f..0000000 --- a/src/plugins/kbddrivers/vr41xx/vr41xx.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qvr41xxkbddriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers -target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers -INSTALLS += target - -DEFINES += QT_QWS_KBD_VR41XX - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdvr41xx_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdvr41xx_qws.cpp - diff --git a/src/plugins/kbddrivers/yopy/main.cpp b/src/plugins/kbddrivers/yopy/main.cpp deleted file mode 100644 index 7079d88..0000000 --- a/src/plugins/kbddrivers/yopy/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qkbddriverplugin_qws.h> -#include <qkbdyopy_qws.h> - -QT_BEGIN_NAMESPACE - -class QYopyKbdDriver : public QKbdDriverPlugin -{ -public: - QYopyKbdDriver(); - - QStringList keys() const; - QWSKeyboardHandler* create(const QString &driver, const QString &device); -}; - -QYopyKbdDriver::QYopyKbdDriver() - : QKbdDriverPlugin() -{ -} - -QStringList QYopyKbdDriver::keys() const -{ - return (QStringList() << QLatin1String("Yopy")); -} - -QWSKeyboardHandler* QYopyKbdDriver::create(const QString &driver, - const QString &device) -{ - if (driver.compare(QLatin1String("Yopy"), Qt::CaseInsensitive)) - return 0; - return new QWSYopyKeyboardHandler(device); -} - -Q_EXPORT_PLUGIN2(qwsyopykbddriver, QYopyKbdDriver) - -QT_END_NAMESPACE diff --git a/src/plugins/kbddrivers/yopy/yopy.pro b/src/plugins/kbddrivers/yopy/yopy.pro deleted file mode 100644 index 66a663c..0000000 --- a/src/plugins/kbddrivers/yopy/yopy.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qyopykbddriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/kbddrivers -target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers -INSTALLS += target - -DEFINES += QT_QWS_KBD_YOPY - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdyopy_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qkbdyopy_qws.cpp - diff --git a/src/plugins/mousedrivers/bus/bus.pro b/src/plugins/mousedrivers/bus/bus.pro deleted file mode 100644 index cdb0332..0000000 --- a/src/plugins/mousedrivers/bus/bus.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qbusmousedriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mousedrivers -target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers -INSTALLS += target - -DEFINES += QT_QWS_MOUSE_BUS - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qmousebus_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qmousebus_qws.cpp - diff --git a/src/plugins/mousedrivers/bus/main.cpp b/src/plugins/mousedrivers/bus/main.cpp deleted file mode 100644 index f56c890..0000000 --- a/src/plugins/mousedrivers/bus/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qmousedriverplugin_qws.h> -#include <qmousebus_qws.h> - -QT_BEGIN_NAMESPACE - -class QBusMouseDriver : public QMouseDriverPlugin -{ -public: - QBusMouseDriver(); - - QStringList keys() const; - QWSMouseHandler* create(const QString &driver, const QString &device); -}; - -QBusMouseDriver::QBusMouseDriver() - : QMouseDriverPlugin() -{ -} - -QStringList QBusMouseDriver::keys() const -{ - return (QStringList() << "Bus"); -} - -QWSMouseHandler* QBusMouseDriver::create(const QString &driver, - const QString &device) -{ - if (driver.compare(QLatin1String("Bus"), Qt::CaseInsensitive)) - return 0; - return new QWSBusMouseHandler(driver, device); -} - -Q_EXPORT_PLUGIN2(qwsbusmousehandler, QBusMouseDriver) - -QT_END_NAMESPACE diff --git a/src/plugins/mousedrivers/linuxis/linuxis.pro b/src/plugins/mousedrivers/linuxis/linuxis.pro deleted file mode 100644 index bcc209b..0000000 --- a/src/plugins/mousedrivers/linuxis/linuxis.pro +++ /dev/null @@ -1,10 +0,0 @@ -TARGET = linuxismousehandler -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mousedrivers -target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers -INSTALLS += target - -HEADERS = linuxismousedriverplugin.h linuxismousehandler.h -SOURCES = linuxismousedriverplugin.cpp linuxismousehandler.cpp - diff --git a/src/plugins/mousedrivers/linuxis/linuxismousedriverplugin.cpp b/src/plugins/mousedrivers/linuxis/linuxismousedriverplugin.cpp deleted file mode 100644 index 4d530d9..0000000 --- a/src/plugins/mousedrivers/linuxis/linuxismousedriverplugin.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "linuxismousedriverplugin.h" -#include "linuxismousehandler.h" - -#include <qdebug.h> -#if 1 -#define qLog(x) qDebug() -#else -#define qLog(x) while (0) qDebug() -#endif -LinuxInputSubsystemMouseDriverPlugin::LinuxInputSubsystemMouseDriverPlugin( QObject *parent ) - : QMouseDriverPlugin( parent ) -{ -} - -LinuxInputSubsystemMouseDriverPlugin::~LinuxInputSubsystemMouseDriverPlugin() -{ -} - -QWSMouseHandler* LinuxInputSubsystemMouseDriverPlugin::create(const QString& driver, const QString& device) -{ - if ( driver.toLower() == "linuxis" ) { - qLog(Input) << "Before call LinuxInputSubsystemMouseHandler()"; - return new LinuxInputSubsystemMouseHandler(device); - } - return 0; -} - -QWSMouseHandler* LinuxInputSubsystemMouseDriverPlugin::create(const QString& driver) -{ - if( driver.toLower() == "linuxis" ) { - qLog(Input) << "Before call LinuxInputSubsystemMouseHandler()"; - return new LinuxInputSubsystemMouseHandler(); - } - return 0; -} - -QStringList LinuxInputSubsystemMouseDriverPlugin::keys() const -{ - return QStringList() << "linuxis"; -} - -Q_EXPORT_PLUGIN2(qwslinuxismousehandler, LinuxInputSubsystemMouseDriverPlugin) diff --git a/src/plugins/mousedrivers/linuxis/linuxismousedriverplugin.h b/src/plugins/mousedrivers/linuxis/linuxismousedriverplugin.h deleted file mode 100644 index 57759c5..0000000 --- a/src/plugins/mousedrivers/linuxis/linuxismousedriverplugin.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LINUXISMOUSEDRIVERPLUGIN_H -#define LINUXISMOUSEDRIVERPLUGIN_H - -#include <QtGui/QWSMouseHandlerFactoryInterface> - -class LinuxInputSubsystemMouseDriverPlugin : public QMouseDriverPlugin { - Q_OBJECT -public: - LinuxInputSubsystemMouseDriverPlugin( QObject *parent = 0 ); - ~LinuxInputSubsystemMouseDriverPlugin(); - - QWSMouseHandler* create(const QString& driver); - QWSMouseHandler* create(const QString& driver, const QString& device); - QStringList keys()const; -}; - -#endif // LINUXISMOUSEDRIVERPLUGIN_H diff --git a/src/plugins/mousedrivers/linuxis/linuxismousehandler.cpp b/src/plugins/mousedrivers/linuxis/linuxismousehandler.cpp deleted file mode 100644 index aaa6eae..0000000 --- a/src/plugins/mousedrivers/linuxis/linuxismousehandler.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "linuxismousehandler.h" - -#include <QFile> -#include <QTextStream> -#include <QScreen> -#include <QSocketNotifier> -#include <QDebug> - -#include <qdebug.h> - -#include <string.h> -#include <errno.h> -#include <stdlib.h> -#include <fcntl.h> -#include <unistd.h> -#include <limits.h> - -#include <linux/input.h> - - -#if 1 -#define qLog(x) qDebug() -#else -#define qLog(x) while (0) qDebug() -#endif - - -// sanity check values of the range of possible mouse positions -#define MOUSE_SAMPLE_MIN 0 -#define MOUSE_SAMPLE_MAX 2000 - -LinuxInputSubsystemMouseHandler::LinuxInputSubsystemMouseHandler(const QString &device) - : mouseX(0), mouseY(0), mouseBtn(0), mouseIdx(0) -{ - qLog(Input) << "Loaded LinuxInputSubsystem touchscreen plugin!"; - setObjectName("LinuxInputSubsystem Mouse Handler"); - mouseFd = ::open(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY); - // mouseFd = ::open(device.toLocal8Bit().constData(), O_RDONLY); - if (mouseFd >= 0) { - qLog(Input) << "Opened" << device << "as touchscreen input"; - m_notify = new QSocketNotifier(mouseFd, QSocketNotifier::Read, this); - connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData())); - } else { - qWarning("Cannot open %s for touchscreen input (%s)", - device.toLocal8Bit().constData(), strerror(errno)); - return; - } -} - -LinuxInputSubsystemMouseHandler::~LinuxInputSubsystemMouseHandler() -{ - if (mouseFd >= 0) - ::close(mouseFd); -} - -void LinuxInputSubsystemMouseHandler::suspend() -{ - m_notify->setEnabled( false ); -} - -void LinuxInputSubsystemMouseHandler::resume() -{ - m_notify->setEnabled( true ); -} - -void LinuxInputSubsystemMouseHandler::readMouseData() -{ - if (!qt_screen) - return; - - int n; - - do { - n = read(mouseFd, mouseBuf + mouseIdx, mouseBufSize - mouseIdx); - if (n > 0) - mouseIdx += n; - - struct input_event *data; - int idx = 0; - - while (mouseIdx-idx >= (int)sizeof(struct input_event)) { - uchar *mb = mouseBuf + idx; - data = (struct input_event *) mb; - // qLog(Input) << "mouse event type =" << data->type << "code =" << data->code << "value =" << data->value; - bool unknown = false; - if (data->type == EV_ABS) { - if (data->code == ABS_X) { - //qLog(Input) << "\tABS_X" << data->value; - mouseX = data->value; - } else if (data->code == ABS_Y) { - //qLog(Input) << "\tABS_Y" << data->value; - mouseY = data->value; - } else { - unknown = true; - } - } else if (data->type == EV_REL) { - //qLog(Input) << "\tEV_REL" << hex << data->code << dec << data->value; - if (data->code == REL_X) { - mouseX += data->value; - } else if (data->code == REL_Y) { - mouseY += data->value; - } else { - unknown = true; - } - } else if (data->type == EV_KEY && data->code == BTN_TOUCH) { - qLog(Input) << "\tBTN_TOUCH" << data->value; - mouseBtn = data->value ? Qt::LeftButton : 0; - } else if (data->type == EV_KEY) { - int button = 0; - switch (data->code) { - case BTN_LEFT: button = Qt::LeftButton; break; - case BTN_MIDDLE: button = Qt::MidButton; break; - case BTN_RIGHT: button = Qt::RightButton; break; - } - if (data->value) - mouseBtn |= button; - else - mouseBtn &= ~button; - } else if (data->type == EV_SYN && data->code == SYN_REPORT) { - QPoint pos( mouseX, mouseY ); - oldmouse = transform( pos ); - //qLog(Input) << "\tSYN_REPORT" << mouseBtn << pos << oldmouse; - emit mouseChanged(oldmouse, mouseBtn); - - } else { - unknown = true; - } - if (unknown) { - qWarning("unknown mouse event type=%x, code=%x, value=%x", data->type, data->code, data->value); - } - idx += sizeof(struct input_event); - } - int surplus = mouseIdx - idx; - for (int i = 0; i < surplus; i++) - mouseBuf[i] = mouseBuf[idx+i]; - mouseIdx = surplus; - } while (n > 0); -} - diff --git a/src/plugins/mousedrivers/linuxis/linuxismousehandler.h b/src/plugins/mousedrivers/linuxis/linuxismousehandler.h deleted file mode 100644 index c898ddb..0000000 --- a/src/plugins/mousedrivers/linuxis/linuxismousehandler.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LINUXISMOUSEHANDLER_H -#define LINUXISMOUSEHANDLER_H - -#include <QtGui/QWSCalibratedMouseHandler> - -class QSocketNotifier; -class LinuxInputSubsystemMouseHandler : public QObject, public QWSCalibratedMouseHandler { - Q_OBJECT -public: - LinuxInputSubsystemMouseHandler(const QString &device = QString("/dev/input/event0")); - ~LinuxInputSubsystemMouseHandler(); - - void suspend(); - void resume(); - -private: - int mouseX, mouseY; - int mouseBtn; - static const int mouseBufSize = 2048; - uchar mouseBuf[mouseBufSize]; - int mouseIdx; - QPoint oldmouse; - - QSocketNotifier *m_notify; - int mouseFd; - -private Q_SLOTS: - void readMouseData(); -}; - -#endif // LINUXISMOUSEHANDLER_H diff --git a/src/plugins/mousedrivers/mousedrivers.pro b/src/plugins/mousedrivers/mousedrivers.pro index e644361..f89682b 100644 --- a/src/plugins/mousedrivers/mousedrivers.pro +++ b/src/plugins/mousedrivers/mousedrivers.pro @@ -1,8 +1,5 @@ TEMPLATE = subdirs -contains(mouse-plugins, bus): SUBDIRS += bus contains(mouse-plugins, linuxtp): SUBDIRS += linuxtp contains(mouse-plugins, pc): SUBDIRS += pc contains(mouse-plugins, tslib): SUBDIRS += tslib -contains(mouse-plugins, vr41xx): SUBDIRS += vr41xx -contains(mouse-plugins, yopy): SUBDIRS += yopy -contains(mouse-plugins, linuxis): SUBDIRS += linuxis +contains(mouse-plugins, linuxinput): SUBDIRS += linuxinput diff --git a/src/plugins/mousedrivers/vr41xx/main.cpp b/src/plugins/mousedrivers/vr41xx/main.cpp deleted file mode 100644 index 8802a02..0000000 --- a/src/plugins/mousedrivers/vr41xx/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qmousedriverplugin_qws.h> -#include <qmousevr41xx_qws.h> - -QT_BEGIN_NAMESPACE - -class QVr41xxMouseDriver : public QMouseDriverPlugin -{ -public: - QVr41xxMouseDriver(); - - QStringList keys() const; - QWSMouseHandler* create(const QString &driver, const QString &device); -}; - -QVr41xxMouseDriver::QVr41xxMouseDriver() - : QMouseDriverPlugin() -{ -} - -QStringList QVr41xxMouseDriver::keys() const -{ - return (QStringList() << QLatin1String("VR41xx")); -} - -QWSMouseHandler* QVr41xxMouseDriver::create(const QString &driver, - const QString &device) -{ - if (driver.compare(QLatin1String("VR41xx"), Qt::CaseInsensitive)) - return 0; - return new QWSVr41xxMouseHandler(driver, device); -} - -Q_EXPORT_PLUGIN2(qwsvr41xxmousehandler, QVr41xxMouseDriver) - -QT_END_NAMESPACE diff --git a/src/plugins/mousedrivers/vr41xx/vr41xx.pro b/src/plugins/mousedrivers/vr41xx/vr41xx.pro deleted file mode 100644 index 1c22d04..0000000 --- a/src/plugins/mousedrivers/vr41xx/vr41xx.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qvr41xxmousedriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mousedrivers -target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers -INSTALLS += target - -DEFINES += QT_QWS_MOUSE_VR41XX - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qmousevr41xx_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qmousevr41xx_qws.cpp - diff --git a/src/plugins/mousedrivers/yopy/main.cpp b/src/plugins/mousedrivers/yopy/main.cpp deleted file mode 100644 index 9db9c4f..0000000 --- a/src/plugins/mousedrivers/yopy/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qmousedriverplugin_qws.h> -#include <qmouseyopy_qws.h> - -QT_BEGIN_NAMESPACE - -class QYopyMouseDriver : public QMouseDriverPlugin -{ -public: - QYopyMouseDriver(); - - QStringList keys() const; - QWSMouseHandler* create(const QString &driver, const QString &device); -}; - -QYopyMouseDriver::QYopyMouseDriver() - : QMouseDriverPlugin() -{ -} - -QStringList QYopyMouseDriver::keys() const -{ - return (QStringList() << QLatin1String("Yopy")); -} - -QWSMouseHandler* QYopyMouseDriver::create(const QString &driver, - const QString &device) -{ - if (driver.compare(QLatin1String("yopy"), Qt::CaseInsensitive)) - return 0; - return new QWSYopyMouseHandler(driver, device); -} - -Q_EXPORT_PLUGIN2(qwsyopymousehandler, QYopyMouseDriver) - -QT_END_NAMESPACE diff --git a/src/plugins/mousedrivers/yopy/yopy.pro b/src/plugins/mousedrivers/yopy/yopy.pro deleted file mode 100644 index 3045430..0000000 --- a/src/plugins/mousedrivers/yopy/yopy.pro +++ /dev/null @@ -1,14 +0,0 @@ -TARGET = qyopymousedriver -include(../../qpluginbase.pri) - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mousedrivers -target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers -INSTALLS += target - -DEFINES += QT_QWS_MOUSE_YOPY - -HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qmouseyopy_qws.h - -SOURCES = main.cpp \ - $$QT_SOURCE_TREE/src/gui/embedded/qmouseyopy_qws.cpp - |