- closer to wayland support; still not tested in solid way - but wayland usage is disabled by default to allow merge back to master

This commit is contained in:
Dmytro Bogovych 2022-05-20 14:40:01 +03:00
parent 8c04eb45d2
commit 6cf8d86ffa
2 changed files with 16 additions and 9 deletions

View File

@ -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;

View File

@ -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++