profile/ivi/wayland.git
11 years agodoc: Only generate Wayland documentation if xsltproc was found
Jonas Ådahl [Sat, 1 Dec 2012 16:33:22 +0000 (17:33 +0100)]
doc: Only generate Wayland documentation if xsltproc was found

Instead of failing to generate documentation because xsltproc doesn't
exist, don't try to generate at all.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agoconfigure.ac: Bump version to 1.0.2
Kristian Høgsberg [Fri, 30 Nov 2012 21:00:00 +0000 (16:00 -0500)]
configure.ac: Bump version to 1.0.2

11 years agoclient: Update libtool version for new entry points
Kristian Høgsberg [Fri, 30 Nov 2012 21:11:04 +0000 (16:11 -0500)]
client: Update libtool version for new entry points

We've added wl_display_dispatch_queue_pending, so update the libtool
library current and age fields accordingly.

11 years agoclient: Add \since tag for wl_display_dispatch_queue_pending() documentation
Kristian Høgsberg [Fri, 30 Nov 2012 19:05:32 +0000 (14:05 -0500)]
client: Add \since tag for wl_display_dispatch_queue_pending() documentation

11 years agopkgconfig: Use configure provided directories
Quentin Glidic [Tue, 27 Nov 2012 21:35:18 +0000 (22:35 +0100)]
pkgconfig: Use configure provided directories

https://bugs.freedesktop.org/show_bug.cgi?id=57630

11 years agoscanner: Fix wrong restriction on since field
Ander Conselvan de Oliveira [Tue, 27 Nov 2012 15:03:40 +0000 (17:03 +0200)]
scanner: Fix wrong restriction on since field

The scanner would not allow two consecutive requests on an interface to
have the same since number, so if a new version of an interface added
two new request the version number would have to be increased by two.

11 years agoclient: Don't cancel a roundtrip when any event is received
Jonas Ådahl [Mon, 26 Nov 2012 22:25:53 +0000 (23:25 +0100)]
client: Don't cancel a roundtrip when any event is received

Since wl_display_dispatch() returns the number of processed events or -1
on error, only cancel the roundtrip if an -1 is returned.

This also fixes a potential memory corruption bug happening when
wl_display_roundtrip() does an early return and the callback later
writes to the then out of scope stack allocated `done' parameter.

Introduced by 33b7637b4500a682018b503837b8aca9afae36f2.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agodoc: Fix typos
Tiago Vignatti [Thu, 22 Nov 2012 20:09:32 +0000 (18:09 -0200)]
doc: Fix typos

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agoclient: Add an entry point for dispatching a queue without blocking
Ander Conselvan de Oliveira [Thu, 22 Nov 2012 13:34:48 +0000 (15:34 +0200)]
client: Add an entry point for dispatching a queue without blocking

On the client side EGL, all the wl_buffer.release events need to be
processed before buffer allocation, otherwise a third buffer might
be allocated unnecessarily. However, the buffer allocation should
not block in the case no event was received. In order to do that, a
non-blocking queue dispatch function is needed.

11 years agodebug: Allow WAYLAND_DEBUG=server/client for server/client side only debug
Kristian Høgsberg [Wed, 21 Nov 2012 22:14:55 +0000 (17:14 -0500)]
debug: Allow WAYLAND_DEBUG=server/client for server/client side only debug

By default the server will dump protocol for both the server and its
clients when run with WAYLAND_DEBUG=1.  That's still the case, but it now
also understands WAYLAND_DEBUG=client or WAYLAND_DEBUG=server, which
will only enable debug dumping on either client or server side.

11 years agoconfigure.ac: Bump version to 1.0.1
Kristian Høgsberg [Mon, 19 Nov 2012 22:27:04 +0000 (17:27 -0500)]
configure.ac: Bump version to 1.0.1

11 years agodoc: Fix out-of-source build so distcheck works again
Kristian Høgsberg [Mon, 19 Nov 2012 22:14:05 +0000 (17:14 -0500)]
doc: Fix out-of-source build so distcheck works again

The amount of generated files and hacks over hacks in the doc/ directory
is getting out of hand and we need a better solution.  For now, just get
distcheck back to working.

11 years agoFix distcheck by adding back protocol/Makefile.am
Kristian Høgsberg [Mon, 19 Nov 2012 22:11:58 +0000 (17:11 -0500)]
Fix distcheck by adding back protocol/Makefile.am

5909dddc78573774bd3a93c280831a7d18d82994 removed protocol/Makefile.am
which meant protocol/wayland.xml no longer got included in the tarball.
Add back protocol/Makefile.am and configure.ac bits and add protocol to
subdirs in Makefile.am to fix this.

11 years agoprotocol: Fix copy and paste summary
Kristian Høgsberg [Mon, 19 Nov 2012 20:44:14 +0000 (15:44 -0500)]
protocol: Fix copy and paste summary

11 years agoprotocol: Add summary description for wl_data_device_manager
Kristian Høgsberg [Mon, 19 Nov 2012 20:02:45 +0000 (15:02 -0500)]
protocol: Add summary description for wl_data_device_manager

11 years agoclient: Fix source comment typos
Martin Olsson [Wed, 14 Nov 2012 18:58:31 +0000 (13:58 -0500)]
client: Fix source comment typos

11 years agodoc: Fix incorrectly formatted section header
Tiago Vignatti [Tue, 6 Nov 2012 19:17:01 +0000 (17:17 -0200)]
doc: Fix incorrectly formatted section header

https://bugs.freedesktop.org/show_bug.cgi?id=56719

Reported-by: Petr Gladkikh <PetrGlad@gmail.com>
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agodoc: Update .gitignore
Tiago Vignatti [Fri, 9 Nov 2012 22:28:51 +0000 (20:28 -0200)]
doc: Update .gitignore

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agodoc: Set publican to quiet mode
Tiago Vignatti [Fri, 9 Nov 2012 22:48:22 +0000 (20:48 -0200)]
doc: Set publican to quiet mode

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agodoc: Remove unused css and xslt for the protocol
Tiago Vignatti [Fri, 9 Nov 2012 22:33:10 +0000 (20:33 -0200)]
doc: Remove unused css and xslt for the protocol

This was added previously (commit 015c42e1) when we didn't have docbook
formatted documentation. Now it became quite useless.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agodoc: Auto-generate API methods and classes documentation
Tiago Vignatti [Fri, 9 Nov 2012 22:14:31 +0000 (20:14 -0200)]
doc: Auto-generate API methods and classes documentation

There's work to do still for giving a prettier style on the documentation, for
instance splitting paragraphs correctly and printing the detailed description
of the methods as well.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agodoc: doxygen: Interpret the first line comment as the brief
Tiago Vignatti [Mon, 12 Nov 2012 18:07:16 +0000 (16:07 -0200)]
doc: doxygen: Interpret the first line comment as the brief

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agotests: Add out of order delete_id queue tests
Jonas Ådahl [Tue, 6 Nov 2012 07:15:04 +0000 (08:15 +0100)]
tests: Add out of order delete_id queue tests

Verify that when receiving the first of two synchronization callback
events, destroying the second one doesn't cause any errors even if the
delete_id event is handled out of order.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agotests: Use a pipe for synchronization to avoid potential deadlock
Jonas Ådahl [Tue, 6 Nov 2012 07:15:03 +0000 (08:15 +0100)]
tests: Use a pipe for synchronization to avoid potential deadlock

Using signals in the previous way could potentially lead to dead locks
if the SIGCONT was signalled before a listener was registered.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agotests: Add queue test case
Jonas Ådahl [Sat, 3 Nov 2012 21:26:11 +0000 (22:26 +0100)]
tests: Add queue test case

Check that after a callback removes a proxy that most likely will have
several events queued up with the same target proxy, no more callbacks
are invoked.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agoclient: Keep track of proxy validity and number of reference holders
Jonas Ådahl [Sat, 3 Nov 2012 21:26:10 +0000 (22:26 +0100)]
client: Keep track of proxy validity and number of reference holders

When events are queued, the associated proxy objects (target proxy and
potentially closure argument proxies) are verified being valid. However,
as any event may destroy some proxy object, validity needs to be
verified again before dispatching. Before this change this was done by
again looking up the object via the display object map, but that did not
work because a delete_id event could be dispatched out-of-order if it
was queued in another queue, causing the object map to either have a new
proxy object with the same id or none at all, had it been destroyed in
an earlier event in the queue.

Instead, make wl_proxy reference counted and increase the reference
counter of every object associated with an event when it is queued. In
wl_proxy_destroy() set a flag saying the proxy has been destroyed by the
application and only free the proxy if the reference counter reaches
zero after decreasing it.

Before dispatching, verify that a proxy object still is valid by
checking that the flag set in wl_proxy_destroy() has not been set. When
dequeuing the event, all associated proxy objects are dereferenced and
free:ed if the reference counter reaches zero. As proxy reference counter
is initiated to 1, when dispatching an event it can never reach zero
without having the destroyed flag set.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agodoc: Remove obsolete doxygen tags
Kristian Høgsberg [Mon, 29 Oct 2012 17:12:40 +0000 (13:12 -0400)]
doc: Remove obsolete doxygen tags

https://bugs.freedesktop.org/show_bug.cgi?id=56377

11 years agoconfigure.ac: Bump version to 1.0.0
Kristian Høgsberg [Mon, 22 Oct 2012 18:55:06 +0000 (14:55 -0400)]
configure.ac: Bump version to 1.0.0

11 years agoscanner: Preserve paragraph breaks in input XML
Kristian Høgsberg [Mon, 22 Oct 2012 02:24:33 +0000 (22:24 -0400)]
scanner: Preserve paragraph breaks in input XML

If we have a blank line in the incoming XML documentation, keep that in
the emitted doxygen comments.

11 years agodoc: Fix typo in generated section header
Kristian Høgsberg [Mon, 22 Oct 2012 02:10:56 +0000 (22:10 -0400)]
doc: Fix typo in generated section header

We were generating headers such as 'Events provided by wl_display events',
drop the last 'events'.

11 years agowayland: Add protocol documentation for various interfaces
Kristian Høgsberg [Mon, 22 Oct 2012 02:08:08 +0000 (22:08 -0400)]
wayland: Add protocol documentation for various interfaces

11 years agoUpdate TODO
Kristian Høgsberg [Mon, 22 Oct 2012 00:53:37 +0000 (20:53 -0400)]
Update TODO

We've knocked a few items of the list.

11 years agotests: Include wayland-private.h for container_of
Kristian Høgsberg [Sun, 21 Oct 2012 14:04:17 +0000 (10:04 -0400)]
tests: Include wayland-private.h for container_of

11 years agoscanner: Fix valgrind errors
Kristian Høgsberg [Sat, 20 Oct 2012 15:38:57 +0000 (11:38 -0400)]
scanner: Fix valgrind errors

11 years agoRename __wl_container_of macro to just wl_container_of
Kristian Høgsberg [Sat, 20 Oct 2012 03:26:38 +0000 (23:26 -0400)]
Rename __wl_container_of macro to just wl_container_of

The _* namespace and identifiers with double underscore are reserved
by the C standard.  That makes __wl_container_of is double plus bad,
so lets just call it wl_container_of.

11 years agoMove un-namespaced container_of into private header
Kristian Høgsberg [Sat, 20 Oct 2012 03:06:53 +0000 (23:06 -0400)]
Move un-namespaced container_of into private header

11 years agoMove ARRAY_LENGTH out of public headers
Kristian Høgsberg [Fri, 19 Oct 2012 21:08:38 +0000 (17:08 -0400)]
Move ARRAY_LENGTH out of public headers

Exporting unprefixed symbols is a pretty bad idea so don't do that.
Instea of redefining it WL_ARRAY_LENGTH, we just move the define to
our private header.  The scanner generates code that uses ARRAY_LENGTH,
but we can just make it count the number elements and emit an integer
constant instead.

11 years agoconfigure: Depend on a more strict version of publican
Tiago Vignatti [Fri, 19 Oct 2012 15:29:54 +0000 (18:29 +0300)]
configure: Depend on a more strict version of publican

Fix https://bugs.freedesktop.org/show_bug.cgi?id=56101

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agodoc: Update doxygen documentation when source files are changed
Ander Conselvan de Oliveira [Fri, 19 Oct 2012 12:30:26 +0000 (15:30 +0300)]
doc: Update doxygen documentation when source files are changed

11 years agodoc: Clarify documentation about dispatching event queues
Ander Conselvan de Oliveira [Fri, 19 Oct 2012 12:30:25 +0000 (15:30 +0300)]
doc: Clarify documentation about dispatching event queues

Clarify on what cases each of the dispatching functions may block, what
is the main thread and add some real world examples.

11 years agodoc: Update wl_display_get_error() documentation
Ander Conselvan de Oliveira [Wed, 17 Oct 2012 18:26:09 +0000 (21:26 +0300)]
doc: Update wl_display_get_error() documentation

11 years agowayland-server: Fix up error handling with client creation.
John Kåre Alsaker [Tue, 16 Oct 2012 18:32:19 +0000 (20:32 +0200)]
wayland-server: Fix up error handling with client creation.

11 years agowayland-egl: Drop ill-defined pixmap support
Kristian Høgsberg [Tue, 16 Oct 2012 19:30:56 +0000 (15:30 -0400)]
wayland-egl: Drop ill-defined pixmap support

We don't have a use case for this and the actual semantics and
synchronization behavior of wl_egl_pixmap were never really well-defined.
It also doesn't provide the cross-process buffer sharing that make
window systems pixmaps useful in other window systems.

11 years agoconnection: Dereference id completely for comparasion.
John Kåre Alsaker [Fri, 12 Oct 2012 09:28:28 +0000 (11:28 +0200)]
connection: Dereference id completely for comparasion.

11 years agoconnection: Removed crashing code.
John Kåre Alsaker [Fri, 12 Oct 2012 09:28:26 +0000 (11:28 +0200)]
connection: Removed crashing code.

11 years agoscanner: Make sure arguments have names.
John Kåre Alsaker [Fri, 12 Oct 2012 09:28:25 +0000 (11:28 +0200)]
scanner: Make sure arguments have names.

11 years agoconnection: Don't call memcpy with null pointer.
John Kåre Alsaker [Fri, 12 Oct 2012 09:28:24 +0000 (11:28 +0200)]
connection: Don't call memcpy with null pointer.

11 years agoprotocol: try to clarify wl_buffer doc
Pekka Paalanen [Fri, 12 Oct 2012 11:29:01 +0000 (14:29 +0300)]
protocol: try to clarify wl_buffer doc

Fix few typos in wl_buffer description.

Mention backing storage in wl_buffer.destroy.

Try to clarify the wl_buffer.release semantics by not explaining what
*might* happen. It is important to not suggest, that if release does not
come before frame callback, it will not come before attaching a new
buffer to the surface. We want to allow the following scenario:

The compositor is able to texture from wl_buffers directly, but it also
keeps a copy of the surface contents. The copy is updated when the
compositor is idle, to avoid the performance hit on
wl_surface.attach/commit. When the copy completes some time later, the
server sends the release event. If the client has not yet allocated a
second buffer (e.g. it updates rarely), it can reuse the old buffer.

Reported-by: John Kåre Alsaker <john.kare.alsaker@gmail.com>
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoprotocol: say update instead of repaint
Pekka Paalanen [Fri, 12 Oct 2012 11:29:00 +0000 (14:29 +0300)]
protocol: say update instead of repaint

wl_surface.commit itself does not force any repainting unless there is
damage, so change the wording to not imply repainting.

Reported-by: John Kåre Alsaker <john.kare.alsaker@gmail.com>
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agodoc: Add doxygen documentation to wl_display_get_error()
Ander Conselvan de Oliveira [Tue, 16 Oct 2012 14:29:09 +0000 (17:29 +0300)]
doc: Add doxygen documentation to wl_display_get_error()

11 years agodoc: Document change of return value of dispatch functions
Ander Conselvan de Oliveira [Tue, 16 Oct 2012 14:29:08 +0000 (17:29 +0300)]
doc: Document change of return value of dispatch functions

11 years agodoc: Document the restriction of destroying queues before the display
Ander Conselvan de Oliveira [Tue, 16 Oct 2012 14:29:07 +0000 (17:29 +0300)]
doc: Document the restriction of destroying queues before the display

11 years agodoc: Put wl_display_flush() documentation in the right place
Ander Conselvan de Oliveira [Tue, 16 Oct 2012 14:29:06 +0000 (17:29 +0300)]
doc: Put wl_display_flush() documentation in the right place

It seems a rebase error caused it to end up in the wrong place.

11 years agoprotocol: Clarify pointer axis event
Jonas Ådahl [Wed, 3 Oct 2012 20:50:55 +0000 (22:50 +0200)]
protocol: Clarify pointer axis event

Pointer axis events are in the same coordinate space as motion events.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agoconfigure.ac: Bump version to 0.99.0
Kristian Høgsberg [Tue, 16 Oct 2012 00:49:41 +0000 (20:49 -0400)]
configure.ac: Bump version to 0.99.0

11 years agodocs: Make distcheck happy
Kristian Høgsberg [Tue, 16 Oct 2012 00:48:12 +0000 (20:48 -0400)]
docs: Make distcheck happy

publican doesn't seem to be a very well-behaved tool and needs a bit
of hacking to work well for both in-tree and out-of-tree builds.

11 years agowayland-server: Add touch grab support
Matt Roper [Wed, 10 Oct 2012 23:56:52 +0000 (16:56 -0700)]
wayland-server: Add touch grab support

Touch grabs allow the compositor to be placed into a mode where touch events
temporarily bypass their default behavior and perform other operations.
Wayland already supports keyboard and pointer grabs, but was lacking
corresponding touch support.  The default touch grab handlers here contain the
client event delivery code that was previously called directly in weston.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
11 years agowayland-client: forward fatal errors to caller
David Herrmann [Thu, 11 Oct 2012 21:37:53 +0000 (23:37 +0200)]
wayland-client: forward fatal errors to caller

If any callback or helper function fails with a fatal error, we now
set the last_error flag and prevent all further I/O on the wl_display. We
wake up all sleeping event-queues and notify the caller that they
should shutdown wl_display.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agowayland: Take ownership of fd in wl_display_connect_to_fd()
Kristian Høgsberg [Mon, 15 Oct 2012 21:50:36 +0000 (17:50 -0400)]
wayland: Take ownership of fd in wl_display_connect_to_fd()

This means we're free to close it when we want, which we'll use to wake
up the main thread if we hit an error in a different thread.

11 years agowayland-client: link all event-queues of each display into a list
David Herrmann [Thu, 11 Oct 2012 21:37:51 +0000 (23:37 +0200)]
wayland-client: link all event-queues of each display into a list

We need access to all event-queues of a single wl_display object. For
instance during connection-errors, we need to be able to wake up all event
queues. Otherwise, they will be stuck waiting for incoming events.

The API user is responsible to keep a wl_display object around until all
event-queues that were created on it are destroyed.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconnection: return error on buffer-overflow during read
Kristian Høgsberg [Mon, 15 Oct 2012 21:19:38 +0000 (17:19 -0400)]
connection: return error on buffer-overflow during read

wl_connection_read() assumes that the caller dispatched all messages
before calling it. wl_buffer_put_iov() does only provide enough room so we
fill the buffer. So the only case when the buffer overflows, is when a
previous read filled up the buffer but we couldn't parse a single message
from it. In this case, the client sent a message bigger than our buffer
and we should return an error and close the connection.

krh: Edited from Davids original patch to just check that the buffer
 isn't full before we try reading into it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconnection: Use uin32_t for circular buffer indexes
Kristian Høgsberg [Mon, 15 Oct 2012 21:16:30 +0000 (17:16 -0400)]
connection: Use uin32_t for circular buffer indexes

We rely on well-defined unsigned overflow behaviour so let's make the
index fields actually unsigned.  Signed ints aren't guaranteed to have the
behavior we want (could be either ones or twos complement).

11 years agoconnection: fix leaking FDs on buffer-overflow during read
David Herrmann [Thu, 11 Oct 2012 21:37:49 +0000 (23:37 +0200)]
connection: fix leaking FDs on buffer-overflow during read

If we read more FDs than we have room for, we currently leak FDs because
we overwrite previous still pending FDs. Instead, we do now close incoming
FDs if the buffer is full and return EOVERFLOW.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconnection: fix buffer-overflow in build_cmsg()
David Herrmann [Thu, 11 Oct 2012 21:37:48 +0000 (23:37 +0200)]
connection: fix buffer-overflow in build_cmsg()

Same problem as we had with close_fds(). We cannot rely on the fds_out
buffer being filled with less than MAX_FDS_OUT file descriptors.
Therefore, write at most MAX_FDS_OUT file-descriptors to the outgoing
buffer.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconnection: close pending incoming FDs on shutdown
David Herrmann [Thu, 11 Oct 2012 21:37:47 +0000 (23:37 +0200)]
connection: close pending incoming FDs on shutdown

Same problem as with outgoing FDs. We need to close these on shutdown,
otherwise we leak open file descriptors.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconnection: fix buffer-overflow in close_fds()
David Herrmann [Thu, 11 Oct 2012 21:37:46 +0000 (23:37 +0200)]
connection: fix buffer-overflow in close_fds()

If we push two messages via wl_connection_write() and both messages
contain more than MAX_FDS_OUT file-descriptors combined, then
wl_connection_flush() will write only MAX_FDS_OUT of them, but close all
pending ones, too.

Furthermore, close_fds() will copy more FDs out of the buffer than it can
hold and cause a buffer overflow. Therefore, we simply pass a maximum
limit to close_fds().

During shutdown, we simply close all available FDs.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconnection: close pending outgoing fds on shutdown
David Herrmann [Thu, 11 Oct 2012 21:37:45 +0000 (23:37 +0200)]
connection: close pending outgoing fds on shutdown

When destroying a wl_connection object, there might still be data in the
queue. We would leak open file-descriptors so we must close them.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agowayland-util: return 0 on OOM in wl_map_insert_new()
David Herrmann [Thu, 11 Oct 2012 21:37:44 +0000 (23:37 +0200)]
wayland-util: return 0 on OOM in wl_map_insert_new()

If we cannot increase the array for new entries, we now return 0 instead
of accessing invalid memory.

krh: Edited to return 0 on failure instead.  In the initialization path,
we call wl_map_insert_new() to insert NULL at index 0, which also returns
0 but not as an error.  Since we do that up front, every other case of
returning 0 is an unambiguous error.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agowayland-util: return -1 if wl_array_copy() fails
David Herrmann [Thu, 11 Oct 2012 21:37:43 +0000 (23:37 +0200)]
wayland-util: return -1 if wl_array_copy() fails

We might have to perform memory allocations in wl_array_copy(), so catch
out-of-memory errors in wl_array_add() and return -1 before changing any
state.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agowayland-client: add wl_display_get_error()
David Herrmann [Thu, 11 Oct 2012 21:37:42 +0000 (23:37 +0200)]
wayland-client: add wl_display_get_error()

A server may asynchronously send errors via wl_display.error() events.
Instead of aborting we now the a "last_error" flag inside of wl_display
objects. The user can retrieve these via wl_display_get_error().

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoprotocol: Clarify pointer axis event
Jonas Ådahl [Thu, 27 Sep 2012 16:40:26 +0000 (18:40 +0200)]
protocol: Clarify pointer axis event

Pointer axis events are in the same coordinate space as motion events.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
11 years agoconfigure: Make documentation option work in fact
Tiago Vignatti [Fri, 12 Oct 2012 17:54:45 +0000 (20:54 +0300)]
configure: Make documentation option work in fact

Also, now doxygen is mandatory for building the documentation (looks
reasonable because both man-pages and publican will need it).

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agodoc: doxygen: Add .gitignore
Tiago Vignatti [Fri, 12 Oct 2012 17:03:44 +0000 (20:03 +0300)]
doc: doxygen: Add .gitignore

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agodoc: Improve libwayland-client doxygen documentation
Ander Conselvan de Oliveira [Mon, 15 Oct 2012 14:53:23 +0000 (17:53 +0300)]
doc: Improve libwayland-client doxygen documentation

Document wl_proxy, wl_display and wl_event_queue classes and add a
description to all public entry points. Also fix some typos.

11 years agodoc: Add some doxygen documentation to wayland-client entry points
Ander Conselvan de Oliveira [Fri, 12 Oct 2012 14:28:57 +0000 (17:28 +0300)]
doc: Add some doxygen documentation to wayland-client entry points

Add some brief documentation for the public libwayland-client entry
points. This is by no means complete, some functions are still
undocumented and some might need extra information.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agodoc: Split protocol description paragraphs properly
Ander Conselvan de Oliveira [Fri, 12 Oct 2012 14:28:56 +0000 (17:28 +0300)]
doc: Split protocol description paragraphs properly

The xsl translation from the protocol xml to publican would create only
one paragraph for all the text in a description. Make it generate one
paragraph for each block of text separated by two consecutive line
breaks instead.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agoscanner: use printf format attributes for desc_dump
Olivier Blin [Sun, 14 Oct 2012 22:49:13 +0000 (00:49 +0200)]
scanner: use printf format attributes for desc_dump

11 years agoscanner: fix writing i586 descriptions
Olivier Blin [Sun, 14 Oct 2012 22:49:11 +0000 (00:49 +0200)]
scanner: fix writing i586 descriptions

This moves desc as first argument of desc_dump().
Description writing was broken on i586 because desc_dump() used
va_arg() after a vsnprintf() call to find the last argument.
But after calling a function with a va_arg argument, this arguments is
undefined.

11 years agoscanner: remove useless desc_dump arguments
Olivier Blin [Sun, 14 Oct 2012 22:49:11 +0000 (00:49 +0200)]
scanner: remove useless desc_dump arguments

This are remnant from the desc_dump generalization in commit 375cb418.

11 years agodoc: Add auto-generated Wayland Library chapter
Tiago Vignatti [Thu, 11 Oct 2012 14:42:09 +0000 (17:42 +0300)]
doc: Add auto-generated Wayland Library chapter

For now only Wayland Client API is described on that chapter, which is
extracted via doxygen on ./src/wayland-client.h. We apply a stylesheet
(doxygen-to-publican) on doxygen output so it becomes docbook valid.

Now all we need to do is populate that header while developing in order to
grow a decent documentation. So please use it!

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agodoc: Remove superfluous 'index'
Tiago Vignatti [Thu, 11 Oct 2012 14:42:08 +0000 (17:42 +0300)]
doc: Remove superfluous 'index'

We're not setting any sort of index. Remove for now.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agodoc: publican: Automate version generation
Tiago Vignatti [Thu, 11 Oct 2012 14:42:07 +0000 (17:42 +0300)]
doc: publican: Automate version generation

It seems reasonable to use protocol's version for the documentation as well.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agodoc: publican: Set table of contents depth to 1
Tiago Vignatti [Thu, 11 Oct 2012 14:42:06 +0000 (17:42 +0300)]
doc: publican: Set table of contents depth to 1

This way looks more pretty, in particular for the Appendix which spawns a big
subsections chain.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
11 years agoclient: Return number of events dispatched from dispatch functions
Kristian Høgsberg [Mon, 15 Oct 2012 15:38:20 +0000 (11:38 -0400)]
client: Return number of events dispatched from dispatch functions

To let clients determine whether any events were dispatched, we return
the number of dispatched events.  An event source with an event queue
(such as wl_display or an X connection) may queue up event as a result of
processing a different event source (data on a network socket, timerfd etc).

After dispatching data from fd (or just before blocking) we have to check
such event sources, which is what wl_event_source_check() is used for.
A checked event source will have its handler called with mask=0 just
before blocking.  If any work is done in any of these handlers, we have
to check all the checked sources again, since the work could have queued up
events in a different source.  This is why the event handlers must return
a positive number if events were handled.  Which in turn is why we need
the wl_display dispatch functions to return that as well.

11 years agoclient: Add wl_display_dispatch_pending() for dispatching without reading
Kristian Høgsberg [Thu, 11 Oct 2012 21:15:08 +0000 (17:15 -0400)]
client: Add wl_display_dispatch_pending() for dispatching without reading

If the main thread ends up dispatching a non-main queue, and not in
a wl_display_dispatch() callback, we may queue up main queue events and read
all data from the socket fd.  When we get back to the main loop, the
socket fd is no longer readable and nothing will trigger dispatching of
the queued up events.

The new function wl_display_dispatch_pending() will dispatch any pending
events, but not attempt to read from the socket.  Clients that integrate
the wayland socket fd into a main loop should call
wl_display_dispatch_pending() and then wl_display_flush()
before going back to blocking in poll(2) or similar mechanism.

11 years agoclient: Discard proxies with no implementation at dispatch time
Kristian Høgsberg [Thu, 11 Oct 2012 21:12:50 +0000 (17:12 -0400)]
client: Discard proxies with no implementation at dispatch time

We need to queue up events even if a proxy doesn't have an implementation
(listener).  In case of server created new objects, the client haven't
had a chance to set the listener when the first events to the new object
come in.  So now we always queue up events and discard them at
dispatch time if they don't have a listener at that point.

11 years agoclient: Don't forget to init and destroy mutex
Kristian Høgsberg [Thu, 11 Oct 2012 21:11:54 +0000 (17:11 -0400)]
client: Don't forget to init and destroy mutex

These chunks were dropped at some point, thanks to David Herrmann for
spotting the omission.

11 years agoconnection: Print object id for new-id arguments in deubug output
Kristian Høgsberg [Thu, 11 Oct 2012 21:08:29 +0000 (17:08 -0400)]
connection: Print object id for new-id arguments in deubug output

We can't use the same behaviour in both the client and the server.  In the
client this is a wl_proxy pointer in the server it's a pointer to the
uint32_t object id.  This doesn't fix the problem, but it's a slightly
more useful default, since we typically use WAYLAND_DEBUG on the client.

11 years agoclient: Fix double locking bug
Ander Conselvan de Oliveira [Thu, 11 Oct 2012 11:55:59 +0000 (14:55 +0300)]
client: Fix double locking bug

The function wl_proxy_create_for_id() would try to acquire the display
lock, but the only call path leading to it would call it with the lock
already acquired.

This patch removes the attempt to acquire the lock and makes the
function static. It was exported before because client had to create
proxy's manually when the server sent a new object id, but since commit
9de9e39f [1] this is no longer necessary.

[1] commit 9de9e39f87adfce1ea9755e394928756254c0ba2
    Author: Kristian Høgsberg <krh@bitplanet.net>
    Date:   Thu Jun 28 22:01:58 2012 -0400

        Allocate client proxy automatically for new objects

v2: Change the right function. Previous patch changed wl_proxy_create()
    instead of wl_proxy_create_for_id().

11 years agoprotocol: clarify multiple wl_surface.attach
Pekka Paalanen [Thu, 11 Oct 2012 11:31:11 +0000 (14:31 +0300)]
protocol: clarify multiple wl_surface.attach

Explicitly say what happens with the wl_buffer.release event, if you
attach several wl_buffers without a commit in between.

Reported-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agodata-device: Don't fake an attach event on drag icon surface
Ander Conselvan de Oliveira [Thu, 11 Oct 2012 11:05:37 +0000 (14:05 +0300)]
data-device: Don't fake an attach event on drag icon surface

Emit a new drag icon signal instead and let the compositor handle the
unmapping of the icon surface.

11 years agoprotocol: fix clarification of input region on drags and pointers
Pekka Paalanen [Thu, 11 Oct 2012 10:58:45 +0000 (13:58 +0300)]
protocol: fix clarification of input region on drags and pointers

The previous clarification did not follow the current implementation in
Weston, where when a surface stops being a cursor or an icon, it becomes
a plain unmapped surface again.

Rewrite the related paragraphs, and fix some typos while at it.

For start drag, make it explicit of which surface argument we are
talking about.

v2:

Make the input region undefined when the use ends. Most likely no-one
will re-use these surfaces for anything else than the same use case, so
leave some slack for the implementations to avoid useless work on
resetting the regions.

Reported-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoprotocol: elaborate on wl_buffer
Pekka Paalanen [Wed, 10 Oct 2012 09:47:50 +0000 (12:47 +0300)]
protocol: elaborate on wl_buffer

Spell out exactly when a client may re-use a wl_buffer or its backing
storage. Mention the optimization for GL-compositor with wl_shm-clients.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoprotocol: wl_surface.frame needs wl_surface.commit
Pekka Paalanen [Wed, 10 Oct 2012 09:47:49 +0000 (12:47 +0300)]
protocol: wl_surface.frame needs wl_surface.commit

Clarify, when frame request takes effect.
Explain when to send/receive the callback.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoprotocol: clarify input region on drags and pointers
Pekka Paalanen [Wed, 10 Oct 2012 09:47:48 +0000 (12:47 +0300)]
protocol: clarify input region on drags and pointers

Drag icon and cursor surfaces must never receive input, so their input
region is always empty.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoprotocol: double-buffered state for wl_surface
Pekka Paalanen [Wed, 10 Oct 2012 09:47:47 +0000 (12:47 +0300)]
protocol: double-buffered state for wl_surface

This change breaks the protocol.

The current protocol is racy in that updates to surface content and
surface state (e.g. damage, input and opaque regions) are not guaranteed
to happen at the same time. Due to protocol buffering and handling
practices, the issues are very hard to trigger.

Committing damage to a surface at arbitrary times makes it hard to
track when the wl_buffer is being read by the server, and when it is
safe to overwrite (the case of wl_shm with a single buffer reused
constantly).

This protocol change introduces the concept of double-buffered state.
Such state is accumulated and cached in the server, unused, until the
final commit request. The surface will receive its new content and apply
its new state atomically.

A wl_surface.commit request is added to the protocol. This is thought to
be more clear, than having wl_surface.attach committing implicitly, and
then having another request to commit without attaching, as would be
required for a GL app that wants to change e.g. input region without
redrawing.

When these changes are implemented, clients do not have to worry about
ordering damage vs. input region vs. attach vs. ... anymore. Clients set
the state in any order they want, and kick it all in with a commit.

The interactions between wl_surface.attach, (wl_surface.commit,)
wl_buffer.release, and wl_buffer.destroy have been undocumented. Only
careful inspection of the compositor code has told when a wl_buffer is
free for re-use, especially for wl_shm and wrt. wl_surface.damage.
Try to clarify how it all should work, and what happens if the wl_buffer
gets destroyed.

An additional minor fix: allow NULL argument to
wl_surface.set_opaque_region. The wording in the documentation already
implied that a nil region is allowed.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
11 years agoFix typecheck in case of multiple instances of type meta data
Kristian Høgsberg [Wed, 10 Oct 2012 23:25:48 +0000 (19:25 -0400)]
Fix typecheck in case of multiple instances of type meta data

In most cases the pointer equality test is sufficient.  However, in
some cases, depending on how things are split across shared objects,
we can end up with multiple instances of the interface metadata
constants.  So if the pointers match, the interfaces are equal, if
they don't match we have to compare the interface names.

11 years agodoc: Update drag and drop section and add info about selections
Ander Conselvan de Oliveira [Wed, 10 Oct 2012 20:29:13 +0000 (23:29 +0300)]
doc: Update drag and drop section and add info about selections

Replace the outdated section about drag and drop support with a
rewritten section covering the data source/offer mechanism and
wl_data_device, explaining how selection and drag ang drop works.

11 years agoconnection: Move object lookup out of wl_connection_demarshal()
Kristian Høgsberg [Tue, 9 Oct 2012 16:14:34 +0000 (12:14 -0400)]
connection: Move object lookup out of wl_connection_demarshal()

On the client side where we queue up multiple events before dispatching, we
need to look up the receiving proxy and argument proxies immediately before
calling the handler.  Between queueing up multiple events and eventually
invoking the handler, previous handlers may have destroyed some of the
proxies.

11 years agoSplit the global registry into its own wl_registry object
Kristian Høgsberg [Mon, 8 Oct 2012 17:53:47 +0000 (13:53 -0400)]
Split the global registry into its own wl_registry object

The only way to make the global object listener interface thread safe is to
make it its own interface and make different listeners different wl_proxies.
The core of the problem is the callback we do when a global show up or
disappears, which we can't do with a lock held.  On the other hand we can't
iterate the global list or the listener list without a lock held as new
globals or listeners may come and go during the iteration.

Making a copy of the list under the lock and then iterating after dropping
the lock wont work either.  In case of the listener list, once we drop the
lock another thread may unregister a listener and destroy the callbackk
data, which means that when we eventually call that listener we'll pass it
free memory and break everything.

We did already solve the thread-safe callback problem, however.  It's what
we do for all protocol events.  So we can just make the global registry
functionality its own new interface and give each thread its own proxy.
That way, the thread will do its own callbacks (with no locks held) and
destroy the proxy when it's no longer interested in wl_registry events.