This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch v-1.29
in repository efl-mxd.

View the commit online.

commit 347ac0fd11ce702219b10838a97443317d40b620
Author: Valera <[email protected]>
AuthorDate: Sun Nov 22 06:28:06 2026 +0000

    Загрузить файлы в «src/lib/elput»
---
 src/lib/elput/elput_manager.c | 144 ++++++++++++++++++
 src/lib/elput/elput_private.h | 340 ++++++++++++++++++++++++++++++++++++++++++
 src/lib/elput/elput_root.c    | 150 +++++++++++++++++++
 src/lib/elput/elput_seatd.c   | 234 +++++++++++++++++++++++++++++
 src/lib/elput/elput_touch.c   | 179 ++++++++++++++++++++++
 5 files changed, 1047 insertions(+)

diff --git a/src/lib/elput/elput_manager.c b/src/lib/elput/elput_manager.c
new file mode 100644
index 0000000000..ec2aa1fbcb
--- /dev/null
+++ b/src/lib/elput/elput_manager.c
@@ -0,0 +1,144 @@
+#include "elput_private.h"
+
+static Elput_Interface *_ifaces[] =
+{
+#ifdef HAVE_SEATD
+   &_seatd_interface,
+#endif
+#ifdef HAVE_SYSTEMD
+   &_logind_interface,
+#endif
+   &_root_interface,
+   NULL,
+};
+
+static Eina_Bool
+_cb_key_down(void *data, int type EINA_UNUSED, void *event)
+{
+   Elput_Manager *em;
+   Ecore_Event_Key *ev;
+   int code = 0, vt = 0;
+
+   em = data;
+   ev = event;
+   code = (ev->keycode - 8);
+
+   if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
+       (ev->modifiers & ECORE_EVENT_MODIFIER_ALT) &&
+       (code >= KEY_F1) && (code <= KEY_F8))
+     {
+        vt = (code - KEY_F1 + 1);
+        if (em->interface->vt_set)
+          {
+             if (!em->interface->vt_set(em, vt))
+               ERR("Failed to switch to virtual terminal %d", vt);
+          }
+     }
+
+   return ECORE_CALLBACK_RENEW;
+}
+
+EAPI Elput_Manager *
+elput_manager_connect(const char *seat, unsigned int tty)
+{
+   Elput_Interface **it;
+
+   for (it = _ifaces; *it != NULL; it++)
+     {
+        Elput_Interface *iface;
+        Elput_Manager *em;
+
+        iface = *it;
+        if (iface->connect(&em, seat, tty))
+          return em;
+     }
+
+   return NULL;
+}
+
+EAPI void
+elput_manager_disconnect(Elput_Manager *manager)
+{
+   EINA_SAFETY_ON_NULL_RETURN(manager);
+   EINA_SAFETY_ON_NULL_RETURN(manager->interface);
+
+   if (manager->input.thread)
+     {
+        ecore_thread_cancel(manager->input.thread);
+        manager->del = 1;
+        return;
+     }
+
+   if (manager->interface->disconnect)
+     manager->interface->disconnect(manager);
+}
+
+EAPI int
+elput_manager_open(Elput_Manager *manager, const char *path, int flags)
+{
+   int ret = -1;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(manager, -1);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(manager->interface, -1);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(path, -1);
+
+   if (flags < 0) flags = O_RDWR;
+
+   if (manager->interface->open)
+     {
+        ret = manager->interface->open(manager, path, flags);
+        if (ret)
+          {
+             manager->vt_hdlr =
+               ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
+                                       _cb_key_down, manager);
+             manager->vt_fd = ret;
+          }
+     }
+
+   return ret;
+}
+
+EAPI void
+elput_manager_close(Elput_Manager *manager, int fd)
+{
+   EINA_SAFETY_ON_NULL_RETURN(manager);
+   EINA_SAFETY_ON_NULL_RETURN(manager->interface);
+
+   if (fd == manager->vt_fd)
+     {
+        if (manager->vt_hdlr) ecore_event_handler_del(manager->vt_hdlr);
+        manager->vt_hdlr = NULL;
+     }
+
+   if (manager->interface->close)
+     manager->interface->close(manager, fd);
+}
+
+EAPI Eina_Bool
+elput_manager_vt_set(Elput_Manager *manager, int vt)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(manager, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(manager->interface, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL((vt < 0), EINA_FALSE);
+
+   if (manager->interface->vt_set)
+     return manager->interface->vt_set(manager, vt);
+
+   return EINA_FALSE;
+}
+
+EAPI void
+elput_manager_window_set(Elput_Manager *manager, unsigned int window)
+{
+   EINA_SAFETY_ON_NULL_RETURN(manager);
+
+   manager->window = window;
+}
+
+EAPI const Eina_List *
+elput_manager_seats_get(Elput_Manager *manager)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(manager, NULL);
+   return manager->input.seats;
+}
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h
new file mode 100644
index 0000000000..a0da331188
--- /dev/null
+++ b/src/lib/elput/elput_private.h
@@ -0,0 +1,340 @@
+#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 <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>
+
+struct libseat;
+
+#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;
+   int rotation;
+
+   Eina_Bool suspended : 1;
+} Elput_Input;
+
+typedef enum _Elput_Leds
+{
+   ELPUT_LED_NUM = (1 << 0),
+   ELPUT_LED_CAPS = (1 << 1),
+   ELPUT_LED_SCROLL = (1 << 2)
+} Elput_Leds;
+
+typedef struct _Elput_Keyboard_Info
+{
+   int refs;
+
+   struct
+     {
+        struct xkb_keymap *map;
+     } keymap;
+
+   struct
+     {
+        xkb_mod_index_t shift;
+        xkb_mod_index_t caps;
+        xkb_mod_index_t num;
+        xkb_mod_index_t ctrl;
+        xkb_mod_index_t alt;
+        xkb_mod_index_t altgr;
+        xkb_mod_index_t super;
+     } mods;
+
+   struct
+     {
+        xkb_led_index_t num;
+        xkb_led_index_t caps;
+        xkb_led_index_t scroll;
+     } leds;
+} 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_Leds leds;
+
+   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;
+
+   double absx, absy;
+
+   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_Swipe_Gesture
+{
+   double dx, dy;
+   int finger_count;
+   int window;
+   Elput_Device *device;
+};
+
+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 libseat *conn;
+        Eina_Hash *devices;
+     } seatd;
+
+   struct
+     {
+        struct xkb_keymap *keymap;
+        struct xkb_context *context;
+        int group;
+     } cached;
+   int output_w, output_h;
+
+   int drm_opens;
+
+   Elput_Input input;
+   Eina_Bool del : 1;
+   Eina_Bool only_gesture_events : 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);
+int _gesture_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;
+extern Elput_Interface _root_interface;
+#ifdef HAVE_SEATD
+extern Elput_Interface _seatd_interface;
+#endif
+
+void _keyboard_keymap_update(Elput_Seat *seat);
+void _keyboard_group_update(Elput_Seat *seat);
+
+void _udev_seat_destroy(Elput_Seat *eseat);
+
+#endif
diff --git a/src/lib/elput/elput_root.c b/src/lib/elput/elput_root.c
new file mode 100644
index 0000000000..3d69dc0e3e
--- /dev/null
+++ b/src/lib/elput/elput_root.c
@@ -0,0 +1,150 @@
+#include "elput_private.h"
+#include <grp.h>
+#include <sys/types.h>
+#include <pwd.h>
+
+# ifdef major
+#  define MAJOR(x) major(x)
+# else
+#  define MAJOR(x) ((((x) >> 8) & 0xfff) | (((x) >> 32) & ~0xfff))
+# endif
+
+static Eina_Bool
+_user_part_of_input(void)
+{
+   uid_t user;
+   struct passwd *user_pw;
+   gid_t *gids = NULL;
+   int number_of_groups = 0;
+   struct group *input_group;
+
+   user = getuid();
+   user_pw = getpwuid(user);
+   input_group = getgrnam("input");
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(user_pw, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input_group, EINA_FALSE);
+
+   if (getgrouplist(user_pw->pw_name, getgid(), NULL, &number_of_groups) != -1)
+     {
+        ERR("Failed to enumerate groups of user");
+        return EINA_FALSE;
+     }
+   number_of_groups ++;
+   gids = alloca((number_of_groups) * sizeof(gid_t));
+   if (getgrouplist(user_pw->pw_name, getgid(), gids, &number_of_groups) == -1)
+     {
+        ERR("Failed to get groups of user");
+        return EINA_FALSE;
+     }
+
+   for (int i = 0; i < number_of_groups; ++i)
+     {
+        if (gids[i] == input_group->gr_gid)
+          return EINA_TRUE;
+     }
+   return EINA_FALSE;
+}
+
+static Eina_Bool
+_root_connect(Elput_Manager **manager EINA_UNUSED, const char *seat EINA_UNUSED, unsigned int tty EINA_UNUSED)
+{
+   Elput_Manager *em;
+
+   em = calloc(1, sizeof(Elput_Manager));
+   if (!em) return EINA_FALSE;
+
+   em->interface = &_root_interface;
+   em->seat = eina_stringshare_add(seat);
+
+   if (!_user_part_of_input())
+     {
+        free(em);
+        return EINA_FALSE;
+     }
+   *manager = em;
+   return EINA_TRUE;
+}
+
+static void
+_root_disconnect(Elput_Manager *em EINA_UNUSED)
+{
+   //Nothing to do here, there is no data to free
+}
+
+static int
+_root_open(Elput_Manager *em EINA_UNUSED, const char *path, int flags)
+{
+   struct stat st;
+   int ret, fd = -1;
+   int fl;
+
+   ret = stat(path, &st);
+   if (ret < 0) return -1;
+
+   if (!S_ISCHR(st.st_mode)) return -1;
+
+   fd = open(path, flags);
+   if (fd < 0) return fd;
+
+   if (MAJOR(st.st_rdev) == 226) //DRM_MAJOR
+     em->drm_opens++;
+
+   fl = fcntl(fd, F_GETFL);
+   if (fl < 0) goto err;
+
+   if (flags & O_NONBLOCK)
+     fl |= O_NONBLOCK;
+
+   ret = fcntl(fd, F_SETFL, fl);
+   if (ret < 0) goto err;
+
+   return fd;
+err:
+   close(fd);
+   return -1;
+}
+
+static void
+_root_open_async(Elput_Manager *em, const char *path, int flags)
+{
+   int fd, ret;
+
+   fd = _root_open(em, path, flags);
+   while (1)
+     {
+        ret = write(em->input.pipe, &fd, sizeof(int));
+        if (ret < 0)
+          {
+             if ((errno == EAGAIN) || (errno == EINTR))
+               continue;
+             WRN("Failed to write to input pipe");
+          }
+        break;
+     }
+   close(em->input.pipe);
+   em->input.pipe = -1;
+}
+
+static void
+_root_close(Elput_Manager *em EINA_UNUSED, int fd)
+{
+   close(fd);
+}
+
+static Eina_Bool
+_root_vt_set(Elput_Manager *em EINA_UNUSED, int vt EINA_UNUSED)
+{
+   //Nothing to do here
+   return EINA_TRUE;
+}
+
+Elput_Interface _root_interface =
+{
+   _root_connect,
+   _root_disconnect,
+   _root_open,
+   _root_open_async,
+   _root_close,
+   _root_vt_set,
+};
diff --git a/src/lib/elput/elput_seatd.c b/src/lib/elput/elput_seatd.c
new file mode 100644
index 0000000000..dca9a4d38c
--- /dev/null
+++ b/src/lib/elput/elput_seatd.c
@@ -0,0 +1,234 @@
+#include "elput_private.h"
+
+#ifdef HAVE_SEATD
+
+#include <libseat.h>
+
+static void
+_seatd_pipe_write_fd(Elput_Manager *em, int fd)
+{
+   int ret;
+
+   while (1)
+     {
+        ret = write(em->input.pipe, &fd, sizeof(int));
+        if (ret < 0)
+          {
+             if ((errno == EAGAIN) || (errno == EINTR))
+               continue;
+             WRN("seatd: failed to write to input pipe");
+          }
+        break;
+     }
+   close(em->input.pipe);
+   em->input.pipe = -1;
+}
+
+
+static void
+_seatd_session_active_cb_free(void *data EINA_UNUSED, void *event)
+{
+   Elput_Event_Session_Active *ev;
+
+   ev = event;
+   eina_stringshare_del(ev->session);
+   free(ev);
+}
+
+static void
+_seatd_session_active_send(Elput_Manager *em, Eina_Bool active)
+{
+   Elput_Event_Session_Active *ev;
+
+   if (active)
+     _elput_input_enable(em);
+   else
+     _elput_input_disable(em);
+
+   ev = calloc(1, sizeof(Elput_Event_Session_Active));
+   if (!ev) return;
+
+   ev->session = eina_stringshare_add(em->sid);
+   ev->active = active;
+
+   ecore_event_add(ELPUT_EVENT_SESSION_ACTIVE, ev,
+                   _seatd_session_active_cb_free, NULL);
+}
+
+
+static void
+_seatd_enable_seat(struct libseat *seat EINA_UNUSED, void *data)
+{
+   Elput_Manager *em = data;
+
+   DBG("seatd: seat enabled");
+   _seatd_session_active_send(em, EINA_TRUE);
+}
+
+static void
+_seatd_disable_seat(struct libseat *seat, void *data)
+{
+   Elput_Manager *em = data;
+
+   DBG("seatd: seat disabled");
+   _seatd_session_active_send(em, EINA_FALSE);
+
+   libseat_disable_seat(seat);
+}
+
+static const struct libseat_seat_listener _seatd_listener =
+{
+   .enable_seat  = _seatd_enable_seat,
+   .disable_seat = _seatd_disable_seat,
+};
+
+
+static Eina_Bool
+_seatd_connect(Elput_Manager **manager, const char *seat, unsigned int tty EINA_UNUSED)
+{
+   Elput_Manager *em;
+   char sid[64];
+
+   em = calloc(1, sizeof(Elput_Manager));
+   if (!em) return EINA_FALSE;
+
+   em->interface = &_seatd_interface;
+   em->seat = eina_stringshare_add(seat ? seat : "seat0");
+
+   /* Seatd не даёт session id — генерируем свой */
+   snprintf(sid, sizeof(sid), "seatd-%d", (int)getpid());
+   em->sid = strdup(sid);
+   if (!em->sid) goto sid_err;
+
+   em->seatd.devices = eina_hash_int32_new(NULL);
+   if (!em->seatd.devices)
+     {
+        ERR("seatd: could not create device hash");
+        goto hash_err;
+     }
+
+   em->seatd.conn =
+     libseat_open_seat((struct libseat_seat_listener *)&_seatd_listener, em);
+   if (!em->seatd.conn)
+     {
+        ERR("seatd: could not open seat");
+        goto seat_err;
+     }
+
+   *manager = em;
+   return EINA_TRUE;
+
+seat_err:
+   eina_hash_free(em->seatd.devices);
+   em->seatd.devices = NULL;
+hash_err:
+   free(em->sid);
+   em->sid = NULL;
+sid_err:
+   eina_stringshare_del(em->seat);
+   free(em);
+   return EINA_FALSE;
+}
+
+static void
+_seatd_disconnect(Elput_Manager *em)
+{
+   if (em->seatd.conn)
+     {
+        libseat_close_seat(em->seatd.conn);
+        em->seatd.conn = NULL;
+     }
+
+   if (em->seatd.devices)
+     {
+        eina_hash_free(em->seatd.devices);
+        em->seatd.devices = NULL;
+     }
+
+   eina_stringshare_del(em->seat);
+   free(em->sid);
+   if (em->cached.context) xkb_context_unref(em->cached.context);
+   if (em->cached.keymap) xkb_keymap_unref(em->cached.keymap);
+   free(em);
+}
+
+static int
+_seatd_open(Elput_Manager *em, const char *path, int flags)
+{
+   int fd = -1;
+   int id;
+
+   if (!em->seatd.conn) return -1;
+
+   id = libseat_open_device(em->seatd.conn, path, &fd);
+   if (id < 0 || fd < 0)
+     {
+        WRN("seatd: could not open device %s", path);
+        return -1;
+     }
+
+   if (flags & O_NONBLOCK)
+     {
+        int fl = fcntl(fd, F_GETFL);
+        if (fl >= 0)
+          fcntl(fd, F_SETFL, fl | O_NONBLOCK);
+     }
+
+   eina_hash_add(em->seatd.devices, &fd, (void *)(intptr_t)id);
+
+   DBG("seatd: opened %s (fd=%d, id=%d)", path, fd, id);
+   return fd;
+}
+
+static void
+_seatd_open_async(Elput_Manager *em, const char *path, int flags)
+{
+
+   int fd = _seatd_open(em, path, flags);
+   _seatd_pipe_write_fd(em, fd);
+}
+
+static void
+_seatd_close(Elput_Manager *em, int fd)
+{
+   int id;
+
+   id = (int)(intptr_t)eina_hash_find(em->seatd.devices, &fd);
+   if (id > 0)
+     {
+        eina_hash_del(em->seatd.devices, &fd, NULL);
+        if (em->seatd.conn)
+          libseat_close_device(em->seatd.conn, id);
+     }
+   else
+     {
+        WRN("seatd: closing unknown fd %d", fd);
+     }
+
+   close(fd);
+}
+
+static Eina_Bool
+_seatd_vt_set(Elput_Manager *em, int vt)
+{
+   if (!em->seatd.conn) return EINA_FALSE;
+
+   if (libseat_switch_session(em->seatd.conn, vt) < 0)
+     {
+        ERR("seatd: could not switch to session/VT %d", vt);
+        return EINA_FALSE;
+     }
+   return EINA_TRUE;
+}
+
+Elput_Interface _seatd_interface =
+{
+   _seatd_connect,
+   _seatd_disconnect,
+   _seatd_open,
+   _seatd_open_async,
+   _seatd_close,
+   _seatd_vt_set,
+};
+
+#endif /* HAVE_SEATD */
\ No newline at end of file
diff --git a/src/lib/elput/elput_touch.c b/src/lib/elput/elput_touch.c
new file mode 100644
index 0000000000..dca8d9fcfc
--- /dev/null
+++ b/src/lib/elput/elput_touch.c
@@ -0,0 +1,179 @@
+#include "elput_private.h"
+
+static inline Eina_Bool
+_check_status(int ret)
+{
+   if (ret == LIBINPUT_CONFIG_STATUS_SUCCESS)
+     return EINA_TRUE;
+   return EINA_FALSE;
+}
+
+EAPI Eina_Bool
+elput_touch_drag_enabled_set(Elput_Device *device, Eina_Bool enabled)
+{
+   int ret = -1;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
+
+   if (enabled)
+     {
+        ret =
+          libinput_device_config_tap_set_drag_enabled(device->device,
+                                                      LIBINPUT_CONFIG_DRAG_ENABLED);
+     }
+   else
+     {
+        ret =
+          libinput_device_config_tap_set_drag_enabled(device->device,
+                                                      LIBINPUT_CONFIG_DRAG_DISABLED);
+     }
+
+   return _check_status(ret);
+}
+
+EAPI Eina_Bool
+elput_touch_drag_enabled_get(Elput_Device *device)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
+
+   return libinput_device_config_tap_get_drag_enabled(device->device);
+}
+
+EAPI Eina_Bool
+elput_touch_drag_lock_enabled_set(Elput_Device *device, Eina_Bool enabled)
+{
+   int ret = -1;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
+
+   if (enabled)
+     {
+        ret =
+          libinput_device_config_tap_set_drag_lock_enabled(device->device,
+                                                           LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
+     }
+   else
+     {
+        ret =
+          libinput_device_config_tap_set_drag_lock_enabled(device->device,
+                                                           LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
+     }
+
+   return _check_status(ret);
+}
+
+EAPI Eina_Bool
+elput_touch_drag_lock_enabled_get(Elput_Device *device)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
+
+   return libinput_device_config_tap_get_drag_lock_enabled(device->device);
+}
+
+EAPI Eina_Bool
+elput_touch_dwt_enabled_set(Elput_Device *device, Eina_Bool enabled)
+{
+   int ret = -1;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
+
+   if (!libinput_device_config_dwt_is_available(device->device))
+     return EINA_FALSE;
+
+   if (enabled)
+     {
+        ret =
+          libinput_device_config_dwt_set_enabled(device->device,
+                                                 LIBINPUT_CONFIG_DWT_ENABLED);
+     }
+   else
+     {
+        ret =
+          libinput_device_config_dwt_set_enabled(device->device,
+                                                 LIBINPUT_CONFIG_DWT_DISABLED);
+     }
+
+   return _check_status(ret);
+}
+
+EAPI Eina_Bool
+elput_touch_dwt_enabled_get(Elput_Device *device)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
+
+   if (!libinput_device_config_dwt_is_available(device->device))
+     return EINA_FALSE;
+
+   return libinput_device_config_dwt_get_enabled(device->device);
+}
+
+EAPI Eina_Bool
+elput_touch_scroll_method_set(Elput_Device *device, int method)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
+
+   if (libinput_device_config_scroll_set_method(device->device, method) ==
+       LIBINPUT_CONFIG_STATUS_SUCCESS)
+     return EINA_TRUE;
+
+   return EINA_FALSE;
+}
+
+EAPI int
+elput_touch_scroll_method_get(Elput_Device *device)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, -1);
+
+   return libinput_device_config_scroll_get_method(device->device);
+}
+
+EAPI Eina_Bool
+elput_touch_click_method_set(Elput_Device *device, int method)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
+
+   if (libinput_device_config_click_set_method(device->device, method) ==
+       LIBINPUT_CONFIG_STATUS_SUCCESS)
+     return EINA_TRUE;
+
+   return EINA_FALSE;
+}
+
+EAPI int
+elput_touch_click_method_get(Elput_Device *device)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, -1);
+
+   return libinput_device_config_click_get_method(device->device);
+}
+
+EAPI Eina_Bool
+elput_touch_tap_enabled_set(Elput_Device *device, Eina_Bool enabled)
+{
+   int ret = -1;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
+
+   if (enabled)
+     {
+        ret =
+          libinput_device_config_tap_set_enabled(device->device,
+                                                 LIBINPUT_CONFIG_TAP_ENABLED);
+     }
+   else
+     {
+        ret =
+          libinput_device_config_tap_set_enabled(device->device,
+                                                 LIBINPUT_CONFIG_TAP_DISABLED);
+     }
+
+   return _check_status(ret);
+}
+
+EAPI Eina_Bool
+elput_touch_tap_enabled_get(Elput_Device *device)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
+
+   return libinput_device_config_tap_get_enabled(device->device);
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to