FdIdleMonitor

FdIdleMonitor

Functions

Description

Functions

FdIdleMonitorWatchFunc ()

void
(*FdIdleMonitorWatchFunc) (FdIdleMonitor *monitor,
                           guint id,
                           gpointer user_data);

fd_idle_monitor_new ()

FdIdleMonitor *
fd_idle_monitor_new (void);

Returns

a new FdIdleMonitor that tracks the server-global idletime for all devices.


fd_idle_monitor_add_idle_watch ()

guint
fd_idle_monitor_add_idle_watch (FdIdleMonitor *monitor,
                                guint64 interval_msec,
                                FdIdleMonitorWatchFunc callback,
                                gpointer user_data,
                                GDestroyNotify notify);

Parameters

monitor

A FdIdleMonitor

 

interval_msec

The idletime interval, in milliseconds. It must be a strictly positive value (> 0).

 

callback

The callback to call when the user has accumulated interval_msec milliseconds of idle time.

[allow-none]

user_data

The user data to pass to the callback.

[allow-none]

notify

A GDestroyNotify

 

Returns

a watch id

Adds a watch for a specific idle time. The callback will be called when the user has accumulated interval_msec milliseconds of idle time. This function will return an ID that can either be passed to fd_idle_monitor_remove_watch(), or can be used to tell idle time watches apart if you have more than one.

Also note that this function will only care about positive transitions (user's idle time exceeding a certain time). If you want to know about when the user has become active, use fd_idle_monitor_add_user_active_watch().


fd_idle_monitor_add_user_active_watch ()

guint
fd_idle_monitor_add_user_active_watch (FdIdleMonitor *monitor,
                                       FdIdleMonitorWatchFunc callback,
                                       gpointer user_data,
                                       GDestroyNotify notify);

Parameters

monitor

A FdIdleMonitor

 

callback

The callback to call when the user is active again.

[allow-none]

user_data

The user data to pass to the callback.

[allow-none]

notify

A GDestroyNotify

 

Returns

a watch id

Add a one-time watch to know when the user is active again. Note that this watch is one-time and will de-activate after the function is called, for efficiency purposes. It's most convenient to call this when an idle watch, as added by fd_idle_monitor_add_idle_watch(), has triggered.


fd_idle_monitor_remove_watch ()

void
fd_idle_monitor_remove_watch (FdIdleMonitor *monitor,
                              guint id);

Removes an idle time watcher, previously added by fd_idle_monitor_add_idle_watch() or fd_idle_monitor_add_user_active_watch().

Parameters

monitor

A FdIdleMonitor

 

id

A watch ID

 

fd_idle_monitor_get_idletime ()

guint64
fd_idle_monitor_get_idletime (FdIdleMonitor *monitor);

Parameters

monitor

A FdIdleMonitor

 

Returns

The current idle time, in milliseconds