platform/upstream/wayland.git
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.

10 years agotests: Fix build of noinst fixed-benchmark test
Bryce W. Harrington [Tue, 11 Mar 2014 00:01:47 +0000 (00:01 +0000)]
tests: Fix build of noinst fixed-benchmark test

Solves this build error:

  tests/fixed-benchmark.o: In function `benchmark':
  ./wayland/tests/fixed-benchmark.c:82: undefined reference to `clock_gettime'
  ./wayland/tests/fixed-benchmark.c:84: undefined reference to `clock_gettime'

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
10 years agoprotocol: try to clarify frame callback semantics
Pekka Paalanen [Mon, 24 Feb 2014 08:00:33 +0000 (10:00 +0200)]
protocol: try to clarify frame callback semantics

"the callback event will arrive after the next output refresh" is wrong,
if you interpret "output refresh" as framebuffer flip or the moment when
the new pixels turn into light the first time. Weston has probably never
worked this way.

Weston triggers the frame callbacks when it submits repainting commands
to the GPU, which is before the framebuffer flip.

Strike the incorrect claim, and the rest of the paragraph which no
longer offers useful information.

As a replacement, expand on the "throttling and driving animations"
characteristic. The main purpose is to let clients animate at the
display refresh rate, while avoiding drawing frames that will never be
presented.

The new claim is that the server should give some time between
triggering frame callbacks and repainting itself, for clients to draw
and commit. This is somewhat intimate with the repaint scheduling
algorithm a compositor uses, but hopefully the right intention.

Another point of this update is to imply, that frame callbacks should
not be used to count compositor repaint cycles nor monitor refresh
cycles. It has never been guaranteed to work. Removing the mention of
frame callback without an attach hopefully discourages such use.

v2: Don't just remove a paragraph, but add useful information about the
request's intent.

v3: Specify the order of posting frame callbacks.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Axel Davy <axel.davy@ens.fr>
Cc: Jason Ekstrand <jason@jlekstrand.net>
10 years agoupdate .gitignore
Pekka Paalanen [Mon, 10 Mar 2014 12:04:00 +0000 (14:04 +0200)]
update .gitignore

Makes 'git status' clean again after a successful 'make distcheck'.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
10 years agobuild: hide doxygen commands with AM_V_GEN
Pekka Paalanen [Mon, 10 Mar 2014 12:03:59 +0000 (14:03 +0200)]
build: hide doxygen commands with AM_V_GEN

I suppose the purpose was to print just one GEN line for each doxygen
rule being executed, not print the doxygen command.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
10 years agodoc: do not rebuild man pages if they are up to date
Pekka Paalanen [Mon, 10 Mar 2014 12:03:58 +0000 (14:03 +0200)]
doc: do not rebuild man pages if they are up to date

The doxygen.man make target was not a real file that was generated,
therefore the man page rule was ran on every make invocation. Replace it
with a real file that is produced by the man page rule.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
10 years agobuild: depend on generated protocol headers
Pekka Paalanen [Mon, 10 Mar 2014 12:03:57 +0000 (14:03 +0200)]
build: depend on generated protocol headers

Fixes the build failure where the protocol headers were not generated at
all before compiling src/.libs/libwayland_server_la-wayland-server.o.

The failure was reproducable by starting fresh with 'git clean -dxf' and
not having any wayland headers installed system-wide.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
10 years agobuild: Include protocol/ so we pick up generated headers
Kristian Høgsberg [Sat, 8 Mar 2014 00:02:19 +0000 (16:02 -0800)]
build: Include protocol/ so we pick up generated headers

10 years agobuild: Generated protocol files live in protocol/ now
Kristian Høgsberg [Fri, 7 Mar 2014 22:02:32 +0000 (14:02 -0800)]
build: Generated protocol files live in protocol/ now

Fix up the references in include_HEADERS.

10 years agobuild: Consolidate scanner build rules
Kristian Høgsberg [Fri, 7 Mar 2014 19:57:34 +0000 (11:57 -0800)]
build: Consolidate scanner build rules

10 years agobuild: Move tests/Makefile.am into toplevel Makefile.am
Kristian Høgsberg [Fri, 7 Mar 2014 08:00:18 +0000 (00:00 -0800)]
build: Move tests/Makefile.am into toplevel Makefile.am

10 years agobuild: Move src/Makefile.am into toplevel Makefile.am
Kristian Høgsberg [Fri, 7 Mar 2014 07:45:56 +0000 (23:45 -0800)]
build: Move src/Makefile.am into toplevel Makefile.am

10 years agobuild: Move cursor Makefile.am into toplevel Makefile.am
Kristian Høgsberg [Fri, 7 Mar 2014 07:15:02 +0000 (23:15 -0800)]
build: Move cursor Makefile.am into toplevel Makefile.am

10 years agobuild: Move protocol/ Makefile.am into toplevel Makefile.am
Kristian Høgsberg [Tue, 18 Feb 2014 22:55:09 +0000 (14:55 -0800)]
build: Move protocol/ Makefile.am into toplevel Makefile.am

A small step towards non-recursive build system for wayland too.

10 years agobuild: Stop using xmllint to validate protocol files
Kristian Høgsberg [Tue, 18 Feb 2014 22:52:00 +0000 (14:52 -0800)]
build: Stop using xmllint to validate protocol files

Same reason as commit cd31275f28b0a04d2ec5426dc81e875197b47e52 from weston:

    The scanner needs to be good enough.  If it crashes or fails to report
    invalid input, that needs to get fixed.

10 years agoconnection: Use wl_log to report errors
Jasper St. Pierre [Tue, 18 Feb 2014 00:04:28 +0000 (19:04 -0500)]
connection: Use wl_log to report errors

In some cases, like Xwayland, stdout and stderr are redirected to
/dev/null, losing us valuable information, while wl_log can be
overridden, allowing us to send it to a log file instead. This
can help debugging immensely.

10 years agoscanner: Add GCC pragmas to disable -Wredundant-decls
Jasper St. Pierre [Sat, 15 Feb 2014 18:29:16 +0000 (13:29 -0500)]
scanner: Add GCC pragmas to disable -Wredundant-decls

The code very intentionally emits a lot of redundant declarations
to simplify the scanner code. Somebody building with -Wredundant-decls
would have compile errors, so emit special pragmas to turn those
warnings off.

These pragmas should be ignored outside of gcc/clang.

10 years agowayland-client: Set a proper errno
Jasper St. Pierre [Mon, 17 Feb 2014 22:30:41 +0000 (17:30 -0500)]
wayland-client: Set a proper errno

errno is supposed to be positive, not negative. It seems that
everything else that calls display_fatal_error() calls it with
a positive error code, so do it here as well.

10 years agoprotocol: when buffer transform and scale change
Pekka Paalanen [Fri, 7 Feb 2014 09:13:01 +0000 (11:13 +0200)]
protocol: when buffer transform and scale change

Clarify when the pending and current buffer transform and scale values
change, and what exactly happens on commit.

This matches what Weston currently does.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
10 years agoclient: Queue display events on private queue and always dispatch
Kristian Høgsberg [Sat, 8 Feb 2014 00:50:50 +0000 (16:50 -0800)]
client: Queue display events on private queue and always dispatch

The wl_display events (error and delete_id) need to be handled even
if the default queue doesn't get dispatched for a while.  For example,
a busy EGL rendering loop hits wl_display.sync every eglSwapBuffers()
and we need to process the delete_id events to maintain the object ID
data structure.

As it is, that doesn't happen, but with this change we special case
wl_display events.  We put them on a custom, private queue and when
dispatching events, we always dispatch display_queue events first.
The wl_display proxy should still be the default_queue, so that objects
created from wl_display requests get assigned to that.

10 years agoclient: Rename display->queue to default_queue
Kristian Høgsberg [Sat, 8 Feb 2014 00:00:21 +0000 (16:00 -0800)]
client: Rename display->queue to default_queue

We'll add a new queue next, so rename the default queue first.

10 years agoMake default log handler print to stderr
Kristian Høgsberg [Fri, 7 Feb 2014 23:57:07 +0000 (15:57 -0800)]
Make default log handler print to stderr

On the client side we log fatal errors before we exit.  If a client doesn't
set a log handler, it's hard to figure out what goes wrong.

10 years agoRename wl_debug to debug_server/client
Jason Ekstrand [Thu, 19 Dec 2013 02:56:18 +0000 (20:56 -0600)]
Rename wl_debug to debug_server/client

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
10 years agoDon't deref the sample pointer in the wl_container_of macro
Neil Roberts [Tue, 4 Feb 2014 14:21:48 +0000 (14:21 +0000)]
Don't deref the sample pointer in the wl_container_of macro

The previous implementation of the wl_container_of macro was
dereferencing the sample pointer in order to get an address of the
member to calculate the offset. Ideally this shouldn't cause any
problems because the dereference doesn't actually cause the address to
be read from so it shouldn't matter if the pointer is uninitialised.
However this is probably technically invalid and could cause undefined
behavior. Clang appears to take advantage of this undefined behavior
and doesn't bother doing the subtraction. It also gives a warning when
it does this.

The documentation for wl_container_of implies that it should only be
given an initialised pointer and if that is done then there is no
problem with clang. However this is quite easy to forget and doesn't
cause any problems or warnings with gcc so it's quite easy to
accidentally break clang.

To fix the problem this changes the macro to use pointer -
offsetof(__typeof__(sample), member) so that it doesn't need to deref
the sample pointer. This does however require that the __typeof__
operator is supported by the compiler. In practice we probably only
care about gcc and clang and both of these happily support the
operator.

The previous implementation was also using __typeof__ but it had a
fallback path avoiding it when the operator isn't available. The
fallback effectively has undefined behaviour and it is targetting
unknown compilers so it is probably not a good idea to leave it in.
Instead, this patch just removes it. If someone finds a compiler that
doesn't have __typeof__ but does work with the old implementation then
maybe they could add it back in as a special case.

This patch removes the initialisation anywhere where the sample
pointer was being unitialised before using wl_container_of. The
documentation for the macro has also been updated to specify that this
is OK.

10 years agoprotocol: Fix build
Jasper St. Pierre [Fri, 31 Jan 2014 21:29:37 +0000 (16:29 -0500)]
protocol: Fix build

"data" is the name of the void* argument in the implementation.
While we probably shouldn't use such an easily-collidable name,
just rename the callback's argument to callback_data for now.

10 years agoprotocol: Fix documentation for the parameter of wl_callback
Jasper St. Pierre [Fri, 31 Jan 2014 20:55:48 +0000 (15:55 -0500)]
protocol: Fix documentation for the parameter of wl_callback

The parameter here is an opaque integer, rather than the event serial.
The "frame" callback uses this to pass the current time of day in
milliseconds.

10 years agoprotocol: Fix the name of the registry argument
Jasper St. Pierre [Fri, 31 Jan 2014 20:38:07 +0000 (15:38 -0500)]
protocol: Fix the name of the registry argument

A simple copy-paste typo.

10 years agoconfigure.ac: Bump version to 1.4 sandbox/pcoval/upstream 1.4.0
Kristian Høgsberg [Fri, 24 Jan 2014 04:50:27 +0000 (20:50 -0800)]
configure.ac: Bump version to 1.4

10 years agoresources-test: Don't send invalid event
Kristian Høgsberg [Mon, 20 Jan 2014 23:07:55 +0000 (15:07 -0800)]
resources-test: Don't send invalid event

Even if nothing receives the even, the arguments still need to be valid.
The test is sending out event 0 from the wl_display interface, which is
the error event.  This requires arg 0 to be a valid object and arg 2 to
be a non-null string.  The test just leaves that undefined, causing
intermittent test failures.

As it is, the resource destroy test doesn't need to send an event to
validate the various resource destroy hooks, so we can just remove the
call to wl_resource_post_event() alltogether.

Thanks to Matt Turner <mattst88@gmail.com> for pointing out the failure.

10 years agoprotocol: Clarify semantics of wl_subsurface.set_position
Jonas Ådahl [Sun, 19 Jan 2014 09:32:11 +0000 (10:32 +0100)]
protocol: Clarify semantics of wl_subsurface.set_position

Make it clear that multiple requests before commit are allowed and how it
is handled.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
10 years agoprotocol: Clarify semantics of sub-surface placement requests
Jonas Ådahl [Sun, 19 Jan 2014 09:32:10 +0000 (10:32 +0100)]
protocol: Clarify semantics of sub-surface placement requests

Clarify some semantics of wl_subsurface.place_below and
wl_subsurface.place_below that were not specified.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
10 years agoconfigure.ac: Bump version to 1.3.93 1.3.93
Kristian Høgsberg [Mon, 20 Jan 2014 05:58:27 +0000 (21:58 -0800)]
configure.ac: Bump version to 1.3.93

This is the release candidate.

10 years agoRevert "xwayland: Add .gitignore"
Kristian Høgsberg [Sun, 19 Jan 2014 18:03:22 +0000 (10:03 -0800)]
Revert "xwayland: Add .gitignore"

I accidentally committed Jaspers xserver patch to wayland.

This reverts commit 8a781aef0ebf8d5be4116fa40d9155af4ba61257.

10 years agoclient: Include poll.h instead of sys/poll.h
Jonas 'Sortie' Termansen [Tue, 14 Jan 2014 17:38:59 +0000 (18:38 +0100)]
client: Include poll.h instead of sys/poll.h

POSIX mandates the poll.h header as the standard location of poll(2).

10 years agoadd_shm_format: check wl_array_add return value before deref
U. Artie Eoff [Tue, 14 Jan 2014 17:18:03 +0000 (09:18 -0800)]
add_shm_format: check wl_array_add return value before deref

In wl_display_add_shm_format(), check the return value from
wl_array_add() before dereferencing it and assigning it a value.
Return the resulting pointer back to the caller.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agoxcursor: don't proceed if XcursorImageCreate failed
U. Artie Eoff [Fri, 10 Jan 2014 22:43:48 +0000 (14:43 -0800)]
xcursor: don't proceed if XcursorImageCreate failed

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agocursor: check for memory allocation errors
U. Artie Eoff [Fri, 10 Jan 2014 22:33:36 +0000 (14:33 -0800)]
cursor: check for memory allocation errors

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agocursor: free theme->name too
U. Artie Eoff [Fri, 10 Jan 2014 21:49:44 +0000 (13:49 -0800)]
cursor: free theme->name too

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agoresources-test: assert non-NULL return values
U. Artie Eoff [Fri, 10 Jan 2014 21:21:04 +0000 (13:21 -0800)]
resources-test: assert non-NULL return values

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agoqueue-test: assert non-NULL return values
U. Artie Eoff [Fri, 10 Jan 2014 21:18:42 +0000 (13:18 -0800)]
queue-test: assert non-NULL return values

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agoos-wrappers-test: assert closure is not NULL before invoking it
U. Artie Eoff [Fri, 10 Jan 2014 21:04:34 +0000 (13:04 -0800)]
os-wrappers-test: assert closure is not NULL before invoking it

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agoevent-loop-test: assert non-NULL results
U. Artie Eoff [Fri, 10 Jan 2014 20:55:25 +0000 (12:55 -0800)]
event-loop-test: assert non-NULL results

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agoconnection-test: assert closure is not NULL before invoking it
U. Artie Eoff [Fri, 10 Jan 2014 20:28:43 +0000 (12:28 -0800)]
connection-test: assert closure is not NULL before invoking it

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agoarray-test: assert wl_array_add result is not NULL
U. Artie Eoff [Fri, 10 Jan 2014 20:17:24 +0000 (12:17 -0800)]
array-test: assert wl_array_add result is not NULL

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agoshm: assert sigbus_data is not NULL before member access
U. Artie Eoff [Fri, 10 Jan 2014 19:26:27 +0000 (11:26 -0800)]
shm: assert sigbus_data is not NULL before member access

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
10 years agoxwayland: Add .gitignore
Jasper St. Pierre [Mon, 9 Dec 2013 21:29:03 +0000 (16:29 -0500)]
xwayland: Add .gitignore

10 years agoFix buffer overflow when serializing a closure object 28/13428/4 1.3.92
chi ding [Thu, 5 Dec 2013 13:28:53 +0000 (14:28 +0100)]
Fix buffer overflow when serializing a closure object

Here is the JIRA page of this issue
https://bugs.tizen.org/jira/browse/TIVI-1889

Change-Id: I773a6d2d8f6fd02ff10c92450db1fa8a69544219
Signed-off-by: Chi Ding <chi.ding@mobica.com>
Closes: https://bugs.freedesktop.org/show_bug.cgi?id=65186

10 years agoscanner: set errno=0 before strtol
Adrian Negreanu [Tue, 17 Dec 2013 11:48:54 +0000 (13:48 +0200)]
scanner: set errno=0 before strtol

POSIX says to set errno=0 before calling strtol since
the return value alne cannot tell a failure.

on ubuntu armel I get:

  ../src/wayland-scanner client-header < ../../protocol/wayland.xml > wayland-client-protocol.h
  <stdin>:1188: error: invalid integer (2)

Signed-off-by: Adrian Negreanu <adrian.m.negreanu@intel.com>
10 years agoconfigure.ac: Bump version to 1.3.91 for the alpha release 1.3.91
Kristian Høgsberg [Tue, 17 Dec 2013 07:51:12 +0000 (23:51 -0800)]
configure.ac: Bump version to 1.3.91 for the alpha release

10 years agoclient: Handle EINTR in wl_display_dispatch_queue()
Kristian Høgsberg [Mon, 9 Dec 2013 23:49:48 +0000 (15:49 -0800)]
client: Handle EINTR in wl_display_dispatch_queue()

Restart the poll() if we take a signal.  This is easily triggered in
an application that ends up blocking in eglSwapBuffers(), and causes EGL
to fail to allocate a back buffer.

10 years agodoc: Fix spelling of parameters
Jonas Ådahl [Mon, 9 Dec 2013 21:35:22 +0000 (22:35 +0100)]
doc: Fix spelling of parameters

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agodoc: Remove incorrect docmentation
Jonas Ådahl [Mon, 9 Dec 2013 21:35:21 +0000 (22:35 +0100)]
doc: Remove incorrect docmentation

The documentation was about wl_client_get_object(), not about
wl_resource_get_client().

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
10 years agoclient: Make wl_proxy_set_queue() with NULL revert to default queue
Neil Roberts [Thu, 5 Dec 2013 00:58:39 +0000 (16:58 -0800)]
client: Make wl_proxy_set_queue() with NULL revert to default queue

This will be useful in order to implement the
EGL_WL_create_wayland_buffer_from_image extension. The buffers created
within Mesa's Wayland platform are created using the the wl_drm object
as a proxy factory which means they will be set to use Mesa's internal
event queue. However, these buffers will be owned by the client
application so they ideally need to use the default event loop. This
function provides a way to set the proxy's event queue back to the
default.

krh: Edited from Neils original patch to just use wl_proxy_set_queue() with
a NULL argument instead of introducing a new function.

10 years agocursor: handle running out of buffer space
Pekka Paalanen [Fri, 29 Nov 2013 15:47:09 +0000 (17:47 +0200)]
cursor: handle running out of buffer space

If posix_fallocate is available, use it to detect when we are running
out of buffer space.

Propagate the failure properly through the various functions, stopping
loading cursors but keeping the cursors that were already successfully
loaded.

This may result in an animated cursor not having all of its images, or a
cursor theme not having all of its cursors. When that happens, the
failure is NOT communicated to the application. Instead, the application
will get NULL from wl_cursor_theme_get_cursor() for a cursor that was
not loaded successfully. If an animated cursor is missing only some
images, the animation is truncated but the cursor is still available.

This patch relies on the commit "os: use posix_fallocate in creating
sharable buffers" for defining HAVE_POSIX_FALLOCATE.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
10 years agoos: use posix_fallocate in creating sharable buffers
Pekka Paalanen [Fri, 29 Nov 2013 15:47:08 +0000 (17:47 +0200)]
os: use posix_fallocate in creating sharable buffers

If posix_fallocate is available, use it instead of ftruncate. Unlike
ftruncate, when posix_fallocate succeeds, it guarantees that you cannot
run out of disk space, when later writing to the mmap()'ed file.

With posix_fallocate, if os_create_anonymous_file() succeeds, the
program cannot get a SIGBUS later from accessing this file via mmap. If
there is insufficient disk space, the function fails and errno is set to
ENOSPC.

This is useful on systems, that limit the available buffer space by
having XDG_RUNTIME_DIR on a small tmpfs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
10 years agoAdd -pthread to AM_CFLAGS to do the right thing when using threads
Kristian Høgsberg [Sat, 23 Nov 2013 20:24:26 +0000 (12:24 -0800)]
Add -pthread to AM_CFLAGS to do the right thing when using threads

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

10 years agoconnection: Error out if file descriptor was not received
Lubomir Rintel [Sat, 16 Nov 2013 13:31:03 +0000 (14:31 +0100)]
connection: Error out if file descriptor was not received

Otherwise the tail of fds_in buffer would just shift beyond the beginning.
That confuses the actual request handler and results in a crash further on
due to corrupted tail.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
10 years agowayland-server: Improve error messages for bad globals
Jasper St. Pierre [Wed, 13 Nov 2013 02:44:37 +0000 (21:44 -0500)]
wayland-server: Improve error messages for bad globals

A bug in Weston's toytoolkit gave me an hour of debugging headaches.
Improve the error messages that we send if a client requests an invalid
global, either by name or by version.

10 years agoUpdate .gitignore for protocol/
Jasper St. Pierre [Wed, 13 Nov 2013 02:44:36 +0000 (21:44 -0500)]
Update .gitignore for protocol/

10 years agoclient: Introduce functions to allocate and marshal proxies atomically
Kristian Høgsberg [Fri, 15 Nov 2013 05:29:06 +0000 (21:29 -0800)]
client: Introduce functions to allocate and marshal proxies atomically

The server requires clients to only allocate one ID ahead of the previously
highest ID in order to keep the ID range tight.  Failure to do so will
make the server close the client connection.  However, the way we allocate
new IDs is racy.  The generated code looks like:

  new_proxy = wl_proxy_create(...);
  wl_proxy_marshal(proxy, ... new_proxy, ...);

If two threads do this at the same time, there's a chance that thread A
will allocate a proxy, then get pre-empted by thread B which then allocates
a proxy and then passes it to wl_proxy_marshal().  The ID for thread As
proxy will be one higher that the currently highest ID, but the ID for
thread Bs proxy will be two higher.  But since thread B prempted thread A
before it could send its new ID, B will send its new ID first, the server
will see the ID from thread Bs proxy first, and will reject it.

We fix this by introducing wl_proxy_marshal_constructor().  This
function is identical to wl_proxy_marshal(), except that it will
allocate a wl_proxy for NEW_ID arguments and send it, all under the
display mutex.  By introducing a new function, we maintain backwards
compatibility with older code from the generator, and make sure that
the new generated code has an explicit dependency on a new enough
libwayland-client.so.

A virtual Wayland merit badge goes to Kalle Vahlman, who tracked this
down and analyzed the issue.

Reported-by: Kalle Vahlman <kalle.vahlman@movial.com>
10 years agoprotocol: add sub-surfaces to the core
Pekka Paalanen [Fri, 15 Nov 2013 14:09:45 +0000 (16:09 +0200)]
protocol: add sub-surfaces to the core

The sub-surface protocol was originally committed into Weston on May
10th, 2013, in commit 2396aec6842c709a714f3825dbad9fd88478f2e6. The
design for the protocol had started in the beginning of December 2012. I
think it is high time to move this into the core now.

This patch copies the sub-surface protocol as it was in Weston on Nov
15th, 2013, into Wayland. Weston gets a patch to remove the protocol from
there.

Sub-surface is a wl_surface role. You create a wl_surface as usual, and
assign it the sub-surface role and a parent wl_surface. Sub-surfaces are
an integral part of the parent surface, and stay glued to the parent.
For window management, a window is the union of the top-level
wl_surface and all its sub-surfaces. Sub-surfaces are not clipped to the
parent, and the union of the surface tree can be larger than the
(top-level) wl_surface at its root.

The representative use case for sub-surfaces is a video player window.
When the video content is given its own wl_surface, there is no need to
modify the video frame contents after decoding or copy them into a whole
window sized buffer before submitting it to the compositor. This allows
efficient, zero-copy video presentation paths, where video decoding
hardware produces a (YUV) buffer, which eventually ends up in a
(YUV-capable) hardware overlay and is scanned out directly.

This can also be used for zero-copy presentation of windowed OpenGL
content, where the OpenGL rendering engine does not need to draw or
avoid window decorations.

Sub-surfaces allow mixing different buffer types into the same window,
e.g. software-rendered decorations in wl_shm buffers, and live content
in EGL-based buffers.

However, the sub-surface extension does not offer clipping or scaling
facilities, or accurate presentation timing. Those are topics for
additional extensions.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>