From c23e106c8be3f7ac68d049710a7a82b5c2a6eec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 27 Mar 2015 14:40:57 +0100 Subject: [PATCH] [input] Include more safety checks nullptr checks as input events might be processed prior to KWin having been fully started. --- input.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/input.cpp b/input.cpp index 0edcfffe6f..9235c98a8e 100644 --- a/input.cpp +++ b/input.cpp @@ -247,12 +247,14 @@ void InputRedirection::setupLibInput() LibInput::Connection *conn = LibInput::Connection::create(this); if (conn) { conn->setup(); - conn->setScreenSize(screens()->size()); - connect(screens(), &Screens::sizeChanged, this, - [this, conn] { - conn->setScreenSize(screens()->size()); - } - ); + if (screens()) { + conn->setScreenSize(screens()->size()); + connect(screens(), &Screens::sizeChanged, this, + [this, conn] { + conn->setScreenSize(screens()->size()); + } + ); + } connect(conn, &LibInput::Connection::pointerButtonChanged, this, &InputRedirection::processPointerButton); connect(conn, &LibInput::Connection::pointerAxisChanged, this, &InputRedirection::processPointerAxis); connect(conn, &LibInput::Connection::keyChanged, this, &InputRedirection::processKeyboardKey); @@ -272,9 +274,9 @@ void InputRedirection::setupLibInput() connect(conn, &LibInput::Connection::touchMotion, this, &InputRedirection::processTouchMotion); connect(conn, &LibInput::Connection::touchCanceled, this, &InputRedirection::cancelTouch); connect(conn, &LibInput::Connection::touchFrame, this, &InputRedirection::touchFrame); - connect(screens(), &Screens::changed, this, &InputRedirection::updatePointerAfterScreenChange); // set pos to center of all screens if (screens()) { + connect(screens(), &Screens::changed, this, &InputRedirection::updatePointerAfterScreenChange); m_globalPointer = screens()->geometry().center(); emit globalPointerChanged(m_globalPointer); // sanitize @@ -465,7 +467,7 @@ void InputRedirection::processKeyboardKey(uint32_t key, InputRedirection::Keyboa } // TODO: pass to internal parts of KWin #ifdef KWIN_BUILD_TABBOX - if (TabBox::TabBox::self()->isGrabbed()) { + if (TabBox::TabBox::self() && TabBox::TabBox::self()->isGrabbed()) { if (state == KWin::InputRedirection::KeyboardKeyPressed) { TabBox::TabBox::self()->keyPress(m_xkb->modifiers() | m_xkb->toQtKey(m_xkb->toKeysym(key))); } @@ -481,11 +483,13 @@ void InputRedirection::processKeyboardKey(uint32_t key, InputRedirection::Keyboa static_cast< EffectsHandlerImpl* >(effects)->grabbedKeyboardEvent(&event); return; } - if (Client *c = workspace()->getMovingClient()) { - // TODO: this does not yet fully support moving of the Client - // cursor events change the cursor and on Wayland pointer warping is not possible - c->keyPressEvent(m_xkb->toQtKey(m_xkb->toKeysym(key))); - return; + if (workspace()) { + if (Client *c = workspace()->getMovingClient()) { + // TODO: this does not yet fully support moving of the Client + // cursor events change the cursor and on Wayland pointer warping is not possible + c->keyPressEvent(m_xkb->toQtKey(m_xkb->toKeysym(key))); + return; + } } // process global shortcuts if (state == KeyboardKeyPressed) {