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

git pushed a commit to branch devs/devilhorns/apos
in repository efl.

View the commit online.

commit f6b0565b2b35050c6fd9481033252c4653b60610
Author: Christopher Michael <devilho...@comcast.net>
AuthorDate: Wed Nov 22 07:39:26 2023 -0500

    ecore_drm2: Add event handler to listen for when devices get added
---
 src/lib/ecore_drm2/ecore_drm2_device.c  | 44 ++++++++++++++++++++++++++++++++-
 src/lib/ecore_drm2/ecore_drm2_private.h |  1 +
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c b/src/lib/ecore_drm2/ecore_drm2_device.c
index 1f9f5584cb..bf87befb0f 100644
--- a/src/lib/ecore_drm2/ecore_drm2_device.c
+++ b/src/lib/ecore_drm2/ecore_drm2_device.c
@@ -33,6 +33,45 @@ _ecore_drm2_device_cb_session_active(void *data EINA_UNUSED, int type EINA_UNUSE
    return ECORE_CALLBACK_RENEW;
 }
 
+static Eina_Bool
+_ecore_drm2_device_cb_device_change(void *data, int type EINA_UNUSED, void *event)
+{
+   Elput_Event_Device_Change *ev;
+   Ecore_Drm2_Device *dev;
+
+   ev = event;
+   dev = data;
+
+   if (ev->type == ELPUT_DEVICE_ADDED)
+     {
+        Eina_Stringshare *name;
+        Ecore_Drm2_Display *disp;
+
+        name = elput_device_output_name_get(ev->device);
+        if (!name)
+          {
+             disp = eina_list_data_get(dev->displays);
+             if (disp)
+               ecore_drm2_device_calibrate(dev, disp->w, disp->h);
+          }
+        else
+          {
+             Eina_List *l;
+
+             EINA_LIST_FOREACH(dev->displays, l, disp)
+               {
+                  if (eina_streq(disp->name, name))
+                    {
+                       ecore_drm2_device_calibrate(dev, disp->w, disp->h);
+                       break;
+                    }
+               }
+          }
+     }
+
+   return ECORE_CALLBACK_RENEW;
+}
+
 static Eina_Bool
 _ecore_drm2_device_modeset_capable_get(int fd)
 {
@@ -278,7 +317,9 @@ ecore_drm2_device_open(const char *seat, unsigned int tty)
      ecore_event_handler_add(ELPUT_EVENT_SESSION_ACTIVE,
                              _ecore_drm2_device_cb_session_active, dev);
 
-   /* TODO: event handler for device_change */
+   dev->device_hdlr =
+     ecore_event_handler_add(ELPUT_EVENT_DEVICE_CHANGE,
+                             _ecore_drm2_device_cb_device_change, dev);
 
    /* cleanup path variable */
    eina_stringshare_del(path);
@@ -314,6 +355,7 @@ ecore_drm2_device_close(Ecore_Drm2_Device *dev)
    _ecore_drm2_planes_destroy(dev);
    _ecore_drm2_crtcs_destroy(dev);
 
+   ecore_event_handler_del(dev->device_hdlr);
    ecore_event_handler_del(dev->session_hdlr);
 
    elput_input_shutdown(dev->em);
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h
index 9a98c86bc2..26b654125f 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -337,6 +337,7 @@ struct _Ecore_Drm2_Device
      } cursor;
 
    Ecore_Event_Handler *session_hdlr;
+   Ecore_Event_Handler *device_hdlr;
 
    Eina_List *crtcs;
    Eina_List *conns;

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

Reply via email to