diff --git a/types/wlr_idle_notify_v1.c b/types/wlr_idle_notify_v1.c index 686ddccc5..b4b9afcc1 100644 --- a/types/wlr_idle_notify_v1.c +++ b/types/wlr_idle_notify_v1.c @@ -4,7 +4,7 @@ #include #include "ext-idle-notify-v1-protocol.h" -#define IDLE_NOTIFIER_VERSION 1 +#define IDLE_NOTIFIER_VERSION 2 struct wlr_idle_notification_v1 { struct wl_resource *resource; @@ -16,6 +16,7 @@ struct wlr_idle_notification_v1 { struct wl_event_source *timer; bool idle; + bool obey_inhibitors; struct wl_listener seat_destroy; }; @@ -81,7 +82,8 @@ static void notification_destroy(struct wlr_idle_notification_v1 *notification) } static void notification_reset_timer(struct wlr_idle_notification_v1 *notification) { - if (notification->notifier->inhibited) { + if (notification->notifier->inhibited && + notification->obey_inhibitors) { notification_set_idle(notification, false); if (notification->timer != NULL) { wl_event_source_timer_update(notification->timer, 0); @@ -115,9 +117,9 @@ static void notification_handle_resource_destroy(struct wl_resource *resource) { notification_destroy(notification); } -static void notifier_handle_get_idle_notification(struct wl_client *client, +static void construct_idle_notification(struct wl_client *client, struct wl_resource *notifier_resource, uint32_t id, uint32_t timeout, - struct wl_resource *seat_resource) { + struct wl_resource *seat_resource, bool obey_inhibitors) { struct wlr_idle_notifier_v1 *notifier = notifier_from_resource(notifier_resource); struct wlr_seat_client *seat_client = @@ -148,6 +150,7 @@ static void notifier_handle_get_idle_notification(struct wl_client *client, notification->resource = resource; notification->timeout_ms = timeout; notification->seat = seat_client->seat; + notification->obey_inhibitors = obey_inhibitors; if (timeout > 0) { struct wl_display *display = wl_client_get_display(client); @@ -170,9 +173,28 @@ static void notifier_handle_get_idle_notification(struct wl_client *client, notification_reset_timer(notification); } +static void notifier_handle_get_input_idle_notification( + struct wl_client *client, + struct wl_resource *notifier_resource, uint32_t id, + uint32_t timeout, struct wl_resource *seat_resource) { + construct_idle_notification(client, notifier_resource, id, + timeout, seat_resource, false); +} + +static void notifier_handle_get_idle_notification( + struct wl_client *client, + struct wl_resource *notifier_resource, uint32_t id, + uint32_t timeout, struct wl_resource *seat_resource) { + construct_idle_notification(client, notifier_resource, id, + timeout, seat_resource, true); +} + static const struct ext_idle_notifier_v1_interface notifier_impl = { .destroy = resource_handle_destroy, - .get_idle_notification = notifier_handle_get_idle_notification, + .get_idle_notification = + notifier_handle_get_idle_notification, + .get_input_idle_notification = + notifier_handle_get_input_idle_notification, }; static void notifier_bind(struct wl_client *client, void *data, @@ -227,19 +249,20 @@ void wlr_idle_notifier_v1_set_inhibited(struct wlr_idle_notifier_v1 *notifier, struct wlr_idle_notification_v1 *notification; wl_list_for_each(notification, ¬ifier->notifications, link) { - notification_reset_timer(notification); + if (notification->obey_inhibitors) { + notification_reset_timer(notification); + } } } void wlr_idle_notifier_v1_notify_activity(struct wlr_idle_notifier_v1 *notifier, struct wlr_seat *seat) { - if (notifier->inhibited) { - return; - } struct wlr_idle_notification_v1 *notification; wl_list_for_each(notification, ¬ifier->notifications, link) { - if (notification->seat == seat) { + if (notification->seat == seat && + !(notifier->inhibited && + notification->obey_inhibitors)) { notification_handle_activity(notification); } }