~canonical-dx-team/unity/unity.fix-ql-losing-focus

« back to all changes in this revision

Viewing changes to src/PluginAdapter.cpp

  • Committer: Neil Jagdish Patel
  • Date: 2010-11-11 18:51:08 UTC
  • mfrom: (572.1.58 unity-3.0)
  • Revision ID: neil.patel@canonical.com-20101111185108-71923a90txzvxbit
[merge] Unity 3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Jason Smith <jason.smith@canonical.com>
 
17
 */
 
18
 
 
19
#include <glib.h>
 
20
#include "PluginAdapter.h"
 
21
 
 
22
PluginAdapter * PluginAdapter::_default = 0;
 
23
 
 
24
/* static */
 
25
PluginAdapter *
 
26
PluginAdapter::Default ()
 
27
{
 
28
    if (!_default)
 
29
        return 0;
 
30
    return _default;
 
31
}
 
32
 
 
33
/* static */
 
34
void
 
35
PluginAdapter::Initialize (CompScreen *screen)
 
36
{
 
37
    _default = new PluginAdapter (screen);
 
38
}
 
39
 
 
40
PluginAdapter::PluginAdapter(CompScreen *screen)
 
41
{
 
42
    m_Screen = screen;
 
43
    m_ExpoAction = 0;
 
44
    m_ScaleAction = 0;
 
45
}
 
46
 
 
47
PluginAdapter::~PluginAdapter()
 
48
{
 
49
 
 
50
}
 
51
 
 
52
void
 
53
PluginAdapter::SetExpoAction (CompAction *expo)
 
54
{
 
55
    m_ExpoAction = expo;
 
56
}
 
57
 
 
58
void
 
59
PluginAdapter::SetScaleAction (CompAction *scale)
 
60
{
 
61
    m_ScaleAction = scale;
 
62
}
 
63
    
 
64
std::string *
 
65
PluginAdapter::MatchStringForXids (std::list<Window> *windows)
 
66
{
 
67
    char *string;
 
68
    std::string *result = new std::string ("any & (");
 
69
    
 
70
    std::list<Window>::iterator it;
 
71
    
 
72
    for (it = windows->begin (); it != windows->end (); it++)
 
73
    {
 
74
        string = g_strdup_printf ("| xid=%i ", (int) *it);
 
75
        result->append (string);
 
76
        g_free (string);
 
77
    }
 
78
    
 
79
    result->append (")");
 
80
    
 
81
    return result;
 
82
}
 
83
    
 
84
void 
 
85
PluginAdapter::InitiateScale (std::string *match)
 
86
{
 
87
    if (!m_ScaleAction)
 
88
        return;
 
89
        
 
90
    CompOption::Value value;
 
91
    CompOption::Type  type;
 
92
    CompOption::Vector argument;
 
93
    char             *name;
 
94
 
 
95
    name = (char *) "root";
 
96
    type = CompOption::TypeInt;
 
97
    value.set ((int) m_Screen->root ());
 
98
    
 
99
    CompOption arg = CompOption (name, type);
 
100
    arg.set (value);
 
101
    argument.push_back (arg);
 
102
    
 
103
    name = (char *) "match";
 
104
    type = CompOption::TypeMatch;
 
105
    value.set (CompMatch (*match));
 
106
    
 
107
    arg = CompOption (name, type);
 
108
    arg.set (value);
 
109
    argument.push_back (arg);
 
110
    
 
111
    m_ScaleAction->initiate () (m_ScaleAction, 0, argument);
 
112
}
 
113
    
 
114
void 
 
115
PluginAdapter::InitiateExpo ()
 
116
{
 
117
    if (!m_ExpoAction)
 
118
        return;
 
119
        
 
120
    CompOption::Value value;
 
121
    CompOption::Type  type;
 
122
    CompOption::Vector argument;
 
123
    char             *name;
 
124
 
 
125
    name = (char *) "root";
 
126
    type = CompOption::TypeInt;
 
127
    value.set ((int) m_Screen->root ());
 
128
    
 
129
    CompOption arg (name, type);
 
130
    arg.set (value);
 
131
    argument.push_back (arg);
 
132
    
 
133
    m_ExpoAction->initiate () (m_ExpoAction, 0, argument);
 
134
}