platform/upstream/wayland.git
9 years agodoc: Mark up some code examples
Benjamin Herr [Mon, 29 Sep 2014 15:26:11 +0000 (17:26 +0200)]
doc: Mark up some code examples

These blocks were misformatted in normal paragraph style in the
generated docs. Also, added \comment{} for comments within one code
example.

Signed-off-by: Benjamin Herr <ben@0x539.de>
9 years agoREADME: Tiny cosmetic change
Daniel Stone [Wed, 8 Oct 2014 11:20:08 +0000 (12:20 +0100)]
README: Tiny cosmetic change

9 years agoprotocol: define error codes for role reassignment
Pekka Paalanen [Wed, 1 Oct 2014 09:52:22 +0000 (12:52 +0300)]
protocol: define error codes for role reassignment

On the interfaces where it was missing:
- wl_data_device
- wl_shell
- wl_pointer
add an error code for requests that set a wl_surface role when the
wl_surface already has a different role.

This is needed for compositors to appropriately report wl_surface
role violations.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
Acked-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agoprotocol: wl_shell.get_shell_surface gives a role
Pekka Paalanen [Thu, 21 Aug 2014 09:50:50 +0000 (12:50 +0300)]
protocol: wl_shell.get_shell_surface gives a role

Now that we have defined "role", use the term.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agoprotocol: wl_subcompositor.get_subsurface gives a role
Pekka Paalanen [Thu, 21 Aug 2014 09:42:50 +0000 (12:42 +0300)]
protocol: wl_subcompositor.get_subsurface gives a role

Reword the conditions to make use of the definition of "role".

It is still forbidden to create more than one wl_subsurface for a
wl_surface at a time.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agoprotocol: wl_data_device.start_drag may give a role
Pekka Paalanen [Thu, 21 Aug 2014 09:38:18 +0000 (12:38 +0300)]
protocol: wl_data_device.start_drag may give a role

Now that we have defined "role", use the term.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agoprotocol: wl_pointer.set_cursor gives a role
Pekka Paalanen [Thu, 21 Aug 2014 09:32:56 +0000 (12:32 +0300)]
protocol: wl_pointer.set_cursor gives a role

Now that we have defined "role", use the term.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agoprotocol: define the concept of wl_surface role
Pekka Paalanen [Mon, 18 Aug 2014 14:07:34 +0000 (17:07 +0300)]
protocol: define the concept of wl_surface role

Define what a role is, and what restrictions there are.

A change to existing behaviour is that a role cannot be changed at all
once set. However, this is unlikely to cause problems, as there is no
reason to re-use wl_surfaces in clients.

v2: give more concrete examples of roles, define losing a role, Jasper
rewrote the paragraph on how a role is set.

v3: make role permanent, there is no such thing as "losing a role".
Re-issuing the same role again must be allowed for wl_pointer.set_cursor
et al. to work.

v4: clarify the semantics of destroying a role object.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agoscanner: Remove stray newline
Jonas Ådahl [Mon, 22 Sep 2014 20:11:19 +0000 (22:11 +0200)]
scanner: Remove stray newline

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
9 years agoscanner: Improve XML parse error reporting
Jonas Ådahl [Mon, 22 Sep 2014 20:11:18 +0000 (22:11 +0200)]
scanner: Improve XML parse error reporting

Print the parse error and exit with a failure if expat can't parse the
XML.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
9 years agodoc: replace publican with xmlto
Peter Hutterer [Thu, 4 Sep 2014 07:32:10 +0000 (17:32 +1000)]
doc: replace publican with xmlto

Publican isn't packaged for some distros, xmlto is a lot more common. Most of
what publican provides for us is the stylesheet anyway, so we can just use
xmlto and the publican stylesheet to get roughly the same look.

PDF and XML generation has been dropped, this needs a bit more more effort
than a mere switchover to xmlto.

The top-level directory structure imposed by publican is kept for now
(specifically the Wayland/en-US/html tree). This makes it easier to transition over
for packagers. Note that the list of files inside has changed.

CSS files are taken from publican to keep a uniform look compared to previous
documentations. Stylesheets are licensed under CC0 1.0 Universal license, see
publican/LICENSE:

1.  Files in the datadir/Common_Content directory and its subdirectories are
    licensed under the CC0 1.0 Universal license.

    To the extent possible under law, the developers of Publican waive all
    copyright and related or neighboring rights to the files contained
    in the datadir/Common_Content directory and its subdirectories.

Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoconfigure.ac: bump version to 1.6.90
Pekka Paalanen [Mon, 22 Sep 2014 06:51:20 +0000 (09:51 +0300)]
configure.ac: bump version to 1.6.90

Master is open for new features again.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoconfigure.ac: bump version to 1.6.0 1.6.0
Pekka Paalanen [Fri, 19 Sep 2014 09:36:04 +0000 (12:36 +0300)]
configure.ac: bump version to 1.6.0

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoconfigure.ac: bump version to 1.5.93 for rc2 1.5.93
Pekka Paalanen [Fri, 12 Sep 2014 09:26:50 +0000 (12:26 +0300)]
configure.ac: bump version to 1.5.93 for rc2

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoshm: fix error in comment
Derek Foreman [Wed, 10 Sep 2014 18:46:09 +0000 (13:46 -0500)]
shm: fix error in comment

9 years agoclient: cancel read in wl_display_read_events() when last_error is set
Marek Chalupa [Wed, 10 Sep 2014 10:47:14 +0000 (12:47 +0200)]
client: cancel read in wl_display_read_events() when last_error is set

Calling wl_display_read_events() after an error should be equivalent
to wl_display_cancel_read(), so that display state is consistent.

Thanks to Pekka Paalanen <pekka.paalanen@collabora.co.uk>
for pointing that out.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoclient: wake-up threads on all return paths from read_events
Marek Chalupa [Wed, 10 Sep 2014 10:47:13 +0000 (12:47 +0200)]
client: wake-up threads on all return paths from read_events

If wl_connection_read returned EAGAIN, we must wake up sleeping
threads. If we don't do this and the thread calling
wl_connection_read won't call wl_display_read_events again,
the sleeping threads will sleep indefinitely.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agodisplay-test: test if threads are woken up on EAGAIN
Marek Chalupa [Wed, 10 Sep 2014 10:47:12 +0000 (12:47 +0200)]
display-test: test if threads are woken up on EAGAIN

When wl_connection_read() in wl_display_read_events() returns with EAGAIN,
we want the sleeping threads to be woken up. Test it!

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: use nanosleep instead of usleep
Marek Chalupa [Tue, 9 Sep 2014 09:11:52 +0000 (11:11 +0200)]
tests: use nanosleep instead of usleep

man usleep says that bahaviour of using usleep with SIGALRM signal
is unspecified. So create our own usleep that calls nanosleep instead.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoconfigure.ac: bump version to 1.5.92 for rc1 1.5.92
Pekka Paalanen [Fri, 5 Sep 2014 11:57:03 +0000 (14:57 +0300)]
configure.ac: bump version to 1.5.92 for rc1

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agodoc: Quell warnings about missing man3 directory before its been built
Bryce W. Harrington [Mon, 21 Jul 2014 19:23:49 +0000 (19:23 +0000)]
doc: Quell warnings about missing man3 directory before its been built

The shell command for dist_man3_MANS gets invoked several times during
the make process but before the man pages have been generated, which
causes the following warnings when running `make`:

    find: `man/man3': No such file or directory
    find: `man/man3': No such file or directory
    find: `man/man3': No such file or directory
      GEN    xml/client/index.xml

Despite these error messages, the generated dist tarball contains the
man3 pages as intended, both before and after this patch.

    $ make dist
    $ tar xxf wayland-1.5.90.tar.xz
    $ find wayland-1.5.90/doc/doxygen/man/man3 -name "wl_*.3" | wc -l
    85

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agodisplay-test: make use of create_thread function
Marek Chalupa [Fri, 29 Aug 2014 09:21:29 +0000 (11:21 +0200)]
display-test: make use of create_thread function

This function is used in one test only, but its functionality can be
used in another tests to (create thread and wait until it is sleeping).
We just need to pass the starting function for the thread as an argument.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoclient: add display_wakeup_threads function
Marek Chalupa [Fri, 29 Aug 2014 09:21:28 +0000 (11:21 +0200)]
client: add display_wakeup_threads function

This helper function wraps the always-repeated pattern:

  display->read_serial++;
  pthread_cond_broadcast(&display->reader_cond);

[Pekka Paalanen: minor whitespace and comment fixes.]

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>

9 years agowayland-client: Initialize newly created wl_proxys to zero
Nils Chr. Brause [Sat, 30 Aug 2014 15:12:26 +0000 (17:12 +0200)]
wayland-client: Initialize newly created wl_proxys to zero

Up until now, newly created wl_proxys (with proxy_create or
wl_proxy_create_for_id) are not initialized properly after memory
allocation. The wl_display object in contrast is. To prevent giving
uninitialized data to the user (e.g. user_data) an appropriate memset
has been added. Also, after a memset members don't have to be
explicitly initialized with zero anymore.

Signed-off-by: Nils Chr. Brause <nilschrbrause@googlemail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agodoc/publican: stop excessive rebuilds
Peter Hutterer [Mon, 1 Sep 2014 23:50:14 +0000 (09:50 +1000)]
doc/publican: stop excessive rebuilds

Traced down to the server/client target always rebuilding, causing a rebuild
of everything else. Rework this so the target name is a file we actually
produce and can check for a timestamp.

Note: this also changes the generated file from the doxygen directory into the
en-US publican path and renames it to (server|client)API.xml.tmp to avoid
copying it into the xml output directory.

9 years agoconfigure.ac: Bump version to 1.5.91 for the alpha release 1.5.91
Pekka Paalanen [Fri, 22 Aug 2014 15:01:35 +0000 (18:01 +0300)]
configure.ac: Bump version to 1.5.91 for the alpha release

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoclient: check for error in wl_display_read_events
Marek Chalupa [Fri, 22 Aug 2014 12:28:59 +0000 (14:28 +0200)]
client: check for error in wl_display_read_events

This prevents from blocking shown in one display test. Also, it
makes sense to not proceed further in the code of the function
when an error ocurred.

v2. set errno
    put note about the errno into wl_display_prepare_read doc
    check for error with mutex locked

v3.
    set errno to display->last_error

    check for the error only in wl_display_read_events. It's sufficient
    as prevention for the hanging and programmer doesn't need to
    check if wl_display_prepare_read (that was previously covered by
    this patch too) returned an error or the queue just was not empty.
    Without the check, it could result in indefinite looping.

Thanks to Pekka Paalanen <pekka.paalanen@collabora.co.uk> for
constant reviewing and discussing this patch.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoclient: broadcast the right pthread_cond variable
Marek Chalupa [Tue, 5 Aug 2014 09:42:01 +0000 (11:42 +0200)]
client: broadcast the right pthread_cond variable

In previous commit we removed unused variables. One of them was
pthread_cond_t that was formerly used when reading from display, but
later was (erroneously) made unused. This patch fixes this error
and is a fix for the failing test introduced few patches ago (tests:
test if thread can block on error)

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoclient: drop unused event queue cond and list variables
Olivier Blin [Thu, 21 Aug 2014 14:54:21 +0000 (16:54 +0200)]
client: drop unused event queue cond and list variables

The wl_event_queue cond variable has been replaced by the wl_display
reader_cond variable (commit 3c7e8bfbb4745315b7bcbf69fa746c3d6718c305).
This cond variable is never waited for anymore, just
signaled/broadcasted, and thus can be safely removed.

The wl_display event_queue_list and link from wl_event_queue
can be removed as well, since it was only used to iterate over
the event queue list in order to broadcast the now unused cond.

No regression on queue unit tests.

Signed-off-by: Olivier Blin <olivier.blin@softathome.com>
v2: fixed and rebased after 886b09c9a3a9d8672039f09fe7eaf3f2b2b012ca
    added signed-off-by

v3: removed link from wl_event_queue

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: add test for reading after an error occurred
Marek Chalupa [Tue, 5 Aug 2014 09:39:51 +0000 (11:39 +0200)]
tests: add test for reading after an error occurred

This test shows that it's possible to successfully call wl_display_prepare_read
and wl_display_read_events after an error occurred. That may lead to
deadlock.

When you call prepare read from two threads and then call read_events,
one thread gets sleeping. The call from the other thread will return -1 and invokes
display_fatal_error, but since
we have display->last_error already set, the broadcast is not called and
the sleeping thread sleeps indefinitely.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: add tests for wl_display_cancel_read
Marek Chalupa [Tue, 5 Aug 2014 09:39:50 +0000 (11:39 +0200)]
tests: add tests for wl_display_cancel_read

Test if wl_display_cancel_read wakes up other threads.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: test if thread can block on error
Marek Chalupa [Tue, 5 Aug 2014 09:39:49 +0000 (11:39 +0200)]
tests: test if thread can block on error

wl_display_read_events() can make a thread wait until some other thread
ends reading. Normally it wakes up all threads after the reading is
done. But there's a place when it does not get to waking up the threads
- when an error occurs. This test reveals bug that can block programs.

If a thread is waiting in wl_display_read_events() and another thread
calls wl_display_read_events and the reading fails,
then the sleeping thread is not woken up. This is because
display_handle_error is using old pthread_cond instead of new
display->reader_cond, that was added along with wl_display_read_events().

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: test posting errors
Marek Chalupa [Mon, 26 May 2014 15:04:23 +0000 (17:04 +0200)]
tests: test posting errors

Test posting errors to one and more clients.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: use test compositor in queue-test
Marek Chalupa [Thu, 21 Aug 2014 14:53:14 +0000 (16:53 +0200)]
tests: use test compositor in queue-test

Most of the code of the queue-test is covered by the test compositor,
so we can save few lines and use the test compositor instead.
I think it's also more readable.

This patch removes timeout from the test. We plan to add timeout
to all tests later, though.

v2.
  rebased to master

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: add test-compositor
Marek Chalupa [Thu, 21 Aug 2014 14:52:16 +0000 (16:52 +0200)]
tests: add test-compositor

This patch introduces a set of functions that can create a display
and clients for tests.
On server side the user can use functions:
  display_create()
  display_destroy()
  create_client()
  display_run()
  display_resume()
and on client side the user can use:
  client_connect()
  client_disconnect()
  stop_display()

The stop_display() and display_resume() are functions that serve as a barrier
and also allow the display to take some action after the display_run() was called,
because after the display is stopped, it can run arbitrary code until it calls
display_resume().

client_connect() function connects to wayland display and creates a proxy to
test_compositor global object, so it can ask for stopping the display later
using stop_display().

An example:

  void
  client_main()
  {
        /* or client can use wl_display_connect(NULL)
         * and do all the stuff manually */
        struct client *c = client_connect();

        /* do some stuff, ... */

        /* stop the display so that it can
         * do some other stuff */
        stop_display(c, 1);

        /* ... */

        client_disconnect(c);
  }

  TEST(dummy_tst)
  {
       struct display *d = display_create();

       /* set up the display */
       wl_global_create(d->wl_display, ...);

       /* ... */

       create_client(d, client_main);
       display_run();

       /* if we are here, the display has been stopped
        * and we can do some code, i. e. create another global or so */
       wl_global_create(d->wl_display, ...);

       /* ... */

       display_resume(d); /* resume display and clients */

       display_destroy(d);
  }

v2:
  added/changed message in few asserts that were not clear
  fixed codying style issues and typo
  client_create_with_name: fixed a condition in an assert
  get_socket_name: use also pid
  check_error: fix errno -> err

[Pekka Paalanen: added test-compositor.h to SOURCES, added
WL_HIDE_DEPRECATED to get rid of deprecated defs and lots of warnings,
fixed one unchecked return value from write().]

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoclient: remove unused variable
Marek Chalupa [Thu, 21 Aug 2014 10:07:08 +0000 (12:07 +0200)]
client: remove unused variable

display_thread variable is unused since
3c7e8bfbb4745315b7bcbf69fa746c3d6718c305

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: remove unnecessary lines from queue-test
Marek Chalupa [Thu, 21 Aug 2014 10:07:07 +0000 (12:07 +0200)]
tests: remove unnecessary lines from queue-test

Earlier, the wl_display_dispatch_pending were setting number of thread
that can dispatch events. This behaviour was removed later,
so now these lines are redundant.

Related commits:

385fe30e8b144a968aa88c6546c2ef247771b3d7
78cfa967681c965d23f6cbf76e080bbb0b564ff6
3c7e8bfbb4745315b7bcbf69fa746c3d6718c305

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: remove leaks from queue-test
Marek Chalupa [Thu, 21 Aug 2014 10:07:06 +0000 (12:07 +0200)]
tests: remove leaks from queue-test

Destroy all objects that we have created

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoserver: Don't expose wl_display as a global
Jasper St. Pierre [Thu, 7 Aug 2014 13:55:49 +0000 (09:55 -0400)]
server: Don't expose wl_display as a global

The idea here was that once upon a time, clients could rebind wl_display
to a higher version, so we offered the ability to rebind it
here. However, this is particularly broken. The existing bind
implementation actually still hardcodes version numbers, and it leaks
previous resources, overwriting the existing one.

The newly bound resource *also* won't have any listeners attached by the
client, meaning that the error and delete_id events won't get delivered
correctly. Unless the client poked into libwayland internals, it also
can't possibly set up these handlers correctly either, so the client
will sustain errors and leak all deleted globals.

Since this never worked correctly in the first place, we can feel safe
removing it.

Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: test the wl_display_roundtrip_queue() function
Giulio Camuffo [Wed, 20 Aug 2014 16:29:10 +0000 (19:29 +0300)]
tests: test the wl_display_roundtrip_queue() function

[Pekka Paalanen: moved variable declarations to before code. Added some
comments, and added the re-arm to additionally test the opposite case.]

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoclient: add a public function to make a roundtrip on a custom queue
Giulio Camuffo [Wed, 20 Aug 2014 16:29:09 +0000 (19:29 +0300)]
client: add a public function to make a roundtrip on a custom queue

wl_display_roundtrip() works on the default queue. Add a parallel
wl_display_roundtrip_queue().

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agowl_surface: clarify the base of time passed in the callback of frame
Ryo Munakata [Wed, 20 Aug 2014 15:25:36 +0000 (00:25 +0900)]
wl_surface: clarify the base of time passed in the callback of frame

Signed-off-by: Ryo Munakata <ryomnktml@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: fix event_loop_timer_updates
Marek Chalupa [Tue, 19 Aug 2014 10:03:48 +0000 (12:03 +0200)]
tests: fix event_loop_timer_updates

It may happen that there's some time between the first and the other timer expire.
If epoll_wait is called after the first timer expired and
the other not, it returns only one source to dispatch and therefore
the test fails. To fix that, sleep a while before
wl_event_loop_dispatch() to make sure both timers expired.

To be 100% sure, we could use poll() before calling
wl_event_loop_dispatch(), but that would need modification in libwayland
(need to get the source's fd somehow)

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

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: event_loop_timer_updates - add asserts and fix indentation
Marek Chalupa [Tue, 19 Aug 2014 08:34:52 +0000 (10:34 +0200)]
tests: event_loop_timer_updates - add asserts and fix indentation

Make sure the wl_event_source_timer_update suceeded. Also, fix weird
indentation.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: add one more test for event-loop signal source
Marek Chalupa [Tue, 12 Aug 2014 09:35:07 +0000 (11:35 +0200)]
tests: add one more test for event-loop signal source

Test if when we get a signal, all signal sources for that signal
get dispatched.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoevent-loop: make signalfd non-blocking
Marek Chalupa [Tue, 12 Aug 2014 09:35:06 +0000 (11:35 +0200)]
event-loop: make signalfd non-blocking

When we add more that one source to a signal, then wayland will
block in wl_event_loop_dispatch. This is due to the attampt to read
from signal's fd each time the source is dispatched.

  wl_event_loop_add_signal(loop, SIGINT, ...);
  wl_event_loop_add_signal(loop, SIGINT, ...);

  /* raise signal .. */

  /* we got two fd's ready, both for the one SIGINT */
  epoll_wait(...) = 2

  [ for (i == 0) ]
      source1->dispatch() --> read(fd1);
  [ for (i == 1) ]
      source2->dispatch() --> read(fd2); /* blocking! */

Reading from fd2 will block, because we got only one signal,
and it was read from fd1.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: make event-loop-test more explicit
Marek Chalupa [Tue, 12 Aug 2014 09:35:05 +0000 (11:35 +0200)]
tests: make event-loop-test more explicit

Check value set in handler against an explicit value instead of:
  assert(value);

also add one assert() for non-NULL value.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoscanner: Make emit_structs more explicit
Jasper St. Pierre [Fri, 8 Aug 2014 22:22:48 +0000 (18:22 -0400)]
scanner: Make emit_structs more explicit

"is_interface" is a really terrible name for the client or server
variants, and instead of checking whether we were passed the requests or
the events, just pass an argument through.

Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoscanner: Use an enum to determine the type of thing we're writing out
Jasper St. Pierre [Fri, 8 Aug 2014 22:22:47 +0000 (18:22 -0400)]
scanner: Use an enum to determine the type of thing we're writing out

Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoserver: fix conditions for fds in wl_socket_destroy
Pekka Paalanen [Thu, 7 Aug 2014 13:46:52 +0000 (16:46 +0300)]
server: fix conditions for fds in wl_socket_destroy

0 is also a valid fd, and needs to be closed.

On error we set fd to -1. We need to also initialize fds to -1, so we do
not accidentally close stdout on error.

While fixing this, also remove one use-before-NULL-check.

Based on the patch by Marek.

Cc: Marek Chalupa <mchqwerty@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
9 years agoserver: fix error handling when adding socket
Marek Chalupa [Wed, 6 Aug 2014 09:21:59 +0000 (11:21 +0200)]
server: fix error handling when adding socket

When some function during adding socket fails, it must clean
everything it set or we can get funky errors.

This patch fixes:
http://lists.freedesktop.org/archives/wayland-devel/2014-August/016331.html

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotests: add tests for bug in adding socket
Marek Chalupa [Wed, 6 Aug 2014 08:33:04 +0000 (10:33 +0200)]
tests: add tests for bug in adding socket

Last set of commits introduced a bug. When adding of socket with
a particular name fails, then the socket and its lockfile are deleted
regardless who created the socket.

/* OK */
wl_display_add_socket(display, "wayland-0");

/* this call fails and will delete the original socket */
wl_display_add_socket(display, "wayland-0");

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoserver: move memset after check
Marek Chalupa [Wed, 6 Aug 2014 09:28:34 +0000 (11:28 +0200)]
server: move memset after check

If the malloc fails, memset would touch invalid memory.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoserver: Add a simple API to find a good default display
Jasper St. Pierre [Thu, 8 May 2014 15:01:24 +0000 (11:01 -0400)]
server: Add a simple API to find a good default display

This allows compositors to easily select a good display to listen on.

9 years agoserver: Save the display name in the wl_socket
Jasper St. Pierre [Thu, 8 May 2014 15:25:34 +0000 (11:25 -0400)]
server: Save the display name in the wl_socket

This allows us to return the display name to the client in a new API.

9 years agoserver: Make get_socket_lock operate directly on the socket's lock_fd
Jasper St. Pierre [Thu, 8 May 2014 14:57:16 +0000 (10:57 -0400)]
server: Make get_socket_lock operate directly on the socket's lock_fd

9 years agoserver: Split out code to initialize the socket address for a display name
Jasper St. Pierre [Thu, 8 May 2014 14:25:13 +0000 (10:25 -0400)]
server: Split out code to initialize the socket address for a display name

We'll use this to autodetect a good socket to open on.

9 years agoserver: Create the socket FD after taking the lock
Jasper St. Pierre [Thu, 8 May 2014 14:24:06 +0000 (10:24 -0400)]
server: Create the socket FD after taking the lock

We're going to split out the lock-taking to another function so we
can repetitively try locks.

9 years agoserver: Clean up socket destruction
Jasper St. Pierre [Thu, 8 May 2014 14:22:25 +0000 (10:22 -0400)]
server: Clean up socket destruction

The code here is wrong, leaky, and inconsistent. We don't free,
unlink or clean up things when we should in every error path.

Centralize the data destruction so it's easier to keep track of
and easier to bug fix.

9 years agowayland-client: Fix indentation
Jasper St. Pierre [Tue, 5 Aug 2014 19:21:36 +0000 (15:21 -0400)]
wayland-client: Fix indentation

10 years agogitignore: Add another test-suite file
Bryce W. Harrington [Mon, 21 Jul 2014 17:51:14 +0000 (17:51 +0000)]
gitignore: Add another test-suite file

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
10 years agoprotocol: add repeat_info event to wl_keyboard
Jonny Lamb [Tue, 22 Jul 2014 16:39:18 +0000 (17:39 +0100)]
protocol: add repeat_info event to wl_keyboard

In the process wl_keyboard's version has been incremented. Given
clients get the wl_keyboard from wl_seat without a version, wl_seat's
version has also been incremented (wl_seat version 4 implies
wl_keyboard version 4).

earlier Acked-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Pekka Paalanen <ppaalanen@gmail.com>
10 years agodoc: Fix link to wl_list_remove()
Bryce W. Harrington [Fri, 25 Jul 2014 00:35:40 +0000 (00:35 +0000)]
doc: Fix link to wl_list_remove()

Use function linking syntax instead of variable linking, to resolve two
warnings:

    wayland-server.h:167: warning: explicit link request to 'wl_list_remove' could not be resolved
    wayland-server.h:188: warning: explicit link request to 'wl_list_remove' could not be resolved

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
10 years agoclient: extend error handling
Marek Chalupa [Fri, 20 Jun 2014 07:29:52 +0000 (09:29 +0200)]
client: extend error handling

When an error occurs, wl_display_get_error() does not
provide any way of getting know if it was a local error or if it was
an error event, respectively what object caused the error and what
the error was.

This patch introduces a new function wl_display_get_protocol_error()
which will return error code, interface and id of the object that
generated the error.
wl_display_get_error() will work the same way as before.

wl_display_get_protocol_error() DOES NOT indicate that a non-protocol
error happened. It returns valid information only in that case that
(protocol) error occurred, so it should be used after calling
wl_display_get_error() with positive result.

[Pekka Paalanen] Applied another hunk of Bryce's comments to docs,
added libtool version bump.

Reviewed-by: Pekka Paalanen <ppaalanen@gmail.com>
Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
10 years agoconfigure: fix publican version detection
Peter Hutterer [Wed, 2 Jul 2014 07:23:46 +0000 (17:23 +1000)]
configure: fix publican version detection

Publican now adds a spurious "v" to the version output.

10 years agodoc: force publican to use fop
Peter Hutterer [Wed, 2 Jul 2014 07:23:45 +0000 (17:23 +1000)]
doc: force publican to use fop

Because wkhtmltopdf requires a $DISPLAY, and a patched Qt.

https://bugzilla.redhat.com/show_bug.cgi?id=997682

10 years agodoc: reduce chunk_section_depth to 0
Peter Hutterer [Wed, 2 Jul 2014 07:23:44 +0000 (17:23 +1000)]
doc: reduce chunk_section_depth to 0

One html page per chapter.

10 years agoconnection: remove unreached code
Boyan Ding [Wed, 4 Jun 2014 03:39:08 +0000 (11:39 +0800)]
connection: remove unreached code

10 years agoprotocol: remove redundant 'the' in description
Silvan Jegen [Fri, 23 May 2014 05:26:56 +0000 (07:26 +0200)]
protocol: remove redundant 'the' in description

Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
10 years agoprotocol: add wl_surface errors enum for bad scale and transform values
Jonny Lamb [Fri, 30 May 2014 10:08:16 +0000 (12:08 +0200)]
protocol: add wl_surface errors enum for bad scale and transform values

10 years agoconfigure.ac: Bump configure.ac version to 1.5.90 on master
Kristian Høgsberg [Wed, 28 May 2014 17:11:55 +0000 (10:11 -0700)]
configure.ac: Bump configure.ac version to 1.5.90 on master

10 years agoconfigure.ac: Bump version to 1.5.0 1.5.0
Kristian Høgsberg [Mon, 19 May 2014 23:24:00 +0000 (16:24 -0700)]
configure.ac: Bump version to 1.5.0

10 years agoscanner: Downgrade non-increasing version error to warning 1.4.93
Kristian Høgsberg [Mon, 12 May 2014 22:17:52 +0000 (15:17 -0700)]
scanner: Downgrade non-increasing version error to warning

Commit 99a72777f96f63e4e25dc528bb37115424adac59 introduced a new error
for when the 'since' version decreases.  It also reset the version for
messages without a version to 1.  Versioning semantics in the spec files
was a little under-specified and we don't want to break projects caught in
this grey zone.

This commits replaces previous configure.ac as the 1.4.93 tag and the
final 1.5 RC.

10 years agoconfigure.ac: Bump version 1.4.93
Kristian Høgsberg [Mon, 12 May 2014 19:54:13 +0000 (12:54 -0700)]
configure.ac: Bump version 1.4.93

This is the last RC before 1.5.

10 years agoDo not distribute generated headers
Thierry Reding [Wed, 7 May 2014 12:09:35 +0000 (14:09 +0200)]
Do not distribute generated headers

The wayland-server-protocol.h and wayland-client-protocol.h headers are
currently being shipped in tarballs created using make dist. This causes
out-of-tree builds to fail since make will detect that the headers exist
by looking at the source directory (via VPATH) and not regenerate them.
But as opposed to ${top_builddir}/protocol, ${top_srcdir}/protocol is
not part of the include path and therefore the shipped files can't be
found during compilation.

Two solutions exist to this problem: 1) add ${top_srcdir}/protocol to
the include path to allow shipped files to be used if available or 2)
don't ship these generated files in release tarballs. The latter seems
the most appropriate. wayland-scanner is already a prerequisite in order
to generate wayland-protocol.c, so it is either built as part of the
package or provided externally. Generating all files from the protocol
definition at build time also ensures that they don't get out of sync.

Both of the generated headers are already listed in Makefile.am as
nodist_*_SOURCES, but at the same time they appear in include_HEADERS,
which will cause them to be added to the list of distributable files
after all. To prevent that, split them off into nodist_include_HEADERS.

Note that this problem will be hidden if a previous version of wayland
has been installed, since these files will exist in /usr/include and be
included from there. So this build error will only show for out-of-tree
builds on systems that don't have wayland installed yet.

Signed-off-by: Thierry Reding <treding@nvidia.com>
10 years agodoc: Remove obsolete doxygen tags
Boyan Ding [Mon, 12 May 2014 12:40:03 +0000 (20:40 +0800)]
doc: Remove obsolete doxygen tags

10 years agoscanner: Generate macros for getting the 'since' version of an event
Jonas Ådahl [Thu, 8 May 2014 21:39:49 +0000 (23:39 +0200)]
scanner: Generate macros for getting the 'since' version of an event

This could be useful for compositors who need to be able to not send
events if the client bound a version lower than the newest provided.

Event version numbers are exposed as
[INTERFACE_NAME]_[EVENT_NAME]_SINCE_VERSION for example wl_output.scale
will have the version macro WL_OUTPUT_SCALE_SINCE_VERSION.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agotests: Add message version sanity test
Jonas Ådahl [Thu, 8 May 2014 21:39:48 +0000 (23:39 +0200)]
tests: Add message version sanity test

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoscanner: Also fail when an implicitly versioned message is out of order
Jonas Ådahl [Thu, 8 May 2014 21:39:47 +0000 (23:39 +0200)]
scanner: Also fail when an implicitly versioned message is out of order

Fail if a message with version implicitly set to 1 (i.e. not specified)
comes after a message with since-version > 1.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoprotocol: Fix order of wl_pointer, wl_keyboard and wl_touch messages
Jonas Ådahl [Fri, 9 May 2014 16:10:32 +0000 (18:10 +0200)]
protocol: Fix order of wl_pointer, wl_keyboard and wl_touch messages

The "release" message of wl_pointer, wl_keyboard and wl_touch introduced
in version 3 was placed first in the respective interface XML element,
causing wayland-scanner to misbehave and set the version number of the
"release" message to all subsequent messages with no explicitly specified
"since" version.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agodoc: Remove deprecated doxygen tag
Jonas Ådahl [Thu, 8 May 2014 21:39:45 +0000 (23:39 +0200)]
doc: Remove deprecated doxygen tag

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoevent-loop-test: Remove unused variable
Jonas Ådahl [Thu, 8 May 2014 21:39:44 +0000 (23:39 +0200)]
event-loop-test: Remove unused variable

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agodoc: Added API documentation for wl_display_create function.
Srivardhan Hebbar [Wed, 7 May 2014 04:07:45 +0000 (09:37 +0530)]
doc: Added API documentation for wl_display_create function.

Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>
10 years agoserver: fix potential memleak and NULL deref
U. Artie Eoff [Mon, 5 May 2014 23:28:26 +0000 (16:28 -0700)]
server: fix potential memleak and NULL deref

If for some reason that errno is neither value (ENOMEM or
EINVAL), then prior to this patch, there would be a NULL
deref in wl_closure_lookup(...) at the "else if" conditional
when closure == NULL. Also, closure might not be NULL but still
fall into the block due to the wl_closure_lookup < 0 condition...
in that case, we need to destroy the closure to avoid a memory
leak.

Currently, wl_connection_demarshal only sets errno to ENOMEM
or EINVAL... we've already checked for ENOMEM so remove check
for EINVAL (just assume it).  Also, call wl_closure_destroy(...)
unconditionally in the "else if" block (assume it can handle
NULL closure, too, which it does right now).

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agoconnection-test: check malloc result
U. Artie Eoff [Mon, 5 May 2014 21:45:20 +0000 (14:45 -0700)]
connection-test: check malloc result

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agoscanner: check wl_array_add result
U. Artie Eoff [Mon, 5 May 2014 21:45:19 +0000 (14:45 -0700)]
scanner: check wl_array_add result

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agoconfigure.ac: Bump version to 1.4.92 1.4.92
Kristian Høgsberg [Thu, 1 May 2014 20:44:09 +0000 (13:44 -0700)]
configure.ac: Bump version to 1.4.92

10 years agoAvoid printing to stderr
Kristian Høgsberg [Wed, 30 Apr 2014 19:18:52 +0000 (12:18 -0700)]
Avoid printing to stderr

Use wl_log in the last few places where we print to stderr.  Remove
logging in a couple of places where we properly return an error code.

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

10 years agoUse non-blocking timerfd to prevent blocking when updating timer event sources
Andrew Wedgbury [Fri, 25 Apr 2014 14:00:54 +0000 (15:00 +0100)]
Use non-blocking timerfd to prevent blocking when updating timer event sources

This implements a simple fix for the blocking problem that occurs when
updating a timer event source after the timer expires, but before its
callback is dispatched. This can happen when another event happens during the
same epoll wakeup as the timer event, and causes the read() call in
wl_event_source_timer_dispatch() to block for the updated duration of the
timer.

We never want this read() call to block, so I believe it makes sense for the
timerfd to be non-blocking, and we simply ignore the case where the read fails
with EAGAIN. We still report all other errors as before, and still ignore the
actual value read from the socket.

With this change, the event_loop_timer_updates unit test case I submitted
previously now passes, and weston appears to work as before.

10 years agotest: Add test showing blocking problem when updating timers
Andrew Wedgbury [Fri, 25 Apr 2014 10:36:57 +0000 (11:36 +0100)]
test: Add test showing blocking problem when updating timers

I've noticed a blocking problem in Wayland's event-loop code when updating
timer event sources. The problem occurs if you update the timer at a point
after is has expired, but before it has been dispatched, i.e. from an event
callback that happens during the same epoll wakeup.

When the timer is subsequently dispatched, wl_event_source_timer_dispatch
blocks for the duration of the new timeout in its call to read() from the
timer fd (which is the expected behaviour according to the man page for
timerfd_settime).

This isn't too uncommon a scenario - for example, a socket with an associated
timeout timer. You'd typically want to update the timer when reading from the
socket. This is how I noticed the issue, since I was setting a timeout of
1 minute, and saw my server blocking for this duration!

The following patch adds a (currently failing) test case to Wayland's
event-loop-test.c. It demonstrates the problem using two timers, which are
set to expire at the same time. The first timer to receive its expiry
callback updates the other timer with a much larger timeout, which then
causes the test to block for this timeout before calling the second timer's
callback.

As for a fix, I'm not so sure (which is why I thought I'd post the failing
test case first to show what I mean). I notice that it doesn't actually do
anything with the value read from the timerfd socket, which gives the number
of times the timer expired since the last read, or when the timer was last
updated (which blocks if the timer hasn't yet expired). I believe this value
should always read as 1 anyway, since we don't use periodic timers.

A simple fix would be to use the TFD_NONBLOCK option when creating the
timerfd, ensuring that the read call won't block. We'd then have to ignore
the case when the read returns EAGAIN.

10 years agoconnection: fix a format string typo in error message
Giulio Camuffo [Tue, 22 Apr 2014 13:03:12 +0000 (16:03 +0300)]
connection: fix a format string typo in error message

10 years agoconnection: Don't write past the end of the connection buffer
Ander Conselvan de Oliveira [Thu, 17 Apr 2014 15:20:37 +0000 (18:20 +0300)]
connection: Don't write past the end of the connection buffer

If a message was too big to fit in the connection buffer, the code
in wl_buffer_put would just write past the end of it.

I haven't seen any real world use case that would trigger this bug, but
it was possible to trigger it by sending a long enough string to the
wl_data_source.offer request.

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

10 years agoconfigure.ac: Bump version to 1.4.91 1.4.91
Kristian Høgsberg [Mon, 7 Apr 2014 23:08:42 +0000 (16:08 -0700)]
configure.ac: Bump version to 1.4.91

10 years agoshm: Disallow shrinking shm pools
Kristian Høgsberg [Mon, 7 Apr 2014 21:42:20 +0000 (14:42 -0700)]
shm: Disallow shrinking shm pools

Unused shm space will be automatically reclaimed if unused or can be
explicitly returned by using fallocate FALLOC_FL_PUNCH_HOLE.

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

10 years agoscanner: Only output each forward declaration once
Kristian Høgsberg [Thu, 3 Apr 2014 22:57:54 +0000 (15:57 -0700)]
scanner: Only output each forward declaration once

Just sort the types and only print unique type names.  We avoid using
the GCC pragma.

10 years agoAdd WL_PRINTF attribute and annotate wl_log_func_t
Kristian Høgsberg [Thu, 3 Apr 2014 21:18:45 +0000 (14:18 -0700)]
Add WL_PRINTF attribute and annotate wl_log_func_t

10 years agoprotocol: Document how clients are supposed to get the xkb keycode
Rui Matos [Tue, 25 Mar 2014 15:35:39 +0000 (16:35 +0100)]
protocol: Document how clients are supposed to get the xkb keycode

This encodes what everyone is doing and avoids other implementers
having to guess.

10 years agoAdd error handling for wl_cursors
Hardening [Tue, 18 Mar 2014 10:29:00 +0000 (11:29 +0100)]
Add error handling for wl_cursors

This patch adds some error management in wayland cursors

Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
10 years agoclient: Delay EPIPE handling so we get a chance to handle error events
Kristian Høgsberg [Wed, 26 Mar 2014 20:28:27 +0000 (13:28 -0700)]
client: Delay EPIPE handling so we get a chance to handle error events

10 years agoserver: Kill some unnecessary logs
Jasper St. Pierre [Sun, 23 Feb 2014 23:51:31 +0000 (18:51 -0500)]
server: Kill some unnecessary logs

In order to set a logging function all the time, the output we get
needs to be useful. Logging about trivial things like the socket
we're using and when clients disconnect doesn't realy help anyone.