From 39636e38fe905ed4f256a447e3451a62624405cd Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 19 Mar 2015 10:14:56 +0100 Subject: [PATCH] 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 --- .../fbconvenience/qfbvthandler.cpp | 24 +++++++++++++++++++ .../platforms/linuxfb/qlinuxfbscreen.cpp | 7 ------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/platformsupport/fbconvenience/qfbvthandler.cpp b/src/platformsupport/fbconvenience/qfbvthandler.cpp index 84844d8eda..c46e470c34 100644 --- a/src/platformsupport/fbconvenience/qfbvthandler.cpp +++ b/src/platformsupport/fbconvenience/qfbvthandler.cpp @@ -38,9 +38,11 @@ #define VTH_ENABLED +#include #include #include #include +#include #include #include #include @@ -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 } diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp index 5407fa66dc..91708c0a47 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp @@ -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); }