Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqnxscreeneventhandler.cpp
Go to the documentation of this file.
1// Copyright (C) 2013 BlackBerry Limited. All rights reserved.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
5
6#include "qqnxglobal.h"
7
10#include "qqnxintegration.h"
11#include "qqnxkeytranslator.h"
12#include "qqnxscreen.h"
14#include "qqnxscreentraits.h"
15
16#include <QDebug>
17#include <QGuiApplication>
18
19#include <errno.h>
20#include <sys/keycodes.h>
21
22Q_LOGGING_CATEGORY(lcQpaScreenEvents, "qt.qpa.screen.events");
23
24static int qtKey(int virtualKey, QChar::Category category)
25{
26 if (Q_UNLIKELY(category == QChar::Other_NotAssigned))
27 return virtualKey;
28 else if (category == QChar::Other_PrivateUse)
29 return qtKeyForPrivateUseQnxKey(virtualKey);
30 else
31 return QChar::toUpper(virtualKey);
32}
33
34static QString keyString(int sym, QChar::Category category)
35{
36 if (Q_UNLIKELY(category == QChar::Other_NotAssigned)) {
37 return QString();
38 } else if (category == QChar::Other_PrivateUse) {
40 } else {
41 return QStringView{QChar::fromUcs4(sym)}.toString();
42 }
43}
44
45static QString capKeyString(int cap, int modifiers, int key)
46{
47 if (cap >= 0x20 && cap <= 0x0ff) {
48 if (modifiers & KEYMOD_CTRL)
49 return QChar((int)(key & 0x3f));
50 }
51 return QString();
52}
53
54template <typename T>
55static void finishCloseEvent(screen_event_t event)
56{
57 T t;
58 screen_get_event_property_pv(event,
60 reinterpret_cast<void**>(&t));
62}
63
64static void finishCloseEvent(screen_event_t event)
65{
66 // Let libscreen know that we're finished with anything that may have been acquired.
67 int objectType = SCREEN_OBJECT_TYPE_CONTEXT;
68 screen_get_event_property_iv(event, SCREEN_PROPERTY_OBJECT_TYPE, &objectType);
69 switch (objectType) {
70 case SCREEN_OBJECT_TYPE_CONTEXT:
71 finishCloseEvent<screen_context_t>(event);
72 break;
73 case SCREEN_OBJECT_TYPE_DEVICE:
74 finishCloseEvent<screen_device_t>(event);
75 break;
76 case SCREEN_OBJECT_TYPE_DISPLAY:
77 // no screen_destroy_display
78 break;
79 case SCREEN_OBJECT_TYPE_GROUP:
80 finishCloseEvent<screen_group_t>(event);
81 break;
82 case SCREEN_OBJECT_TYPE_PIXMAP:
83 finishCloseEvent<screen_pixmap_t>(event);
84 break;
85 case SCREEN_OBJECT_TYPE_SESSION:
86 finishCloseEvent<screen_session_t>(event);
87 break;
88#if _SCREEN_VERSION >= _SCREEN_MAKE_VERSION(2, 0, 0)
89 case SCREEN_OBJECT_TYPE_STREAM:
90 finishCloseEvent<screen_stream_t>(event);
91 break;
92#endif
93 case SCREEN_OBJECT_TYPE_WINDOW:
94 finishCloseEvent<screen_window_t>(event);
95 break;
96 }
97}
98
100
101using namespace Qt::StringLiterals;
102
104 : m_qnxIntegration(integration)
105 , m_lastButtonState(Qt::NoButton)
106 , m_lastMouseWindow(0)
107 , m_touchDevice(0)
108 , m_mouseDevice(0)
109 , m_eventThread(0)
110 , m_focusLostTimer(-1)
111{
112 // Create a touch device
113 m_touchDevice = new QPointingDevice(
114 "touchscreen"_L1, 1, QInputDevice::DeviceType::TouchScreen,
119 MaximumTouchPoints, 8);
121
122 m_mouseDevice = new QPointingDevice("mouse"_L1, 2, QInputDevice::DeviceType::Mouse,
126
127 // initialize array of touch points
128 for (int i = 0; i < MaximumTouchPoints; i++) {
129
130 // map array index to id
131 m_touchPoints[i].id = i;
132
133 // pressure is not supported - use default
134 m_touchPoints[i].pressure = 1.0;
135
136 // nothing touching
137 m_touchPoints[i].state = QEventPoint::State::Released;
138 }
139}
140
145
150
152{
153 // get the event type
154 int qnxType;
155 Q_SCREEN_CHECKERROR(screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &qnxType),
156 "Failed to query event type");
157
158 return handleEvent(event, qnxType);
159}
160
161bool QQnxScreenEventHandler::handleEvent(screen_event_t event, int qnxType)
162{
163 switch (qnxType) {
164 case SCREEN_EVENT_MTOUCH_TOUCH:
165 case SCREEN_EVENT_MTOUCH_MOVE:
166 case SCREEN_EVENT_MTOUCH_RELEASE:
167 handleTouchEvent(event, qnxType);
168 break;
169
170 case SCREEN_EVENT_KEYBOARD:
171 handleKeyboardEvent(event);
172 break;
173
174 case SCREEN_EVENT_POINTER:
175 handlePointerEvent(event);
176 break;
177
178 case SCREEN_EVENT_CREATE:
179 handleCreateEvent(event);
180 break;
181
182 case SCREEN_EVENT_CLOSE:
183 handleCloseEvent(event);
184 break;
185
186 case SCREEN_EVENT_DISPLAY:
187 handleDisplayEvent(event);
188 break;
189
190 case SCREEN_EVENT_PROPERTY:
191 handlePropertyEvent(event);
192 break;
193
194 default:
195 // event ignored
196 qCDebug(lcQpaScreenEvents) << Q_FUNC_INFO << "Unknown event" << qnxType;
197 return false;
198 }
199
200 return true;
201}
202
204{
205 Q_UNUSED(scan);
206
207 if (!(flags & KEY_CAP_VALID))
208 return;
209
210 // Correct erroneous information.
211 if ((flags & KEY_SYM_VALID) && sym == static_cast<int>(0xFFFFFFFF))
212 flags &= ~(KEY_SYM_VALID);
213
214 Qt::KeyboardModifiers qtMod = Qt::NoModifier;
215 if (modifiers & KEYMOD_SHIFT)
216 qtMod |= Qt::ShiftModifier;
217 if (modifiers & KEYMOD_CTRL)
218 qtMod |= Qt::ControlModifier;
219 if (modifiers & KEYMOD_ALT)
220 qtMod |= Qt::AltModifier;
221 if (isKeypadKey(cap))
222 qtMod |= Qt::KeypadModifier;
223
225
226 int virtualKey = (flags & KEY_SYM_VALID) ? sym : cap;
227 QChar::Category category = QChar::category(virtualKey);
228 int key = qtKey(virtualKey, category);
229 QString keyStr = (flags & KEY_SYM_VALID) ? keyString(sym, category) :
231
233 scan, virtualKey, modifiers, keyStr, flags & KEY_REPEAT);
234 qCDebug(lcQpaScreenEvents) << "Qt key t=" << type << ", k=" << key << ", s=" << keyStr;
235}
236
238{
239 m_eventThread = eventThread;
241 this, &QQnxScreenEventHandler::processEvents);
242}
243
244void QQnxScreenEventHandler::processEvents()
245{
246 if (!m_eventThread)
247 return;
248
249 screen_event_t event = nullptr;
250 if (screen_create_event(&event) != 0)
251 return;
252
253 int count = 0;
254 for (;;) {
255 if (screen_get_event(m_eventThread->context(), event, 0) != 0)
256 break;
257
258 int type = SCREEN_EVENT_NONE;
259 screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &type);
260 if (type == SCREEN_EVENT_NONE)
261 break;
262
263 ++count;
264 qintptr result = 0;
266 bool handled = dispatcher && dispatcher->filterNativeEvent(QByteArrayLiteral("screen_event_t"), event, &result);
267 if (!handled)
269
270 if (type == SCREEN_EVENT_CLOSE)
272 }
273
274 m_eventThread->armEventsPending(count);
275 screen_destroy_event(event);
276}
277
278void QQnxScreenEventHandler::handleKeyboardEvent(screen_event_t event)
279{
280 // get flags of key event
281 int flags;
282 Q_SCREEN_CHECKERROR(screen_get_event_property_iv(event, SCREEN_PROPERTY_FLAGS, &flags),
283 "Failed to query event flags");
284
285 // get key code
286 int sym;
287 Q_SCREEN_CHECKERROR(screen_get_event_property_iv(event, SCREEN_PROPERTY_SYM, &sym),
288 "Failed to query event sym");
289
290 int modifiers;
291 Q_SCREEN_CHECKERROR(screen_get_event_property_iv(event, SCREEN_PROPERTY_MODIFIERS, &modifiers),
292 "Failed to query event modifieres");
293
294 int scan;
295 Q_SCREEN_CHECKERROR(screen_get_event_property_iv(event, SCREEN_PROPERTY_SCAN, &scan),
296 "Failed to query event scan");
297
298 int cap;
299 Q_SCREEN_CHECKERROR(screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap),
300 "Failed to query event cap");
301
302 int sequenceId = 0;
303 bool inject = true;
304
305 Q_FOREACH (QQnxScreenEventFilter *filter, m_eventFilters) {
306 if (filter->handleKeyboardEvent(flags, sym, modifiers, scan, cap, sequenceId)) {
307 inject = false;
308 break;
309 }
310 }
311
312 if (inject)
314}
315
316void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event)
317{
318 errno = 0;
319
320 // Query the window that was clicked
321 screen_window_t qnxWindow;
322 void *handle;
323 Q_SCREEN_CHECKERROR(screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &handle),
324 "Failed to query event window");
325
326 qnxWindow = static_cast<screen_window_t>(handle);
327
328 // Query the button states
329 int buttonState = 0;
330 Q_SCREEN_CHECKERROR(screen_get_event_property_iv(event, SCREEN_PROPERTY_BUTTONS, &buttonState),
331 "Failed to query event button state");
332
333 // Query the window position
334 int windowPos[2];
336 screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos),
337 "Failed to query event window position");
338
339 // Query the screen position
340 int pos[2];
341 Q_SCREEN_CHECKERROR(screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos),
342 "Failed to query event position");
343
344 // Query the wheel delta
345 int wheelDelta = 0;
347 screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheelDelta),
348 "Failed to query event wheel delta");
349
350 long long timestamp;
351 Q_SCREEN_CHECKERROR(screen_get_event_property_llv(event, SCREEN_PROPERTY_TIMESTAMP, &timestamp),
352 "Failed to get timestamp");
353
354 // Map window handle to top-level QWindow
355 QWindow *w = QQnxIntegration::instance()->window(qnxWindow);
356
357 // Generate enter and leave events as needed.
358 if (qnxWindow != m_lastMouseWindow) {
359 QWindow *wOld = QQnxIntegration::instance()->window(m_lastMouseWindow);
360
361 if (wOld) {
363 qCDebug(lcQpaScreenEvents) << "Qt leave, w=" << wOld;
364 }
365
366 if (w) {
368 qCDebug(lcQpaScreenEvents) << "Qt enter, w=" << w;
369 }
370 }
371
372 m_lastMouseWindow = qnxWindow;
373
374 // Apply scaling to wheel delta and invert value for Qt. We'll probably want to scale
375 // this via a system preference at some point. But for now this is a sane value and makes
376 // the wheel usable.
377 wheelDelta *= -10;
378
379 // convert point to local coordinates
380 QPoint globalPoint(pos[0], pos[1]);
381 QPoint localPoint(windowPos[0], windowPos[1]);
382
383 // Convert buttons.
384 // Some QNX header files invert 'Right Button versus "Left Button' ('Right' == 0x01). But they also offer a 'Button Swap' bit,
385 // so we may receive events as shown. (If this is wrong, the fix is easy.)
386 // QNX Button mask is 8 buttons wide, with a maximum value of x080.
387 Qt::MouseButtons buttons = Qt::NoButton;
388 if (buttonState & 0x01)
389 buttons |= Qt::LeftButton;
390 if (buttonState & 0x02)
391 buttons |= Qt::MiddleButton;
392 if (buttonState & 0x04)
393 buttons |= Qt::RightButton;
394 if (buttonState & 0x08)
395 buttons |= Qt::ExtraButton1; // AKA 'Qt::BackButton'
396 if (buttonState & 0x10)
397 buttons |= Qt::ExtraButton2; // AKA 'Qt::ForwardButton'
398 if (buttonState & 0x20)
399 buttons |= Qt::ExtraButton3;
400 if (buttonState & 0x40)
401 buttons |= Qt::ExtraButton4;
402 if (buttonState & 0x80)
403 buttons |= Qt::ExtraButton5;
404
405 if (w) {
406 // Inject mouse event into Qt only if something has changed.
407 if (m_lastGlobalMousePoint != globalPoint || m_lastLocalMousePoint != localPoint) {
408 QWindowSystemInterface::handleMouseEvent(w, timestamp, m_mouseDevice, localPoint,
409 globalPoint, buttons, Qt::NoButton,
411 qCDebug(lcQpaScreenEvents) << "Qt mouse move, w=" << w << ", (" << localPoint.x() << ","
412 << localPoint.y() << "), b=" << static_cast<int>(buttons);
413 }
414
415 if (m_lastButtonState != buttons) {
416 static const auto supportedButtons = { Qt::LeftButton, Qt::MiddleButton,
420
421 int releasedButtons = (m_lastButtonState ^ buttons) & ~buttons;
422 for (auto button : supportedButtons) {
423 if (releasedButtons & button) {
424 QWindowSystemInterface::handleMouseEvent(w, timestamp, m_mouseDevice,
425 localPoint, globalPoint, buttons,
427 qCDebug(lcQpaScreenEvents) << "Qt mouse release, w=" << w << ", (" << localPoint.x()
428 << "," << localPoint.y() << "), b=" << button;
429 }
430 }
431
432 if (m_lastButtonState != 0 && buttons == 0) {
433 (static_cast<QQnxWindow *>(w->handle()))->handleActivationEvent();
434 }
435
436 int pressedButtons = (m_lastButtonState ^ buttons) & buttons;
437 for (auto button : supportedButtons) {
438 if (pressedButtons & button) {
439 QWindowSystemInterface::handleMouseEvent(w, timestamp, m_mouseDevice,
440 localPoint, globalPoint, buttons,
442 qCDebug(lcQpaScreenEvents) << "Qt mouse press, w=" << w << ", (" << localPoint.x()
443 << "," << localPoint.y() << "), b=" << button;
444 }
445 }
446 }
447
448 if (wheelDelta) {
449 // Screen only supports a single wheel, so we will assume Vertical orientation for
450 // now since that is pretty much standard.
451 QPoint angleDelta(0, wheelDelta);
452 QWindowSystemInterface::handleWheelEvent(w, timestamp, m_mouseDevice, localPoint,
453 globalPoint, QPoint(), angleDelta);
454 qCDebug(lcQpaScreenEvents) << "Qt wheel, w=" << w << ", (" << localPoint.x() << ","
455 << localPoint.y() << "), d=" << static_cast<int>(wheelDelta);
456 }
457 }
458
459 m_lastGlobalMousePoint = globalPoint;
460 m_lastLocalMousePoint = localPoint;
461 m_lastButtonState = buttons;
462}
463
464void QQnxScreenEventHandler::handleTouchEvent(screen_event_t event, int qnxType)
465{
466 // get display coordinates of touch
467 int pos[2];
468 Q_SCREEN_CHECKERROR(screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos),
469 "Failed to query event position");
470
471 QCursor::setPos(pos[0], pos[1]);
472
473 // get window coordinates of touch
474 int windowPos[2];
475 Q_SCREEN_CHECKERROR(screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos),
476 "Failed to query event window position");
477
478 // determine which finger touched
479 int touchId;
480 Q_SCREEN_CHECKERROR(screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_ID, &touchId),
481 "Failed to query event touch id");
482
483 // determine which window was touched
484 void *handle;
485 Q_SCREEN_CHECKERROR(screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &handle),
486 "Failed to query event window");
487
488 errno = 0;
489 int touchArea[2];
490 Q_SCREEN_CHECKERROR(screen_get_event_property_iv(event, SCREEN_PROPERTY_SIZE, touchArea),
491 "Failed to query event touch area");
492
493 int touchPressure;
495 screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_PRESSURE, &touchPressure),
496 "Failed to query event touch pressure");
497
498 screen_window_t qnxWindow = static_cast<screen_window_t>(handle);
499
500 // check if finger is valid
501 if (touchId < MaximumTouchPoints) {
502
503 // Map window handle to top-level QWindow
504 QWindow *w = QQnxIntegration::instance()->window(qnxWindow);
505
506 // Generate enter and leave events as needed.
507 if (qnxWindow != m_lastMouseWindow) {
508 QWindow *wOld = QQnxIntegration::instance()->window(m_lastMouseWindow);
509
510 if (wOld) {
512 qCDebug(lcQpaScreenEvents) << "Qt leave, w=" << wOld;
513 }
514
515 if (w) {
517 qCDebug(lcQpaScreenEvents) << "Qt enter, w=" << w;
518 }
519 }
520 m_lastMouseWindow = qnxWindow;
521
522 if (w) {
523 if (qnxType == SCREEN_EVENT_MTOUCH_RELEASE)
524 (static_cast<QQnxWindow *>(w->handle()))->handleActivationEvent();
525
526 // get size of screen which contains window
528 QSizeF screenSize = platformScreen->geometry().size();
529
530 // update cached position of current touch point
531 m_touchPoints[touchId].normalPosition =
532 QPointF(static_cast<qreal>(pos[0]) / screenSize.width(),
533 static_cast<qreal>(pos[1]) / screenSize.height());
534
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));
538 QWindow *parent = w->parent();
539 while (parent) {
540 m_touchPoints[touchId].area.translate(parent->geometry().topLeft());
541 parent = parent->parent();
542 }
543
544 //Qt expects the pressure between 0 and 1. There is however no definite upper limit for
545 //the integer value of touch event pressure. The 200 was determined by experiment, it
546 //usually does not get higher than that.
547 m_touchPoints[touchId].pressure = static_cast<qreal>(touchPressure)/200.0;
548 // Can happen, because there is no upper limit for pressure
549 if (m_touchPoints[touchId].pressure > 1)
550 m_touchPoints[touchId].pressure = 1;
551
552 // determine event type and update state of current touch point
554 switch (qnxType) {
555 case SCREEN_EVENT_MTOUCH_TOUCH:
556 m_touchPoints[touchId].state = QEventPoint::State::Pressed;
558 break;
559 case SCREEN_EVENT_MTOUCH_MOVE:
560 m_touchPoints[touchId].state = QEventPoint::State::Updated;
562 break;
563 case SCREEN_EVENT_MTOUCH_RELEASE:
564 m_touchPoints[touchId].state = QEventPoint::State::Released;
566 break;
567 }
568
569 // build list of active touch points
570 QList<QWindowSystemInterface::TouchPoint> pointList;
571 for (int i = 0; i < MaximumTouchPoints; i++) {
572 if (i == touchId) {
573 // current touch point is always active
574 pointList.append(m_touchPoints[i]);
575 } else if (m_touchPoints[i].state != QEventPoint::State::Released) {
576 // finger is down but did not move
577 m_touchPoints[i].state = QEventPoint::State::Stationary;
578 pointList.append(m_touchPoints[i]);
579 }
580 }
581
582 // inject event into Qt
583 QWindowSystemInterface::handleTouchEvent(w, m_touchDevice, pointList);
584 qCDebug(lcQpaScreenEvents) << "Qt touch, w =" << w
585 << ", p=" << m_touchPoints[touchId].area.topLeft()
586 << ", t=" << type;
587 }
588 }
589}
590
591void QQnxScreenEventHandler::handleCloseEvent(screen_event_t event)
592{
593 screen_window_t window = 0;
595 screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, (void**)&window),
596 "Failed to query window property");
597
599
600 // Map window handle to top-level QWindow
602 if (w != 0)
604}
605
606void QQnxScreenEventHandler::handleCreateEvent(screen_event_t event)
607{
608 screen_window_t window = 0;
610 screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, (void**)&window),
611 "Failed to query window property");
612
614}
615
616void QQnxScreenEventHandler::handleDisplayEvent(screen_event_t event)
617{
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);
621 return;
622 }
623
624 int isAttached = 0;
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);
627 return;
628 }
629
630 qCDebug(lcQpaScreenEvents) << "display attachment is now:" << isAttached;
631
632 QQnxScreen *screen = m_qnxIntegration->screenForNative(nativeDisplay);
633
634 if (!screen) {
635 if (isAttached) {
636 int val[2];
637 screen_get_display_property_iv(nativeDisplay, SCREEN_PROPERTY_SIZE, val);
638 if (val[0] == 0 && val[1] == 0) //If screen size is invalid, wait for the next event
639 return;
640
641 qCDebug(lcQpaScreenEvents) << "Creating new QQnxScreen for newly attached display";
642 m_qnxIntegration->createDisplay(nativeDisplay, false /* not primary, we assume */);
643 }
644 } else if (!isAttached) {
645 // We never remove the primary display, the qpa plugin doesn't support that and it crashes.
646 // To support it, this would be needed:
647 // - Adjust all qnx qpa code which uses screens
648 // - Make QWidgetRepaintManager not dereference a null paint device
649 // - Create platform resources ( QQnxWindow ) for all QWindow because they would be deleted
650 // when you delete the screen
651
652 if (!screen->isPrimaryScreen()) {
653 // libscreen display is deactivated, let's remove the QQnxScreen / QScreen
654 qCDebug(lcQpaScreenEvents) << "Removing display";
655 m_qnxIntegration->removeDisplay(screen);
656 }
657 }
658}
659
660void QQnxScreenEventHandler::handlePropertyEvent(screen_event_t event)
661{
662 errno = 0;
663 int objectType;
665 screen_get_event_property_iv(event, SCREEN_PROPERTY_OBJECT_TYPE, &objectType),
666 "Failed to query object type property");
667
668 if (objectType != SCREEN_OBJECT_TYPE_WINDOW)
669 return;
670
671 errno = 0;
672 screen_window_t window = 0;
673 if (Q_UNLIKELY(screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, (void**)&window) != 0))
674 qFatal("QQnx: failed to query window property, errno=%d", errno);
675
676 errno = 0;
677 int property;
678 if (Q_UNLIKELY(screen_get_event_property_iv(event, SCREEN_PROPERTY_NAME, &property) != 0))
679 qFatal("QQnx: failed to query window property, errno=%d", errno);
680
681 switch (property) {
683 handleKeyboardFocusPropertyEvent(window);
684 break;
685 case SCREEN_PROPERTY_SIZE:
686 case SCREEN_PROPERTY_POSITION:
687 handleGeometryPropertyEvent(window);
688 break;
689 default:
690 // event ignored
691 qCDebug(lcQpaScreenEvents) << "Ignore property event for property: " << property;
692 }
693}
694
695void QQnxScreenEventHandler::handleKeyboardFocusPropertyEvent(screen_window_t window)
696{
697 errno = 0;
698 int focus = 0;
699 if (Q_UNLIKELY(window && screen_get_window_property_iv(window, SCREEN_PROPERTY_FOCUS, &focus) != 0))
700 qFatal("QQnx: failed to query keyboard focus property, errno=%d", errno);
701
702 QWindow *focusWindow = QQnxIntegration::instance()->window(window);
703
704 if (m_focusLostTimer != -1) {
705 killTimer(m_focusLostTimer);
706 m_focusLostTimer = -1;
707 }
708
709 if (focus && focusWindow != QGuiApplication::focusWindow())
711 else if (!focus && focusWindow == QGuiApplication::focusWindow())
712 m_focusLostTimer = startTimer(50);
713}
714
715void QQnxScreenEventHandler::handleGeometryPropertyEvent(screen_window_t window)
716{
717 int pos[2];
718 if (screen_get_window_property_iv(window, SCREEN_PROPERTY_POSITION, pos) != 0) {
719 qFatal("QQnx: failed to query window property, errno=%d", errno);
720 }
721
722 int size[2];
723 if (screen_get_window_property_iv(window, SCREEN_PROPERTY_SIZE, size) != 0) {
724 qFatal("QQnx: failed to query window property, errno=%d", errno);
725 }
726
727 QRect rect(pos[0], pos[1], size[0], size[1]);
728 QWindow *qtWindow = QQnxIntegration::instance()->window(window);
729 if (qtWindow) {
730 qtWindow->setGeometry(rect);
732 }
733
734 qCDebug(lcQpaScreenEvents) << qtWindow << "moved to" << rect;
735}
736
738{
739 if (event->timerId() == m_focusLostTimer) {
740 killTimer(m_focusLostTimer);
741 m_focusLostTimer = -1;
742 event->accept();
743 } else {
745 }
746}
747
749
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().
\inmodule QtCore
static void setPos(int x, int y)
Moves the cursor (hot spot) of the primary screen to the global screen position (x,...
Definition qcursor.cpp:240
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
@ KeyRelease
Definition qcoreevent.h:65
@ MouseMove
Definition qcoreevent.h:63
@ KeyPress
Definition qcoreevent.h:64
@ MouseButtonPress
Definition qcoreevent.h:60
@ TouchUpdate
Definition qcoreevent.h:242
@ TouchBegin
Definition qcoreevent.h:241
@ MouseButtonRelease
Definition qcoreevent.h:61
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
bool removeOne(const AT &t)
Definition qlist.h:598
void append(parameter_type t)
Definition qlist.h:458
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...
Definition qobject.cpp:1817
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
Definition qobject.cpp:1470
void killTimer(int id)
Kills the timer with timer identifier, id.
Definition qobject.cpp:1912
The QPlatformScreen class provides an abstraction for visual displays.
static QPlatformScreen * platformScreenForWindow(const QWindow *window)
virtual QRect geometry() const =0
Reimplement in subclass to return the pixel geometry of the screen.
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore\reentrant
Definition qpoint.h:25
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)
screen_context_t context() const
The QQnxWindow is the base class of the various classes used as instances of QPlatformWindow in the Q...
Definition qqnxwindow.h:31
\inmodule QtCore\reentrant
Definition qrect.h:484
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
Definition qrect.h:511
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.
Definition qrect.h:738
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:208
constexpr qreal width() const noexcept
Returns the width.
Definition qsize.h:332
constexpr qreal height() const noexcept
Returns the height.
Definition qsize.h:335
\inmodule QtCore
Definition qstringview.h:78
QString toString() const
Returns a deep copy of this string view's data as a QString.
Definition qstring.h:1121
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qcoreevent.h:366
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)
\inmodule QtGui
Definition qwindow.h:63
EGLImageKHR int int EGLuint64KHR * modifiers
const QLoggingCategory & category()
[1]
QPushButton * button
[2]
bool focus
[0]
rect
[4]
else opt state
[0]
Combined button and popup list for selecting options.
Definition qcompare.h:63
@ LeftButton
Definition qnamespace.h:58
@ ExtraButton5
Definition qnamespace.h:70
@ RightButton
Definition qnamespace.h:59
@ MiddleButton
Definition qnamespace.h:60
@ ExtraButton2
Definition qnamespace.h:66
@ ExtraButton1
Definition qnamespace.h:63
@ NoButton
Definition qnamespace.h:57
@ ExtraButton3
Definition qnamespace.h:68
@ ExtraButton4
Definition qnamespace.h:69
@ ShiftModifier
@ ControlModifier
@ KeypadModifier
@ NoModifier
@ AltModifier
@ ActiveWindowFocusReason
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
#define Q_UNLIKELY(x)
#define Q_FUNC_INFO
#define Q_FOREACH(variable, container)
Definition qforeach.h:66
#define qWarning
Definition qlogging.h:166
#define qFatal
Definition qlogging.h:168
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLuint64 GLenum void * handle
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLenum type
GLbitfield flags
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
struct _cl_event * event
GLuint GLfloat * val
GLdouble GLdouble t
Definition qopenglext.h:243
GLuint64EXT * result
[6]
GLenum cap
#define Q_SCREEN_CHECKERROR(x, message)
Definition qqnxglobal.h:13
QString keyStringForPrivateUseQnxKey(int key)
bool isKeypadKey(int key)
QT_BEGIN_NAMESPACE int qtKeyForPrivateUseQnxKey(int key)
const int SCREEN_PROPERTY_SYM
Definition qqnxscreen.h:28
const int SCREEN_PROPERTY_SCAN
Definition qqnxscreen.h:27
const int SCREEN_PROPERTY_FOCUS
Definition qqnxscreen.h:25
const int SCREEN_PROPERTY_MODIFIERS
Definition qqnxscreen.h:26
const int SCREEN_PROPERTY_FLAGS
Definition qqnxscreen.h:24
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)
QScreen * screen
[1]
Definition main.cpp:29
#define Q_EMIT
#define Q_UNUSED(x)
double qreal
Definition qtypes.h:187
ptrdiff_t qintptr
Definition qtypes.h:166
const char property[13]
Definition qwizard.cpp:101
aWidget window() -> setWindowTitle("New Window Title")
[2]