wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
idle.c File Reference
#include "idle.h"
#include <libbase/libbase.h>
#include <libbase/plist.h>
#include <stdint.h>
#include <stdlib.h>
#include <wayland-server-core.h>
#include <wayland-server-protocol.h>
#include <wayland-util.h>
#include <wlr/types/wlr_idle_inhibit_v1.h>
#include "subprocess_monitor.h"
#include "toolkit/toolkit.h"
Include dependency graph for idle.c:

Classes

struct  _wlmaker_idle_monitor_t
 
struct  _wlmaker_idle_inhibitor_t
 

Typedefs

typedef struct _wlmaker_idle_inhibitor_t wlmaker_idle_inhibitor_t
 

Functions

static void _wlmaker_idle_monitor_consider_locking (wlmaker_idle_monitor_t *idle_monitor_ptr)
 
static int _wlmaker_idle_monitor_timer (void *data_ptr)
 
static int _wlmaker_idle_msec (wlmaker_idle_monitor_t *idle_monitor_ptr)
 
static bool _wlmaker_idle_monitor_add_inhibitor (wlmaker_idle_monitor_t *idle_monitor_ptr, struct wlr_idle_inhibitor_v1 *wlr_idle_inhibitor_v1_ptr)
 
static void _wlmaker_idle_monitor_handle_destroy_inhibitor (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmaker_idle_monitor_handle_new_inhibitor (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmaker_idle_monitor_handle_unlock (struct wl_listener *listener_ptr, void *data_ptr)
 
wlmaker_idle_monitor_twlmaker_idle_monitor_create (wlmaker_server_t *server_ptr)
 
void wlmaker_idle_monitor_destroy (wlmaker_idle_monitor_t *idle_monitor_ptr)
 
void wlmaker_idle_monitor_reset (wlmaker_idle_monitor_t *idle_monitor_ptr)
 
bool wlmaker_idle_monitor_lock (wlmaker_idle_monitor_t *idle_monitor_ptr)
 
void wlmaker_idle_monitor_inhibit (wlmaker_idle_monitor_t *idle_monitor_ptr)
 
void wlmaker_idle_monitor_uninhibit (wlmaker_idle_monitor_t *idle_monitor_ptr)
 

Detailed Description

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Typedef Documentation

◆ wlmaker_idle_inhibitor_t

Forward declaration: Handle of an idle inhibitor.

Function Documentation

◆ _wlmaker_idle_monitor_add_inhibitor()

bool _wlmaker_idle_monitor_add_inhibitor ( wlmaker_idle_monitor_t idle_monitor_ptr,
struct wlr_idle_inhibitor_v1 *  wlr_idle_inhibitor_v1_ptr 
)
static

Creates and adds a new inhibitor to the monitor.

Parameters
idle_monitor_ptr
wlr_idle_inhibitor_v1_ptr
Returns
true on success.

◆ _wlmaker_idle_monitor_consider_locking()

void _wlmaker_idle_monitor_consider_locking ( wlmaker_idle_monitor_t idle_monitor_ptr)
static

Executes a lock, if not inhibited & timer has indeed expired.

◆ _wlmaker_idle_monitor_handle_destroy_inhibitor()

void _wlmaker_idle_monitor_handle_destroy_inhibitor ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handler for the destroy signal of the inhibitor. Destroys it.

Parameters
listener_ptr
data_ptrUnused.

◆ _wlmaker_idle_monitor_handle_new_inhibitor()

static void _wlmaker_idle_monitor_handle_new_inhibitor ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handler for the new_inhibitor signal of the inhibit manager: Registers the inhibitor.

Parameters
listener_ptr
data_ptrPointer to struct wlr_idle_inhibitor_v1.

◆ _wlmaker_idle_monitor_handle_unlock()

void _wlmaker_idle_monitor_handle_unlock ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handler for wlmtk_root_events_t::unlock_event. Re-arms the timer.

Parameters
listener_ptr
data_ptrunused.

◆ _wlmaker_idle_monitor_timer()

int _wlmaker_idle_monitor_timer ( void *  data_ptr)
static

Timer function for the wayland event loop.

Parameters
data_ptrUntyped pointer to wlmaker_idle_monitor_t.
Returns
Whether the event source is registered for re-check with wl_event_source_check(): 0 for all done, 1 for needing a re-check. If not registered, the return value is ignored and should be zero.

◆ _wlmaker_idle_msec()

int _wlmaker_idle_msec ( wlmaker_idle_monitor_t idle_monitor_ptr)
static

Returns the idle timeout time in milliseconds.

Parameters
idle_monitor_ptr
Returns
The idle timeout, read from the config dictionnary. If no or a negative value was configured, 0 is returned, indicating the timer to NOT be armed.

◆ wlmaker_idle_monitor_create()

wlmaker_idle_monitor_t * wlmaker_idle_monitor_create ( wlmaker_server_t server_ptr)

Creates the idle monitor.

Parameters
server_ptr
Returns
Handle of the idle monitor or NULL on error.

◆ wlmaker_idle_monitor_destroy()

void wlmaker_idle_monitor_destroy ( wlmaker_idle_monitor_t idle_monitor_ptr)

Destroys the idle monitor.

Parameters
idle_monitor_ptr

◆ wlmaker_idle_monitor_inhibit()

void wlmaker_idle_monitor_inhibit ( wlmaker_idle_monitor_t idle_monitor_ptr)

Inhibits locking: Increases inhibitor counter, which will prevent locking when the idle timer expires.

See also
wlmaker_idle_monitor_uninhibit for releasing the inhibitor.
Parameters
idle_monitor_ptr

◆ wlmaker_idle_monitor_lock()

bool wlmaker_idle_monitor_lock ( wlmaker_idle_monitor_t idle_monitor_ptr)

Executes the configured 'Command' for locking. Overrides inhibits.

Parameters
idle_monitor_ptr
Returns
true on success.

◆ wlmaker_idle_monitor_reset()

void wlmaker_idle_monitor_reset ( wlmaker_idle_monitor_t idle_monitor_ptr)

Resets the idle monitor: For example, when a key is pressed.

Parameters
idle_monitor_ptr

◆ wlmaker_idle_monitor_uninhibit()

void wlmaker_idle_monitor_uninhibit ( wlmaker_idle_monitor_t idle_monitor_ptr)

Uninhibits locking: Decreases the counter. If 0, and no other inhibitors found, an expired idle timer will lock.

Parameters
idle_monitor_ptr