discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=0d69422cca743a1c57b63995caee23ea16516ab7

commit 0d69422cca743a1c57b63995caee23ea16516ab7
Author: Derek Foreman <der...@osg.samsung.com>
Date:   Thu Feb 19 14:47:34 2015 -0500

    ecore-drm Add hooks for updating wl_output when outputs are hotplugged
    
    Summary:
    This provides callbacks to any bound wl_output listeners when a
    display is hotplugged.
    
    NOTE: Currently we don't receive hotplug events
    ANOTHER NOTE: We don't yet handle display removal
    
    Reviewers: devilhorns, zmike
    
    Reviewed By: devilhorns, zmike
    
    Subscribers: cedric
    
    Maniphest Tasks: T2131
    
    Differential Revision: https://phab.enlightenment.org/D2006
---
 src/lib/ecore_drm/Ecore_Drm.h         | 19 +++++++++++++++++
 src/lib/ecore_drm/ecore_drm.c         |  1 +
 src/lib/ecore_drm/ecore_drm_output.c  | 39 +++++++++++++++++++++++++++++++++++
 src/lib/ecore_drm/ecore_drm_private.h |  1 +
 4 files changed, 60 insertions(+)

diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h
index 17def6e..9ce2722 100644
--- a/src/lib/ecore_drm/Ecore_Drm.h
+++ b/src/lib/ecore_drm/Ecore_Drm.h
@@ -116,6 +116,19 @@ struct _Ecore_Drm_Event_Activate
    Eina_Bool active;
 };
 
+struct _Ecore_Drm_Event_Output
+{
+   int x, y;
+   int w, h;
+   int phys_width, phys_height;
+   unsigned int refresh;
+   int subpixel_order;
+   int transform;
+   const char *make;
+   const char *model;
+   Eina_Bool plug : 1;
+};
+
 /* opaque structure to represent a drm device */
 typedef struct _Ecore_Drm_Device Ecore_Drm_Device;
 
@@ -140,8 +153,14 @@ typedef struct _Ecore_Drm_Sprite Ecore_Drm_Sprite;
 /* structure to inform drm activation state */
 typedef struct _Ecore_Drm_Event_Activate Ecore_Drm_Event_Activate;
 
+/* structure to inform drm output plug events */
+/** @since 1.14 */
+typedef struct _Ecore_Drm_Event_Output Ecore_Drm_Event_Output;
+
 EAPI extern int ECORE_DRM_EVENT_ACTIVATE;
 
+EAPI extern int ECORE_DRM_EVENT_OUTPUT; /**< @since 1.14 */
+
 /**
  * @file
  * @brief Ecore functions for dealing with drm, virtual terminals
diff --git a/src/lib/ecore_drm/ecore_drm.c b/src/lib/ecore_drm/ecore_drm.c
index 81a6fa9..2ae0766 100644
--- a/src/lib/ecore_drm/ecore_drm.c
+++ b/src/lib/ecore_drm/ecore_drm.c
@@ -89,6 +89,7 @@ ecore_drm_init(void)
    if (!eeze_init()) goto eeze_err;
 
    ECORE_DRM_EVENT_ACTIVATE = ecore_event_type_new();
+   ECORE_DRM_EVENT_OUTPUT = ecore_event_type_new();
 
    /* return init count */
    return _ecore_drm_init_count;
diff --git a/src/lib/ecore_drm/ecore_drm_output.c 
b/src/lib/ecore_drm/ecore_drm_output.c
index 827a4fc..c264877 100644
--- a/src/lib/ecore_drm/ecore_drm_output.c
+++ b/src/lib/ecore_drm/ecore_drm_output.c
@@ -13,6 +13,8 @@ static const char *conn_types[] =
    "DP", "HDMI", "HDMI", "TV", "eDP",
 };
 
+EAPI int ECORE_DRM_EVENT_OUTPUT = 0;
+
 /* local functions */
 
 static Eina_Bool 
@@ -359,6 +361,8 @@ _ecore_drm_output_create(Ecore_Drm_Device *dev, drmModeRes 
*res, drmModeConnecto
    output->backlight = 
      _ecore_drm_output_backlight_init(output, conn->connector_type);
 
+   _ecore_drm_event_output_send(output, EINA_TRUE);
+
    return output;
 
 mode_err:
@@ -580,6 +584,41 @@ _ecore_drm_output_event(const char *device EINA_UNUSED, 
Eeze_Udev_Event event EI
      _ecore_drm_update_outputs(output);
 }
 
+static void
+_ecore_drm_event_output_free(void *data EINA_UNUSED, void *event)
+{
+   Ecore_Drm_Event_Output *e = event;
+
+   eina_stringshare_del(e->make);
+   eina_stringshare_del(e->model);
+   free(event);
+}
+
+void
+_ecore_drm_event_output_send(const Ecore_Drm_Output *output, Eina_Bool plug)
+{
+   Ecore_Drm_Event_Output *e;
+
+   if (!(e = calloc(1, sizeof(Ecore_Drm_Event_Output)))) return;
+   e->plug = plug;
+   if (plug)
+     {
+        e->w = output->current_mode->width;
+        e->h = output->current_mode->height;
+        e->x = output->x;
+        e->y = output->y;
+        e->phys_width = 0;
+        e->phys_height = 0;
+        e->refresh = output->current_mode->refresh;
+        e->subpixel_order = output->subpixel;
+        e->make = eina_stringshare_ref(output->make);
+        e->model = eina_stringshare_ref(output->model);
+        e->transform = 0;
+     }
+   ecore_event_add(ECORE_DRM_EVENT_OUTPUT, e,
+                   _ecore_drm_event_output_free, NULL);
+}
+
 /* public functions */
 
 /**
diff --git a/src/lib/ecore_drm/ecore_drm_private.h 
b/src/lib/ecore_drm/ecore_drm_private.h
index 444b1c0..03a7c27 100644
--- a/src/lib/ecore_drm/ecore_drm_private.h
+++ b/src/lib/ecore_drm/ecore_drm_private.h
@@ -234,6 +234,7 @@ struct _Ecore_Drm_Sprite
 typedef void (*Ecore_Drm_Open_Cb)(void *data, int fd, Eina_Bool b);
 
 void _ecore_drm_event_activate_send(Eina_Bool active);
+void _ecore_drm_event_output_send(const Ecore_Drm_Output *output, Eina_Bool 
plug);
 
 Eina_Bool _ecore_drm_launcher_device_open(const char *device, 
Ecore_Drm_Open_Cb callback, void *data, int flags);
 int _ecore_drm_launcher_device_open_no_pending(const char *device, int flags);

-- 


Reply via email to