From 594ce5bff5595d6191290186f9ca406004fb1f89 Mon Sep 17 00:00:00 2001
From: Rob Bradford <rob@linux.intel.com>
Date: Fri, 15 Jun 2012 18:04:13 +0100
Subject: [PATCH 1/2] Ecore_Wayland: Port to updated Wayland API

The cursor on the pointer is now a Wayland surface rather than a buffer.
---
 ChangeLog                               |    5 +++++
 src/lib/ecore_wayland/Ecore_Wayland.h   |    7 +++++--
 src/lib/ecore_wayland/ecore_wl_input.c  |   25 +++++++++++++++++++------
 src/lib/ecore_wayland/ecore_wl_window.c |    4 ++--
 4 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d3706d9..a66db8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -748,3 +748,8 @@
 
         * Fixed bug in ecore-file monitoring with inotify where watching a file
           that was deleted broke the world.
+
+2012-06-15 Rob Bradford
+
+	* Ecore_Wayland: Port to latest Wayland protocol. The cursor for a
+	pointer is now a surface rather than a buffer.
diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h b/src/lib/ecore_wayland/Ecore_Wayland.h
index 25f8158..6111704 100644
--- a/src/lib/ecore_wayland/Ecore_Wayland.h
+++ b/src/lib/ecore_wayland/Ecore_Wayland.h
@@ -121,6 +121,9 @@ struct _Ecore_Wl_Input
    struct wl_keyboard *keyboard;
    struct wl_touch *touch;
 
+
+   struct wl_surface *cursor_surface;
+
    struct wl_data_device *data_device;
 
    Ecore_Wl_Window *pointer_focus;
@@ -313,7 +316,7 @@ EAPI struct wl_cursor *ecore_wl_cursor_get(const char *cursor_name);
 
 EAPI void ecore_wl_input_grab(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int button);
 EAPI void ecore_wl_input_ungrab(Ecore_Wl_Input *input);
-EAPI void ecore_wl_input_pointer_set(Ecore_Wl_Input *input, struct wl_buffer *buffer, int hot_x, int hot_y);
+EAPI void ecore_wl_input_pointer_set(Ecore_Wl_Input *input, struct wl_surface *surface, int hot_x, int hot_y);
 EAPI void ecore_wl_input_cursor_from_name_set(Ecore_Wl_Input *input, const char *cursor_name);
 EAPI void ecore_wl_input_cursor_default_restore(Ecore_Wl_Input *input);
 
@@ -337,7 +340,7 @@ EAPI struct wl_surface *ecore_wl_window_surface_get(Ecore_Wl_Window *win);
 EAPI struct wl_shell_surface *ecore_wl_window_shell_surface_get(Ecore_Wl_Window *win);
 EAPI Ecore_Wl_Window *ecore_wl_window_find(unsigned int id);
 EAPI void ecore_wl_window_type_set(Ecore_Wl_Window *win, Ecore_Wl_Window_Type type);
-EAPI void ecore_wl_window_pointer_set(Ecore_Wl_Window *win, struct wl_buffer *buffer, int hot_x, int hot_y);
+EAPI void ecore_wl_window_pointer_set(Ecore_Wl_Window *win, struct wl_surface *surface, int hot_x, int hot_y);
 EAPI void ecore_wl_window_cursor_from_name_set(Ecore_Wl_Window *win, const char *cursor_name);
 EAPI void ecore_wl_window_cursor_default_restore(Ecore_Wl_Window *win);
 EAPI void ecore_wl_window_parent_set(Ecore_Wl_Window *win, Ecore_Wl_Window *parent);
diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c
index 19e39b2..acc7e09 100644
--- a/src/lib/ecore_wayland/ecore_wl_input.c
+++ b/src/lib/ecore_wayland/ecore_wl_input.c
@@ -142,13 +142,13 @@ ecore_wl_input_ungrab(Ecore_Wl_Input *input)
 }
 
 EAPI void
-ecore_wl_input_pointer_set(Ecore_Wl_Input *input, struct wl_buffer *buffer, int hot_x, int hot_y)
+ecore_wl_input_pointer_set(Ecore_Wl_Input *input, struct wl_surface *surface, int hot_x, int hot_y)
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
    if (input)
-     wl_pointer_attach(input->pointer, input->pointer_enter_serial, 
-                       buffer, hot_x, hot_y);
+     wl_pointer_set_cursor(input->pointer, input->pointer_enter_serial, 
+                           surface, hot_x, hot_y);
 }
 
 EAPI void
@@ -177,9 +177,14 @@ ecore_wl_input_cursor_from_name_set(Ecore_Wl_Input *input, const char *cursor_na
 
    cursor_image = cursor->images[0];
    if ((buffer = wl_cursor_image_get_buffer(cursor_image)))
-     ecore_wl_input_pointer_set(input, buffer,
-                                cursor_image->hotspot_x,
-                                cursor_image->hotspot_y);
+     {
+        ecore_wl_input_pointer_set(input, input->cursor_surface,
+                                   cursor_image->hotspot_x,
+                                   cursor_image->hotspot_y);
+        wl_surface_attach(input->cursor_surface, buffer, 0, 0);
+        wl_surface_damage(input->cursor_surface, 0, 0,
+                          cursor_image->width, cursor_image->height);
+     }
 }
 
 EAPI void
@@ -220,6 +225,10 @@ _ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id)
                                             input->seat);
    wl_data_device_add_listener(input->data_device, 
                                &_ecore_wl_data_listener, input);
+
+   input->cursor_surface =
+     wl_compositor_create_surface(_ecore_wl_disp->wl.compositor);
+
    ewd->input = input;
 }
 
@@ -242,6 +251,10 @@ _ecore_wl_input_del(Ecore_Wl_Input *input)
      xkb_state_unref(input->xkb.state);
    if (input->xkb.keymap)
      xkb_map_unref(input->xkb.keymap);
+
+   if (input->cursor_surface)
+     wl_surface_destroy(input->cursor_surface);
+
    free(input);
 }
 
diff --git a/src/lib/ecore_wayland/ecore_wl_window.c b/src/lib/ecore_wayland/ecore_wl_window.c
index 7a97d06..d834919 100644
--- a/src/lib/ecore_wayland/ecore_wl_window.c
+++ b/src/lib/ecore_wayland/ecore_wl_window.c
@@ -541,7 +541,7 @@ ecore_wl_window_type_set(Ecore_Wl_Window *win, Ecore_Wl_Window_Type type)
 }
 
 EAPI void 
-ecore_wl_window_pointer_set(Ecore_Wl_Window *win, struct wl_buffer *buffer, int hot_x, int hot_y)
+ecore_wl_window_pointer_set(Ecore_Wl_Window *win, struct wl_surface *surface, int hot_x, int hot_y)
 {
    Ecore_Wl_Input *input;
 
@@ -550,7 +550,7 @@ ecore_wl_window_pointer_set(Ecore_Wl_Window *win, struct wl_buffer *buffer, int
    if (!win) return;
 
    if ((input = win->pointer_device))
-     ecore_wl_input_pointer_set(input, buffer, hot_x, hot_y);
+     ecore_wl_input_pointer_set(input, surface, hot_x, hot_y);
 }
 
 EAPI void
-- 
1.7.10.2

