Commit Graph

1131 Commits

Author SHA1 Message Date
Kristian Høgsberg
85a6a47087 scanner: Send interface name and version for types new_id args
This makes the scanner generate the code and meta data to send the
interface name and version when we pass a typeless new_id.  This way, the
generic factory mechanism provided by wl_display.bind can be provided by
any interface.
2012-10-10 20:59:00 -04:00
Kristian Høgsberg
385fe30e8b client: Add wl_event_queue for multi-thread dispatching
This introduces wl_event_queue, which is what will make multi-threaded
wayland clients possible and useful.  The driving use case is that of a
GL rendering thread that renders and calls eglSwapBuffer independently of
a "main thread" that owns the wl_display and handles input events and
everything else.  In general, the EGL and GL APIs have a threading model
that requires the wayland client library to be usable from several threads.
Finally, the current callback model gets into trouble even in a single
threaded scenario: if we have to block in eglSwapBuffers, we may end up
doing unrelated callbacks from within EGL.

The wl_event_queue mechanism lets the application (or middleware such as
EGL or toolkits) assign a proxy to an event queue.  Only events from objects
associated with the queue will be put in the queue, and conversely,
events from objects associated with the queue will not be queue up anywhere
else.  The wl_display struct has a built-in event queue, which is considered
the main and default event queue.  New proxies are associated with the
same queue as the object that created them (either the object that a
request with a new-id argument was sent to or the object that sent an
event with a new-id argument).  A proxy can be moved to a different event
queue by calling wl_proxy_set_queue().

A subsystem, such as EGL, will then create its own event queue and associate
the objects it expects to receive events from with that queue.  If EGL
needs to block and wait for a certain event, it can keep dispatching event
from its queue until that events comes in.  This wont call out to unrelated
code with an EGL lock held.  Similarly, we don't risk the main thread
handling an event from an EGL object and then calling into EGL from a
different thread without the lock held.
2012-10-10 20:59:00 -04:00
Kristian Høgsberg
de961dc1f3 client: Make wl_display thread safe
Not all entry points are thread safe: global listeners and global lookup
is still only main thread.
2012-10-10 20:59:00 -04:00
Kristian Høgsberg
ce1f4c29ab client: Split event handling into demarshal and dispatch steps
This lets us demarshal with a mutex held and then do dispatching after
releasing the mutex.
2012-10-10 20:59:00 -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
Matt Roper
0371668dcc Ensure cursor_data.c is included in distribution tarballs
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
2012-10-09 23:42:52 -04:00
Rob Bradford
6685d19301 connection: Add missing free from error path
On the error codepath that errors out on ENOMEM we should free the allocated
closure.

Signed-off-by: Rob Bradford <rob@linux.intel.com>
2012-10-09 23:01:42 -04:00
Rob Bradford
0201708773 xcursor: Fix allocation based on string length
strlen() doesn't include the terminating NUL. Therefore when allocating a
block of memory to hold something equivalent to the length of the string we
must increment to take the NUL byte into consideration.

Signed-off-by: Rob Bradford <rob@linux.intel.com>
2012-10-09 23:01:23 -04:00
Tiago Vignatti
b41dc10063 wayland: Fix typos
My vim spell checker is able to find typos of xml files after adding "syn spell
toplevel" to ~/.vim/after/syntax/xml.vim

aah, and Wayland is capital letter :)

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2012-10-09 22:45:48 -04:00
Tiago Vignatti
b5af60a57b doc: Remove Shared Object Cache section
We don't support anything like that yet.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2012-10-09 22:45:45 -04:00
Tiago Vignatti
7fe381861b doc: Auto-generate Protocol/Interfaces section instead
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2012-10-09 22:45:43 -04:00
Tiago Vignatti
d3fe28384c doc: Improve Wire Format section
Fixed the wayland socket name and added documentation for fixed format.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2012-10-09 22:45:40 -04:00
Kristian Høgsberg
5495bcd15a connection: Drop unused static closures 2012-10-01 13:21:29 -04:00
David Herrmann
56ea2e793b man: fix compilation without xsltproc
We really shouldn't add the man-pages when HAVE_XSLTPROC is not true so
move it into the if-clause.
But declare the automake-variables outside of the if-clause to avoid
automake complaints.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-09-26 12:28:22 -04:00
David Herrmann
49dee9a86c man: add man-page infrastructure
This adds a man-page infrastructure based on Docbook XML files. This
allows us to integrate the man-pages into the publican books later. An
example page for wl_display_connect() (with an alias
wl_display_connect_to_fd()) is also added.

Feel free to add more man-pages. Function calls are put in man3 and
overview pages into man7. All pages (including aliases) have to be added
to the Makefile.

Docbook does generate aliases automatically from the additional names that
were put in the XML file. However, a small SED script is needed to fixup
the include-paths in the generated troff files. If someone knows how to
avoid that (or even install them gzip'ped), please fix it up.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-09-25 11:02:52 -04:00
Tiago Vignatti
35d8da8ef6 protocol: Fix typo
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2012-09-25 10:15:17 -04:00
Diego Viola
4b681a7fd4 Fix typo (ratio, not ration)
Signed-off-by: Diego Viola <diego.viola@gmail.com>
2012-09-13 11:31:44 -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
David Herrmann
397a0c6ada event-loop: remove dead code
There is really no need to increment "n" if we never read the value. The
do-while() loop overwrites the value before it is read the first time.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-09-10 21:28:34 -04:00
Philipp Brüschweiler
7fafa994a4 cursor: add cursor.pcf and extraction program 2012-09-10 21:05:14 -04:00
Philipp Brüschweiler
9ce9336c57 cursor: Add a default cursor theme
This theme is loaded when the specified cursor theme can not be found.

These cursors are extracted from the xorg sources and transformed into
raw ARGB data by a small helper program (commited separately).
2012-09-10 21:04:55 -04:00
Kristian Høgsberg
2be6e0ed14 tests: Quiet warning 2012-08-29 14:12:11 -04:00
U. Artie Eoff
91931bcabb tests: ensure sanity leak check tests pass when leak checks are disabled.
This finalizes Robert Bradfords patch to allow NO_ASSERT_LEAK_CHECK
environment variable to disable leak checks in unit tests.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2012-08-29 14:10:24 -04:00
Rob Bradford
c95c2dffb0 tests: Allow disabling leak checking assertions by env
Some code coverage tools trigger these assertions when run against the test
suite since they don't free all their memory.
2012-08-29 14:10:20 -04:00
Kristian Høgsberg
7d3ccec18e Add wl_shm_buffer_create() 2012-08-16 10:49:48 -04:00
Kristian Høgsberg
c855d6eec4 client: Add wl_display_connect_to_fd() function
This lets us connect a display to an already existing socket fd.
2012-08-16 10:49:48 -04:00
Scott Moreau
599a455fb4 protocol: Fix typo. 2012-08-16 10:49:48 -04:00
Philipp Brüschweiler
0a633704e6 socket-test: don't try to be clever, fail if no XDG_RUNTIME_DIR is set
Not only setenv(), also putenv() allocates memory on my system
(glibc 2.16.0). Just fail with a clear message if XDG_RUNTIME_DIR is
not set.

https://bugs.freedesktop.org/show_bug.cgi?id=52618
2012-08-14 10:10:47 -04:00
Christopher Michael
b57694ca0e Add support for X cursor themes.
This patch adds a few more directories to search for xcursor themes.

Along with the weston patch, this adds the ability to configure weston
to use an X11 cursor theme. Previously, wayland cursor would just look
in the icons and pixmaps directories for cursor images to load. This
adds the ability to also search in the x cursors directory.
2012-08-13 11:02:56 -04:00
Christopher Michael
89eddb4245 Fix grammar in the rendering section.
Upon reading some docs, I found a small grammar mistake in the
rendering section. This patch fixes that.
2012-08-13 11:00:28 -04:00
Kristian Høgsberg
915cdeee29 connection: zero out string padding
We don't want to send random data to the client and this also keeps
valgrind happy.
2012-08-03 22:39:51 -04:00
Andre Heider
7f3d22776b protocol: Remove "repeat" from "key_state"
This is unused and apparently was never implemented.
2012-07-31 22:35:45 -04:00
Dima Ryazanov
31c0258ff1 Don't skip the first directory entry when reading cursors.
I end up missing the "bottom_right_corner" cursor.
2012-07-26 22:04:32 -04:00
Kristian Høgsberg
f5ccd7a9e6 Bump version to 0.95.0 2012-07-24 15:45:00 -04:00
Kristian Høgsberg
6ebde80f0f Make distcheck work from builddir configured with --disable-documentation 2012-07-24 15:10:12 -04:00
Daniel Stone
3ec40512c7 More consistent ID printing
Use unsigned rather than signed for IDs, so they match up with what we
see in other prints.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-23 20:17:10 -04:00
Daniel Stone
db0add6d5e Make NEW_IDs nullable
The connection-handling code already allows this, so make it legal in
the protocol definition too.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-23 20:16:57 -04:00
Daniel Stone
efe23443d8 Unstatic arg_count_for_signature and get_next_argument
Expose these to other files using wayland-private.h, so wayland-client.c
can walk NULLables properly.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-23 20:15:28 -04:00
Kristian Høgsberg
a2c79b14a1 tests: Wrap calloc by just returning NULL if we're called too early
Since glibc dlsym() calls calloc, we get a call to our calloc wrapper as
we try to look up the real calloc implementation.  dlsym() will fall back
to a static buffer in case calloc returns NULL, so that's what we'll do.

This is all highly glibc dependent, of course, but the entire malloc
weak symbol wrapper mechanism is, so there's no loss of generality here.
2012-07-23 20:14:33 -04:00
Daniel Stone
61e9196f56 test-runner: Wrap realloc() too
So all our tests don't start failing just because we had the temerity to
use realloc() rather than malloc().

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-23 16:40:58 -04:00
Daniel Stone
16b4c87470 .gitignore: Add ctags and cscope files
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-23 16:40:38 -04:00
Kristian Høgsberg
eadb68ec32 protocol: Add transform argument to wl_output.geometry event 2012-07-22 15:50:37 -04:00
Mathias Fiedler
0b8b397e34 connection: reserve id on incoming new object
If a new object id arrives ensure that there is an empty array entry
created, otherwise we might get out of sync for new ids if object isn't
created by interface implementation.
2012-07-22 14:09:51 -04:00
Mathias Fiedler
bfcd681930 wayland-util: add method for reserving new object id
wl_map_reserve_new() ensures that new id is valid and will point to an
empty array entry.
2012-07-22 14:09:48 -04:00
Mathias Fiedler
900e4b63ef wayland-server: send error on invalid new object id
Creation of new client resources was silently ignored when
wl_client_add_resource() was used on server side and new object id was out
of range.

An error is now send out to the client in such case.

Also changed error message in wl_client_add_object, since
wl_map_insert_at() returns -1 only at invalid new id.
2012-07-22 14:06:37 -04:00
Kristian Høgsberg
76bfd68f47 wayland-shm: Commit the width/height getters that actually compile 2012-07-20 12:30:07 -04:00
Kristian Høgsberg
0b4ed5fe72 README: Update
The wayland README had outdated build instructions for weston.  Let's just
trim it down to build instructions for wayland and a link to the web site.
2012-07-20 12:20:20 -04:00
Kristian Høgsberg
7ba218c9f8 shm: Add shm_buffer getters for width and height 2012-07-20 12:04:42 -04:00
Robert Ancell
0a9cd16f6a wayland-client: Add missing newline from an error message 2012-07-20 12:04:05 -04:00