Added applicator for global settings

This commit is contained in:
Sanel Zukan 2009-02-27 15:43:57 +00:00
parent 99c4913b8c
commit 4705a79876
3 changed files with 111 additions and 1 deletions

View File

@ -16,7 +16,8 @@ SOURCE = evoke.cpp
Xsm.cpp
Logout.cpp
Autostart.cpp
Xshutdown.cpp ;
Xshutdown.cpp
SettingsApplicator.cpp ;
CONFIG = ede-settings.conf
ede-startup.conf ;

View File

@ -0,0 +1,83 @@
/*
* $Id$
*
* Evoke, head honcho of everything
* Part of Equinox Desktop Environment (EDE).
* Copyright (c) 2007-2009 EDE Authors.
*
* This program is licensed under terms of the
* GNU General Public License version 2 or newer.
* See COPYING for details.
*/
#include <string.h>
#include <edelib/XSettingsClient.h>
#include <edelib/Debug.h>
#include "SettingsApplicator.h"
EDELIB_NS_USING(XSettingsClient)
EDELIB_NS_USING(XSettingsAction)
EDELIB_NS_USING(XSettingsSetting)
EDELIB_NS_USING(XSETTINGS_ACTION_NEW)
EDELIB_NS_USING(XSETTINGS_ACTION_CHANGED)
EDELIB_NS_USING(XSETTINGS_ACTION_DELETED)
EDELIB_NS_USING(XSETTINGS_TYPE_INT)
static XSettingsClient* client = NULL;
static Display* client_display = NULL;
static int client_screen;
static void xsettings_cb(const char* name, XSettingsAction a, XSettingsSetting* s, void* data) {
if(!client)
return;
if(strcmp(name, "Bell/Volume") == 0 && s->type == XSETTINGS_TYPE_INT) {
XKeyboardControl kc;
kc.bell_percent = s->data.v_int;
XChangeKeyboardControl(client_display, KBBellPercent, &kc);
return;
}
if(strcmp(name, "Bell/Pitch") == 0 && s->type == XSETTINGS_TYPE_INT) {
XKeyboardControl kc;
kc.bell_pitch = s->data.v_int;
XChangeKeyboardControl(client_display, KBBellPitch, &kc);
return;
}
if(strcmp(name, "Bell/Duration") == 0 && s->type == XSETTINGS_TYPE_INT) {
XKeyboardControl kc;
kc.bell_duration = s->data.v_int;
XChangeKeyboardControl(client_display, KBBellDuration, &kc);
return;
}
}
void xsettings_applicator_init(Display* dpy, int scr) {
/*
* make sure we set display first, because after 'init()' callback
* will be imediately called
*/
client_display = dpy;
client_screen = scr;
client = new XSettingsClient;
if(!client->init(dpy, scr, xsettings_cb, NULL)) {
delete client;
client = NULL;
return;
}
}
void xsettings_applicator_shutdown(void) {
delete client;
client = NULL;
}
void xsettings_applicator_process_event(const XEvent* xev) {
if(client)
client->process_xevent(xev);
}

View File

@ -0,0 +1,26 @@
/*
* $Id$
*
* Evoke, head honcho of everything
* Part of Equinox Desktop Environment (EDE).
* Copyright (c) 2007-2009 EDE Authors.
*
* This program is licensed under terms of the
* GNU General Public License version 2 or newer.
* See COPYING for details.
*/
#ifndef __SETTINGSAPPLICATOR_H__
#define __SETTINGSAPPLICATOR_H__
#include <X11/Xlib.h>
/*
* Settings applicator are bunch of functions to run XSettingsClient
* and apply known settings.
*/
void xsettings_applicator_init(Display* dpy, int scr);
void xsettings_applicator_shutdown(void);
void xsettings_applicator_process_event(const XEvent* xev);
#endif