~ubuntu-branches/ubuntu/trusty/compiz/trusty

« back to all changes in this revision

Viewing changes to plugins/commands/src/commands.cpp

  • Committer: Dennis kasprzyk
  • Author(s): Dennis Kasprzyk
  • Date: 2009-03-15 05:09:18 UTC
  • Revision ID: git-v1:163f6b6f3c3b7764987cbdf8e03cc355edeaa499
New generalized build system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2009 Danny Baumann
 
3
 *
 
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
 
13
 * implied warranty.
 
14
 *
 
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.
 
22
 *
 
23
 * Author: Danny Baumann <dannybaumann@web.de>
 
24
 */
 
25
 
 
26
#include "commands.h"
 
27
 
 
28
COMPIZ_PLUGIN_20081216 (commands, CommandsPluginVTable);
 
29
 
 
30
bool
 
31
CommandsScreen::runCommand (CompAction          *action,
 
32
                            CompAction::State   state,
 
33
                            CompOption::Vector& options,
 
34
                            int                 commandOption)
 
35
{
 
36
    CommandsScreen *cs;
 
37
    Window         xid;
 
38
 
 
39
    xid = CompOption::getIntOptionNamed (options, "root", 0);
 
40
    if (xid != screen->root ())
 
41
        return false;
 
42
 
 
43
    cs = CommandsScreen::get (screen);
 
44
 
 
45
    screen->runCommand (cs->opt[commandOption].value (). s());
 
46
 
 
47
    return true;
 
48
}
 
49
 
 
50
#define DISPATCH(opt) boost::bind (CommandsScreen::runCommand, _1, _2, _3, opt)
 
51
 
 
52
static const CompMetadata::OptionInfo commandsOptionInfo[] = {
 
53
    { "command0", "string", 0, 0, 0 },
 
54
    { "command1", "string", 0, 0, 0 },
 
55
    { "command2", "string", 0, 0, 0 },
 
56
    { "command3", "string", 0, 0, 0 },
 
57
    { "command4", "string", 0, 0, 0 },
 
58
    { "command5", "string", 0, 0, 0 },
 
59
    { "command6", "string", 0, 0, 0 },
 
60
    { "command7", "string", 0, 0, 0 },
 
61
    { "command8", "string", 0, 0, 0 },
 
62
    { "command9", "string", 0, 0, 0 },
 
63
    { "command10", "string", 0, 0, 0 },
 
64
    { "command11", "string", 0, 0, 0 },
 
65
    { "run_command0_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND0), 0 },
 
66
    { "run_command1_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND1), 0 },
 
67
    { "run_command2_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND2), 0 },
 
68
    { "run_command3_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND3), 0 },
 
69
    { "run_command4_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND4), 0 },
 
70
    { "run_command5_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND5), 0 },
 
71
    { "run_command6_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND6), 0 },
 
72
    { "run_command7_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND7), 0 },
 
73
    { "run_command8_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND8), 0 },
 
74
    { "run_command9_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND9), 0 },
 
75
    { "run_command10_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND10), 0 },
 
76
    { "run_command11_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND11), 0 },
 
77
    { "run_command0_button", "button", 0,
 
78
      DISPATCH (COMMANDS_OPTION_COMMAND0), 0 },
 
79
    { "run_command1_button", "button", 0,
 
80
      DISPATCH (COMMANDS_OPTION_COMMAND1), 0 },
 
81
    { "run_command2_button", "button", 0,
 
82
      DISPATCH (COMMANDS_OPTION_COMMAND2), 0 },
 
83
    { "run_command3_button", "button", 0,
 
84
      DISPATCH (COMMANDS_OPTION_COMMAND3), 0 },
 
85
    { "run_command4_button", "button", 0,
 
86
      DISPATCH (COMMANDS_OPTION_COMMAND4), 0 },
 
87
    { "run_command5_button", "button", 0,
 
88
      DISPATCH (COMMANDS_OPTION_COMMAND5), 0 },
 
89
    { "run_command6_button", "button", 0,
 
90
      DISPATCH (COMMANDS_OPTION_COMMAND6), 0 },
 
91
    { "run_command7_button", "button", 0,
 
92
      DISPATCH (COMMANDS_OPTION_COMMAND7), 0 },
 
93
    { "run_command8_button", "button", 0,
 
94
      DISPATCH (COMMANDS_OPTION_COMMAND8), 0 },
 
95
    { "run_command9_button", "button", 0,
 
96
      DISPATCH (COMMANDS_OPTION_COMMAND9), 0 },
 
97
    { "run_command10_button", "button", 0,
 
98
      DISPATCH (COMMANDS_OPTION_COMMAND10), 0 },
 
99
    { "run_command11_button", "button", 0,
 
100
      DISPATCH (COMMANDS_OPTION_COMMAND11), 0 },
 
101
    { "run_command0_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND0), 0 },
 
102
    { "run_command1_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND1), 0 },
 
103
    { "run_command2_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND2), 0 },
 
104
    { "run_command3_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND3), 0 },
 
105
    { "run_command4_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND4), 0 },
 
106
    { "run_command5_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND5), 0 },
 
107
    { "run_command6_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND6), 0 },
 
108
    { "run_command7_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND7), 0 },
 
109
    { "run_command8_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND8), 0 },
 
110
    { "run_command9_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND9), 0 },
 
111
    { "run_command10_edge", "edge", 0,
 
112
      DISPATCH (COMMANDS_OPTION_COMMAND10), 0 },
 
113
    { "run_command11_edge", "edge", 0,
 
114
      DISPATCH (COMMANDS_OPTION_COMMAND11), 0 }
 
115
};
 
116
 
 
117
CommandsScreen::CommandsScreen (CompScreen *s) :
 
118
    PrivateHandler<CommandsScreen, CompScreen> (s)
 
119
{
 
120
    if (!commandsVTable->getMetadata ()->initOptions (commandsOptionInfo,
 
121
                                                      COMMANDS_OPTION_NUM,
 
122
                                                      opt))
 
123
        setFailed ();
 
124
}
 
125
 
 
126
CompOption::Vector&
 
127
CommandsScreen::getOptions ()
 
128
{
 
129
    return opt;
 
130
}
 
131
 
 
132
bool
 
133
CommandsScreen::setOption (const char         *name,
 
134
                           CompOption::Value& value)
 
135
{
 
136
    CompOption *o;
 
137
 
 
138
    o = CompOption::findOption (opt, name, NULL);
 
139
    if (!o)
 
140
        return false;
 
141
 
 
142
    return CompOption::setOption (*o, value);
 
143
}
 
144
 
 
145
bool
 
146
CommandsPluginVTable::init ()
 
147
{
 
148
    if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
 
149
        return false;
 
150
 
 
151
    getMetadata ()->addFromOptionInfo (commandsOptionInfo, COMMANDS_OPTION_NUM);
 
152
    getMetadata ()->addFromFile (name ());
 
153
 
 
154
    return true;
 
155
}
 
156