[input] Include more safety checks

nullptr checks as input events might be processed prior to KWin having
been fully started.
This commit is contained in:
Martin Gräßlin 2015-03-27 14:40:57 +01:00
parent 7a96c3ee46
commit c23e106c8b

View file

@ -247,12 +247,14 @@ void InputRedirection::setupLibInput()
LibInput::Connection *conn = LibInput::Connection::create(this); LibInput::Connection *conn = LibInput::Connection::create(this);
if (conn) { if (conn) {
conn->setup(); conn->setup();
conn->setScreenSize(screens()->size()); if (screens()) {
connect(screens(), &Screens::sizeChanged, this, conn->setScreenSize(screens()->size());
[this, conn] { connect(screens(), &Screens::sizeChanged, this,
conn->setScreenSize(screens()->size()); [this, conn] {
} conn->setScreenSize(screens()->size());
); }
);
}
connect(conn, &LibInput::Connection::pointerButtonChanged, this, &InputRedirection::processPointerButton); connect(conn, &LibInput::Connection::pointerButtonChanged, this, &InputRedirection::processPointerButton);
connect(conn, &LibInput::Connection::pointerAxisChanged, this, &InputRedirection::processPointerAxis); connect(conn, &LibInput::Connection::pointerAxisChanged, this, &InputRedirection::processPointerAxis);
connect(conn, &LibInput::Connection::keyChanged, this, &InputRedirection::processKeyboardKey); 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::touchMotion, this, &InputRedirection::processTouchMotion);
connect(conn, &LibInput::Connection::touchCanceled, this, &InputRedirection::cancelTouch); connect(conn, &LibInput::Connection::touchCanceled, this, &InputRedirection::cancelTouch);
connect(conn, &LibInput::Connection::touchFrame, this, &InputRedirection::touchFrame); connect(conn, &LibInput::Connection::touchFrame, this, &InputRedirection::touchFrame);
connect(screens(), &Screens::changed, this, &InputRedirection::updatePointerAfterScreenChange);
// set pos to center of all screens // set pos to center of all screens
if (screens()) { if (screens()) {
connect(screens(), &Screens::changed, this, &InputRedirection::updatePointerAfterScreenChange);
m_globalPointer = screens()->geometry().center(); m_globalPointer = screens()->geometry().center();
emit globalPointerChanged(m_globalPointer); emit globalPointerChanged(m_globalPointer);
// sanitize // sanitize
@ -465,7 +467,7 @@ void InputRedirection::processKeyboardKey(uint32_t key, InputRedirection::Keyboa
} }
// TODO: pass to internal parts of KWin // TODO: pass to internal parts of KWin
#ifdef KWIN_BUILD_TABBOX #ifdef KWIN_BUILD_TABBOX
if (TabBox::TabBox::self()->isGrabbed()) { if (TabBox::TabBox::self() && TabBox::TabBox::self()->isGrabbed()) {
if (state == KWin::InputRedirection::KeyboardKeyPressed) { if (state == KWin::InputRedirection::KeyboardKeyPressed) {
TabBox::TabBox::self()->keyPress(m_xkb->modifiers() | m_xkb->toQtKey(m_xkb->toKeysym(key))); 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); static_cast< EffectsHandlerImpl* >(effects)->grabbedKeyboardEvent(&event);
return; return;
} }
if (Client *c = workspace()->getMovingClient()) { if (workspace()) {
// TODO: this does not yet fully support moving of the Client if (Client *c = workspace()->getMovingClient()) {
// cursor events change the cursor and on Wayland pointer warping is not possible // TODO: this does not yet fully support moving of the Client
c->keyPressEvent(m_xkb->toQtKey(m_xkb->toKeysym(key))); // cursor events change the cursor and on Wayland pointer warping is not possible
return; c->keyPressEvent(m_xkb->toQtKey(m_xkb->toKeysym(key)));
return;
}
} }
// process global shortcuts // process global shortcuts
if (state == KeyboardKeyPressed) { if (state == KeyboardKeyPressed) {