From eaae7b1d03ca4d252d3797a8f010f7cf0ad055f7 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 17 Aug 2020 09:54:03 +0400 Subject: [PATCH] Decrease indentation in XCBLastUserInputTime --- .../platform/linux/specific_linux.cpp | 63 +++++++++---------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 8d6a9e78d6..bea4f434f4 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -386,41 +386,38 @@ std::vector GetXCBWMSupported(xcb_connection_t *connection) { } std::optional XCBLastUserInputTime() { - if (const auto native = QGuiApplication::platformNativeInterface()) { - const auto connection = reinterpret_cast( - native->nativeResourceForIntegration(QByteArray("connection"))); - - if (!connection) { - return std::nullopt; - } - - const auto screen = xcb_setup_roots_iterator( - xcb_get_setup(connection)).data; - - if (!screen) { - return std::nullopt; - } - - const auto cookie = xcb_screensaver_query_info( - connection, - screen->root); - - auto reply = xcb_screensaver_query_info_reply( - connection, - cookie, - nullptr); - - if (!reply) { - return std::nullopt; - } - - const auto idle = reply->ms_since_user_input; - free(reply); - - return (crl::now() - static_cast(idle)); + const auto native = QGuiApplication::platformNativeInterface(); + if (!native) { + return std::nullopt; } - return std::nullopt; + const auto connection = reinterpret_cast( + native->nativeResourceForIntegration(QByteArray("connection"))); + + if (!connection) { + return std::nullopt; + } + + const auto root = static_cast(reinterpret_cast( + native->nativeResourceForIntegration(QByteArray("rootwindow")))); + + const auto cookie = xcb_screensaver_query_info( + connection, + root); + + auto reply = xcb_screensaver_query_info_reply( + connection, + cookie, + nullptr); + + if (!reply) { + return std::nullopt; + } + + const auto idle = reply->ms_since_user_input; + free(reply); + + return (crl::now() - static_cast(idle)); } #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION