2665.2.25
by Sam Spilsbury
Move sources around into relevant files |
1 |
/*
|
2677
by Sam Spilsbury
Relicence eventsource.cpp to MIT |
2 |
* Copyright © 2010 Canonical Ltd.
|
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
|
|
2679
by Sam Spilsbury
s/Novell Inc./Canonical Ltd./ in eventsource.cpp copyright |
9 |
* Canonical Ltd. not be used in advertising or publicity pertaining to
|
2677
by Sam Spilsbury
Relicence eventsource.cpp to MIT |
10 |
* distribution of the software without specific, written prior permission.
|
2679
by Sam Spilsbury
s/Novell Inc./Canonical Ltd./ in eventsource.cpp copyright |
11 |
* Canonical Ltd. makes no representations about the suitability of this
|
2677
by Sam Spilsbury
Relicence eventsource.cpp to MIT |
12 |
* software for any purpose. It is provided "as is" without express or
|
13 |
* implied warranty.
|
|
14 |
*
|
|
15 |
* CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
16 |
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
|
17 |
* NO EVENT SHALL CANONICAL, LTD. 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.
|
|
2665.2.25
by Sam Spilsbury
Move sources around into relevant files |
22 |
*
|
23 |
* Authored by: Jason Smith <jason.smith@canonical.com>
|
|
24 |
* : Sam Spilsbury <sam.spilsbury@canonical.com>
|
|
25 |
*/
|
|
26 |
||
3132.1.8
by Alan Griffiths
Remove unnecessary includes of privatescreen.h |
27 |
#include "privateeventsource.h" |
28 |
#include "core/screen.h" |
|
2665.2.25
by Sam Spilsbury
Move sources around into relevant files |
29 |
|
3778.1.1
by Andrea Azzarone
Use Glib::RefPtr<Glib::Source> in glib_integration_test and compiz core too. After the fix of bug https://bugzilla.gnome.org/show_bug.cgi?id=561885 Glib::Source::~Source is called when both Source::unreference() and SourceCallbackData::destroy_notify_callback() are called. |
30 |
Glib::RefPtr<CompEventSource> |
2665.2.25
by Sam Spilsbury
Move sources around into relevant files |
31 |
CompEventSource::create () |
32 |
{
|
|
3778.1.1
by Andrea Azzarone
Use Glib::RefPtr<Glib::Source> in glib_integration_test and compiz core too. After the fix of bug https://bugzilla.gnome.org/show_bug.cgi?id=561885 Glib::Source::~Source is called when both Source::unreference() and SourceCallbackData::destroy_notify_callback() are called. |
33 |
return Glib::RefPtr<CompEventSource> (new CompEventSource (screen->dpy (), ConnectionNumber (screen->dpy ()))); |
2665.2.25
by Sam Spilsbury
Move sources around into relevant files |
34 |
}
|
35 |
||
36 |
sigc::connection |
|
37 |
CompEventSource::connect (const sigc::slot <bool> &slot) |
|
38 |
{
|
|
39 |
return connect_generic (slot); |
|
40 |
}
|
|
41 |
||
3494.2.1
by Sam Spilsbury
In order to safely destroy a Glib::Source you need to g_source_destroy its underlying gobj () |
42 |
CompEventSource::CompEventSource (Display *dpy, int fd) : |
2665.2.25
by Sam Spilsbury
Move sources around into relevant files |
43 |
Glib::Source (), |
3494.2.1
by Sam Spilsbury
In order to safely destroy a Glib::Source you need to g_source_destroy its underlying gobj () |
44 |
mDpy (dpy), |
3494.2.5
by Sam Spilsbury
We already have the connnection number use the provided fd |
45 |
mConnectionFD (fd) |
2665.2.25
by Sam Spilsbury
Move sources around into relevant files |
46 |
{
|
47 |
mPollFD.set_fd (mConnectionFD); |
|
48 |
mPollFD.set_events (Glib::IO_IN); |
|
49 |
||
50 |
set_priority (G_PRIORITY_DEFAULT); |
|
51 |
add_poll (mPollFD); |
|
52 |
set_can_recurse (true); |
|
53 |
||
54 |
connect (sigc::mem_fun <bool, CompEventSource> (this, &CompEventSource::callback)); |
|
55 |
}
|
|
56 |
||
57 |
CompEventSource::~CompEventSource () |
|
58 |
{
|
|
59 |
}
|
|
60 |
||
61 |
bool
|
|
62 |
CompEventSource::callback () |
|
63 |
{
|
|
2961.6.31
by Alan Griffiths
Remove a friend at the cost of a forwarding function |
64 |
screen->processEvents (); |
2665.2.25
by Sam Spilsbury
Move sources around into relevant files |
65 |
return true; |
66 |
}
|
|
67 |
||
68 |
bool
|
|
69 |
CompEventSource::prepare (int &timeout) |
|
70 |
{
|
|
71 |
timeout = -1; |
|
72 |
return XPending (mDpy); |
|
73 |
}
|
|
74 |
||
75 |
bool
|
|
76 |
CompEventSource::check () |
|
77 |
{
|
|
78 |
if (mPollFD.get_revents () & Glib::IO_IN) |
|
79 |
return XPending (mDpy); |
|
80 |
||
81 |
return false; |
|
82 |
}
|
|
83 |
||
84 |
bool
|
|
85 |
CompEventSource::dispatch (sigc::slot_base *slot) |
|
86 |
{
|
|
87 |
return (*static_cast <sigc::slot <bool> *> (slot)) (); |
|
88 |
}
|