discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=4276b3ac55671c6cab52f5b84b18c863c5f4a9c1

commit 4276b3ac55671c6cab52f5b84b18c863c5f4a9c1
Author: Derek Foreman <der...@osg.samsung.com>
Date:   Thu Feb 19 14:49:01 2015 -0500

    Provide wl_output interface to clients
    
    Reviewers: devilhorns, zmike
    
    Reviewed By: devilhorns, zmike
    
    Subscribers: cedric
    
    Maniphest Tasks: T2131
    
    Differential Revision: https://phab.enlightenment.org/D2007
---
 src/bin/Makefile.mk |  2 +-
 src/bin/e_comp_wl.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/bin/e_comp_wl.h |  5 ++++
 3 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/src/bin/Makefile.mk b/src/bin/Makefile.mk
index e64dcfb..e227076 100644
--- a/src/bin/Makefile.mk
+++ b/src/bin/Makefile.mk
@@ -382,7 +382,7 @@ src/bin/e_main.c \
 $(enlightenment_src)
 
 src_bin_enlightenment_LDFLAGS = -export-dynamic
-src_bin_enlightenment_LDADD = @e_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ 
@WAYLAND_LIBS@ @WAYLAND_EGL_LIBS@ -lm @ECORE_X_LIBS@ @SHM_OPEN_LIBS@
+src_bin_enlightenment_LDADD = @e_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ 
@WAYLAND_LIBS@ @WL_DRM_LIBS@ @WAYLAND_EGL_LIBS@ -lm @ECORE_X_LIBS@ 
@SHM_OPEN_LIBS@
 
 src_bin_enlightenment_imc_SOURCES = \
 src/bin/e.h \
diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
index bf4af05..e837292 100644
--- a/src/bin/e_comp_wl.c
+++ b/src/bin/e_comp_wl.c
@@ -1,6 +1,9 @@
 #define E_COMP_WL
 #include "e.h"
 
+#include <Evas_Engine_Drm.h>
+#include <Ecore_Drm.h>
+
 /* handle include for printing uint64_t */
 #define __STDC_FORMAT_MACROS
 #include <inttypes.h>
@@ -1350,6 +1353,8 @@ _e_comp_wl_compositor_cb_del(E_Comp *comp)
    /* delete fd handler */
    if (cdata->fd_hdlr) ecore_main_fd_handler_del(cdata->fd_hdlr);
 
+   eina_list_free(cdata->output.resources);
+
    /* free allocated data structure */
    free(cdata);
 }
@@ -2241,6 +2246,65 @@ _e_comp_wl_client_cb_resize_end(void *data EINA_UNUSED, 
E_Client *ec)
    E_FREE_LIST(ec->pending_resize, free);
 }
 
+static void
+_e_comp_wl_cb_output_unbind(struct wl_resource *resource)
+{
+   E_Comp_Data *cdata = wl_resource_get_user_data(resource);
+
+   cdata->output.resources = eina_list_remove(cdata->output.resources,
+                                              resource);
+}
+
+static void
+_e_comp_wl_output_bind(struct wl_client *client, void *data, uint32_t version, 
uint32_t id)
+{
+   E_Comp_Data *cdata = data;
+   Evas_Engine_Info_Drm *einfo;
+   Ecore_Drm_Device *dev;
+   Eina_List *l;
+   Ecore_Drm_Output *output;
+   struct wl_resource *resource;
+
+   einfo = (Evas_Engine_Info_Drm *)evas_engine_info_get(e_comp->evas);
+   dev = einfo->info.dev;
+   resource = wl_resource_create(client, &wl_output_interface,
+                                 MIN(version, 2), id);
+   if (resource == NULL)
+     {
+        wl_client_post_no_memory(client);
+        return;
+     }
+
+   cdata->output.resources = eina_list_append(cdata->output.resources,
+                                              resource);
+   wl_resource_set_implementation(resource, NULL, data, NULL);
+   wl_resource_set_user_data(resource, cdata);
+   EINA_LIST_FOREACH(dev->outputs, l, output)
+     {
+        int ox, oy, rw, rh, rr, pw, ph;
+        unsigned int spo;
+        const char *make, *model;
+
+        ecore_drm_output_position_get(output, &ox, &oy);
+        ecore_drm_output_current_resolution_get(output, &rw, &rh, &rr);
+        ecore_drm_output_physical_size_get(output, &pw, &ph);
+        spo = ecore_drm_output_subpixel_order_get(output);
+        make = ecore_drm_output_model_get(output);
+        model = ecore_drm_output_make_get(output);
+
+        wl_output_send_geometry(resource, ox, oy, pw, ph, spo, make, model,
+                                0/* output transform*/);
+
+        if (version >= WL_OUTPUT_SCALE_SINCE_VERSION)
+          wl_output_send_scale(resource, 1/* current scale */);
+
+        wl_output_send_mode(resource, 3/*preferred + current */, rw, rh, rr);
+     }
+
+   if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
+     wl_output_send_done(resource);
+}
+
 static Eina_Bool 
 _e_comp_wl_compositor_create(void)
 {
@@ -2301,6 +2365,12 @@ _e_comp_wl_compositor_create(void)
         ERR("Could not add subcompositor to wayland globals: %m");
         goto comp_global_err;
      }
+   if (!wl_global_create(cdata->wl.disp, &wl_output_interface, 2,
+                         cdata, _e_comp_wl_output_bind))
+     {
+        ERR("Could not add output to wayland globals: %m");
+        goto comp_global_err;
+     }
 
    /* try to init data manager */
    if (!e_comp_wl_data_manager_init(cdata))
diff --git a/src/bin/e_comp_wl.h b/src/bin/e_comp_wl.h
index ba07134..7b2f6b8 100644
--- a/src/bin/e_comp_wl.h
+++ b/src/bin/e_comp_wl.h
@@ -203,6 +203,11 @@ struct _E_Comp_Wl_Data
         char *area;
      } xkb;
 
+   struct
+     {
+        Eina_List *resources;
+     } output;
+
    Ecore_Fd_Handler *fd_hdlr;
    Ecore_Idler *idler;
 

-- 


Reply via email to