[PATCH 2/2] Add new XWayland API.

Axel Davy axel.davy at ens.fr
Thu Oct 17 00:16:59 CEST 2013


The new API:
.Allows to use the frame event.
.Introduces a new object: xwl_buffer, that allow to manipulate
the buffer sent to the Wayland compositor.
.Allows to use the release event.

Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 hw/xfree86/xwayland/Makefile.am        |   2 +
 hw/xfree86/xwayland/xwayland-buffers.c | 114 +++++++++++++++++
 hw/xfree86/xwayland/xwayland-drm.c     |  10 +-
 hw/xfree86/xwayland/xwayland-events.c  | 222 +++++++++++++++++++++++++++++++++
 hw/xfree86/xwayland/xwayland-private.h |  20 ++-
 hw/xfree86/xwayland/xwayland-window.c  |  21 ++--
 hw/xfree86/xwayland/xwayland.c         |  23 +++-
 hw/xfree86/xwayland/xwayland.h         |  68 ++++++++++
 8 files changed, 465 insertions(+), 15 deletions(-)
 create mode 100644 hw/xfree86/xwayland/xwayland-buffers.c
 create mode 100644 hw/xfree86/xwayland/xwayland-events.c

diff --git a/hw/xfree86/xwayland/Makefile.am b/hw/xfree86/xwayland/Makefile.am
index 22ab154..43209f4 100644
--- a/hw/xfree86/xwayland/Makefile.am
+++ b/hw/xfree86/xwayland/Makefile.am
@@ -21,6 +21,8 @@ libxwayland_la_SOURCES =			\
 	xwayland-output.c			\
 	xwayland-cursor.c			\
 	xwayland-window.c			\
+	xwayland-buffers.c			\
+	xwayland-events.c			\
 	xwayland-private.h			\
 	drm-client-protocol.h			\
 	drm-protocol.c				\
diff --git a/hw/xfree86/xwayland/xwayland-buffers.c b/hw/xfree86/xwayland/xwayland-buffers.c
new file mode 100644
index 0000000..94361b5
--- /dev/null
+++ b/hw/xfree86/xwayland/xwayland-buffers.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright © 2013 Axel Davy
+ *
+ * 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.
+ */ 
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include "xorg-config.h"
+#endif
+
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <xf86drm.h>
+#include <wayland-util.h>
+#include <wayland-client.h>
+#include <drm-client-protocol.h>
+
+#include <xf86Xinput.h>
+#include <xf86Crtc.h>
+#include <xf86str.h>
+#include <windowstr.h>
+#include <input.h>
+#include <inputstr.h>
+#include <exevents.h>
+
+#include "xwayland.h"
+#include "xwayland-private.h"
+
+
+/*
+ * Buffer Management API
+ * Exchange buffers,
+ * Create Buffers if needed,
+ * Deleted Buffers
+ * 
+ */
+
+
+
+Bool xwl_is_released_buffer(struct xwl_buffer* xwl_buffer)
+{
+  return !xwl_buffer->busy; 
+}
+
+struct xwl_buffer* xwl_get_xwl_buffer_from_visible_window(WindowPtr window)
+{
+  struct xwl_window* xwl_window = get_xwl_window(window);
+  if (!xwl_window) /* Is not in our 'visible' list */
+    return NULL;
+  return xwl_window->buffer;
+}
+
+struct xwl_buffer* 
+xwl_exchange_xwl_buffer_from_visible_window(WindowPtr window,
+					    struct xwl_buffer* new_xwl_buffer)
+{
+  struct xwl_window* xwl_window = get_xwl_window(window);
+  struct xwl_buffer* temp;
+  if (!xwl_window || !new_xwl_buffer) /* Is not in our 'visible' list */
+    return new_xwl_buffer;
+  temp = xwl_window->buffer;
+  xwl_window->buffer = new_xwl_buffer;
+  return temp;
+}
+
+struct xwl_buffer* 
+xwl_create_new_xwl_buffer_from_pixmap(struct xwl_screen* xwl_screen,
+				      WindowPtr window,
+				      PixmapPtr pixmap)
+{
+  struct xwl_window *xwl_window = calloc(sizeof *xwl_window, 1);
+  struct xwl_buffer *xwl_buffer = NULL;
+  if(!xwl_window)
+    return NULL;
+  xwl_window->xwl_screen = xwl_screen;
+  xwl_window->window = window;
+  xwl_window->buffer = calloc(sizeof (struct xwl_buffer), 1);
+  if(!xwl_window->buffer)
+    goto quit;
+  xwl_screen->driver->create_window_buffer(xwl_window, pixmap);
+  if(xwl_window->buffer->buffer)
+    xwl_buffer = xwl_window->buffer;
+  else
+    free(xwl_window->buffer);
+quit:
+  free(xwl_window);
+  return xwl_buffer;
+}
+
+void xwl_delete_xwl_buffer(struct xwl_buffer* xwl_buffer)
+{
+  destroy_xwl_buffer_complete(xwl_buffer);
+}
\ No newline at end of file
diff --git a/hw/xfree86/xwayland/xwayland-drm.c b/hw/xfree86/xwayland/xwayland-drm.c
index 428711b..b47f6ae 100644
--- a/hw/xfree86/xwayland/xwayland-drm.c
+++ b/hw/xfree86/xwayland/xwayland-drm.c
@@ -238,14 +238,18 @@ xwl_create_window_buffer_drm(struct xwl_window *xwl_window,
         break;
     }
 
-    xwl_window->buffer =
+    xwl_window->buffer->buffer =
       wl_drm_create_buffer(xwl_window->xwl_screen->drm,
 			   name,
 			   pixmap->drawable.width,
 			   pixmap->drawable.height,
 			   pixmap->devKind,
 			   format);
-
-    return xwl_window->buffer ? Success : BadDrawable;
+    if(xwl_window->buffer->buffer)
+    {
+      xwl_window->buffer->busy = FALSE;
+      xwl_buffer_add_listener(xwl_window->buffer);
+    }
+    return xwl_window->buffer->buffer ? Success : BadDrawable;
 }
 
diff --git a/hw/xfree86/xwayland/xwayland-events.c b/hw/xfree86/xwayland/xwayland-events.c
new file mode 100644
index 0000000..be16569
--- /dev/null
+++ b/hw/xfree86/xwayland/xwayland-events.c
@@ -0,0 +1,222 @@
+/*
+ * Copyright © 2013 Axel Davy
+ *
+ * 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.
+ */ 
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include "xorg-config.h"
+#endif
+
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <xf86drm.h>
+#include <wayland-util.h>
+#include <wayland-client.h>
+#include <drm-client-protocol.h>
+
+#include <xf86Xinput.h>
+#include <xf86Crtc.h>
+#include <xf86str.h>
+#include <windowstr.h>
+#include <input.h>
+#include <inputstr.h>
+#include <exevents.h>
+
+#include "xwayland.h"
+#include "xwayland-private.h"
+
+
+/*
+ * Handling of frame events and buffer events.
+ * API to use them
+ */
+
+
+struct _todo
+{
+  todo_func tocall;
+  void *args;
+  struct wl_list link;
+};
+
+
+
+static const struct wl_callback_listener frame_listener;
+
+static void frame_listener_callback(void *data, struct wl_callback *callback,
+				    uint32_t time)
+{
+  struct xwl_window* window = data; 
+  struct wl_list todo_list;
+  struct _todo* todo;
+
+  wl_callback_destroy(window->frame_callback);
+  window->frame_callback = wl_surface_frame(window->surface);
+  wl_callback_add_listener(window->frame_callback,&frame_listener, window);
+
+  if (wl_list_empty(&window->frame_todo))
+    return;
+
+  /* todo funcs will be able to ask to be recalled */
+
+  wl_list_init(&todo_list);
+  wl_list_insert_list(&todo_list, &window->frame_todo);
+  wl_list_init(&window->frame_todo);
+  wl_list_for_each(todo, &todo_list,link)
+    todo->tocall(todo->args);
+  event_todo_destroy(&todo_list);
+
+  if (!wl_list_empty(&window->frame_todo))
+    wl_surface_commit(window->surface);
+}
+
+
+
+static const struct wl_callback_listener frame_listener = {
+	frame_listener_callback
+};
+
+
+static void wl_buffer_release_event(void *data, struct wl_buffer *buffer)
+{
+  struct xwl_buffer* xwl_buffer = data; 
+  struct wl_list todo_list;
+  struct _todo* todo;
+
+  xwl_buffer->busy = FALSE;
+  if(wl_list_empty(&xwl_buffer->buffer_todo))
+    return;
+  wl_list_init(&todo_list);
+  wl_list_insert_list(&todo_list, &xwl_buffer->buffer_todo);
+  wl_list_init(&xwl_buffer->buffer_todo);
+  wl_list_for_each(todo, &todo_list,link)
+    todo->tocall(todo->args);
+  event_todo_destroy(&todo_list);  
+}
+
+
+static struct wl_buffer_listener wl_buffer_listener = {
+  wl_buffer_release_event
+};
+
+
+
+void create_frame_listener(struct xwl_window* window)
+{
+  wl_list_init(&window->frame_todo);
+  window->frame_callback = wl_surface_frame(window->surface);
+  wl_callback_add_listener(window->frame_callback, &frame_listener, window);
+  wl_surface_commit(window->surface);
+}
+
+Bool xwl_add_frame_todo_visible_window(WindowPtr window,
+				       todo_func tocall, void *arg)
+{
+  struct xwl_window* xwl_window = get_xwl_window(window);
+  struct _todo* todo;
+
+  if (!xwl_window || !xwl_window->buffer->buffer) /* Is not in our 'visible' list */
+    return FALSE;
+  if (!xwl_window->frame_callback)
+    create_frame_listener(xwl_window);
+  if (!xwl_window->frame_callback) /* Memory error? */
+    return FALSE;
+  if (wl_list_empty(&xwl_window->frame_todo))
+    wl_surface_commit(xwl_window->surface);
+  todo = calloc(sizeof (struct _todo), 1);
+  if(!todo) 
+    return FALSE;
+  todo->tocall = tocall;
+  todo->args = arg;
+  wl_list_insert(&xwl_window->frame_todo, &todo->link);
+  return TRUE;
+}
+
+
+
+Bool xwl_add_buffer_release_todo_buffer(struct xwl_buffer* xwl_buffer,
+					todo_func tocall, void *arg)
+{
+  struct _todo* todo;
+  todo = calloc(sizeof (struct _todo), 1);
+  if(!todo) 
+    return FALSE;
+  todo->tocall = tocall;
+  todo->args = arg;
+  wl_list_insert(&xwl_buffer->buffer_todo, &todo->link);
+  return TRUE;
+}
+
+Bool xwl_add_buffer_release_todo_visible_window(WindowPtr window,
+						todo_func tocall, void *arg)
+{
+  struct xwl_window* xwl_window = get_xwl_window(window);
+  if (!xwl_window) /* Is not in our 'visible' list */
+    return FALSE;
+  return xwl_add_buffer_release_todo_buffer(xwl_window->buffer, tocall, arg);
+}
+
+void event_todo_destroy(struct wl_list* todo_list) 
+{
+  struct _todo* pos,*tmp;
+  wl_list_for_each_safe(pos,tmp,todo_list,link)
+  {
+    wl_list_remove(&pos->link);
+    free (pos);
+  }
+}
+
+void destroy_frame_listener(struct xwl_window* window)
+{
+  struct wl_callback* frame_callback;
+  if(!window->frame_callback)
+    return;
+  frame_callback = window->frame_callback;
+  window->frame_callback = NULL;
+  wl_callback_destroy(frame_callback);
+  event_todo_destroy(&window->frame_todo);
+}
+
+void destroy_xwl_buffer(struct xwl_buffer* xwl_buffer)
+{
+  wl_buffer_destroy(xwl_buffer->buffer);
+  event_todo_destroy(&xwl_buffer->buffer_todo);
+}
+
+void destroy_xwl_buffer_complete(struct xwl_buffer* xwl_buffer)
+{
+  wl_buffer_destroy(xwl_buffer->buffer);
+  xwl_buffer->buffer = NULL;
+  event_todo_destroy(&xwl_buffer->buffer_todo);
+  free(xwl_buffer);
+}
+
+void xwl_buffer_add_listener(struct xwl_buffer* xwl_buffer)
+{
+  if (!xwl_buffer->buffer)
+    return;
+  wl_buffer_add_listener(xwl_buffer->buffer, &wl_buffer_listener, xwl_buffer);
+  wl_list_init(&xwl_buffer->buffer_todo);
+}
diff --git a/hw/xfree86/xwayland/xwayland-private.h b/hw/xfree86/xwayland/xwayland-private.h
index aa9fc03..590bb94 100644
--- a/hw/xfree86/xwayland/xwayland-private.h
+++ b/hw/xfree86/xwayland/xwayland-private.h
@@ -26,10 +26,19 @@
 #ifndef _XWAYLAND_PRIVATE_H_
 #define _XWAYLAND_PRIVATE_H_
 
+struct xwl_buffer
+{
+    struct wl_buffer		*buffer;
+    struct wl_list		 buffer_todo;
+    Bool			 busy;
+};
+
 struct xwl_window {
     struct xwl_screen		*xwl_screen;
     struct wl_surface		*surface;
-    struct wl_buffer		*buffer;
+    struct wl_callback    	*frame_callback;
+    struct wl_list		 frame_todo;
+    struct xwl_buffer		*buffer;
     WindowPtr			 window;
     DamagePtr			 damage;
     struct xorg_list		 link;
@@ -135,6 +144,15 @@ void xwl_seat_set_cursor(struct xwl_seat *xwl_seat);
 
 void xwl_output_remove(struct xwl_output *output);
 
+void xwl_buffer_add_listener(struct xwl_buffer* xwl_buffer);
+void destroy_frame_listener(struct xwl_window* window);
+void destroy_xwl_buffer_complete(struct xwl_buffer* xwl_buffer);
+void destroy_xwl_buffer(struct xwl_buffer* xwl_buffer);
+
+struct wl_list;
+void event_todo_destroy(struct wl_list* todo_list);
+struct xwl_window* get_xwl_window(WindowPtr window);
+
 extern const struct xserver_listener xwl_server_listener;
 
 #endif /* _XWAYLAND_PRIVATE_H_ */
diff --git a/hw/xfree86/xwayland/xwayland-window.c b/hw/xfree86/xwayland/xwayland-window.c
index 20db80c..1c87990 100644
--- a/hw/xfree86/xwayland/xwayland-window.c
+++ b/hw/xfree86/xwayland/xwayland-window.c
@@ -44,6 +44,11 @@
 
 static DevPrivateKeyRec xwl_window_private_key;
 
+struct xwl_window* get_xwl_window(WindowPtr window)
+{
+  return dixLookupPrivate(&window->devPrivates, &xwl_window_private_key);
+}
+
 static void
 free_pixmap(void *data, struct wl_callback *callback, uint32_t time)
 {
@@ -66,21 +71,22 @@ xwl_window_attach(struct xwl_window *xwl_window, PixmapPtr pixmap)
 
     /* We can safely destroy the buffer because we only use one buffer
      * per surface in xwayland model */
-    if (xwl_window->buffer)
-        wl_buffer_destroy(xwl_window->buffer);
+    if (xwl_window->buffer->buffer)
+        destroy_xwl_buffer(xwl_window->buffer); 
 
     xwl_screen->driver->create_window_buffer(xwl_window, pixmap);
 
-    if (!xwl_window->buffer) {
+    if (!xwl_window->buffer->buffer) {
         ErrorF("failed to create buffer\n");
 	return;
     }
 
-    wl_surface_attach(xwl_window->surface, xwl_window->buffer, 0, 0);
+    wl_surface_attach(xwl_window->surface, xwl_window->buffer->buffer, 0, 0);
     wl_surface_damage(xwl_window->surface, 0, 0,
 		      pixmap->drawable.width,
 		      pixmap->drawable.height);
     wl_surface_commit(xwl_window->surface);
+    xwl_window->buffer->busy = TRUE;
 
     callback = wl_display_sync(xwl_screen->display);
     wl_callback_add_listener(callback, &free_pixmap_listener, pixmap);
@@ -182,6 +188,7 @@ xwl_realize_window(WindowPtr window)
 			      xwl_window->surface, window->drawable.id);
 
     wl_surface_set_user_data(xwl_window->surface, xwl_window);
+    xwl_window->buffer = calloc(sizeof (struct xwl_buffer), 1);
     xwl_window_attach(xwl_window, (*screen->GetWindowPixmap)(window));
 
     dixSetPrivate(&window->devPrivates,
@@ -229,9 +236,9 @@ xwl_unrealize_window(WindowPtr window)
 	dixLookupPrivate(&window->devPrivates, &xwl_window_private_key);
     if (!xwl_window)
 	return ret;
-
-    if (xwl_window->buffer)
-	wl_buffer_destroy(xwl_window->buffer);
+    destroy_frame_listener(xwl_window);
+    if (xwl_window->buffer->buffer)
+	destroy_xwl_buffer_complete(xwl_window->buffer); 
     wl_surface_destroy(xwl_window->surface);
     xorg_list_del(&xwl_window->link);
     if (RegionNotEmpty(DamageRegion(xwl_window->damage)))
diff --git a/hw/xfree86/xwayland/xwayland.c b/hw/xfree86/xwayland/xwayland.c
index c70a52d..20dd772 100644
--- a/hw/xfree86/xwayland/xwayland.c
+++ b/hw/xfree86/xwayland/xwayland.c
@@ -277,13 +277,18 @@ xwl_create_window_buffer_shm(struct xwl_window *xwl_window,
     size = stride * pixmap->drawable.height;
 
     pool = wl_shm_create_pool(xwl_window->xwl_screen->shm, fd, size);
-    xwl_window->buffer =  wl_shm_pool_create_buffer(pool, 0,
+    xwl_window->buffer->buffer =  wl_shm_pool_create_buffer(pool, 0,
 			   pixmap->drawable.width,
 			   pixmap->drawable.height,
 			   stride, format);
     wl_shm_pool_destroy(pool);
+    if(xwl_window->buffer->buffer)
+    {
+      xwl_window->buffer->busy = FALSE;
+      xwl_buffer_add_listener(xwl_window->buffer);
+    }
 
-    return xwl_window->buffer ? Success : BadDrawable;
+    return xwl_window->buffer->buffer ? Success : BadDrawable;
 }
 
 void xwl_screen_close(struct xwl_screen *xwl_screen)
@@ -302,7 +307,8 @@ void xwl_screen_close(struct xwl_screen *xwl_screen)
     }
     xorg_list_for_each_entry_safe(xwl_window, wtmp,
 				  &xwl_screen->window_list, link) {
-	wl_buffer_destroy(xwl_window->buffer);
+        destroy_frame_listener(xwl_window);
+	destroy_xwl_buffer_complete(xwl_window->buffer); 
 	wl_surface_destroy(xwl_window->surface);
 	free(xwl_window);
     }
@@ -327,6 +333,14 @@ void xwl_screen_destroy(struct xwl_screen *xwl_screen)
     free(xwl_screen);
 }
 
+struct wl_display *xwl_display_get(struct xwl_screen *xwl_screen)
+{
+  if(xwl_screen)
+    return xwl_screen->display;
+  else
+    return NULL;
+}
+
 /* DDX driver must call this after submitting the rendering */
 void xwl_screen_post_damage(struct xwl_screen *xwl_screen)
 {
@@ -347,9 +361,10 @@ void xwl_screen_post_damage(struct xwl_screen *xwl_screen)
 			      box->y2 - box->y1);
 	}
 	wl_surface_attach(xwl_window->surface,
-			  xwl_window->buffer,
+			  xwl_window->buffer->buffer,
 			  0, 0);
 	wl_surface_commit(xwl_window->surface);
+	xwl_window->buffer->busy = TRUE;
 	DamageEmpty(xwl_window->damage);
     }
 
diff --git a/hw/xfree86/xwayland/xwayland.h b/hw/xfree86/xwayland/xwayland.h
index f268366..9a6c6a0 100644
--- a/hw/xfree86/xwayland/xwayland.h
+++ b/hw/xfree86/xwayland/xwayland.h
@@ -30,6 +30,7 @@
 
 struct xwl_window;
 struct xwl_screen;
+struct xwl_buffer;
 
 struct xwl_driver {
     int version;
@@ -38,6 +39,8 @@ struct xwl_driver {
                                 PixmapPtr pixmap);
 };
 
+typedef	void (*todo_func)(void *arg);
+
 #define XWL_FLAGS_ROOTLESS 0x01
 
 extern _X_EXPORT int
@@ -80,4 +83,69 @@ extern _X_EXPORT int
 xwl_create_window_buffer_shm(struct xwl_window *xwl_window,
 			     PixmapPtr pixmap, int fd);
 
+extern _X_EXPORT struct wl_display *
+xwl_display_get(struct xwl_screen *xwl_screen);
+
+/* A visible window is a window with a Wayland surface associated.
+ * Typically, it is a child of the screen window
+ */
+
+/* Add a request for a todo_func to be called with arg, when the frame callback
+ * of the Wayland surface associated to the window is called. This function
+ * can be called also if we are in the todo_func, in this case the added 
+ * todo_func will be called for next frame. The window argument need to be a 
+ * visible window.
+ */
+extern _X_EXPORT Bool
+xwl_add_frame_todo_visible_window(WindowPtr window, todo_func tocall,
+				  void *arg);
+
+/* Similar function, but the todo_func is called at the release of the
+ * xwl_buffer associated with the window by the wayland compositor
+ */
+
+extern _X_EXPORT Bool
+xwl_add_buffer_release_todo_visible_window(WindowPtr window, todo_func tocall,
+					   void *arg);
+
+/* Similar function, but doesn't need a visible window as argument */
+
+extern _X_EXPORT Bool
+xwl_add_buffer_release_todo_buffer(struct xwl_buffer* buffer, todo_func tocall,
+				   void *arg);
+
+/* Get if a xwl_buffer has been released by the Wayland compositor, 
+ * and can be used freely. Note that at creation, a xwl_buffer is considered
+ * released, and that the state of the xwl_buffer associated to a visible
+ * window can change.
+ */
+
+extern _X_EXPORT Bool
+xwl_is_released_buffer(struct xwl_buffer* xwl_buffer);
+
+/* Get a pointer to the xwl_buffer of a visible window */
+
+extern _X_EXPORT struct xwl_buffer*
+xwl_get_xwl_buffer_from_visible_window(WindowPtr window);
+
+/* Exchange the xwl_buffer linked with a visible window. 
+ * Returns NULL if failed. */
+
+extern _X_EXPORT struct xwl_buffer*
+xwl_exchange_xwl_buffer_from_visible_window(WindowPtr window,
+					    struct xwl_buffer* new_xwl_buffer);
+
+/* create a xwl_buffer from a pixmap. You need to give a window argument, 
+ * it will be used only to determine the visuals to use.
+ */  
+
+extern _X_EXPORT struct xwl_buffer*
+xwl_create_new_xwl_buffer_from_pixmap(struct xwl_screen* xwl_screen,
+				      WindowPtr window, PixmapPtr pixmap);
+
+/* destroy an xwl_buffer */
+
+extern _X_EXPORT void
+xwl_delete_xwl_buffer(struct xwl_buffer* xwl_buffer);
+
 #endif /* _XWAYLAND_H_ */
-- 
1.8.1.2



More information about the wayland-devel mailing list