Commit graph

84 commits

Author SHA1 Message Date
Aaron Faanes
5a92553237 doc: Slight tweaks to wl_listener
Prefer \comment over // in code blocks for consistency's sake and keep
variable definitions separated by a line from the rest of the body.
2013-09-21 11:31:50 -07:00
Aaron Faanes
5197aa30c8 wayland-server: Improve wording for wl_signal_get's doc
The old description was a bit vague; this commit hopefully improves
describing what is returned.
2013-09-16 21:59:28 -07:00
Aaron Faanes
bc30c5eb8a utils: Reference some useful methods in wl_signal's doxygen
This commit adds a bit more detail on the lifecycle of a signal.
2013-09-16 21:59:00 -07:00
Aaron Faanes
f8b2730039 wayland-server: Document wl_listener
This patch takes Kristian's comments into account, adding a demonstration and
giving a more thorough idea of how wl_listener is used.
2013-09-16 21:47:52 -07:00
Rob Bradford
656f3ea5b3 wayland-server: Add a wl_resource_for_each_safe macro
A version of wl_resource_for_each that is safe for iteration when items
in the list are removed.
2013-09-11 12:03:22 -07:00
Aaron Faanes
660f2d7acc wayland-server: Document wl_signal 2013-09-11 10:52:41 -07:00
Jason Ekstrand
c44090908d Add support for server-side language bindings
This commit adds support for server-side languages bindings.  This is done
in two ways:

1. Adding a wl_resource_set_dispatcher function that corresponds to
wl_resource_set_interface.  The only difference between the two functions
is that the new version takes a dispatcher along with the implementation,
data, and destructor.  This allows for runtime calling of native language
functions for callbacks instead of having to generate function pointers.

2. Adding versions of wl_resource_post_event and wl_resource_queue_event
that take an array of wl_argument instead of a variable argument list.
This allows for easier run-time argument conversion and removes the need
for libffi-based calling of variadic functions.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-08-19 16:23:08 -07:00
Rob Bradford
748c20c46f wayland-server: Add a wl_resource_for_each macro
This macro allows you to correctly iterate through a list of resources
handling the opaque nature of this type.
2013-08-12 16:26:36 -07:00
Tomeu Vizoso
d9883a6be1 shm: Add API for renderers to register additional pixel formats 2013-08-06 16:48:02 -07:00
Kristian Høgsberg
4cffa0fd61 wayland-server: Add wl_global_create/destroy()
This patch introduces wl_global_create() and wl_global_destroy() as
replacements for wl_display_add_global() and wl_display_remove_global().
The add/remove_global API did not allow a compositor to indicate
the implemented version of a global, it just took the version from
the interface meta data.  The problem is that the meta data
(which lives in libwayland-server.so) can get out of sync with a
compositor implementation.  The compositor will then advertise a
higher version of a global than what it actually implements.

The new API lets a compositor pass in a version when it registers
a global, which solves the problem.  The add/remove API is deprecated
with this patch and will be removed.
2013-07-09 01:15:37 -04:00
Kristian Høgsberg
c82a52a47e 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.
2013-07-02 17:01:46 -04:00
Kristian Høgsberg
b5b1165008 wayland-server: Mark wl_client_add/new_object as deprecated 2013-07-02 17:01:46 -04:00
Jason Ekstrand
4917a967bd 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>
2013-07-02 17:01:23 -04:00
Kristian Høgsberg
d94a8722cb 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>
2013-07-02 15:52:47 -04:00
Jason Ekstrand
3af748b872 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>
2013-06-21 19:18:08 -04:00
Jason Ekstrand
ee0d986a50 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>
2013-06-21 19:18:06 -04:00
Jason Ekstrand
5ac5d55d81 Add a wl_resource_instance_of function
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-21 19:18:04 -04:00
Jason Ekstrand
61ac9c6849 server: Add aditional wl_resource accessors
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-14 15:56:08 -04:00
Kristian Høgsberg
bca4124045 server: Add wl_resource_get_id() 2013-06-07 01:00:30 -04:00
Jason Ekstrand
1488c96a5d Add accessor functions for wl_resource and deprecate wl_client_add_resource
This is the first step towards making wl_resource an opaque pointer type.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-05 00:59:08 -04:00
Kristian Høgsberg
508dd69b56 server: Drop struct wl_surface
This struct was only defined in the server API for the purpose of the
input structs and helper functions.  Now that those are gone we can dro it.
2013-05-08 09:45:59 -04:00
Kristian Høgsberg
e920572e5c Remove input structs
Looking at the functionality in the server library, it's clear (in
hindsight) that there are two different "things" in there: 1) The IPC
API, that is, everything that concerns wl_display, wl_client,
wl_resource and 2) and half-hearted attempt at sharing input code and
focus logic that leaves a lot of problematic structs in the API
surface, only to share less than 1000 lines of code.

We can just move those input structs and helper functions into weston
and cut libwayland-server down to just the core server side IPC API.
In the short term, compositors can copy those structs and functions
into their source, but longer term, they're probably better off
reimplementing those objects and logic their native framework
(QObject, GObject etc).
2013-05-07 09:10:49 -04:00
Rob Bradford
db19b443cc wayland-server: Listen for pointer current surface destruction
Add a destroy listener so that when the current surface associated with the
pointer is destroyed we can reset the pointer to the current surface. In order
to achieve this add a wl_pointer_set_current() which handles assigning the
surface and creating the listener.

This resolves a use-after-free error triggered with nested popup surfaces

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=696946
2013-04-03 12:46:57 -04:00
Giulio Camuffo
6ca428edc8 server: use the right function pointer type in wl_signal_get
use the wl_notify_func type, and not void *, or else wl_signal_get
will not be usable by a c++ plugin because it will not cast
void * to a function pointer.
2013-04-02 17:11:44 -04:00
Jason Ekstrand
bedc3432ff Add wl_resource_init and use it in libwayland implementations of data sharing and SHM
This commit adds a wl_resource_init function for initializing wl_resource
structures similar to wl_client_add_object.

From this commit forward, wl_resource structures should not be initialized
manually, but should use wl_resource_init.  In the event of a change to the
wl_resource structure, this allows us to protect against regressions by filling
in added fields with reasonable defaults.  In this way, while changing
wl_object or wl_resource still constitutes an ABI break, compositors following
this rule will only need to be recompiled in order to properly link against the
new version.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-03-18 23:04:32 -04:00
Jason Ekstrand
2423497b99 Add a destroy signal to the wl_event_loop object 2013-01-15 14:05:27 -05:00
Jason Ekstrand
31511d0ea0 Added a destroy signal to the wl_display object.
Added a destroy signal to the wl_display object.
2013-01-11 15:52:39 -05:00
Matt Roper
4ce294d641 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>
2012-10-15 19:44:08 -04:00
Kristian Høgsberg
53d24713a3 Change filedescriptor API to be thread safe
The update callback for the file descriptors was always a bit awkward and
un-intuitive.  The idea was that whenever the protocol code needed to
write data to the fd it would call the 'update' function.  This function
would adjust the mainloop so that it polls for POLLOUT on the fd so we
can eventually flush the data to the socket.

The problem is that in multi-threaded applications, any thread can issue
a request, which writes data to the output buffer and thus triggers the
update callback.  Thus, we'll be calling out with the display mutex
held and may call from any thread.

The solution is to eliminate the udpate callback and just require that
the application or server flushes all connection buffers before blocking.
This turns out to be a simpler API, although we now require clients to
deal with EAGAIN and non-blocking writes.  It also saves a few syscalls,
since the socket will be writable most of the time and most writes will
complete, so we avoid changing epoll to poll for POLLOUT, then write and
then change it back for each write.
2012-10-10 20:59:00 -04:00
David Herrmann
003a946aa6 event-loop: export wl_event_loop_dispatch_idle()
When integrating the wayland event-loop into another event-loop, we
currently have no chance of checking whether there are pending idle
sources that have to be called. This patch exports the
"dispatch_idle_sources()" call so other event loops can call this before
going to sleep. This is what wl_event_loop_dispatch() currently does so we
simply allow external event-loops to do the same now.

To avoid breaking existing applications, we keep the call to
dispatch_idle_sources() in wl_event_loop_dispatch() for now. However, if
we want we can remove this later and require every application to call
this manually. This needs to be discussed, but the overhead is negligible
so we will probably leave it as it is.

This finally allows to fully integrate the wayland-server API into
existing event-loops without any nasty workarounds.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-09-12 12:28:54 -04:00
David Herrmann
9fe135c46f wayland-server: return new ID in wl_client_add_resource()
wl_client_add_resource() used to return no error even though the new
resource wasn't added to the client. This currently makes it very easy to
DOS weston by simply posting thousands of "create_surface" requests with
an invalid ID. Weston simply assumes the wl_client_add_resource() request
succeeds but will never destroy the surface again as the "destroy" signal
is never called (because the surface isn't linked into the wl_map).

This change makes wl_client_add_resource() return the new ID of the added
object and 0 on failure. Servers (like weston) can now correctly
immediately destroy the surface when this call fails instead of leaving
the surface around and producing memory-leaks.

Instead of returning -1 on failure and 0 on success, I made it return the
new ID as this seems more appropriate. We can directly use it when calling
it with new_id==0.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-09-10 21:44:47 -04:00
Kristian Høgsberg
7d3ccec18e Add wl_shm_buffer_create() 2012-08-16 10:49:48 -04:00
Kristian Høgsberg
7ba218c9f8 shm: Add shm_buffer getters for width and height 2012-07-20 12:04:42 -04:00
Daniel Stone
bcefacb89d Maintain keyboard modifier state in wayland-server
Provide a slot for keyboard modifier state inside wl_keyboard for
implementations to update, and use this to send wl_keyboard:;modifier
events whenever the keyboard or pointer focus changes.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-22 11:06:44 -04:00
Jonas Ådahl
1432bd62df wayland-server: Add destroy signal to wl_seat
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2012-06-12 20:18:42 -04:00
Kristian Høgsberg
aa792ad3d6 Add a focus change signal for wl_pointer and wl_keyboard 2012-06-05 09:56:42 -04:00
Kristian Høgsberg
68f058ffd3 data-device: Don't implement data source through data offer object
The wl_data_source object used to specify the implementation for data
offers created for it.  This means you need a data offer to retrieve the
data from the source, which makes it awkward to use in-process in a
compositor.  Now we instead have three virtual functions that can be
connected to a protocol object or in-process data-sources such as an
X server proxy or clipboard.
2012-06-03 17:30:12 -04:00
Daniel Stone
9a1705c5f5 wl_keyboard: Add modifier event
This event sends the current keyboard modifier/group state from the
compositor to the client, allowing all clients to have a consistent view
of the keyboard state (e.g. current layout, Caps Lock, et al).  It
should be sent after a keyboard enter event, and also immediately after
any key event which changes the modifier state.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-31 14:01:56 -04:00
Martin Minarik
8e2a786703 Wayland: logging
The core libwayland libraries should not handle logging, only passing
the error messages to subscribed functions.
An application linked to libwayland-server or libwayland-client
will be able to set own functions (one per library) to handle error
messages.

Change in this series: make the wl_log return int, because
of compatibility with printf. It will return the number of bytes logged.
2012-05-31 13:57:15 -04:00
Ander Conselvan de Oliveira
75a5f7476a data-device: implement drags with no data source for self-dnd
Properly handle a drag with no data source, i.e., don't crash and send
events only to the client that initiated the drag. This way a client can
do self drag and drop without offering anything to other clients.
2012-05-29 09:58:13 -04:00
Daniel Stone
aa0fb0f49c Convert wl_input_device to wl_seat (and friends)
wl_input_device has been both renamed and split.  wl_seat is now a
virtual object representing a group of logically related input devices
with related focus.

It now only generates one event: to let clients know that it has new
capabilities.  It takes requests which hand back objects for the
wl_pointer, wl_keyboard and wl_touch interfaces it exposes which all
provide the old input interface, just under different names.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-16 14:19:22 -04:00
Daniel Stone
0c20496e1a Input: Convert pointer co-ordinates to signed_24_8
This offers more precision when using devices like tablets, and also for
transformed surfaces.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08 14:40:46 -04:00
Daniel Stone
c5aba11acc Add support for signed 24.8 decimal numbers
'fixed' is a signed decimal type which offers a sign bit, 23 bits of
integer precision, and 8 bits of decimal precision.  This is exposed as
an opaque struct with conversion helpers to and from double and int on
the C API side.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08 14:40:39 -04:00
Daniel Stone
3f7048e0e9 Use unsigned for key/button up/down state in grabs
Since we just use it as a simple boolean flag, might as well convert it
to unsigned.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-07 12:15:14 -04:00
Kristian Høgsberg
ac73a74f43 Add wl_client_get_object() 2012-04-27 11:28:06 -04:00
Kristian Høgsberg
4fd3696f98 Drop stale prototype 2012-04-27 11:26:57 -04:00
Kristian Høgsberg
a9f951b003 data-device: Record the serial number for the current selection
And reject setting a selection that's older than our current selection.
2012-04-13 12:48:38 -04:00
Kristian Høgsberg
fa5f7b1191 server: Add client destroy signal 2012-04-13 09:53:15 -04:00
Neil Roberts
18a770c80d Add a public header for the version number
This adds a public header so that applications can get the Wayland
version number at compile time. This can be used to make applications
that support compiling against multiple versions of Wayland.

There is a separate installed header called cogl-version.h which gets
included by both wayland-client.h and wayland-server.h

The canonical place for the version number is the configure.ac script
which splits it into three separate m4 defines for the major, minor
and micro version. These are copied into the generated
wayland-version.h header using AC_SUBST. There is also a string form
of the complete version number.

The version number is now also automatically copied into the two .pc
files.

Because the major, minor and micro parts are required it is no longer
possible to leave the version number as 'master' when building from
git. Most projects seem to immediately bump the git repo to a fake
version number (usually odd) after making a release so that there is
always a relative number that can be used for comparison. This patch
sets the git version to 0.99.0 under the assumption that the next
release will be 1.0.0.
2012-04-12 17:54:44 -04:00
Kristian Høgsberg
6802eaa68a Introduce wl_signal
This is mostly renaming and consolidating the listener_list pattern
into something more concise and reusable.
2012-04-12 15:52:44 -04:00