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

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2013-08-22 06:58:07 UTC
  • mto: This revision was merged to the branch mainline in revision 3352.
  • Revision ID: package-import@ubuntu.com-20130822065807-17nlzez0d30y09so
Tags: upstream-0.9.10+13.10.20130822
ImportĀ upstreamĀ versionĀ 0.9.10+13.10.20130822

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
COMPIZ_PLUGIN_20090315 (mousepoll, MousepollPluginVTable);
26
26
 
27
 
const unsigned short MP_OPTION_MOUSE_POLL_INTERVAL = 0;
28
 
const unsigned short MP_OPTION_NUM = 1;
29
 
 
30
27
bool
31
28
MousepollScreen::getMousePosition ()
32
29
{
35
32
    int          winX, winY;
36
33
    int          w = screen->width (), h = screen->height ();
37
34
    unsigned int maskReturn;
38
 
    bool         status;
39
35
 
40
 
    status = XQueryPointer (screen->dpy (), screen->root (),
41
 
                            &root, &child, &rootX, &rootY,
42
 
                            &winX, &winY, &maskReturn);
 
36
    bool status = XQueryPointer (screen->dpy (), screen->root (),
 
37
                                 &root, &child, &rootX, &rootY,
 
38
                                 &winX, &winY, &maskReturn);
43
39
 
44
40
    if (!status || rootX > w || rootY > h || screen->root () != root)
45
41
        return false;
56
52
bool
57
53
MousepollScreen::updatePosition ()
58
54
{
59
 
 
60
55
    if (getMousePosition ())
61
56
    {
62
 
        std::list<MousePoller *>::iterator it;
63
 
        for (it = pollers.begin (); it != pollers.end (); )
64
 
        {
65
 
            MousePoller *poller = *it;
 
57
        for (std::list<MousePoller *>::iterator it = pollers.begin ();
 
58
             it != pollers.end ();)
 
59
        {
 
60
            MousePoller *poller = *it;
66
61
 
67
 
            ++it;
68
 
            poller->mPoint = pos;
69
 
            poller->mCallback (pos);
70
 
        }
 
62
            ++it;
 
63
            poller->mPoint = pos;
 
64
            poller->mCallback (pos);
 
65
        }
71
66
    }
72
67
 
73
 
 
74
68
    return true;
75
69
}
76
70
 
77
71
bool
78
72
MousepollScreen::addTimer (MousePoller *poller)
79
73
{
80
 
    bool                               start = pollers.empty ();
81
 
    std::list<MousePoller *>::iterator it;
82
 
 
83
 
    it = std::find (pollers.begin (), pollers.end (), poller);
 
74
    bool start = pollers.empty ();
 
75
 
 
76
    std::list<MousePoller *>::iterator it =
 
77
            std::find (pollers.begin (), pollers.end (), poller);
 
78
 
84
79
    if (it != pollers.end ())
85
80
        return false;
86
81
 
98
93
void
99
94
MousepollScreen::removeTimer (MousePoller *poller)
100
95
{
101
 
    std::list<MousePoller *>::iterator it;
 
96
    std::list<MousePoller *>::iterator it =
 
97
        std::find (pollers.begin(), pollers.end (), poller);
102
98
 
103
 
    it = std::find (pollers.begin(), pollers.end (), poller);
104
99
    if (it == pollers.end ())
105
100
        return;
106
101
 
164
159
        compLogMessage ("mousepoll",
165
160
                        CompLogLevelWarn,
166
161
                        "Plugin version mismatch, can't stop mouse poller.");
167
 
 
168
162
        return;
169
163
    }
170
164
 
187
181
    MOUSEPOLL_SCREEN (screen);
188
182
 
189
183
    if (!ms)
190
 
    {
191
184
        compLogMessage ("mousepoll", CompLogLevelWarn,
192
185
                        "Plugin version mismatch, can't get mouse position.");
193
 
    }
194
186
    else
195
187
    {
196
188
        ms->getMousePosition ();
241
233
bool
242
234
MousepollPluginVTable::init ()
243
235
{
244
 
    if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
245
 
        return false;
246
 
 
247
 
    CompPrivate p;
248
 
    p.uval = COMPIZ_MOUSEPOLL_ABI;
249
 
    screen->storeValue ("mousepoll_ABI", p);
250
 
 
251
 
    return true;
 
236
    if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
 
237
    {
 
238
        CompPrivate p;
 
239
        p.uval = COMPIZ_MOUSEPOLL_ABI;
 
240
        screen->storeValue ("mousepoll_ABI", p);
 
241
        return true;
 
242
    }
 
243
 
 
244
    return false;
252
245
}
253
246
 
254
247
void