@ -33,6 +33,9 @@ static int idle_notify(void *data) {
}
static void handle_activity ( struct wlr_idle_timeout * timer ) {
if ( ! timer - > enabled ) {
return ;
}
// rearm the timer
wl_event_source_timer_update ( timer - > idle_source , timer - > timeout ) ;
// in case the previous state was sleeping send a resume event and switch state
@ -106,6 +109,7 @@ static void create_idle_timer(struct wl_client *client,
timer - > seat = client_seat - > seat ;
timer - > timeout = timeout ;
timer - > idle_state = false ;
timer - > enabled = idle - > enabled ;
timer - > resource = wl_resource_create ( client ,
& org_kde_kwin_idle_timeout_interface ,
wl_resource_get_version ( idle_resource ) , id ) ;
@ -135,14 +139,36 @@ static void create_idle_timer(struct wl_client *client,
wl_resource_post_no_memory ( idle_resource ) ;
return ;
}
if ( timer - > enabled ) {
// arm the timer
wl_event_source_timer_update ( timer - > idle_source , timer - > timeout ) ;
}
}
static const struct org_kde_kwin_idle_interface idle_impl = {
. get_idle_timeout = create_idle_timer ,
} ;
void wlr_idle_set_enabled ( struct wlr_idle * idle , struct wlr_seat * seat ,
bool enabled ) {
if ( idle - > enabled = = enabled ) {
return ;
}
wlr_log ( L_DEBUG , " %s idle timers for %s " ,
enabled ? " Enabling " : " Disabling " ,
seat ? seat - > name : " all seats " ) ;
idle - > enabled = enabled ;
struct wlr_idle_timeout * timer ;
wl_list_for_each ( timer , & idle - > idle_timers , link ) {
if ( seat ! = NULL & & timer - > seat ! = seat ) {
continue ;
}
int timeout = enabled ? timer - > timeout : 0 ;
wl_event_source_timer_update ( timer - > idle_source , timeout ) ;
timer - > enabled = enabled ;
}
}
static void idle_bind ( struct wl_client * wl_client , void * data ,
uint32_t version , uint32_t id ) {
struct wlr_idle * idle = data ;
@ -182,6 +208,7 @@ struct wlr_idle *wlr_idle_create(struct wl_display *display) {
}
wl_list_init ( & idle - > idle_timers ) ;
wl_signal_init ( & idle - > events . activity_notify ) ;
idle - > enabled = true ;
idle - > event_loop = wl_display_get_event_loop ( display ) ;
if ( idle - > event_loop = = NULL ) {