[input] Only update seat state if session is active
When our session gets inactive libinput loses all devices, thus our Seat would not have neither keyboard, pointer nor touch. To not confuse all connected clients we block updates while libinput is suspended. After resume we check whether something actually changed and emit the corresponding signals to ensure everything is up to date.
This commit is contained in:
parent
634fd68446
commit
61579506e3
4 changed files with 59 additions and 4 deletions
27
input.cpp
27
input.cpp
|
@ -280,9 +280,30 @@ void InputRedirection::setupLibInput()
|
|||
s->setHasKeyboard(conn->hasKeyboard());
|
||||
s->setHasPointer(conn->hasPointer());
|
||||
s->setHasTouch(conn->hasTouch());
|
||||
connect(conn, &LibInput::Connection::hasKeyboardChanged, s, &KWayland::Server::SeatInterface::setHasKeyboard);
|
||||
connect(conn, &LibInput::Connection::hasPointerChanged, s, &KWayland::Server::SeatInterface::setHasPointer);
|
||||
connect(conn, &LibInput::Connection::hasTouchChanged, s, &KWayland::Server::SeatInterface::setHasTouch);
|
||||
connect(conn, &LibInput::Connection::hasKeyboardChanged, this,
|
||||
[this, s] (bool set) {
|
||||
if (m_libInput->isSuspended()) {
|
||||
return;
|
||||
}
|
||||
s->setHasKeyboard(set);
|
||||
}
|
||||
);
|
||||
connect(conn, &LibInput::Connection::hasPointerChanged, this,
|
||||
[this, s] (bool set) {
|
||||
if (m_libInput->isSuspended()) {
|
||||
return;
|
||||
}
|
||||
s->setHasPointer(set);
|
||||
}
|
||||
);
|
||||
connect(conn, &LibInput::Connection::hasTouchChanged, this,
|
||||
[this, s] (bool set) {
|
||||
if (m_libInput->isSuspended()) {
|
||||
return;
|
||||
}
|
||||
s->setHasTouch(set);
|
||||
}
|
||||
);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -94,7 +94,25 @@ void Connection::setup()
|
|||
LogindIntegration *logind = LogindIntegration::self();
|
||||
connect(logind, &LogindIntegration::sessionActiveChanged, this,
|
||||
[this](bool active) {
|
||||
active ? m_input->resume() : m_input->suspend();
|
||||
if (active) {
|
||||
m_input->resume();
|
||||
handleEvent();
|
||||
if (m_keyboardBeforeSuspend && !m_keyboard) {
|
||||
emit hasKeyboardChanged(false);
|
||||
}
|
||||
if (m_pointerBeforeSuspend && !m_pointer) {
|
||||
emit hasPointerChanged(false);
|
||||
}
|
||||
if (m_touchBeforeSuspend && !m_touch) {
|
||||
emit hasTouchChanged(false);
|
||||
}
|
||||
} else {
|
||||
m_keyboardBeforeSuspend = hasKeyboard();
|
||||
m_pointerBeforeSuspend = hasPointer();
|
||||
m_touchBeforeSuspend = hasTouch();
|
||||
m_input->suspend();
|
||||
handleEvent();
|
||||
}
|
||||
}
|
||||
);
|
||||
handleEvent();
|
||||
|
@ -212,5 +230,13 @@ void Connection::setScreenSize(const QSize &size)
|
|||
m_size = size;
|
||||
}
|
||||
|
||||
bool Connection::isSuspended() const
|
||||
{
|
||||
if (!s_context) {
|
||||
return false;
|
||||
}
|
||||
return s_context->isSuspended();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ public:
|
|||
return m_pointer > 0;
|
||||
}
|
||||
|
||||
bool isSuspended() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void keyChanged(uint32_t key, InputRedirection::KeyboardKeyState, uint32_t time);
|
||||
void pointerButtonChanged(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time);
|
||||
|
@ -82,6 +84,9 @@ private:
|
|||
int m_keyboard = 0;
|
||||
int m_pointer = 0;
|
||||
int m_touch = 0;
|
||||
bool m_keyboardBeforeSuspend = false;
|
||||
bool m_pointerBeforeSuspend = false;
|
||||
bool m_touchBeforeSuspend = false;
|
||||
|
||||
KWIN_SINGLETON(Connection)
|
||||
};
|
||||
|
|
|
@ -59,6 +59,9 @@ public:
|
|||
bool isValid() const {
|
||||
return m_libinput != nullptr;
|
||||
}
|
||||
bool isSuspended() const {
|
||||
return m_suspended;
|
||||
}
|
||||
|
||||
int fileDescriptor();
|
||||
void dispatch();
|
||||
|
|
Loading…
Reference in a new issue