Skip to content

Commit ed9c517

Browse files
author
James Ramsey
committed
Allow Workrave to ignore idle inhibitors if possible
This uses version 2 of the ext-idle-notify protocol where possible. If version 2 is unavailable, Workrave will fallback to using the older version of the protocol that does not ignore idle inhibitors.
1 parent f5afb09 commit ed9c517

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed

libs/input-monitor/src/unix/WaylandInputMonitor.cc

+21-1
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,28 @@ WaylandInputMonitor::init()
7777
}
7878

7979
auto *wl_seat = gdk_wayland_seat_get_wl_seat(gdk_display_get_default_seat(gdk_display));
80-
auto *wl_notification = ext_idle_notifier_v1_get_idle_notification(wl_notifier, timeout, wl_seat);
8180

81+
const auto wl_ntfr_ver = ext_idle_notifier_v1_get_version(wl_notifier);
82+
const auto wl_ntfr_ver_w_input_idle = decltype(wl_ntfr_ver){2};
83+
84+
ext_idle_notification_v1 *wl_notification = nullptr;
85+
if (wl_ntfr_ver < wl_ntfr_ver_w_input_idle)
86+
{
87+
TRACE_MSG("Falling back to version of ext-idle-notify-v1 protocol that "
88+
"does not support ignoring idle inhibitors");
89+
90+
wl_notification = ext_idle_notifier_v1_get_idle_notification(wl_notifier,
91+
timeout, wl_seat);
92+
}
93+
else
94+
{
95+
TRACE_MSG("Using version of ext-idle-notify-v1 protocol that "
96+
"supports ignoring idle inhibitors");
97+
98+
wl_notification = ext_idle_notifier_v1_get_input_idle_notification(wl_notifier,
99+
timeout, wl_seat);
100+
}
101+
82102
ext_idle_notification_v1_add_listener(wl_notification, &idle_notification_listener, this);
83103
monitor_thread = std::make_shared<std::thread>([this] { run(); });
84104

libs/input-monitor/src/unix/protocols/ext-idle-notify-v1.xml

+34-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
DEALINGS IN THE SOFTWARE.
2525
</copyright>
2626

27-
<interface name="ext_idle_notifier_v1" version="1">
27+
<interface name="ext_idle_notifier_v1" version="2">
2828
<description summary="idle notification manager">
2929
This interface allows clients to monitor user idle status.
3030

@@ -54,9 +54,30 @@
5454
<arg name="timeout" type="uint" summary="minimum idle timeout in msec"/>
5555
<arg name="seat" type="object" interface="wl_seat"/>
5656
</request>
57+
58+
<!-- Version 2 additions -->
59+
60+
<request name="get_input_idle_notification" since="2">
61+
<description summary="create a notification object">
62+
Create a new idle notification object to track input from the
63+
user, such as keyboard and mouse movement. Because this object is
64+
meant to track user input alone, it ignores idle inhibitors.
65+
66+
The notification object has a minimum timeout duration and is tied to a
67+
seat. The client will be notified if the seat is inactive for at least
68+
the provided timeout. See ext_idle_notification_v1 for more details.
69+
70+
A zero timeout is valid and means the client wants to be notified as
71+
soon as possible when the seat is inactive.
72+
</description>
73+
<arg name="id" type="new_id" interface="ext_idle_notification_v1"/>
74+
<arg name="timeout" type="uint" summary="minimum idle timeout in msec"/>
75+
<arg name="seat" type="object" interface="wl_seat"/>
76+
</request>
77+
5778
</interface>
5879

59-
<interface name="ext_idle_notification_v1" version="1">
80+
<interface name="ext_idle_notification_v1" version="2">
6081
<description summary="idle notification">
6182
This interface is used by the compositor to send idle notification events
6283
to clients.
@@ -65,9 +86,17 @@
6586
becomes idle when no user activity has happened for at least the timeout
6687
duration, starting from the creation of the notification object. User
6788
activity may include input events or a presence sensor, but is
68-
compositor-specific. If an idle inhibitor is active (e.g. another client
69-
has created a zwp_idle_inhibitor_v1 on a visible surface), the compositor
70-
must not make the notification object idle.
89+
compositor-specific.
90+
91+
How this notification responds to idle inhibitors depends on how
92+
it was constructed. If constructed from the
93+
get_idle_notification request, then if an idle inhibitor is
94+
active (e.g. another client has created a zwp_idle_inhibitor_v1
95+
on a visible surface), the compositor must not make the
96+
notification object idle. However, if constructed from the
97+
get_input_idle_notification request, then idle inhibitors are
98+
ignored, and only input from the user, e.g. from a keyboard or
99+
mouse, counts as activity.
71100

72101
When the notification object becomes idle, an idled event is sent. When
73102
user activity starts again, the notification object stops being idle,

0 commit comments

Comments
 (0)