2
* Copyright © 2009 Danny Baumann
4
* Permission to use, copy, modify, distribute, and sell this software
5
* and its documentation for any purpose is hereby granted without
6
* fee, provided that the above copyright notice appear in all copies
7
* and that both that copyright notice and this permission notice
8
* appear in supporting documentation, and that the name of
9
* Danny Baumann not be used in advertising or publicity pertaining to
10
* distribution of the software without specific, written prior permission.
11
* Danny Baumann makes no representations about the suitability of this
12
* software for any purpose. It is provided "as is" without express or
15
* DANNY BAUMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17
* NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
* Author: Danny Baumann <dannybaumann@web.de>
26
#include "gnomecompat.h"
28
COMPIZ_PLUGIN_20081216 (gnomecompat, GnomeCompatPluginVTable);
31
runCommand (CompAction *action,
32
CompAction::State state,
33
CompOption::Vector& options,
34
unsigned int commandOption)
38
GNOME_SCREEN (screen);
40
xid = CompOption::getIntOptionNamed (options, "root", 0);
41
if (xid != screen->root ())
44
screen->runCommand (gs->opt[commandOption].value ().s ());
50
GnomeCompatScreen::panelAction (CompOption::Vector& options,
57
xid = CompOption::getIntOptionNamed (options, "root", 0);
58
if (xid != screen->root ())
61
time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
63
/* we need to ungrab the keyboard here, otherwise the panel main
64
menu won't popup as it wants to grab the keyboard itself */
65
XUngrabKeyboard (screen->dpy (), time);
67
event.type = ClientMessage;
68
event.xclient.window = screen->root ();
69
event.xclient.message_type = panelActionAtom;
70
event.xclient.format = 32;
71
event.xclient.data.l[0] = actionAtom;
72
event.xclient.data.l[1] = time;
73
event.xclient.data.l[2] = 0;
74
event.xclient.data.l[3] = 0;
75
event.xclient.data.l[4] = 0;
77
XSendEvent (screen->dpy (), screen->root (), FALSE,
78
StructureNotifyMask, &event);
82
showMainMenu (CompAction *action,
83
CompAction::State state,
84
CompOption::Vector& options)
86
GNOME_SCREEN (screen);
88
gs->panelAction (options, gs->panelMainMenuAtom);
94
showRunDialog (CompAction *action,
95
CompAction::State state,
96
CompOption::Vector& options)
98
GNOME_SCREEN (screen);
100
gs->panelAction (options, gs->panelRunDialogAtom);
105
#define COMMAND_BIND(opt) \
106
boost::bind (runCommand, _1, _2, _3, opt)
108
static const CompMetadata::OptionInfo gnomeOptionInfo[] = {
109
{ "main_menu_key", "key", 0, showMainMenu, 0 },
110
{ "run_key", "key", 0, showRunDialog, 0 },
111
{ "command_screenshot", "string", 0, 0, 0 },
112
{ "run_command_screenshot_key", "key", 0,
113
COMMAND_BIND (GNOME_OPTION_SCREENSHOT_CMD), 0 },
114
{ "command_window_screenshot", "string", 0, 0, 0 },
115
{ "run_command_window_screenshot_key", "key", 0,
116
COMMAND_BIND (GNOME_OPTION_WINDOW_SCREENSHOT_CMD), 0 },
117
{ "command_terminal", "string", 0, 0, 0 },
118
{ "run_command_terminal_key", "key", 0,
119
COMMAND_BIND (GNOME_OPTION_TERMINAL_CMD), 0 }
122
GnomeCompatScreen::GnomeCompatScreen (CompScreen *s) :
123
PrivateHandler<GnomeCompatScreen, CompScreen> (s)
125
if (!gnomecompatVTable->getMetadata ()->initOptions (gnomeOptionInfo,
134
XInternAtom (screen->dpy (), "_GNOME_PANEL_ACTION", FALSE);
136
XInternAtom (screen->dpy (), "_GNOME_PANEL_ACTION_MAIN_MENU", FALSE);
138
XInternAtom (screen->dpy (), "_GNOME_PANEL_ACTION_RUN_DIALOG", FALSE);
142
GnomeCompatScreen::getOptions ()
148
GnomeCompatScreen::setOption (const char *name,
149
CompOption::Value& value)
153
o = CompOption::findOption (opt, name, NULL);
157
return CompOption::setOption (*o, value);
161
GnomeCompatPluginVTable::init ()
163
if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
166
getMetadata ()->addFromOptionInfo (gnomeOptionInfo, GNOME_OPTION_NUM);
167
getMetadata ()->addFromFile (name ());