~didrocks/unity/launcher-bug-fix-fest

« back to all changes in this revision

Viewing changes to src/PluginAdapter.cpp

Import the work done so far with Compiz

Show diffs side-by-side

added added

removed removed

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