backends/x11: Start reading host X11 events in initialize()

There's no reason to wait until the workspace is created.
This commit is contained in:
Vlad Zahorodnii 2022-12-02 18:05:34 +02:00
parent 28baea1c29
commit b4441cd502
2 changed files with 14 additions and 17 deletions

View file

@ -196,7 +196,7 @@ bool X11WindowedBackend::initialize()
initXInput();
XRenderUtils::init(m_connection, m_screen->root);
createOutputs();
connect(kwinApp(), &Application::workspaceCreated, this, &X11WindowedBackend::startEventReading);
m_pointerDevice = std::make_unique<X11WindowedInputDevice>();
m_pointerDevice->setPointer(true);
m_keyboardDevice = std::make_unique<X11WindowedInputDevice>();
@ -205,6 +205,19 @@ bool X11WindowedBackend::initialize()
m_touchDevice = std::make_unique<X11WindowedInputDevice>();
m_touchDevice->setTouch(true);
}
m_eventNotifier = std::make_unique<QSocketNotifier>(xcb_get_file_descriptor(m_connection), QSocketNotifier::Read);
auto processXcbEvents = [this] {
while (auto event = xcb_poll_for_event(m_connection)) {
handleEvent(event);
free(event);
}
xcb_flush(m_connection);
};
connect(m_eventNotifier.get(), &QSocketNotifier::activated, this, processXcbEvents);
connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, processXcbEvents);
connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::awake, this, processXcbEvents);
Q_EMIT outputsQueried();
return true;
}
@ -282,21 +295,6 @@ void X11WindowedBackend::createOutputs()
xcb_flush(m_connection);
}
void X11WindowedBackend::startEventReading()
{
m_eventNotifier = std::make_unique<QSocketNotifier>(xcb_get_file_descriptor(m_connection), QSocketNotifier::Read);
auto processXcbEvents = [this] {
while (auto event = xcb_poll_for_event(m_connection)) {
handleEvent(event);
free(event);
}
xcb_flush(m_connection);
};
connect(m_eventNotifier.get(), &QSocketNotifier::activated, this, processXcbEvents);
connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, processXcbEvents);
connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::awake, this, processXcbEvents);
}
#if HAVE_X11_XINPUT
static inline qreal fixed1616ToReal(FP1616 val)

View file

@ -142,7 +142,6 @@ Q_SIGNALS:
private:
void createOutputs();
void startEventReading();
void grabKeyboard(xcb_timestamp_t time);
void updateWindowTitle();
void handleEvent(xcb_generic_event_t *event);