From 6cf8d86ffadb34908f1e73e709cff57fc4265849 Mon Sep 17 00:00:00 2001 From: Dmytro Bogovych Date: Fri, 20 May 2022 14:40:01 +0300 Subject: [PATCH] - closer to wayland support; still not tested in solid way - but wayland usage is disabled by default to allow merge back to master --- app/idle_tracking.cpp | 17 +++++++++++------ app/qbreak.pro | 8 +++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/idle_tracking.cpp b/app/idle_tracking.cpp index 2746f62..b990dd1 100644 --- a/app/idle_tracking.cpp +++ b/app/idle_tracking.cpp @@ -133,7 +133,9 @@ public: kde_idle_detector() {} ~kde_idle_detector() - {} + { + stop(); + } // Idle timeout is in msec void start(int idle_timeout) @@ -145,12 +147,14 @@ public: registry.on_global() = [&] (uint32_t name, const std::string& interface, uint32_t version) { if (interface == wayland::seat_t::interface_name) - registry.bind(name, seat, version); + registry.bind(name, this->seat, version); + else if (interface == wayland::org_kde_kwin_idle_t::interface_name) - registry.bind(name, idle, version); + registry.bind(name, this->idle, version); }; d.roundtrip(); + bool has_keyboard = false, has_pointer = false; seat.on_capabilities() = [&] (const wayland::seat_capability& capability) { @@ -199,7 +203,7 @@ kde_idle_detector kde_idle; int get_idle_time_kde_wayland() { // Ensure idle detector runs - kde_idle.start(1000); + kde_idle.start(1); return kde_idle.get_idle_time(); } @@ -210,9 +214,10 @@ int get_idle_time_dynamically() { #if defined(USE_WAYLAND) const char* wl_display = std::getenv("WAYLAND_DISPLAY"); - if (wl_display) + const char* x11_display = std::getenv("DISPLAY"); + if (wl_display && !x11_display) { - const char* desktop_name = std::getenv("XDG_DESKTOP_NAME"); + const char* desktop_name = std::getenv("XDG_SESSION_DESKTOP"); if (!desktop_name) return 0; diff --git a/app/qbreak.pro b/app/qbreak.pro index 65432a1..73d237f 100644 --- a/app/qbreak.pro +++ b/app/qbreak.pro @@ -50,8 +50,10 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin # X11 and wayland libraries unix:LIBS += -L/usr/X11R6/lib/ \ - -L/usr/local/lib \ - -lX11 -lXext -lXss -ldl \ - -lwayland-client-unstable++ -lwayland-client-extra++ -lwayland-client++ + -lX11 -lXext -lXss -ldl + +# When using wayland: +# unix:LIBS += -L/usr/local/lib \ +# -lwayland-client-unstable++ -lwayland-client-extra++ -lwayland-client++