Add a wl_resource_instance_of function

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Change SHM wl_buffer functions to use the wl_shm_buffer structure

This commit does not break ABI.  It merely changes the types of some things
and adds a wl_shm_buffer_get function.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Change wl_shm_buffer to use a resource pointer

This commit also has the effect of making wl_shm_buffer no longer a
wl_buffer derivative.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
protocol: add no_keymap format to keymap formats

This format is used to specify that the key button events received are not in
relation to any key map and that the codes should be interpreted directly.

v2: Use zero for the no keymap enum value and enhance the documentation
for the enum entry.
server: Make wl_object and wl_resource opaque structs

With the work to add wl_resource accessors and port weston to use them,
we're ready to make wl_resource and wl_object opaque structs.  We keep
wl_buffer in the header for EGL stacks to use, but don't expose it by
default.  In time we'll remove it completely, but for now it provides a
transition paths for code that still uses wl_buffer.

Reviewed-by: Jason Ekstrand<jason@jlekstrand.net>
Add version information to wl_message signatures.

This commit adds version information to wl_message signatures and a
wl_message_get_since function to retrieve.  The since version comes in the
form of a (possible) integer at the begining of the message.  If the
message starts with an integer, then it specifies the "since" version of
that message.  Messages present in version one do not get this "since"
information.  In this way we can run-time detect the version information
for a structure on a per-message basis.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Add wl_resource_create() and a version field to wl_resource

A new function, wl_resource_create(), lets the compositor create a
wl_resource for a given version of the interface.  Passing 0 for the
object ID will allocate a new ID. The implementation, user data and
destructor can be set with wl_resource_set_implementation().

These two functions deprecates wl_client_add/new_object and the
main difference and motivation is the ability to provide a version number
for the resource.  This lets the compositor track which version of the
interface a client has created and we'll use that to verify incoming requests.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
wayland-server: Verify request versions before invoking handler

This commit provides a layer of protection for the compositor in the form
of message version checking.  We track version information in the
wl_resource and now use this version information to verify that a request
exists in that protocol version before invoking it.  This way libwayland
won't accidentally invoke a request that does not exist and thereby cause
the compositor to crash.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
wayland-server: Dont free resource in user data destroy callback
wayland-server: Mark wl_client_add/new_object as deprecated
wayland-server: Remove error event posting from wl_resource_create

The wl_client_add/new_object() functions sends out an NO_MEMORY error if
the allocation fails.  This was convenient in a couple of places where
that was all the error handling that was needed.  Unfortunately that
looks like out-of-memory isn't handled at the call site and set a bad
precedent for not cleaning up properly or not handling at all.

As we're introducing wl_resource_create() as a replacement for those two
functions, let's remove the automatic error event posting and require
the caller to do that if necessary.

This commit also introduces a new helper, wl_client_post_no_memory() to
make it possible to send NO_MEMORY events from bind where we don't have
a wl_resource.
wayland-server: Remove left-over double free in unbind_resource() helper
wayland-server: Free non-legacy wl_resource structs during wl_client_destroy

We need to free the non-legacy resources during client shutdown as well.