summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2009-02-03 17:37:55 +0100
committerDanny Baumann <dannybaumann@web.de>2009-02-04 08:47:37 +0100
commit183841ea25ae82ef4a7da8ee2908cb0951599abb (patch)
treec2df6dd91b5b63e0a1132986b0b1d9976489c47c
parent4f5303389ba89517b66526ba917e5ac6ed7abc4f (diff)
Add Gnome compatibility plugin that receives key bindings only relevant for Gnome.
-rw-r--r--metadata/Makefile.am61
-rw-r--r--metadata/gnomecompat.xml.in52
-rw-r--r--plugins/Makefile.am4
-rw-r--r--plugins/gnomecompat.c339
-rw-r--r--po/POTFILES.in1
5 files changed, 427 insertions, 30 deletions
diff --git a/metadata/Makefile.am b/metadata/Makefile.am
index 05517d11..b197d494 100644
--- a/metadata/Makefile.am
+++ b/metadata/Makefile.am
@@ -1,34 +1,35 @@
xmldir = $(metadatadir)
-xml_in_files = \
- core.xml.in \
- annotate.xml.in \
- blur.xml.in \
- clone.xml.in \
- commands.xml.in \
- cube.xml.in \
- dbus.xml.in \
- decoration.xml.in \
- fade.xml.in \
- fs.xml.in \
- gconf.xml.in \
- glib.xml.in \
- ini.xml.in \
- inotify.xml.in \
- kconfig.xml.in \
- minimize.xml.in \
- move.xml.in \
- obs.xml.in \
- place.xml.in \
- png.xml.in \
- regex.xml.in \
- resize.xml.in \
- rotate.xml.in \
- scale.xml.in \
- screenshot.xml.in \
- svg.xml.in \
- switcher.xml.in \
- video.xml.in \
- water.xml.in \
+xml_in_files = \
+ core.xml.in \
+ annotate.xml.in \
+ blur.xml.in \
+ clone.xml.in \
+ commands.xml.in \
+ cube.xml.in \
+ dbus.xml.in \
+ decoration.xml.in \
+ fade.xml.in \
+ fs.xml.in \
+ gconf.xml.in \
+ glib.xml.in \
+ gnomecompat.xml.in \
+ ini.xml.in \
+ inotify.xml.in \
+ kconfig.xml.in \
+ minimize.xml.in \
+ move.xml.in \
+ obs.xml.in \
+ place.xml.in \
+ png.xml.in \
+ regex.xml.in \
+ resize.xml.in \
+ rotate.xml.in \
+ scale.xml.in \
+ screenshot.xml.in \
+ svg.xml.in \
+ switcher.xml.in \
+ video.xml.in \
+ water.xml.in \
wobbly.xml.in
xml_files = $(xml_in_files:.xml.in=.xml)
xml_DATA = $(xml_files)
diff --git a/metadata/gnomecompat.xml.in b/metadata/gnomecompat.xml.in
new file mode 100644
index 00000000..b40ae4a3
--- /dev/null
+++ b/metadata/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>
+ <display>
+ <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>
+ </display>
+ </plugin>
+</compiz>
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 1fa1d7b7..97cd23c5 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -68,6 +68,9 @@ libobs_la_SOURCES = obs.c
libcommands_la_LDFLAGS = -module -avoid-version -no-undefined
libcommands_la_SOURCES = commands.c
+libgnomecompat_la_LDFLAGS = -module -avoid-version -no-undefined
+libgnomecompat_la_SOURCES = gnomecompat.c
+
if USE_LIBRSVG
libsvg_la_DEPENDENCIES = $(top_builddir)/libdecoration/libdecoration.la
libsvg_la_LDFLAGS = -module -avoid-version -no-undefined
@@ -173,6 +176,7 @@ module_LTLIBRARIES = \
libini.la \
libobs.la \
libcommands.la \
+ libgnomecompat.la \
$(libsvg_module) \
$(libannotate_module) \
$(libinotify_module) \
diff --git a/plugins/gnomecompat.c b/plugins/gnomecompat.c
new file mode 100644
index 00000000..3fdda9bd
--- /dev/null
+++ b/plugins/gnomecompat.c
@@ -0,0 +1,339 @@
+/*
+ * 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 <compiz-core.h>
+
+static CompMetadata gnomeMetadata;
+
+static int displayPrivateIndex;
+
+#define GNOME_DISPLAY_OPTION_MAIN_MENU_KEY 0
+#define GNOME_DISPLAY_OPTION_RUN_DIALOG_KEY 1
+#define GNOME_DISPLAY_OPTION_SCREENSHOT_CMD 2
+#define GNOME_DISPLAY_OPTION_RUN_SCREENSHOT_KEY 3
+#define GNOME_DISPLAY_OPTION_WINDOW_SCREENSHOT_CMD 4
+#define GNOME_DISPLAY_OPTION_RUN_WINDOW_SCREENSHOT_KEY 5
+#define GNOME_DISPLAY_OPTION_TERMINAL_CMD 6
+#define GNOME_DISPLAY_OPTION_RUN_TERMINAL_KEY 7
+#define GNOME_DISPLAY_OPTION_NUM 8
+
+typedef struct _GnomeDisplay {
+ CompOption opt[GNOME_DISPLAY_OPTION_NUM];
+
+ Atom panelActionAtom;
+ Atom panelMainMenuAtom;
+ Atom panelRunDialogAtom;
+} GnomeDisplay;
+
+#define GET_GNOME_DISPLAY(d) \
+ ((GnomeDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
+#define GNOME_DISPLAY(d) \
+ GnomeDisplay *gd = GET_GNOME_DISPLAY (d)
+
+#define NUM_OPTIONS(d) (sizeof ((d)->opt) / sizeof (CompOption))
+
+static Bool
+runDispatch (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
+{
+ CompScreen *s;
+ Window xid;
+
+ xid = getIntOptionNamed (option, nOption, "root", 0);
+ s = findScreenAtDisplay (d, xid);
+
+ if (s)
+ {
+ GNOME_DISPLAY (d);
+
+ runCommand (s, gd->opt[action->priv.val].value.s);
+ }
+
+ return TRUE;
+}
+
+static void
+panelAction (CompDisplay *d,
+ CompOption *option,
+ int nOption,
+ Atom actionAtom)
+{
+ Window xid;
+ CompScreen *s;
+ XEvent event;
+ Time time;
+
+ GNOME_DISPLAY (d);
+
+ xid = getIntOptionNamed (option, nOption, "window", 0);
+ s = findScreenAtDisplay (d, xid);
+
+ if (!s)
+ return;
+
+ time = getIntOptionNamed (option, nOption, "time", 0);
+
+ event.type = ClientMessage;
+ event.xclient.window = s->root;
+ event.xclient.message_type = gd->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 (d->display, s->root, FALSE, StructureNotifyMask, &event);
+}
+
+static Bool
+showMainMenu (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
+{
+ GNOME_DISPLAY (d);
+
+ panelAction (d, option, nOption, gd->panelMainMenuAtom);
+
+ return TRUE;
+}
+
+static Bool
+showRunDialog (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
+{
+ GNOME_DISPLAY (d);
+
+ panelAction (d, option, nOption, gd->panelRunDialogAtom);
+
+ return TRUE;
+}
+static const CompMetadataOptionInfo gnomeDisplayOptionInfo[] = {
+ { "main_menu_key", "key", 0, showMainMenu, 0 },
+ { "run_dialog_key", "key", 0, showRunDialog, 0 },
+ { "command_screenshot", "string", 0, 0, 0 },
+ { "run_command_screenshot_key", "key", 0, runDispatch, 0 },
+ { "command_window_screenshot", "string", 0, 0, 0 },
+ { "run_command_window_screenshot_key", "key", 0, runDispatch, 0 },
+ { "command_terminal", "string", 0, 0, 0 },
+ { "run_command_terminal_key", "key", 0, runDispatch, 0 }
+};
+
+static CompBool
+gnomeInitDisplay (CompPlugin *p,
+ CompDisplay *d)
+{
+ GnomeDisplay *gd;
+ int opt, index;
+
+ if (!checkPluginABI ("core", CORE_ABIVERSION))
+ return FALSE;
+
+ gd = malloc (sizeof (GnomeDisplay));
+ if (!gd)
+ return FALSE;
+
+ if (!compInitDisplayOptionsFromMetadata (d,
+ &gnomeMetadata,
+ gnomeDisplayOptionInfo,
+ gd->opt,
+ GNOME_DISPLAY_OPTION_NUM))
+ {
+ free (gd);
+ return FALSE;
+ }
+
+ opt = GNOME_DISPLAY_OPTION_RUN_SCREENSHOT_KEY;
+ gd->opt[opt].value.action.priv.val = GNOME_DISPLAY_OPTION_SCREENSHOT_CMD;
+
+ opt = GNOME_DISPLAY_OPTION_RUN_WINDOW_SCREENSHOT_KEY;
+ index = GNOME_DISPLAY_OPTION_WINDOW_SCREENSHOT_CMD;
+ gd->opt[opt].value.action.priv.val = index;
+
+ opt = GNOME_DISPLAY_OPTION_RUN_TERMINAL_KEY;
+ gd->opt[opt].value.action.priv.val = GNOME_DISPLAY_OPTION_TERMINAL_CMD;
+
+ gd->panelActionAtom =
+ XInternAtom (d->display, "_GNOME_PANEL_ACTION", FALSE);
+ gd->panelMainMenuAtom =
+ XInternAtom (d->display, "_GNOME_PANEL_ACTION_MAIN_MENU", FALSE);
+ gd->panelRunDialogAtom =
+ XInternAtom (d->display, "_GNOME_PANEL_ACTION_RUN_DIALOG", FALSE);
+
+ d->base.privates[displayPrivateIndex].ptr = gd;
+
+ return TRUE;
+}
+
+static void
+gnomeFiniDisplay (CompPlugin *p,
+ CompDisplay *d)
+{
+ GNOME_DISPLAY (d);
+
+ compFiniDisplayOptions (d, gd->opt, GNOME_DISPLAY_OPTION_NUM);
+
+ free (gd);
+}
+
+static CompOption *
+gnomeGetDisplayOptions (CompPlugin *p,
+ CompDisplay *d,
+ int *count)
+{
+ GNOME_DISPLAY (d);
+
+ *count = NUM_OPTIONS (gd);
+ return gd->opt;
+}
+
+static CompBool
+gnomeSetDisplayOption (CompPlugin *p,
+ CompDisplay *d,
+ const char *name,
+ CompOptionValue *value)
+{
+ CompOption *o;
+
+ GNOME_DISPLAY (d);
+
+ o = compFindOption (gd->opt, NUM_OPTIONS (gd), name, NULL);
+ if (!o)
+ return FALSE;
+
+ return compSetDisplayOption (d, o, value);
+}
+
+static CompBool
+gnomeInitObject (CompPlugin *p,
+ CompObject *o)
+{
+ static InitPluginObjectProc dispTab[] = {
+ (InitPluginObjectProc) 0, /* InitCore */
+ (InitPluginObjectProc) gnomeInitDisplay
+ };
+
+ RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
+}
+
+static void
+gnomeFiniObject (CompPlugin *p,
+ CompObject *o)
+{
+ static FiniPluginObjectProc dispTab[] = {
+ (FiniPluginObjectProc) 0, /* FiniCore */
+ (FiniPluginObjectProc) gnomeFiniDisplay
+ };
+
+ DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
+}
+
+static CompOption *
+gnomeGetObjectOptions (CompPlugin *p,
+ CompObject *o,
+ int *count)
+{
+ static GetPluginObjectOptionsProc dispTab[] = {
+ (GetPluginObjectOptionsProc) 0, /* GetCoreOptions */
+ (GetPluginObjectOptionsProc) gnomeGetDisplayOptions
+ };
+
+ RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab),
+ (void *) (*count = 0), (p, o, count));
+}
+
+static CompBool
+gnomeSetObjectOption (CompPlugin *p,
+ CompObject *o,
+ const char *name,
+ CompOptionValue *value)
+{
+ static SetPluginObjectOptionProc dispTab[] = {
+ (SetPluginObjectOptionProc) 0, /* SetCoreOption */
+ (SetPluginObjectOptionProc) gnomeSetDisplayOption,
+ };
+
+ RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), FALSE,
+ (p, o, name, value));
+}
+
+static Bool
+gnomeInit (CompPlugin *p)
+{
+ if (!compInitPluginMetadataFromInfo (&gnomeMetadata,
+ p->vTable->name,
+ gnomeDisplayOptionInfo,
+ GNOME_DISPLAY_OPTION_NUM, 0, 0))
+ return FALSE;
+
+ displayPrivateIndex = allocateDisplayPrivateIndex ();
+ if (displayPrivateIndex < 0)
+ {
+ compFiniMetadata (&gnomeMetadata);
+ return FALSE;
+ }
+
+ compAddMetadataFromFile (&gnomeMetadata, p->vTable->name);
+
+ return TRUE;
+}
+
+static void
+gnomeFini (CompPlugin *p)
+{
+ freeDisplayPrivateIndex (displayPrivateIndex);
+ compFiniMetadata (&gnomeMetadata);
+}
+
+static CompMetadata *
+gnomeGetMetadata (CompPlugin *p)
+{
+ return &gnomeMetadata;
+}
+
+static CompPluginVTable gnomeVTable = {
+ "gnomecompat",
+ gnomeGetMetadata,
+ gnomeInit,
+ gnomeFini,
+ gnomeInitObject,
+ gnomeFiniObject,
+ gnomeGetObjectOptions,
+ gnomeSetObjectOption
+};
+
+CompPluginVTable *
+getCompPluginInfo20070830 (void)
+{
+ return &gnomeVTable;
+}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6944cddf..823f5959 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -16,6 +16,7 @@ metadata/fade.xml.in
metadata/fs.xml.in
metadata/gconf.xml.in
metadata/glib.xml.in
+metadata/gnomecompat.xml.in
metadata/ini.xml.in
metadata/inotify.xml.in
metadata/kconfig.xml.in