summaryrefslogtreecommitdiff
path: root/src/lib/elput/elput_private.h
blob: 6b253d2fae3d67bf4cd3c17aca64811a8b33ef39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#ifndef _ELPUT_PRIVATE_H
# define _ELPUT_PRIVATE_H

# ifdef HAVE_CONFIG_H
#  include "config.h"
# endif

# include "Ecore.h"
# include "ecore_private.h"
# include "Ecore_Input.h"
# include "Eeze.h"
# include "Eldbus.h"
# include <Elput.h>

# include <ctype.h>
# include <sys/mman.h>
# include <fcntl.h>
# include <unistd.h>
# include <linux/vt.h>
# include <linux/kd.h>
# include <linux/major.h>
# include <linux/input.h>
# include <libinput.h>
# include <xkbcommon/xkbcommon.h>
# include <xkbcommon/xkbcommon-compose.h>

# ifdef HAVE_SYSTEMD
#  include <systemd/sd-login.h>
# endif

#ifndef ELPUT_NODEFS
# ifdef ELPUT_DEFAULT_LOG_COLOR
#  undef ELPUT_DEFAULT_LOG_COLOR
# endif
# define ELPUT_DEFAULT_LOG_COLOR EINA_COLOR_GREEN

extern int _elput_log_dom;

# ifdef ERR
#  undef ERR
# endif
# define ERR(...) EINA_LOG_DOM_ERR(_elput_log_dom, __VA_ARGS__)

# ifdef DBG
#  undef DBG
# endif
# define DBG(...) EINA_LOG_DOM_DBG(_elput_log_dom, __VA_ARGS__)

# ifdef INF
#  undef INF
# endif
# define INF(...) EINA_LOG_DOM_INFO(_elput_log_dom, __VA_ARGS__)

# ifdef WRN
#  undef WRN
# endif
# define WRN(...) EINA_LOG_DOM_WARN(_elput_log_dom, __VA_ARGS__)

# ifdef CRIT
#  undef CRIT
# endif
# define CRIT(...) EINA_LOG_DOM_CRIT(_elput_log_dom, __VA_ARGS__)
#endif
typedef struct _Elput_Interface
{
   Eina_Bool (*connect)(Elput_Manager **manager, const char *seat, unsigned int tty);
   void (*disconnect)(Elput_Manager *manager);
   int (*open)(Elput_Manager *manager, const char *path, int flags);
   void (*open_async)(Elput_Manager *manager, const char *path, int flags);
   void (*close)(Elput_Manager *manager, int fd);
   Eina_Bool (*vt_set)(Elput_Manager *manager, int vt);
} Elput_Interface;

typedef struct _Elput_Input
{
   struct libinput *lib;

   Ecore_Fd_Handler *hdlr;

   Eina_List *seats;
   Ecore_Thread *thread;
   Eldbus_Pending *current_pending;
   int pipe;
   int pointer_w, pointer_h;

   Eina_Bool suspended : 1;
} Elput_Input;

typedef struct _Elput_Keyboard_Info
{
   int refs;

   struct
     {
        int fd;
        size_t size;
        char *area;
        struct xkb_keymap *map;
     } keymap;

   struct
     {
        xkb_mod_index_t shift;
        xkb_mod_index_t caps;
        xkb_mod_index_t ctrl;
        xkb_mod_index_t alt;
        xkb_mod_index_t altgr;
        xkb_mod_index_t super;
     } mods;
} Elput_Keyboard_Info;

struct _Elput_Keyboard
{
   struct
     {
        unsigned int depressed;
        unsigned int latched;
        unsigned int locked;
        unsigned int group;
     } mods;

   struct
     {
        unsigned int key;
        unsigned int timestamp;
     } grab;

   Elput_Keyboard_Info *info;
   unsigned int key_count;

   struct xkb_state *state;
   struct xkb_state *maskless_state;
   struct xkb_context *context;
   struct xkb_rule_names names;
   struct xkb_compose_table *compose_table;
   struct xkb_compose_state *compose_state;

   Elput_Seat *seat;

   Eina_Bool pending_keymap : 1;
};

struct _Elput_Pointer
{
   int buttons;
   unsigned int timestamp;
   double pressure;

   int minx, miny;
   int hotx, hoty;

   struct
     {
        double x, y;
        unsigned int button;
        unsigned int timestamp;
     } grab;

   struct
     {
        unsigned int threshold;
        unsigned int last_button, prev_button;
        unsigned int last_time, prev_time;
        Eina_Bool double_click : 1;
        Eina_Bool triple_click : 1;
     } mouse;

   Elput_Seat *seat;
};

struct _Elput_Touch
{
   int slot;
   unsigned int points;
   unsigned int timestamp;
   double pressure;

   struct
     {
        int id;
        double x, y;
        unsigned int timestamp;
     } grab;

   Elput_Seat *seat;
};

struct _Elput_Seat
{
   int refs; //for events
   const char *name;

   struct
     {
        int kbd, ptr, touch;
     } count;

   struct
     {
        double x, y;
     } pointer;

   unsigned int modifiers;

   Elput_Keyboard *kbd;
   Elput_Pointer *ptr;
   Elput_Touch *touch;

   Eina_List *devices;
   Elput_Manager *manager;
   Eina_Bool pending_motion : 1;
};

struct _Elput_Device
{
   Elput_Seat *seat;
   int refs; //for events

   uint32_t ow, oh;

   const char *path;
   const char *output_name;
   struct libinput_device *device;

   Elput_Device_Caps caps;

   Eina_Hash *key_remap_hash;
   Eo *evas_device;

   Eina_Bool left_handed : 1;
   Eina_Bool key_remap : 1;
   Eina_Bool swap : 1;
   Eina_Bool invert_x : 1;
   Eina_Bool invert_y : 1;
};

struct _Elput_Manager
{
   Elput_Interface *interface;

   int fd;
   char *sid;
   const char *seat;
   unsigned int vt_num;
   int vt_fd;
   Ecore_Event_Handler *vt_hdlr;
   uint32_t window;

   int pending_ptr_x;
   int pending_ptr_y;

   struct
     {
        char *path;
        Eldbus_Object *obj;
        Eldbus_Connection *conn;
        Eldbus_Proxy *session;
        Eldbus_Proxy *manager;
     } dbus;

   struct
     {
        struct xkb_keymap *keymap;
        struct xkb_context *context;
        int group;
     } cached;
   int output_w, output_h;

   Elput_Input input;
   Eina_Bool del : 1;
};

typedef struct _Elput_Async_Open
{
   Elput_Manager *manager;
   char *path;
   int flags;
} Elput_Async_Open;

void _elput_input_enable(Elput_Manager *manager);
void _elput_input_disable(Elput_Manager *manager);

int _evdev_event_process(struct libinput_event *event);
Elput_Device *_evdev_device_create(Elput_Seat *seat, struct libinput_device *device);
void _evdev_device_destroy(Elput_Device *edev);
void _evdev_keyboard_destroy(Elput_Keyboard *kbd);
void _evdev_pointer_destroy(Elput_Pointer *ptr);
void _evdev_touch_destroy(Elput_Touch *touch);
void _evdev_pointer_motion_send(Elput_Device *edev);
void _evdev_device_calibrate(Elput_Device *dev);

Elput_Pointer *_evdev_pointer_get(Elput_Seat *seat);
Elput_Keyboard *_evdev_keyboard_get(Elput_Seat *seat);
Elput_Touch *_evdev_touch_get(Elput_Seat *seat);

extern Elput_Interface _logind_interface;

void _keyboard_keymap_update(Elput_Seat *seat);
void _keyboard_group_update(Elput_Seat *seat);


void _udev_seat_destroy(Elput_Seat *eseat);
#endif