15#include <QGuiApplication>
18#include <sys/keycodes.h>
20#if defined(QQNXSCREENEVENT_DEBUG)
21#define qScreenEventDebug qDebug
23#define qScreenEventDebug QT_NO_QDEBUG_MACRO
49 if (
cap >= 0x20 &&
cap <= 0x0ff) {
60 screen_get_event_property_pv(
event,
62 reinterpret_cast<void**
>(&
t));
69 int objectType = SCREEN_OBJECT_TYPE_CONTEXT;
70 screen_get_event_property_iv(
event, SCREEN_PROPERTY_OBJECT_TYPE, &objectType);
72 case SCREEN_OBJECT_TYPE_CONTEXT:
73 finishCloseEvent<screen_context_t>(
event);
75 case SCREEN_OBJECT_TYPE_DEVICE:
76 finishCloseEvent<screen_device_t>(
event);
78 case SCREEN_OBJECT_TYPE_DISPLAY:
81 case SCREEN_OBJECT_TYPE_GROUP:
82 finishCloseEvent<screen_group_t>(
event);
84 case SCREEN_OBJECT_TYPE_PIXMAP:
85 finishCloseEvent<screen_pixmap_t>(
event);
87 case SCREEN_OBJECT_TYPE_SESSION:
88 finishCloseEvent<screen_session_t>(
event);
90#if _SCREEN_VERSION >= _SCREEN_MAKE_VERSION(2, 0, 0)
91 case SCREEN_OBJECT_TYPE_STREAM:
92 finishCloseEvent<screen_stream_t>(
event);
95 case SCREEN_OBJECT_TYPE_WINDOW:
96 finishCloseEvent<screen_window_t>(
event);
106 : m_qnxIntegration(integration)
107 , m_lastButtonState(
Qt::NoButton)
108 , m_lastMouseWindow(0)
112 , m_focusLostTimer(-1)
121 MaximumTouchPoints, 8);
130 for (
int i = 0;
i < MaximumTouchPoints;
i++) {
133 m_touchPoints[
i].
id =
i;
158 "Failed to query event type");
166 case SCREEN_EVENT_MTOUCH_TOUCH:
167 case SCREEN_EVENT_MTOUCH_MOVE:
168 case SCREEN_EVENT_MTOUCH_RELEASE:
169 handleTouchEvent(
event, qnxType);
172 case SCREEN_EVENT_KEYBOARD:
173 handleKeyboardEvent(
event);
176 case SCREEN_EVENT_POINTER:
177 handlePointerEvent(
event);
180 case SCREEN_EVENT_CREATE:
181 handleCreateEvent(
event);
184 case SCREEN_EVENT_CLOSE:
185 handleCloseEvent(
event);
188 case SCREEN_EVENT_DISPLAY:
189 handleDisplayEvent(
event);
192 case SCREEN_EVENT_PROPERTY:
193 handlePropertyEvent(
event);
209 if (!(
flags & KEY_CAP_VALID))
213 if ((
flags & KEY_SYM_VALID) && sym ==
static_cast<int>(0xFFFFFFFF))
214 flags &= ~(KEY_SYM_VALID);
228 int virtualKey = (
flags & KEY_SYM_VALID) ? sym :
cap;
241 m_eventThread = eventThread;
243 this, &QQnxScreenEventHandler::processEvents);
246void QQnxScreenEventHandler::processEvents()
251 screen_event_t
event =
nullptr;
252 if (screen_create_event(&
event) != 0)
257 if (screen_get_event(m_eventThread->
context(),
event, 0) != 0)
260 int type = SCREEN_EVENT_NONE;
261 screen_get_event_property_iv(
event, SCREEN_PROPERTY_TYPE, &
type);
262 if (
type == SCREEN_EVENT_NONE)
272 if (
type == SCREEN_EVENT_CLOSE)
277 screen_destroy_event(
event);
280void QQnxScreenEventHandler::handleKeyboardEvent(screen_event_t
event)
285 "Failed to query event flags");
290 "Failed to query event sym");
294 "Failed to query event modifieres");
298 "Failed to query event scan");
302 "Failed to query event cap");
318void QQnxScreenEventHandler::handlePointerEvent(screen_event_t
event)
323 screen_window_t qnxWindow;
326 "Failed to query event window");
328 qnxWindow =
static_cast<screen_window_t
>(
handle);
333 "Failed to query event button state");
338 screen_get_event_property_iv(
event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos),
339 "Failed to query event window position");
344 "Failed to query event position");
349 screen_get_event_property_iv(
event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheelDelta),
350 "Failed to query event wheel delta");
354 "Failed to get timestamp");
360 if (qnxWindow != m_lastMouseWindow) {
374 m_lastMouseWindow = qnxWindow;
383 QPoint localPoint(windowPos[0], windowPos[1]);
390 if (buttonState & 0x01)
392 if (buttonState & 0x02)
394 if (buttonState & 0x04)
396 if (buttonState & 0x08)
398 if (buttonState & 0x10)
400 if (buttonState & 0x20)
402 if (buttonState & 0x40)
404 if (buttonState & 0x80)
409 if (m_lastGlobalMousePoint != globalPoint || m_lastLocalMousePoint != localPoint) {
414 << localPoint.y() <<
"), b=" <<
static_cast<int>(buttons);
417 if (m_lastButtonState != buttons) {
423 int releasedButtons = (m_lastButtonState ^ buttons) & ~buttons;
424 for (
auto button : supportedButtons) {
425 if (releasedButtons &
button) {
427 localPoint, globalPoint, buttons,
430 <<
"," << localPoint.y() <<
"), b=" <<
button;
434 if (m_lastButtonState != 0 && buttons == 0) {
435 (
static_cast<QQnxWindow *
>(
w->handle()))->handleActivationEvent();
438 int pressedButtons = (m_lastButtonState ^ buttons) & buttons;
439 for (
auto button : supportedButtons) {
440 if (pressedButtons &
button) {
442 localPoint, globalPoint, buttons,
445 <<
"," << localPoint.y() <<
"), b=" <<
button;
453 QPoint angleDelta(0, wheelDelta);
455 globalPoint,
QPoint(), angleDelta);
457 << localPoint.y() <<
"), d=" <<
static_cast<int>(wheelDelta);
461 m_lastGlobalMousePoint = globalPoint;
462 m_lastLocalMousePoint = localPoint;
463 m_lastButtonState = buttons;
466void QQnxScreenEventHandler::handleTouchEvent(screen_event_t
event,
int qnxType)
471 "Failed to query event position");
478 "Failed to query event window position");
483 "Failed to query event touch id");
488 "Failed to query event window");
493 "Failed to query event touch area");
497 screen_get_event_property_iv(
event, SCREEN_PROPERTY_TOUCH_PRESSURE, &touchPressure),
498 "Failed to query event touch pressure");
500 screen_window_t qnxWindow =
static_cast<screen_window_t
>(
handle);
503 if (touchId < MaximumTouchPoints) {
509 if (qnxWindow != m_lastMouseWindow) {
522 m_lastMouseWindow = qnxWindow;
525 if (qnxType == SCREEN_EVENT_MTOUCH_RELEASE)
526 (
static_cast<QQnxWindow *
>(
w->handle()))->handleActivationEvent();
537 m_touchPoints[touchId].
area =
QRectF(
w->geometry().left() + windowPos[0] - (touchArea[0]>>1),
538 w->geometry().top() + windowPos[1] - (touchArea[1]>>1),
539 (touchArea[0]>>1), (touchArea[1]>>1));
549 m_touchPoints[touchId].
pressure =
static_cast<qreal>(touchPressure)/200.0;
551 if (m_touchPoints[touchId].pressure > 1)
552 m_touchPoints[touchId].
pressure = 1;
557 case SCREEN_EVENT_MTOUCH_TOUCH:
561 case SCREEN_EVENT_MTOUCH_MOVE:
565 case SCREEN_EVENT_MTOUCH_RELEASE:
573 for (
int i = 0;
i < MaximumTouchPoints;
i++) {
576 pointList.
append(m_touchPoints[
i]);
580 pointList.
append(m_touchPoints[
i]);
593void QQnxScreenEventHandler::handleCloseEvent(screen_event_t
event)
595 screen_window_t
window = 0;
597 screen_get_event_property_pv(
event, SCREEN_PROPERTY_WINDOW, (
void**)&
window),
598 "Failed to query window property");
608void QQnxScreenEventHandler::handleCreateEvent(screen_event_t
event)
610 screen_window_t
window = 0;
612 screen_get_event_property_pv(
event, SCREEN_PROPERTY_WINDOW, (
void**)&
window),
613 "Failed to query window property");
618void QQnxScreenEventHandler::handleDisplayEvent(screen_event_t
event)
620 screen_display_t nativeDisplay = 0;
621 if (screen_get_event_property_pv(
event, SCREEN_PROPERTY_DISPLAY, (
void **)&nativeDisplay) != 0) {
622 qWarning(
"QQnx: failed to query display property, errno=%d", errno);
627 if (screen_get_event_property_iv(
event, SCREEN_PROPERTY_ATTACHED, &isAttached) != 0) {
628 qWarning(
"QQnx: failed to query display attached property, errno=%d", errno);
638 screen_get_display_property_iv(nativeDisplay, SCREEN_PROPERTY_SIZE,
val);
639 if (
val[0] == 0 &&
val[1] == 0)
645 }
else if (!isAttached) {
653 if (!
screen->isPrimaryScreen()) {
661void QQnxScreenEventHandler::handlePropertyEvent(screen_event_t
event)
666 screen_get_event_property_iv(
event, SCREEN_PROPERTY_OBJECT_TYPE, &objectType),
667 "Failed to query object type property");
669 if (objectType != SCREEN_OBJECT_TYPE_WINDOW)
673 screen_window_t
window = 0;
675 qFatal(
"QQnx: failed to query window property, errno=%d", errno);
680 qFatal(
"QQnx: failed to query window property, errno=%d", errno);
684 handleKeyboardFocusPropertyEvent(
window);
686 case SCREEN_PROPERTY_SIZE:
687 case SCREEN_PROPERTY_POSITION:
688 handleGeometryPropertyEvent(
window);
696void QQnxScreenEventHandler::handleKeyboardFocusPropertyEvent(screen_window_t
window)
701 qFatal(
"QQnx: failed to query keyboard focus property, errno=%d", errno);
705 if (m_focusLostTimer != -1) {
707 m_focusLostTimer = -1;
716void QQnxScreenEventHandler::handleGeometryPropertyEvent(screen_window_t
window)
719 if (screen_get_window_property_iv(
window, SCREEN_PROPERTY_POSITION,
pos) != 0) {
720 qFatal(
"QQnx: failed to query window property, errno=%d", errno);
724 if (screen_get_window_property_iv(
window, SCREEN_PROPERTY_SIZE,
size) != 0) {
725 qFatal(
"QQnx: failed to query window property, errno=%d", errno);
740 if (
event->timerId() == m_focusLostTimer) {
742 m_focusLostTimer = -1;
751#include "moc_qqnxscreeneventhandler.cpp"
static QAbstractEventDispatcher * instance(QThread *thread=nullptr)
Returns a pointer to the event dispatcher object for the specified thread.
bool filterNativeEvent(const QByteArray &eventType, void *message, qintptr *result)
Sends message through the event filters that were set by installNativeEventFilter().
static constexpr auto fromUcs4(char32_t c) noexcept
Category
This enum maps the Unicode character categories.
Category category() const noexcept
Returns the character's category.
QChar toUpper() const noexcept
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
static void setPos(int x, int y)
Moves the cursor (hot spot) of the primary screen to the global screen position (x,...
Type
This enum type defines the valid event types in Qt.
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
bool removeOne(const AT &t)
void append(parameter_type t)
int startTimer(int interval, Qt::TimerType timerType=Qt::CoarseTimer)
This is an overloaded function that will start a timer of type timerType and a timeout of interval mi...
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
void killTimer(int id)
Kills the timer with timer identifier, id.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
static QQnxIntegration * instance()
void removeDisplay(QQnxScreen *screen)
QQnxScreen * screenForNative(screen_display_t qnxScreen) const
void createDisplay(screen_display_t display, bool isPrimary)
QWindow * window(screen_window_t qnxWindow) const
void removeScreenEventFilter(QQnxScreenEventFilter *filter)
void windowClosed(void *window)
void setScreenEventThread(QQnxScreenEventThread *eventThread)
void newWindowCreated(void *window)
QQnxScreenEventHandler(QQnxIntegration *integration)
void timerEvent(QTimerEvent *event) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
bool handleEvent(screen_event_t event)
static void injectKeyboardEvent(int flags, int sym, int mod, int scan, int cap)
void addScreenEventFilter(QQnxScreenEventFilter *filter)
void armEventsPending(int count)
screen_context_t context() const
The QQnxWindow is the base class of the various classes used as instances of QPlatformWindow in the Q...
\inmodule QtCore\reentrant
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr void translate(qreal dx, qreal dy) noexcept
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position.
\inmodule QtCore\reentrant
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static bool handleTouchEvent(QWindow *window, const QPointingDevice *device, const QList< struct TouchPoint > &points, Qt::KeyboardModifiers mods=Qt::NoModifier)
static void handleLeaveEvent(QWindow *window)
static bool handleMouseEvent(QWindow *window, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
static void registerInputDevice(const QInputDevice *device)
static bool handleCloseEvent(QWindow *window)
static void handleGeometryChange(QWindow *window, const QRect &newRect)
static bool handleExtendedKeyEvent(QWindow *window, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text=QString(), bool autorep=false, ushort count=1)
static void handleWindowActivated(QWindow *window, Qt::FocusReason r=Qt::OtherFocusReason)
static void handleEnterEvent(QWindow *window, const QPointF &local=QPointF(), const QPointF &global=QPointF())
static bool handleWheelEvent(QWindow *window, const QPointF &local, const QPointF &global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::ScrollPhase phase=Qt::NoScrollPhase, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
void setGeometry(int posx, int posy, int w, int h)
Sets the geometry of the window, excluding its window frame, to a rectangle constructed from posx,...
EGLImageKHR int int EGLuint64KHR * modifiers
const QLoggingCategory & category()
[1]
Combined button and popup list for selecting options.
@ ActiveWindowFocusReason
#define QByteArrayLiteral(str)
#define Q_FOREACH(variable, container)
GLuint64 GLenum void * handle
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
#define Q_SCREEN_CHECKERROR(x, message)
QString keyStringForPrivateUseQnxKey(int key)
bool isKeypadKey(int key)
QT_BEGIN_NAMESPACE int qtKeyForPrivateUseQnxKey(int key)
const int SCREEN_PROPERTY_SYM
const int SCREEN_PROPERTY_SCAN
const int SCREEN_PROPERTY_FOCUS
const int SCREEN_PROPERTY_MODIFIERS
const int SCREEN_PROPERTY_FLAGS
#define qScreenEventDebug
static int qtKey(int virtualKey, QChar::Category category)
static QString keyString(int sym, QChar::Category category)
static void finishCloseEvent(screen_event_t event)
static QString capKeyString(int cap, int modifiers, int key)
static QString qtKey(CFStringRef cfkey)