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

Public Functions

 QDirectFBMouseHandlerPrivate (QDirectFBMouseHandler *h)
 
void setEnabled (bool on)
 
 ~QDirectFBMouseHandlerPrivate ()
 
- 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 Slots

void readMouseData ()
 

Properties

uint bytesRead
 
DFBEvent event
 
IDirectFBEventBuffer * eventBuffer
 
QDirectFBMouseHandlerhandler
 
IDirectFBDisplayLayer * layer
 
QSocketNotifiermouseNotifier
 
Qt::MouseButtons prevbuttons
 
QPoint prevPoint
 

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 56 of file qdirectfbmouse.cpp.

Constructors and Destructors

◆ QDirectFBMouseHandlerPrivate()

QDirectFBMouseHandlerPrivate::QDirectFBMouseHandlerPrivate ( QDirectFBMouseHandler h)

Definition at line 82 of file qdirectfbmouse.cpp.

83  : handler(h), eventBuffer(0)
84 {
85  DFBResult result;
86 
87  QScreen *screen = QScreen::instance();
88  if (!screen) {
89  qCritical("QDirectFBMouseHandler: no screen instance found");
90  return;
91  }
92 
93  IDirectFB *fb = QDirectFBScreen::instance()->dfb();
94  if (!fb) {
95  qCritical("QDirectFBMouseHandler: DirectFB not initialized");
96  return;
97  }
98 
99 #ifndef QT_NO_DIRECTFB_LAYER
101  if (!layer) {
102  qCritical("QDirectFBMouseHandler: Unable to get primary display layer");
103  return;
104  }
105 #endif
106 
107  DFBInputDeviceCapabilities caps;
108  caps = DICAPS_BUTTONS | DICAPS_AXES;
109  result = fb->CreateInputEventBuffer(fb, caps, DFB_TRUE, &eventBuffer);
110  if (result != DFB_OK) {
111  DirectFBError("QDirectFBMouseHandler: "
112  "Unable to create input event buffer", result);
113  return;
114  }
115 
116  int fd;
117  result = eventBuffer->CreateFileDescriptor(eventBuffer, &fd);
118  if (result != DFB_OK) {
119  DirectFBError("QDirectFBMouseHandler: "
120  "Unable to create file descriptor", result);
121  return;
122  }
123 
124  int flags = fcntl(fd, F_GETFL, 0);
125  fcntl(fd, F_SETFL, flags | O_NONBLOCK);
126 
127  // DirectFB seems to assume that the mouse always starts centered
128  prevPoint = QPoint(screen->deviceWidth() / 2, screen->deviceHeight() / 2);
130  memset(&event, 0, sizeof(event));
131  bytesRead = 0;
132 
134  connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
135  setEnabled(true);
136 }
IDirectFBDisplayLayer * layer
QDirectFBMouseHandler * handler
#define SLOT(a)
Definition: qobjectdefs.h:226
IDirectFBDisplayLayer * dfbDisplayLayer()
int deviceWidth() const
Returns the physical width of the framebuffer device in pixels.
Definition: qscreen_qws.h:233
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
IDirectFBEventBuffer * eventBuffer
#define SIGNAL(a)
Definition: qobjectdefs.h:227
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
IDirectFB * dfb()
static QScreen * instance()
Returns a pointer to the application&#39;s QScreen instance.
Definition: qscreen_qws.h:201
int fcntl(int, int,...)
int deviceHeight() const
Returns the full height of the framebuffer device in pixels.
Definition: qscreen_qws.h:234
QSocketNotifier * mouseNotifier
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
static QDirectFBScreen * instance()
Q_CORE_EXPORT void qCritical(const char *,...)

◆ ~QDirectFBMouseHandlerPrivate()

QDirectFBMouseHandlerPrivate::~QDirectFBMouseHandlerPrivate ( )

Definition at line 138 of file qdirectfbmouse.cpp.

139 {
140  if (eventBuffer)
141  eventBuffer->Release(eventBuffer);
142 }
IDirectFBEventBuffer * eventBuffer

Functions

◆ readMouseData

void QDirectFBMouseHandlerPrivate::readMouseData ( )
privateslot

Definition at line 172 of file qdirectfbmouse.cpp.

Referenced by QDirectFBMouseHandlerPrivate().

173 {
174  if (!QScreen::instance())
175  return;
176 
177  for (;;) {
178  // GetEvent returns DFB_UNSUPPORTED after CreateFileDescriptor().
179  // This seems stupid and I really hope it's a bug which will be fixed.
180 
181  // DFBResult ret = eventBuffer->GetEvent(eventBuffer, &event);
182 
183  char *buf = reinterpret_cast<char*>(&event);
184  int ret = ::read(mouseNotifier->socket(),
185  buf + bytesRead, sizeof(DFBEvent) - bytesRead);
186  if (ret == -1) {
187  if (errno == EINTR)
188  continue;
189  if (errno == EAGAIN)
190  return;
191  qWarning("QDirectFBMouseHandlerPrivate::readMouseData(): %s",
192  strerror(errno));
193  return;
194  }
195 
196  Q_ASSERT(ret >= 0);
197  bytesRead += ret;
198  if (bytesRead < sizeof(DFBEvent))
199  break;
200  bytesRead = 0;
201 
202  Q_ASSERT(event.clazz == DFEC_INPUT);
203 
204  const DFBInputEvent input = event.input;
205  int x = prevPoint.x();
206  int y = prevPoint.y();
207  int wheel = 0;
208 
209  if (input.type == DIET_AXISMOTION) {
210 #if defined(QT_NO_DIRECTFB_LAYER) || defined(QT_DIRECTFB_WINDOW_AS_CURSOR)
211  if (input.flags & DIEF_AXISABS) {
212  switch (input.axis) {
213  case DIAI_X: x = input.axisabs; break;
214  case DIAI_Y: y = input.axisabs; break;
215  default:
216  qWarning("QDirectFBMouseHandlerPrivate::readMouseData: "
217  "unknown axis (absolute) %d", input.axis);
218  break;
219  }
220  } else if (input.flags & DIEF_AXISREL) {
221  switch (input.axis) {
222  case DIAI_X: x += input.axisrel; break;
223  case DIAI_Y: y += input.axisrel; break;
224  case DIAI_Z: wheel = -120 * input.axisrel; break;
225  default:
226  qWarning("QDirectFBMouseHandlerPrivate::readMouseData: "
227  "unknown axis (releative) %d", input.axis);
228  }
229  }
230 #else
231  if (input.axis == DIAI_X || input.axis == DIAI_Y) {
232  DFBResult result = layer->GetCursorPosition(layer, &x, &y);
233  if (result != DFB_OK) {
234  DirectFBError("QDirectFBMouseHandler::readMouseData",
235  result);
236  }
237  } else if (input.axis == DIAI_Z) {
238  Q_ASSERT(input.flags & DIEF_AXISREL);
239  wheel = input.axisrel;
240  wheel *= -120;
241  }
242 #endif
243  }
244 
245  Qt::MouseButtons buttons = Qt::NoButton;
246  if (input.flags & DIEF_BUTTONS) {
247  if (input.buttons & DIBM_LEFT)
248  buttons |= Qt::LeftButton;
249  if (input.buttons & DIBM_MIDDLE)
250  buttons |= Qt::MidButton;
251  if (input.buttons & DIBM_RIGHT)
252  buttons |= Qt::RightButton;
253  }
254 
255  QPoint p = QPoint(x, y);
257 
258  if (p == prevPoint && wheel == 0 && buttons == prevbuttons)
259  continue;
260 
261  prevPoint = p;
263 
264  handler->mouseChanged(p, buttons, wheel);
265  }
266 }
IDirectFBDisplayLayer * layer
QDirectFBMouseHandler * handler
static Qt::MouseButtons buttons
void mouseChanged(const QPoint &pos, int bstate, int wheel=0)
Notifies the system of a new mouse event.
Definition: qmouse_qws.cpp:285
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT void qWarning(const char *,...)
static QScreen * instance()
Returns a pointer to the application&#39;s QScreen instance.
Definition: qscreen_qws.h:201
QSocketNotifier * mouseNotifier
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
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
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
int errno
int socket() const
Returns the socket identifier specified to the constructor.

◆ setEnabled()

void QDirectFBMouseHandlerPrivate::setEnabled ( bool  on)

Definition at line 144 of file qdirectfbmouse.cpp.

Referenced by QDirectFBMouseHandlerPrivate(), QDirectFBMouseHandler::resume(), and QDirectFBMouseHandler::suspend().

145 {
146  if (mouseNotifier->isEnabled() != on) {
147 #ifndef QT_NO_DIRECTFB_LAYER
148  DFBResult result;
149  result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
150  if (result != DFB_OK) {
151  DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: "
152  "Unable to set cooperative level", result);
153  }
154  result = layer->EnableCursor(layer, on ? 1 : 0);
155  if (result != DFB_OK) {
156  DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: "
157  "Unable to enable cursor", result);
158  }
159 
160  result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
161  if (result != DFB_OK) {
162  DirectFBError("QDirectFBScreenCursor::show: "
163  "Unable to set cooperative level", result);
164  }
165 
166  layer->SetCooperativeLevel(layer, DLSCL_SHARED);
167 #endif
169  }
170 }
IDirectFBDisplayLayer * layer
QSocketNotifier * mouseNotifier
bool isEnabled() const
Returns true if the notifier is enabled; otherwise returns false.
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.

Properties

◆ bytesRead

uint QDirectFBMouseHandlerPrivate::bytesRead
private

Definition at line 76 of file qdirectfbmouse.cpp.

Referenced by QDirectFBMouseHandlerPrivate(), and readMouseData().

◆ event

DFBEvent QDirectFBMouseHandlerPrivate::event
private

Definition at line 75 of file qdirectfbmouse.cpp.

Referenced by QDirectFBMouseHandlerPrivate(), and readMouseData().

◆ eventBuffer

IDirectFBEventBuffer* QDirectFBMouseHandlerPrivate::eventBuffer
private

◆ handler

QDirectFBMouseHandler* QDirectFBMouseHandlerPrivate::handler
private

Definition at line 65 of file qdirectfbmouse.cpp.

Referenced by readMouseData().

◆ layer

IDirectFBDisplayLayer* QDirectFBMouseHandlerPrivate::layer
private

Definition at line 68 of file qdirectfbmouse.cpp.

Referenced by QDirectFBMouseHandlerPrivate(), readMouseData(), and setEnabled().

◆ mouseNotifier

QSocketNotifier* QDirectFBMouseHandlerPrivate::mouseNotifier
private

Definition at line 70 of file qdirectfbmouse.cpp.

Referenced by QDirectFBMouseHandlerPrivate(), readMouseData(), and setEnabled().

◆ prevbuttons

Qt::MouseButtons QDirectFBMouseHandlerPrivate::prevbuttons
private

Definition at line 73 of file qdirectfbmouse.cpp.

Referenced by QDirectFBMouseHandlerPrivate(), and readMouseData().

◆ prevPoint

QPoint QDirectFBMouseHandlerPrivate::prevPoint
private

Definition at line 72 of file qdirectfbmouse.cpp.

Referenced by QDirectFBMouseHandlerPrivate(), and readMouseData().


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