~chasedouglas/geis/delta-test

« back to all changes in this revision

Viewing changes to libutouch-geis/backend/grail/geis_grail_xsync.h

  • Committer: Daniel d'Andrada
  • Date: 2012-03-30 16:44:52 UTC
  • Revision ID: daniel.dandrada@canonical.com-20120330164452-qlt41h39idaa7oom
grail backend: Use XSyncAlarms instead of XSyncAwait for setting up timers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @file geis_grail_xsync.h
 
3
 * @brief Handles XSync lib usage for the GEIS grail backend
 
4
 */
 
5
/*
 
6
 * Copyright 2012 Canonical Ltd.
 
7
 *
 
8
 * This file is part of UTouch GEIS.
 
9
 *
 
10
 * UTouch GEIS is free software: you can redistribute it and/or modify it
 
11
 * under the terms of the GNU Lesser General Public License as published by the
 
12
 * Free Software Foundation, either version 3 of the License, or (at your
 
13
 * option) any later version.
 
14
 *
 
15
 * UTouch GEIS is distributed in the hope that it will be useful, but WITHOUT
 
16
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
17
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 
18
 * details.
 
19
 *
 
20
 * You should have received a copy of the GNU Lesser General Public License
 
21
 * along with UTouch GEIS.  If not, see <http://www.gnu.org/licenses/>.
 
22
 */
 
23
 
 
24
#ifndef GEIS_BACKEND_GRAIL_XSYNC_H_
 
25
#define GEIS_BACKEND_GRAIL_XSYNC_H_
 
26
 
 
27
#include <X11/Xlib.h> // For Display and XEvent
 
28
#include <stdint.h> // For uint64_t
 
29
#include "geis/geisimpl.h" // For GeisBoolean
 
30
 
 
31
/**
 
32
 * The opaque "X Synchronization Extension Library" handler
 
33
 *
 
34
 * It facilitates and encapsulates the use of the XSync extension. Specially
 
35
 * by managing the XSyncAlarm instances needed to implement timeouts.
 
36
 */
 
37
typedef struct GeisGrailXSync *GeisGrailXSync;
 
38
 
 
39
/**
 
40
 * Constructs a new GeisGrailXSync instance.
 
41
 *
 
42
 * It returns NULL if the initialization wasn't successful.
 
43
 *
 
44
 * OBS: Having multiple GeisGrailXSync instances is not supported and doesn't
 
45
 * make sense.
 
46
 */
 
47
GeisGrailXSync
 
48
geis_grail_xsync_new(Display *display);
 
49
 
 
50
/**
 
51
 * Destroys the given GeisGrailXSync
 
52
 */
 
53
void
 
54
geis_grail_xsync_delete(GeisGrailXSync xsync);
 
55
 
 
56
 
 
57
/**
 
58
 * Creates an XSyncAlarm with the given timeout
 
59
 *
 
60
 * If there's already an XSyncAlarm with that timeout,
 
61
 * nothing is done.
 
62
 *
 
63
 * An XSyncAlarmNotifyEvent will be sent once that timeout
 
64
 * is reached on the server.
 
65
 */
 
66
void
 
67
geis_grail_xsync_set_timeout(GeisGrailXSync xsync, uint64_t timeout);
 
68
 
 
69
/**
 
70
 * Returns true if the given XEvent is an XSyncAlarmNotifyEvent for
 
71
 * one of the existing XSyncAlarm instances and false otherwise.
 
72
 *
 
73
 * It also takes care of destroying the XSyncAlarm that had its
 
74
 * timeout reached.
 
75
 */
 
76
GeisBoolean
 
77
geis_grail_xsync_is_timeout(GeisGrailXSync xsync, const XEvent *event);
 
78
 
 
79
/**
 
80
 * Gets the server time contained in the given event.
 
81
 *
 
82
 * That event must be an XSyncAlarmNotifyEvent. It will be the case when
 
83
 * geis_grail_xsync_is_timeout() returns GeisTrue for it.
 
84
 *
 
85
 */
 
86
uint64_t
 
87
geis_grail_xsync_get_server_time(const XEvent *event);
 
88
 
 
89
#endif // GEIS_BACKEND_GRAIL_XSYNC_H_