summaryrefslogtreecommitdiff
path: root/plugins/gnomecompat
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2009-03-15 06:09:18 +0100
committerDennis kasprzyk <onestone@compiz-fusion.org>2009-03-15 06:09:18 +0100
commit163f6b6f3c3b7764987cbdf8e03cc355edeaa499 (patch)
tree4278afde195343dcb8277b0bb0b6efc926ce8907 /plugins/gnomecompat
parent28e45c55c11e20206d3bc9056aea8fc7f1b7a0e7 (diff)
downloadmobilebling-163f6b6f3c3b7764987cbdf8e03cc355edeaa499.tar.gz
mobilebling-163f6b6f3c3b7764987cbdf8e03cc355edeaa499.tar.bz2
New generalized build system.
Diffstat (limited to 'plugins/gnomecompat')
-rw-r--r--plugins/gnomecompat/CMakeLists.txt5
-rw-r--r--plugins/gnomecompat/gnomecompat.xml.in52
-rw-r--r--plugins/gnomecompat/src/gnomecompat.cpp170
-rw-r--r--plugins/gnomecompat/src/gnomecompat.h67
4 files changed, 294 insertions, 0 deletions
diff --git a/plugins/gnomecompat/CMakeLists.txt b/plugins/gnomecompat/CMakeLists.txt
new file mode 100644
index 0000000..3e3535d
--- /dev/null
+++ b/plugins/gnomecompat/CMakeLists.txt
@@ -0,0 +1,5 @@
+find_package (Compiz REQUIRED)
+
+include (CompizPlugin)
+
+compiz_plugin(gnomecompat PLUGINDEPS composite opengl) \ No newline at end of file
diff --git a/plugins/gnomecompat/gnomecompat.xml.in b/plugins/gnomecompat/gnomecompat.xml.in
new file mode 100644
index 0000000..122bf83
--- /dev/null
+++ b/plugins/gnomecompat/gnomecompat.xml.in
@@ -0,0 +1,52 @@
+<compiz>
+ <plugin name="gnomecompat">
+ <_short>Gnome Compatibility</_short>
+ <_long>Options that keep Compiz compatible to the Gnome desktop environment</_long>
+ <category>General</category>
+ <options>
+ <option name="main_menu_key" type="key">
+ <_short>Show Main Menu</_short>
+ <_long>Show the main menu</_long>
+ <default>&lt;Alt&gt;F1</default>
+ </option>
+ <option name="run_key" type="key">
+ <_short>Run Dialog</_short>
+ <_long>Show Run Application dialog</_long>
+ <default>&lt;Alt&gt;F2</default>
+ </option>
+ <group>
+ <_short>Commands</_short>
+ <option name="command_screenshot" type="string">
+ <_short>Screenshot command line</_short>
+ <_long>Screenshot command line</_long>
+ <default>gnome-screenshot</default>
+ </option>
+ <option name="run_command_screenshot_key" type="key">
+ <_short>Take a screenshot</_short>
+ <_long>Take a screenshot</_long>
+ <default>Print</default>
+ </option>
+ <option name="command_window_screenshot" type="string">
+ <_short>Window screenshot command line</_short>
+ <_long>Window screenshot command line</_long>
+ <default>gnome-screenshot --window</default>
+ </option>
+ <option name="run_command_window_screenshot_key" type="key">
+ <_short>Take a screenshot of a window</_short>
+ <_long>Take a screenshot of a window</_long>
+ <default>&lt;Alt&gt;Print</default>
+ </option>
+ <_short>Run terminal command</_short>
+ <option name="command_terminal" type="string">
+ <_short>Terminal command line</_short>
+ <_long>Terminal command line</_long>
+ <default></default>
+ </option>
+ <option name="run_command_terminal_key" type="key">
+ <_short>Open a terminal</_short>
+ <_long>Open a terminal</_long>
+ </option>
+ </group>
+ </options>
+ </plugin>
+</compiz>
diff --git a/plugins/gnomecompat/src/gnomecompat.cpp b/plugins/gnomecompat/src/gnomecompat.cpp
new file mode 100644
index 0000000..8b8e331
--- /dev/null
+++ b/plugins/gnomecompat/src/gnomecompat.cpp
@@ -0,0 +1,170 @@
+/*
+ * Copyright © 2009 Danny Baumann
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Danny Baumann not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Danny Baumann makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DANNY BAUMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Danny Baumann <dannybaumann@web.de>
+ */
+
+#include "gnomecompat.h"
+
+COMPIZ_PLUGIN_20081216 (gnomecompat, GnomeCompatPluginVTable);
+
+static bool
+runCommand (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector& options,
+ unsigned int commandOption)
+{
+ Window xid;
+
+ GNOME_SCREEN (screen);
+
+ xid = CompOption::getIntOptionNamed (options, "root", 0);
+ if (xid != screen->root ())
+ return false;
+
+ screen->runCommand (gs->opt[commandOption].value ().s ());
+
+ return true;
+}
+
+void
+GnomeCompatScreen::panelAction (CompOption::Vector& options,
+ Atom actionAtom)
+{
+ Window xid;
+ XEvent event;
+ Time time;
+
+ xid = CompOption::getIntOptionNamed (options, "root", 0);
+ if (xid != screen->root ())
+ return;
+
+ time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
+
+ /* we need to ungrab the keyboard here, otherwise the panel main
+ menu won't popup as it wants to grab the keyboard itself */
+ XUngrabKeyboard (screen->dpy (), time);
+
+ event.type = ClientMessage;
+ event.xclient.window = screen->root ();
+ event.xclient.message_type = panelActionAtom;
+ event.xclient.format = 32;
+ event.xclient.data.l[0] = actionAtom;
+ event.xclient.data.l[1] = time;
+ event.xclient.data.l[2] = 0;
+ event.xclient.data.l[3] = 0;
+ event.xclient.data.l[4] = 0;
+
+ XSendEvent (screen->dpy (), screen->root (), FALSE,
+ StructureNotifyMask, &event);
+}
+
+static bool
+showMainMenu (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector& options)
+{
+ GNOME_SCREEN (screen);
+
+ gs->panelAction (options, gs->panelMainMenuAtom);
+
+ return true;
+}
+
+static bool
+showRunDialog (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector& options)
+{
+ GNOME_SCREEN (screen);
+
+ gs->panelAction (options, gs->panelRunDialogAtom);
+
+ return true;
+}
+
+#define COMMAND_BIND(opt) \
+ boost::bind (runCommand, _1, _2, _3, opt)
+
+static const CompMetadata::OptionInfo gnomeOptionInfo[] = {
+ { "main_menu_key", "key", 0, showMainMenu, 0 },
+ { "run_key", "key", 0, showRunDialog, 0 },
+ { "command_screenshot", "string", 0, 0, 0 },
+ { "run_command_screenshot_key", "key", 0,
+ COMMAND_BIND (GNOME_OPTION_SCREENSHOT_CMD), 0 },
+ { "command_window_screenshot", "string", 0, 0, 0 },
+ { "run_command_window_screenshot_key", "key", 0,
+ COMMAND_BIND (GNOME_OPTION_WINDOW_SCREENSHOT_CMD), 0 },
+ { "command_terminal", "string", 0, 0, 0 },
+ { "run_command_terminal_key", "key", 0,
+ COMMAND_BIND (GNOME_OPTION_TERMINAL_CMD), 0 }
+};
+
+GnomeCompatScreen::GnomeCompatScreen (CompScreen *s) :
+ PrivateHandler<GnomeCompatScreen, CompScreen> (s)
+{
+ if (!gnomecompatVTable->getMetadata ()->initOptions (gnomeOptionInfo,
+ GNOME_OPTION_NUM,
+ opt))
+ {
+ setFailed ();
+ return;
+ }
+
+ panelActionAtom =
+ XInternAtom (screen->dpy (), "_GNOME_PANEL_ACTION", FALSE);
+ panelMainMenuAtom =
+ XInternAtom (screen->dpy (), "_GNOME_PANEL_ACTION_MAIN_MENU", FALSE);
+ panelRunDialogAtom =
+ XInternAtom (screen->dpy (), "_GNOME_PANEL_ACTION_RUN_DIALOG", FALSE);
+}
+
+CompOption::Vector&
+GnomeCompatScreen::getOptions ()
+{
+ return opt;
+}
+
+bool
+GnomeCompatScreen::setOption (const char *name,
+ CompOption::Value& value)
+{
+ CompOption *o;
+
+ o = CompOption::findOption (opt, name, NULL);
+ if (!o)
+ return false;
+
+ return CompOption::setOption (*o, value);
+}
+
+bool
+GnomeCompatPluginVTable::init ()
+{
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
+ return false;
+
+ getMetadata ()->addFromOptionInfo (gnomeOptionInfo, GNOME_OPTION_NUM);
+ getMetadata ()->addFromFile (name ());
+
+ return true;
+}
diff --git a/plugins/gnomecompat/src/gnomecompat.h b/plugins/gnomecompat/src/gnomecompat.h
new file mode 100644
index 0000000..56c4b7a
--- /dev/null
+++ b/plugins/gnomecompat/src/gnomecompat.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2009 Danny Baumann
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Danny Baumann not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Danny Baumann makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DANNY BAUMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Danny Baumann <dannybaumann@web.de>
+ */
+
+#include <core/core.h>
+#include <core/privatehandler.h>
+
+#define GNOME_OPTION_MAIN_MENU_KEY 0
+#define GNOME_OPTION_RUN_DIALOG_KEY 1
+#define GNOME_OPTION_SCREENSHOT_CMD 2
+#define GNOME_OPTION_RUN_SCREENSHOT_KEY 3
+#define GNOME_OPTION_WINDOW_SCREENSHOT_CMD 4
+#define GNOME_OPTION_RUN_WINDOW_SCREENSHOT_KEY 5
+#define GNOME_OPTION_TERMINAL_CMD 6
+#define GNOME_OPTION_RUN_TERMINAL_KEY 7
+#define GNOME_OPTION_NUM 8
+
+class GnomeCompatScreen :
+ public PrivateHandler<GnomeCompatScreen, CompScreen>
+{
+ public:
+ GnomeCompatScreen (CompScreen *s);
+
+ CompOption::Vector & getOptions ();
+ bool setOption (const char *name, CompOption::Value& value);
+
+ void panelAction (CompOption::Vector& options, Atom action);
+
+ Atom panelActionAtom;
+ Atom panelMainMenuAtom;
+ Atom panelRunDialogAtom;
+
+ CompOption::Vector opt;
+};
+
+#define GNOME_SCREEN(s) \
+ GnomeCompatScreen *gs = GnomeCompatScreen::get (s)
+
+class GnomeCompatPluginVTable :
+ public CompPlugin::VTableForScreen<GnomeCompatScreen>
+{
+ public:
+ bool init ();
+
+ PLUGIN_OPTION_HELPER (GnomeCompatScreen);
+};