devilhorns pushed a commit to branch master.

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

commit d722b41e1aa659d0614eb1ae3fbba45b01d5dc37
Author: Chris Michael <cp.mich...@samsung.com>
Date:   Thu Sep 10 10:37:40 2015 -0400

    ecore-wl2: Add start of Ecore_Wl2_Output code for outputs
    
    Signed-off-by: Chris Michael <cp.mich...@samsung.com>
---
 src/Makefile_Ecore_Wl2.am             |  1 +
 src/lib/ecore_wl2/Ecore_Wl2.h         |  1 +
 src/lib/ecore_wl2/ecore_wl2_display.c |  9 ++++
 src/lib/ecore_wl2/ecore_wl2_output.c  | 97 +++++++++++++++++++++++++++++++++++
 src/lib/ecore_wl2/ecore_wl2_private.h | 17 ++++++
 5 files changed, 125 insertions(+)

diff --git a/src/Makefile_Ecore_Wl2.am b/src/Makefile_Ecore_Wl2.am
index 1560ed3..d3a6369 100644
--- a/src/Makefile_Ecore_Wl2.am
+++ b/src/Makefile_Ecore_Wl2.am
@@ -11,6 +11,7 @@ lib_ecore_wl2_libecore_wl2_la_SOURCES = \
 lib/ecore_wl2/xdg-shell-client-protocol.h \
 lib/ecore_wl2/xdg-shell-protocol.c \
 lib/ecore_wl2/ecore_wl2_window.c \
+lib/ecore_wl2/ecore_wl2_output.c \
 lib/ecore_wl2/ecore_wl2_display.c \
 lib/ecore_wl2/ecore_wl2.c \
 lib/ecore_wl2/ecore_wl2_private.h
diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h
index f3302bb..6c44ad7 100644
--- a/src/lib/ecore_wl2/Ecore_Wl2.h
+++ b/src/lib/ecore_wl2/Ecore_Wl2.h
@@ -33,6 +33,7 @@ typedef struct _Ecore_Wl2_Window Ecore_Wl2_Window;
 # endif
 
 typedef struct _Ecore_Wl2_Display Ecore_Wl2_Display;
+typedef struct _Ecore_Wl2_Output Ecore_Wl2_Output;
 
 typedef struct _Ecore_Wl2_Global
 {
diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c 
b/src/lib/ecore_wl2/ecore_wl2_display.c
index 0c9b032..4efb75e 100644
--- a/src/lib/ecore_wl2/ecore_wl2_display.c
+++ b/src/lib/ecore_wl2/ecore_wl2_display.c
@@ -76,6 +76,8 @@ _cb_global_add(void *data, struct wl_registry *registry, 
unsigned int id, const
         xdg_shell_use_unstable_version(ewd->wl.xdg_shell, XDG_VERSION);
         /* TODO: Add listener */
      }
+   else if (!strcmp(interface, "wl_output"))
+     _ecore_wl2_output_add(ewd, id);
 
    /* allocate space for event structure */
    ev = calloc(1, sizeof(Ecore_Wl2_Event_Global));
@@ -203,6 +205,13 @@ static const struct wl_callback_listener _sync_listener =
 static void
 _ecore_wl2_display_cleanup(Ecore_Wl2_Display *ewd)
 {
+   Ecore_Wl2_Output *output;
+   Eina_Inlist *tmp;
+
+   /* free each output */
+   EINA_INLIST_FOREACH_SAFE(ewd->outputs, tmp, output)
+     _ecore_wl2_output_del(output);
+
    if (ewd->xkb_context) xkb_context_unref(ewd->xkb_context);
 
    wl_registry_destroy(wl_display_get_registry(ewd->wl.display));
diff --git a/src/lib/ecore_wl2/ecore_wl2_output.c 
b/src/lib/ecore_wl2/ecore_wl2_output.c
new file mode 100644
index 0000000..b9bf7f9
--- /dev/null
+++ b/src/lib/ecore_wl2/ecore_wl2_output.c
@@ -0,0 +1,97 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ecore_wl2_private.h"
+
+static void
+_cb_geometry(void *data, struct wl_output *wl_output EINA_UNUSED, int x, int 
y, int w, int h, int subpixel EINA_UNUSED, const char *make, const char *model, 
int transform)
+{
+   Ecore_Wl2_Output *output;
+
+   output = data;
+   if (!output) return;
+
+   output->mw = w;
+   output->mh = h;
+   output->geometry.x = x;
+   output->geometry.y = y;
+   output->transform = transform;
+   eina_stringshare_replace(&output->make, make);
+   eina_stringshare_replace(&output->model, model);
+}
+
+static void
+_cb_mode(void *data, struct wl_output *wl_output EINA_UNUSED, unsigned int 
flags, int w, int h, int refresh EINA_UNUSED)
+{
+   Ecore_Wl2_Output *output;
+
+   output = data;
+   if (!output) return;
+
+   if (flags & WL_OUTPUT_MODE_CURRENT)
+     {
+        output->geometry.w = w;
+        output->geometry.h = h;
+     }
+}
+
+static void
+_cb_done(void *data EINA_UNUSED, struct wl_output *output EINA_UNUSED)
+{
+   /* NB: Use this event to raise any "output (re)configured events" */
+}
+
+static void
+_cb_scale(void *data EINA_UNUSED, struct wl_output *output EINA_UNUSED, int 
scale EINA_UNUSED)
+{
+
+}
+
+static const struct wl_output_listener _output_listener =
+{
+   _cb_geometry,
+   _cb_mode,
+   _cb_done,
+   _cb_scale
+};
+
+void
+_ecore_wl2_output_add(Ecore_Wl2_Display *display, unsigned int id)
+{
+   Ecore_Wl2_Output *output;
+
+   output = calloc(1, sizeof(Ecore_Wl2_Output));
+   if (!output) return;
+
+   output->display = display;
+
+   output->wl_output =
+     wl_registry_bind(wl_display_get_registry(display->wl.display),
+                      id, &wl_output_interface, 2);
+
+   display->outputs =
+     eina_inlist_append(display->outputs, EINA_INLIST_GET(output));
+
+   wl_output_add_listener(output->wl_output, &_output_listener, output);
+}
+
+void
+_ecore_wl2_output_del(Ecore_Wl2_Output *output)
+{
+   Ecore_Wl2_Display *display;
+
+   if (!output) return;
+
+   display = output->display;
+
+   if (output->wl_output) wl_output_destroy(output->wl_output);
+   if (output->make) eina_stringshare_del(output->make);
+   if (output->model) eina_stringshare_del(output->model);
+
+   display->outputs =
+     eina_inlist_remove(display->outputs, EINA_INLIST_GET(output));
+
+   free(output);
+}
+
diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h 
b/src/lib/ecore_wl2/ecore_wl2_private.h
index 6080ae1..18c851a 100644
--- a/src/lib/ecore_wl2/ecore_wl2_private.h
+++ b/src/lib/ecore_wl2/ecore_wl2_private.h
@@ -60,6 +60,8 @@ struct _Ecore_Wl2_Display
 
    Eina_Hash *globals;
 
+   Eina_Inlist *outputs;
+
    Eina_Bool sync_done : 1;
 };
 
@@ -89,4 +91,19 @@ struct _Ecore_Wl2_Window
    Eina_Bool resizing : 1;
 };
 
+struct _Ecore_Wl2_Output
+{
+   EINA_INLIST;
+
+   Ecore_Wl2_Display *display;
+   struct wl_output *wl_output;
+
+   int mw, mh, transform;
+   const char *make, *model;
+   Eina_Rectangle geometry;
+};
+
+void _ecore_wl2_output_add(Ecore_Wl2_Display *display, unsigned int id);
+void _ecore_wl2_output_del(Ecore_Wl2_Output *output);
+
 #endif

-- 


Reply via email to