• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2014 Red Hat, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #ifndef TIMER_H
25 #define TIMER_H
26 
27 #include <stdint.h>
28 
29 #include "libinput-util.h"
30 
31 struct libinput;
32 
33 struct libinput_timer {
34 	struct libinput *libinput;
35 	char *timer_name;
36 	struct list link;
37 	uint64_t expire; /* in absolute us CLOCK_MONOTONIC */
38 	void (*timer_func)(uint64_t now, void *timer_func_data);
39 	void *timer_func_data;
40 };
41 
42 void
43 libinput_timer_init(struct libinput_timer *timer, struct libinput *libinput,
44 		    const char *timer_name,
45 		    void (*timer_func)(uint64_t now, void *timer_func_data),
46 		    void *timer_func_data);
47 
48 void
49 libinput_timer_destroy(struct libinput_timer *timer);
50 
51 /* Set timer expire time, in absolute us CLOCK_MONOTONIC */
52 void
53 libinput_timer_set(struct libinput_timer *timer, uint64_t expire);
54 
55 enum timer_flags {
56 	TIMER_FLAG_NONE = 0,
57 	TIMER_FLAG_ALLOW_NEGATIVE = (1 << 0),
58 };
59 
60 void
61 libinput_timer_set_flags(struct libinput_timer *timer,
62 			 uint64_t expire,
63 			 uint32_t flags);
64 
65 void
66 libinput_timer_cancel(struct libinput_timer *timer);
67 
68 int
69 libinput_timer_subsys_init(struct libinput *libinput);
70 
71 void
72 libinput_timer_subsys_destroy(struct libinput *libinput);
73 
74 void
75 libinput_timer_flush(struct libinput *libinput, uint64_t now);
76 
77 #endif
78