eglfs: Disable the blinking cursor

Make eglfs and linuxfb use the same code via QFbVtHandler.

Task-number: QTBUG-45106
Change-Id: I876bbf5f13bab6d4a81f616c01f15f9c98edf5fc
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
This commit is contained in:
Laszlo Agocs 2015-03-19 10:14:56 +01:00
parent ddf6ac03cb
commit 39636e38fe
2 changed files with 24 additions and 7 deletions

View File

@ -38,9 +38,11 @@
#define VTH_ENABLED
#include <private/qcore_unix_p.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/signalfd.h>
#include <sys/ioctl.h>
#include <linux/kd.h>
@ -59,6 +61,24 @@
QT_BEGIN_NAMESPACE
#ifdef VTH_ENABLED
static void setTTYCursor(bool enable)
{
const char * const devs[] = { "/dev/tty0", "/dev/tty", "/dev/console", 0 };
int fd = -1;
for (const char * const *dev = devs; *dev; ++dev) {
fd = QT_OPEN(*dev, O_RDWR);
if (fd != -1) {
// Enable/disable screen blanking and the blinking cursor.
const char *termctl = enable ? "\033[9;15]\033[?33h\033[?25h\033[?0c" : "\033[9;0]\033[?33l\033[?25l\033[?1c";
QT_WRITE(fd, termctl, strlen(termctl) + 1);
QT_CLOSE(fd);
return;
}
}
}
#endif
QFbVtHandler::QFbVtHandler(QObject *parent)
: QObject(parent),
m_tty(-1),
@ -66,6 +86,8 @@ QFbVtHandler::QFbVtHandler(QObject *parent)
m_signalNotifier(0)
{
#ifdef VTH_ENABLED
setTTYCursor(false);
if (isatty(0)) {
m_tty = 0;
ioctl(m_tty, KDGKBMODE, &m_oldKbdMode);
@ -114,6 +136,7 @@ QFbVtHandler::~QFbVtHandler()
{
#ifdef VTH_ENABLED
restoreKeyboard();
setTTYCursor(true);
if (m_signalFd != -1)
close(m_signalFd);
@ -172,6 +195,7 @@ void QFbVtHandler::handleInt()
#ifdef VTH_ENABLED
emit interrupted();
restoreKeyboard();
setTTYCursor(true);
_exit(1);
#endif
}

View File

@ -264,9 +264,6 @@ static bool switchToGraphicsMode(int ttyfd, int *oldMode)
return false;
}
// No blankin' screen, no blinkin' cursor!, no cursor!
const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c";
QT_WRITE(ttyfd, termctl, sizeof(termctl));
return true;
}
@ -274,10 +271,6 @@ static void resetTty(int ttyfd, int oldMode)
{
ioctl(ttyfd, KDSETMODE, oldMode);
// Blankin' screen, blinkin' cursor!
const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c";
QT_WRITE(ttyfd, termctl, sizeof(termctl));
QT_CLOSE(ttyfd);
}