[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

wayland: Changes to 'upstream-experimental'



 Makefile.am                  |    2 
 TODO                         |  139 ------
 configure.ac                 |   18 
 protocol/screenshooter.xml   |    7 
 protocol/wayland.xml         |  457 ++++++++++++---------
 src/.gitignore               |    4 
 src/Makefile.am              |   64 ++
 src/connection.c             |  813 ++++++++++++++++++++++++++++++++++++++
 src/event-loop.c             |  475 ++++++++++++++++++++++
 src/scanner.c                |  870 ++++++++++++++++++++++++++++++++++++++++
 src/scanner.mk               |    8 
 src/wayland-client.c         |  579 +++++++++++++++++++++++++++
 src/wayland-client.h         |  101 ++++
 src/wayland-client.pc.in     |   10 
 src/wayland-egl.h            |   66 +++
 src/wayland-hash.c           |  306 ++++++++++++++
 src/wayland-private.h        |   91 ++++
 src/wayland-server.c         |  919 +++++++++++++++++++++++++++++++++++++++++++
 src/wayland-server.h         |  277 ++++++++++++
 src/wayland-server.pc.in     |   10 
 src/wayland-shm.c            |  253 +++++++++++
 src/wayland-util.c           |  272 ++++++++++++
 src/wayland-util.h           |  163 +++++++
 wayland/.gitignore           |    4 
 wayland/Makefile.am          |   63 --
 wayland/connection.c         |  737 ----------------------------------
 wayland/connection.h         |   68 ---
 wayland/event-loop.c         |  466 ---------------------
 wayland/scanner.c            |  730 ----------------------------------
 wayland/scanner.mk           |    8 
 wayland/wayland-client.c     |  575 --------------------------
 wayland/wayland-client.h     |   90 ----
 wayland/wayland-client.pc.in |   10 
 wayland/wayland-egl.h        |   68 ---
 wayland/wayland-hash.c       |  296 -------------
 wayland/wayland-server.c     |  891 -----------------------------------------
 wayland/wayland-server.h     |  302 --------------
 wayland/wayland-server.pc.in |   10 
 wayland/wayland-shm.c        |  222 ----------
 wayland/wayland-util.c       |  123 -----
 wayland/wayland-util.h       |  152 -------
 41 files changed, 5569 insertions(+), 5150 deletions(-)

New commits:
commit bc79f1f820409fb92c158a9d2df8a99ad269018e
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Thu Dec 22 15:32:37 2011 -0500

    Rename all instances of typeof

diff --git a/src/wayland-util.h b/src/wayland-util.h
index 8061368..944e7f0 100644
--- a/src/wayland-util.h
+++ b/src/wayland-util.h
@@ -119,7 +119,7 @@ void wl_list_insert_list(struct wl_list *list, struct wl_list *other);
 
 #ifdef __GNUC__
 #define __container_of(ptr, sample, member)				\
-	(typeof(sample))((char *)(ptr)	-				\
+	(__typeof__(sample))((char *)(ptr)	-			\
 		 ((char *)&(sample)->member - (char *)(sample)))
 #else
 #define __container_of(ptr, sample, member)				\

commit 5e078bfa5a64b1d3ebf78ff2cec0a8e7daaaf983
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Thu Dec 22 15:23:54 2011 -0500

    Use __typeof__ instead of typeof
    
    Thiago Macieira compiles with -std=c++11.

diff --git a/src/wayland-util.h b/src/wayland-util.h
index 625a2d3..8061368 100644
--- a/src/wayland-util.h
+++ b/src/wayland-util.h
@@ -40,8 +40,8 @@ extern "C" {
 #define ALIGN(n, a) ( ((n) + ((a) - 1)) & ~((a) - 1) )
 #define DIV_ROUNDUP(n, a) ( ((n) + ((a) - 1)) / (a) )
 
-#define container_of(ptr, type, member) ({			\
-	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
+#define container_of(ptr, type, member) ({				\
+	const __typeof__( ((type *)0)->member ) *__mptr = (ptr);	\
 	(type *)( (char *)__mptr - offsetof(type,member) );})
 
 struct wl_message {

commit aad1e190588a0edc5a39a9feba534e7a6d4532d4
Author: Pekka Paalanen <ppaalanen@gmail.com>
Date:   Thu Dec 22 16:52:37 2011 +0200

    server: destroy the socket event source on display destroy
    
    On wl_display_add_socket(), the listening socket fd is added to the
    event loop. However, wl_event_source object is not stored and hence
    cannot be freed, resulting in a minor leak.
    
    Store wl_event_source pointer in struct wl_socket so we can track it,
    and destroy it on wl_display_destroy(). The event loop itself must be
    destroyed after destroying the event sources linked to it.
    
    Fixes a Valgrind reported memory leak.
    
    Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>

diff --git a/src/wayland-server.c b/src/wayland-server.c
index 87e4ed5..415173b 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -51,6 +51,7 @@ struct wl_socket {
 	struct sockaddr_un addr;
 	char lock_addr[113];
 	struct wl_list link;
+	struct wl_event_source *source;
 };
 
 struct wl_client {
@@ -667,14 +668,15 @@ wl_display_destroy(struct wl_display *display)
 	struct wl_socket *s, *next;
 	struct wl_global *global, *gnext;
 
-  	wl_event_loop_destroy(display->loop);
 	wl_list_for_each_safe(s, next, &display->socket_list, link) {
+		wl_event_source_remove(s->source);
 		close(s->fd);
 		unlink(s->addr.sun_path);
 		close(s->fd_lock);
 		unlink(s->lock_addr);
 		free(s);
 	}
+	wl_event_loop_destroy(display->loop);
 
 	wl_list_for_each_safe(global, gnext, &display->global_list, link)
 		free(global);
@@ -858,9 +860,10 @@ wl_display_add_socket(struct wl_display *display, const char *name)
 		return -1;
 	}
 
-	if (wl_event_loop_add_fd(display->loop, s->fd,
-				 WL_EVENT_READABLE,
-				 socket_data, display) == NULL) {
+	s->source = wl_event_loop_add_fd(display->loop, s->fd,
+					 WL_EVENT_READABLE,
+					 socket_data, display);
+	if (s->source == NULL) {
 		close(s->fd);
 		unlink(s->addr.sun_path);
 		free(s);

commit 1f58d155da09f66dc1eaaafafddae3312e71704f
Author: Tiago Vignatti <tiago.vignatti@intel.com>
Date:   Wed Dec 21 19:34:08 2011 +0200

    protocol: update touch_down with focus surface
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 0f245e3..0c3a4ef 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -463,6 +463,7 @@
 
     <event name="touch_down">
       <arg name="time" type="uint"/>
+      <arg name="surface" type="object" interface="wl_surface"/>
       <arg name="id" type="int" />
       <arg name="x" type="int" />
       <arg name="y" type="int" />

commit e68529b52f30974841974c53605f00c9a8ca1580
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Mon Dec 19 13:15:06 2011 -0500

    protocol: Add a bit of documentation

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index b80f25e..0f245e3 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -228,6 +228,13 @@
       <arg name="time" type="uint"/>
     </request>
 
+    <!-- The data_offer event introduces a new wl_data_offer object,
+         which will subsequently be used in either the
+         data_device.enter event (for drag and drop) or the
+         data_device.selection event (for selections).  Immediately
+         following the data_device_data_offer event, the new
+         data_offer object will send out data_offer.offer events to
+         describe the mime-types it offers. -->
     <event name="data_offer">
       <arg name="id" type="new_id" interface="wl_data_offer"/>
     </event>
@@ -250,6 +257,15 @@
 
     <event name="drop"/>
 
+    <!-- The selection event is sent out to notify the client of a new
+         wl_data_offer for the selection for this device.  The
+         data_device.data_offer and the data_offer.offer events are
+         sent out immediately before this event to introduce the data
+         offer object.  The selection event is sent to a client
+         immediately before receiving keyboard focus and when a new
+         selection is set while the client has keyboard focus.  The
+         data_offer is valid until a new data_offer or NULL is
+         received or until the client loses keyboard focus. -->
     <event name="selection">
       <arg name="id" type="object" interface="wl_data_offer"/>
     </event>

commit 1b31149f92888eae01df6ff442166b91b35843b3
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Sat Dec 17 16:05:44 2011 -0500

    connection: Fix printf format warnings

diff --git a/src/connection.c b/src/connection.c
index 06b6130..4ac5bf8 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -525,7 +525,7 @@ wl_connection_vmarshal(struct wl_connection *connection,
 	return closure;
 
 err:
-	printf("request too big to marshal, maximum size is %d\n",
+	printf("request too big to marshal, maximum size is %lu\n",
 	       sizeof closure->buffer);
 	errno = ENOMEM;
 	return NULL;
@@ -555,7 +555,7 @@ wl_connection_demarshal(struct wl_connection *connection,
 
 	extra_space = wl_message_size_extra(message);
 	if (sizeof closure->buffer < size + extra_space) {
-		printf("request too big to demarshal, maximum %d actual %d\n",
+		printf("request too big to demarshal, maximum %lu actual %d\n",
 		       sizeof closure->buffer, size + extra_space);
 		errno = ENOMEM;
 		wl_connection_consume(connection, size);

commit 34901868b8d037c3ec230a6828aa75c79ffae59c
Author: Laszlo Agocs <laszlo.p.agocs@nokia.com>
Date:   Fri Dec 16 10:29:36 2011 +0200

    Increase closure buffer size and fail gracefully for too big closures.
    
    Buffer size changed from 256 to 1024 bytes. Marshalling will now stop
    if the buffer is not big enough.

diff --git a/src/connection.c b/src/connection.c
index f19280a..06b6130 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -39,8 +39,6 @@
 #include "wayland-util.h"
 #include "wayland-private.h"
 
-#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
-
 struct wl_buffer {
 	char data[4096];
 	int head, tail;
@@ -54,7 +52,7 @@ struct wl_closure {
 	ffi_type *types[20];
 	ffi_cif cif;
 	void *args[20];
-	uint32_t buffer[64];
+	uint32_t buffer[256];
 	uint32_t *start;
 };
 
@@ -392,7 +390,7 @@ wl_connection_vmarshal(struct wl_connection *connection,
 {
 	struct wl_closure *closure = &connection->send_closure;
 	struct wl_object **objectp, *object;
-	uint32_t length, *p, *start, size;
+	uint32_t length, *p, *start, size, *end;
 	int dup_fd;
 	struct wl_array **arrayp, *array;
 	const char **sp, *s;
@@ -403,17 +401,23 @@ wl_connection_vmarshal(struct wl_connection *connection,
 	count = strlen(message->signature) + 2;
 	extra = (char *) closure->buffer;
 	start = &closure->buffer[DIV_ROUNDUP(extra_size, sizeof *p)];
+	end = &closure->buffer[ARRAY_LENGTH(closure->buffer)];
 	p = &start[2];
+
 	for (i = 2; i < count; i++) {
 		switch (message->signature[i - 2]) {
 		case 'u':
 			closure->types[i] = &ffi_type_uint32;
 			closure->args[i] = p;
+			if (end - p < 1)
+				goto err;
 			*p++ = va_arg(ap, uint32_t);
 			break;
 		case 'i':
 			closure->types[i] = &ffi_type_sint32;
 			closure->args[i] = p;
+			if (end - p < 1)
+				goto err;
 			*p++ = va_arg(ap, int32_t);
 			break;
 		case 's':
@@ -424,6 +428,8 @@ wl_connection_vmarshal(struct wl_connection *connection,
 
 			s = va_arg(ap, const char *);
 			length = s ? strlen(s) + 1: 0;
+			if (end - p < DIV_ROUNDUP(length, sizeof *p) + 1)
+				goto err;
 			*p++ = length;
 
 			if (length > 0)
@@ -442,6 +448,8 @@ wl_connection_vmarshal(struct wl_connection *connection,
 
 			object = va_arg(ap, struct wl_object *);
 			*objectp = object;
+			if (end - p < 1)
+				goto err;
 			*p++ = object ? object->id : 0;
 			break;
 
@@ -449,6 +457,8 @@ wl_connection_vmarshal(struct wl_connection *connection,
 			closure->types[i] = &ffi_type_uint32;
 			closure->args[i] = p;
 			object = va_arg(ap, struct wl_object *);
+			if (end - p < 1)
+				goto err;
 			*p++ = object ? object->id : 0;
 			break;
 
@@ -463,9 +473,13 @@ wl_connection_vmarshal(struct wl_connection *connection,
 
 			array = va_arg(ap, struct wl_array *);
 			if (array == NULL || array->size == 0) {
+				if (end - p < 1)
+					goto err;
 				*p++ = 0;
 				break;
 			}
+			if (end - p < DIV_ROUNDUP(array->size, sizeof *p) + 1)
+				goto err;
 			*p++ = array->size;
 			memcpy(p, array->data, array->size);
 
@@ -509,6 +523,12 @@ wl_connection_vmarshal(struct wl_connection *connection,
 	closure->count = count;
 
 	return closure;
+
+err:
+	printf("request too big to marshal, maximum size is %d\n",
+	       sizeof closure->buffer);
+	errno = ENOMEM;
+	return NULL;
 }
 
 struct wl_closure *
@@ -535,7 +555,8 @@ wl_connection_demarshal(struct wl_connection *connection,
 
 	extra_space = wl_message_size_extra(message);
 	if (sizeof closure->buffer < size + extra_space) {
-		printf("request too big, should malloc tmp buffer here\n");
+		printf("request too big to demarshal, maximum %d actual %d\n",
+		       sizeof closure->buffer, size + extra_space);
 		errno = ENOMEM;
 		wl_connection_consume(connection, size);
 		return NULL;
diff --git a/src/wayland-client.c b/src/wayland-client.c
index e4f2c99..bbfc035 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -198,6 +198,11 @@ wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...)
 					 &proxy->object.interface->methods[opcode]);
 	va_end(ap);
 
+	if (closure == NULL) {
+		fprintf(stderr, "Error marshalling request\n");
+		abort();
+	}
+
 	wl_closure_send(closure, proxy->display->connection);
 
 	if (wl_debug)
@@ -473,7 +478,7 @@ handle_event(struct wl_display *display,
 					  size, &display->objects, message);
 
 	if (closure == NULL) {
-		fprintf(stderr, "Error demarshalling event: %m\n");
+		fprintf(stderr, "Error demarshalling event\n");
 		abort();
 	}
 
diff --git a/src/wayland-server.c b/src/wayland-server.c
index 421c3f0..87e4ed5 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -100,6 +100,9 @@ wl_resource_post_event(struct wl_resource *resource, uint32_t opcode, ...)
 					 &object->interface->events[opcode]);
 	va_end(ap);
 
+	if (closure == NULL)
+		return;
+
 	wl_closure_send(closure, resource->client->connection);
 
 	if (wl_debug)
@@ -122,6 +125,9 @@ wl_resource_queue_event(struct wl_resource *resource, uint32_t opcode, ...)
 					 &object->interface->events[opcode]);
 	va_end(ap);
 
+	if (closure == NULL)
+		return;
+
 	wl_closure_queue(closure, resource->client->connection);
 
 	if (wl_debug)

commit f598691831db779aab1f5dd17ace5992a0928960
Author: Andy Nichols <andy.nichols@nokia.com>
Date:   Thu Nov 24 10:19:18 2011 +0100

    Removed superfluous call to wl_copy_connection
    
    The only purpose those code seems to serve is to introduce a buffer
    overflow when events contain more than 128 bytes of data.

diff --git a/src/wayland-client.c b/src/wayland-client.c
index 836a31c..e4f2c99 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -453,12 +453,10 @@ static void
 handle_event(struct wl_display *display,
 	     uint32_t id, uint32_t opcode, uint32_t size)
 {
-	uint32_t p[32];
 	struct wl_proxy *proxy;
 	struct wl_closure *closure;
 	const struct wl_message *message;
 
-	wl_connection_copy(display->connection, p, size);
 	proxy = wl_map_lookup(&display->objects, id);
 
 	if (proxy == WL_ZOMBIE_OBJECT) {

commit 187eace6139754eae58a21303c808a270f70dc3f
Author: Jørgen Lind <jorgen.lind@nokia.com>
Date:   Tue Dec 13 22:01:34 2011 +0100

    Make wl_list_for_each* work for c++

diff --git a/src/wayland-util.h b/src/wayland-util.h
index 953d51a..625a2d3 100644
--- a/src/wayland-util.h
+++ b/src/wayland-util.h
@@ -117,9 +117,15 @@ int wl_list_length(struct wl_list *list);
 int wl_list_empty(struct wl_list *list);
 void wl_list_insert_list(struct wl_list *list, struct wl_list *other);
 
+#ifdef __GNUC__
 #define __container_of(ptr, sample, member)				\
-	(void *)((char *)(ptr)	-					\
+	(typeof(sample))((char *)(ptr)	-				\
 		 ((char *)&(sample)->member - (char *)(sample)))
+#else
+#define __container_of(ptr, sample, member)				\
+	(void *)((char *)(ptr)	-				        \
+		 ((char *)&(sample)->member - (char *)(sample)))
+#endif
 
 #define wl_list_for_each(pos, head, member)				\
 	for (pos = 0, pos = __container_of((head)->next, pos, member);	\

commit e631ab6cde2fa0d0fe59cc4f5776c9a8b3002989
Author: Pekka Paalanen <ppaalanen@gmail.com>
Date:   Tue Dec 13 14:53:54 2011 +0200

    client: fix a strdup memory leak
    
    Memory leak found by valgrinding simple-shm client.
    struct wl_global::interface is a strdup()'d string that was never freed.
    
    Make a function for freeing a wl_global, and use it.
    
    krh: Edit to name wl_global destructor wl_global_destroy.
    
    Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>

diff --git a/src/wayland-client.c b/src/wayland-client.c
index 22244f8..836a31c 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -252,6 +252,14 @@ display_handle_global(void *data,
 }
 
 static void
+wl_global_destroy(struct wl_global *global)
+{
+	wl_list_remove(&global->link);
+	free(global->interface);
+	free(global);
+}
+
+static void
 display_handle_global_remove(void *data,
                              struct wl_display *display, uint32_t id)
 {
@@ -259,8 +267,7 @@ display_handle_global_remove(void *data,
 
 	wl_list_for_each(global, &display->global_list, link)
 		if (global->id == id) {
-			wl_list_remove(&global->link);
-			free(global);
+			wl_global_destroy(global);
 			break;
 		}
 }
@@ -394,7 +401,7 @@ wl_display_destroy(struct wl_display *display)
 	wl_map_release(&display->objects);
 	wl_list_for_each_safe(global, gnext,
 			      &display->global_list, link)
-		free(global);
+		wl_global_destroy(global);
 	wl_list_for_each_safe(listener, lnext,
 			      &display->global_listener_list, link)
 		free(listener);

commit 58bb064afa3bfc706e3b30dd170804235aa272ea
Author: Pekka Paalanen <ppaalanen@gmail.com>
Date:   Mon Dec 5 10:04:37 2011 +0200

    client: unset WAYLAND_SOCKET env variable
    
    WAYLAND_SOCKET contains a file descriptor that is an open connection to
    a Wayland server. It is private to us, and makes no sense to relay the
    same value (or any value) to our child processes.
    
    Unset the environment variable to prevent it from being accidentally
    relayed to other processes.
    
    Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>

diff --git a/src/wayland-client.c b/src/wayland-client.c
index 939c17d..22244f8 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -352,6 +352,7 @@ wl_display_connect(const char *name)
 		flags = fcntl(display->fd, F_GETFD);
 		if (flags != -1)
 			fcntl(display->fd, F_SETFD, flags | FD_CLOEXEC);
+		unsetenv("WAYLAND_SOCKET");
 	} else if (connect_to_socket(display, name) < 0) {
 		free(display);
 		return NULL;

commit cf89b40c4ca105416240df737ba8e30c070a44af
Author: Pekka Paalanen <ppaalanen@gmail.com>
Date:   Tue Nov 29 14:32:32 2011 +0200

    server: do not send delete_id to a dead client
    
    During client tear-down, all objects are destroyed in id order.
    Therefore the display object is destroyed first.
    
    If the destroy listeners of any object destroy another object by calling
    wl_resoruce_destroy(), we try to send a delete_id event to the client.
    This leads to a segmentation fault without a display object.
    
    Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>

diff --git a/src/wayland-server.c b/src/wayland-server.c
index 9358eb4..421c3f0 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -348,9 +348,11 @@ wl_resource_destroy(struct wl_resource *resource, uint32_t time)
 	struct wl_client *client = resource->client;
 
 	if (resource->object.id < WL_SERVER_ID_START) {
-		wl_resource_queue_event(resource->client->display_resource,
-					WL_DISPLAY_DELETE_ID,
-					resource->object.id);
+		if (client->display_resource) {
+			wl_resource_queue_event(client->display_resource,
+						WL_DISPLAY_DELETE_ID,
+						resource->object.id);
+		}
 		wl_map_insert_at(&client->objects, resource->object.id, NULL);
 	} else {
 		wl_map_remove(&client->objects, resource->object.id);

commit 42eed3235a8349ac2139bb9a06cb8ac294872809
Author: Pekka Paalanen <ppaalanen@gmail.com>
Date:   Thu Nov 24 16:19:03 2011 +0200

    protocol: introduce wl_shell_surface
    
    Requests like 'move' and 'set_toplevel' are really methods of a surface,
    not methods of a global shell object. Move all these methods to a new
    interface, wl_shell_surface.
    
    The global object wl_shell will contain only 'get_shell_surface'
    request, which creates and associates a wl_shell_surface object to a
    given wl_surface object.
    
    This will also give the shell plugin (if you look at the demo
    compositor) means to store per-surface private data in a natural way.
    
    Due to a limitation in delete_id event handling on client side, the
    client must destroy its wl_shell_surface object before destroying the
    wl_surface object. Otherwise it may just leak an id.
    
    Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 51a83ef..b80f25e 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -267,8 +267,19 @@
   </interface>
 
   <interface name="wl_shell" version="1">
-    <request name="move">
+    <request name="get_shell_surface">
+      <arg name="id" type="new_id" interface="wl_shell_surface"/>
       <arg name="surface" type="object" interface="wl_surface"/>
+    </request>
+  </interface>
+
+  <!-- A wrapper interface for shell related actions on a wl_surface.
+       On server side the object is automatically destroyed when the
+       related wl_surface is destroyed.
+       On client side, wl_shell_surface_destroy() must be called
+       before destroying the wl_surface object. -->
+  <interface name="wl_shell_surface" version="1">
+    <request name="move">
       <arg name="input_device" type="object" interface="wl_input_device"/>
       <arg name="time" type="uint"/>
     </request>
@@ -286,7 +297,6 @@
     </enum>
 
     <request name="resize">
-      <arg name="surface" type="object" interface="wl_surface"/>
       <arg name="input_device" type="object" interface="wl_input_device"/>
       <arg name="time" type="uint"/>
       <!-- edges is an enum, need to get the values in here -->
@@ -294,9 +304,7 @@
     </request>
 
     <!-- Make the surface visible as a toplevel window. -->
-    <request name="set_toplevel">
-      <arg name="surface" type="object" interface="wl_surface"/>
-    </request>
+    <request name="set_toplevel"/>
 
     <!-- Map the surface relative to an existing surface. The x and y
          arguments specify the locations of the upper left corner of
@@ -307,8 +315,7 @@
          determines the initial position or if the surface is locked
          to that relative position during moves. -->
     <request name="set_transient">
-      <arg name="surface" type="object" interface="wl_surface"/>
-      <arg name="parent" type="object" interface="wl_surface"/>
+      <arg name="parent" type="object" interface="wl_shell_surface"/>
       <arg name="x" type="int"/>
       <arg name="y" type="int"/>
       <arg name="flags" type="uint"/>
@@ -322,9 +329,7 @@
          fullscreen? what if there's already a fullscreen surface on
          the output, maybe you can only go fullscreen if you're
          active?  -->
-    <request name="set_fullscreen">
-      <arg name="surface" type="object" interface="wl_surface"/>
-    </request>
+    <request name="set_fullscreen"/>
 
     <!-- The configure event asks the client to resize its surface.
          The size is a hint, in the sense that the client is free to
@@ -335,7 +340,6 @@
     <event name="configure">
       <arg name="time" type="uint"/>
       <arg name="edges" type="uint"/>
-      <arg name="surface" type="object" interface="wl_surface"/>
       <arg name="width" type="int"/>
       <arg name="height" type="int"/>
     </event>

commit e04c137e86f3672f5274a3168a3e88483a191693
Author: Pekka Paalanen <ppaalanen@gmail.com>
Date:   Mon Nov 28 12:23:32 2011 +0200

    server: document wl_resource_post_event() arguments
    
    Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>

diff --git a/src/wayland-server.h b/src/wayland-server.h
index 4de2e83..8019c56 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -180,10 +180,27 @@ struct wl_input_device {
 	struct wl_listener grab_listener;
 };
 
+/*
+ * Post an event to the client's object referred to by 'resource'.
+ * 'opcode' is the event number generated from the protocol XML
+ * description (the event name). The variable arguments are the event
+ * parameters, in the order they appear in the protocol XML specification.
+ *
+ * The variable arguments' types are:
+ * - type=uint: 	uint32_t
+ * - type=int:		int32_t
+ * - type=string:	(const char *) to a nil-terminated string
+ * - type=array:	(struct wl_array *)
+ * - type=fd:		int, that is an open file descriptor
+ * - type=new_id:	(struct wl_object *) or (struct wl_resource *)
+ * - type=object:	(struct wl_object *) or (struct wl_resource *)
+ */
 void wl_resource_post_event(struct wl_resource *resource,
 			    uint32_t opcode, ...);
 void wl_resource_queue_event(struct wl_resource *resource,
 			     uint32_t opcode, ...);
+
+/* msg is a printf format string, variable args are its args. */
 void wl_resource_post_error(struct wl_resource *resource,
 			    uint32_t code, const char *msg, ...);
 void wl_resource_post_no_memory(struct wl_resource *resource);

commit 804d5dd348567fd286b8aa5101d3aff95ecd69d7
Author: Pekka Paalanen <ppaalanen@gmail.com>
Date:   Wed Nov 9 16:27:07 2011 +0200

    util: clear pointers on wl_list_remove()
    
    Set the next and prev pointers of the removed list element to NULL. This
    will catch programming errors that would use invalid list pointers,
    double-remove for instance.
    
    It also helps debugging, making it easy to see in gdb if an object is
    not in a list.
    
    Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>

diff --git a/src/wayland-util.c b/src/wayland-util.c
index 647b861..06bd245 100644
--- a/src/wayland-util.c
+++ b/src/wayland-util.c
@@ -49,6 +49,8 @@ wl_list_remove(struct wl_list *elm)
 {
 	elm->prev->next = elm->next;
 	elm->next->prev = elm->prev;
+	elm->next = NULL;
+	elm->prev = NULL;
 }
 
 WL_EXPORT int

commit ab6b0738c67bb6a3eec5b198ff909dc18a562294
Author: Pekka Paalanen <ppaalanen@gmail.com>
Date:   Mon Nov 28 09:47:15 2011 +0200

    server: no errors to a dead client
    
    Do not try to send errors to an already dead client, while in the
    middle of cleanup.
    
    Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>

diff --git a/src/wayland-server.c b/src/wayland-server.c
index 7c93e3f..9358eb4 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -143,6 +143,17 @@ wl_resource_post_error(struct wl_resource *resource,
 	va_end(ap);
 
 	client->error = 1;
+
+	/*
+	 * When a client aborts, its resources are destroyed in id order,
+	 * which means the display resource is destroyed first. If destruction
+	 * of any later resources results in a protocol error, we end up here
+	 * with a NULL display_resource. Do not try to send errors to an
+	 * already dead client.
+	 */
+	if (!client->display_resource)
+		return;
+
 	wl_resource_post_event(client->display_resource,
 			       WL_DISPLAY_ERROR, resource, code, buffer);
 }
@@ -579,6 +590,13 @@ struct wl_display_interface display_interface = {
 };
 
 static void
+destroy_client_display_resource(struct wl_resource *resource)
+{
+	resource->client->display_resource = NULL;
+	free(resource);
+}
+
+static void
 bind_display(struct wl_client *client,
 	     void *data, uint32_t version, uint32_t id)
 {
@@ -588,6 +606,7 @@ bind_display(struct wl_client *client,
 	client->display_resource =
 		wl_client_add_object(client, &wl_display_interface,
 				     &display_interface, id, display);
+	client->display_resource->destroy = destroy_client_display_resource;
 
 	wl_list_for_each(global, &display->global_list, link)
 		wl_resource_post_event(client->display_resource,

commit eae3bcb4ccb80ef1c4dcd2f71987c1187aeb9e73
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Nov 15 08:58:34 2011 -0500

    New drag and drop / selection protocol
    
    This commit brings a big change to the DND and copy/paste interfaces.
    Most importantly the functionality is now independent of wl_shell.
    The wl_shell interface is intended for desktop style UI interaction and
    an optional and experimental interface.
    
    The new interface also allows receiving the DND data multiple times or
    multiple times during the drag, and the mechanism for offering and receiving
    data is now shared between DND and selections.

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 7e6392a..51a83ef 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -157,6 +157,115 @@
     <event name="release"/>
   </interface>
 
+
+  <interface name="wl_data_offer" version="1">
+    <!-- Indicate that the client can accept the given mime-type, or
+         NULL for not accepted.  Use for feedback during drag and
+         drop. -->
+    <request name="accept">
+      <arg name="time" type="uint"/>
+      <arg name="type" type="string"/>
+    </request>
+
+    <request name="receive">
+      <arg name="mime_type" type="string"/>
+      <arg name="fd" type="fd"/>
+    </request>
+
+    <request name="destroy" type="destructor"/>
+
+    <!-- Sent immediately after creating the wl_data_offer object.  One
+         event per offered mime type. -->
+    <event name="offer">
+      <arg name="type" type="string"/>
+    </event>
+  </interface>
+
+  <interface name="wl_data_source" version="1">
+    <!-- Add an offered mime type.  Can be called several times to
+         offer multiple types. -->
+    <request name="offer">
+      <arg name="type" type="string"/>
+    </request>
+
+    <!-- Destroy the selection. -->
+    <request name="destroy" type="destructor"/>
+
+    <!-- Sent when a target accepts pointer_focus or motion events.
+         If a target does not accept any of the offered types, type is
+         NULL -->
+    <event name="target">
+      <arg name="mime_type" type="string"/>
+    </event>
+
+    <!-- Request for data from another client.  Send the data in the
+         specified mime-type over the passed fd, the close it. -->
+    <event name="send">
+      <arg name="mime_type" type="string"/>
+      <arg name="fd" type="fd"/>
+    </event>
+
+    <!-- Another selection became active. -->
+    <event name="cancelled"/>
+  </interface>
+
+  <interface name="wl_data_device" version="1">
+    <request name="start_drag">
+      <arg name="source" type="object" interface="wl_data_source"/>
+      <arg name="surface" type="object" interface="wl_surface"/>
+      <arg name="time" type="uint"/>
+    </request>
+
+    <request name="attach">
+      <arg name="time" type="uint"/>
+      <arg name="buffer" type="object" interface="wl_buffer"/>
+      <arg name="x" type="int"/>
+      <arg name="y" type="int"/>
+    </request>
+
+    <request name="set_selection">
+      <arg name="source" type="object" interface="wl_data_source"/>
+      <arg name="time" type="uint"/>
+    </request>
+
+    <event name="data_offer">
+      <arg name="id" type="new_id" interface="wl_data_offer"/>
+    </event>
+
+    <event name="enter">
+      <arg name="time" type="uint"/>
+      <arg name="surface" type="object" interface="wl_surface"/>
+      <arg name="x" type="int"/>
+      <arg name="y" type="int"/>
+      <arg name="id" type="object" interface="wl_data_offer"/>
+    </event>
+
+    <event name="leave"/>
+
+    <event name="motion">
+      <arg name="time" type="uint"/>
+      <arg name="x" type="int"/>
+      <arg name="y" type="int"/>
+    </event>
+
+    <event name="drop"/>
+
+    <event name="selection">
+      <arg name="id" type="object" interface="wl_data_offer"/>
+    </event>
+  </interface>
+
+  <interface name="wl_data_device_manager" version="1">
+    <request name="create_data_source">
+      <arg name="id" type="new_id" interface="wl_data_source"/>
+    </request>
+
+    <request name="get_data_device">
+      <arg name="id" type="new_id" interface="wl_data_device"/>
+      <arg name="input_device" type="object" interface="wl_input_device"/>
+    </request>
+  </interface>
+
   <interface name="wl_shell" version="1">
     <request name="move">
       <arg name="surface" type="object" interface="wl_surface"/>
@@ -184,14 +293,6 @@
       <arg name="edges" type="uint"/>
     </request>
 
-    <request name="create_drag">
-      <arg name="id" type="new_id" interface="wl_drag"/>
-    </request>
-
-    <request name="create_selection">
-      <arg name="id" type="new_id" interface="wl_selection"/>
-    </request>
-
     <!-- Make the surface visible as a toplevel window. -->
     <request name="set_toplevel">
       <arg name="surface" type="object" interface="wl_surface"/>
@@ -240,145 +341,6 @@
     </event>
   </interface>
 
-  <interface name="wl_selection" version="1">
-    <!-- Add an offered mime type.  Can be called several times to
-         offer multiple types, but must be called before 'activate'. -->
-    <request name="offer">
-      <arg name="type" type="string"/>
-    </request>
-
-    <!-- Can the selection be activated for multiple devices? -->
-    <request name="activate">
-      <arg name="input_device" type="object" interface="wl_input_device"/>
-      <arg name="time" type="uint"/>
-    </request>
-
-    <!-- Destroy the selection. -->
-    <request name="destroy" type="destructor"/>
-
-    <!-- Another client pasted the selection, send the mime-type over
-         the passed fd. -->
-    <event name="send">
-      <arg name="mime_type" type="string"/>
-      <arg name="fd" type="fd"/>
-    </event>
-
-    <!-- Another selection became active. -->
-    <event name="cancelled"/>
-  </interface>
-
-  <interface name="wl_selection_offer" version="1">
-    <!-- Called to receive the selection data as the specified type.
-         Sends the pipe fd to the compositor, which forwards it to the
-         source in the 'send' event -->
-    <request name="receive">


Reply to: