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