10#include <QtCore/QDebug>
17#if defined(QQNXSCREENEVENTTHREAD_DEBUG)
18#define qScreenEventThreadDebug qDebug
20#define qScreenEventThreadDebug QT_NO_QDEBUG_MACRO
24static const int c_armCode = _PULSE_CODE_MINAVAIL + 1;
27#if !defined(screen_register_event)
30 return MsgRegisterEvent(
event, -1);
35 return MsgUnregisterEvent(
event);
43 m_channelId = ChannelCreate(_NTO_CHF_DISCONNECT | _NTO_CHF_UNBLOCK | _NTO_CHF_PRIVATE);
44 if (m_channelId == -1) {
45 qFatal(
"QQnxScreenEventThread: Can't continue without a channel");
48 m_connectionId = ConnectAttach(0, 0, m_channelId, _NTO_SIDE_CHANNEL, 0);
49 if (m_connectionId == -1) {
50 ChannelDestroy(m_channelId);
51 qFatal(
"QQnxScreenEventThread: Can't continue without a channel connection");
54 SIGEV_PULSE_INIT(&m_screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT,
c_screenCode, 0);
56 ConnectDetach(m_connectionId);
57 ChannelDestroy(m_channelId);
58 qFatal(
"QQnxScreenEventThread: Can't continue without a registered event");
61 screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT,
nullptr, &m_screenEvent);
69 screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT,
nullptr,
nullptr);
71 ConnectDetach(m_connectionId);
72 ChannelDestroy(m_channelId);
81 memset(&msg, 0,
sizeof(msg));
82 int receiveId = MsgReceive(m_channelId, &msg,
sizeof(msg),
nullptr);
85 else if (receiveId == 0)
87 else if (receiveId > 0)
88 qWarning() <<
"Unexpected message" << msg.code;
90 qWarning() <<
"MsgReceive error" << strerror(errno);
98 MsgSendPulse(m_connectionId, SIGEV_PULSE_PRIO_INHERIT,
c_armCode,
count);
101void QQnxScreenEventThread::handleScreenPulse(
const struct _pulse &msg)
105 ++m_screenPulsesSinceLastArmPulse;
106 if (m_emitNeededOnNextScreenPulse) {
107 m_emitNeededOnNextScreenPulse =
false;
112void QQnxScreenEventThread::handleArmPulse(
const struct _pulse &msg)
114 if (msg.value.sival_int == 0 && m_screenPulsesSinceLastArmPulse == 0) {
115 m_emitNeededOnNextScreenPulse =
true;
117 m_screenPulsesSinceLastArmPulse = 0;
118 m_emitNeededOnNextScreenPulse =
false;
123void QQnxScreenEventThread::handlePulse(
const struct _pulse &msg)
126 handleScreenPulse(msg);
130 qWarning() <<
"Unexpected pulse" << msg.code;
133void QQnxScreenEventThread::shutdown()
135 MsgSendPulse(m_connectionId, SIGEV_PULSE_PRIO_INHERIT,
c_quitCode, 0);
QQnxScreenEventThread(screen_context_t context)
void armEventsPending(int count)
bool wait(QDeadlineTimer deadline=QDeadlineTimer(QDeadlineTimer::Forever))
GLenum GLenum GLsizei count
static const int c_screenCode
static const int c_armCode
static const int c_quitCode
#define qScreenEventThreadDebug
int screen_register_event(screen_context_t, struct sigevent *event)
int screen_unregister_event(struct sigevent *event)