Dynamically show/hide the mouse cursor, depending on the input type
This commit is contained in:
parent
4fb4c911bf
commit
0a0f952740
@ -67,6 +67,10 @@ RaspberryPiHelper::RaspberryPiHelper(QObject *parent) : QObject(parent)
|
||||
if (m_screenOffTimer.interval() > 0) {
|
||||
m_screenOffTimer.start();
|
||||
}
|
||||
|
||||
// Hide the mouse cursor right away, it'll be restored on mouse move events
|
||||
QApplication::setOverrideCursor(Qt::BlankCursor);
|
||||
m_cursorHidden = true;
|
||||
}
|
||||
|
||||
bool RaspberryPiHelper::active() const
|
||||
@ -126,6 +130,29 @@ bool RaspberryPiHelper::eventFilter(QObject *watched, QEvent *event)
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
// Hide the mouse cursor if touchscreen events are coming in
|
||||
QList<QEvent::Type> touchTypes = {
|
||||
QEvent::TouchBegin,
|
||||
QEvent::TouchUpdate,
|
||||
QEvent::TouchEnd
|
||||
};
|
||||
if (touchTypes.contains(event->type()) && !m_cursorHidden) {
|
||||
QApplication::setOverrideCursor(Qt::BlankCursor);
|
||||
m_cursorHidden = true;
|
||||
}
|
||||
|
||||
// Restore the mouse cursor if hidden and mouse events come in
|
||||
QList<QEvent::Type> mouseTypes = {
|
||||
QEvent::MouseMove,
|
||||
QEvent::MouseButtonPress,
|
||||
QEvent::GrabMouse
|
||||
};
|
||||
if (mouseTypes.contains(event->type()) && m_cursorHidden) {
|
||||
QApplication::restoreOverrideCursor();
|
||||
m_cursorHidden = false;
|
||||
}
|
||||
|
||||
|
||||
if (!m_screenOffTimer.isActive()) {
|
||||
screenOn();
|
||||
m_screenOffTimer.start();
|
||||
|
||||
@ -59,6 +59,8 @@ private:
|
||||
QFile m_powerFile;
|
||||
QFile m_brightnessFile;
|
||||
|
||||
bool m_cursorHidden = false;
|
||||
|
||||
int m_currentBrightness = 255;
|
||||
};
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
[Seat:*]
|
||||
autologin-user=nymea
|
||||
user-session=nymea-app-kiosk
|
||||
xserver-command=X -s 0 -dpms -nocursor
|
||||
xserver-command=X -s 0 -dpms
|
||||
|
||||
Reference in New Issue
Block a user