Qt 4.8
Public Functions | Private Types | Private Slots | Private Functions | Properties | List of all members
QWSPcMouseHandlerPrivate Class Reference
Inheritance diagram for QWSPcMouseHandlerPrivate:
QObject

Public Functions

 QWSPcMouseHandlerPrivate (QWSPcMouseHandler *h, const QString &, const QString &)
 
void resume ()
 
void suspend ()
 
 ~QWSPcMouseHandlerPrivate ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Types

enum  { max_dev =32 }
 

Private Slots

void readMouseData (int)
 

Private Functions

void closeDevices ()
 
void notify (int fd)
 
void openDevices ()
 
bool sendEvent (QWSPcMouseSubHandler &h)
 

Properties

qreal accel
 
int accel_limit
 
QString device
 
QString driver
 
QWSPcMouseHandlerhandler
 
QList< QSocketNotifier * > notifiers
 
int nsub
 
int retries
 
QWSPcMouseSubHandlersub [max_dev]
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 478 of file qmousepc_qws.cpp.

Enumerations

◆ anonymous enum

anonymous enum
private
Enumerator
max_dev 

Definition at line 489 of file qmousepc_qws.cpp.

Constructors and Destructors

◆ QWSPcMouseHandlerPrivate()

QWSPcMouseHandlerPrivate::QWSPcMouseHandlerPrivate ( QWSPcMouseHandler h,
const QString drv,
const QString arg 
)

Definition at line 534 of file qmousepc_qws.cpp.

536  : handler(h), driver(drv)
537 {
539 
540  int index;
541 
542  accel = qreal(2.0);
543  QRegExp accelRegex(QLatin1String("^accel=(\\d+\\.?\\d*)$"));
544  index = args.indexOf(accelRegex);
545  if (index >= 0) {
546  accel = qreal(accelRegex.cap(1).toDouble());
547  args.removeAt(index);
548  }
549 
550  accel_limit = 5;
551  QRegExp accelLimitRegex(QLatin1String("^accel_limit=(\\d+)$"));
552  index = args.indexOf(accelLimitRegex);
553  if (index >= 0) {
554  accel_limit = accelLimitRegex.cap(1).toInt();
555  args.removeAt(index);
556  }
557 
558  device = args.join(QString());
559 
560  retries = 0;
561  openDevices();
562 }
double qreal
Definition: qglobal.h:1193
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
int indexOf(const QRegExp &rx, int from=0) const
Returns the index position of the first exact match of rx in the list, searching forward from index p...
Definition: qstringlist.h:195
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QString join(const QString &sep) const
Joins all the string list&#39;s strings into a single string with each element separated by the given sep...
Definition: qstringlist.h:162
quint16 index
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
QWSPcMouseHandler * handler
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ ~QWSPcMouseHandlerPrivate()

QWSPcMouseHandlerPrivate::~QWSPcMouseHandlerPrivate ( )

Definition at line 564 of file qmousepc_qws.cpp.

565 {
566  closeDevices();
567 }

Functions

◆ closeDevices()

void QWSPcMouseHandlerPrivate::closeDevices ( )
private

Definition at line 710 of file qmousepc_qws.cpp.

Referenced by readMouseData(), and ~QWSPcMouseHandlerPrivate().

711 {
712  int pfd=-1;
713  for (int i=0; i<nsub; i++) {
714  sub[i]->closeIfNot(pfd);
715  delete sub[i];
716  }
718  notifiers.clear();
719 }
QList< QSocketNotifier * > notifiers
void clear()
Removes all items from the list.
Definition: qlist.h:764
QWSPcMouseSubHandler * sub[max_dev]
void closeIfNot(int &f)
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

◆ notify()

void QWSPcMouseHandlerPrivate::notify ( int  fd)
private

Definition at line 738 of file qmousepc_qws.cpp.

Referenced by openDevices().

739 {
740  QSocketNotifier *mouseNotifier
741  = new QSocketNotifier(fd, QSocketNotifier::Read, this);
742  connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData(int)));
743  notifiers.append(mouseNotifier);
744 }
#define SLOT(a)
Definition: qobjectdefs.h:226
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QSocketNotifier * > notifiers
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580

◆ openDevices()

void QWSPcMouseHandlerPrivate::openDevices ( )
private

Definition at line 640 of file qmousepc_qws.cpp.

Referenced by QWSPcMouseHandlerPrivate(), and readMouseData().

641 {
642  nsub=0;
643  int fd = -1;
644 
645  QString drv = driver.toLower();
646  if (!drv.isEmpty() && drv != QLatin1String("auto")) {
647  // Manually specified mouse
648  QByteArray dev = device.toLatin1();
649  if (drv == QLatin1String("intellimouse")) {
650  if (dev.isEmpty())
651  dev = "/dev/psaux";
652  fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
653  if (fd >= 0)
655  } else if (drv == QLatin1String("microsoft")) {
656  if (dev.isEmpty())
657  dev = "/dev/ttyS0";
658  fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
659  if (fd >= 0)
660  sub[nsub++] = new QWSPcMouseSubHandler_ms(fd);
661  } else if (drv == QLatin1String("mousesystems")) {
662  if (dev.isEmpty())
663  dev = "/dev/ttyS0";
664  fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
665  if (fd >= 0)
667  } else if (drv == QLatin1String("mouseman")) {
668  if (dev.isEmpty())
669  dev = "/dev/psaux";
670  fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
671  if (fd >= 0)
673  }
674  if (fd >= 0)
675  notify(fd);
676  else
677  qCritical("Error opening mouse device '%s': %s",
678  dev.constData(), strerror(errno));
679  } else {
680  // Try automatically
681  fd = QT_OPEN("/dev/psaux", O_RDWR | O_NDELAY);
682  if (fd >= 0) {
684  notify(fd);
685  }
686  fd = QT_OPEN("/dev/input/mice", O_RDWR | O_NDELAY);
687  if (fd >= 0) {
689  notify(fd);
690  //qDebug("/dev/input/mice fd %d #%d", fd, nsub-1);
691  }
692 
693 // include the code below to auto-detect serial mice, and to mess up
694 // any sort of serial communication
695 #if 0
696  const char fn[4][11] = { "/dev/ttyS0", "/dev/ttyS1", "/dev/ttyS2", "/dev/ttyS3" };
697  for (int ch = 0; ch < 4; ++ch) {
698  fd = QT_OPEN(fn[ch], O_RDWR | O_NDELAY);
699  if (fd >= 0) {
700  //sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
702  sub[nsub++] = new QWSPcMouseSubHandler_ms(fd);
703  notify(fd);
704  }
705  }
706 #endif
707  }
708 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
#define QT_OPEN
Definition: qcore_unix_p.h:186
QWSPcMouseSubHandler * sub[max_dev]
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
#define O_RDWR
Q_CORE_EXPORT void qCritical(const char *,...)
int errno

◆ readMouseData

void QWSPcMouseHandlerPrivate::readMouseData ( int  fd)
privateslot

Definition at line 746 of file qmousepc_qws.cpp.

Referenced by notify().

747 {
748  for (;;) {
749  uchar buf[8];
750  int n = read(fd, buf, 8);
751  if (n<=0)
752  break;
753  for (int i=0; i<nsub; i++) {
754  QWSPcMouseSubHandler& h = *sub[i];
755  if (h.file() == fd) {
756  h.appendData(buf,n);
757  for (;;) {
758  switch (h.useData()) {
760  sendEvent(h);
761  break;
763  goto breakbreak;
765  break;
766  }
767  }
768  breakbreak:
769  ;
770  }
771  }
772  }
773  bool any_reliable=false;
774  for (int i=0; i<nsub; i++) {
775  QWSPcMouseSubHandler& h = *sub[i];
776  if (h.motionPending())
777  sendEvent(h);
778  any_reliable = any_reliable || h.reliable();
779  }
780  if (any_reliable) {
781  // ... get rid of all unreliable ones? All bad ones?
782  } else if (retries < 2) {
783  // Try again - maybe the mouse was being moved when we tried to init.
784  closeDevices();
785  openDevices();
786  retries++;
787  }
788 }
bool motionPending() const
bool sendEvent(QWSPcMouseSubHandler &h)
UsageResult useData()
unsigned char uchar
Definition: qglobal.h:994
void appendData(uchar *data, int length)
QWSPcMouseSubHandler * sub[max_dev]

◆ resume()

void QWSPcMouseHandlerPrivate::resume ( )

Definition at line 727 of file qmousepc_qws.cpp.

Referenced by QWSPcMouseHandler::resume().

728 {
729  for (int i=0; i<nsub; i++)
730  sub[i]->initState();
731 
732  for (int i=0; i<notifiers.size(); ++i)
733  notifiers.at(i)->setEnabled(true);
734 }
QList< QSocketNotifier * > notifiers
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QWSPcMouseSubHandler * sub[max_dev]
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.

◆ sendEvent()

bool QWSPcMouseHandlerPrivate::sendEvent ( QWSPcMouseSubHandler h)
private

Definition at line 614 of file qmousepc_qws.cpp.

Referenced by readMouseData().

615 {
616  if (h.reliable()) {
617  QPoint motion = h.takeMotion();
618  if (qAbs(motion.x()) > accel_limit || qAbs(motion.y()) > accel_limit)
619  motion *= accel;
620  QPoint newPos = handler->pos() + motion;
621  if (qt_screen->isTransformed()) {
623  newPos = qt_screen->mapToDevice(newPos, s);
624  }
625  handler->limitToScreen(newPos);
626 
627  handler->mouseChanged(newPos, h.buttonState(), h.takeWheel());
628  return true;
629  } else {
630  h.takeMotion();
632  // Strange for the user to press right or middle without
633  // a moving mouse!
634  h.worse();
635  }
636  return false;
637  }
638 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
int height() const
Returns the logical height of the framebuffer in pixels.
Definition: qscreen_qws.h:228
const QPoint & pos() const
Returns the current mouse position.
Definition: qmouse_qws.h:82
void mouseChanged(const QPoint &pos, int bstate, int wheel=0)
Notifies the system of a new mouse event.
Definition: qmouse_qws.cpp:285
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
virtual QSize mapToDevice(const QSize &) const
Maps the given size from the coordinate space used by the application to the framebuffer coordinate s...
int width() const
Returns the logical width of the framebuffer in pixels.
Definition: qscreen_qws.h:227
void worse(int by=1)
virtual bool isTransformed() const
Returns true if the screen is transformed (for instance, rotated 90 degrees); otherwise returns false...
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QWSPcMouseHandler * handler
void limitToScreen(QPoint &pt)
Ensures that the given position is within the screen&#39;s boundaries, changing the position if necessary...
Definition: qmouse_qws.cpp:248

◆ suspend()

void QWSPcMouseHandlerPrivate::suspend ( )

Definition at line 721 of file qmousepc_qws.cpp.

Referenced by QWSPcMouseHandler::suspend().

722 {
723  for (int i=0; i<notifiers.size(); ++i)
724  notifiers.at(i)->setEnabled(false);
725 }
QList< QSocketNotifier * > notifiers
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.

Properties

◆ accel

qreal QWSPcMouseHandlerPrivate::accel
private

Definition at line 508 of file qmousepc_qws.cpp.

Referenced by QWSPcMouseHandlerPrivate(), and sendEvent().

◆ accel_limit

int QWSPcMouseHandlerPrivate::accel_limit
private

Definition at line 509 of file qmousepc_qws.cpp.

Referenced by QWSPcMouseHandlerPrivate(), and sendEvent().

◆ device

QString QWSPcMouseHandlerPrivate::device
private

Definition at line 507 of file qmousepc_qws.cpp.

Referenced by openDevices(), and QWSPcMouseHandlerPrivate().

◆ driver

QString QWSPcMouseHandlerPrivate::driver
private

Definition at line 506 of file qmousepc_qws.cpp.

Referenced by openDevices().

◆ handler

QWSPcMouseHandler* QWSPcMouseHandlerPrivate::handler
private

Definition at line 505 of file qmousepc_qws.cpp.

Referenced by sendEvent().

◆ notifiers

QList<QSocketNotifier*> QWSPcMouseHandlerPrivate::notifiers
private

Definition at line 491 of file qmousepc_qws.cpp.

Referenced by closeDevices(), notify(), resume(), and suspend().

◆ nsub

int QWSPcMouseHandlerPrivate::nsub
private

Definition at line 492 of file qmousepc_qws.cpp.

Referenced by closeDevices(), openDevices(), readMouseData(), and resume().

◆ retries

int QWSPcMouseHandlerPrivate::retries
private

Definition at line 493 of file qmousepc_qws.cpp.

Referenced by QWSPcMouseHandlerPrivate(), and readMouseData().

◆ sub

QWSPcMouseSubHandler* QWSPcMouseHandlerPrivate::sub[max_dev]
private

Definition at line 490 of file qmousepc_qws.cpp.

Referenced by closeDevices(), openDevices(), readMouseData(), and resume().


The documentation for this class was generated from the following file: