From b4441cd50229484adc67c0ac95f497090ef0f477 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 2 Dec 2022 18:05:34 +0200 Subject: [PATCH] backends/x11: Start reading host X11 events in initialize() There's no reason to wait until the workspace is created. --- .../x11/windowed/x11_windowed_backend.cpp | 30 +++++++++---------- .../x11/windowed/x11_windowed_backend.h | 1 - 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/backends/x11/windowed/x11_windowed_backend.cpp b/src/backends/x11/windowed/x11_windowed_backend.cpp index f27cb0bc07..ae7db45983 100644 --- a/src/backends/x11/windowed/x11_windowed_backend.cpp +++ b/src/backends/x11/windowed/x11_windowed_backend.cpp @@ -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(); m_pointerDevice->setPointer(true); m_keyboardDevice = std::make_unique(); @@ -205,6 +205,19 @@ bool X11WindowedBackend::initialize() m_touchDevice = std::make_unique(); m_touchDevice->setTouch(true); } + + m_eventNotifier = std::make_unique(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(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) diff --git a/src/backends/x11/windowed/x11_windowed_backend.h b/src/backends/x11/windowed/x11_windowed_backend.h index b4116f63ea..605d2918b9 100644 --- a/src/backends/x11/windowed/x11_windowed_backend.h +++ b/src/backends/x11/windowed/x11_windowed_backend.h @@ -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);