edelib
2.1.0
|
Client part of XSETTINGS protocol. More...
#include <edelib/XSettingsClient.h>
Public Member Functions | |
XSettingsClient () | |
~XSettingsClient () | |
bool | init (Display *dpy, int screen, XSettingsCallback cb=0, void *data=0) |
void | clear (void) |
void | callback (XSettingsCallback cb, void *data=0) |
int | process_xevent (const XEvent *xev) |
void | set (const char *name, int val) |
void | set (const char *name, const char *val) |
void | set (const char *name, unsigned short red, unsigned short green, unsigned short blue, unsigned short alpha) |
void | manager_notify (void) |
Static Public Member Functions | |
static bool | manager_running (Display *dpy, int screen) |
Client part of XSETTINGS protocol.
This class is used to query XSETTINGS data from manager. Due XSETTINGS protocol requirements, manager must already be running. To see differences between official protocol and current implementation, please see XSettingsData documentation.
Before query data, init() must be called. init() will register needed data and (optionaly) register callback for listening changes. This callback will be triggered when one of the settings are changed on manager side so application can update needed data.
Also to get changes via callback, process_xevent() must be placed in loop with X events so XSettingsClient can capture needed events and process them.
This is simple example how stuff should be set up:
init() function intentionally have (optional) callback parameter since after calling init(), callback can be triggered immediately if manager is running so XSettingsClient can pick up currently stored settings from it. Alternatively there is callback() function which can be used to change callback during runtime.
Calling callback() before init() is the same as calling init() with callback function.
Note that if callback() is called after init(), settings will not be queried from manager until one of the settings is changed on manager side.
XSettingsClient | ( | ) |
Empty constructor
~XSettingsClient | ( | ) |
Clears internal data
void callback | ( | XSettingsCallback | cb, |
void * | data = 0 |
||
) |
Set callback for listening changes
cb | is callback parameter |
data | is data passed to the callback function |
void clear | ( | void | ) |
Clears internal data. init() must be called agan if other functions are going to be called
bool init | ( | Display * | dpy, |
int | screen, | ||
XSettingsCallback | cb = 0 , |
||
void * | data = 0 |
||
) |
Init needed communication parts.
dpy | is display |
screen | is screen |
cb | is callback parameter |
data | is data passed to the callback function |
void manager_notify | ( | void | ) |
Send changed data to manager. This should be called aftear set()
|
static |
Checks if manager is running
dpy | is display |
screen | is screen |
int process_xevent | ( | const XEvent * | xev | ) |
This function should be placed in loop with X events
void set | ( | const char * | name, |
int | val | ||
) |
Set integer value on manager
name | is setting name |
val | is int value |
void set | ( | const char * | name, |
const char * | val | ||
) |
Set string (char*) value on manager. Data will be copied
name | is setting name |
val | is string value |
void set | ( | const char * | name, |
unsigned short | red, | ||
unsigned short | green, | ||
unsigned short | blue, | ||
unsigned short | alpha | ||
) |
Set RGBA color values on manager
name | is setting name |
red | is red component |
green | is green component |
blue | is blue component |
alpha | is alpha component |