updated client to bind version 2 of the ext-idle-notifier protocol
This commit is contained in:
+5
-1
@@ -3,6 +3,7 @@
|
||||
#include <gtk-layer-shell.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
@@ -28,8 +29,11 @@ void waybar::Client::handleGlobal(void *data, struct wl_registry *registry, uint
|
||||
client->idle_inhibit_manager = static_cast<struct zwp_idle_inhibit_manager_v1 *>(
|
||||
wl_registry_bind(registry, name, &zwp_idle_inhibit_manager_v1_interface, 1));
|
||||
} else if (strcmp(interface, ext_idle_notifier_v1_interface.name) == 0) {
|
||||
// Bind version 2 if available (for get_input_idle_notification), otherwise version 1
|
||||
auto bind_version = std::min(version, 2u);
|
||||
client->idle_notifier = static_cast<struct ext_idle_notifier_v1 *>(
|
||||
wl_registry_bind(registry, name, &ext_idle_notifier_v1_interface, 1));
|
||||
wl_registry_bind(registry, name, &ext_idle_notifier_v1_interface, bind_version));
|
||||
spdlog::debug("Bound ext-idle-notifier-v1 at version {}", bind_version);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -207,12 +207,26 @@ void waybar::modules::IdleInhibitor::setupIdleNotification() {
|
||||
}
|
||||
auto* wl_seat = gdk_wayland_seat_get_wl_seat(gdk_seat);
|
||||
|
||||
// Create idle notification that monitors all input (not just when inhibitor is active)
|
||||
// We use get_idle_notification instead of get_input_idle_notification to respect
|
||||
// idle inhibitors from other applications
|
||||
spdlog::debug("idle_inhibitor: creating notification with timeout {} ms", idle_timeout_ms_);
|
||||
idle_notification_ = ext_idle_notifier_v1_get_idle_notification(
|
||||
client->idle_notifier, idle_timeout_ms_, wl_seat);
|
||||
// Check protocol version to determine which function to use
|
||||
uint32_t version = wl_proxy_get_version(reinterpret_cast<struct wl_proxy*>(client->idle_notifier));
|
||||
|
||||
spdlog::debug("idle_inhibitor: creating notification with timeout {} ms (protocol version {})",
|
||||
idle_timeout_ms_, version);
|
||||
|
||||
if (version >= 2) {
|
||||
// Version 2+: Use get_input_idle_notification which ignores idle inhibitors
|
||||
// This allows us to detect actual user inactivity even while the inhibitor is active
|
||||
spdlog::debug("idle_inhibitor: using get_input_idle_notification (ignores inhibitors)");
|
||||
idle_notification_ = ext_idle_notifier_v1_get_input_idle_notification(
|
||||
client->idle_notifier, idle_timeout_ms_, wl_seat);
|
||||
} else {
|
||||
// Version 1: Fall back to get_idle_notification
|
||||
// WARNING: This respects idle inhibitors, so it won't fire while inhibitor is active
|
||||
spdlog::warn("idle_inhibitor: ext-idle-notifier-v1 version {} doesn't support get_input_idle_notification, "
|
||||
"wait-for-activity may not work correctly", version);
|
||||
idle_notification_ = ext_idle_notifier_v1_get_idle_notification(
|
||||
client->idle_notifier, idle_timeout_ms_, wl_seat);
|
||||
}
|
||||
|
||||
if (idle_notification_ == nullptr) {
|
||||
spdlog::error("idle_inhibitor: failed to create idle notification");
|
||||
|
||||
Reference in New Issue
Block a user