14
14
* Lesser General Public License for more details.
16
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the
18
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
* Boston, MA 02111-1307, USA.
17
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
22
22
#ifdef HAVE_CONFIG_H
74
clutter_event_source_new (ClutterBackend *backend)
75
clutter_event_source_new (ClutterBackendEGL *backend)
76
77
GSource *source = g_source_new (&event_funcs, sizeof (ClutterEventSource));
77
78
ClutterEventSource *event_source = (ClutterEventSource *) source;
95
_clutter_events_init (ClutterBackend *backend)
96
_clutter_events_egl_init (ClutterBackendEGL *backend_egl)
97
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
99
98
ClutterEventSource *event_source;
99
const char *device_name;
101
102
CLUTTER_NOTE (EVENT, "Starting timer");
102
103
g_assert (backend_egl->event_timer != NULL);
103
104
g_timer_start (backend_egl->event_timer);
105
106
#ifdef HAVE_TSLIB
106
/* FIXME LEAK on error paths */
107
source = backend_egl->event_source = clutter_event_source_new (backend);
107
source = backend_egl->event_source = clutter_event_source_new (backend_egl);
108
108
event_source = (ClutterEventSource *) source;
110
event_source->ts_device = ts_open (g_getenv ("TSLIB_TSDEVICE"), 0);
110
device_name = g_getenv ("TSLIB_TSDEVICE");
111
if (device_name == NULL || device_name[0] == '\0')
113
g_warning ("No device for TSLib has been defined; please set the "
114
"TSLIB_TSDEVICE environment variable to define a touch "
115
"screen device to be used with Clutter.");
116
g_source_unref (source);
120
event_source->ts_device = ts_open (device_name, 0);
112
121
if (event_source->ts_device)
114
CLUTTER_NOTE (EVENT, "Opened '%s'", g_getenv ("TSLIB_TSDEVICE"));
123
CLUTTER_NOTE (EVENT, "Opened '%s'", device_name);
116
125
if (ts_config (event_source->ts_device))
118
g_warning ("ts_config() failed");
127
g_warning ("Closing device '%s': ts_config() failed", device_name);
119
128
ts_close (event_source->ts_device);
129
g_source_unref (source);
123
133
g_source_set_priority (source, CLUTTER_PRIORITY_EVENTS);
124
event_source->event_poll_fd.fd = ts_fd(event_source->ts_device);
134
event_source->event_poll_fd.fd = ts_fd (event_source->ts_device);
125
135
event_source->event_poll_fd.events = G_IO_IN;
127
137
event_sources = g_list_prepend (event_sources, event_source);
131
141
g_source_attach (source, NULL);
134
g_warning ("ts_open() failed opening %s'",
135
g_getenv("TSLIB_TSDEVICE") ?
136
g_getenv("TSLIB_TSDEVICE") : "None, TSLIB_TSDEVICE not set");
145
g_warning ("Unable to open '%s'", device_name);
146
g_source_unref (source);
148
#endif /* HAVE_TSLIB */
141
_clutter_events_uninit (ClutterBackend *backend)
152
_clutter_events_egl_uninit (ClutterBackendEGL *backend_egl)
143
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend);
145
if (backend_egl->event_timer)
154
if (backend_egl->event_timer != NULL)
147
156
CLUTTER_NOTE (EVENT, "Stopping the timer");
148
157
g_timer_stop (backend_egl->event_timer);
151
if (backend_egl->event_source)
160
if (backend_egl->event_source != NULL)
153
162
CLUTTER_NOTE (EVENT, "Destroying the event source");
158
167
#ifdef HAVE_TSLIB
159
168
ts_close (event_source->ts_device);
160
event_sources = g_list_remove (event_sources,
161
backend_egl->event_source);
169
event_sources = g_list_remove (event_sources, backend_egl->event_source);
170
#endif /* HAVE_TSLIB */
163
172
g_source_destroy (backend_egl->event_source);
164
173
g_source_unref (backend_egl->event_source);
165
174
backend_egl->event_source = NULL;
222
228
#ifdef HAVE_TSLIB
223
229
/* FIXME while would be better here but need to deal with lockups */
224
230
if ((!clutter_events_pending()) &&
225
(ts_read(event_source->ts_device, &tsevent, 1) == 1))
231
(ts_read(event_source->ts_device, &tsevent, 1) == 1))
227
233
/* Avoid sending too many events which are just pressure changes.
228
* We dont current handle pressure in events (FIXME) and thus
235
* FIXME - We don't current handle pressure in events and thus
229
236
* event_button_generate gets confused generating lots of double
230
237
* and triple clicks.