Qt 4.8
Signals | Public Functions | Static Public Functions | Private Types | Private Functions | Properties | List of all members
QBBScreenEventHandler Class Reference

#include <qbbscreeneventhandler.h>

Inheritance diagram for QBBScreenEventHandler:
QObject

Signals

void newWindowCreated (screen_window_t window)
 
void windowClosed (screen_window_t window)
 
- 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...
 

Public Functions

bool handleEvent (screen_event_t event)
 
bool handleEvent (screen_event_t event, int qnxType)
 
void injectPointerMoveEvent (int x, int y)
 
 QBBScreenEventHandler (QBBIntegration *integration)
 
- 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...
 

Static Public Functions

static void injectKeyboardEvent (int flags, int sym, int mod, int scan, int cap)
 
- 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)
 

Private Types

enum  { MAX_TOUCH_POINTS = 10 }
 

Private Functions

void handleCloseEvent (screen_event_t event)
 
void handleCreateEvent (screen_event_t event)
 
void handleDisplayEvent (screen_event_t event)
 
void handleKeyboardEvent (screen_event_t event)
 
void handlePointerEvent (screen_event_t event)
 
void handleTouchEvent (screen_event_t event, int type)
 

Properties

QBBIntegrationmBBIntegration
 
Qt::MouseButtons mLastButtonState
 
QPoint mLastGlobalMousePoint
 
QPoint mLastLocalMousePoint
 
void * mLastMouseWindow
 
QWindowSystemInterface::TouchPoint mTouchPoints [MAX_TOUCH_POINTS]
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- 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 53 of file qbbscreeneventhandler.h.

Enumerations

◆ anonymous enum

anonymous enum
private
Enumerator
MAX_TOUCH_POINTS 

Definition at line 78 of file qbbscreeneventhandler.h.

Constructors and Destructors

◆ QBBScreenEventHandler()

QBBScreenEventHandler::QBBScreenEventHandler ( QBBIntegration integration)
explicit

Definition at line 59 of file qbbscreeneventhandler.cpp.

60  : mBBIntegration(integration)
62  , mLastMouseWindow(0)
63 {
64  // initialize array of touch points
65  for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
66 
67  // map array index to id
68  mTouchPoints[i].id = i;
69 
70  // first finger is primary
71  mTouchPoints[i].isPrimary = (i == 0);
72 
73  // pressure is not supported - use default
74  mTouchPoints[i].pressure = 1.0;
75 
76  // nothing touching
78  }
79 }
Qt::MouseButtons mLastButtonState
QBBIntegration * mBBIntegration
QWindowSystemInterface::TouchPoint mTouchPoints[MAX_TOUCH_POINTS]

Functions

◆ handleCloseEvent()

void QBBScreenEventHandler::handleCloseEvent ( screen_event_t  event)
private

Definition at line 529 of file qbbscreeneventhandler.cpp.

Referenced by handleEvent().

530 {
531  screen_window_t window = 0;
532  if (screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0)
533  qFatal("QBB: failed to query event window property, errno=%d", errno);
534 
535  emit windowClosed(window);
536 
537  // map window to top-level widget
538  QWidget* w = QWidget::find( (WId)window );
539  if (w != NULL)
541 }
unsigned long WId
Definition: qwindowdefs.h:119
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
NSWindow * window
#define emit
Definition: qobjectdefs.h:76
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
static void handleCloseEvent(QWidget *w)
Q_CORE_EXPORT void qFatal(const char *,...)
void windowClosed(screen_window_t window)
int errno

◆ handleCreateEvent()

void QBBScreenEventHandler::handleCreateEvent ( screen_event_t  event)
private

Definition at line 543 of file qbbscreeneventhandler.cpp.

Referenced by handleEvent().

544 {
545  screen_window_t window = 0;
546  if (screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0)
547  qFatal("QBB: failed to query event window property, errno=%d", errno);
548 
549  emit newWindowCreated(window);
550 }
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
NSWindow * window
#define emit
Definition: qobjectdefs.h:76
void newWindowCreated(screen_window_t window)
Q_CORE_EXPORT void qFatal(const char *,...)
int errno

◆ handleDisplayEvent()

void QBBScreenEventHandler::handleDisplayEvent ( screen_event_t  event)
private

Definition at line 552 of file qbbscreeneventhandler.cpp.

Referenced by handleEvent().

553 {
554  screen_display_t nativeDisplay = 0;
555  if (screen_get_event_property_pv(event, SCREEN_PROPERTY_DISPLAY, (void **)&nativeDisplay) != 0) {
556  qWarning("QBB: failed to query display property, errno=%d", errno);
557  return;
558  }
559 
560  int isAttached = 0;
561  if (screen_get_event_property_iv(event, SCREEN_PROPERTY_ATTACHED, &isAttached) != 0) {
562  qWarning("QBB: failed to query display attached property, errno=%d", errno);
563  return;
564  }
565 
566 #if defined(QBBSCREENEVENTHANDLER_DEBUG)
567  qDebug() << Q_FUNC_INFO << "display attachment is now:" << isAttached;
568 #endif
569  QBBScreen *screen = mBBIntegration->screenForNative(nativeDisplay);
570  if (!screen) {
571  if (isAttached)
572  mBBIntegration->createDisplay(nativeDisplay, false /* not primary, we assume */);
573  } else if (!isAttached) {
574  // libscreen display is deactivated, let's remove the QBBScreen / QScreen
575  mBBIntegration->removeDisplay(screen);
576  }
577 }
void createDisplay(screen_display_t display, int screenIndex)
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
Q_CORE_EXPORT void qDebug(const char *,...)
QBBIntegration * mBBIntegration
Q_CORE_EXPORT void qWarning(const char *,...)
QBBScreen * screenForNative(screen_display_t screen) const
Q_GUI_EXPORT EGLNativeDisplayType nativeDisplay()
Definition: qegl_qpa.cpp:55
void removeDisplay(QBBScreen *screen)
int errno
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ handleEvent() [1/2]

bool QBBScreenEventHandler::handleEvent ( screen_event_t  event)

Definition at line 81 of file qbbscreeneventhandler.cpp.

Referenced by QBBBpsEventFilter::bpsEventFilter(), and QBBScreenEventThread::run().

82 {
83  // get the event type
84  errno = 0;
85  int qnxType;
86  int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &qnxType);
87  if (result)
88  qFatal("QBB: failed to query event type, errno=%d", errno);
89 
90  return handleEvent(event, qnxType);
91 }
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
bool handleEvent(screen_event_t event)
Q_CORE_EXPORT void qFatal(const char *,...)
int errno

◆ handleEvent() [2/2]

bool QBBScreenEventHandler::handleEvent ( screen_event_t  event,
int  qnxType 
)

Definition at line 94 of file qbbscreeneventhandler.cpp.

95 {
96  switch (qnxType) {
97  case SCREEN_EVENT_MTOUCH_TOUCH:
98  case SCREEN_EVENT_MTOUCH_MOVE:
99  case SCREEN_EVENT_MTOUCH_RELEASE:
100  handleTouchEvent(event, qnxType);
101  break;
102 
103  case SCREEN_EVENT_KEYBOARD:
105  break;
106 
107  case SCREEN_EVENT_POINTER:
109  break;
110 
111  case SCREEN_EVENT_CLOSE:
113  break;
114 
115  case SCREEN_EVENT_CREATE:
117  break;
118 
119  case SCREEN_EVENT_DISPLAY:
121  break;
122 
123  default:
124  // event ignored
125 #if defined(QBBSCREENEVENTHANDLER_DEBUG)
126  qDebug() << "QBB: QNX unknown event";
127 #endif
128  return false;
129  }
130 
131  return true;
132 }
void handleCreateEvent(screen_event_t event)
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
void handleKeyboardEvent(screen_event_t event)
Q_CORE_EXPORT void qDebug(const char *,...)
void handleDisplayEvent(screen_event_t event)
void handleTouchEvent(screen_event_t event, int type)
void handlePointerEvent(screen_event_t event)
void handleCloseEvent(screen_event_t event)

◆ handleKeyboardEvent()

void QBBScreenEventHandler::handleKeyboardEvent ( screen_event_t  event)
private

Definition at line 134 of file qbbscreeneventhandler.cpp.

Referenced by handleEvent().

135 {
136  // get flags of key event
137  errno = 0;
138  int flags;
139  int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags);
140  if (result) {
141  qFatal("QBB: failed to query event flags, errno=%d", errno);
142  }
143 
144  // get key code
145  errno = 0;
146  int sym;
147  result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SYM, &sym);
148  if (result) {
149  qFatal("QBB: failed to query event sym, errno=%d", errno);
150  }
151 
152  int modifiers;
153  result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &modifiers);
154  if (result) {
155  qFatal("QBB: failed to query event modifiers, errno=%d", errno);
156  }
157 
158  int scan;
159  result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SCAN, &scan);
160  if (result) {
161  qFatal("QBB: failed to query event modifiers, errno=%d", errno);
162  }
163 
164  int cap;
165  result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap);
166  if (result) {
167  qFatal("QBB: failed to query event cap, errno=%d", errno);
168  }
169 
170  // Let the input context have a stab at it first.
171  QWidget *focusWidget = QApplication::focusWidget();
172  if (focusWidget) {
173  QInputContext* inputContext = focusWidget->inputContext();
174  if (inputContext) {
175  QBBInputContext *qbbInputContext = dynamic_cast<QBBInputContext *>(inputContext);
176 
177  if (qbbInputContext && qbbInputContext->handleKeyboardEvent(flags, sym, modifiers, scan, cap))
178  return;
179  }
180  }
181 
182  injectKeyboardEvent(flags, sym, modifiers, scan, cap);
183 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
bool handleKeyboardEvent(int flags, int sym, int mod, int scan, int cap)
static void injectKeyboardEvent(int flags, int sym, int mod, int scan, int cap)
QInputContext * inputContext()
This function returns the QInputContext for this widget.
Definition: qwidget.cpp:474
Q_CORE_EXPORT void qFatal(const char *,...)
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
int errno

◆ handlePointerEvent()

void QBBScreenEventHandler::handlePointerEvent ( screen_event_t  event)
private

Definition at line 289 of file qbbscreeneventhandler.cpp.

Referenced by handleEvent().

290 {
291  errno = 0;
292 
293  // Query the window that was clicked
294  void *qnxWindow;
295  int result = screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &qnxWindow);
296  if (result) {
297  qFatal("QBB: failed to query event window, errno=%d", errno);
298  }
299 
300  // Query the button states
301  int buttonState = 0;
302  result = screen_get_event_property_iv(event, SCREEN_PROPERTY_BUTTONS, &buttonState);
303  if (result) {
304  qFatal("QBB: failed to query event button state, errno=%d", errno);
305  }
306 
307  // Query the window position
308  int windowPos[2];
309  result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos);
310  if (result) {
311  qFatal("QBB: failed to query event window position, errno=%d", errno);
312  }
313 
314  // Query the screen position
315  int pos[2];
316  result = screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos);
317  if (result) {
318  qFatal("QBB: failed to query event position, errno=%d", errno);
319  }
320 
321  // Query the wheel delta
322  int wheelDelta = 0;
323  result = screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheelDelta);
324  if (result) {
325  qFatal("QBB: failed to query event wheel delta, errno=%d", errno);
326  }
327 
328  // map window to top-level widget
329  QWidget* w = QWidget::find( (WId)qnxWindow );
330 
331  // Generate enter and leave events as needed.
332  if (qnxWindow != mLastMouseWindow) {
334 
335  if (wOld) {
337 #if defined(QBBSCREENEVENTHANDLER_DEBUG)
338  qDebug() << "QBB: Qt leave, w=" << wOld;
339 #endif
340  }
341 
342  if (w) {
344 #if defined(QBBSCREENEVENTHANDLER_DEBUG)
345  qDebug() << "QBB: Qt enter, w=" << w;
346 #endif
347  }
348  }
349  mLastMouseWindow = qnxWindow;
350 
351  // Apply scaling to wheel delta and invert value for Qt. We'll probably want to scale
352  // this via a system preference at some point. But for now this is a sane value and makes
353  // the wheel usable.
354  wheelDelta *= -10;
355 
356  // convert point to local coordinates
357  QPoint globalPoint(pos[0], pos[1]);
358  QPoint localPoint(windowPos[0], windowPos[1]);
359 
360  // Convert buttons.
361  // Some QNX header files invert 'Right Button versus "Left Button' ('Right' == 0x01). But they also offer a 'Button Swap' bit,
362  // so we may receive events as shown. (If this is wrong, the fix is easy.)
363  // QNX Button mask is 8 buttons wide, with a maximum value of 0x80.
364  Qt::MouseButtons buttons = Qt::NoButton;
365  if (buttonState & 0x01)
366  buttons |= Qt::LeftButton;
367  if (buttonState & 0x02)
368  buttons |= Qt::MidButton;
369  if (buttonState & 0x04)
370  buttons |= Qt::RightButton;
371  if (buttonState & 0x08)
372  buttons |= Qt::XButton1;
373  if (buttonState & 0x10)
374  buttons |= Qt::XButton2;
375 
376  if (w) {
377  // Inject mouse event into Qt only if something has changed.
378  if (mLastGlobalMousePoint != globalPoint ||
379  mLastLocalMousePoint != localPoint ||
380  mLastButtonState != buttons) {
381  QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons);
382 #if defined(QBBSCREENEVENTHANDLER_DEBUG)
383  qDebug() << "QBB: Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << (int)buttons;
384 #endif
385  }
386 
387  if (wheelDelta) {
388  // Screen only supports a single wheel, so we will assume Vertical orientation for
389  // now since that is pretty much standard.
390  QWindowSystemInterface::handleWheelEvent(w, localPoint, globalPoint, wheelDelta, Qt::Vertical);
391 #if defined(QBBSCREENEVENTHANDLER_DEBUG)
392  qDebug() << "QBB: Qt wheel, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), d=" << (int)wheelDelta;
393 #endif
394  }
395  }
396 
397  mLastGlobalMousePoint = globalPoint;
398  mLastLocalMousePoint = localPoint;
400 }
Qt::MouseButtons mLastButtonState
unsigned long WId
Definition: qwindowdefs.h:119
static void handleWheelEvent(QWidget *w, const QPoint &local, const QPoint &global, int d, Qt::Orientation o)
static Qt::MouseButtons buttons
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
int x
the x coordinate of the widget relative to its parent including any window frame
Definition: qwidget.h:161
Q_CORE_EXPORT void qDebug(const char *,...)
static void handleMouseEvent(QWidget *w, const QPoint &local, const QPoint &global, Qt::MouseButtons b)
tlw == 0 means that ev is in global coords only
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
Q_CORE_EXPORT void qFatal(const char *,...)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static void handleEnterEvent(QWidget *w)
static void handleLeaveEvent(QWidget *w)
int errno

◆ handleTouchEvent()

void QBBScreenEventHandler::handleTouchEvent ( screen_event_t  event,
int  type 
)
private

Definition at line 402 of file qbbscreeneventhandler.cpp.

Referenced by handleEvent().

403 {
404  // get display coordinates of touch
405  errno = 0;
406  int pos[2];
407  int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos);
408  if (result) {
409  qFatal("QBB: failed to query event position, errno=%d", errno);
410  }
411 
412  QCursor::setPos(pos[0], pos[1]);
413 
414  // get window coordinates of touch
415  errno = 0;
416  int windowPos[2];
417  result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos);
418  if (result) {
419  qFatal("QBB: failed to query event window position, errno=%d", errno);
420  }
421 
422  // determine which finger touched
423  errno = 0;
424  int touchId;
425  result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_ID, &touchId);
426  if (result) {
427  qFatal("QBB: failed to query event touch id, errno=%d", errno);
428  }
429 
430  // determine which window was touched
431  errno = 0;
432  void *qnxWindow;
433  result = screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &qnxWindow);
434  if (result) {
435  qFatal("QBB: failed to query event window, errno=%d", errno);
436  }
437 
438  // check if finger is valid
439  if (touchId < MAX_TOUCH_POINTS) {
440 
441  // map window to top-level widget
442  QWidget* w = QWidget::find( (WId)qnxWindow );
443 
444  // Generate enter and leave events as needed.
445  if (qnxWindow != mLastMouseWindow) {
447 
448  if (wOld) {
450  #if defined(QBBSCREENEVENTHANDLER_DEBUG)
451  qDebug() << "QBB: Qt leave, w=" << wOld;
452  #endif
453  }
454 
455  if (w) {
457  #if defined(QBBSCREENEVENTHANDLER_DEBUG)
458  qDebug() << "QBB: Qt enter, w=" << w;
459  #endif
460  }
461  }
462  mLastMouseWindow = qnxWindow;
463 
464  if (w) {
465  // convert primary touch to mouse event
466  if (touchId == 0) {
467 
468  // convert point to local coordinates
469  QPoint globalPoint(pos[0], pos[1]);
470  QPoint localPoint(windowPos[0], windowPos[1]);
471 
472  // map touch state to button state
473  Qt::MouseButtons buttons = (qnxType == SCREEN_EVENT_MTOUCH_RELEASE) ? Qt::NoButton : Qt::LeftButton;
474 
475  // inject event into Qt
476  QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons);
477 #if defined(QBBSCREENEVENTHANDLER_DEBUG)
478  qDebug() << "QBB: Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << buttons;
479 #endif
480  }
481 
482  // get size of screen which contains window
484  QSize screenSize = platformScreen->physicalSize();
485 
486  // update cached position of current touch point
487  mTouchPoints[touchId].normalPosition = QPointF( ((qreal)pos[0]) / screenSize.width(), ((qreal)pos[1]) / screenSize.height() );
488  mTouchPoints[touchId].area = QRectF( pos[0], pos[1], 0.0, 0.0 );
489 
490  // determine event type and update state of current touch point
492  switch (qnxType) {
493  case SCREEN_EVENT_MTOUCH_TOUCH:
495  type = QEvent::TouchBegin;
496  break;
497  case SCREEN_EVENT_MTOUCH_MOVE:
499  type = QEvent::TouchUpdate;
500  break;
501  case SCREEN_EVENT_MTOUCH_RELEASE:
503  type = QEvent::TouchEnd;
504  break;
505  }
506 
507  // build list of active touch points
509  for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
510  if (i == touchId) {
511  // current touch point is always active
512  pointList.append(mTouchPoints[i]);
513  } else if (mTouchPoints[i].state != Qt::TouchPointReleased) {
514  // finger is down but did not move
516  pointList.append(mTouchPoints[i]);
517  }
518  }
519 
520  // inject event into Qt
522 #if defined(QBBSCREENEVENTHANDLER_DEBUG)
523  qDebug() << "QBB: Qt touch, w=" << w << ", p=(" << pos[0] << "," << pos[1] << "), t=" << type;
524 #endif
525  }
526  }
527 }
unsigned long WId
Definition: qwindowdefs.h:119
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
The QPlatformScreen class provides an abstraction for visual displays.
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
static Qt::MouseButtons buttons
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static void setPos(int x, int y)
Moves the cursor (hot spot) to the global screen position (x, y).
Definition: qcursor_mac.mm:315
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
int x
the x coordinate of the widget relative to its parent including any window frame
Definition: qwidget.h:161
static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList< struct TouchPoint > &points)
Q_CORE_EXPORT void qDebug(const char *,...)
int width() const
Returns the width.
Definition: qsize.h:126
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
static void handleMouseEvent(QWidget *w, const QPoint &local, const QPoint &global, Qt::MouseButtons b)
tlw == 0 means that ev is in global coords only
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
static QPlatformScreen * platformScreenForWidget(const QWidget *widget)
virtual QSize physicalSize() const
Reimplement this function in subclass to return the physical size of the screen.
Q_CORE_EXPORT void qFatal(const char *,...)
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int height() const
Returns the height.
Definition: qsize.h:129
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QWindowSystemInterface::TouchPoint mTouchPoints[MAX_TOUCH_POINTS]
static void handleEnterEvent(QWidget *w)
static void handleLeaveEvent(QWidget *w)
int errno
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ injectKeyboardEvent()

void QBBScreenEventHandler::injectKeyboardEvent ( int  flags,
int  sym,
int  mod,
int  scan,
int  cap 
)
static

Definition at line 185 of file qbbscreeneventhandler.cpp.

Referenced by handleKeyboardEvent(), and QBBScreenEventThread::injectKeyboardEvent().

186 {
187  Q_UNUSED(scan);
188 
189  Qt::KeyboardModifiers qtMod = Qt::NoModifier;
190  if (modifiers & KEYMOD_SHIFT)
191  qtMod |= Qt::ShiftModifier;
192  if (modifiers & KEYMOD_CTRL)
193  qtMod |= Qt::ControlModifier;
194  if (modifiers & KEYMOD_ALT)
195  qtMod |= Qt::AltModifier;
196 
197  // determine event type
198  QEvent::Type type = (flags & KEY_DOWN) ? QEvent::KeyPress : QEvent::KeyRelease;
199 
200  // Check if the key cap is valid
201  if (flags & KEY_CAP_VALID) {
202  Qt::Key key;
203  QString keyStr;
204 
205  if (cap >= 0x20 && cap <= 0x0ff) {
206  key = Qt::Key(std::toupper(cap)); // Qt expects the CAP to be upper case.
207 
208  if ( qtMod & Qt::ControlModifier ) {
209  keyStr = QChar((int)(key & 0x3f));
210  } else {
211  if (flags & KEY_SYM_VALID) {
212  keyStr = QChar(sym);
213  }
214  }
215  } else if ((cap > 0x0ff && cap < UNICODE_PRIVATE_USE_AREA_FIRST) || cap > UNICODE_PRIVATE_USE_AREA_LAST) {
216  key = (Qt::Key)cap;
217  keyStr = QChar(sym);
218  } else {
219  if (isKeypadKey(cap))
220  qtMod |= Qt::KeypadModifier; // Is this right?
221  key = keyTranslator(cap);
222  }
223 
225  scan, sym, modifiers, keyStr);
226 #if defined(QBBScreenEventHandler_DEBUG)
227  qDebug() << "QBB: Qt key t=" << type << ", k=" << key << ", s=" << keyStr;
228 #endif
229  }
230 }
int type
Definition: qmetatype.cpp:239
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or 0 if no application wi...
bool isKeypadKey(int key)
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Q_CORE_EXPORT void qDebug(const char *,...)
static void handleExtendedKeyEvent(QWidget *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text=QString(), bool autorep=false, ushort count=1)
Qt::Key keyTranslator(int key)
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
int key
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ injectPointerMoveEvent()

void QBBScreenEventHandler::injectPointerMoveEvent ( int  x,
int  y 
)

Definition at line 232 of file qbbscreeneventhandler.cpp.

Referenced by QBBScreenEventThread::injectPointerMoveEvent().

233 {
234 #if defined(QBBScreenEventHandler_DEBUG)
235  qDebug() << "Injecting mouse event..." << x << y;
236 #endif
237 
238  QWidget *w = qApp->topLevelAt(x, y);
239  void *qnxWindow = w ? w->platformWindow() : 0;
240 
241  // Generate enter and leave events as needed.
242  if (qnxWindow != mLastMouseWindow) {
244 
245  if (wOld) {
247 #if defined(QBBScreenEventHandler_DEBUG)
248  qDebug() << "QBB: Qt leave, w=" << wOld;
249 #endif
250  }
251 
252  if (w) {
254 #if defined(QBBScreenEventHandler_DEBUG)
255  qDebug() << "QBB: Qt enter, w=" << w;
256 #endif
257  }
258  }
259 
260  mLastMouseWindow = qnxWindow;
261 
262  // convert point to local coordinates
263  QPoint globalPoint(x, y);
264  QPoint localPoint(x, y);
265 
266  if (w)
267  localPoint = QPoint(x - w->x(), y - w->y());
268 
269  // Convert buttons.
270  Qt::MouseButtons buttons = mLastButtonState;
271 
272  if (w) {
273  // Inject mouse event into Qt only if something has changed.
274  if (mLastGlobalMousePoint != globalPoint ||
275  mLastLocalMousePoint != localPoint ||
276  mLastButtonState != buttons) {
277  QWindowSystemInterface::handleMouseEvent(w, localPoint, globalPoint, buttons);
278 #if defined(QBBScreenEventHandler_DEBUG)
279  qDebug() << "QBB: Qt mouse, w=" << w << ", (" << localPoint.x() << "," << localPoint.y() << "), b=" << (int)buttons;
280 #endif
281  }
282  }
283 
284  mLastGlobalMousePoint = globalPoint;
285  mLastLocalMousePoint = localPoint;
287 }
Qt::MouseButtons mLastButtonState
unsigned long WId
Definition: qwindowdefs.h:119
static Qt::MouseButtons buttons
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int x
the x coordinate of the widget relative to its parent including any window frame
Definition: qwidget.h:161
Q_CORE_EXPORT void qDebug(const char *,...)
#define qApp
static void handleMouseEvent(QWidget *w, const QPoint &local, const QPoint &global, Qt::MouseButtons b)
tlw == 0 means that ev is in global coords only
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
int y
the y coordinate of the widget relative to its parent and including any window frame ...
Definition: qwidget.h:162
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static void handleEnterEvent(QWidget *w)
static void handleLeaveEvent(QWidget *w)

◆ newWindowCreated

void QBBScreenEventHandler::newWindowCreated ( screen_window_t  window)
signal

Referenced by handleCreateEvent().

◆ windowClosed

void QBBScreenEventHandler::windowClosed ( screen_window_t  window)
signal

Referenced by handleCloseEvent().

Properties

◆ mBBIntegration

QBBIntegration* QBBScreenEventHandler::mBBIntegration
private

Definition at line 82 of file qbbscreeneventhandler.h.

Referenced by handleDisplayEvent().

◆ mLastButtonState

Qt::MouseButtons QBBScreenEventHandler::mLastButtonState
private

Definition at line 85 of file qbbscreeneventhandler.h.

Referenced by handlePointerEvent(), and injectPointerMoveEvent().

◆ mLastGlobalMousePoint

QPoint QBBScreenEventHandler::mLastGlobalMousePoint
private

Definition at line 83 of file qbbscreeneventhandler.h.

Referenced by handlePointerEvent(), and injectPointerMoveEvent().

◆ mLastLocalMousePoint

QPoint QBBScreenEventHandler::mLastLocalMousePoint
private

Definition at line 84 of file qbbscreeneventhandler.h.

Referenced by handlePointerEvent(), and injectPointerMoveEvent().

◆ mLastMouseWindow

void* QBBScreenEventHandler::mLastMouseWindow
private

◆ mTouchPoints

QWindowSystemInterface::TouchPoint QBBScreenEventHandler::mTouchPoints[MAX_TOUCH_POINTS]
private

Definition at line 88 of file qbbscreeneventhandler.h.

Referenced by handleTouchEvent(), and QBBScreenEventHandler().


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