Register the screen pulse event

Future versions of QNX will, by default, require the use of registered
events. Currently, event registration is supported but optional.

Change-Id: Ie45484d5ca9fa832a28ccf08cb1764cf24262dcc
Reviewed-by: Dan Cape <dcape@qnx.com>
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
This commit is contained in:
James McDonnell 2019-11-21 11:09:24 -05:00
parent 7be4bbcbc5
commit e0a43e348c
2 changed files with 23 additions and 3 deletions

View File

@ -60,6 +60,18 @@ static const int c_screenCode = _PULSE_CODE_MINAVAIL + 0;
static const int c_armCode = _PULSE_CODE_MINAVAIL + 1;
static const int c_quitCode = _PULSE_CODE_MINAVAIL + 2;
#if !defined(screen_register_event)
int screen_register_event(screen_context_t, struct sigevent *event)
{
return MsgRegisterEvent(event, -1);
}
int screen_unregister_event(struct sigevent *event)
{
return MsgUnregisterEvent(event);
}
#endif
QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context)
: QThread()
, m_screenContext(context)
@ -75,10 +87,14 @@ QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context)
qFatal("QQnxScreenEventThread: Can't continue without a channel connection");
}
struct sigevent screenEvent;
SIGEV_PULSE_INIT(&screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_screenCode, 0);
SIGEV_PULSE_INIT(&m_screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_screenCode, 0);
if (screen_register_event(m_screenContext, &m_screenEvent) == -1) {
ConnectDetach(m_connectionId);
ChannelDestroy(m_channelId);
qFatal("QQnxScreenEventThread: Can't continue without a registered event");
}
screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, &screenEvent);
screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, &m_screenEvent);
}
QQnxScreenEventThread::~QQnxScreenEventThread()
@ -86,6 +102,8 @@ QQnxScreenEventThread::~QQnxScreenEventThread()
// block until thread terminates
shutdown();
screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, nullptr);
screen_unregister_event(&m_screenEvent);
ConnectDetach(m_connectionId);
ChannelDestroy(m_channelId);
}

View File

@ -45,6 +45,7 @@
#include <QtCore/QMutex>
#include <screen/screen.h>
#include <sys/siginfo.h>
QT_BEGIN_NAMESPACE
@ -73,6 +74,7 @@ private:
int m_channelId;
int m_connectionId;
struct sigevent m_screenEvent;
screen_context_t m_screenContext;
bool m_emitNeededOnNextScreenPulse = true;
int m_screenPulsesSinceLastArmPulse = 0;