diff options
author | onestone <onestone> | 2006-12-05 19:22:19 +0000 |
---|---|---|
committer | onestone <onestone> | 2006-12-05 19:22:19 +0000 |
commit | f9b70c34ce5407ffa23bc0147009b4d3d76b8761 (patch) | |
tree | 7b9ee6866bc78c533b2746778f1f8ca676a3ee7c /src | |
parent | dc255b3c8bc6f921da1d7db8a777dc8239a1c45d (diff) | |
download | aquamarine-f9b70c34ce5407ffa23bc0147009b4d3d76b8761.tar.gz aquamarine-f9b70c34ce5407ffa23bc0147009b4d3d76b8761.tar.bz2 |
aquamarine: Added KDE->Beryl integration
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 8 | ||||
-rw-r--r-- | src/aquamarine.cpp | 3 | ||||
-rw-r--r-- | src/decorator.cpp | 27 | ||||
-rw-r--r-- | src/decorator.h | 16 | ||||
-rw-r--r-- | src/integration.cpp | 338 | ||||
-rw-r--r-- | src/integration.h | 67 |
6 files changed, 456 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 46c704c..d7d18fb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,10 +8,12 @@ aquamarine_SOURCES = aquamarine.cpp \ window.cpp \ switcher.cpp \ KWinInterface.skel \ - options.cpp + options.cpp \ + integration.cpp -aquamarine_LDADD = $(LIB_KDECORE) -lkdecorations -aquamarine_LDFLAGS = $(all_libraries) +aquamarine_LDADD = $(LIB_KDECORE) -lkdecorations $(BERYLSETTINGS_LIBS) +aquamarine_LDFLAGS = $(all_libraries) +KDE_CXXFLAGS = $(BERYLSETTINGS_CFLAGS) METASOURCES = AUTO diff --git a/src/aquamarine.cpp b/src/aquamarine.cpp index 716f263..3e9718a 100644 --- a/src/aquamarine.cpp +++ b/src/aquamarine.cpp @@ -49,6 +49,9 @@ 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 2b6f390..09b7c04 100644 --- a/src/decorator.cpp +++ b/src/decorator.cpp @@ -40,6 +40,7 @@ #include "decorator.h" #include "options.h" #include "utils.h" +#include "integration.h" #include <stdio.h> @@ -124,6 +125,17 @@ 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))); + QString decoName; if (args->isSet ("deco")) @@ -450,6 +462,11 @@ Aquamarine::Decorator::reconfigure () unsigned long changed = m_options->updateSettings (); +#ifdef HAVE_BERYL_SETTINGS + if (m_integrate) + m_integration->updateSettings(); +#endif + if (m_plugins->reset (changed)) { for (QMap < WId, Aquamarine::Window * >::ConstIterator it = @@ -462,6 +479,16 @@ Aquamarine::Decorator::reconfigure () } void +Aquamarine::Decorator::slotSettingsChanged (int) +{ + kdDebug () << k_funcinfo << endl; +#ifdef HAVE_BERYL_SETTINGS + if (m_integrate) + m_integration->updateSettings(); +#endif +} + +void Aquamarine::Decorator::slotWindowAdded (WId id) { kdDebug () << k_funcinfo << endl; diff --git a/src/decorator.h b/src/decorator.h index 08bfb72..8100b40 100644 --- a/src/decorator.h +++ b/src/decorator.h @@ -28,6 +28,10 @@ #ifndef AQUAMARINE_DECORATOR_H #define AQUAMARINE_DECORATOR_H +#ifdef HAVE_CONFIG_H +# include "../config.h" +#endif + #include <kapplication.h> #include <X11/Xlib.h> @@ -55,6 +59,8 @@ struct _cursor class KConfig; class KWinModule; + + static const long defaultMask = StructureNotifyMask | PropertyChangeMask; namespace Aquamarine @@ -63,6 +69,10 @@ namespace Aquamarine class Options; class Switcher; +#ifdef HAVE_BERYL_SETTINGS + class Integration; +#endif + class PluginManager:public KDecorationPlugins { public: @@ -124,6 +134,7 @@ namespace Aquamarine void slotWindowRemoved (WId id); void slotActiveWindowChanged (WId id); void slotWindowChanged (WId id, const unsigned long *properties); + void slotSettingsChanged (int category); private: @@ -151,6 +162,11 @@ 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 new file mode 100644 index 0000000..7d27bbc --- /dev/null +++ b/src/integration.cpp @@ -0,0 +1,338 @@ +/* + * 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, "command0"); + changed |= KdeKeyToBeryl(gc->readEntry("Kill Window"), core, "run_command0"); + + 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 new file mode 100644 index 0000000..db76763 --- /dev/null +++ b/src/integration.h @@ -0,0 +1,67 @@ +/* + * 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 |