ecore-wayland: Implement ivi-shell support for Ecore_Wayland
authorChris Michael <cp.michael@samsung.com>
Mon, 25 Aug 2014 12:44:10 +0000 (08:44 -0400)
committerChris Michael <cp.michael@samsung.com>
Mon, 25 Aug 2014 13:04:38 +0000 (09:04 -0400)
IVI-Shell is a wayland shell implementation for in-vehicle infotainment.

Summary: This is a set of patches proposed to implement IVI-Shell (https://phab.enlightenment.org/T1552).

Reviewers: ntanibata, devilhorns

Subscribers: mbachmann

Projects: #efl

Differential Revision: https://phab.enlightenment.org/D1350

@feature

configure.ac
src/Makefile_Ecore_Wayland.am
src/lib/ecore_wayland/ecore_wl.c
src/lib/ecore_wayland/ecore_wl_private.h
src/lib/ecore_wayland/ecore_wl_window.c
src/lib/ecore_wayland/ivi-application-client-protocol.h [new file with mode: 0644]
src/lib/ecore_wayland/ivi-application-protocol.c [new file with mode: 0644]

index 3247ee6..5a865ab 100644 (file)
@@ -1255,6 +1255,18 @@ if test "${want_wayland}" = "yes"; then
    EFL_PKG_CHECK_STRICT([wayland-client >= 1.3.0])
 fi
 
+# Wayland IVI-Shell
+AC_ARG_ENABLE([wayland-ivi-shell],
+   [AS_HELP_STRING([--enable-wayland-ivi-shell],[enable ivi-shell support. @<:@default=disabled@:>@])],
+   [
+    if test "x${enableval}" = "xyes" ; then
+       want_wayland_ivi_shell="yes"
+    else
+       want_wayland_ivi_shell="no"
+    fi
+   ],
+   [want_wayland_ivi_shell="no"])
+
 # Fb
 AC_ARG_ENABLE([fb],
    [AS_HELP_STRING([--enable-fb],[enable raw Framebuffer access. @<:@default=disabled@:>@])],
@@ -2815,6 +2827,10 @@ EFL_LIB_END_OPTIONAL([Ecore_SDL])
 #### Ecore_Wayland
 EFL_LIB_START_OPTIONAL([Ecore_Wayland], [test "${want_wayland}" = "yes"])
 
+if test "x${want_wayland_ivi_shell}" = "xyes" ; then
+   AC_DEFINE(USE_IVI_SHELL, 1, [Ecore_Wayland IVI-Shell Support])
+fi
+
 ### Additional options to configure
 
 ### Default values
@@ -4593,6 +4609,7 @@ echo "Ecore_IMF.......: ${efl_lib_optional_ecore_imf} (${features_ecore_imf})"
 echo "Ecore_X.........: ${with_x11} (${features_ecore_x})"
 echo "Ecore_SDL.......: $want_sdl"
 echo "Ecore_Wayland...: $want_wayland"
+echo "IVI-Shell.......: $want_wayland_ivi_shell"
 if test "${have_linux}" = "yes"; then
 echo "Ecore_FB........: $want_fb (${features_ecore_fb})"
 elif test "${have_ps3}" = "yes"; then
index f11c3a5..22cc60b 100644 (file)
@@ -17,7 +17,10 @@ lib/ecore_wayland/ecore_wl_window.c \
 lib/ecore_wayland/ecore_wl_subsurf.c \
 lib/ecore_wayland/ecore_wl_private.h \
 lib/ecore_wayland/subsurface-protocol.c \
-lib/ecore_wayland/subsurface-client-protocol.h
+lib/ecore_wayland/subsurface-client-protocol.h \
+lib/ecore_wayland/ivi-application-protocol.c \
+lib/ecore_wayland/ivi-application-client-protocol.h
+
 
 lib_ecore_wayland_libecore_wayland_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECORE_WAYLAND_CFLAGS@
 lib_ecore_wayland_libecore_wayland_la_LIBADD = @ECORE_WAYLAND_LIBS@
index 49d10b7..9b63f2e 100644 (file)
@@ -458,6 +458,10 @@ _ecore_wl_shutdown(Eina_Bool close)
 
         _ecore_wl_xkb_shutdown(_ecore_wl_disp);
 
+#ifdef USE_IVI_SHELL
+        if (_ecore_wl_disp->wl.ivi_application)
+          ivi_application_destroy(_ecore_wl_disp->wl.ivi_application);
+#endif
         if (_ecore_wl_disp->wl.shell)
           wl_shell_destroy(_ecore_wl_disp->wl.shell);
         if (_ecore_wl_disp->wl.shm) wl_shm_destroy(_ecore_wl_disp->wl.shm);
@@ -599,6 +603,13 @@ _ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned in
      _ecore_wl_output_add(ewd, id);
    else if (!strcmp(interface, "wl_seat"))
      _ecore_wl_input_add(ewd, id);
+#ifdef USE_IVI_SHELL
+   else if (!strcmp(interface, "ivi_application"))
+     {
+        ewd->wl.ivi_application =
+          wl_registry_bind(registry, id, &ivi_application_interface, 1);
+     }
+#endif
    else if (!strcmp(interface, "wl_shell"))
      {
         ewd->wl.shell =
index c7791a9..624211f 100644 (file)
@@ -7,6 +7,10 @@
 # include "Ecore.h"
 # include "Ecore_Input.h"
 # include "Ecore_Wayland.h"
+# ifdef USE_IVI_SHELL
+# include "ivi-application-client-protocol.h"
+# define IVI_SURFACE_ID 6000
+# endif
 
 //# define LOGFNS 1
 
@@ -61,6 +65,9 @@ struct _Ecore_Wl_Display
         struct wl_subcompositor *subcompositor;
         struct wl_shell *shell;
         struct wl_shell *desktop_shell;
+# ifdef USE_IVI_SHELL
+        struct ivi_application *ivi_application;
+# endif
         struct wl_shm *shm;
         struct wl_data_device_manager *data_device_manager;
      } wl;
@@ -99,6 +106,10 @@ struct _Ecore_Wl_Window
 
    struct wl_surface *surface;
    struct wl_shell_surface *shell_surface;
+# ifdef USE_IVI_SHELL
+   struct ivi_surface *ivi_surface;
+   int ivi_surface_id;
+# endif
 
    struct
      {
index 5dfb35c..13a4e7b 100644 (file)
@@ -117,6 +117,10 @@ ecore_wl_window_free(Ecore_Wl_Window *win)
 
    if (win->subsurfs) _ecore_wl_subsurfs_del_all(win);
 
+#ifdef USE_IVI_SHELL
+   if (win->ivi_surface) ivi_surface_destroy(win->ivi_surface);
+   win->ivi_surface = NULL;
+#endif
    if (win->shell_surface) wl_shell_surface_destroy(win->shell_surface);
    win->shell_surface = NULL;
    if (win->surface) wl_surface_destroy(win->surface);
@@ -250,6 +254,10 @@ ecore_wl_window_surface_create(Ecore_Wl_Window *win)
 EAPI void 
 ecore_wl_window_show(Ecore_Wl_Window *win)
 {
+#ifdef USE_IVI_SHELL
+   char *env;
+#endif
+
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
    if (!win) return;
@@ -259,6 +267,22 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
    if ((win->type != ECORE_WL_WINDOW_TYPE_DND) &&
        (win->type != ECORE_WL_WINDOW_TYPE_NONE))
      {
+#ifdef USE_IVI_SHELL
+        if ((!win->ivi_surface) && (_ecore_wl_disp->wl.ivi_application))
+          {
+             if (win->parent && win->parent->ivi_surface)
+               win->ivi_surface_id = win->parent->ivi_surface_id + 1;
+             else if ((env = getenv("ECORE_IVI_SURFACE_ID")))
+               win->ivi_surface_id = atoi(env);
+             else
+               win->ivi_surface_id = IVI_SURFACE_ID + getpid();
+
+             win->ivi_surface =
+               ivi_application_surface_create(_ecore_wl_disp->wl.ivi_application,
+                                              win->ivi_surface_id, win->surface);
+          }
+        if (!win->ivi_surface) {
+#endif
         if ((!win->shell_surface) && (_ecore_wl_disp->wl.shell))
           {
              win->shell_surface = 
@@ -275,6 +299,9 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
         if (win->shell_surface)
           wl_shell_surface_add_listener(win->shell_surface, 
                                         &_ecore_wl_shell_surface_listener, win);
+#ifdef USE_IVI_SHELL
+        }
+#endif
      }
 
    /* trap for valid shell surface */
diff --git a/src/lib/ecore_wayland/ivi-application-client-protocol.h b/src/lib/ecore_wayland/ivi-application-client-protocol.h
new file mode 100644 (file)
index 0000000..20c7d38
--- /dev/null
@@ -0,0 +1,176 @@
+/* 
+ * Copyright (C) 2013 DENSO CORPORATION
+ * Copyright (c) 2013 BMW Car IT GmbH
+ * 
+ * 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, sublicense, 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 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 NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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 IVI_APPLICATION_CLIENT_PROTOCOL_H
+#define IVI_APPLICATION_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 ivi_surface;
+struct ivi_application;
+
+extern const struct wl_interface ivi_surface_interface;
+extern const struct wl_interface ivi_application_interface;
+
+#ifndef IVI_SURFACE_WARNING_CODE_ENUM
+#define IVI_SURFACE_WARNING_CODE_ENUM
+/**
+ * ivi_surface_warning_code - possible warning codes returned by ivi
+ *     compositor
+ * @IVI_SURFACE_WARNING_CODE_INVALID_WL_SURFACE: wl_surface is invalid
+ * @IVI_SURFACE_WARNING_CODE_IVI_ID_IN_USE: ivi_id is in use and can not
+ *     be shared
+ *
+ * These define all possible warning codes returned by ivi compositor on
+ * server-side warnings. invalid_wl_surface: - wl_surface already has a
+ * another role. - wl_surface is destroyed before the ivi_surface is
+ * destroyed. ivi_id_in_use: ivi_id is already assigned by another
+ * application.
+ */
+enum ivi_surface_warning_code {
+       IVI_SURFACE_WARNING_CODE_INVALID_WL_SURFACE = 1,
+       IVI_SURFACE_WARNING_CODE_IVI_ID_IN_USE = 2,
+};
+#endif /* IVI_SURFACE_WARNING_CODE_ENUM */
+
+/**
+ * ivi_surface - application interface to surface in ivi compositor
+ * @visibility: visibility of surface in ivi compositor has changed
+ * @warning: server-side warning detected
+ *
+ * 
+ */
+struct ivi_surface_listener {
+       /**
+        * visibility - visibility of surface in ivi compositor has
+        *      changed
+        * @visibility: (none)
+        *
+        * The new visibility state is provided in argument visibility.
+        * If visibility is 0, the surface has become invisible. If
+        * visibility is not 0, the surface has become visible.
+        */
+       void (*visibility)(void *data,
+                          struct ivi_surface *ivi_surface,
+                          int32_t visibility);
+       /**
+        * warning - server-side warning detected
+        * @warning_code: (none)
+        * @warning_text: (none)
+        *
+        * The ivi compositor encountered warning while processing a
+        * request by this application. The warning is defined by argument
+        * warning_code and optional warning_text. If the warning is
+        * detected, client shall destroy the ivi_surface object.
+        *
+        * When a warning event is sent, the compositor turns the
+        * ivi_surface object inert. The ivi_surface will not deliver
+        * further events, all requests on it are ignored except 'destroy',
+        * and the association to the ivi_id is removed. The client should
+        * destroy the ivi_surface object. If an inert ivi_surface object
+        * is used as an argument to any other object's request, that
+        * request will [produce a fatal error / produce a warning / be
+        * ignored].
+        */
+       void (*warning)(void *data,
+                       struct ivi_surface *ivi_surface,
+                       int32_t warning_code,
+                       const char *warning_text);
+};
+
+static inline int
+ivi_surface_add_listener(struct ivi_surface *ivi_surface,
+                        const struct ivi_surface_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) ivi_surface,
+                                    (void (**)(void)) listener, data);
+}
+
+#define IVI_SURFACE_DESTROY    0
+
+static inline void
+ivi_surface_set_user_data(struct ivi_surface *ivi_surface, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) ivi_surface, user_data);
+}
+
+static inline void *
+ivi_surface_get_user_data(struct ivi_surface *ivi_surface)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) ivi_surface);
+}
+
+static inline void
+ivi_surface_destroy(struct ivi_surface *ivi_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) ivi_surface,
+                        IVI_SURFACE_DESTROY);
+
+       wl_proxy_destroy((struct wl_proxy *) ivi_surface);
+}
+
+#define IVI_APPLICATION_SURFACE_CREATE 0
+
+static inline void
+ivi_application_set_user_data(struct ivi_application *ivi_application, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) ivi_application, user_data);
+}
+
+static inline void *
+ivi_application_get_user_data(struct ivi_application *ivi_application)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) ivi_application);
+}
+
+static inline void
+ivi_application_destroy(struct ivi_application *ivi_application)
+{
+       wl_proxy_destroy((struct wl_proxy *) ivi_application);
+}
+
+static inline struct ivi_surface *
+ivi_application_surface_create(struct ivi_application *ivi_application, uint32_t ivi_id, struct wl_surface *surface)
+{
+       struct wl_proxy *id;
+
+       id = wl_proxy_marshal_constructor((struct wl_proxy *) ivi_application,
+                        IVI_APPLICATION_SURFACE_CREATE, &ivi_surface_interface, ivi_id, surface, NULL);
+
+       return (struct ivi_surface *) id;
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/ecore_wayland/ivi-application-protocol.c b/src/lib/ecore_wayland/ivi-application-protocol.c
new file mode 100644 (file)
index 0000000..5ab298c
--- /dev/null
@@ -0,0 +1,63 @@
+/* 
+ * Copyright (C) 2013 DENSO CORPORATION
+ * Copyright (c) 2013 BMW Car IT GmbH
+ * 
+ * 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, sublicense, 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 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 NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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 <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+extern const struct wl_interface ivi_surface_interface;
+extern const struct wl_interface wl_surface_interface;
+
+static const struct wl_interface *types[] = {
+       NULL,
+       NULL,
+       NULL,
+       &wl_surface_interface,
+       &ivi_surface_interface,
+};
+
+static const struct wl_message ivi_surface_requests[] = {
+       { "destroy", "", types + 0 },
+};
+
+static const struct wl_message ivi_surface_events[] = {
+       { "visibility", "i", types + 0 },
+       { "warning", "i?s", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface ivi_surface_interface = {
+       "ivi_surface", 1,
+       1, ivi_surface_requests,
+       2, ivi_surface_events,
+};
+
+static const struct wl_message ivi_application_requests[] = {
+       { "surface_create", "uon", types + 2 },
+};
+
+WL_EXPORT const struct wl_interface ivi_application_interface = {
+       "ivi_application", 1,
+       1, ivi_application_requests,
+       0, NULL,
+};
+