diff options
author | onestone <onestone> | 2006-12-07 00:54:55 +0000 |
---|---|---|
committer | onestone <onestone> | 2006-12-07 00:54:55 +0000 |
commit | e02162a4315bc27567a195b3851de10ada6e184f (patch) | |
tree | f661d934cbcaf28db2a141cabd82fc17820e6730 | |
parent | 367f29f773d711747a76facbf5335cbafda73826 (diff) | |
download | aquamarine-e02162a4315bc27567a195b3851de10ada6e184f.tar.gz aquamarine-e02162a4315bc27567a195b3851de10ada6e184f.tar.bz2 |
aquamarine: removed kde integration
kconfig-backend: added kde integrated settings reading
-rw-r--r-- | settings-backend/kconfig_backend.cpp | 356 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/aquamarine.cpp | 3 | ||||
-rw-r--r-- | src/decorator.cpp | 23 | ||||
-rw-r--r-- | src/decorator.h | 8 | ||||
-rw-r--r-- | src/integration.cpp | 338 | ||||
-rw-r--r-- | src/integration.h | 67 |
7 files changed, 350 insertions, 448 deletions
diff --git a/settings-backend/kconfig_backend.cpp b/settings-backend/kconfig_backend.cpp index 8e900be..a4154ec 100644 --- a/settings-backend/kconfig_backend.cpp +++ b/settings-backend/kconfig_backend.cpp @@ -1,9 +1,3 @@ -#include <kconfig.h> -#include <ksimpleconfig.h> -#include <kdebug.h> -#include <kinstance.h> -#include <stdlib.h> - /* * Aquamarine the KDE window decorator * @@ -25,6 +19,13 @@ * */ +#include <kconfig.h> +#include <ksimpleconfig.h> +#include <kdebug.h> +#include <kinstance.h> +#include <kshortcut.h> +#include <stdlib.h> + extern "C" { #include <beryl-settings-backend.h> } @@ -42,9 +43,300 @@ const static char *edgeName[] = { "BottomRight" }; +const static char *fspLevel[] = { + "None", + "Low", + "Normal", + "High", + "Extreme" +}; + +typedef struct _ConfigFiles { + KSimpleConfig *beryl; + KConfig *kwin; + KConfig *global; +} ConfigFiles; + +typedef enum { + OptionInt, + OptionBool, + OptionKey, + OptionSpecial +} SpecialOptionType; + +struct _SpecialOption { + QString berylName; + QString berylPlugin; + QString kdeName; + bool global; + SpecialOptionType type; +} const specialOptions[] = { + {"close_window", NULL, "Window Close", true, OptionKey}, + {"run", NULL, "Run Command", true, OptionKey}, + {"main_menu", NULL, "Popup Launch Menu", true, OptionKey}, + {"lower_window", NULL, "Window Lower", true, OptionKey}, + {"toggle_window_maximized", NULL, "Window Maximize", true, OptionKey}, + {"minimize_window", NULL, "Window Minimize", true, OptionKey}, + {"toggle_maximize_window_horizontally", NULL, "Window Maximize Horizontal", true, OptionKey}, + {"toggle_maximize_window_vertically", NULL, "Window Maximize Vertical", true, OptionKey}, + {"show_desktop", NULL, "Toggle Showing Desktop", true, OptionKey}, + {"run_command_screenshot", NULL, "Desktop Screenshot", true, OptionKey}, + {"run_command_window_screenshot", NULL, "Window Screenshot", true, OptionKey}, + {"window_menu", NULL, "Window Operations Menu", true, OptionKey}, + {"toggle_window_shaded", NULL, "Window Shade", true, OptionKey}, + {"raise_window", NULL, "Window Raise", true, OptionKey}, + {"toggle_window_fullscreen", NULL, "Window Fullscreen", true, OptionKey}, + {"run_command11", NULL, "Kill Window", true, OptionKey}, + {"initiate", "move", "Window Move", true, OptionKey}, + {"initiate", "resize", "Window Resize", true, OptionKey}, + {"rotate_right", "rotate", "Switch to Next Desktop", true, OptionKey}, + {"rotate_left", "rotate", "Switch to Previous Desktop", true, OptionKey}, + {"rotate_to_1", "rotate", "Switch to Desktop 1", true, OptionKey}, + {"rotate_to_2", "rotate", "Switch to Desktop 2", true, OptionKey}, + {"rotate_to_3", "rotate", "Switch to Desktop 3", true, OptionKey}, + {"rotate_to_4", "rotate", "Switch to Desktop 4", true, OptionKey}, + {"rotate_to_5", "rotate", "Switch to Desktop 5", true, OptionKey}, + {"rotate_to_6", "rotate", "Switch to Desktop 6", true, OptionKey}, + {"rotate_to_7", "rotate", "Switch to Desktop 7", true, OptionKey}, + {"rotate_to_8", "rotate", "Switch to Desktop 8", true, OptionKey}, + {"rotate_to_9", "rotate", "Switch to Desktop 9", true, OptionKey}, + {"rotate_to_10", "rotate", "Switch to Desktop 10", true, OptionKey}, + {"rotate_to_11", "rotate", "Switch to Desktop 11", true, OptionKey}, + {"rotate_to_12", "rotate", "Switch to Desktop 12", true, OptionKey}, + + {"rotate_right_window", "rotate", "Window to Next Desktop", true, OptionKey}, + {"rotate_left_window", "rotate", "Window to Previous Desktop", true, OptionKey}, + {"rotate_to_1_window", "rotate", "Window to Desktop 1", true, OptionKey}, + {"rotate_to_2_window", "rotate", "Window to Desktop 2", true, OptionKey}, + {"rotate_to_3_window", "rotate", "Window to Desktop 3", true, OptionKey}, + {"rotate_to_4_window", "rotate", "Window to Desktop 4", true, OptionKey}, + {"rotate_to_5_window", "rotate", "Window to Desktop 5", true, OptionKey}, + {"rotate_to_6_window", "rotate", "Window to Desktop 6", true, OptionKey}, + {"rotate_to_7_window", "rotate", "Window to Desktop 7", true, OptionKey}, + {"rotate_to_8_window", "rotate", "Window to Desktop 8", true, OptionKey}, + {"rotate_to_9_window", "rotate", "Window to Desktop 9", true, OptionKey}, + {"rotate_to_10_window", "rotate", "Window to Desktop 10", true, OptionKey}, + {"rotate_to_11_window", "rotate", "Window to Desktop 11", true, OptionKey}, + {"rotate_to_12_window", "rotate", "Window to Desktop 12", true, OptionKey}, + + {"plane_up", "plane", "Switch One Desktop Up", true, OptionKey}, + {"plane_down", "plane", "Switch One Desktop Down", true, OptionKey}, + {"plane_left", "plane", "Switch One Desktop to the Left", true, OptionKey}, + {"plane_right", "plane", "Switch One Desktop to the Right", true, OptionKey}, + + {"plane_to_1", "plane", "Switch to Desktop 1", true, OptionKey}, + {"plane_to_2", "plane", "Switch to Desktop 2", true, OptionKey}, + {"plane_to_3", "plane", "Switch to Desktop 3", true, OptionKey}, + {"plane_to_4", "plane", "Switch to Desktop 4", true, OptionKey}, + {"plane_to_5", "plane", "Switch to Desktop 5", true, OptionKey}, + {"plane_to_6", "plane", "Switch to Desktop 6", true, OptionKey}, + {"plane_to_7", "plane", "Switch to Desktop 7", true, OptionKey}, + {"plane_to_8", "plane", "Switch to Desktop 8", true, OptionKey}, + {"plane_to_9", "plane", "Switch to Desktop 9", true, OptionKey}, + {"plane_to_10", "plane", "Switch to Desktop 10", true, OptionKey}, + {"plane_to_11", "plane", "Switch to Desktop 11", true, OptionKey}, + {"plane_to_12", "plane", "Switch to Desktop 12", true, OptionKey}, + + {"next", "switcher", "Walk Through Windows", true, OptionKey}, + {"prev", "switcher", "Walk Through Windows (Reverse)", true, OptionKey}, + + {"autoraise", NULL, "AutoRaise", false, OptionBool}, + {"raise_on_click", NULL, "ClickRaise", false, OptionBool}, + {"snapoff_maximized", "move", "MoveResizeMaximizedWindows", false, OptionBool}, + + {"autoraise_delay", NULL, "AutoRaiseInterval", false, OptionInt}, + + {"command_screenshot", NULL, NULL, true, OptionSpecial}, + {"command_window_screenshot", NULL, NULL, true, OptionSpecial}, + {"unmaximize_window", NULL, NULL, true, OptionSpecial}, + {"maximize_window", NULL, NULL, true, OptionSpecial}, + {"maximize_window_horizontally", NULL, NULL, true, OptionSpecial}, + {"maximize_window_vertically", NULL, NULL, true, OptionSpecial}, + {"command11", NULL, NULL, true, OptionSpecial}, + {"click_to_focus", NULL, NULL, false, OptionSpecial}, + {"focus_stealing_prevention_level", NULL, NULL, false, OptionSpecial}, + {"number_of_desktops", NULL, "Number", false, OptionSpecial}, + {"resize_mode", "resize", NULL, true, OptionSpecial}, +}; + +#define N_SOPTIONS (sizeof (specialOptions) / sizeof (struct _SpecialOption)) + +static bool isIntegratedOption(BerylSetting * setting) +{ + + for (unsigned int i = 0; i < N_SOPTIONS; i++) + { + if (setting->name == specialOptions[i].berylName && + QString(setting->parent->name) == specialOptions[i].berylPlugin) + return true; + } + return false; +} + +static void KdeIntToBeryl (ConfigFiles *cFiles, BerylSetting * setting, int num) +{ + KConfig *cfg = (specialOptions[num].global)?cFiles->global:cFiles->kwin; + + int val = cfg->readNumEntry(specialOptions[num].kdeName); + + beryl_setting_value_set_int(&setting->value,&val); +} + +static void KdeBoolToBeryl (ConfigFiles *cFiles, BerylSetting * setting, int num) +{ + KConfig *cfg = (specialOptions[num].global)?cFiles->global:cFiles->kwin; + + Bool val = (cfg->readBoolEntry(specialOptions[num].kdeName))?TRUE:FALSE; + + beryl_setting_value_set_bool(&setting->value,&val); +} + +static void KdeKeyToBeryl (ConfigFiles *cFiles, BerylSetting * setting, int num) +{ + KConfig *cfg = (specialOptions[num].global)?cFiles->global:cFiles->kwin; + + KKey key(cfg->readEntry(specialOptions[num].kdeName)); + + gboolean kde_enabled = !key.isNull(); + + int kde_keysym = key.sym(); + int kde_keymod = 0; + + if (key.modFlags() & KKey::SHIFT) + kde_keymod |= ShiftMask; + if (key.modFlags() & KKey::CTRL) + kde_keymod |= ControlMask; + if (key.modFlags() & KKey::ALT) + kde_keymod |= CompAltMask; + if (key.modFlags() & KKey::WIN) + kde_keymod |= CompSuperMask; + + + if (kde_enabled) + { + beryl_setting_value_set_keysym(&setting->value,&kde_keysym); + beryl_setting_value_set_keymods(&setting->value,&kde_keymod); + beryl_setting_value_set_key_enabled(&setting->value,&kde_enabled); + } + else + { + char * sval = NULL; + if (cFiles->beryl->hasKey(specialOptions[num].berylName + "_key (Integrated)")) + sval = strdup(cFiles->beryl->readEntry(specialOptions[num].berylName + "_key (Integrated)").ascii()); + + int keysym = 0; + int keymods = 0; + gchar * spos = NULL; + if (sval) keymods = beryl_settings_get_mods_and_endptr(sval,&spos); + if (spos && *spos) + { + keysym=XStringToKeysym(spos); + } + beryl_setting_value_set_keysym(&setting->value,&keysym); + beryl_setting_value_set_keymods(&setting->value,&keymods); + beryl_setting_value_set_key_enabled(&setting->value,&kde_enabled); + delete sval; + } +} + +static void readIntegratedOption(ConfigFiles *cFiles, BerylSetting * setting) +{ + int option = 0; + for (unsigned int i = 0; i < N_SOPTIONS; i++) + { + if (setting->name == specialOptions[i].berylName && + QString(setting->parent->name) == specialOptions[i].berylPlugin) + { + option = i; + break; + } + } + setting->is_default=FALSE; + switch (specialOptions[option].type) + { + case OptionInt: + KdeIntToBeryl (cFiles, setting, option); + break; + case OptionBool: + KdeBoolToBeryl (cFiles, setting, option); + break; + case OptionKey: + KdeKeyToBeryl (cFiles, setting, option); + break; + case OptionSpecial: + if (specialOptions[option].berylName == "command_screenshot") + { + setting->value.value.as_string = + g_strdup("ksnapshot"); + } + if (specialOptions[option].berylName == "command_window_screenshot") + { + setting->value.value.as_string = + g_strdup("ksnapshot -c"); + } + if (specialOptions[option].berylName == "command11") + { + setting->value.value.as_string = + g_strdup("xkill"); + } + if (specialOptions[option].berylName == "unmaximize_window" + || specialOptions[option].berylName == "maximize_window" + || specialOptions[option].berylName == "maximize_window_horizontally" + || specialOptions[option].berylName == "maximize_window_vertically") + { + int val = 0; + beryl_setting_value_set_keysym(&setting->value,&val); + beryl_setting_value_set_keymods(&setting->value,&val); + beryl_setting_value_set_key_enabled(&setting->value,&val); + } + if (specialOptions[option].berylName == "click_to_focus") + { + setting->value.value.as_string = g_strdup("xkill"); + } + 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]); + } + if (specialOptions[option].berylName == "number_of_desktops") + { + cFiles->kwin->setGroup("Desktops"); + KdeIntToBeryl (cFiles, setting, option); + cFiles->kwin->setGroup("Windows"); + } + if (specialOptions[option].berylName == "resize_mode") + { + QString mode = cFiles->kwin->readEntry("ResizeMode"); + QString imode; + QString result = "Normal"; + if (cFiles->beryl->hasKey(specialOptions[option].berylName + " (Integrated)")) + imode = cFiles->beryl->readEntry(specialOptions[option].berylName + " (Integrated)"); + + if (mode == "Opaque") + { + result = "Normal"; + if (imode == "Stretch") + result = "Stretch"; + } + else if (mode == "Transparent") + { + result = "Outline"; + if (imode == "Filled Outline") + result = "Filled Outline"; + } + setting->value.value.as_string = g_strdup(result.ascii()); + } + break; + default: + break; + } +} + void read_setting(BerylSettingsContext * c, BerylSetting * setting) { - KSimpleConfig *cfg = (KSimpleConfig *)c->backend_private_ptr; + ConfigFiles *cFiles = (ConfigFiles *)c->backend_private_ptr; + KSimpleConfig *cfg = cFiles->beryl; QString key(setting->name); QString group(setting->parent->name); @@ -52,6 +344,12 @@ void read_setting(BerylSettingsContext * c, BerylSetting * setting) group += "_screen0"; cfg->setGroup(group); + if (isIntegratedOption(setting)) + { + readIntegratedOption(cFiles, setting); + return; + } + if (setting->type != BERYL_SETTING_TYPE_BINDING && !cfg->hasKey(key)) return; @@ -350,7 +648,8 @@ static void copy_color(BerylSettingValue * value, QStringList *list) void write_setting(BerylSettingsContext * c, BerylSetting * setting) { - KSimpleConfig *cfg = (KSimpleConfig *)c->backend_private_ptr; + ConfigFiles *cFiles = (ConfigFiles *)c->backend_private_ptr; + KSimpleConfig *cfg = cFiles->beryl; QString key(setting->name); QString group(setting->parent->name); @@ -358,6 +657,11 @@ void write_setting(BerylSettingsContext * c, BerylSetting * setting) group += "_screen0"; cfg->setGroup(group); + if (isIntegratedOption(setting)) + { + return; + } + if (setting->is_default) { if (cfg->hasKey(key)) @@ -523,16 +827,25 @@ gboolean read_init(BerylSettingsContext * c) if (!instance) instance = new KInstance("beryl-kconfig"); - KSimpleConfig *cfg = new KSimpleConfig("berylrc",true); - c->backend_private_ptr=(void *)cfg; + ConfigFiles *cFiles = new ConfigFiles; + cFiles->beryl = new KSimpleConfig("berylrc",true); + cFiles->kwin = new KConfig("kwinrc",true); + cFiles->global = new KConfig("kdeglobals",true); + cFiles->kwin->setGroup("Windows"); + cFiles->global->setGroup("Global Shortcuts"); + + c->backend_private_ptr=(void *)cFiles; return TRUE; } void read_done(BerylSettingsContext * c) { - KSimpleConfig *cfg = (KSimpleConfig *)c->backend_private_ptr; + ConfigFiles *cFiles = (ConfigFiles *)c->backend_private_ptr; + delete cFiles->beryl; + delete cFiles->kwin; + delete cFiles->global; + delete cFiles; c->backend_private_ptr=NULL; - delete cfg; } gboolean write_init(BerylSettingsContext * c) @@ -540,17 +853,26 @@ gboolean write_init(BerylSettingsContext * c) if (!instance) instance = new KInstance("beryl-kconfig"); - KSimpleConfig *cfg = new KSimpleConfig("berylrc"); - c->backend_private_ptr=(void *)cfg; + ConfigFiles *cFiles = new ConfigFiles; + cFiles->beryl = new KSimpleConfig("berylrc"); + cFiles->kwin = new KConfig("kwinrc"); + cFiles->global = new KConfig("kdeglobals"); + cFiles->kwin->setGroup("Windows"); + cFiles->global->setGroup("Global Shortcuts"); + + c->backend_private_ptr=(void *)cFiles; return TRUE; } void write_done(BerylSettingsContext * c) { - KSimpleConfig *cfg = (KSimpleConfig *)c->backend_private_ptr; + ConfigFiles *cFiles = (ConfigFiles *)c->backend_private_ptr; + cFiles->beryl->sync(); + delete cFiles->beryl; + delete cFiles->kwin; + delete cFiles->global; + delete cFiles; c->backend_private_ptr=NULL; - cfg->sync(); - delete cfg; } diff --git a/src/Makefile.am b/src/Makefile.am index d7d18fb..e6fefd0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,8 +8,7 @@ aquamarine_SOURCES = aquamarine.cpp \ window.cpp \ switcher.cpp \ KWinInterface.skel \ - options.cpp \ - integration.cpp + options.cpp aquamarine_LDADD = $(LIB_KDECORE) -lkdecorations $(BERYLSETTINGS_LIBS) aquamarine_LDFLAGS = $(all_libraries) diff --git a/src/aquamarine.cpp b/src/aquamarine.cpp index 3e9718a..716f263 100644 --- a/src/aquamarine.cpp +++ b/src/aquamarine.cpp @@ -49,9 +49,6 @@ static const KCmdLineOptions options[] = { {"replace", "Replace existing window decorator", 0}, {"deco <deco>", "Decoration", 0}, -#ifdef HAVE_BERYL_SETTINGS - {"integration", "Integrate KDE settings into Beryl", 0}, -#endif KCmdLineLastOption }; diff --git a/src/decorator.cpp b/src/decorator.cpp index 09b7c04..3176512 100644 --- a/src/decorator.cpp +++ b/src/decorator.cpp @@ -40,10 +40,17 @@ #include "decorator.h" #include "options.h" #include "utils.h" -#include "integration.h" #include <stdio.h> +#ifdef HAVE_BERYL_SETTINGS + +extern "C" { +#include <beryl-settings.h> +} + +#endif + #define GRAVITY_WEST (1 << 0) #define GRAVITY_EAST (1 << 1) #define GRAVITY_NORTH (1 << 2) @@ -125,14 +132,6 @@ m_kwinmodule (new KWinModule (this, KWinModule::INFO_ALL)), m_switcher (0) m_config = new KConfig ("kwinrc"); m_config->setGroup ("Style"); -#ifdef HAVE_BERYL_SETTINGS - m_integrate = args->isSet ("integration"); - printf("Integration : %s\n",m_integrate? "Enabled" : "Disabled"); - if (m_integrate) - { - m_integration = new Aquamarine::Integration (); - } -#endif connect (this, SIGNAL (settingsChanged (int)), SLOT (slotSettingsChanged (int))); @@ -463,8 +462,7 @@ Aquamarine::Decorator::reconfigure () changed = m_options->updateSettings (); #ifdef HAVE_BERYL_SETTINGS - if (m_integrate) - m_integration->updateSettings(); + beryl_settings_send_reload_signal(); #endif if (m_plugins->reset (changed)) @@ -483,8 +481,7 @@ Aquamarine::Decorator::slotSettingsChanged (int) { kdDebug () << k_funcinfo << endl; #ifdef HAVE_BERYL_SETTINGS - if (m_integrate) - m_integration->updateSettings(); + beryl_settings_send_reload_signal(); #endif } diff --git a/src/decorator.h b/src/decorator.h index 8100b40..c55d1dc 100644 --- a/src/decorator.h +++ b/src/decorator.h @@ -69,10 +69,6 @@ namespace Aquamarine class Options; class Switcher; -#ifdef HAVE_BERYL_SETTINGS - class Integration; -#endif - class PluginManager:public KDecorationPlugins { public: @@ -163,10 +159,6 @@ namespace Aquamarine WId m_activeWM; bool m_restart; -#ifdef HAVE_BERYL_SETTINGS - bool m_integrate; - Aquamarine::Integration * m_integration; -#endif }; } diff --git a/src/integration.cpp b/src/integration.cpp deleted file mode 100644 index a068f3d..0000000 --- a/src/integration.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Aquamarine the KDE window decorator - * - * Copyright (c) 2006 Dennis Kasprzyk <onestone@beryl-project.org> - * Copyright (c) 2006 Volker Krause <vkrause@kde.org> - * - * Uses code of: - * Emerald window decorator (www.beryl-project.org) - * gtk-window-decorator (www.freedesktop.org/wiki/Software/Compiz) - * KWin window manager (www.kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif - -#ifdef HAVE_BERYL_SETTINGS - -#include <kconfig.h> -#include <kshortcut.h> -#include <kdebug.h> - -#include "integration.h" - -Aquamarine::Integration::Integration () -{ - updateSettings (); -} - -void -Aquamarine::Integration::updateSettings () -{ - KConfig *gc = new KConfig("kdeglobals",false,false); - KConfig *kwc = new KConfig("kwinrc",false); - gc->setGroup("Global Shortcuts"); - kwc->setGroup("Windows"); - - BerylSettingsContext *settings = beryl_settings_context_new(); - beryl_settings_context_read(settings); - - BerylSettingsPlugin *core,*move,*resize,*rotate,*plane,*switcher; - core = beryl_settings_context_find_plugin(settings, NULL); - move = beryl_settings_context_find_plugin(settings, "move"); - resize = beryl_settings_context_find_plugin(settings, "resize"); - rotate = beryl_settings_context_find_plugin(settings, "rotate"); - plane = beryl_settings_context_find_plugin(settings, "plane"); - switcher = beryl_settings_context_find_plugin(settings, "switcher"); - - bool changed = false; - - // core - changed |= KdeKeyToBeryl(gc->readEntry("Window Close"), core, "close_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Run Command"), core, "run"); - changed |= KdeKeyToBeryl(gc->readEntry("Popup Launch Menu"), core, "main_menu"); - changed |= KdeKeyToBeryl(gc->readEntry("Window Lower"), core, "lower_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window Maximize"), core, "toggle_window_maximized"); - changed |= KdeKeyToBeryl(gc->readEntry("Window Minimize"), core, "minimize_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window Maximize Horizontal"), core, "toggle_maximize_window_horizontally"); - changed |= KdeKeyToBeryl(gc->readEntry("Window Maximize Vertical"), core, "toggle_maximize_window_vertically"); - changed |= KdeKeyToBeryl(gc->readEntry("Toggle Showing Desktop"), core, "show_desktop"); - changed |= KdeKeyToBeryl(gc->readEntry("Desktop Screenshot"), core, "run_command_screenshot"); - changed |= KdeStrToBeryl("ksnapshot", core, "command_screenshot"); - changed |= KdeKeyToBeryl(gc->readEntry("Window Screenshot"), core, "run_command_window_screenshot"); - changed |= KdeStrToBeryl("ksnapshot -c", core, "command_window_screenshot"); - changed |= KdeKeyToBeryl(gc->readEntry("Window Operations Menu"), core, "window_menu"); - changed |= KdeKeyToBeryl(gc->readEntry("Window Shade"), core, "toggle_window_shaded"); - changed |= KdeKeyToBeryl(gc->readEntry("Window Raise"), core, "raise_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window Fullscreen"), core, "toggle_window_fullscreen"); - - changed |= KdeKeyToBeryl("none", core, "unmaximize_window"); - changed |= KdeKeyToBeryl("none", core, "maximize_window"); - changed |= KdeKeyToBeryl("none", core, "maximize_window_horizontally"); - changed |= KdeKeyToBeryl("none", core, "maximize_window_vertically"); - - changed |= KdeStrToBeryl("xkill", core, "command11"); - changed |= KdeKeyToBeryl(gc->readEntry("Kill Window"), core, "run_command11"); - - changed |= KdeBoolToBeryl(kwc->readBoolEntry("AutoRaise"), core, "autoraise"); - changed |= KdeIntToBeryl(kwc->readNumEntry("AutoRaiseInterval"), core, "autoraise_delay"); - changed |= KdeBoolToBeryl(kwc->readBoolEntry("ClickRaise"), core, "raise_on_click"); - changed |= KdeBoolToBeryl(kwc->readEntry("FocusPolicy") == "ClickToFocus", core, "click_to_focus"); - - switch (kwc->readNumEntry("FocusStealingPreventionLevel")) - { - case 1: - changed |= KdeStrToBeryl("Low", core, "focus_stealing_prevention_level"); - break; - case 2: - changed |= KdeStrToBeryl("Normal", core, "focus_stealing_prevention_level"); - break; - case 3: - changed |= KdeStrToBeryl("High", core, "focus_stealing_prevention_level"); - break; - case 4: - changed |= KdeStrToBeryl("Extreme", core, "focus_stealing_prevention_level"); - break; - default: - changed |= KdeStrToBeryl("None", core, "focus_stealing_prevention_level"); - break; - } - - kwc->setGroup("Desktops"); - changed |= KdeIntToBeryl(kwc->readNumEntry("Number"), core, "number_of_desktops"); - kwc->setGroup("Windows"); - - // move - changed |= KdeBoolToBeryl(kwc->readBoolEntry("MoveResizeMaximizedWindows"), move, "snapoff_maximized"); - changed |= KdeKeyToBeryl(gc->readEntry("Window Move"), move, "initiate"); - - // resize - if (kwc->readEntry("ResizeMode") == "Opaque") - changed |= KdeStrToBeryl("Normal", resize, "resize_mode"); - else if (kwc->readEntry("ResizeMode") == "Transparent") - changed |= KdeStrToBeryl("Outline", resize, "resize_mode"); - changed |= KdeKeyToBeryl(gc->readEntry("Window Resize"), resize, "initiate"); - - // rotate - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Next Desktop"), rotate, "rotate_right"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Previous Desktop"), rotate, "rotate_left"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 1"), rotate, "rotate_to_1"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 2"), rotate, "rotate_to_2"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 3"), rotate, "rotate_to_3"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 4"), rotate, "rotate_to_4"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 5"), rotate, "rotate_to_5"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 6"), rotate, "rotate_to_6"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 7"), rotate, "rotate_to_7"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 8"), rotate, "rotate_to_8"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 9"), rotate, "rotate_to_9"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 10"), rotate, "rotate_to_10"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 11"), rotate, "rotate_to_11"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 12"), rotate, "rotate_to_12"); - - changed |= KdeKeyToBeryl(gc->readEntry("Window to Next Desktop"), rotate, "rotate_right_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Previous Desktop"), rotate, "rotate_left_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Desktop 1"), rotate, "rotate_to_1_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Desktop 2"), rotate, "rotate_to_2_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Desktop 3"), rotate, "rotate_to_3_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Desktop 4"), rotate, "rotate_to_4_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Desktop 5"), rotate, "rotate_to_5_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Desktop 6"), rotate, "rotate_to_6_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Desktop 7"), rotate, "rotate_to_7_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Desktop 8"), rotate, "rotate_to_8_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Desktop 9"), rotate, "rotate_to_9_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Desktop 10"), rotate, "rotate_to_10_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Desktop 11"), rotate, "rotate_to_11_window"); - changed |= KdeKeyToBeryl(gc->readEntry("Window to Desktop 12"), rotate, "rotate_to_12_window"); - - // plane - changed |= KdeKeyToBeryl(gc->readEntry("Switch One Desktop Up"), rotate, "plane_up"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch One Desktop Down"), rotate, "plane_down"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch One Desktop to the Left"), rotate, "plane_left"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch One Desktop to the Right"), rotate, "plane_right"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 1"), rotate, "plane_to_1"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 2"), rotate, "plane_to_2"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 3"), rotate, "plane_to_3"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 4"), rotate, "plane_to_4"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 5"), rotate, "plane_to_5"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 6"), rotate, "plane_to_6"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 7"), rotate, "plane_to_7"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 8"), rotate, "plane_to_8"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 9"), rotate, "plane_to_9"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 10"), rotate, "plane_to_10"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 11"), rotate, "plane_to_11"); - changed |= KdeKeyToBeryl(gc->readEntry("Switch to Desktop 12"), rotate, "plane_to_12"); - - // switcher - changed |= KdeKeyToBeryl(gc->readEntry("Walk Through Windows"), switcher, "next"); - changed |= KdeKeyToBeryl(gc->readEntry("Walk Through Windows (Reverse)"), switcher, "prev"); - - if (changed) - { - beryl_settings_context_write(settings); - beryl_settings_send_reload_signal(); - } - - beryl_settings_context_destroy(settings); - delete gc; - delete kwc; -} - -bool Aquamarine::Integration::KdeKeyToBeryl (QString keyString, BerylSettingsPlugin * plugin, char * beryl_name) -{ - if (!plugin) - return false; - - BerylSetting *setting; - - KKey key(keyString); - - setting = beryl_settings_plugin_find_setting(plugin, beryl_name, FALSE); - if (!setting) - return false; - - gint keysym; - gint keymod; - gboolean enabled; - beryl_setting_value_get_keysym(&setting->value,&keysym); - beryl_setting_value_get_keymods(&setting->value,&keymod); - beryl_setting_value_get_key_enabled(&setting->value,&enabled); - - gboolean kde_enabled = !key.isNull(); - int kde_keysym = key.sym(); - int kde_keymod = 0; - - if (key.modFlags() & KKey::SHIFT) - kde_keymod |= ShiftMask; - if (key.modFlags() & KKey::CTRL) - kde_keymod |= ControlMask; - if (key.modFlags() & KKey::ALT) - kde_keymod |= CompAltMask; - if (key.modFlags() & KKey::WIN) - kde_keymod |= CompSuperMask; - - if (keysym != kde_keysym || keymod != kde_keymod || enabled != kde_enabled) - { - kdDebug () << "Changing keybinding for \"" << beryl_name << "\" to \"" - << key.toString() << "\"" << endl; - beryl_setting_value_set_keysym(&setting->value,&kde_keysym); - beryl_setting_value_set_keymods(&setting->value,&kde_keymod); - beryl_setting_value_set_key_enabled(&setting->value,&kde_enabled); - return true; - } - else - { - kdDebug () << "Keybinding \"" << key.toString() << "\" for \"" << beryl_name - << "\" is already set in Beryl" << endl; - return false; - } -} - -bool Aquamarine::Integration::KdeStrToBeryl (QString val, BerylSettingsPlugin * plugin, char * beryl_name) -{ - if (!plugin) - return false; - - BerylSetting *setting; - - setting = beryl_settings_plugin_find_setting(plugin, beryl_name, FALSE); - if (!setting) - return false; - - const gchar *bstr; - beryl_setting_value_get_string(&setting->value,&bstr); - - QString berylStr(bstr); - - if (berylStr != val) - { - kdDebug () << "Changing string value for \"" << beryl_name << "\" to \"" - << val << "\"" << endl; - const gchar *to = val.ascii(); - beryl_setting_value_set_string(&setting->value,&to); - return true; - } - else - { - kdDebug () << "String value \"" << val << "\" for \"" << beryl_name - << "\" is already set in Beryl" << endl; - return false; - } -} - -bool Aquamarine::Integration::KdeBoolToBeryl (bool val, BerylSettingsPlugin * plugin, char * beryl_name) -{ - if (!plugin) - return false; - - BerylSetting *setting; - - setting = beryl_settings_plugin_find_setting(plugin, beryl_name, FALSE); - if (!setting) - return false; - - gboolean bbool; - beryl_setting_value_get_bool(&setting->value,&bbool); - - gboolean berylBool = val; - - if (berylBool != bbool) - { - kdDebug () << "Changing bool value for \"" << beryl_name << "\" to \"" - << val << "\"" << endl; - beryl_setting_value_set_bool(&setting->value,&berylBool); - return true; - } - else - { - kdDebug () << "Bool value \"" << val << "\" for \"" << beryl_name - << "\" is already set in Beryl" << endl; - return false; - } -} - -bool Aquamarine::Integration::KdeIntToBeryl (int val, BerylSettingsPlugin * plugin, char * beryl_name) -{ - if (!plugin) - return false; - - BerylSetting *setting; - - setting = beryl_settings_plugin_find_setting(plugin, beryl_name, FALSE); - if (!setting) - return false; - - gint bint; - beryl_setting_value_get_bool(&setting->value,&bint); - - if (bint != val) - { - kdDebug () << "Changing int value for \"" << beryl_name << "\" to \"" - << val << "\"" << endl; - beryl_setting_value_set_int(&setting->value,&val); - return true; - } - else - { - kdDebug () << "Int value \"" << val << "\" for \"" << beryl_name - << "\" is already set in Beryl" << endl; - return false; - } -} - -#endif diff --git a/src/integration.h b/src/integration.h deleted file mode 100644 index db76763..0000000 --- a/src/integration.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Aquamarine the KDE window decorator - * - * Copyright (c) 2006 Dennis Kasprzyk <onestone@beryl-project.org> - * Copyright (c) 2006 Volker Krause <vkrause@kde.org> - * - * Uses code of: - * Emerald window decorator (www.beryl-project.org) - * gtk-window-decorator (www.freedesktop.org/wiki/Software/Compiz) - * KWin window manager (www.kde.org) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - - - -#ifndef AQUAMARINE_INTEGRATION_H -#define AQUAMARINE_INTEGRATION_H - -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif - -#ifdef HAVE_BERYL_SETTINGS - -extern "C" { -#include <beryl-settings.h> -} - -class KConfig; - -namespace Aquamarine -{ - - class Integration - { - public: - - Integration (); - - void updateSettings (); - - private: - - bool KdeKeyToBeryl (QString keyString, BerylSettingsPlugin * plugin, char * beryl_name); - bool KdeStrToBeryl (QString val, BerylSettingsPlugin * plugin, char * beryl_name); - bool KdeBoolToBeryl (bool val, BerylSettingsPlugin * plugin, char * beryl_name); - bool KdeIntToBeryl (int val, BerylSettingsPlugin * plugin, char * beryl_name); - }; - -} - -#endif -#endif |