wayland: use the xdg-shell protocol to trigger window state 53/16953/2 accepted/tizen_ivi_release tizen_ivi_release accepted/tizen/generic/20140306.125737 accepted/tizen/ivi/20140306.205002 accepted/tizen/ivi/release/20140315.015610 accepted/tizen/ivi/release/20140412.070453 submit/heads/tizen/20140306.102504 submit/tizen/20140306.125701 submit/tizen_ivi_release/20140315.015643 submit/tizen_ivi_release/20140412.065334
authorManuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Thu, 27 Feb 2014 12:36:40 +0000 (13:36 +0100)
committerManuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Tue, 4 Mar 2014 10:43:39 +0000 (11:43 +0100)
Implement the optional xdg-shell protocol for maximization,
fullscreen, title settings... in case it is implemented by
the compositor. Fall back gracefully to wl_shell otherwise.

Added feature: minimization.

Bug-Tizen: TIVI-2809

Change-Id: Ib764e6b267a24b70e916519b03d92920892c387b
Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
configure.ac
src/lib/ecore_evas/ecore_evas_wayland_egl.c
src/lib/ecore_evas/ecore_evas_wayland_shm.c
src/lib/ecore_wayland/Ecore_Wayland.h
src/lib/ecore_wayland/Makefile.am
src/lib/ecore_wayland/ecore_wl.c
src/lib/ecore_wayland/ecore_wl_window.c
src/lib/ecore_wayland/xdg-shell-client-protocol.h [new file with mode: 0644]
src/lib/ecore_wayland/xdg-shell-protocol.c [new file with mode: 0644]

index b18c773..ba7f8bd 100644 (file)
@@ -131,6 +131,7 @@ want_ecore_fb="no"
 want_ecore_directfb="no"
 want_ecore_wince="no"
 want_ecore_wayland="no"
+want_ecore_wayland_xdg_shell="no"
 
 # ecore_x options (both xlib and xcb)
 want_ecore_x_composite="yes"
@@ -230,6 +231,7 @@ case "$host_os" in
       want_ecore_imf="yes"
       want_ecore_x="yes"
       want_ecore_wayland="yes"
+      want_ecore_wayland_xdg_shell="yes"
       want_ecore_evas_software_x11="yes"
       want_ecore_evas_opengl_x11="yes"
       want_ecore_evas_software_16_x11="yes"
@@ -1204,6 +1206,13 @@ AC_SUBST(ecore_x_libs_private)
 AM_CONDITIONAL(BUILD_ECORE_X_XLIB, test $have_ecore_x_xlib = yes)
 AM_CONDITIONAL(BUILD_ECORE_X_XCB, test $have_ecore_x_xcb = yes)
 
+# Wayland (ecore_wayland)
+
+AC_ARG_ENABLE(ecore-wayland-xdg-shell,
+   AC_HELP_STRING([--enable-wayland-xdg-shell],
+       [enable the ecore_wayland support for XDG-Shell
+        @<:@default=enabled@:>@]),
+   [want_ecore_wayland_xdg_shell=$enableval])
 
 # Evas library (ecore_config, ecore_input_evas, ecore_imf_evas and ecore_evas)
 
@@ -1972,6 +1981,9 @@ ECORE_CHECK_MODULE([wayland], [${want_ecore_wayland}], [Wayland], [${ecore_wayla
 if test "x${have_ecore_wayland}" = "xyes" ; then
   requirements_ecore_wayland="ecore-input >= 1.7.8 wayland-client wayland-cursor xkbcommon ${requirements_ecore_wayland}"
 fi
+if test "x${want_ecore_wayland_xdg_shell}" = "xyes" ; then
+  AC_DEFINE(USE_XDG_SHELL, 1, [Ecore Wayland XDG-Shell Support])
+fi
 
 ECORE_EVAS_CHECK_MODULE_FULL([wayland-shm], [wayland-shm], 
    [${want_ecore_evas_wayland_shm}],
@@ -2225,6 +2237,7 @@ echo "  Ecore_DirectFB...............: $have_ecore_directfb"
 echo "  Ecore_WinCE..................: $have_ecore_wince"
 echo "  Ecore_PSL1GHT................: $have_ecore_psl1ght"
 echo "  Ecore_Wayland................: $have_ecore_wayland"
+echo "  Ecore_Wayland XDG-Shell......: $have_ecore_wayland_xdg_shell"
 
 echo
 echo " Ecore Evas:"
index 706c19a..1669794 100644 (file)
@@ -583,13 +583,24 @@ _ecore_evas_wl_show(Ecore_Evas *ee)
         ecore_wl_window_update_size(ee->engine.wl.win, ee->w, ee->h);
         ecore_wl_window_buffer_attach(ee->engine.wl.win, NULL, 0, 0);
 
-        if ((ee->prop.clas) && (ee->engine.wl.win->shell_surface))
-          wl_shell_surface_set_class(ee->engine.wl.win->shell_surface, 
-                                     ee->prop.clas);
-        if ((ee->prop.title) && (ee->engine.wl.win->shell_surface))
-          wl_shell_surface_set_title(ee->engine.wl.win->shell_surface, 
+        if (ee->engine.wl.win->xdg_surface)
+          {
+             if (ee->prop.clas)
+               xdg_surface_set_app_id(ee->engine.wl.win->xdg_surface,
+                                      ee->prop.clas);
+             if (ee->prop.title)
+               xdg_surface_set_title(ee->engine.wl.win->xdg_surface,
                                      ee->prop.title);
-
+          }
+        else if (ee->engine.wl.win->shell_surface)
+          {
+             if (ee->prop.clas)
+               wl_shell_surface_set_class(ee->engine.wl.win->shell_surface,
+                                          ee->prop.clas);
+             if (ee->prop.title)
+               wl_shell_surface_set_title(ee->engine.wl.win->shell_surface,
+                                          ee->prop.title);
+          }
      }
 
    if (ee->engine.wl.frame)
@@ -674,7 +685,10 @@ _ecore_evas_wl_title_set(Ecore_Evas *ee, const char *title)
 
      }
 
-   if ((ee->prop.title) && (ee->engine.wl.win->shell_surface))
+   if ((ee->prop.title) && (ee->engine.wl.win->xdg_surface))
+     xdg_surface_set_title(ee->engine.wl.win->xdg_surface,
+                           ee->prop.title);
+   else if ((ee->prop.title) && (ee->engine.wl.win->shell_surface))
      wl_shell_surface_set_title(ee->engine.wl.win->shell_surface, 
                                 ee->prop.title);
 }
@@ -692,7 +706,10 @@ _ecore_evas_wl_name_class_set(Ecore_Evas *ee, const char *n, const char *c)
    if (n) ee->prop.name = strdup(n);
    if (c) ee->prop.clas = strdup(c);
 
-   if ((ee->prop.clas) && (ee->engine.wl.win->shell_surface))
+   if ((ee->prop.clas) && (ee->engine.wl.win->xdg_surface))
+     xdg_surface_set_app_id(ee->engine.wl.win->xdg_surface,
+                            ee->prop.clas);
+   else if ((ee->prop.clas) && (ee->engine.wl.win->shell_surface))
      wl_shell_surface_set_class(ee->engine.wl.win->shell_surface, 
                                 ee->prop.clas);
 }
@@ -767,9 +784,9 @@ _ecore_evas_wl_iconified_set(Ecore_Evas *ee, int iconify)
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
    if (!ee) return;
-   if (ee->prop.iconified == iconify) return;
-   ee->prop.iconified = iconify;
-   /* FIXME: Implement this in Wayland someshow */
+   //if (ee->prop.iconified == iconify) return;
+   //ee->prop.iconified = iconify;
+   ecore_wl_window_iconified_set(ee->engine.wl.win);
 }
 
 static void 
index 3dfa4fe..f79be43 100644 (file)
@@ -669,12 +669,24 @@ _ecore_evas_wl_show(Ecore_Evas *ee)
         ecore_wl_window_buffer_attach(ee->engine.wl.win, 
                                       ee->engine.wl.buffer, 0, 0);
 
-        if ((ee->prop.clas) && (ee->engine.wl.win->shell_surface))
-          wl_shell_surface_set_class(ee->engine.wl.win->shell_surface, 
-                                     ee->prop.clas);
-        if ((ee->prop.title) && (ee->engine.wl.win->shell_surface))
-          wl_shell_surface_set_title(ee->engine.wl.win->shell_surface, 
+        if (ee->engine.wl.win->xdg_surface)
+          {
+             if (ee->prop.clas)
+               xdg_surface_set_app_id(ee->engine.wl.win->xdg_surface,
+                                      ee->prop.clas);
+             if (ee->prop.title)
+               xdg_surface_set_title(ee->engine.wl.win->xdg_surface,
                                      ee->prop.title);
+          }
+        else if (ee->engine.wl.win->shell_surface)
+          {
+             if (ee->prop.clas)
+               wl_shell_surface_set_class(ee->engine.wl.win->shell_surface,
+                                          ee->prop.clas);
+             if (ee->prop.title)
+               wl_shell_surface_set_title(ee->engine.wl.win->shell_surface,
+                                          ee->prop.title);
+          }
      }
 
    if (ee->engine.wl.frame)
@@ -745,8 +757,11 @@ _ecore_evas_wl_title_set(Ecore_Evas *ee, const char *title)
           evas_object_text_text_set(sd->text, ee->prop.title);
      }
 
-   if ((ee->prop.title) && (ee->engine.wl.win->shell_surface))
-     wl_shell_surface_set_title(ee->engine.wl.win->shell_surface, 
+   if ((ee->prop.title) && (ee->engine.wl.win->xdg_surface))
+     xdg_surface_set_title(ee->engine.wl.win->xdg_surface,
+                           ee->prop.title);
+   else if ((ee->prop.title) && (ee->engine.wl.win->shell_surface))
+     wl_shell_surface_set_title(ee->engine.wl.win->shell_surface,
                                 ee->prop.title);
 }
 
@@ -763,8 +778,11 @@ _ecore_evas_wl_name_class_set(Ecore_Evas *ee, const char *n, const char *c)
    if (n) ee->prop.name = strdup(n);
    if (c) ee->prop.clas = strdup(c);
 
-   if ((ee->prop.clas) && (ee->engine.wl.win->shell_surface))
-     wl_shell_surface_set_class(ee->engine.wl.win->shell_surface, 
+   if ((ee->prop.clas) && (ee->engine.wl.win->xdg_surface))
+     xdg_surface_set_app_id(ee->engine.wl.win->xdg_surface,
+                            ee->prop.clas);
+   else if ((ee->prop.clas) && (ee->engine.wl.win->shell_surface))
+     wl_shell_surface_set_class(ee->engine.wl.win->shell_surface,
                                 ee->prop.clas);
 }
 
@@ -838,9 +856,9 @@ _ecore_evas_wl_iconified_set(Ecore_Evas *ee, int iconify)
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
    if (!ee) return;
-   if (ee->prop.iconified == iconify) return;
-   ee->prop.iconified = iconify;
-   /* FIXME: Implement this in Wayland someshow */
+   //if (ee->prop.iconified == iconify) return;
+   //ee->prop.iconified = iconify;
+   ecore_wl_window_iconified_set(ee->engine.wl.win);
 }
 
 static void 
index 5b2ac46..4160473 100644 (file)
@@ -11,6 +11,7 @@
 # include <wayland-client.h>
 # include <wayland-cursor.h>
 # include <xkbcommon/xkbcommon.h>
+# include "xdg-shell-client-protocol.h"
 
 # ifdef EAPI
 #  undef EAPI
@@ -96,6 +97,7 @@ struct _Ecore_Wl_Display
         struct wl_subcompositor *subcompositor;
         struct wl_shell *shell;
         struct wl_shell *desktop_shell;
+        struct xdg_shell *xdg_shell;
         struct wl_shm *shm;
         struct wl_data_device_manager *data_device_manager;
      } wl;
@@ -195,6 +197,8 @@ struct _Ecore_Wl_Window
 
    struct wl_surface *surface;
    struct wl_shell_surface *shell_surface;
+   struct xdg_surface *xdg_surface;
+   struct xdg_popup *xdg_popup;
 
    struct 
      {
@@ -415,6 +419,7 @@ EAPI void ecore_wl_window_commit(Ecore_Wl_Window *win);
 EAPI void ecore_wl_window_show(Ecore_Wl_Window *win);
 EAPI void ecore_wl_window_hide(Ecore_Wl_Window *win);
 EAPI void ecore_wl_window_raise(Ecore_Wl_Window *win);
+EAPI void ecore_wl_window_iconified_set(Ecore_Wl_Window *win);
 EAPI void ecore_wl_window_maximized_set(Ecore_Wl_Window *win, Eina_Bool maximized);
 EAPI void ecore_wl_window_fullscreen_set(Ecore_Wl_Window *win, Eina_Bool fullscreen);
 EAPI void ecore_wl_window_transparent_set(Ecore_Wl_Window *win, Eina_Bool transparent);
index 81bd45b..56655e2 100644 (file)
@@ -10,7 +10,7 @@ AM_CPPFLAGS = \
 @EINA_CFLAGS@
 
 lib_LTLIBRARIES = libecore_wayland.la
-includes_HEADERS = Ecore_Wayland.h
+includes_HEADERS = Ecore_Wayland.h xdg-shell-client-protocol.h
 includesdir = $(includedir)/ecore-@VMAJ@
 
 libecore_wayland_la_SOURCES = \
@@ -21,7 +21,9 @@ ecore_wl_window.c \
 ecore_wl_dnd.c \
 ecore_wl_subsurf.c \
 subsurface-protocol.c \
-subsurface-client-protocol.h
+subsurface-client-protocol.h \
+xdg-shell-protocol.c \
+xdg-shell-client-protocol.h
 
 libecore_wayland_la_LIBADD = \
 $(top_builddir)/src/lib/ecore/libecore.la \
index 90d9afd..f82e049 100644 (file)
@@ -458,6 +458,8 @@ _ecore_wl_shutdown(Eina_Bool close)
 
         _ecore_wl_xkb_shutdown(_ecore_wl_disp);
 
+        if (_ecore_wl_disp->wl.xdg_shell)
+          xdg_shell_destroy(_ecore_wl_disp->wl.xdg_shell);
         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);
@@ -571,6 +573,14 @@ _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_XDG_SHELL
+   else if (!strcmp(interface, "xdg_shell"))
+     {
+        ewd->wl.xdg_shell =
+          wl_registry_bind(registry, id, &xdg_shell_interface, 1);
+        xdg_shell_use_unstable_version(ewd->wl.xdg_shell, XDG_SHELL_VERSION_CURRENT);
+     }
+#endif
    else if (!strcmp(interface, "wl_shell"))
      {
         ewd->wl.shell = 
index 2935ded..3d262f0 100644 (file)
@@ -31,9 +31,15 @@ void *alloca (size_t);
 #include "ecore_wl_private.h"
 
 /* local function prototypes */
-static void _ecore_wl_window_cb_ping(void *data __UNUSED__, struct wl_shell_surface *shell_surface, unsigned int serial);
-static void _ecore_wl_window_cb_configure(void *data, struct wl_shell_surface *shell_surface __UNUSED__, unsigned int edges, int w, int h);
-static void _ecore_wl_window_cb_popup_done(void *data, struct wl_shell_surface *shell_surface __UNUSED__);
+#ifdef USE_XDG_SHELL
+static void _ecore_wl_window_cb_xdg_surface_ping(void *data __UNUSED__, struct xdg_surface *xdg_surface, unsigned int serial);
+static void _ecore_wl_window_cb_xdg_surface_configure(void *data, struct xdg_surface *xdg_surface __UNUSED__, unsigned int edges, int w, int h);
+static void _ecore_wl_window_cb_xdg_popup_ping(void *data __UNUSED__, struct xdg_popup *xdg_popup, unsigned int serial);
+static void _ecore_wl_window_cb_xdg_popup_popup_done(void *data, struct xdg_popup *xdg_popup, unsigned int serial);
+#endif
+static void _ecore_wl_window_cb_shell_surface_ping(void *data __UNUSED__, struct wl_shell_surface *shell_surface, unsigned int serial);
+static void _ecore_wl_window_cb_shell_surface_configure(void *data, struct wl_shell_surface *shell_surface __UNUSED__, unsigned int edges, int w, int h);
+static void _ecore_wl_window_cb_shell_surface_popup_done(void *data, struct wl_shell_surface *shell_surface __UNUSED__);
 static void _ecore_wl_window_cb_surface_enter(void *data, struct wl_surface *surface, struct wl_output *output __UNUSED__);
 static void _ecore_wl_window_cb_surface_leave(void *data, struct wl_surface *surface, struct wl_output *output __UNUSED__);
 static void _ecore_wl_window_configure_send(Ecore_Wl_Window *win, int w, int h);
@@ -49,11 +55,31 @@ static const struct wl_surface_listener _ecore_wl_surface_listener =
    _ecore_wl_window_cb_surface_leave
 };
 
+#ifdef USE_XDG_SHELL
+static const struct xdg_popup_listener _ecore_xdg_popup_listener =
+{
+   _ecore_wl_window_cb_xdg_popup_ping,
+   _ecore_wl_window_cb_xdg_popup_popup_done
+};
+
+static const struct xdg_surface_listener _ecore_xdg_surface_listener =
+{
+   _ecore_wl_window_cb_xdg_surface_ping,
+   _ecore_wl_window_cb_xdg_surface_configure,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL
+};
+#endif
+
 static const struct wl_shell_surface_listener _ecore_wl_shell_surface_listener = 
 {
-   _ecore_wl_window_cb_ping,
-   _ecore_wl_window_cb_configure,
-   _ecore_wl_window_cb_popup_done
+   _ecore_wl_window_cb_shell_surface_ping,
+   _ecore_wl_window_cb_shell_surface_configure,
+   _ecore_wl_window_cb_shell_surface_popup_done
 };
 
 /* internal functions */
@@ -158,6 +184,10 @@ ecore_wl_window_free(Ecore_Wl_Window *win)
    win->region.input = NULL;
    if (win->region.opaque) wl_region_destroy(win->region.opaque);
    win->region.opaque = NULL;
+   if (win->xdg_surface) xdg_surface_destroy(win->xdg_surface);
+   win->xdg_surface = NULL;
+   if (win->xdg_popup) xdg_popup_destroy(win->xdg_popup);
+   win->xdg_popup = NULL;
    if (win->shell_surface) wl_shell_surface_destroy(win->shell_surface);
    win->shell_surface = NULL;
 
@@ -191,7 +221,7 @@ ecore_wl_window_move(Ecore_Wl_Window *win, int x, int y)
    win->allocation.x = x;
    win->allocation.y = y;
 
-   if (win->shell_surface)
+   if ((win->shell_surface) || (win->xdg_surface))
      {
         Ecore_Wl_Input *input;
 
@@ -207,8 +237,13 @@ ecore_wl_window_move(Ecore_Wl_Window *win, int x, int y)
         if ((!input) || (!input->seat)) return;
 
         _ecore_wl_input_grab_release(input, win);
-        wl_shell_surface_move(win->shell_surface, input->seat,
-                              input->display->serial);
+
+        if (win->xdg_surface)
+          xdg_surface_move(win->xdg_surface, input->seat,
+                           input->display->serial);
+        else if (win->shell_surface)
+          wl_shell_surface_move(win->shell_surface, input->seat,
+                                input->display->serial);
      }
 }
 
@@ -252,7 +287,7 @@ ecore_wl_window_resize(Ecore_Wl_Window *win, int w, int h, int location)
                       win->allocation.w, win->allocation.h);
      }
 
-   if (win->shell_surface)
+   if ((win->shell_surface) || (win->xdg_surface))
      {
         Ecore_Wl_Input *input;
 
@@ -268,8 +303,13 @@ ecore_wl_window_resize(Ecore_Wl_Window *win, int w, int h, int location)
         if ((!input) || (!input->seat)) return;
 
         _ecore_wl_input_grab_release(input, win);
-        wl_shell_surface_resize(win->shell_surface, input->seat, 
-                                input->display->serial, location);
+
+        if (win->xdg_surface)
+          xdg_surface_resize(win->xdg_surface, input->seat,
+                             input->display->serial, location);
+        else if (win->shell_surface)
+          wl_shell_surface_resize(win->shell_surface, input->seat, 
+                                  input->display->serial, location);
      }
 }
 
@@ -386,36 +426,74 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
 
    if (win->type != ECORE_WL_WINDOW_TYPE_NONE)
      {
-        win->shell_surface =
-           wl_shell_get_shell_surface(_ecore_wl_disp->wl.shell, win->surface);
-           wl_shell_surface_add_listener(win->shell_surface,
-                                         &_ecore_wl_shell_surface_listener, win);
+#ifdef USE_XDG_SHELL
+        if (_ecore_wl_disp->wl.xdg_shell)
+          {
+            win->xdg_surface =
+               xdg_shell_get_xdg_surface(_ecore_wl_disp->wl.xdg_shell, win->surface);
+               xdg_surface_add_listener(win->xdg_surface,
+                                        &_ecore_xdg_surface_listener, win);
+          }
+        else if (_ecore_wl_disp->wl.shell)
+          {
+#endif
+            win->shell_surface =
+               wl_shell_get_shell_surface(_ecore_wl_disp->wl.shell, win->surface);
+               wl_shell_surface_add_listener(win->shell_surface,
+                                             &_ecore_wl_shell_surface_listener, win);
+#ifdef USE_XDG_SHELL
+          }
+#endif
      }
 
    switch (win->type)
      {
       case ECORE_WL_WINDOW_TYPE_FULLSCREEN:
-        wl_shell_surface_set_fullscreen(win->shell_surface, 
-                                        WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
-                                        0, NULL);
+        if (win->xdg_surface)
+          xdg_surface_set_fullscreen(win->xdg_surface);
+        else if (win->shell_surface)
+          wl_shell_surface_set_fullscreen(win->shell_surface,
+                                          WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
+                                          0, NULL);
         break;
       case ECORE_WL_WINDOW_TYPE_MAXIMIZED:
-        wl_shell_surface_set_maximized(win->shell_surface, NULL);
+        if (win->xdg_surface)
+          xdg_surface_set_maximized(win->xdg_surface);
+        else if (win->shell_surface)
+          wl_shell_surface_set_maximized(win->shell_surface, NULL);
         break;
       case ECORE_WL_WINDOW_TYPE_TRANSIENT:
-        wl_shell_surface_set_transient(win->shell_surface, 
-                                       win->parent->surface, 
-                                       win->allocation.x, win->allocation.y, 0);
+        if (win->xdg_surface)
+          xdg_surface_set_transient_for(win->xdg_surface,
+                                        win->parent->surface);
+        else if (win->shell_surface)
+          wl_shell_surface_set_transient(win->shell_surface,
+                                         win->parent->surface,
+                                         win->allocation.x, win->allocation.y, 0);
         break;
       case ECORE_WL_WINDOW_TYPE_MENU:
-        wl_shell_surface_set_popup(win->shell_surface, 
-                                   _ecore_wl_disp->input->seat,
-                                   _ecore_wl_disp->serial,
-                                   win->parent->surface, 
-                                   win->allocation.x, win->allocation.y, 0);
+#ifdef USE_XDG_SHELL
+        if (win->xdg_surface)
+          {
+            win->xdg_popup = xdg_shell_get_xdg_popup(_ecore_wl_disp->wl.xdg_shell,
+                                                     win->surface,
+                                                     win->parent->surface,
+                                                     _ecore_wl_disp->input->seat,
+                                                     _ecore_wl_disp->serial,
+                                                     win->allocation.x, win->allocation.y, 0);
+            xdg_popup_add_listener(win->xdg_popup, &_ecore_xdg_popup_listener, win);
+          }
+        else if (win->shell_surface)
+#endif
+          wl_shell_surface_set_popup(win->shell_surface,
+                                     _ecore_wl_disp->input->seat,
+                                     _ecore_wl_disp->serial,
+                                     win->parent->surface,
+                                     win->allocation.x, win->allocation.y, 0);
         break;
       case ECORE_WL_WINDOW_TYPE_TOPLEVEL:
-        wl_shell_surface_set_toplevel(win->shell_surface);
+        if (win->shell_surface)
+          wl_shell_surface_set_toplevel(win->shell_surface);
         break;
       default:
         break;
@@ -454,6 +532,8 @@ ecore_wl_window_hide(Ecore_Wl_Window *win)
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
    if (!win) return;
+   if (win->xdg_surface) xdg_surface_destroy(win->xdg_surface);
+   win->xdg_surface = NULL;
    if (win->shell_surface) wl_shell_surface_destroy(win->shell_surface);
    win->shell_surface = NULL;
    if (win->surface) wl_surface_destroy(win->surface);
@@ -488,22 +568,41 @@ ecore_wl_window_maximized_set(Ecore_Wl_Window *win, Eina_Bool maximized)
    if ((win->type == ECORE_WL_WINDOW_TYPE_MAXIMIZED) == maximized) return;
    if (win->type == ECORE_WL_WINDOW_TYPE_TOPLEVEL)
      {
-        win->saved_allocation = win->allocation;
-        if (win->shell_surface) 
-          wl_shell_surface_set_maximized(win->shell_surface, NULL);
+        if (win->xdg_surface)
+          xdg_surface_set_maximized(win->xdg_surface);
+        if (win->shell_surface)
+          {
+            win->saved_allocation = win->allocation;
+            wl_shell_surface_set_maximized(win->shell_surface, NULL);
+          }
         win->type = ECORE_WL_WINDOW_TYPE_MAXIMIZED;
      }
    else if (win->type == ECORE_WL_WINDOW_TYPE_MAXIMIZED)
      {
-        if (win->shell_surface) 
-          wl_shell_surface_set_toplevel(win->shell_surface);
+        if (win->xdg_surface)
+          xdg_surface_unset_maximized(win->xdg_surface);
+        if (win->shell_surface)
+          {
+            wl_shell_surface_set_toplevel(win->shell_surface);
+            _ecore_wl_window_configure_send(win, win->saved_allocation.w,
+                                           win->saved_allocation.h);
+          }
         win->type = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
-        _ecore_wl_window_configure_send(win, win->saved_allocation.w, 
-                                        win->saved_allocation.h);
      }
    win->edges = 0;
 }
 
+EAPI void
+ecore_wl_window_iconified_set(Ecore_Wl_Window *win)
+{
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   if (!win) return;
+   if (!win->xdg_surface) return;
+
+   xdg_surface_set_minimized(win->xdg_surface);
+}
+
 EAPI void 
 ecore_wl_window_fullscreen_set(Ecore_Wl_Window *win, Eina_Bool fullscreen)
 {
@@ -513,20 +612,28 @@ ecore_wl_window_fullscreen_set(Ecore_Wl_Window *win, Eina_Bool fullscreen)
    if ((win->type == ECORE_WL_WINDOW_TYPE_FULLSCREEN) == fullscreen) return;
    if (fullscreen)
      {
-        win->type = ECORE_WL_WINDOW_TYPE_FULLSCREEN;
-        win->saved_allocation = win->allocation;
+        if (win->xdg_surface)
+         xdg_surface_set_fullscreen(win->xdg_surface);
         if (win->shell_surface)
-          wl_shell_surface_set_fullscreen(win->shell_surface, 
-                                          WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
-                                          0, NULL);
+          {
+            win->saved_allocation = win->allocation;
+            wl_shell_surface_set_fullscreen(win->shell_surface, 
+                                            WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
+                                            0, NULL);
+          }
+        win->type = ECORE_WL_WINDOW_TYPE_FULLSCREEN;
      }
    else 
      {
+        if (win->xdg_surface)
+          xdg_surface_unset_fullscreen(win->xdg_surface);
         if (win->shell_surface)
-          wl_shell_surface_set_toplevel(win->shell_surface);
+          {
+            wl_shell_surface_set_toplevel(win->shell_surface);
+            _ecore_wl_window_configure_send(win, win->saved_allocation.w, 
+                                           win->saved_allocation.h);
+          }
         win->type = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
-        _ecore_wl_window_configure_send(win, win->saved_allocation.w, 
-                                        win->saved_allocation.h);
      }
    win->edges = 0;
 }
@@ -607,6 +714,15 @@ ecore_wl_window_shell_surface_get(Ecore_Wl_Window *win)
    return win->shell_surface;
 }
 
+EAPI struct xdg_surface *
+ecore_wl_window_xdg_surface_get(Ecore_Wl_Window *win)
+{
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   if (!win) return NULL;
+   return win->xdg_surface;
+}
+
 EAPI Ecore_Wl_Window *
 ecore_wl_window_find(unsigned int id)
 {
@@ -675,14 +791,35 @@ ecore_wl_window_parent_set(Ecore_Wl_Window *win, Ecore_Wl_Window *parent)
 
 /* local functions */
 static void 
-_ecore_wl_window_cb_ping(void *data __UNUSED__, struct wl_shell_surface *shell_surface, unsigned int serial)
+_ecore_wl_window_cb_xdg_popup_ping(void *data, struct xdg_popup *xdg_popup, unsigned int serial)
 {
-   if (!shell_surface) return;
-   wl_shell_surface_pong(shell_surface, serial);
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   if (!xdg_popup) return;
+   xdg_popup_pong (xdg_popup, serial);
 }
 
 static void 
-_ecore_wl_window_cb_configure(void *data, struct wl_shell_surface *shell_surface __UNUSED__, unsigned int edges, int w, int h)
+_ecore_wl_window_cb_xdg_popup_popup_done(void *data, struct xdg_popup *xdg_popup, unsigned int serial)
+{
+   Ecore_Wl_Window *win;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   if (!xdg_popup) return;
+   if (!(win = data)) return;
+   ecore_wl_input_ungrab(win->pointer_device);
+}
+
+static void
+_ecore_wl_window_cb_xdg_surface_ping(void *data __UNUSED__, struct xdg_surface *xdg_surface, unsigned int serial)
+{
+   if (!xdg_surface) return;
+   xdg_surface_pong(xdg_surface, serial);
+}
+
+static void
+_ecore_wl_window_cb_xdg_surface_configure(void *data, struct xdg_surface *xdg_surface __UNUSED__, unsigned int edges, int w, int h)
 {
    Ecore_Wl_Window *win;
 
@@ -706,7 +843,38 @@ _ecore_wl_window_cb_configure(void *data, struct wl_shell_surface *shell_surface
 }
 
 static void 
-_ecore_wl_window_cb_popup_done(void *data, struct wl_shell_surface *shell_surface __UNUSED__)
+_ecore_wl_window_cb_shell_surface_ping(void *data __UNUSED__, struct wl_shell_surface *shell_surface, unsigned int serial)
+{
+   if (!shell_surface) return;
+   wl_shell_surface_pong(shell_surface, serial);
+}
+
+static void
+_ecore_wl_window_cb_shell_surface_configure(void *data, struct wl_shell_surface *shell_surface __UNUSED__, unsigned int edges, int w, int h)
+{
+   Ecore_Wl_Window *win;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   if (!(win = data)) return;
+
+   if ((w <= 0) || (h <= 0)) return;
+
+   if ((win->allocation.w != w) || (win->allocation.h != h))
+     {
+        if (win->type == ECORE_WL_WINDOW_TYPE_TOPLEVEL)
+          win->edges = edges;
+        if (win->region.input) wl_region_destroy(win->region.input);
+        win->region.input = NULL;
+        if (win->region.opaque) wl_region_destroy(win->region.opaque);
+        win->region.opaque = NULL;
+
+        _ecore_wl_window_configure_send(win, w, h);
+     }
+}
+
+static void
+_ecore_wl_window_cb_shell_surface_popup_done(void *data, struct wl_shell_surface *shell_surface __UNUSED__)
 {
    Ecore_Wl_Window *win;
 
diff --git a/src/lib/ecore_wayland/xdg-shell-client-protocol.h b/src/lib/ecore_wayland/xdg-shell-client-protocol.h
new file mode 100644 (file)
index 0000000..353d38a
--- /dev/null
@@ -0,0 +1,512 @@
+/* 
+ * 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
+ *
+ * Use this enum to check the protocol version, and it will be updated
+ * automatically.
+ */
+enum xdg_shell_version {
+       XDG_SHELL_VERSION_CURRENT = 1,
+};
+#endif /* XDG_SHELL_VERSION_ENUM */
+
+#define XDG_SHELL_USE_UNSTABLE_VERSION 0
+#define XDG_SHELL_GET_XDG_SURFACE      1
+#define XDG_SHELL_GET_XDG_POPUP        2
+
+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;
+}
+
+#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 */
+
+/**
+ * xdg_surface - desktop-style metadata interface
+ * @ping: ping client
+ * @configure: suggest resize
+ * @request_set_fullscreen: server requests that the client set
+ *     fullscreen
+ * @request_unset_fullscreen: server requests that the client unset
+ *     fullscreen
+ * @request_set_maximized: server requests that the client set maximized
+ * @request_unset_maximized: server requests that the client unset
+ *     maximized
+ * @request_set_minimized: server requests that the client set minimized
+ * @request_unset_minimized: server requests that the client unset
+ *     maximized
+ * @focused_set: surface was focused
+ * @focused_unset: surface was unfocused
+ *
+ * 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 {
+       /**
+        * ping - ping client
+        * @serial: (none)
+        *
+        * Ping a client to check if it is receiving events and sending
+        * requests. A client is expected to reply with a pong request.
+        */
+       void (*ping)(void *data,
+                    struct xdg_surface *xdg_surface,
+                    uint32_t serial);
+       /**
+        * configure - suggest resize
+        * @edges: (none)
+        * @width: (none)
+        * @height: (none)
+        *
+        * The configure event asks the client to resize its surface.
+        *
+        * The size is a hint, in the sense that the client is free to
+        * ignore it if it doesn't resize, pick a smaller size (to satisfy
+        * aspect ratio or resize in steps of NxM pixels).
+        *
+        * The edges parameter provides a hint about how the surface was
+        * resized. The client may use this information to decide how to
+        * adjust its content to the new size (e.g. a scrolling area might
+        * adjust its content position to leave the viewable content
+        * unmoved). Valid edge values are from resize_edge enum.
+        *
+        * The client is free to dismiss all but the last configure event
+        * it received.
+        *
+        * The width and height arguments specify the size of the window in
+        * surface local coordinates.
+        */
+       void (*configure)(void *data,
+                         struct xdg_surface *xdg_surface,
+                         uint32_t edges,
+                         int32_t width,
+                         int32_t height);
+       /**
+        * request_set_fullscreen - server requests that the client set
+        *      fullscreen
+        *
+        * Event sent from the compositor to the client requesting that
+        * the client goes to a fullscreen state. It's the client job to
+        * call set_fullscreen and really trigger the fullscreen state.
+        */
+       void (*request_set_fullscreen)(void *data,
+                                      struct xdg_surface *xdg_surface);
+       /**
+        * request_unset_fullscreen - server requests that the client
+        *      unset fullscreen
+        *
+        * Event sent from the compositor to the client requesting that
+        * the client leaves the fullscreen state. It's the client job to
+        * call unset_fullscreen and really leave the fullscreen state.
+        */
+       void (*request_unset_fullscreen)(void *data,
+                                        struct xdg_surface *xdg_surface);
+       /**
+        * request_set_maximized - server requests that the client set
+        *      maximized
+        *
+        * Event sent from the compositor to the client requesting that
+        * the client goes to a maximized state. It's the client job to
+        * call set_maximized and really trigger the maximized state.
+        */
+       void (*request_set_maximized)(void *data,
+                                     struct xdg_surface *xdg_surface);
+       /**
+        * request_unset_maximized - server requests that the client
+        *      unset maximized
+        *
+        * Event sent from the compositor to the client requesting that
+        * the client leaves the maximized state. It's the client job to
+        * call unset_maximized and really leave the maximized state.
+        */
+       void (*request_unset_maximized)(void *data,
+                                       struct xdg_surface *xdg_surface);
+       /**
+        * request_set_minimized - server requests that the client set
+        *      minimized
+        *
+        * Event sent from the compositor to the client requesting that
+        * the client goes to a minimized state. It's the client job to
+        * call set_minimized and trigger its minimized state.
+        */
+       void (*request_set_minimized)(void *data,
+                                     struct xdg_surface *xdg_surface);
+       /**
+        * request_unset_minimized - server requests that the client
+        *      unset maximized
+        *
+        * Event sent from the compositor to the client requesting that
+        * the client leaves the minimized state. It's the client job to
+        * call unset_maximized and leave its minimized state.
+        */
+       void (*request_unset_minimized)(void *data,
+                                       struct xdg_surface *xdg_surface);
+       /**
+        * focused_set - surface was focused
+        *
+        * The focused_set event is sent when this surface has been
+        * activated. Window decorations should be updated accordingly.
+        */
+       void (*focused_set)(void *data,
+                           struct xdg_surface *xdg_surface);
+       /**
+        * focused_unset - surface was unfocused
+        *
+        * The focused_unset event is sent when this surface has been
+        * deactivated, because another surface has been activated. Window
+        * decorations should be updated accordingly.
+        */
+       void (*focused_unset)(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_TRANSIENT_FOR  1
+#define XDG_SURFACE_SET_TITLE  2
+#define XDG_SURFACE_SET_APP_ID 3
+#define XDG_SURFACE_PONG       4
+#define XDG_SURFACE_MOVE       5
+#define XDG_SURFACE_RESIZE     6
+#define XDG_SURFACE_SET_OUTPUT 7
+#define XDG_SURFACE_SET_FULLSCREEN     8
+#define XDG_SURFACE_UNSET_FULLSCREEN   9
+#define XDG_SURFACE_SET_MAXIMIZED      10
+#define XDG_SURFACE_UNSET_MAXIMIZED    11
+#define XDG_SURFACE_SET_MINIMIZED      12
+
+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_transient_for(struct xdg_surface *xdg_surface, struct wl_surface *parent)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_TRANSIENT_FOR, 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_pong(struct xdg_surface *xdg_surface, uint32_t serial)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_PONG, serial);
+}
+
+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_set_output(struct xdg_surface *xdg_surface, struct wl_output *output)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_OUTPUT, output);
+}
+
+static inline void
+xdg_surface_set_fullscreen(struct xdg_surface *xdg_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_FULLSCREEN);
+}
+
+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_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_minimized(struct xdg_surface *xdg_surface)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+                        XDG_SURFACE_SET_MINIMIZED);
+}
+
+/**
+ * xdg_popup - desktop-style metadata interface
+ * @ping: ping client
+ * @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 {
+       /**
+        * ping - ping client
+        * @serial: (none)
+        *
+        * Ping a client to check if it is receiving events and sending
+        * requests. A client is expected to reply with a pong request.
+        */
+       void (*ping)(void *data,
+                    struct xdg_popup *xdg_popup,
+                    uint32_t serial);
+       /**
+        * 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
+#define XDG_POPUP_PONG 1
+
+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);
+}
+
+static inline void
+xdg_popup_pong(struct xdg_popup *xdg_popup, uint32_t serial)
+{
+       wl_proxy_marshal((struct wl_proxy *) xdg_popup,
+                        XDG_POPUP_PONG, serial);
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/ecore_wayland/xdg-shell-protocol.c b/src/lib/ecore_wayland/xdg-shell-protocol.c
new file mode 100644 (file)
index 0000000..ef72997
--- /dev/null
@@ -0,0 +1,129 @@
+/* 
+ * 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 xdg_surface_interface;
+extern const struct wl_interface wl_surface_interface;
+extern const struct wl_interface xdg_popup_interface;
+extern const struct wl_interface wl_surface_interface;
+extern const struct wl_interface wl_surface_interface;
+extern const struct wl_interface wl_seat_interface;
+extern const struct wl_interface wl_surface_interface;
+extern const struct wl_interface wl_seat_interface;
+extern const struct wl_interface wl_seat_interface;
+extern const struct wl_interface wl_output_interface;
+
+static const struct wl_interface *types[] = {
+       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,
+       &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 + 3 },
+       { "get_xdg_popup", "nooouiiu", types + 5 },
+};
+
+WL_EXPORT const struct wl_interface xdg_shell_interface = {
+       "xdg_shell", 1,
+       3, xdg_shell_requests,
+       0, NULL,
+};
+
+static const struct wl_message xdg_surface_requests[] = {
+       { "destroy", "", types + 0 },
+       { "set_transient_for", "?o", types + 13 },
+       { "set_title", "s", types + 0 },
+       { "set_app_id", "s", types + 0 },
+       { "pong", "u", types + 0 },
+       { "move", "ou", types + 14 },
+       { "resize", "ouu", types + 16 },
+       { "set_output", "?o", types + 19 },
+       { "set_fullscreen", "", types + 0 },
+       { "unset_fullscreen", "", types + 0 },
+       { "set_maximized", "", types + 0 },
+       { "unset_maximized", "", types + 0 },
+       { "set_minimized", "", types + 0 },
+};
+
+static const struct wl_message xdg_surface_events[] = {
+       { "ping", "u", types + 0 },
+       { "configure", "uii", types + 0 },
+       { "request_set_fullscreen", "", types + 0 },
+       { "request_unset_fullscreen", "", types + 0 },
+       { "request_set_maximized", "", types + 0 },
+       { "request_unset_maximized", "", types + 0 },
+       { "request_set_minimized", "", types + 0 },
+       { "request_unset_minimized", "", types + 0 },
+       { "focused_set", "", types + 0 },
+       { "focused_unset", "", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_surface_interface = {
+       "xdg_surface", 1,
+       13, xdg_surface_requests,
+       10, xdg_surface_events,
+};
+
+static const struct wl_message xdg_popup_requests[] = {
+       { "destroy", "", types + 0 },
+       { "pong", "u", types + 0 },
+};
+
+static const struct wl_message xdg_popup_events[] = {
+       { "ping", "u", types + 0 },
+       { "popup_done", "u", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface xdg_popup_interface = {
+       "xdg_popup", 1,
+       2, xdg_popup_requests,
+       2, xdg_popup_events,
+};
+