devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=7fb23c2da13eb204b54e94bd18083d125e941b8f

commit 7fb23c2da13eb204b54e94bd18083d125e941b8f
Author: Christopher Michael <[email protected]>
Date:   Tue Nov 19 09:16:31 2019 -0500

    ecore-wl2: Add API to find a connected display given a name
    
    This patch adds a convenience function to find a connected display
    given a name
    
    @feature
---
 src/lib/ecore_wl2/Ecore_Wl2.h         | 16 ++++++++++++++++
 src/lib/ecore_wl2/ecore_wl2_display.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h
index 38c81055f1..ffb32e390d 100644
--- a/src/lib/ecore_wl2/Ecore_Wl2.h
+++ b/src/lib/ecore_wl2/Ecore_Wl2.h
@@ -726,6 +726,22 @@ EAPI const char *ecore_wl2_display_name_get(const 
Ecore_Wl2_Display *display);
  */
 EAPI Ecore_Wl2_Window 
*ecore_wl2_display_window_find_by_surface(Ecore_Wl2_Display *display, struct 
wl_surface *surface);
 
+/**
+ * Gets the connected display object
+ *
+ * @brief This function is typically used by clients to get an
+ * ​existing Wayland display.
+ *
+ * ​@param name The display target name. If @c NULL, the default
+ *             display is assumed.
+ *
+ * ​@return The Ecore_Wl2_Display which was connected to
+ *
+ * ​@ingroup Ecore_Wl2_Display_Group
+ * ​@since 1.24
+ */
+EAPI Ecore_Wl2_Display *ecore_wl2_connected_display_get(const char *name);
+
 /**
  * @defgroup Ecore_Wl2_Window_Group Wayland Library Window Functions
  * @ingroup Ecore_Wl2_Group
diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c 
b/src/lib/ecore_wl2/ecore_wl2_display.c
index 85873fac69..267e62511d 100644
--- a/src/lib/ecore_wl2/ecore_wl2_display.c
+++ b/src/lib/ecore_wl2/ecore_wl2_display.c
@@ -1169,3 +1169,34 @@ 
ecore_wl2_display_window_find_by_surface(Ecore_Wl2_Display *display, struct wl_s
 {
    return _ecore_wl2_display_window_surface_find(display, surface);
 }
+
+EAPI Ecore_Wl2_Display *
+ecore_wl2_connected_display_get(const char *name)
+{
+   Ecore_Wl2_Display *ewd;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(_client_displays, NULL);
+
+   if (!name)
+     {
+        const char *n;
+
+        /* client wants to connected to default display */
+        n = getenv("WAYLAND_DISPLAY");
+        if (!n) n = "wayland-0";
+
+        /* we have a default wayland display */
+
+        /* check hash of cached client displays for this name */
+        ewd = eina_hash_find(_client_displays, n);
+     }
+   else
+     {
+        /* client wants to connect to specific display */
+
+        /* check hash of cached client displays for this name */
+        ewd = eina_hash_find(_client_displays, name);
+     }
+
+   return ewd;
+}

-- 


Reply via email to