summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-24 13:51:21 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-03-06 07:13:21 +0000
commitf6e6ef46b382e1a7f827afc5f70ce6e5deaa7e86 (patch)
treed466e53e50b99b32064319907c2f2edad74939bc /src/plugins
parent374c60e046405601ff5089c1da6f63a4bc7ea6dc (diff)
Fix up signal handling in QFbVtHandler
Start using signalfd where we can. Drop the crash (SIGSEGV, SIGBUS) handling completely. The crash handling that was in place previously was not async-safe. It also prevented getting a core dump. So just remove it. There is no safe solution for a single application process since restoring the keyboard, video modes, etc. all need unsafe calls in the signal handler almost for sure. We can however improve the handling of non-crash scenarios greatly: Introduce support for SIGINT, allowing nicely and cleanly restoring the video mode with the KMS backend when pressing Ctrl+C while QT_QPA_ENABLE_TERMINAL_KEYBOARD is set. Same goes for keyboard suspend (SIGTSTP, Ctrl+Z). When QT_QPA_ENABLE_TERMINAL_KEYBOARD is set, platform plugins now have the possibility to act upon Ctrl+Z. As an example eglfs' KMS backend is enhanced to handle this by restoring the video mode before suspending the process, and reinitializing when brought into foreground again (SIGCONT). SIGTERM is also handled. This is extremely handy when starting an application locally on the embedded device and then kill-ing it via a remote ssh session. Keyboard and video mode is now cleanly restored. Finally, when disabling the keyboard, try setting also KDSKBMUTE. Change-Id: I2b3608dc23c798e2b39f74cb27f12dcb0e958435 Reviewed-by: Louai Al-Khanji <louai.al-khanji@theqtcompany.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp34
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h3
2 files changed, 34 insertions, 3 deletions
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp
index 45287ae36e..a36ce50b76 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.cpp
@@ -37,10 +37,35 @@
#include <QtCore/QLoggingCategory>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtPlatformSupport/private/qeglplatformintegration_p.h>
+#include <QtPlatformSupport/private/qfbvthandler_p.h>
+
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
+class QEglFSKmsInterruptHandler : public QObject
+{
+public:
+ QEglFSKmsInterruptHandler(QEglFSKmsScreen *screen) : m_screen(screen) {
+ m_vtHandler = static_cast<QEGLPlatformIntegration *>(QGuiApplicationPrivate::platformIntegration())->vtHandler();
+ connect(m_vtHandler, &QFbVtHandler::interrupted, this, &QEglFSKmsInterruptHandler::restoreVideoMode);
+ connect(m_vtHandler, &QFbVtHandler::suspendRequested, this, &QEglFSKmsInterruptHandler::handleSuspendRequest);
+ }
+
+public slots:
+ void restoreVideoMode() { m_screen->restoreMode(); }
+ void handleSuspendRequest() {
+ m_screen->restoreMode();
+ m_vtHandler->suspend();
+ }
+
+private:
+ QFbVtHandler *m_vtHandler;
+ QEglFSKmsScreen *m_screen;
+};
+
void QEglFSKmsScreen::bufferDestroyedHandler(gbm_bo *bo, void *data)
{
FrameBuffer *fb = static_cast<FrameBuffer *>(data);
@@ -93,12 +118,18 @@ QEglFSKmsScreen::QEglFSKmsScreen(QEglFSKmsIntegration *integration,
, m_output(output)
, m_pos(position)
, m_cursor(Q_NULLPTR)
+ , m_interruptHandler(new QEglFSKmsInterruptHandler(this))
{
}
QEglFSKmsScreen::~QEglFSKmsScreen()
{
restoreMode();
+ if (m_output.saved_crtc) {
+ drmModeFreeCrtc(m_output.saved_crtc);
+ m_output.saved_crtc = Q_NULLPTR;
+ }
+ delete m_interruptHandler;
}
QRect QEglFSKmsScreen::geometry() const
@@ -268,9 +299,6 @@ void QEglFSKmsScreen::restoreMode()
&m_output.connector_id, 1,
&m_output.saved_crtc->mode);
- drmModeFreeCrtc(m_output.saved_crtc);
- m_output.saved_crtc = Q_NULLPTR;
-
m_output.mode_set = false;
}
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h
index cc2d6942d6..ed79d00896 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsscreen.h
@@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE
class QEglFSKmsDevice;
class QEglFSKmsCursor;
+class QEglFSKmsInterruptHandler;
struct QEglFSKmsOutput
{
@@ -115,6 +116,8 @@ private:
FrameBuffer *framebufferForBufferObject(gbm_bo *bo);
static QMutex m_waitForFlipMutex;
+
+ QEglFSKmsInterruptHandler *m_interruptHandler;
};
QT_END_NAMESPACE