Main Loop

Main Loop — Running an app using Ghosd.

Synopsis


#include <ghosd/ghosd.h>


void        ghosd_main_iterations           (Ghosd *ghosd);
void        ghosd_main_until                (Ghosd *ghosd,
                                             struct timeval *until);
void        ghosd_flash                     (Ghosd *ghosd,
                                             int fade_ms,
                                             int total_display_ms);
int         ghosd_get_socket                (Ghosd *ghosd);

Description

Once you've created a Ghosd object, you need to loop, handling X events, to display it. There are multiple ways you can go about doing this.

Details

ghosd_main_iterations ()

void        ghosd_main_iterations           (Ghosd *ghosd);

Iterate the main loop on the Ghosd, handling all pending X events. This function does not wait for X events, so it returns immediately unless there are already events pending.

ghosd : a Ghosd object.

ghosd_main_until ()

void        ghosd_main_until                (Ghosd *ghosd,
                                             struct timeval *until);

Efficiently iterate the main loop on the Ghosd, handling all pending X events, until the current time reaches the time specified in until.

ghosd : a Ghosd object.
until : a pointer to a timeval to update until.

ghosd_flash ()

void        ghosd_flash                     (Ghosd *ghosd,
                                             int fade_ms,
                                             int total_display_ms);

Fade in a Ghosd, display at full opacity for a while, fade out, and then return.

This is easy enough to implement using ghosd_main_until(), but is a a common enough use of Ghosd to make it a builtin.

ghosd : a Ghosd object.
fade_ms : how long to fade, in milliseconds.
total_display_ms : total display time, including fades, in milliseconds.

ghosd_get_socket ()

int         ghosd_get_socket                (Ghosd *ghosd);

Get the file descriptor of the Ghosd X socket. When this file descriptor has data available, call ghosd_main_iterations() to process the pending X events. Use this with select()/poll() etc. to multiplex Ghosd with other processing.

ghosd : a Ghosd object.
Returns : a file descriptor, suitable for use in select() or poll().