implementation wayland backend 27/42427/1
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 18 Jun 2015 14:10:52 +0000 (23:10 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 29 Jun 2015 06:41:24 +0000 (15:41 +0900)
Change-Id: I3cf9a28cf4e50afa89207970df492fb8850d5f31

13 files changed:
configure.ac
packaging/libeom.spec
src/Makefile.am
src/dbus/eom-dbus.c
src/dbus/eom-dbus.h
src/eom.c
src/wayland/eom-wayland.c [new file with mode: 0755]
src/wayland/eom-wayland.h [new file with mode: 0755]
src/wayland/protocol/eom-client-protocol.h [new file with mode: 0644]
src/wayland/protocol/eom-protocol.c [new file with mode: 0644]
src/wayland/protocol/eom.xml [new file with mode: 0644]
src/wayland/protocol/xdg-shell-client-protocol.h [new file with mode: 0644]
src/wayland/protocol/xdg-shell-protocol.c [new file with mode: 0644]

index 672c16c..de40fd0 100755 (executable)
@@ -82,9 +82,13 @@ if test "x$EOM_PLATFORM" = "xWAYLAND"; then
     LIBEOM_CFLAGS="$LIBEOM_CFLAGS $WAYLAND_CLIENT_CFLAGS"
     LIBEOM_LIBS="$LIBEOM_LIBS $WAYLAND_CLIENT_LIBS"
 
-       WAYLAND_PREFIX=`$PKG_CONFIG --variable=prefix wayland-client`
-    AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner],,
-                   [${WAYLAND_PREFIX}/bin$PATH_SEPARATOR$PATH])
+    PKG_CHECK_MODULES(ECORE_WAYLAND, ecore-wayland)
+    LIBEOM_CFLAGS="$LIBEOM_CFLAGS $ECORE_WAYLAND_CFLAGS"
+    LIBEOM_LIBS="$LIBEOM_LIBS $ECORE_WAYLAND_LIBS"
+
+#      WAYLAND_PREFIX=`$PKG_CONFIG --variable=prefix wayland-client`
+#    AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner],,
+#                  [${WAYLAND_PREFIX}/bin$PATH_SEPARATOR$PATH])
 fi
 
 
index 4a1d22c..2a13700 100644 (file)
@@ -12,6 +12,7 @@ Source1001:   libeom.manifest
 
 %if %{with wayland}
 BuildRequires:  pkgconfig(wayland-client)
+BuildRequires:  pkgconfig(ecore-wayland)
 %else
 %endif
 BuildRequires:  pkgconfig(dlog)
index 30b85cb..beada14 100755 (executable)
@@ -31,14 +31,30 @@ libeom_la_LDFLAGS = ${LDFLAGS}
 libeom_la_CFLAGS = \
     ${CFLAGS} \
     @LIBEOM_CFLAGS@ \
-    -I$(top_srcdir)/include
-
-libeom_la_CFLAGS += \
-       -I$(top_srcdir)/src/dbus
+    -I$(top_srcdir)/include \
+    -I$(top_srcdir)/src
 
 libeom_la_SOURCES = \
        eom.c
 
+if HAVE_EOM_PLATFORM_X11
+libeom_la_CFLAGS += \
+       -I$(top_srcdir)/src/dbus
+
 libeom_la_SOURCES += \
        dbus/eom-dbus.c
+endif
+
+if HAVE_EOM_PLATFORM_WAYLAND
+libeom_la_CFLAGS += \
+       -I$(top_srcdir)/src/wayland \
+       -I$(top_srcdir)/src/wayland/protocol
+
+libeom_la_SOURCES += \
+       wayland/protocol/xdg-shell-protocol.c \
+       wayland/protocol/eom-protocol.c \
+       wayland/eom-wayland.c
+endif
+
+
 
index ff0b07b..1b5afd9 100755 (executable)
@@ -569,3 +569,123 @@ err_send:
 
        return NULL;
 }
+
+
+GValueArray *
+eom_dbus_client_get_output_ids(void)
+{
+       GValueArray *array = NULL;
+
+       array = eom_dbus_client_send_message("GetOutputIDs", NULL);
+       RETV_IF_FAIL(array != NULL, NULL);
+
+       return array;
+}
+
+GValueArray *
+eom_dbus_client_get_output_info(eom_output_id output_id)
+{
+       GValueArray *array = NULL;
+       GValueArray *msg_array;
+       GValue v = G_VALUE_INIT;
+
+       msg_array = g_value_array_new(0);
+
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, output_id);
+       msg_array = g_value_array_append(msg_array, &v);
+
+       array = eom_dbus_client_send_message("GetOutputInfo", msg_array);
+       GOTO_IF_FAIL(array != NULL, fail);
+
+       g_value_array_free(msg_array);
+
+       return array;
+fail:
+       g_value_array_free(msg_array);
+
+       return NULL;
+}
+
+GValueArray *
+eom_dbus_client_set_attribute(eom_output_id output_id, eom_output_attribute_e attr)
+{
+       GValueArray *array = NULL;
+       GValueArray *msg_array;
+       GValue v = G_VALUE_INIT;
+       int pid = 0;
+
+       pid = getpid();
+
+       INFO("output_id: %d, pid: %d, attr: %d\n", output_id, pid, attr);
+
+       msg_array = g_value_array_new(0);
+
+       /* 0:output_id, 1:pid, 2:eom_attribuete_e */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, output_id);
+       msg_array = g_value_array_append(msg_array, &v);
+       g_value_set_int(&v, pid);
+       msg_array = g_value_array_append(msg_array, &v);
+       g_value_set_int(&v, attr);
+       msg_array = g_value_array_append(msg_array, &v);
+
+       array = eom_dbus_client_send_message("SetOutputAttribute", msg_array);
+       GOTO_IF_FAIL(array != NULL, fail);
+
+       g_value_array_free(msg_array);
+
+       return array;
+fail:
+       g_value_array_free(msg_array);
+
+       return NULL;
+}
+
+GValueArray *
+eom_dbus_client_set_window(eom_output_id output_id, Evas_Object *win)
+{
+       GValueArray *array = NULL;
+       GValueArray *msg_array;
+       GValue v = G_VALUE_INIT;
+       int pid = 0;
+       Ecore_X_Window xwin;
+       int ret = 0;
+
+       pid = getpid();
+       xwin = elm_win_xwindow_get(win);
+
+       INFO("output_id: %d, pid: %d, xwin: %d\n", output_id, pid, xwin);
+
+       msg_array = g_value_array_new(0);
+
+       /* 0:output_id, 1:pid, 2:eom_attribuete_e */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, output_id);
+       msg_array = g_value_array_append(msg_array, &v);
+       g_value_set_int(&v, pid);
+       msg_array = g_value_array_append(msg_array, &v);
+       g_value_set_int(&v, xwin);
+       msg_array = g_value_array_append(msg_array, &v);
+
+       array = eom_dbus_client_send_message("SetWindow", msg_array);
+       RETV_IF_FAIL(array != NULL, NULL);
+
+       g_value_array_free(msg_array);
+
+       ret = g_value_get_int(g_value_array_get_nth(array, 0));
+       GOTO_IF_FAIL(ret != 0, fail);
+
+#ifdef HAVE_TIZEN_2_X
+       const char *profile = "desktop";
+       elm_win_profiles_set(win, &profile, 1);
+#endif
+       elm_win_fullscreen_set(win, EINA_TRUE);
+
+       return array;
+fail:
+       g_value_array_free(msg_array);
+
+       return NULL;
+}
+
index 99cfbce..083d7a8 100755 (executable)
@@ -43,6 +43,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 bool eom_dbus_client_init(notify_func func);
 void eom_dbus_client_deinit(GList *cb_info_list);
 
+GValueArray *eom_dbus_client_get_output_ids(void);
+GValueArray *eom_dbus_client_get_output_info(eom_output_id output_id);
+GValueArray *eom_dbus_client_set_attribute(eom_output_id output_id, eom_output_attribute_e attry);
+GValueArray *eom_dbus_client_set_window(eom_output_id output_id, Evas_Object *win);
+
 GValueArray *eom_dbus_client_send_message(char *method, GValueArray *array);
 
 #endif /* __EOM_DBUS_H__ */
index b3f50f0..1d6d903 100755 (executable)
--- a/src/eom.c
+++ b/src/eom.c
@@ -41,7 +41,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "eom.h"
 #include "eom_internal.h"
 #include "eom-log.h"
+#ifdef HAVE_WAYLAND
+#include "eom-wayland.h"
+#else
 #include "eom-dbus.h"
+#endif
 #include "eom-private.h"
 
 typedef struct {
@@ -481,7 +485,11 @@ eom_init(void)
 
        _eom_mutex_lock();
 
+#ifdef HAVE_WAYLAND
+       ret = eom_wayland_client_init(_eom_output_process_notify_cb);
+#else
        ret = eom_dbus_client_init(_eom_output_process_notify_cb);
+#endif
 
        _eom_mutex_unlock();
 
@@ -496,8 +504,11 @@ eom_deinit(void)
        GList *l;
 
        _eom_mutex_lock();
-
+#ifdef HAVE_WAYLAND
+       eom_wayland_client_deinit(cb_info_list);
+#else
        eom_dbus_client_deinit(cb_info_list);
+#endif
 
        /* TODO: redesign the life-cycle of output_infos */
        /* destory output_info. */
@@ -527,8 +538,11 @@ eom_get_eom_output_ids(int *count)
 
        _eom_mutex_lock();
 
-       ret_array = eom_dbus_client_send_message("GetOutputIDs", NULL);
-
+#ifdef HAVE_WAYLAND
+       ret_array = eom_wayland_client_get_output_ids();
+#else
+       ret_array = eom_dbus_client_get_output_ids();
+#endif
        if (!ret_array) {
                *count = 0;
                _eom_mutex_unlock();
@@ -562,22 +576,16 @@ eom_get_eom_output_ids(int *count)
                /* add output_info to output_info_list */
                eom_output_info *output_info;
                eom_output_id output_id = output_ids[i];
-               GValueArray *msg_array;
-               GValue v = G_VALUE_INIT;
 
                output_info = _eom_find_output_info(output_id);
                if (output_info)
                        continue;
 
-               msg_array = g_value_array_new(0);
-
-               g_value_init(&v, G_TYPE_INT);
-               g_value_set_int(&v, output_id);
-               msg_array = g_value_array_append(msg_array, &v);
-
-               ret_array = eom_dbus_client_send_message("GetOutputInfo", msg_array);
-               g_value_array_free(msg_array);
-
+#ifdef HAVE_WAYLAND
+               ret_array = eom_wayland_client_get_output_info(output_id);
+#else
+               ret_array = eom_dbus_client_get_output_info(output_id);
+#endif
                if (ret_array) {
                        /* 0:output_id, 1:output_type, 2:output_mode, 3:w, 4:h, 5:w_mm, 6:h_mm */
                        output_info = _eom_alloc_output_info(g_value_get_int(g_value_array_get_nth(ret_array, 0)),
@@ -886,10 +894,7 @@ eom_set_output_attribute(eom_output_id output_id, eom_output_attribute_e attr)
 {
        eom_output_info *output_info = NULL;
        bool ret = false;
-       GValueArray *msg_array;
        GValueArray *ret_array;
-       GValue v = G_VALUE_INIT;
-       int pid = 0;
 
        RETV_IF_FAIL(output_id != 0, EOM_ERROR_INVALID_PARAMETER);
        RETV_IF_FAIL(attr > EOM_OUTPUT_ATTRIBUTE_NONE, EOM_ERROR_INVALID_PARAMETER);
@@ -904,23 +909,13 @@ eom_set_output_attribute(eom_output_id output_id, eom_output_attribute_e attr)
                return EOM_ERROR_NO_SUCH_DEVICE;
        }
 
-       pid = getpid();
-
-       INFO("output_id: %d, pid: %d, mode: %d\n", output_id, pid, attr);
-
-       msg_array = g_value_array_new(0);
+       INFO("output_id: %d, attr: %d\n", output_id, attr);
 
-       /* 0:output_id, 1:pid, 2:eom_attribuete_e */
-       g_value_init(&v, G_TYPE_INT);
-       g_value_set_int(&v, output_id);
-       msg_array = g_value_array_append(msg_array, &v);
-       g_value_set_int(&v, pid);
-       msg_array = g_value_array_append(msg_array, &v);
-       g_value_set_int(&v, attr);
-       msg_array = g_value_array_append(msg_array, &v);
-
-       ret_array = eom_dbus_client_send_message("SetOutputAttribute", msg_array);
-       g_value_array_free(msg_array);
+#ifdef HAVE_WAYLAND
+       ret_array = eom_wayland_client_set_attribute(output_id, attr);
+#else
+       ret_array = eom_dbus_client_set_attribute(output_id, attr);
+#endif
        if (!ret_array) {
                _eom_mutex_unlock();
                return EOM_ERROR_MESSAGE_SENDING_FAILURE;
@@ -1099,14 +1094,9 @@ eom_get_output_physical_size(eom_output_id output_id, int *phy_width, int *phy_h
 API int
 eom_set_output_window(eom_output_id output_id, Evas_Object *win)
 {
-#ifdef HAVE_X11
        eom_output_info *output_info = NULL;
        bool ret = false;
-       GValueArray *msg_array;
        GValueArray *ret_array;
-       GValue v = G_VALUE_INIT;
-       Ecore_X_Window xwin;
-       int pid = 0;
 
        RETV_IF_FAIL(output_id != 0, EOM_ERROR_INVALID_PARAMETER);
        RETV_IF_FAIL(win != NULL, EOM_ERROR_INVALID_PARAMETER);
@@ -1120,49 +1110,30 @@ eom_set_output_window(eom_output_id output_id, Evas_Object *win)
                return EOM_ERROR_NO_SUCH_DEVICE;
        }
 
-       pid = getpid();
-       xwin = elm_win_xwindow_get(win);
-
-       INFO("output_id: %d, pid: %d, xwin: %d\n", output_id, pid, xwin);
+       INFO("output_id: %d, evas_win: %p\n", output_id, win);
 
-       msg_array = g_value_array_new(0);
-
-       /* 0:output_id, 1:pid, 2:eom_attribuete_e */
-       g_value_init(&v, G_TYPE_INT);
-       g_value_set_int(&v, output_id);
-       msg_array = g_value_array_append(msg_array, &v);
-       g_value_set_int(&v, pid);
-       msg_array = g_value_array_append(msg_array, &v);
-       g_value_set_int(&v, xwin);
-       msg_array = g_value_array_append(msg_array, &v);
-
-       ret_array = eom_dbus_client_send_message("SetWindow", msg_array);
-       g_value_array_free(msg_array);
+#ifdef HAVE_WAYLAND
+       ret_array = eom_wayland_client_set_window(output_id, win);
+#else
+       ret_array = eom_dbus_client_set_window(output_id, win);
+#endif
        if (!ret_array) {
                _eom_mutex_unlock();
                return EOM_ERROR_MESSAGE_SENDING_FAILURE;
        }
 
        ret = g_value_get_int(g_value_array_get_nth(ret_array, 0));
-
        g_value_array_free(ret_array);
-
-       if (ret == 1) {
-#ifdef HAVE_TIZEN_2_X
-               const char *profile = "desktop";
-               elm_win_profiles_set(win, &profile, 1);
-#endif
-               elm_win_fullscreen_set(win, EINA_TRUE);
-               INFO("SetWindow: success\n");
+       if (ret == 0) {
+               ERR("SetWindow: failed\n");
                _eom_mutex_unlock();
-               return EOM_ERROR_NONE;
+               return EOM_ERROR_MESSAGE_OPERATION_FAILURE;
        }
 
-       INFO("SetWindow: failed\n");
+       INFO("SetWindow: success\n");
+
        _eom_mutex_unlock();
-       return EOM_ERROR_MESSAGE_OPERATION_FAILURE;
-#else
+
        return EOM_ERROR_NONE;
-#endif
 }
 
diff --git a/src/wayland/eom-wayland.c b/src/wayland/eom-wayland.c
new file mode 100755 (executable)
index 0000000..2fe1804
--- /dev/null
@@ -0,0 +1,862 @@
+/**************************************************************************
+
+eom (external output manager)
+
+Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#include <config.h>
+#include "eom.h"
+#include "eom_internal.h"
+#include "eom-log.h"
+#include "eom-wayland.h"
+#include "eom-private.h"
+#include "eom-client-protocol.h"
+#include "xdg-shell-client-protocol.h"
+#include <Ecore_Wayland.h>
+
+typedef struct _EomWaylandClientInfo {
+       /* wl */
+    struct wl_display *display;
+    struct wl_registry *registry;
+
+    struct wl_eom *eom;
+
+    /* eom wayland output list */
+    struct wl_list eom_wl_output_list;
+       int num_outputs;
+
+       notify_func func;
+} EomWaylandClientInfo;
+
+typedef struct _EomWaylandOutput {
+       eom_output_id id;
+       struct wl_output *output;
+
+       /* current output data */
+       int32_t x;
+       int32_t y;
+       int32_t physical_width;
+       int32_t physical_height;
+       enum wl_output_subpixel subpixel;
+       const char *make;
+       const char *model;
+       enum wl_output_transform transform;
+
+       uint32_t flags;
+       int32_t width;
+       int32_t height;
+       int32_t refresh;
+
+       int32_t factor;
+
+       /* current eom data */
+       enum wl_eom_type eom_type;
+       enum wl_eom_status eom_status;
+       enum wl_eom_mode eom_mode;
+       enum wl_eom_attribute eom_attribute;
+       enum wl_eom_attribute_state eom_attribute_state;
+
+       /* client info */
+       EomWaylandClientInfo *client_info;
+
+       struct wl_list link;
+} EomWaylandOutput;
+
+static EomWaylandClientInfo wl_client_info;
+static int eom_wayland_init = 0;
+
+static eom_output_type_e
+_convert_to_eom_output_type(enum wl_eom_type eom_type)
+{
+       eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
+       switch (eom_type)
+       {
+               case WL_EOM_TYPE_NONE:
+                       output_type = EOM_OUTPUT_TYPE_UNKNOWN;
+                       break;
+               case WL_EOM_TYPE_VGA:
+                       output_type = EOM_OUTPUT_TYPE_VGA;
+                       break;
+               case WL_EOM_TYPE_DIVI:
+                       output_type = EOM_OUTPUT_TYPE_DVII;;
+                       break;
+               case WL_EOM_TYPE_DIVD:
+                       output_type = EOM_OUTPUT_TYPE_DVID;
+                       break;
+               case WL_EOM_TYPE_DIVA:
+                       output_type = EOM_OUTPUT_TYPE_DVIA;
+                       break;
+               case WL_EOM_TYPE_COMPOSITE:
+                       output_type = EOM_OUTPUT_TYPE_COMPOSITE;
+                       break;
+               case WL_EOM_TYPE_SVIDEO:
+                       output_type = EOM_OUTPUT_TYPE_SVIDEO;
+                       break;
+               case WL_EOM_TYPE_LVDS:
+                       output_type = EOM_OUTPUT_TYPE_LVDS;
+                       break;
+               case WL_EOM_TYPE_COMPONENT:
+                       output_type = EOM_OUTPUT_TYPE_COMPONENT;
+                       break;
+               case WL_EOM_TYPE_9PINDIN:
+                       output_type = EOM_OUTPUT_TYPE_9PINDIN;
+                       break;
+               case WL_EOM_TYPE_DISPLAYPORT:
+                       output_type = EOM_OUTPUT_TYPE_DISPLAYPORT;
+                       break;
+               case WL_EOM_TYPE_HDMIA:
+                       output_type = EOM_OUTPUT_TYPE_HDMIA;
+                       break;
+               case WL_EOM_TYPE_HDMIB:
+                       output_type = EOM_OUTPUT_TYPE_HDMIB;
+                       break;
+               case WL_EOM_TYPE_TV:
+                       output_type = EOM_OUTPUT_TYPE_TV;
+                       break;
+               case WL_EOM_TYPE_EDP:
+                       output_type = EOM_OUTPUT_TYPE_EDP;
+                       break;
+               case WL_EOM_TYPE_VIRTUAL:
+                       output_type = EOM_OUTPUT_TYPE_VIRTUAL;
+                       break;
+               case WL_EOM_TYPE_DSI:
+                       output_type = EOM_OUTPUT_TYPE_DSI;
+                       break;
+               default:
+                       ERR("no type.");
+                       break;
+         }
+
+       return output_type;
+}
+
+static eom_output_mode_e
+_convert_to_eom_output_mode(enum wl_eom_mode eom_mode)
+{
+       eom_output_mode_e output_mode = EOM_OUTPUT_MODE_NONE;
+       switch (eom_mode)
+       {
+               case WL_EOM_MODE_NONE:
+                       output_mode = EOM_OUTPUT_MODE_NONE;
+                       break;
+               case WL_EOM_MODE_MIRROR:
+                       output_mode = EOM_OUTPUT_MODE_MIRROR;
+                       break;
+               case WL_EOM_MODE_PRESENTATION:
+                       output_mode = EOM_OUTPUT_MODE_PRESENTATION;
+                       break;
+               default:
+                       ERR("no mode.");
+                       break;
+       }
+
+       return output_mode;
+}
+
+static eom_output_attribute_e
+_convert_to_eom_output_attribute(enum wl_eom_attribute eom_attribute)
+{
+       eom_output_attribute_e output_attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
+       switch (eom_attribute)
+       {
+               case WL_EOM_ATTRIBUTE_NONE:
+                       output_attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
+                       break;
+               case WL_EOM_ATTRIBUTE_NORMAL:
+                       output_attribute = EOM_OUTPUT_ATTRIBUTE_NORMAL;
+                       break;
+               case WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARED:
+                       output_attribute = EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE_SHARE;
+                       break;
+               case WL_EOM_ATTRIBUTE_EXCLUSIVE:
+                       output_attribute = EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE;
+                       break;
+               default:
+                       ERR("no attribute.");
+                       break;
+       }
+
+       return output_attribute;
+}
+
+static eom_output_attribute_state_e
+_convert_to_eom_output_attribute_state(enum wl_eom_attribute_state eom_attribute_state)
+{
+       eom_output_attribute_state_e output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
+       switch (eom_attribute_state)
+       {
+               case WL_EOM_ATTRIBUTE_STATE_NONE:
+                       output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
+                       break;
+               case WL_EOM_ATTRIBUTE_STATE_ACTIVE:
+                       output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE;
+                       break;
+               case WL_EOM_ATTRIBUTE_STATE_INACTIVE:
+                       output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_INACTIVE;
+                       break;
+               case WL_EOM_ATTRIBUTE_STATE_LOST:
+                       output_attribute_state = EOM_OUTPUT_ATTRIBUTE_STATE_LOST;
+                       break;
+               default:
+                       ERR("no attribute state.");
+                       break;
+       }
+
+       return output_attribute_state;
+}
+
+static enum wl_eom_attribute
+_convert_to_wl_eom_attribute(eom_output_attribute_e attr)
+{
+       enum wl_eom_attribute eom_attribute = WL_EOM_ATTRIBUTE_NONE;
+       switch (attr)
+       {
+               case EOM_OUTPUT_ATTRIBUTE_NONE:
+                       eom_attribute = WL_EOM_ATTRIBUTE_NONE;
+                       break;
+               case EOM_OUTPUT_ATTRIBUTE_NORMAL:
+                       eom_attribute = WL_EOM_ATTRIBUTE_NORMAL;
+                       break;
+               case EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE_SHARE:
+                       eom_attribute = WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARED;
+                       break;
+               case EOM_OUTPUT_ATTRIBUTE_EXCLUSIVE:
+                       eom_attribute = WL_EOM_ATTRIBUTE_EXCLUSIVE;
+                       break;
+               default:
+                       ERR("no wl attribute.");
+                       break;
+       }
+
+       return eom_attribute;
+}
+
+
+static void
+_eom_wayland_client_call_notify(EomWaylandOutput *eom_wl_output, eom_output_notify_type_e type)
+{
+       GValueArray *array = NULL;
+       GValue v = G_VALUE_INIT;
+
+       array = g_value_array_new(0);
+
+       /* 11 args 0: notify_type 1:output_id, 2:output_type, 3:output_mode, 4:w, 5:h, 6:w_mm, 7:h_mm, 8:pid, 9:attri, 10:state */
+       /* 0: notify_type */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, type);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 1:output_id */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->id);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 2:output_type */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, _convert_to_eom_output_type(eom_wl_output->eom_type));
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 3:output_mode */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, _convert_to_eom_output_mode(eom_wl_output->eom_mode));
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 4:w */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->width);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 5:h */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->height);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 6:w_mm */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->physical_width);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 7:h_mm */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->physical_height);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 8:pid */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->physical_width);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 9:attri */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, _convert_to_eom_output_attribute(eom_wl_output->eom_attribute));
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 10:state */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, _convert_to_eom_output_attribute_state(eom_wl_output->eom_attribute_state));
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       if (eom_wl_output->client_info->func)
+               eom_wl_output->client_info->func(NULL, array);
+
+       if (array)
+               g_value_array_free(array);
+
+}
+
+
+static EomWaylandOutput *
+_eom_wayland_client_find_output_from_wl_output(struct wl_list *eom_wl_output_list, struct wl_output *output)
+{
+       EomWaylandOutput *eom_wl_output = NULL;
+       EomWaylandOutput *tmp = NULL;
+       EomWaylandOutput *ret = NULL;
+
+       /* remove all eom_wl_outputs */
+       if (!wl_list_empty(eom_wl_output_list)) {
+               wl_list_for_each_safe(eom_wl_output, tmp, eom_wl_output_list, link) {
+                       if (eom_wl_output->output == output) {
+                               ret = eom_wl_output;
+                               break;
+                       }
+               }
+       }
+
+       return ret;
+}
+
+static EomWaylandOutput *
+_eom_wayland_client_find_output_from_eom_output(struct wl_list *eom_wl_output_list, eom_output_id id)
+{
+       EomWaylandOutput *eom_wl_output = NULL;
+       EomWaylandOutput *tmp = NULL;
+       EomWaylandOutput *ret = NULL;
+
+       /* remove all eom_wl_outputs */
+       if (!wl_list_empty(eom_wl_output_list)) {
+               wl_list_for_each_safe(eom_wl_output, tmp, eom_wl_output_list, link) {
+                       if (eom_wl_output->id == id) {
+                               ret = eom_wl_output;
+                               break;
+                       }
+               }
+       }
+
+       return ret;
+}
+
+
+static void
+_eom_wl_output_handle_geometry(void *data,
+         struct wl_output *wl_output,
+         int32_t x,
+         int32_t y,
+         int32_t physical_width,
+         int32_t physical_height,
+         int32_t subpixel,
+         const char *make,
+         const char *model,
+         int32_t transform)
+{
+       EomWaylandOutput *eom_wl_output = (EomWaylandOutput *) data;
+
+    INFO("wl_output:%p x:%d y:%d phy_w:%d phy_h:%d subpixel:%d make:%s model:%s transform:%d\n",
+        wl_output, x, y, physical_width, physical_height, subpixel, make, model, transform);
+
+       /* save vaules if it is different before */
+       if (eom_wl_output->x != x)
+               eom_wl_output->x = x;
+       if (eom_wl_output->y != y)
+               eom_wl_output->y = y;
+       if (eom_wl_output->physical_height)
+               eom_wl_output->physical_height = physical_height;
+       if (eom_wl_output->physical_width)
+               eom_wl_output->physical_width = physical_width;
+       if (eom_wl_output->subpixel)
+               eom_wl_output->subpixel = subpixel;
+       if (eom_wl_output->transform)
+               eom_wl_output->transform = transform;
+
+}
+
+
+static void
+_eom_wl_output_handle_mode(void *data,
+         struct wl_output *wl_output,
+         uint32_t flags,
+         int32_t width,
+         int32_t height,
+         int32_t refresh)
+{
+       EomWaylandOutput *eom_wl_output = (EomWaylandOutput *) data;
+
+    INFO("wl_output:%p flags:%d width:%d height:%d refresh:%d\n",
+        wl_output, flags, width, height, refresh);
+
+       /* save vaules if it is different before */
+       if (eom_wl_output->flags != flags)
+               eom_wl_output->flags = flags;
+       if (eom_wl_output->width != width)
+               eom_wl_output->width = width;
+       if (eom_wl_output->height != height)
+               eom_wl_output->height = height;
+       if (eom_wl_output->refresh != refresh)
+               eom_wl_output->refresh = refresh;
+}
+
+static void
+_eom_wl_output_handle_done(void *data,
+         struct wl_output *wl_output)
+{
+    INFO("wl_output:%p\n", wl_output);
+}
+
+static void
+_eom_wl_output_handle_scale(void *data,
+          struct wl_output *wl_output,
+          int32_t factor)
+{
+       EomWaylandOutput *eom_wl_output = (EomWaylandOutput *) data;
+
+    INFO("wl_output:%p factor:%d\n", wl_output, factor);
+
+       /* save vaules if it is different before */
+       if (eom_wl_output->factor != factor)
+               eom_wl_output->factor = factor;
+}
+
+static const struct wl_output_listener eom_wl_output_listener =
+{
+    _eom_wl_output_handle_geometry,
+    _eom_wl_output_handle_mode,
+    _eom_wl_output_handle_done,
+    _eom_wl_output_handle_scale,
+};
+
+static void
+_eom_wl_eom_output_type(void *data,
+                       struct wl_eom *wl_eom,
+                       struct wl_output *output,
+                       uint32_t type,
+                       uint32_t status)
+{
+       EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *) data;
+       EomWaylandOutput *eom_wl_output = NULL;
+
+       eom_wl_output = _eom_wayland_client_find_output_from_wl_output(&eom_client_info->eom_wl_output_list, output);
+       RET_IF_FAIL(eom_wl_output != NULL);
+
+       /* save the output type */
+       if (eom_wl_output->eom_type != type)
+               eom_wl_output->eom_type = type;
+
+       /* check the connection status and call the notify */
+       if (eom_wl_output->eom_status != status) {
+               eom_wl_output->eom_status = status;
+
+               if (status == WL_EOM_STATUS_CONNECTION) {
+                       _eom_wayland_client_call_notify(eom_wl_output, EOM_OUTPUT_NOTIFY_ADD);
+               } else if (status == WL_EOM_STATUS_DISCONNECTION) {
+                       _eom_wayland_client_call_notify(eom_wl_output, EOM_OUTPUT_NOTIFY_REMOVE);
+               }
+       }
+}
+
+static void
+_eom_wl_eom_output_mode(void *data,
+                       struct wl_eom *wl_eom,
+                       struct wl_output *output,
+                       uint32_t mode)
+{
+       EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *) data;
+       EomWaylandOutput *eom_wl_output = NULL;
+
+       eom_wl_output = _eom_wayland_client_find_output_from_wl_output(&eom_client_info->eom_wl_output_list, output);
+       RET_IF_FAIL(eom_wl_output != NULL);
+
+       /* check the eom mode and call the notify */
+       if (eom_wl_output->eom_mode != mode) {
+               eom_wl_output->eom_mode = mode;
+
+               _eom_wayland_client_call_notify(eom_wl_output, EOM_OUTPUT_NOTIFY_MODE_CHANGED);
+       }
+}
+
+static void
+_eom_wl_eom_output_attribute(void *data,
+                        struct wl_eom *wl_eom,
+                        struct wl_output *output,
+                        uint32_t attribute,
+                        uint32_t attribute_state,
+                        uint32_t error)
+{
+       EomWaylandClientInfo *eom_client_info = (EomWaylandClientInfo *) data;
+       EomWaylandOutput *eom_wl_output = NULL;
+
+       eom_wl_output = _eom_wayland_client_find_output_from_wl_output(&eom_client_info->eom_wl_output_list, output);
+       RET_IF_FAIL(eom_wl_output != NULL);
+
+       /* check the eom attribute and call the notify */
+       if (eom_wl_output->eom_attribute != attribute || eom_wl_output->eom_attribute_state != attribute_state) {
+               eom_wl_output->eom_attribute = attribute;
+               eom_wl_output->eom_attribute_state = attribute_state;
+
+               _eom_wayland_client_call_notify(eom_wl_output, EOM_OUTPUT_NOTIFY_ATTRIBUTE_CHANGED);
+       }
+}
+
+
+static const struct wl_eom_listener eom_wl_eom_listener =
+{
+    _eom_wl_eom_output_type,
+    _eom_wl_eom_output_mode,
+    _eom_wl_eom_output_attribute,
+};
+
+
+static void
+_eom_wl_registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
+{
+       EomWaylandClientInfo *ci = (EomWaylandClientInfo *)data;
+       EomWaylandOutput *eom_wl_output = NULL;
+       struct wl_output *output = NULL;
+       struct wl_eom *eom = NULL;
+
+    if (strcmp(interface, "wl_output") == 0) {
+        output = wl_registry_bind(registry, name, &wl_output_interface, 1);
+        if (!output)
+            ERR("Error. fail to bind  %s.\n", interface);
+        else {
+            INFO("bind %s.\n", interface);
+
+                       /* create the eom_wl_output */
+            eom_wl_output = calloc(1, sizeof(EomWaylandOutput));
+            if (!eom_wl_output) {
+                               ERR("error. fail to allocate the eom_output.\n");
+                               return;
+            }
+                       ci->num_outputs++;
+                       eom_wl_output->id = ci->num_outputs;
+            eom_wl_output->output = output;
+            wl_list_insert(&ci->eom_wl_output_list, &eom_wl_output->link);
+
+                       /* add listener */
+               wl_output_add_listener(eom_wl_output->output, &eom_wl_output_listener, eom_wl_output);
+        }
+    } else if (strcmp(interface, "wl_eom")== 0) {
+        eom = wl_registry_bind(registry, name, &wl_eom_interface, 1);
+               if (!eom)
+                       ERR("Error. fail to bind  %s.\n", interface);
+               else {
+                       INFO("bind %s.\n", interface);
+
+                       ci->eom = eom;
+
+                       /* add listener */
+               wl_eom_add_listener(ci->eom, &eom_wl_eom_listener, ci);
+               }
+    } else {
+        INFO("Not bind %s.\n", interface);
+    }
+}
+
+static void
+_eom_wl_registry_handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
+{
+
+}
+
+static const struct wl_registry_listener eom_registry_listener =
+{
+    _eom_wl_registry_handle_global,
+    _eom_wl_registry_handle_global_remove
+};
+
+static bool
+_eom_wayland_client_initialize()
+{
+    int ecore_count = -1;
+
+    ecore_count = ecore_wl_init(NULL);
+    GOTO_IF_FAIL(ecore_count > 0, fail);
+
+       wl_list_init(&wl_client_info.eom_wl_output_list);
+
+    wl_client_info.display = ecore_wl_display_get();
+    GOTO_IF_FAIL(wl_client_info.display != NULL, fail);
+
+    /* get the registry */
+    wl_client_info.registry = wl_display_get_registry(wl_client_info.display);
+    GOTO_IF_FAIL(wl_client_info.registry != NULL, fail);
+
+    /* get the global objects */
+    wl_registry_add_listener(wl_client_info.registry, &eom_registry_listener, &wl_client_info);
+    wl_display_dispatch(wl_client_info.display);
+    wl_display_roundtrip(wl_client_info.display);
+
+    /* output list */
+    if (wl_list_empty(&wl_client_info.eom_wl_output_list)) {
+               WARN("[EOM_CLIENT] no wl output at this device.\n");
+    }
+
+       INFO("[EOM_CLIENT] wayland client init.");
+
+       return true;
+fail:
+       return false;
+}
+
+static void
+_eom_wayland_client_deinitialize()
+{
+       EomWaylandOutput *eom_wl_output = NULL;
+       EomWaylandOutput *tmp = NULL;
+
+       /* remove all eom_wl_outputs */
+       if (!wl_list_empty(&wl_client_info.eom_wl_output_list)) {
+               wl_list_for_each_safe(eom_wl_output, tmp, &wl_client_info.eom_wl_output_list, link) {
+                       if (eom_wl_output->output)
+                               wl_output_destroy(eom_wl_output->output);
+                       free(eom_wl_output);
+                       eom_wl_output = NULL;
+               }
+       }
+
+    ecore_wl_shutdown();
+
+       INFO("[EOM_CLIENT] wayland client deinit.");
+}
+
+bool
+eom_wayland_client_init(notify_func func)
+{
+    bool ret = false;
+
+    if (eom_wayland_init) return true;
+
+    ret = _eom_wayland_client_initialize();
+    GOTO_IF_FAIL(ret != true, fail);
+
+       wl_client_info.func = func;
+
+       eom_wayland_init = 1;
+
+       return ret;
+fail:
+       return false;
+}
+
+void
+eom_wayland_client_deinit(GList *cb_info_list)
+{
+       _eom_wayland_client_deinitialize();
+
+       eom_wayland_init = 0;
+
+       memset(&wl_client_info, 0x0, sizeof(EomWaylandClientInfo));
+}
+
+GValueArray *
+eom_wayland_client_get_output_ids(void)
+{
+       GValueArray *array = NULL;
+       GValue v = G_VALUE_INIT;
+       EomWaylandOutput *eom_wl_output = NULL;
+       EomWaylandOutput *tmp = NULL;
+
+       if (wl_list_empty(&wl_client_info.eom_wl_output_list)) {
+               ERR("error. no outputs.\n");
+               return NULL;
+       }
+
+       array = g_value_array_new(0);
+
+       /* remove all eom_wl_outputs */
+       wl_list_for_each_safe(eom_wl_output, tmp, &wl_client_info.eom_wl_output_list, link) {
+               if (eom_wl_output->output) {
+                       g_value_init(&v, G_TYPE_INT);
+                       g_value_set_int(&v, eom_wl_output->id);
+                       array = g_value_array_append(array, &v);
+                       g_value_unset(&v);
+               }
+       }
+
+       /* returned array will be freed by caller */
+       return array;
+}
+
+GValueArray *
+eom_wayland_client_get_output_info(eom_output_id output_id)
+{
+       GValueArray *array = NULL;
+       GValue v = G_VALUE_INIT;
+       EomWaylandOutput *eom_wl_output = NULL;
+
+       eom_wl_output = _eom_wayland_client_find_output_from_eom_output(&wl_client_info.eom_wl_output_list, output_id);
+       RETV_IF_FAIL(eom_wl_output != NULL, NULL);
+
+       array = g_value_array_new(0);
+
+       /* 0:output_id, 1:output_type, 2:output_mode, 3:w, 4:h, 5:w_mm, 6:h_mm */
+       /* 0:output_id */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->id);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 1:output_type */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->eom_type);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 2:output_mode */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->eom_mode);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 3:w */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->width);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 4:h */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->height);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 5:w_mm */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->physical_width);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* 6:h_mm */
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, eom_wl_output->physical_height);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* returned array will be freed by caller */
+       return array;
+}
+
+GValueArray *
+eom_wayland_client_set_attribute(eom_output_id output_id, eom_output_attribute_e attr)
+{
+       GValueArray *array = NULL;
+       GValue v = G_VALUE_INIT;
+       EomWaylandOutput *eom_wl_output = NULL;
+       int ret = 0;
+
+       eom_wl_output = _eom_wayland_client_find_output_from_eom_output(&wl_client_info.eom_wl_output_list, output_id);
+       GOTO_IF_FAIL(eom_wl_output != NULL, fail);
+
+       wl_eom_set_attribute(wl_client_info.eom, eom_wl_output->output, _convert_to_wl_eom_attribute(attr));
+
+       /* TODO: wait for the result of set_attribute. this should be the blocking call. */
+    wl_display_dispatch(wl_client_info.display);
+    wl_display_roundtrip(wl_client_info.display);
+
+       ret = 1;
+
+       array = g_value_array_new(0);
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, ret);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* returned array will be freed by caller */
+       return array;
+fail:
+
+       return NULL;
+}
+
+GValueArray *
+eom_wayland_client_set_window(eom_output_id output_id, Evas_Object *win)
+{
+       GValueArray *array = NULL;
+       GValue v = G_VALUE_INIT;
+       Ecore_Wl_Window *e_wl_win = NULL;
+       EomWaylandOutput *eom_wl_output = NULL;
+       struct wl_shell_surface * shell_surface = NULL;
+       struct xdg_surface * xdg_shell_surface = NULL;
+       int ret = 0;
+
+       e_wl_win = elm_win_wl_window_get(win);
+       GOTO_IF_FAIL(e_wl_win != NULL, fail);
+
+       eom_wl_output = _eom_wayland_client_find_output_from_eom_output(&wl_client_info.eom_wl_output_list, output_id);
+       GOTO_IF_FAIL(eom_wl_output != NULL, fail);
+
+       /* set full screen at output */
+       xdg_shell_surface = ecore_wl_window_xdg_surface_get(e_wl_win);
+       if (xdg_shell_surface) {
+               xdg_surface_set_fullscreen(xdg_shell_surface, eom_wl_output->output);
+       } else {
+               shell_surface = ecore_wl_window_shell_surface_get(e_wl_win);
+               if (shell_surface) {
+                       wl_shell_surface_set_fullscreen(shell_surface,
+                                                                                 WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
+                                                                                 0, eom_wl_output->output);
+               } else {
+                       ERR("no wl surface.\n");
+                       goto fail;
+               }
+       }
+
+       ret = 1;
+
+       array = g_value_array_new(0);
+       g_value_init(&v, G_TYPE_INT);
+       g_value_set_int(&v, ret);
+       array = g_value_array_append(array, &v);
+       g_value_unset(&v);
+
+       /* returned array will be freed by caller */
+       return array;
+fail:
+
+       return NULL;
+}
+
diff --git a/src/wayland/eom-wayland.h b/src/wayland/eom-wayland.h
new file mode 100755 (executable)
index 0000000..6ce7403
--- /dev/null
@@ -0,0 +1,51 @@
+/**************************************************************************
+
+eom (external output manager)
+
+Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+SooChan Lim <sc1.lim@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef __EOM_WAYLAND_H__
+#define __EOM_WAYLAND_H__
+
+#include <stdbool.h>
+#include <glib.h>
+#include <glib-object.h>
+#include "eom.h"
+#include "eom-private.h"
+
+bool eom_wayland_client_init(notify_func func);
+void eom_wayland_client_deinit(GList *cb_info_list);
+
+GValueArray *eom_wayland_client_get_output_ids(void);
+GValueArray *eom_wayland_client_get_output_info(eom_output_id output_id);
+GValueArray *eom_wayland_client_set_attribute(eom_output_id output_id, eom_output_attribute_e attry);
+GValueArray *eom_wayland_client_set_window(eom_output_id output_id, Evas_Object *win);
+
+
+#endif /* __EOM_WAYLAND_H__ */
+
diff --git a/src/wayland/protocol/eom-client-protocol.h b/src/wayland/protocol/eom-client-protocol.h
new file mode 100644 (file)
index 0000000..9f91c45
--- /dev/null
@@ -0,0 +1,229 @@
+#ifndef WL_EOM_CLIENT_PROTOCOL_H
+#define WL_EOM_CLIENT_PROTOCOL_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-client.h"
+
+struct wl_client;
+struct wl_resource;
+
+struct wl_eom;
+
+extern const struct wl_interface wl_eom_interface;
+
+#ifndef WL_EOM_ERROR_ENUM
+#define WL_EOM_ERROR_ENUM
+enum wl_eom_error {
+       WL_EOM_ERROR_NONE = 0,
+       WL_EOM_ERROR_NO_OUTPUT = 1,
+       WL_EOM_ERROR_NO_ATTRIBUTE = 2,
+       WL_EOM_ERROR_OUTPUT_OCCUPIED = 3,
+};
+#endif /* WL_EOM_ERROR_ENUM */
+
+#ifndef WL_EOM_TYPE_ENUM
+#define WL_EOM_TYPE_ENUM
+/**
+ * wl_eom_type - connector type of the external output
+ * @WL_EOM_TYPE_NONE: none
+ * @WL_EOM_TYPE_VGA: VGA output connector type
+ * @WL_EOM_TYPE_DIVI: VGA output connector type
+ * @WL_EOM_TYPE_DIVD: VGA output connector type
+ * @WL_EOM_TYPE_DIVA: VGA output connector type
+ * @WL_EOM_TYPE_COMPOSITE: VGA output connector type
+ * @WL_EOM_TYPE_SVIDEO: VGA output connector type
+ * @WL_EOM_TYPE_LVDS: VGA output connector type
+ * @WL_EOM_TYPE_COMPONENT: VGA output connector type
+ * @WL_EOM_TYPE_9PINDIN: VGA output connector type
+ * @WL_EOM_TYPE_DISPLAYPORT: VGA output connector type
+ * @WL_EOM_TYPE_HDMIA: VGA output connector type
+ * @WL_EOM_TYPE_HDMIB: VGA output connector type
+ * @WL_EOM_TYPE_TV: VGA output connector type
+ * @WL_EOM_TYPE_EDP: VGA output connector type
+ * @WL_EOM_TYPE_VIRTUAL: VGA output connector type
+ * @WL_EOM_TYPE_DSI: VGA output connector type
+ *
+ * ***** TODO ******
+ */
+enum wl_eom_type {
+       WL_EOM_TYPE_NONE = 0,
+       WL_EOM_TYPE_VGA = 1,
+       WL_EOM_TYPE_DIVI = 2,
+       WL_EOM_TYPE_DIVD = 3,
+       WL_EOM_TYPE_DIVA = 4,
+       WL_EOM_TYPE_COMPOSITE = 5,
+       WL_EOM_TYPE_SVIDEO = 6,
+       WL_EOM_TYPE_LVDS = 7,
+       WL_EOM_TYPE_COMPONENT = 8,
+       WL_EOM_TYPE_9PINDIN = 9,
+       WL_EOM_TYPE_DISPLAYPORT = 10,
+       WL_EOM_TYPE_HDMIA = 11,
+       WL_EOM_TYPE_HDMIB = 12,
+       WL_EOM_TYPE_TV = 13,
+       WL_EOM_TYPE_EDP = 14,
+       WL_EOM_TYPE_VIRTUAL = 15,
+       WL_EOM_TYPE_DSI = 16,
+};
+#endif /* WL_EOM_TYPE_ENUM */
+
+#ifndef WL_EOM_STATUS_ENUM
+#define WL_EOM_STATUS_ENUM
+/**
+ * wl_eom_status - connection status of the external output
+ * @WL_EOM_STATUS_NONE: none
+ * @WL_EOM_STATUS_CONNECTION: output connected
+ * @WL_EOM_STATUS_DISCONNECTION: output disconnected
+ *
+ * ***** TODO ******
+ */
+enum wl_eom_status {
+       WL_EOM_STATUS_NONE = 0,
+       WL_EOM_STATUS_CONNECTION = 1,
+       WL_EOM_STATUS_DISCONNECTION = 2,
+};
+#endif /* WL_EOM_STATUS_ENUM */
+
+#ifndef WL_EOM_MODE_ENUM
+#define WL_EOM_MODE_ENUM
+/**
+ * wl_eom_mode - mode of the external output
+ * @WL_EOM_MODE_NONE: none
+ * @WL_EOM_MODE_MIRROR: mirror mode
+ * @WL_EOM_MODE_PRESENTATION: presentation mode
+ *
+ * ***** TODO ******
+ */
+enum wl_eom_mode {
+       WL_EOM_MODE_NONE = 0,
+       WL_EOM_MODE_MIRROR = 1,
+       WL_EOM_MODE_PRESENTATION = 2,
+};
+#endif /* WL_EOM_MODE_ENUM */
+
+#ifndef WL_EOM_ATTRIBUTE_ENUM
+#define WL_EOM_ATTRIBUTE_ENUM
+/**
+ * wl_eom_attribute - attribute of the external output
+ * @WL_EOM_ATTRIBUTE_NONE: none
+ * @WL_EOM_ATTRIBUTE_NORMAL: nomal attribute
+ * @WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARED: exclusive shared attribute
+ * @WL_EOM_ATTRIBUTE_EXCLUSIVE: exclusive attribute
+ *
+ * ***** TODO ******
+ */
+enum wl_eom_attribute {
+       WL_EOM_ATTRIBUTE_NONE = 0,
+       WL_EOM_ATTRIBUTE_NORMAL = 1,
+       WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARED = 2,
+       WL_EOM_ATTRIBUTE_EXCLUSIVE = 3,
+};
+#endif /* WL_EOM_ATTRIBUTE_ENUM */
+
+#ifndef WL_EOM_ATTRIBUTE_STATE_ENUM
+#define WL_EOM_ATTRIBUTE_STATE_ENUM
+/**
+ * wl_eom_attribute_state - state of the external output attribute
+ * @WL_EOM_ATTRIBUTE_STATE_NONE: none
+ * @WL_EOM_ATTRIBUTE_STATE_ACTIVE: attribute is active on the output
+ * @WL_EOM_ATTRIBUTE_STATE_INACTIVE: attribute is inactive on the output
+ * @WL_EOM_ATTRIBUTE_STATE_LOST: the connection of output is lost
+ *
+ * ***** TODO ******
+ */
+enum wl_eom_attribute_state {
+       WL_EOM_ATTRIBUTE_STATE_NONE = 0,
+       WL_EOM_ATTRIBUTE_STATE_ACTIVE = 1,
+       WL_EOM_ATTRIBUTE_STATE_INACTIVE = 2,
+       WL_EOM_ATTRIBUTE_STATE_LOST = 3,
+};
+#endif /* WL_EOM_ATTRIBUTE_STATE_ENUM */
+
+/**
+ * wl_eom - an interface to get the information of the external outputs
+ * @output_type: (none)
+ * @output_mode: (none)
+ * @output_attribute: (none)
+ *
+ * ***** TODO ******
+ */
+struct wl_eom_listener {
+       /**
+        * output_type - (none)
+        * @output: (none)
+        * @type: (none)
+        * @status: (none)
+        */
+       void (*output_type)(void *data,
+                           struct wl_eom *wl_eom,
+                           struct wl_output *output,
+                           uint32_t type,
+                           uint32_t status);
+       /**
+        * output_mode - (none)
+        * @output: (none)
+        * @mode: (none)
+        */
+       void (*output_mode)(void *data,
+                           struct wl_eom *wl_eom,
+                           struct wl_output *output,
+                           uint32_t mode);
+       /**
+        * output_attribute - (none)
+        * @output: (none)
+        * @attribute: (none)
+        * @attribute_state: (none)
+        * @error: (none)
+        */
+       void (*output_attribute)(void *data,
+                                struct wl_eom *wl_eom,
+                                struct wl_output *output,
+                                uint32_t attribute,
+                                uint32_t attribute_state,
+                                uint32_t error);
+};
+
+static inline int
+wl_eom_add_listener(struct wl_eom *wl_eom,
+                   const struct wl_eom_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) wl_eom,
+                                    (void (**)(void)) listener, data);
+}
+
+#define WL_EOM_SET_ATTRIBUTE   0
+
+static inline void
+wl_eom_set_user_data(struct wl_eom *wl_eom, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) wl_eom, user_data);
+}
+
+static inline void *
+wl_eom_get_user_data(struct wl_eom *wl_eom)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) wl_eom);
+}
+
+static inline void
+wl_eom_destroy(struct wl_eom *wl_eom)
+{
+       wl_proxy_destroy((struct wl_proxy *) wl_eom);
+}
+
+static inline void
+wl_eom_set_attribute(struct wl_eom *wl_eom, struct wl_output *output, uint32_t attribute)
+{
+       wl_proxy_marshal((struct wl_proxy *) wl_eom,
+                        WL_EOM_SET_ATTRIBUTE, output, attribute);
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/wayland/protocol/eom-protocol.c b/src/wayland/protocol/eom-protocol.c
new file mode 100644 (file)
index 0000000..fc7ccc7
--- /dev/null
@@ -0,0 +1,36 @@
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+extern const struct wl_interface wl_output_interface;
+
+static const struct wl_interface *types[] = {
+       &wl_output_interface,
+       NULL,
+       &wl_output_interface,
+       NULL,
+       NULL,
+       &wl_output_interface,
+       NULL,
+       &wl_output_interface,
+       NULL,
+       NULL,
+       NULL,
+};
+
+static const struct wl_message wl_eom_requests[] = {
+       { "set_attribute", "ou", types + 0 },
+};
+
+static const struct wl_message wl_eom_events[] = {
+       { "output_type", "ouu", types + 2 },
+       { "output_mode", "ou", types + 5 },
+       { "output_attribute", "ouuu", types + 7 },
+};
+
+WL_EXPORT const struct wl_interface wl_eom_interface = {
+       "wl_eom", 1,
+       1, wl_eom_requests,
+       3, wl_eom_events,
+};
+
diff --git a/src/wayland/protocol/eom.xml b/src/wayland/protocol/eom.xml
new file mode 100644 (file)
index 0000000..ed162a9
--- /dev/null
@@ -0,0 +1,102 @@
+<protocol name="wl_eom">
+  <interface name="wl_eom" version="1">
+    <description summary="an interface to get the information of the external outputs">
+      ***** TODO ******
+    </description>
+
+    <enum name="error">
+      <entry name="none" value="0" summary="no error"/>
+      <entry name="no_output" value="1" summary="Given output is invalid."/>
+      <entry name="no_attribute" value="2" summary="Given attribute is invalid."/>
+      <entry name="output_occupied" value="3" summary="The key has been grabbed already."/>
+    </enum>
+
+    <enum name="type">
+      <description summary="connector type of the external output">
+      ***** TODO ******
+      </description>
+      <entry name="none" value="0" summary="none"/>
+      <entry name="vga" value="1" summary="VGA output connector type"/>
+      <entry name="divi" value="2" summary="VGA output connector type"/>
+      <entry name="divd" value="3" summary="VGA output connector type"/>
+      <entry name="diva" value="4" summary="VGA output connector type"/>
+      <entry name="composite" value="5" summary="VGA output connector type"/>
+      <entry name="svideo" value="6" summary="VGA output connector type"/>
+      <entry name="lvds" value="7" summary="VGA output connector type"/>
+      <entry name="component" value="8" summary="VGA output connector type"/>
+      <entry name="9pindin" value="9" summary="VGA output connector type"/>
+      <entry name="displayport" value="10" summary="VGA output connector type"/>
+      <entry name="hdmia" value="11" summary="VGA output connector type"/>
+      <entry name="hdmib" value="12" summary="VGA output connector type"/>
+      <entry name="tv" value="13" summary="VGA output connector type"/>
+      <entry name="edp" value="14" summary="VGA output connector type"/>
+      <entry name="virtual" value="15" summary="VGA output connector type"/>
+      <entry name="dsi" value="16" summary="VGA output connector type"/>
+    </enum>
+
+   <enum name="status">
+      <description summary="connection status of the external output">
+      ***** TODO ******
+      </description>
+      <entry name="none" value="0" summary="none"/>
+      <entry name="connection" value="1" summary="output connected"/>
+      <entry name="disconnection" value="2" summary="output disconnected"/>
+    </enum>
+
+   <enum name="mode">
+      <description summary="mode of the external output">
+      ***** TODO ******
+      </description>
+      <entry name="none" value="0" summary="none"/>
+      <entry name="mirror" value="1" summary="mirror mode"/>
+      <entry name="presentation" value="2" summary="presentation mode"/>
+    </enum>
+
+   <enum name="attribute">
+      <description summary="attribute of the external output">
+      ***** TODO ******
+      </description>
+      <entry name="none" value="0" summary="none"/>
+      <entry name="normal" value="1" summary="nomal attribute"/>
+      <entry name="exclusive_shared" value="2" summary="exclusive shared attribute"/>
+      <entry name="exclusive" value="3" summary="exclusive attribute"/>
+    </enum>
+
+   <enum name="attribute_state">
+      <description summary="state of the external output attribute">
+      ***** TODO ******
+      </description>
+      <entry name="none" value="0" summary="none"/>
+      <entry name="active" value="1" summary="attribute is active on the output"/>
+      <entry name="inactive" value="2" summary="attribute is inactive on the output"/>
+      <entry name="lost" value="3" summary="the connection of output is lost"/>
+    </enum>
+
+    <request name="set_attribute">
+      <arg name="output" type="object" interface="wl_output"/>
+      <arg name="attribute" type="uint"/>
+    </request>
+
+    <event name="output_type">
+      <arg name="output" type="object" interface="wl_output"/>
+      <arg name="type" type="uint"/>
+      <arg name="status" type="uint"/>
+      <arg name="error" type="uint"/>
+    </event>
+
+    <event name="output_mode">
+      <arg name="output" type="object" interface="wl_output"/>
+      <arg name="mode" type="uint"/>
+      <arg name="error" type="uint"/>
+    </event>
+
+    <event name="output_attribute">
+      <arg name="output" type="object" interface="wl_output"/>
+      <arg name="attribute" type="uint"/>
+      <arg name="attribute_state" type="uint"/>
+      <arg name="error" type="uint"/>
+    </event>
+
+  </interface>
+</protocol>
+
diff --git a/src/wayland/protocol/xdg-shell-client-protocol.h b/src/wayland/protocol/xdg-shell-client-protocol.h
new file mode 100644 (file)
index 0000000..ed743fd
--- /dev/null
@@ -0,0 +1,496 @@
+/*
+ * Copyright © 2008-2013 Kristian Høgsberg
+ * Copyright © 2013      Rafael Antognolli
+ * Copyright © 2013      Jasper St. Pierre
+ * Copyright © 2010-2013 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this
+ * software and its documentation for any purpose is hereby granted
+ * without fee, provided that the above copyright notice appear in
+ * all copies and that both that copyright notice and this permission
+ * notice appear in supporting documentation, and that the name of
+ * the copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+
+#ifndef XDG_SHELL_CLIENT_PROTOCOL_H
+#define XDG_SHELL_CLIENT_PROTOCOL_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-client.h"
+
+struct wl_client;
+struct wl_resource;
+
+struct xdg_shell;
+struct xdg_surface;
+struct xdg_popup;
+
+extern const struct wl_interface xdg_shell_interface;
+extern const struct wl_interface xdg_surface_interface;
+extern const struct wl_interface xdg_popup_interface;
+
+#ifndef XDG_SHELL_VERSION_ENUM
+#define XDG_SHELL_VERSION_ENUM
+/**
+ * xdg_shell_version - latest protocol version
+ * @XDG_SHELL_VERSION_CURRENT: Always the latest version
+ *
+ * The 'current' member of this enum gives the version of the protocol.
+ * Implementations can compare this to the version they implement using
+ * static_assert to ensure the protocol and implementation versions match.
+ */
+enum xdg_shell_version {
+       XDG_SHELL_VERSION_CURRENT = 4,
+};
+#endif /* XDG_SHELL_VERSION_ENUM */
+
+/**
+ * xdg_shell - create desktop-style surfaces
+ * @ping: check if the client is alive
+ *
+ * This interface is implemented by servers that provide desktop-style
+ * user interfaces.
+ *
+ * It allows clients to associate a xdg_surface with a basic surface.
+ */
+struct xdg_shell_listener {
+       /**
+        * ping - check if the client is alive
+        * @serial: pass this to the callback
+        *
+        * The ping event asks the client if it's still alive. Pass the
+        * serial specified in the event back to the compositor by sending
+        * a "pong" request back with the specified serial.
+        *
+        * Compositors can use this to determine if the client is still
+        * alive. It's unspecified what will happen if the client doesn't
+        * respond to the ping request, or in what timeframe. Clients
+        * should try to respond in a reasonable amount of time.
+        */
+       void (*ping)(void *data,
+                    struct xdg_shell *xdg_shell,
+                    uint32_t serial);
+};
+
+static inline int
+xdg_shell_add_listener(struct xdg_shell *xdg_shell,
+                      const struct xdg_shell_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) xdg_shell,
+                                    (void (**)(void)) listener, data);
+}
+
+#define XDG_SHELL_USE_UNSTABLE_VERSION 0
+#define XDG_SHELL_GET_XDG_SURFACE      1
+#define XDG_SHELL_GET_XDG_POPUP        2
+#define XDG_SHELL_PONG 3
+
+static inline void
+xdg_shell_set_user_data(struct xdg_shell *xdg_shell, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) xdg_shell, user_data);
+}
+
+static inline void *
+xdg_shell_get_user_data(struct xdg_shell *xdg_shell)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) xdg_shell);
+}
+
+static inline void
+xdg_shell_destroy(struct xdg_shell *xdg_shell)
+{
+       wl_proxy_destroy((struct wl_proxy *) xdg_shell);
+}
+
+static inline void
+xdg_shell_use_unstable_version(struct xdg_shell *xdg_shell, int32_t version)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_shell,
+                        XDG_SHELL_USE_UNSTABLE_VERSION, version);
+}
+
+static inline struct xdg_surface *
+xdg_shell_get_xdg_surface(struct xdg_shell *xdg_shell, struct wl_surface *surface)
+{
+       struct wl_proxy *id;
+
+       id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_shell,
+                        XDG_SHELL_GET_XDG_SURFACE, &xdg_surface_interface, NULL, surface);
+
+       return (struct xdg_surface *) id;
+}
+
+static inline struct xdg_popup *
+xdg_shell_get_xdg_popup(struct xdg_shell *xdg_shell, struct wl_surface *surface, struct wl_surface *parent, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y, uint32_t flags)
+{
+       struct wl_proxy *id;
+
+       id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_shell,
+                        XDG_SHELL_GET_XDG_POPUP, &xdg_popup_interface, NULL, surface, parent, seat, serial, x, y, flags);
+
+       return (struct xdg_popup *) id;
+}
+
+static inline void
+xdg_shell_pong(struct xdg_shell *xdg_shell, uint32_t serial)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_shell,
+                        XDG_SHELL_PONG, serial);
+}
+
+#ifndef XDG_SURFACE_RESIZE_EDGE_ENUM
+#define XDG_SURFACE_RESIZE_EDGE_ENUM
+/**
+ * xdg_surface_resize_edge - edge values for resizing
+ * @XDG_SURFACE_RESIZE_EDGE_NONE: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_TOP: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_BOTTOM: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_LEFT: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_TOP_LEFT: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_RIGHT: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT: (none)
+ * @XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT: (none)
+ *
+ * These values are used to indicate which edge of a surface is being
+ * dragged in a resize operation. The server may use this information to
+ * adapt its behavior, e.g. choose an appropriate cursor image.
+ */
+enum xdg_surface_resize_edge {
+       XDG_SURFACE_RESIZE_EDGE_NONE = 0,
+       XDG_SURFACE_RESIZE_EDGE_TOP = 1,
+       XDG_SURFACE_RESIZE_EDGE_BOTTOM = 2,
+       XDG_SURFACE_RESIZE_EDGE_LEFT = 4,
+       XDG_SURFACE_RESIZE_EDGE_TOP_LEFT = 5,
+       XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT = 6,
+       XDG_SURFACE_RESIZE_EDGE_RIGHT = 8,
+       XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT = 9,
+       XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT = 10,
+};
+#endif /* XDG_SURFACE_RESIZE_EDGE_ENUM */
+
+#ifndef XDG_SURFACE_STATE_ENUM
+#define XDG_SURFACE_STATE_ENUM
+/**
+ * xdg_surface_state - types of state on the surface
+ * @XDG_SURFACE_STATE_MAXIMIZED: the surface is maximized
+ * @XDG_SURFACE_STATE_FULLSCREEN: the surface is fullscreen
+ * @XDG_SURFACE_STATE_RESIZING: (none)
+ * @XDG_SURFACE_STATE_ACTIVATED: (none)
+ *
+ * The different state values used on the surface. This is designed for
+ * state values like maximized, fullscreen. It is paired with the configure
+ * event to ensure that both the client and the compositor setting the
+ * state can be synchronized.
+ *
+ * States set in this way are double-buffered. They will get applied on the
+ * next commit.
+ *
+ * Desktop environments may extend this enum by taking up a range of values
+ * and documenting the range they chose in this description. They are not
+ * required to document the values for the range that they chose. Ideally,
+ * any good extensions from a desktop environment should make its way into
+ * standardization into this enum.
+ *
+ * The current reserved ranges are:
+ *
+ * 0x0000 - 0x0FFF: xdg-shell core values, documented below. 0x1000 -
+ * 0x1FFF: GNOME
+ */
+enum xdg_surface_state {
+       XDG_SURFACE_STATE_MAXIMIZED = 1,
+       XDG_SURFACE_STATE_FULLSCREEN = 2,
+       XDG_SURFACE_STATE_RESIZING = 3,
+       XDG_SURFACE_STATE_ACTIVATED = 4,
+};
+#endif /* XDG_SURFACE_STATE_ENUM */
+
+/**
+ * xdg_surface - desktop-style metadata interface
+ * @configure: suggest a surface change
+ * @close: surface wants to be closed
+ *
+ * An interface that may be implemented by a wl_surface, for
+ * implementations that provide a desktop-style user interface.
+ *
+ * It provides requests to treat surfaces like windows, allowing to set
+ * properties like maximized, fullscreen, minimized, and to move and resize
+ * them, and associate metadata like title and app id.
+ *
+ * On the server side the object is automatically destroyed when the
+ * related wl_surface is destroyed. On client side, xdg_surface.destroy()
+ * must be called before destroying the wl_surface object.
+ */
+struct xdg_surface_listener {
+       /**
+        * configure - suggest a surface change
+        * @width: (none)
+        * @height: (none)
+        * @states: (none)
+        * @serial: (none)
+        *
+        * The configure event asks the client to resize its surface.
+        *
+        * The width and height arguments specify a hint to the window
+        * about how its surface should be resized in window geometry
+        * coordinates. The states listed in the event specify how the
+        * width/height arguments should be interpreted.
+        *
+        * A client should arrange a new surface, and then send a
+        * ack_configure request with the serial sent in this configure
+        * event before attaching a new surface.
+        *
+        * If the client receives multiple configure events before it can
+        * respond to one, it is free to discard all but the last event it
+        * received.
+        */
+       void (*configure)(void *data,
+                         struct xdg_surface *xdg_surface,
+                         int32_t width,
+                         int32_t height,
+                         struct wl_array *states,
+                         uint32_t serial);
+       /**
+        * close - surface wants to be closed
+        *
+        * The close event is sent by the compositor when the user wants
+        * the surface to be closed. This should be equivalent to the user
+        * clicking the close button in client-side decorations, if your
+        * application has any...
+        *
+        * This is only a request that the user intends to close your
+        * window. The client may choose to ignore this request, or show a
+        * dialog to ask the user to save their data...
+        */
+       void (*close)(void *data,
+                     struct xdg_surface *xdg_surface);
+};
+
+static inline int
+xdg_surface_add_listener(struct xdg_surface *xdg_surface,
+                        const struct xdg_surface_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) xdg_surface,
+                                    (void (**)(void)) listener, data);
+}
+
+#define XDG_SURFACE_DESTROY    0
+#define XDG_SURFACE_SET_PARENT 1
+#define XDG_SURFACE_SET_TITLE  2
+#define XDG_SURFACE_SET_APP_ID 3
+#define XDG_SURFACE_SHOW_WINDOW_MENU   4
+#define XDG_SURFACE_MOVE       5
+#define XDG_SURFACE_RESIZE     6
+#define XDG_SURFACE_ACK_CONFIGURE      7
+#define XDG_SURFACE_SET_WINDOW_GEOMETRY        8
+#define XDG_SURFACE_SET_MAXIMIZED      9
+#define XDG_SURFACE_UNSET_MAXIMIZED    10
+#define XDG_SURFACE_SET_FULLSCREEN     11
+#define XDG_SURFACE_UNSET_FULLSCREEN   12
+#define XDG_SURFACE_SET_MINIMIZED      13
+
+static inline void
+xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) xdg_surface, user_data);
+}
+
+static inline void *
+xdg_surface_get_user_data(struct xdg_surface *xdg_surface)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) xdg_surface);
+}
+
+static inline void
+xdg_surface_destroy(struct xdg_surface *xdg_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_DESTROY);
+
+       wl_proxy_destroy((struct wl_proxy *) xdg_surface);
+}
+
+static inline void
+xdg_surface_set_parent(struct xdg_surface *xdg_surface, struct wl_surface *parent)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_PARENT, parent);
+}
+
+static inline void
+xdg_surface_set_title(struct xdg_surface *xdg_surface, const char *title)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_TITLE, title);
+}
+
+static inline void
+xdg_surface_set_app_id(struct xdg_surface *xdg_surface, const char *app_id)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_APP_ID, app_id);
+}
+
+static inline void
+xdg_surface_show_window_menu(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SHOW_WINDOW_MENU, seat, serial, x, y);
+}
+
+static inline void
+xdg_surface_move(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_MOVE, seat, serial);
+}
+
+static inline void
+xdg_surface_resize(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial, uint32_t edges)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_RESIZE, seat, serial, edges);
+}
+
+static inline void
+xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_ACK_CONFIGURE, serial);
+}
+
+static inline void
+xdg_surface_set_window_geometry(struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_WINDOW_GEOMETRY, x, y, width, height);
+}
+
+static inline void
+xdg_surface_set_maximized(struct xdg_surface *xdg_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_MAXIMIZED);
+}
+
+static inline void
+xdg_surface_unset_maximized(struct xdg_surface *xdg_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_UNSET_MAXIMIZED);
+}
+
+static inline void
+xdg_surface_set_fullscreen(struct xdg_surface *xdg_surface, struct wl_output *output)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_FULLSCREEN, output);
+}
+
+static inline void
+xdg_surface_unset_fullscreen(struct xdg_surface *xdg_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_UNSET_FULLSCREEN);
+}
+
+static inline void
+xdg_surface_set_minimized(struct xdg_surface *xdg_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_MINIMIZED);
+}
+
+/**
+ * xdg_popup - desktop-style metadata interface
+ * @popup_done: popup interaction is done
+ *
+ * An interface that may be implemented by a wl_surface, for
+ * implementations that provide a desktop-style popups/menus. A popup
+ * surface is a transient surface with an added pointer grab.
+ *
+ * An existing implicit grab will be changed to owner-events mode, and the
+ * popup grab will continue after the implicit grab ends (i.e. releasing
+ * the mouse button does not cause the popup to be unmapped).
+ *
+ * The popup grab continues until the window is destroyed or a mouse button
+ * is pressed in any other clients window. A click in any of the clients
+ * surfaces is reported as normal, however, clicks in other clients
+ * surfaces will be discarded and trigger the callback.
+ *
+ * The x and y arguments specify the locations of the upper left corner of
+ * the surface relative to the upper left corner of the parent surface, in
+ * surface local coordinates.
+ *
+ * xdg_popup surfaces are always transient for another surface.
+ */
+struct xdg_popup_listener {
+       /**
+        * popup_done - popup interaction is done
+        * @serial: serial of the implicit grab on the pointer
+        *
+        * The popup_done event is sent out when a popup grab is broken,
+        * that is, when the users clicks a surface that doesn't belong to
+        * the client owning the popup surface.
+        */
+       void (*popup_done)(void *data,
+                          struct xdg_popup *xdg_popup,
+                          uint32_t serial);
+};
+
+static inline int
+xdg_popup_add_listener(struct xdg_popup *xdg_popup,
+                      const struct xdg_popup_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) xdg_popup,
+                                    (void (**)(void)) listener, data);
+}
+
+#define XDG_POPUP_DESTROY      0
+
+static inline void
+xdg_popup_set_user_data(struct xdg_popup *xdg_popup, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) xdg_popup, user_data);
+}
+
+static inline void *
+xdg_popup_get_user_data(struct xdg_popup *xdg_popup)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) xdg_popup);
+}
+
+static inline void
+xdg_popup_destroy(struct xdg_popup *xdg_popup)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_popup,
+                        XDG_POPUP_DESTROY);
+
+       wl_proxy_destroy((struct wl_proxy *) xdg_popup);
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/wayland/protocol/xdg-shell-protocol.c b/src/wayland/protocol/xdg-shell-protocol.c
new file mode 100644 (file)
index 0000000..863f74e
--- /dev/null
@@ -0,0 +1,125 @@
+/* 
+ * Copyright © 2008-2013 Kristian Høgsberg
+ * Copyright © 2013      Rafael Antognolli
+ * Copyright © 2013      Jasper St. Pierre
+ * Copyright © 2010-2013 Intel Corporation
+ * 
+ * Permission to use, copy, modify, distribute, and sell this
+ * software and its documentation for any purpose is hereby granted
+ * without fee, provided that the above copyright notice appear in
+ * all copies and that both that copyright notice and this permission
+ * notice appear in supporting documentation, and that the name of
+ * the copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied
+ * warranty.
+ * 
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+extern const struct wl_interface wl_output_interface;
+extern const struct wl_interface wl_seat_interface;
+extern const struct wl_interface wl_surface_interface;
+extern const struct wl_interface xdg_popup_interface;
+extern const struct wl_interface xdg_surface_interface;
+
+static const struct wl_interface *types[] = {
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       &xdg_surface_interface,
+       &wl_surface_interface,
+       &xdg_popup_interface,
+       &wl_surface_interface,
+       &wl_surface_interface,
+       &wl_seat_interface,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       &wl_surface_interface,
+       &wl_seat_interface,
+       NULL,
+       NULL,
+       NULL,
+       &wl_seat_interface,
+       NULL,
+       &wl_seat_interface,
+       NULL,
+       NULL,
+       &wl_output_interface,
+};
+
+static const struct wl_message xdg_shell_requests[] = {
+       { "use_unstable_version", "i", types + 0 },
+       { "get_xdg_surface", "no", types + 4 },
+       { "get_xdg_popup", "nooouiiu", types + 6 },
+       { "pong", "u", types + 0 },
+};
+
+static const struct wl_message xdg_shell_events[] = {
+       { "ping", "u", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_shell_interface = {
+       "xdg_shell", 1,
+       4, xdg_shell_requests,
+       1, xdg_shell_events,
+};
+
+static const struct wl_message xdg_surface_requests[] = {
+       { "destroy", "", types + 0 },
+       { "set_parent", "?o", types + 14 },
+       { "set_title", "s", types + 0 },
+       { "set_app_id", "s", types + 0 },
+       { "show_window_menu", "ouii", types + 15 },
+       { "move", "ou", types + 19 },
+       { "resize", "ouu", types + 21 },
+       { "ack_configure", "u", types + 0 },
+       { "set_window_geometry", "iiii", types + 0 },
+       { "set_maximized", "", types + 0 },
+       { "unset_maximized", "", types + 0 },
+       { "set_fullscreen", "?o", types + 24 },
+       { "unset_fullscreen", "", types + 0 },
+       { "set_minimized", "", types + 0 },
+};
+
+static const struct wl_message xdg_surface_events[] = {
+       { "configure", "iiau", types + 0 },
+       { "close", "", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_surface_interface = {
+       "xdg_surface", 1,
+       14, xdg_surface_requests,
+       2, xdg_surface_events,
+};
+
+static const struct wl_message xdg_popup_requests[] = {
+       { "destroy", "", types + 0 },
+};
+
+static const struct wl_message xdg_popup_events[] = {
+       { "popup_done", "u", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_popup_interface = {
+       "xdg_popup", 1,
+       1, xdg_popup_requests,
+       1, xdg_popup_events,
+};
+