diff --git a/evoke/Jamfile b/evoke/Jamfile index 172c5c1..3d67dfa 100644 --- a/evoke/Jamfile +++ b/evoke/Jamfile @@ -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 ; diff --git a/evoke/SettingsApplicator.cpp b/evoke/SettingsApplicator.cpp new file mode 100644 index 0000000..82d4a9e --- /dev/null +++ b/evoke/SettingsApplicator.cpp @@ -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 +#include +#include +#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); +} diff --git a/evoke/SettingsApplicator.h b/evoke/SettingsApplicator.h new file mode 100644 index 0000000..6dd9975 --- /dev/null +++ b/evoke/SettingsApplicator.h @@ -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 + +/* + * 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