[libinput] Bind libinput support to VirtualTerminal
This change is motivated by the fact that we need to suspend libinput before switching the virtual terminal. Also we don't want to take over libinput if we do not have a VirtualTerminal created - in windowed mode we don't want libinput to be started. So binding it to the backends which create the VirtualTerminal makes sense. The KWin::Application gains a new signal virtualTerminalCreated which is emitted from VirtualTerminal once it's properly setup. This is used by Input to create Libinput integration instead of binding it to logind. Furthermore Libinput gets suspended when the VirtualTerminal reports that it is no longer active. For re-activation we still just use logind's session active property.icc-effect-5.14.5
parent
2f312f35c9
commit
efa0500313
26
input.cpp
26
input.cpp
|
@ -202,19 +202,10 @@ InputRedirection::InputRedirection(QObject *parent)
|
|||
{
|
||||
#if HAVE_INPUT
|
||||
if (Application::usesLibinput()) {
|
||||
LogindIntegration *logind = LogindIntegration::self();
|
||||
auto takeControl = [logind, this]() {
|
||||
if (logind->hasSessionControl()) {
|
||||
setupLibInput();
|
||||
} else {
|
||||
logind->takeControl();
|
||||
m_sessionControlConnection = connect(logind, &LogindIntegration::hasSessionControlChanged, this, &InputRedirection::setupLibInput);
|
||||
}
|
||||
};
|
||||
if (logind->isConnected()) {
|
||||
takeControl();
|
||||
if (VirtualTerminal::self()) {
|
||||
setupLibInput();
|
||||
} else {
|
||||
connect(logind, &LogindIntegration::connectedChanged, this, takeControl);
|
||||
connect(kwinApp(), &Application::virtualTerminalCreated, this, &InputRedirection::setupLibInput);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -242,10 +233,6 @@ void InputRedirection::setupLibInput()
|
|||
if (!Application::usesLibinput()) {
|
||||
return;
|
||||
}
|
||||
if (m_sessionControlConnection) {
|
||||
disconnect(m_sessionControlConnection);
|
||||
m_sessionControlConnection = QMetaObject::Connection();
|
||||
}
|
||||
if (m_libInput) {
|
||||
return;
|
||||
}
|
||||
|
@ -307,6 +294,13 @@ void InputRedirection::setupLibInput()
|
|||
}
|
||||
);
|
||||
}
|
||||
connect(VirtualTerminal::self(), &VirtualTerminal::activeChanged, m_libInput,
|
||||
[this] (bool active) {
|
||||
if (!active) {
|
||||
m_libInput->deactivate();
|
||||
}
|
||||
}
|
||||
);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
2
input.h
2
input.h
|
@ -203,8 +203,6 @@ private:
|
|||
|
||||
GlobalShortcutsManager *m_shortcuts;
|
||||
|
||||
QMetaObject::Connection m_sessionControlConnection;
|
||||
|
||||
LibInput::Connection *m_libInput = nullptr;
|
||||
|
||||
KWIN_SINGLETON(InputRedirection)
|
||||
|
|
|
@ -96,6 +96,9 @@ void Connection::setup()
|
|||
connect(logind, &LogindIntegration::sessionActiveChanged, this,
|
||||
[this](bool active) {
|
||||
if (active) {
|
||||
if (!m_input->isSuspended()) {
|
||||
return;
|
||||
}
|
||||
m_input->resume();
|
||||
handleEvent();
|
||||
if (m_keyboardBeforeSuspend && !m_keyboard) {
|
||||
|
@ -108,17 +111,25 @@ void Connection::setup()
|
|||
emit hasTouchChanged(false);
|
||||
}
|
||||
} else {
|
||||
m_keyboardBeforeSuspend = hasKeyboard();
|
||||
m_pointerBeforeSuspend = hasPointer();
|
||||
m_touchBeforeSuspend = hasTouch();
|
||||
m_input->suspend();
|
||||
handleEvent();
|
||||
deactivate();
|
||||
}
|
||||
}
|
||||
);
|
||||
handleEvent();
|
||||
}
|
||||
|
||||
void Connection::deactivate()
|
||||
{
|
||||
if (m_input->isSuspended()) {
|
||||
return;
|
||||
}
|
||||
m_keyboardBeforeSuspend = hasKeyboard();
|
||||
m_pointerBeforeSuspend = hasPointer();
|
||||
m_touchBeforeSuspend = hasTouch();
|
||||
m_input->suspend();
|
||||
handleEvent();
|
||||
}
|
||||
|
||||
void Connection::handleEvent()
|
||||
{
|
||||
do {
|
||||
|
|
|
@ -60,6 +60,8 @@ public:
|
|||
|
||||
bool isSuspended() const;
|
||||
|
||||
void deactivate();
|
||||
|
||||
Q_SIGNALS:
|
||||
void keyChanged(uint32_t key, InputRedirection::KeyboardKeyState, uint32_t time);
|
||||
void pointerButtonChanged(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time);
|
||||
|
|
1
main.h
1
main.h
|
@ -152,6 +152,7 @@ Q_SIGNALS:
|
|||
void x11ConnectionChanged();
|
||||
void workspaceCreated();
|
||||
void screensCreated();
|
||||
void virtualTerminalCreated();
|
||||
|
||||
protected:
|
||||
Application(OperationMode mode, int &argc, char **argv);
|
||||
|
|
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "virtual_terminal.h"
|
||||
// kwin
|
||||
#include "logind.h"
|
||||
#include "main.h"
|
||||
#include "utils.h"
|
||||
// Qt
|
||||
#include <QDebug>
|
||||
|
@ -126,6 +127,7 @@ void VirtualTerminal::setup(int vtNr)
|
|||
return;
|
||||
}
|
||||
setActive(true);
|
||||
emit kwinApp()->virtualTerminalCreated();
|
||||
}
|
||||
|
||||
void VirtualTerminal::closeFd()
|
||||
|
|
Loading…
Reference in New Issue