Added grabbing option for qevdevkeyboard and mouse.
Added option grab=1/0 which allows user to choose using environment variable if the application will exclusively grab the input device or let the OS read it in paralel(default). Task-number: QTBUG-30004 Change-Id: If3caa8419584be46f320931ddb152a41893d8693 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com> Reviewed-by: Andy Nichols <andy.nichols@digia.com>
This commit is contained in:
parent
3b992f8319
commit
2fbfad8b0d
@ -104,6 +104,7 @@ QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device, cons
|
||||
int repeatRate = 80;
|
||||
bool disableZap = false;
|
||||
bool enableCompose = false;
|
||||
int grab = 0;
|
||||
|
||||
QStringList args = specification.split(QLatin1Char(':'));
|
||||
foreach (const QString &arg, args) {
|
||||
@ -117,6 +118,8 @@ QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device, cons
|
||||
repeatDelay = arg.mid(13).toInt();
|
||||
else if (arg.startsWith(QLatin1String("repeat-rate=")))
|
||||
repeatRate = arg.mid(12).toInt();
|
||||
else if (arg.startsWith(QLatin1String("grab=")))
|
||||
grab = arg.mid(5).toInt();
|
||||
}
|
||||
|
||||
#ifdef QT_QPA_KEYMAP_DEBUG
|
||||
@ -126,6 +129,7 @@ QEvdevKeyboardHandler *QEvdevKeyboardHandler::create(const QString &device, cons
|
||||
int fd;
|
||||
fd = qt_safe_open(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
|
||||
if (fd >= 0) {
|
||||
::ioctl(fd, EVIOCGRAB, grab);
|
||||
if (repeatDelay > 0 && repeatRate > 0) {
|
||||
int kbdrep[2] = { repeatDelay, repeatRate };
|
||||
::ioctl(fd, EVIOCSREP, kbdrep);
|
||||
|
@ -70,6 +70,7 @@ QEvdevMouseHandler *QEvdevMouseHandler::create(const QString &device, const QStr
|
||||
|
||||
bool compression = true;
|
||||
int jitterLimit = 0;
|
||||
int grab = 0;
|
||||
|
||||
QStringList args = specification.split(QLatin1Char(':'));
|
||||
foreach (const QString &arg, args) {
|
||||
@ -77,11 +78,14 @@ QEvdevMouseHandler *QEvdevMouseHandler::create(const QString &device, const QStr
|
||||
compression = false;
|
||||
else if (arg.startsWith(QLatin1String("dejitter=")))
|
||||
jitterLimit = arg.mid(9).toInt();
|
||||
else if (arg.startsWith(QLatin1String("grab=")))
|
||||
grab = arg.mid(5).toInt();
|
||||
}
|
||||
|
||||
int fd;
|
||||
fd = qt_safe_open(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
|
||||
if (fd >= 0) {
|
||||
::ioctl(fd, EVIOCGRAB, grab);
|
||||
return new QEvdevMouseHandler(device, fd, compression, jitterLimit);
|
||||
} else {
|
||||
qWarning("Cannot open mouse input device '%s': %s", qPrintable(device), strerror(errno));
|
||||
|
Loading…
Reference in New Issue
Block a user