17#include <QGuiApplication>
20#include <sys/keycodes.h>
28 else if (
category == QChar::Other_PrivateUse)
31 return QChar::toUpper(virtualKey);
38 }
else if (
category == QChar::Other_PrivateUse) {
47 if (
cap >= 0x20 &&
cap <= 0x0ff) {
58 screen_get_event_property_pv(
event,
60 reinterpret_cast<void**
>(&
t));
67 int objectType = SCREEN_OBJECT_TYPE_CONTEXT;
68 screen_get_event_property_iv(
event, SCREEN_PROPERTY_OBJECT_TYPE, &objectType);
70 case SCREEN_OBJECT_TYPE_CONTEXT:
71 finishCloseEvent<screen_context_t>(
event);
73 case SCREEN_OBJECT_TYPE_DEVICE:
74 finishCloseEvent<screen_device_t>(
event);
76 case SCREEN_OBJECT_TYPE_DISPLAY:
79 case SCREEN_OBJECT_TYPE_GROUP:
80 finishCloseEvent<screen_group_t>(
event);
82 case SCREEN_OBJECT_TYPE_PIXMAP:
83 finishCloseEvent<screen_pixmap_t>(
event);
85 case SCREEN_OBJECT_TYPE_SESSION:
86 finishCloseEvent<screen_session_t>(
event);
88#if _SCREEN_VERSION >= _SCREEN_MAKE_VERSION(2, 0, 0)
89 case SCREEN_OBJECT_TYPE_STREAM:
90 finishCloseEvent<screen_stream_t>(
event);
93 case SCREEN_OBJECT_TYPE_WINDOW:
94 finishCloseEvent<screen_window_t>(
event);
104 : m_qnxIntegration(integration)
105 , m_lastButtonState(
Qt::NoButton)
106 , m_lastMouseWindow(0)
110 , m_focusLostTimer(-1)
119 MaximumTouchPoints, 8);
128 for (
int i = 0;
i < MaximumTouchPoints;
i++) {
131 m_touchPoints[
i].
id =
i;
156 "Failed to query event type");
164 case SCREEN_EVENT_MTOUCH_TOUCH:
165 case SCREEN_EVENT_MTOUCH_MOVE:
166 case SCREEN_EVENT_MTOUCH_RELEASE:
167 handleTouchEvent(
event, qnxType);
170 case SCREEN_EVENT_KEYBOARD:
171 handleKeyboardEvent(
event);
174 case SCREEN_EVENT_POINTER:
175 handlePointerEvent(
event);
178 case SCREEN_EVENT_CREATE:
179 handleCreateEvent(
event);
182 case SCREEN_EVENT_CLOSE:
183 handleCloseEvent(
event);
186 case SCREEN_EVENT_DISPLAY:
187 handleDisplayEvent(
event);
190 case SCREEN_EVENT_PROPERTY:
191 handlePropertyEvent(
event);
207 if (!(
flags & KEY_CAP_VALID))
211 if ((
flags & KEY_SYM_VALID) && sym ==
static_cast<int>(0xFFFFFFFF))
212 flags &= ~(KEY_SYM_VALID);
226 int virtualKey = (
flags & KEY_SYM_VALID) ? sym :
cap;
227 QChar::Category
category = QChar::category(virtualKey);
234 qCDebug(lcQpaScreenEvents) <<
"Qt key t=" <<
type <<
", k=" <<
key <<
", s=" << keyStr;
239 m_eventThread = eventThread;
241 this, &QQnxScreenEventHandler::processEvents);
244void QQnxScreenEventHandler::processEvents()
249 screen_event_t
event =
nullptr;
250 if (screen_create_event(&
event) != 0)
255 if (screen_get_event(m_eventThread->
context(),
event, 0) != 0)
258 int type = SCREEN_EVENT_NONE;
259 screen_get_event_property_iv(
event, SCREEN_PROPERTY_TYPE, &
type);
260 if (
type == SCREEN_EVENT_NONE)
270 if (
type == SCREEN_EVENT_CLOSE)
275 screen_destroy_event(
event);
278void QQnxScreenEventHandler::handleKeyboardEvent(screen_event_t
event)
283 "Failed to query event flags");
288 "Failed to query event sym");
292 "Failed to query event modifieres");
296 "Failed to query event scan");
300 "Failed to query event cap");
316void QQnxScreenEventHandler::handlePointerEvent(screen_event_t
event)
321 screen_window_t qnxWindow;
324 "Failed to query event window");
326 qnxWindow =
static_cast<screen_window_t
>(
handle);
331 "Failed to query event button state");
336 screen_get_event_property_iv(
event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos),
337 "Failed to query event window position");
342 "Failed to query event position");
347 screen_get_event_property_iv(
event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheelDelta),
348 "Failed to query event wheel delta");
352 "Failed to get timestamp");
358 if (qnxWindow != m_lastMouseWindow) {
363 qCDebug(lcQpaScreenEvents) <<
"Qt leave, w=" << wOld;
368 qCDebug(lcQpaScreenEvents) <<
"Qt enter, w=" <<
w;
372 m_lastMouseWindow = qnxWindow;
381 QPoint localPoint(windowPos[0], windowPos[1]);
388 if (buttonState & 0x01)
390 if (buttonState & 0x02)
392 if (buttonState & 0x04)
394 if (buttonState & 0x08)
396 if (buttonState & 0x10)
398 if (buttonState & 0x20)
400 if (buttonState & 0x40)
402 if (buttonState & 0x80)
407 if (m_lastGlobalMousePoint != globalPoint || m_lastLocalMousePoint != localPoint) {
411 qCDebug(lcQpaScreenEvents) <<
"Qt mouse move, w=" <<
w <<
", (" << localPoint.x() <<
","
412 << localPoint.y() <<
"), b=" <<
static_cast<int>(buttons);
415 if (m_lastButtonState != buttons) {
421 int releasedButtons = (m_lastButtonState ^ buttons) & ~buttons;
422 for (
auto button : supportedButtons) {
423 if (releasedButtons &
button) {
425 localPoint, globalPoint, buttons,
427 qCDebug(lcQpaScreenEvents) <<
"Qt mouse release, w=" <<
w <<
", (" << localPoint.x()
428 <<
"," << localPoint.y() <<
"), b=" <<
button;
432 if (m_lastButtonState != 0 && buttons == 0) {
433 (
static_cast<QQnxWindow *
>(
w->handle()))->handleActivationEvent();
436 int pressedButtons = (m_lastButtonState ^ buttons) & buttons;
437 for (
auto button : supportedButtons) {
438 if (pressedButtons &
button) {
440 localPoint, globalPoint, buttons,
442 qCDebug(lcQpaScreenEvents) <<
"Qt mouse press, w=" <<
w <<
", (" << localPoint.x()
443 <<
"," << localPoint.y() <<
"), b=" <<
button;
451 QPoint angleDelta(0, wheelDelta);
453 globalPoint,
QPoint(), angleDelta);
454 qCDebug(lcQpaScreenEvents) <<
"Qt wheel, w=" <<
w <<
", (" << localPoint.x() <<
","
455 << localPoint.y() <<
"), d=" <<
static_cast<int>(wheelDelta);
459 m_lastGlobalMousePoint = globalPoint;
460 m_lastLocalMousePoint = localPoint;
461 m_lastButtonState = buttons;
464void QQnxScreenEventHandler::handleTouchEvent(screen_event_t
event,
int qnxType)
469 "Failed to query event position");
476 "Failed to query event window position");
481 "Failed to query event touch id");
486 "Failed to query event window");
491 "Failed to query event touch area");
495 screen_get_event_property_iv(
event, SCREEN_PROPERTY_TOUCH_PRESSURE, &touchPressure),
496 "Failed to query event touch pressure");
498 screen_window_t qnxWindow =
static_cast<screen_window_t
>(
handle);
501 if (touchId < MaximumTouchPoints) {
507 if (qnxWindow != m_lastMouseWindow) {
512 qCDebug(lcQpaScreenEvents) <<
"Qt leave, w=" << wOld;
517 qCDebug(lcQpaScreenEvents) <<
"Qt enter, w=" <<
w;
520 m_lastMouseWindow = qnxWindow;
523 if (qnxType == SCREEN_EVENT_MTOUCH_RELEASE)
524 (
static_cast<QQnxWindow *
>(
w->handle()))->handleActivationEvent();
535 m_touchPoints[touchId].
area =
QRectF(
w->geometry().left() + windowPos[0] - (touchArea[0]>>1),
536 w->geometry().top() + windowPos[1] - (touchArea[1]>>1),
537 (touchArea[0]>>1), (touchArea[1]>>1));
547 m_touchPoints[touchId].
pressure =
static_cast<qreal>(touchPressure)/200.0;
549 if (m_touchPoints[touchId].pressure > 1)
550 m_touchPoints[touchId].
pressure = 1;
555 case SCREEN_EVENT_MTOUCH_TOUCH:
559 case SCREEN_EVENT_MTOUCH_MOVE:
563 case SCREEN_EVENT_MTOUCH_RELEASE:
570 QList<QWindowSystemInterface::TouchPoint> pointList;
571 for (
int i = 0;
i < MaximumTouchPoints;
i++) {
574 pointList.append(m_touchPoints[
i]);
578 pointList.append(m_touchPoints[
i]);
584 qCDebug(lcQpaScreenEvents) <<
"Qt touch, w =" <<
w
591void QQnxScreenEventHandler::handleCloseEvent(screen_event_t
event)
593 screen_window_t
window = 0;
595 screen_get_event_property_pv(
event, SCREEN_PROPERTY_WINDOW, (
void**)&
window),
596 "Failed to query window property");
606void QQnxScreenEventHandler::handleCreateEvent(screen_event_t
event)
608 screen_window_t
window = 0;
610 screen_get_event_property_pv(
event, SCREEN_PROPERTY_WINDOW, (
void**)&
window),
611 "Failed to query window property");
616void QQnxScreenEventHandler::handleDisplayEvent(screen_event_t
event)
618 screen_display_t nativeDisplay = 0;
619 if (screen_get_event_property_pv(
event, SCREEN_PROPERTY_DISPLAY, (
void **)&nativeDisplay) != 0) {
620 qWarning(
"QQnx: failed to query display property, errno=%d", errno);
625 if (screen_get_event_property_iv(
event, SCREEN_PROPERTY_ATTACHED, &isAttached) != 0) {
626 qWarning(
"QQnx: failed to query display attached property, errno=%d", errno);
630 qCDebug(lcQpaScreenEvents) <<
"display attachment is now:" << isAttached;
637 screen_get_display_property_iv(nativeDisplay, SCREEN_PROPERTY_SIZE,
val);
638 if (
val[0] == 0 &&
val[1] == 0)
641 qCDebug(lcQpaScreenEvents) <<
"Creating new QQnxScreen for newly attached display";
644 }
else if (!isAttached) {
652 if (!
screen->isPrimaryScreen()) {
654 qCDebug(lcQpaScreenEvents) <<
"Removing display";
660void QQnxScreenEventHandler::handlePropertyEvent(screen_event_t
event)
665 screen_get_event_property_iv(
event, SCREEN_PROPERTY_OBJECT_TYPE, &objectType),
666 "Failed to query object type property");
668 if (objectType != SCREEN_OBJECT_TYPE_WINDOW)
672 screen_window_t
window = 0;
674 qFatal(
"QQnx: failed to query window property, errno=%d", errno);
679 qFatal(
"QQnx: failed to query window property, errno=%d", errno);
683 handleKeyboardFocusPropertyEvent(
window);
685 case SCREEN_PROPERTY_SIZE:
686 case SCREEN_PROPERTY_POSITION:
687 handleGeometryPropertyEvent(
window);
691 qCDebug(lcQpaScreenEvents) <<
"Ignore property event for property: " <<
property;
695void QQnxScreenEventHandler::handleKeyboardFocusPropertyEvent(screen_window_t
window)
700 qFatal(
"QQnx: failed to query keyboard focus property, errno=%d", errno);
704 if (m_focusLostTimer != -1) {
706 m_focusLostTimer = -1;
715void QQnxScreenEventHandler::handleGeometryPropertyEvent(screen_window_t
window)
718 if (screen_get_window_property_iv(
window, SCREEN_PROPERTY_POSITION,
pos) != 0) {
719 qFatal(
"QQnx: failed to query window property, errno=%d", errno);
723 if (screen_get_window_property_iv(
window, SCREEN_PROPERTY_SIZE,
size) != 0) {
724 qFatal(
"QQnx: failed to query window property, errno=%d", errno);
730 qtWindow->setGeometry(
rect);
734 qCDebug(lcQpaScreenEvents) << qtWindow <<
"moved to" <<
rect;
739 if (
event->timerId() == m_focusLostTimer) {
741 m_focusLostTimer = -1;
750#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 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)
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 qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
QString toString() const
Returns a deep copy of this string view's data as a QString.
\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 void handleFocusWindowChanged(QWindow *window, Qt::FocusReason r=Qt::OtherFocusReason)
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 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)
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)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
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
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)