summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--settings-backend/kconfig_backend.cpp149
1 files changed, 137 insertions, 12 deletions
diff --git a/settings-backend/kconfig_backend.cpp b/settings-backend/kconfig_backend.cpp
index 9104776..ad9ef87 100644
--- a/settings-backend/kconfig_backend.cpp
+++ b/settings-backend/kconfig_backend.cpp
@@ -24,6 +24,9 @@
#include <kdebug.h>
#include <kinstance.h>
#include <kshortcut.h>
+#include <kipc.h>
+#include <kapplication.h>
+#include <dcopclient.h>
#include <stdlib.h>
extern "C" {
@@ -648,6 +651,90 @@ static void copy_color(BerylSettingValue * value, QStringList *list)
list->append(color);
}
+static void BerylIntToKde (ConfigFiles *cFiles, BerylSetting * setting, int num)
+{
+ KConfig *cfg = (specialOptions[num].global)?cFiles->global:cFiles->kwin;
+
+ int val = setting->value.value.as_int;
+
+ if (cfg->readNumEntry(specialOptions[num].kdeName) != val)
+ {
+ cFiles->modified = true;
+ cfg->writeEntry(specialOptions[num].kdeName,val);
+ }
+}
+
+static void BerylBoolToKde (ConfigFiles *cFiles, BerylSetting * setting, int num)
+{
+ KConfig *cfg = (specialOptions[num].global)?cFiles->global:cFiles->kwin;
+
+ bool val = setting->value.value.as_bool;
+
+ if (cfg->readBoolEntry(specialOptions[num].kdeName) != val)
+ {
+ cFiles->modified = true;
+ cfg->writeEntry(specialOptions[num].kdeName,val);
+ }
+}
+
+static void BerylKeyToKde (ConfigFiles *cFiles, BerylSetting * setting, int num)
+{
+ KConfig *cfg = (specialOptions[num].global)?cFiles->global:cFiles->kwin;
+
+ Bool enabled = FALSE;
+ int keysym = 0;
+ int keymod = 0;
+
+ beryl_setting_value_get_key_enabled(&setting->value,&enabled);
+ beryl_setting_value_get_keymods(&setting->value,&keymod);
+ // do not store only modifiers
+ if (!beryl_setting_value_get_keysym(&setting->value,&keysym))
+ enabled = FALSE;
+
+ int kde_keymod = 0;
+
+ if (keymod & ShiftMask)
+ kde_keymod |= KKey::SHIFT;
+ if (keymod & ControlMask)
+ kde_keymod |= KKey::CTRL;
+ if (keymod & CompAltMask)
+ kde_keymod |= KKey::ALT;
+ if (keymod & CompSuperMask)
+ kde_keymod |= KKey::WIN;
+
+ KKey key(keysym, kde_keymod);
+ KKey akey(cfg->readEntry(specialOptions[num].kdeName));
+
+ if (enabled && akey != key)
+ {
+ cFiles->modified = true;
+ cfg->writeEntry(specialOptions[num].kdeName,key.toString());
+ if (cFiles->beryl->hasKey(specialOptions[num].berylName + "_key (Integrated)"))
+ cFiles->beryl->deleteEntry(specialOptions[num].berylName + "_key (Integrated)");
+ }
+ if (!enabled)
+ {
+ if (cfg->readEntry(specialOptions[num].kdeName) != "none")
+ {
+ cFiles->modified = true;
+ cfg->writeEntry(specialOptions[num].kdeName,"none");
+ }
+ gint ire;
+ QString binding;
+ QString keysym;
+
+ if (beryl_setting_value_get_keymods(&setting->value,&ire))
+ binding += beryl_settings_mods_to_string(ire);
+ if (beryl_setting_value_get_keysym(&setting->value,&ire))
+ keysym = XKeysymToString(ire);
+ if (keysym.isEmpty()) keysym = "None";
+
+ binding += keysym;
+ cFiles->beryl->writeEntry(specialOptions[num].berylName + "_key (Integrated)",binding);
+ }
+}
+
+
static void writeIntegratedOption(ConfigFiles *cFiles, BerylSetting * setting)
{
int option = 0;
@@ -664,13 +751,13 @@ static void writeIntegratedOption(ConfigFiles *cFiles, BerylSetting * setting)
switch (specialOptions[option].type)
{
case OptionInt:
-
+ BerylIntToKde(cFiles, setting, option);
break;
case OptionBool:
-
+ BerylBoolToKde(cFiles, setting, option);
break;
case OptionKey:
-
+ BerylKeyToKde(cFiles, setting, option);
break;
case OptionSpecial:
if (specialOptions[option].berylName == "command_screenshot"
@@ -684,23 +771,53 @@ static void writeIntegratedOption(ConfigFiles *cFiles, BerylSetting * setting)
if (specialOptions[option].berylName == "click_to_focus")
{
-
+ QString mode = cFiles->kwin->readEntry("FocusPolicy");
+ QString val = "ClickToFocus";
+ if (!setting->value.value.as_bool)
+ {
+ val = "FocusFollowsMouse";
+ }
+ if (mode != val)
+ {
+ cFiles->modified = true;
+ cFiles->kwin->writeEntry("FocusPolicy",val);
+ }
}
if (specialOptions[option].berylName == "focus_stealing_prevention_level")
{
- //int level = cFiles->kwin->readNumEntry("FocusStealingPreventionLevel");
- //level = MAX(0,MIN(4,level));
- //setting->value.value.as_string = g_strdup(fspLevel[level]);
+ int level = cFiles->kwin->readNumEntry("FocusStealingPreventionLevel");
+ level = MAX(0,MIN(4,level));
+ int val = 0;
+ for (int i = 0; i < 5; i++)
+ if (strcmp(fspLevel[i],setting->value.value.as_string) == 0)
+ val = i;
+ if (val != level)
+ {
+ cFiles->modified = true;
+ cFiles->kwin->writeEntry("FocusStealingPreventionLevel",val);
+ }
}
if (specialOptions[option].berylName == "number_of_desktops")
{
- //cFiles->kwin->setGroup("Desktops");
-
- //cFiles->kwin->setGroup("Windows");
+ cFiles->kwin->setGroup("Desktops");
+ BerylIntToKde(cFiles, setting, option);
+ cFiles->kwin->setGroup("Windows");
}
if (specialOptions[option].berylName == "resize_mode")
{
-
+ QString mode = cFiles->kwin->readEntry("ResizeMode");
+ QString val = "Opaque";
+ if (strcmp(setting->value.value.as_string,"Outline") == 0
+ || strcmp(setting->value.value.as_string,"Filled Outline") == 0)
+ {
+ val = "Transparent";
+ }
+ if (mode != val)
+ {
+ cFiles->modified = true;
+ cFiles->kwin->writeEntry("ResizeMode",val);
+ }
+ cFiles->beryl->writeEntry(specialOptions[option].berylName + " (Integrated)",setting->value.value.as_string);
}
break;
default:
@@ -931,7 +1048,15 @@ gboolean write_init(BerylSettingsContext * c)
void write_done(BerylSettingsContext * c)
{
ConfigFiles *cFiles = (ConfigFiles *)c->backend_private_ptr;
- cFiles->beryl->sync();
+ if (cFiles->modified)
+ {
+ printf("sending command\n");
+ KIPC::sendMessageAll( KIPC::SettingsChanged, KApplication::SETTINGS_SHORTCUTS );
+ DCOPClient *client = kapp->dcopClient();
+ if (!client->isAttached())
+ client->attach();
+ client->send("kwin", "KWinInterface", "reconfigure()", "");
+ }
delete cFiles->beryl;
delete cFiles->kwin;
delete cFiles->global;