From 98d91319f43a2042ce3c060072b40f6ec7200a2e Mon Sep 17 00:00:00 2001 From: "J. J. Ramsey" Date: Sat, 7 Dec 2024 11:25:05 -0500 Subject: [PATCH 1/2] Update ext-idle-notify-protocol to new version This version allows for idle notifications to ignore idle inhibitors. --- .../src/unix/protocols/ext-idle-notify-v1.xml | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/libs/input-monitor/src/unix/protocols/ext-idle-notify-v1.xml b/libs/input-monitor/src/unix/protocols/ext-idle-notify-v1.xml index 6fe97d737..db7d9c165 100644 --- a/libs/input-monitor/src/unix/protocols/ext-idle-notify-v1.xml +++ b/libs/input-monitor/src/unix/protocols/ext-idle-notify-v1.xml @@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE. - + This interface allows clients to monitor user idle status. @@ -54,9 +54,30 @@ + + + + + + Create a new idle notification object to track input from the + user, such as keyboard and mouse movement. Because this object is + meant to track user input alone, it ignores idle inhibitors. + + The notification object has a minimum timeout duration and is tied to a + seat. The client will be notified if the seat is inactive for at least + the provided timeout. See ext_idle_notification_v1 for more details. + + A zero timeout is valid and means the client wants to be notified as + soon as possible when the seat is inactive. + + + + + + - + This interface is used by the compositor to send idle notification events to clients. @@ -65,9 +86,17 @@ becomes idle when no user activity has happened for at least the timeout duration, starting from the creation of the notification object. User activity may include input events or a presence sensor, but is - compositor-specific. If an idle inhibitor is active (e.g. another client - has created a zwp_idle_inhibitor_v1 on a visible surface), the compositor - must not make the notification object idle. + compositor-specific. + + How this notification responds to idle inhibitors depends on how + it was constructed. If constructed from the + get_idle_notification request, then if an idle inhibitor is + active (e.g. another client has created a zwp_idle_inhibitor_v1 + on a visible surface), the compositor must not make the + notification object idle. However, if constructed from the + get_input_idle_notification request, then idle inhibitors are + ignored, and only input from the user, e.g. from a keyboard or + mouse, counts as activity. When the notification object becomes idle, an idled event is sent. When user activity starts again, the notification object stops being idle, From ee8bf61818f01592dfbd22cd149e7b7a7a387f7b Mon Sep 17 00:00:00 2001 From: "J. J. Ramsey" Date: Sat, 7 Dec 2024 11:26:12 -0500 Subject: [PATCH 2/2] Allow Wayland input monitor to ignore idle inhibitors if possible If the ext-idle-notify-v1 protocol has a notifier interface version of 2 or higher, then it will ignore idle inhibitors. Otherwise, it will fallback to the older protocol. --- .../src/unix/WaylandInputMonitor.cc | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/libs/input-monitor/src/unix/WaylandInputMonitor.cc b/libs/input-monitor/src/unix/WaylandInputMonitor.cc index 54e24c224..cff951416 100644 --- a/libs/input-monitor/src/unix/WaylandInputMonitor.cc +++ b/libs/input-monitor/src/unix/WaylandInputMonitor.cc @@ -77,8 +77,28 @@ WaylandInputMonitor::init() } auto *wl_seat = gdk_wayland_seat_get_wl_seat(gdk_display_get_default_seat(gdk_display)); - auto *wl_notification = ext_idle_notifier_v1_get_idle_notification(wl_notifier, timeout, wl_seat); + const auto wl_ntfr_ver = ext_idle_notifier_v1_get_version(wl_notifier); + const auto wl_ntfr_ver_w_input_idle = decltype(wl_ntfr_ver){2}; + + ext_idle_notification_v1 *wl_notification = nullptr; + if (wl_ntfr_ver < wl_ntfr_ver_w_input_idle) + { + TRACE_MSG("Falling back to version of ext-idle-notify-v1 protocol that " + "does not support ignoring idle inhibitors"); + + wl_notification = ext_idle_notifier_v1_get_idle_notification(wl_notifier, + timeout, wl_seat); + } + else + { + TRACE_MSG("Using version of ext-idle-notify-v1 protocol that " + "supports ignoring idle inhibitors"); + + wl_notification = ext_idle_notifier_v1_get_input_idle_notification(wl_notifier, + timeout, wl_seat); + } + ext_idle_notification_v1_add_listener(wl_notification, &idle_notification_listener, this); monitor_thread = std::make_shared([this] { run(); });