summaryrefslogtreecommitdiff
path: root/plugins/commands/src/commands.cpp
blob: dd9ecd68961905312cc6b1e933492370268ba6a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
 * 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 "commands.h"

COMPIZ_PLUGIN_20090315 (commands, CommandsPluginVTable);

bool
CommandsScreen::runCommand (CompAction          *action,
			    CompAction::State   state,
			    CompOption::Vector& options,
			    int                 commandOption)
{
    CommandsScreen *cs;
    Window         xid;

    xid = CompOption::getIntOptionNamed (options, "root", 0);
    if (xid != screen->root ())
	return false;

    cs = CommandsScreen::get (screen);

    screen->runCommand (cs->mOptions[commandOption].value (). s());

    return true;
}


CommandsScreen::CommandsScreen (CompScreen *s) :
    PluginClassHandler<CommandsScreen, CompScreen> (s)
{

#define DISPATCH(opt) boost::bind (CommandsScreen::runCommand, _1, _2, _3, opt)

    optionSetRunCommand0KeyInitiate (DISPATCH (CommandsOptions::Command0));
    optionSetRunCommand1KeyInitiate (DISPATCH (CommandsOptions::Command1));
    optionSetRunCommand2KeyInitiate (DISPATCH (CommandsOptions::Command2));
    optionSetRunCommand3KeyInitiate (DISPATCH (CommandsOptions::Command3));
    optionSetRunCommand4KeyInitiate (DISPATCH (CommandsOptions::Command4));
    optionSetRunCommand5KeyInitiate (DISPATCH (CommandsOptions::Command5));
    optionSetRunCommand6KeyInitiate (DISPATCH (CommandsOptions::Command6));
    optionSetRunCommand7KeyInitiate (DISPATCH (CommandsOptions::Command7));
    optionSetRunCommand8KeyInitiate (DISPATCH (CommandsOptions::Command8));
    optionSetRunCommand9KeyInitiate (DISPATCH (CommandsOptions::Command9));
    optionSetRunCommand10KeyInitiate (DISPATCH (CommandsOptions::Command10));
    optionSetRunCommand11KeyInitiate (DISPATCH (CommandsOptions::Command11));

    optionSetRunCommand0ButtonInitiate (DISPATCH (CommandsOptions::Command0));
    optionSetRunCommand1ButtonInitiate (DISPATCH (CommandsOptions::Command1));
    optionSetRunCommand2ButtonInitiate (DISPATCH (CommandsOptions::Command2));
    optionSetRunCommand3ButtonInitiate (DISPATCH (CommandsOptions::Command3));
    optionSetRunCommand4ButtonInitiate (DISPATCH (CommandsOptions::Command4));
    optionSetRunCommand5ButtonInitiate (DISPATCH (CommandsOptions::Command5));
    optionSetRunCommand6ButtonInitiate (DISPATCH (CommandsOptions::Command6));
    optionSetRunCommand7ButtonInitiate (DISPATCH (CommandsOptions::Command7));
    optionSetRunCommand8ButtonInitiate (DISPATCH (CommandsOptions::Command8));
    optionSetRunCommand9ButtonInitiate (DISPATCH (CommandsOptions::Command9));
    optionSetRunCommand10ButtonInitiate (DISPATCH (CommandsOptions::Command10));
    optionSetRunCommand11ButtonInitiate (DISPATCH (CommandsOptions::Command11));

    optionSetRunCommand0EdgeInitiate (DISPATCH (CommandsOptions::Command0));
    optionSetRunCommand1EdgeInitiate (DISPATCH (CommandsOptions::Command1));
    optionSetRunCommand2EdgeInitiate (DISPATCH (CommandsOptions::Command2));
    optionSetRunCommand3EdgeInitiate (DISPATCH (CommandsOptions::Command3));
    optionSetRunCommand4EdgeInitiate (DISPATCH (CommandsOptions::Command4));
    optionSetRunCommand5EdgeInitiate (DISPATCH (CommandsOptions::Command5));
    optionSetRunCommand6EdgeInitiate (DISPATCH (CommandsOptions::Command6));
    optionSetRunCommand7EdgeInitiate (DISPATCH (CommandsOptions::Command7));
    optionSetRunCommand8EdgeInitiate (DISPATCH (CommandsOptions::Command8));
    optionSetRunCommand9EdgeInitiate (DISPATCH (CommandsOptions::Command9));
    optionSetRunCommand10EdgeInitiate (DISPATCH (CommandsOptions::Command10));
    optionSetRunCommand11EdgeInitiate (DISPATCH (CommandsOptions::Command11));
}

bool
CommandsPluginVTable::init ()
{
    if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
	return false;

    return true;
}