Basics

Basics — Creation, rendering, destruction.

Synopsis


#include <ghosd/ghosd.h>


            Ghosd;
void        (*GhosdRenderFunc)              (Ghosd *ghosd,
                                             cairo_t *cr,
                                             void *user_data);
Ghosd*      ghosd_new                       (void);
void        ghosd_destroy                   (Ghosd *ghosd);
void        ghosd_set_transparent           (Ghosd *ghosd,
                                             int transparent);
#define     GHOSD_COORD_CENTER
void        ghosd_set_position              (Ghosd *ghosd,
                                             int x,
                                             int y,
                                             int width,
                                             int height);
void        ghosd_set_render                (Ghosd *ghosd,
                                             GhosdRenderFunc render_func,
                                             void *user_data,
                                             void (*user_data_d) (void*));
void        ghosd_render                    (Ghosd *ghosd);
void        ghosd_show                      (Ghosd *ghosd);
void        ghosd_hide                      (Ghosd *ghosd);

Description

The basic functions for creating a Ghosd.

Details

Ghosd

typedef struct _Ghosd Ghosd;

An opaque Ghosd object. Think of it as the window that the content is displayed in.


GhosdRenderFunc ()

void        (*GhosdRenderFunc)              (Ghosd *ghosd,
                                             cairo_t *cr,
                                             void *user_data);

The type of callback called when Ghosd needs to render the content.

ghosd : A Ghosd object.
cr : A cairo_t to draw on.
user_data : User data that was passed to ghosd_set_render().

ghosd_new ()

Ghosd*      ghosd_new                       (void);

Create a new Ghosd object.

Can return NULL if unable to connect to the X server.

Returns : a new Ghosd object.

ghosd_destroy ()

void        ghosd_destroy                   (Ghosd *ghosd);

Free a Ghosd object.

ghosd : a Ghosd object.

ghosd_set_transparent ()

void        ghosd_set_transparent           (Ghosd *ghosd,
                                             int transparent);

Change the "transparent" setting. Setting transparent to FALSE is mostly useful for debugging.

ghosd : a Ghosd object.
transparent : a boolean indicating the transparent setting.

GHOSD_COORD_CENTER

#define GHOSD_COORD_CENTER MAXINT

Pass this as a coordinate to ghosd_set_position() to center along that axis.


ghosd_set_position ()

void        ghosd_set_position              (Ghosd *ghosd,
                                             int x,
                                             int y,
                                             int width,
                                             int height);

Position the initial Ghosd. Must be called before ghosd_render() and ghosd_show(), and can only be called once.

Positive x,y are interpreted as normal coordinates. Pass GHOSD_COORD_CENTER to center on a given dimension, and negative coordinates right-align (like CSS right).

ghosd : a Ghosd object.
x : x coordinate in screen pixels.
y : y coordinate in screen pixels.
width : width in screen pixels.
height : width in screen pixels.

ghosd_set_render ()

void        ghosd_set_render                (Ghosd *ghosd,
                                             GhosdRenderFunc render_func,
                                             void *user_data,
                                             void (*user_data_d) (void*));

Register a function to draw on the Ghosd.

ghosd : a Ghosd object.
render_func : a GhosdRenderFunc callback.
user_data : user data to pass to the callback.
user_data_d : a function to free user_data when the Ghosd is destroyed, or NULL if not needed.

ghosd_render ()

void        ghosd_render                    (Ghosd *ghosd);

Make the Ghosd redraw itself.

ghosd : a Ghosd object.

ghosd_show ()

void        ghosd_show                      (Ghosd *ghosd);

Show the Ghosd.

ghosd : a Ghosd object.

ghosd_hide ()

void        ghosd_hide                      (Ghosd *ghosd);

Hide the Ghosd.

ghosd : a Ghosd object.