platform/upstream/wayland.git
8 years agoscanner: Replace #define tab with space
Yong Bakos [Tue, 24 May 2016 19:55:12 +0000 (13:55 -0600)]
scanner: Replace #define tab with space

wayland-client-protocol.h and wayland-server-protocol.h use a tab
between the identifier and token of generated #defines for request/event
opcodes and versions. While this sometimes enables vertical alignment,
it more frequently doesn't, and leads to awkward spacing.

Replace the tab with a space, for consistency and readability.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Quentin Glidic <sardemff7+git@sardemff7.net>
8 years agoserver, server-core: Minimize fwd decs, use macro, and format
Yong Bakos [Mon, 23 May 2016 23:59:33 +0000 (17:59 -0600)]
server, server-core: Minimize fwd decs, use macro, and format

wayland-server.h: Adjust line breaks between prototypes.

wayland-server-core.h:
Adjust line breaks between prototypes.
Adjust space between splats and identifiers.
Remove unconventional linebreak before first parameter.
Add line breaks after return types.
Remove unnecessary forward declarations, and:
- move 'struct wl_client' declaration close to the dependent typedef
- tastefully move 'wl_shm_buffer_get' to leverage the return type
Replace explicit __attribute__ with WL_PRINTF macro.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoclient-core: Add missing line breaks
Yong Bakos [Mon, 23 May 2016 23:06:09 +0000 (17:06 -0600)]
client-core: Add missing line breaks

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoevent-loop: Include wayland-util.h
Yong Bakos [Sat, 21 May 2016 04:23:58 +0000 (22:23 -0600)]
event-loop: Include wayland-util.h

event-loop.c uses WL_EXPORT and wl_list, which are defined in
wayland-util.h.

Include wayland-util.h explicitly, rather than transitively through
wayland-server-core.h.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Sam Spilsbury <smspillaz@gmail.com>
8 years agowayland-shm: Include wayland-util.h
Yong Bakos [Sat, 21 May 2016 04:18:36 +0000 (22:18 -0600)]
wayland-shm: Include wayland-util.h

wayland-shm.c uses WL_EXPORT and wl_array, which are defined in
wayland-util.h.

Include wayland-util.h explicitly, rather than transitively through
wayland-server.h.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Sam Spilsbury <smspillaz@gmail.com>
8 years agoscanner: Fix reported executable name to 'wayland-scanner'
Bryce Harrington [Mon, 6 Jun 2016 17:58:56 +0000 (10:58 -0700)]
scanner: Fix reported executable name to 'wayland-scanner'

'wayland-scanner -v' (correctly) reports the program as named
"wayland-scanner", but 'wayland-scanner -h' was inconsistent, referring
to it as './scanner'.

Also refactor this and other references to the program name to use a
common #define, PROGRAM_NAME.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Tested-by: Yong Bakos <ybakos@humanoriented.com>
8 years agowayland-server: Clarify included header dependencies
Yong Bakos [Wed, 18 May 2016 03:02:01 +0000 (21:02 -0600)]
wayland-server: Clarify included header dependencies

wayland-server.c directly depends on wayland-util.h, and will include
wayland-server-protocol.h via wayland-server.h.

Explicitly include wayland-util.h, making this dependency clear.
Remove the redundant inclusion of wayland-server-protocol.h.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoevent-loop: Make transitive include explicit
Yong Bakos [Mon, 16 May 2016 18:05:39 +0000 (12:05 -0600)]
event-loop: Make transitive include explicit

The explicit inclusion of wayland-server.h hides the real dependency, which
is wayland-server-core.h.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
8 years agodoc: Unpublish global_zombie_object and wl_interface_equal
Yong Bakos [Thu, 12 May 2016 20:52:39 +0000 (15:52 -0500)]
doc: Unpublish global_zombie_object and wl_interface_equal

Both global_zombie_object and wl_interface_equal are private, yet were
part of public documentation despite not being part of the public API.

Move these two definitions to the top of an existing doxygen \cond block,
which removes them from the public documentation.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agodoc: Unpublish wl_log* and wl_abort
Yong Bakos [Thu, 12 May 2016 20:52:38 +0000 (15:52 -0500)]
doc: Unpublish wl_log* and wl_abort

The public documentation included descriptions of wl_log_stderr_handler,
wl_log_func_t wl_log_handler, wl_log and wl_abort. These are not accessible
via the public API.

Move the doxygen \endcond command to wrap these definitions, removing them
from publication.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agodoc: Unpublish wl_display_get_additional_shm_formats
Yong Bakos [Thu, 12 May 2016 20:52:37 +0000 (15:52 -0500)]
doc: Unpublish wl_display_get_additional_shm_formats

The Wayland docbook and the doxygen html docs had been presenting
wl_display_get_additional_shm_formats as part of the public API, but the
prototype for this function is in wayland-private.h.

Add a \private annotation to the doc comment, preventing doxygen from
publishing this function as public.
Add logic to the publican xsl to only transform elements with a "prot"
attribute value of "public".

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoconfigure.ac: bump version to 1.11.90 for open development
Pekka Paalanen [Wed, 1 Jun 2016 08:08:02 +0000 (11:08 +0300)]
configure.ac: bump version to 1.11.90 for open development

As announced in 1.11.0 release notes, master is open again.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoconfigure.ac: bump to version 1.11.0 for the official release 1.11.0
Bryce Harrington [Wed, 1 Jun 2016 00:11:20 +0000 (17:11 -0700)]
configure.ac: bump to version 1.11.0 for the official release

8 years agoconfigure.ac: bump to version 1.10.93 for the RC1 release 1.10.93
Bryce Harrington [Tue, 24 May 2016 19:29:59 +0000 (12:29 -0700)]
configure.ac: bump to version 1.10.93 for the RC1 release

8 years agoscanner: Remove unused forward decs from client protocol
Yong Bakos [Fri, 20 May 2016 02:31:16 +0000 (20:31 -0600)]
scanner: Remove unused forward decs from client protocol

wayland-client-protocol.h had forward declarations for wl_client and
wl_resource, yet nothing on the client side references these types.

Add a 'side' condition to only generate these forward declarations in the
server protocol header.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agodisplay-test: move a misplaced comment
Marek Chalupa [Fri, 13 May 2016 13:01:18 +0000 (15:01 +0200)]
display-test: move a misplaced comment

we split a function while refactoring in c643781 and now
the comment makes no sense

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agotests: Check for client/server-core.h inclusion
Yong Bakos [Thu, 19 May 2016 16:27:29 +0000 (10:27 -0600)]
tests: Check for client/server-core.h inclusion

The purpose of wayland-*-protocol-core.h is to mimc the
wayland-*-protocol.h generated by scanner --include-core-only.
The only difference being what wayland-*-protocol.h should include.

Add an include check in the headers-protocol-core-test, to be sure that
a wayland-*-protocol.h generated with the --include-core-only option
properly includes wayland-*-core.h.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoconfigure.ac: bump to version 1.10.92 for the beta release 1.10.92
Bryce Harrington [Wed, 18 May 2016 05:07:48 +0000 (22:07 -0700)]
configure.ac: bump to version 1.10.92 for the beta release

8 years agoprivate: Remove unnecessary forward declarations
Yong Bakos [Sat, 7 May 2016 14:11:30 +0000 (09:11 -0500)]
private: Remove unnecessary forward declarations

Declarations for wl_connection and wl_closure are not needed here.
wl_closure already has a complete definition.
Removing these forward declarations results in a clean, warning-free compile.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
[Updated to apply to trunk]
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoconnection: Move wl_interface_equal to util
Yong Bakos [Sun, 8 May 2016 13:44:08 +0000 (08:44 -0500)]
connection: Move wl_interface_equal to util

Move the wl_interface_equal prototype to the top of wayland-private, where
it is not buried in the middle of map, connection and closure functions.

Move the implementation out of connection and into util. This is a utility
function, not specific to connections, and has call sites within connection,
wayland-client and wayland-server.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agodoc: Formalize file comment in wayland-client.h, wayland-server.h
Yong Bakos [Sun, 8 May 2016 19:42:28 +0000 (14:42 -0500)]
doc: Formalize file comment in wayland-client.h, wayland-server.h

Publican was generating a subtle error during a build:
Error: no ID for constraint linkend: Server-wayland-server-core_8h.

This was caused by doxygen applying the doc comment at the top of
wayland-server.h as the documentation for struct wl_object. As such, the
generated documentation for wl_object was also very incorrect.

Make the file doc comments in wayland-client.h and wayland-server.h real
doxygen file doc comments with the \file command, add a \brief, make the
inclusion warning a \warning, correct the language of the comment in
wayland-server.h, and remove one unnecessary line break.

This squelches the publican error, removes the bad wl_object documentation,
and makes the comment appear in the generated html documentation.

References: d74a9c079b1aeb44f69b4132dc2c38362e21f281

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoprotocol: Remove double line break
Yong Bakos [Sat, 7 May 2016 23:14:11 +0000 (18:14 -0500)]
protocol: Remove double line break

All vertical whitespace should manifest as a single blank line, never two.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
8 years agoscanner: Add version argument to wayland-scanner
Armin Krezović [Thu, 5 May 2016 15:27:57 +0000 (17:27 +0200)]
scanner: Add version argument to wayland-scanner

This adds a command line argument to print wayland-scanner version.

It also makes wayland-scanner emit a comment with wayland library
version to every file it generates.

v2: separate variable definitions into their own lines and remove
    old style "version" argument

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Tested-by: Yong Bakos <ybakos@humanoriented.com>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoconfigure.ac: bump to version 1.10.91 for the alpha release 1.10.91
Bryce Harrington [Wed, 4 May 2016 00:56:22 +0000 (17:56 -0700)]
configure.ac: bump to version 1.10.91 for the alpha release

8 years agoprotocol: add support for cross-interface enum attributes
Auke Booij [Sat, 5 Dec 2015 12:39:12 +0000 (12:39 +0000)]
protocol: add support for cross-interface enum attributes

The enum attribute, for which scanner support was introduced in
1771299, can be used to link message arguments to <enum>s. However,
some arguments refer to <enum>s in a different <interface>.

This adds scanner support for referring to an <enum> in a different
<interface> using dot notation. It also sets the attributes in this
style in the wayland XML protocol (wl_shm_pool::create_buffer::format
to wl_shm::format, and wl_surface::set_buffer_transform::transform to
wl_output::transform), and updates the documentation XSL so that this
new style is supported.

Changes since v2:
 - add object:: prefix for all enumerations in the documentation
 - fix whitespace in scanner.c
 - minor code fixup to return early and avoid casts in scanner.c

Changes since v1:
 - several implementation bugs fixed

Signed-off-by: Auke Booij <auke@tulcod.com>
Reviewed-by: Nils Christopher Brause <nilschrbrause@googlemail.com>
Reviewed-by: Bill Spitzak <spitzak@gmail.com>
[Pekka: rebased across cde251a124d41977b447098cc530fcad2834a45f]
[Pekka: wrap lines and space fixes in scanner.c]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoprotocol: Add summaries to event parameters
Yong Bakos [Sat, 30 Apr 2016 12:35:50 +0000 (07:35 -0500)]
protocol: Add summaries to event parameters

All event arg elements now have an appropriate summary attribute.
This was conducted mostly in response to the undocumented parameter
warnings generated during 'make check'.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agotests: fix typo
Eric Engestrom [Mon, 2 May 2016 08:49:37 +0000 (09:49 +0100)]
tests: fix typo

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agodoc: fix typos
Eric Engestrom [Mon, 2 May 2016 08:49:36 +0000 (09:49 +0100)]
doc: fix typos

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoutil: fix typo
Eric Engestrom [Mon, 2 May 2016 08:49:35 +0000 (09:49 +0100)]
util: fix typo

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoserver: fix typo
Eric Engestrom [Mon, 2 May 2016 08:49:34 +0000 (09:49 +0100)]
server: fix typo

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoclient: fix typo
Eric Engestrom [Mon, 2 May 2016 08:49:33 +0000 (09:49 +0100)]
client: fix typo

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoprotocol: Hyphenate compound adjective surface-local
Yong Bakos [Thu, 28 Apr 2016 17:01:34 +0000 (12:01 -0500)]
protocol: Hyphenate compound adjective surface-local

Remove superfluous 'local' from 'buffer local'.
In addition, simplify the phrasing of local x/y coordinates in parameter
summaries.

See https://lists.freedesktop.org/archives/wayland-devel/2016-April/028249.html.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agodoc: Hyphenate compound adjectives window-local, surface-local
Yong Bakos [Thu, 28 Apr 2016 17:01:33 +0000 (12:01 -0500)]
doc: Hyphenate compound adjectives window-local, surface-local

See https://lists.freedesktop.org/archives/wayland-devel/2016-April/028249.html.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoclient: Fix wl_display_roundtrip_queue() race condition
Jonas Ådahl [Wed, 27 Apr 2016 07:37:41 +0000 (15:37 +0800)]
client: Fix wl_display_roundtrip_queue() race condition

Without this commit, wl_display_roundtrip_queue() is vulnerable to a
race condition, causing the callback to be dispatched on the wrong
queue.

The race condition happens if some non-main thread calls
wl_display_roundtrip_queue() with its thread local queue, and the main
thread reads and dispatches the callback event from the
wl_display_sync() call before the thread local queue is set.

The issue is fixed by using a proxy wrapper, making the initialization
of the callback proxy atomic, effectively making it no longer possible
for some other thread to dispatch the proxy before the correct thread
local queue is set.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
[Pekka: check display_wrapper]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agotests/queue-test: Add tests for proxy wrappers
Jonas Ådahl [Fri, 29 Apr 2016 11:30:23 +0000 (19:30 +0800)]
tests/queue-test: Add tests for proxy wrappers

Test that doing wl_display.sync on a wrapped proxy with a special queue
works as expected.

Test that creating a wrapper on a destroyed but not freed proxy fails.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoclient: Introduce proxy wrappers
Jonas Ådahl [Fri, 29 Apr 2016 11:30:22 +0000 (19:30 +0800)]
client: Introduce proxy wrappers

Using the libwayland-client client API with multiple threads with
thread local queues are prone to race conditions.

The problem is that one thread can read and queue events after another
thread creates a proxy but before it sets the queue.

This may result in the event to the proxy being silently dropped, or
potentially dispatched on the wrong thread had the creating thread set
the implementation before setting the queue.

This patch introduces API to solve this case by introducing "proxy
wrappers". In short, a proxy wrapper is a wl_proxy struct that will
never itself proxy any events, but may be used by the client to set a
queue, and use it instead of the original proxy when sending requests
that creates new proxies. When sending requests, the wrapper will
work in the same way as the normal proxy object, but the proxy created
by sending a request (for example wl_display.sync) will inherit to the
same proxy queue as the wrapper.

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

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
8 years agoclient: Make proxy_destroy a static function
Jonas Ådahl [Wed, 27 Apr 2016 06:46:54 +0000 (14:46 +0800)]
client: Make proxy_destroy a static function

proxy_destroy() is just the implementation of the atomic part of
wl_proxy_destroy(), so lets make it static.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoconnection: remove redundant assignment
Marek Chalupa [Fri, 22 Apr 2016 15:46:00 +0000 (17:46 +0200)]
connection: remove redundant assignment

the code is something like:

  if (object == NULL && ...) {
      object = NULL;
      return;
  }

first, the object is already NULL, second, the assignment has no effect
since we return from the function right away

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
8 years agoprotocol: Correct grammar and spelling
Yong Bakos [Tue, 5 Apr 2016 23:24:01 +0000 (18:24 -0500)]
protocol: Correct grammar and spelling

Fix grammar, spelling, tense, and other inconsistencies, based on
correctness, consistency, and precedence both here and influenced
by wayland-protocols.

- Standardize lower case for summary attribute values.
- Minor vertical whitespace removal consistency.
- Standarize references to coordinates, preferring 'surface local'
- Fix spelling, grammar, tense, and punctuation.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
8 years agoutils: move include directives before extern "C" wrapper
Emil Velikov [Sun, 17 Apr 2016 11:29:24 +0000 (12:29 +0100)]
utils: move include directives before extern "C" wrapper

Analogous to last two commits.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
8 years agoserver: move include directives before extern "C" wrapper
Emil Velikov [Sun, 17 Apr 2016 11:29:23 +0000 (12:29 +0100)]
server: move include directives before extern "C" wrapper

Analogous to previous commit but for the server(-core) header.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
8 years agoscanner: move include directives before extern "C" wrapper
Emil Velikov [Sun, 17 Apr 2016 11:29:22 +0000 (12:29 +0100)]
scanner: move include directives before extern "C" wrapper

Adding extern "C" wrapper before includes (especially system ones) is
illadvised as the headers themselves can behave diffently in that case.

See the section "Including C Headers in C++ Code" in the following
http://www.oracle.com/technetwork/articles/servers-storage-dev/mixingcandcpluspluscode-305840.html

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
8 years agowayland-client: fix spelling mistake
Eric Engestrom [Sat, 2 Apr 2016 16:04:05 +0000 (17:04 +0100)]
wayland-client: fix spelling mistake

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
8 years agoprotocol: fix spelling mistake
Eric Engestrom [Sat, 2 Apr 2016 16:04:04 +0000 (17:04 +0100)]
protocol: fix spelling mistake

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
8 years agoscanner: Fix spacing of @param
Yong Bakos [Thu, 31 Mar 2016 23:55:54 +0000 (18:55 -0500)]
scanner: Fix spacing of @param

Adds one space to the @param lines in generated .h files,
aligning the indentation with the rest of the comment block.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agoignore: Add *.dtd.embed
Yong Bakos [Fri, 11 Mar 2016 04:31:59 +0000 (22:31 -0600)]
ignore: Add *.dtd.embed

Although autogen.sh has a --disable-dtd-validation option, it is
on by default, so it seems convenient to add the generated symlink
to .gitignore.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agodoc: Ignore html subdirectory.
Yong Bakos [Thu, 10 Mar 2016 20:36:08 +0000 (14:36 -0600)]
doc: Ignore html subdirectory.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoshm: Log a warning if a shm buffer address is requested when it may be invalid
Derek Foreman [Tue, 9 Feb 2016 22:29:49 +0000 (16:29 -0600)]
shm: Log a warning if a shm buffer address is requested when it may be invalid

If wl_shm_buffer_get_data() is called on a shm pool that has an external
reference and a pending resize, then the buffer may be outside the pool's
current mapping.

Log a warning if this happens.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoshm: Defer wl_shm_pool_resize if a pool has external references
Derek Foreman [Tue, 9 Feb 2016 22:03:48 +0000 (16:03 -0600)]
shm: Defer wl_shm_pool_resize if a pool has external references

If a compositor is rendering in one thread while dispatching wayland
events in another, a wl_shm_pool_resize() could change the memory
mappings it's rendering from and cause a crash.

Now we defer wl_shm_pool_resize() if the compositor has references on a
pool, and perform the actual resize when it drops those references.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoshm: Split pool reference counting into external and internal references
Derek Foreman [Tue, 9 Feb 2016 22:03:47 +0000 (16:03 -0600)]
shm: Split pool reference counting into external and internal references

This is a preliminary step towards deferring shm resize operations until
after the compositor has released all external references on a pool.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoserver: Fix shm_create_pool size fail path fd leak
Sergi Granell [Thu, 18 Feb 2016 22:59:29 +0000 (23:59 +0100)]
server: Fix shm_create_pool size fail path fd leak

If the client passed a size <= 0 to shm_create_pool, it would
go to err_free, which wouldn't close the fd, and thus leave it opened.

We can also move the size check before the struct wl_shm_pool
malloc, so in case the client passes a wrong size, it won't
do an unnecessary malloc and then free.
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agodoc: Note strong recommendation to use S-o-b in contributions
Bryce Harrington [Fri, 4 Mar 2016 18:50:23 +0000 (10:50 -0800)]
doc: Note strong recommendation to use S-o-b in contributions

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agodoc: link between client and server doc and to the wayland book
Peter Hutterer [Mon, 29 Feb 2016 23:28:49 +0000 (09:28 +1000)]
doc: link between client and server doc and to the wayland book

And insert "client" or "server" into the PROJECT_NAME to know which one we
have.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agodoc: generate doxygen html output from the scanner
Peter Hutterer [Mon, 29 Feb 2016 23:26:21 +0000 (09:26 +1000)]
doc: generate doxygen html output from the scanner

This switches the scanner to generate doxygen-compatible tags for the
generated protocol headers, and hooks up the doxygen build to generate server
and client-side API documentation. That documentation is now in
Client/ and Server/, respectively.

GENERATE_HTML is on by default and must be disabled for the xml/man targets to
avoid messing up the new documentation. We disable all three three targets in
the doxyfile (xml and man default to NO anyway) to make it obvious that they
need to be set in the per-target instructions.

Each protocol is a separate doxygen @page, with each interface a @subpage.
Wayland only has one protocol, wayland-protocols will have these nested.
Each protocol page has a list of interfaces and the copyright and description
where available.
All interfaces are grouped by doxygen @defgroup and @ingroups and appear in
"Modules" in the generated output. Each interface subpage has the description
and a link to the actual API doc.
Function, struct and #defines are documented in doxygen style and associated
with the matching interface.

Note that pages and groups have fixed HTML file names and are directly
linkable/bookmark-able.

The @mainpage is a separate file that's included at build time. It doesn't
contain much other than links to where the interesting bits are. It's a static
file though that supports markdown, so we can extend it easily in the future.

For doxygen we need the new options EXTRACT_ALL and OPTIMIZE_OUTPUT_FOR_C so
it scans C code properly. EXTRACT_STATIC is needed since most of the protocol
hooks are static.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoscanner: avoid executable stack
Pekka Paalanen [Wed, 2 Mar 2016 09:00:35 +0000 (11:00 +0200)]
scanner: avoid executable stack

Before this patch:
$ scanelf -lpqe ./wayland-scanner
RWX --- ---  ./wayland-scanner

That indicates the stack is executable, which is a bad thing for
security. Wayland-scanner does not actually need an executable stack, it
is just an oversight from using an .S file in the sources.

Add a special incantation in dtddata.S to make it not cause the stack to
become executable.

Reported-by: Mart Raudsepp <leio@gentoo.org>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Mart Raudsepp <leio@gentoo.org>
8 years agobuild: fix ./configure --disable-dtd-validation
Pekka Paalanen [Mon, 29 Feb 2016 12:59:51 +0000 (14:59 +0200)]
build: fix ./configure --disable-dtd-validation

When configured with --disable-dtd-validation:

  CPPAS    src/dtddata.o
src/dtddata.S: Assembler messages:
src/dtddata.S:39: Error: file not found: src/wayland.dtd.embed
Makefile:1520: recipe for target 'src/dtddata.o' failed

This is because the variable name used does not match the implicit
variable name in autoconf.

Fix the variable name, making both --disable-dtd-validation and
--enable-dtd-validation to what they should.

Do not try to build dtddata.S if dtd-validation is disabled. It depends
on wayland.dtd.embed which is created by configure only if
dtd-validation is enabled.

If not building dtddata.S, also make sure the extern definitions in
scanner.c are compiled out.

Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=575212
Reported-by: leio@gentoo.org
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agotests: add test for receiving an error on destroyed object
Marek Chalupa [Mon, 22 Feb 2016 13:37:00 +0000 (14:37 +0100)]
tests: add test for receiving an error on destroyed object

test if receiving an error on already destroyed object won't
do any harm

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Tested-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoclient: Don't segfault when receiving error on destroyed object
Jonas Ådahl [Mon, 22 Feb 2016 05:37:26 +0000 (13:37 +0800)]
client: Don't segfault when receiving error on destroyed object

If an error is received on a destroyed object, we'd get NULL passed
to display_handle_error() instead of a pointer to a valid wl_proxy.

The logging is changed to report [unknown interface] and [unknown id]
instead of the actual interface name and id.

The wl_display_get_protocol_error() documentation is updated to handle
the situation. For when the proxy was NULL, the object id 0 and
interface NULL is written.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
[Pekka: changed the error message wording]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Jonas Ådahl <jadahl@gmail.com>
8 years agodoc: Use enum argument type to make links in protocol documentation
Bill Spitzak [Fri, 6 Nov 2015 16:27:27 +0000 (08:27 -0800)]
doc: Use enum argument type to make links in protocol documentation

Reviewed-by: Auke Booij <auke@tulcod.com>
8 years agoRevert "server: validate resource versions at creation time"
Derek Foreman [Fri, 19 Feb 2016 00:23:05 +0000 (18:23 -0600)]
Revert "server: validate resource versions at creation time"

This reverts commit 88ff135ad46b556b6fdeb1244ffd019a262967bc.

The parent interface version may be higher than this interface version,
and the child object should inherit that version.

This check is wrong.

8 years agoRevert "build: build distcheck with --enable-fatal-warnings"
Derek Foreman [Wed, 17 Feb 2016 15:12:58 +0000 (09:12 -0600)]
Revert "build: build distcheck with --enable-fatal-warnings"

This reverts commit 8125919b0d8e7c776652e4f1d829b9edfa6c4a68.

This makes things far more annoying than intended, especially since
the list of default warnings isn't consistent from distro to distro.

8 years agobuild: build distcheck with --enable-fatal-warnings
Derek Foreman [Fri, 15 Jan 2016 19:33:53 +0000 (13:33 -0600)]
build: build distcheck with --enable-fatal-warnings

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agobuild: Add an --enable-fatal-warnings configure option
Derek Foreman [Fri, 15 Jan 2016 19:33:52 +0000 (13:33 -0600)]
build: Add an --enable-fatal-warnings configure option

New --enable-fatal-warnings ./configure option that just adds -Werror
to GCC_CFLAGS

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoserver: validate resource versions at creation time
Derek Foreman [Fri, 15 Jan 2016 16:06:48 +0000 (10:06 -0600)]
server: validate resource versions at creation time

We shouldn't ever create a resource with version less than 1 or
greater than the interface version.

Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
8 years agoresource-test: Use wl_seat instead of wl_display for testing
Derek Foreman [Thu, 14 Jan 2016 20:32:38 +0000 (14:32 -0600)]
resource-test: Use wl_seat instead of wl_display for testing

We're creating resources with versions up to 4.  wl_display isn't version 4,
so this is technically verifying that we can do something we shouldn't.

wl_seat already has versions this high, so switch to that.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoconfigure.ac: bump to version 1.10.90 for open development
Bryce Harrington [Wed, 17 Feb 2016 01:15:26 +0000 (17:15 -0800)]
configure.ac: bump to version 1.10.90 for open development

Master is open for new feature development again.

8 years agoconfigure.ac: bump to version 1.10.0 for the official release 1.10.0
Bryce Harrington [Tue, 16 Feb 2016 20:03:40 +0000 (12:03 -0800)]
configure.ac: bump to version 1.10.0 for the official release

8 years agoconnection: Don't add uninitialized memory as 4 byte alignment padding
Jonas Ådahl [Wed, 10 Feb 2016 15:35:44 +0000 (23:35 +0800)]
connection: Don't add uninitialized memory as 4 byte alignment padding

When we are adding padding bytes making our wl_buffer buffer content 4
byte aligned, we are just moving the pointer. Since the buffer is
allocated using plain malloc(), this means our padding bytes are
effectively uninitialized data, which could be anything previously
allocated in the server process. As we'll be sharing this buffer
content with arbitrary clients, we are effectively sharing private
memory with every client, and even though a well behaving client will
discard any such memory, a malicious client may not.

Therefor, to avoid any potential missuse of the uninitialized padding
memory shared between the server and client, initialize the buffer
content to 0, making the padding bytes always 0.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoconfigure.ac: bump to version 1.9.93 for the RC1 release 1.9.93
Bryce Harrington [Tue, 9 Feb 2016 21:26:21 +0000 (13:26 -0800)]
configure.ac: bump to version 1.9.93 for the RC1 release

8 years agocosmetic: add an space after if
Sergi Granell [Thu, 4 Feb 2016 20:48:21 +0000 (21:48 +0100)]
cosmetic: add an space after if

8 years agocosmetic: use tabs instead of spaces
Sergi Granell [Thu, 4 Feb 2016 20:35:07 +0000 (21:35 +0100)]
cosmetic: use tabs instead of spaces

8 years agoscanner: Fix oddities in copyright printing
Derek Foreman [Tue, 2 Feb 2016 20:56:57 +0000 (14:56 -0600)]
scanner: Fix oddities in copyright printing

Some copyright strings could result in broken generated header files with
unmatched */

This change:
Runs the loop long enough so the copyright[i] == 0 test can actually
happen. (if there was no \n no copyright text was printed, */ still was)

Prints the opening /* even if there was whitespace at the start of
the very first line.

Only emits a */ if a /* was printed.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoconfigure.ac: bump to version 1.9.92 for the beta release 1.9.92
Bryce Harrington [Tue, 2 Feb 2016 23:30:36 +0000 (15:30 -0800)]
configure.ac: bump to version 1.9.92 for the beta release

8 years agoscanner: Print filename on DTD validation error
Jonas Ådahl [Mon, 25 Jan 2016 09:28:06 +0000 (17:28 +0800)]
scanner: Print filename on DTD validation error

Don't just print prefix the errors with "protocol", but the actual file
name, if wayland-scanner was passed with the filename of the protocol
file. If wayland-scanner is reading from stdin, errors will be prefixed
with "<stdin>" instead of "protocol".

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: David Fort <contact@hardening-consulting.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoserver: Fail to bind object when requested version is 0
Derek Foreman [Thu, 14 Jan 2016 19:33:52 +0000 (13:33 -0600)]
server: Fail to bind object when requested version is 0

0 is not a valid version number for registry bind requests, so
let's check for it in registry_bind.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agocosmetic: return NULL instead of 0
Marek Chalupa [Wed, 27 Jan 2016 09:06:28 +0000 (10:06 +0100)]
cosmetic: return NULL instead of 0

we're returning a pointer

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoprotocol: Add note about per version requirements to wl_data_device_manager
Jonas Ådahl [Mon, 18 Jan 2016 10:18:16 +0000 (18:18 +0800)]
protocol: Add note about per version requirements to wl_data_device_manager

Add a note to the wl_data_device_manager global interface about the
different requirements for operating the objects created from the bound
global.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
8 years agoserver: Fix possible wl_display_add_socket_fd memleak
Sergi Granell [Mon, 1 Feb 2016 18:35:51 +0000 (19:35 +0100)]
server: Fix possible wl_display_add_socket_fd memleak

If wl_event_loop_add_fd failed, the fail path didn't free the
newly allocated struct wl_socket.
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
8 years agoconfigure.ac: re-bump to version 1.9.91 for the alpha release 1.9.91
Bryce Harrington [Tue, 19 Jan 2016 22:54:32 +0000 (14:54 -0800)]
configure.ac: re-bump to version 1.9.91 for the alpha release

8 years agoserver: Add an API to get the file descriptor for a client
Sung-Jin Park [Thu, 14 Jan 2016 07:03:43 +0000 (16:03 +0900)]
server: Add an API to get the file descriptor for a client

This adds an API to get the file descriptor for a client.
The client file descriptor can be used for a wayland compositor to validate
a request from a client if there are any additional information provided from
the client's file descriptor.

For instance, this will be helpful in some linux distributions, in which SELinux
or SMACK is enabled. In those environments, each file (including socket) will have
each security contexts in its inode as xattr member variable. A wayland compositor
can validate a client request by getting the file descriptor of the client and
by checking the security contexts associated with the file descriptor.

Signed-off-by: Sung-Jin Park <input.hacker@gmail.com>
8 years agoconfigure.ac: bump to version 1.9.91 for the alpha release
Bryce Harrington [Tue, 19 Jan 2016 22:30:33 +0000 (14:30 -0800)]
configure.ac: bump to version 1.9.91 for the alpha release

8 years agotests: Test proxy versions
Derek Foreman [Tue, 12 Jan 2016 22:15:04 +0000 (16:15 -0600)]
tests: Test proxy versions

Add a test that confirms that proxy versions are always 0 for display
and correct otherwise.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoTrack protocol object versions inside wl_proxy.
Jason Ekstrand [Thu, 12 Nov 2015 19:53:15 +0000 (13:53 -0600)]
Track protocol object versions inside wl_proxy.

This provides a standardized mechanism for tracking protocol object
versions in client code.  The wl_display object is created with version 1.
Every time an object is created from within wl_registry_bind, it gets the
bound version.  Every other time an object is created, it simply inherits
it's version from the parent object that created it.

(comments and minor reformatting added
by Derek Foreman <derekf@osg.samsung.com>)

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Second trivial commit squashed into this one:
Authored by Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
(it's literally one of code and a lot of comments)

This sets wl_display's version (for proxy version query purposes)
to 0.  Any proxy created with unversioned API (this happens when
a client compiled with old headers links against new wayland)
will inherit this 0.

This gives us a way for new libraries linked by old clients to
realize they can't know a proxy's version.

wl_display's version being unqueryable (always returning 0) is
an acceptable side effect, since it's a special object you can't
bind specific versions of anyway.

Second half:
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
8 years agotests: Test that one can fetch the protocol error after EPIPE
Jonas Ådahl [Mon, 28 Dec 2015 06:33:36 +0000 (14:33 +0800)]
tests: Test that one can fetch the protocol error after EPIPE

If a client is terminated due to some reason, it should always be
possible to retrieve protocol error associated with the termination.
Test that, while either using the dispatch helpers
(wl_display_dispatch(_queue)() or the prepare read API, it should be
possible to retrieve the error after EPIPE.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agotests: Pass argument to client main
Jonas Ådahl [Mon, 28 Dec 2015 03:25:00 +0000 (11:25 +0800)]
tests: Pass argument to client main

Change the API to pass an "void *" argument to the client main
function, allowing the caller to call the same main function with
different input.

A helper (client_create_noarg) is added for when no argument is passed,
and the existing test cases are changed to use this function instead.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agotests: Synchronize client termination in idle callback
Jonas Ådahl [Thu, 24 Dec 2015 04:41:46 +0000 (12:41 +0800)]
tests: Synchronize client termination in idle callback

We currently wait for clients in the wl_client destroy signal, which is
called before the client is destructed and the socket is closed. If test
clients rely on being closed due to the socket being closed we'd dead
lock. Avoid this by synchronizing in an idle task that is called after
the client is fully destroyed.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoclient: Fully flush during blocking dispatch
Jonas Ådahl [Mon, 28 Dec 2015 06:50:12 +0000 (14:50 +0800)]
client: Fully flush during blocking dispatch

wl_display_flush() may fail with EAGAIN which means that not all data
waiting in the buffer has been flushed. We later block until there is
data to read, which could mean that we block on input from the
compositor without having sent out all data from the client. Avoid this
by fully flushing the socket before starting to wait.

This commit also changes the array length of the struct pollfd array
from 2 to 1, as only one element was ever used.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoclient: Use read preparation API in wl_display_dispatch_queue()
Jonas Ådahl [Fri, 2 Oct 2015 09:11:13 +0000 (17:11 +0800)]
client: Use read preparation API in wl_display_dispatch_queue()

Instead of doing things that do the equivalent of using
wl_display_prepare_read() and friends, just use the public API. The
only semantical difference is that we will now unlock and lock the mutex
more times compared to before.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoclient: Don't make EPIPE fatal if triggered when flushing
Jonas Ådahl [Mon, 28 Dec 2015 06:35:50 +0000 (14:35 +0800)]
client: Don't make EPIPE fatal if triggered when flushing

If flushing hits EPIPE it should not make it a fatal error since it
would make it impossible to process the rest of the data available in
the buffer. Instead, let reading the socket make EPIPE fatal, letting
the client have the possibility to process the last messages including
any error causing the termination.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoclient: Remove misplaced documentation about main loop intergration
Jonas Ådahl [Fri, 2 Oct 2015 03:18:12 +0000 (11:18 +0800)]
client: Remove misplaced documentation about main loop intergration

There was documentation about how to integrate the display server file
descriptor in the documentation about wl_display_dispatch_pending().
This is not the right place to put it, and it also had incorrect usage
of the API (calling wl_display_dispatch_queue() on input on an unrelated
fd) as an example.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoclient: Correct documentation regarding thread safeness
Jonas Ådahl [Fri, 2 Oct 2015 03:12:02 +0000 (11:12 +0800)]
client: Correct documentation regarding thread safeness

The current documentation about wl_display_dispatch() states one may not
mix wl_display_dispatch(_queue)() with wl_display_prepare_read() and
friends, but this is a misconception about how
wl_display_dispatch(_queue)() works. The fact is that the dispatch
functions does the equivalent of what the preparation API does
internally, and it is safe to use together.

What is not safe is to dispatch using the wl_display_dispatch(_queue)()
functions while being prepared to read using wl_display_read_events().

This patch rewrites the documentation to correctly state when the
various API's are thread safe and how they may not be used.

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

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoprotocol: Add DnD actions
Carlos Garnacho [Fri, 15 Jan 2016 20:11:40 +0000 (21:11 +0100)]
protocol: Add DnD actions

These 2 requests have been added:

- wl_data_source.set_actions: Notifies the compositor of the available
  actions on the data source.
- wl_data_offer.set_actions: Notifies the compositor of the available
  actions on the destination side, plus the preferred action.

Out of the data from these requests, the compositor can determine the action
both parts agree on (and let the user play a role through eg. keyboard
modifiers). The chosen option will be notified to both parties
through the following two requests:

- wl_data_source.action
- wl_data_offer.action

In addition, the destination side can peek the source side actions through
wl_data_offer.source_actions.

Compared to the XDND protocol, there's two notable changes:

- XDND lets the source suggest an action, whereas wl_data_device lets
  the destination prefer a given action. The difference is subtle here,
  it comes off as convenience because it is the drag destination which
  receives the motion events (unlike in X) and can perform action updates.

  The drag destination seems also in a better position to update the
  preferred action based on things like the data being transferred, the
  place being dropped, and whether the drag is client-local.

- That same source-side preferred action is used in XDND to convey the
  modifier-induced action to the drag destination, which would then ack
  it, or reply with another action that's accepted (or none), this makes
  the XdndPosition/XdndStatus messaging very verbose, and synchronous
  because the drag source always needs to know the latest status/action
  for every position+action sent.

  Here it's the compositor which takes care of modifiers and matching
  available/accepted actions, this allows for the signaling to happen
  only whenever the actions/modifiers change for real.

Roughly based on previous work by Giulio Camuffo <giuliocamuffo@gmail.com>

Changes since v10:
- Narrow down the situations where wl_data_source/offer.accept requests
  are supposed to happen.

Changes since v9:
- Deferred the protocol errors to .finish after some IRC chat with Jonas,
  added further errors if actions API is used on selection sources/offers.

Changes since v8:
- Defined further the expected behavior on "ask", described the protocol
  errors that may happen. Fix more spaces vs tabs issues.

Changes since v7:
- Misc changes after updating the progress notification patch.

Changes since v6:
- Further explanations on wl_data_source/offer.set_actions, including a
  description of "ask" actions. Added protocol errors for unknown action
  values.

Changes since v5:
- Applied rewording suggestions from Jonas Ådahl. Dropped slot reservation
  scheme for actions. Fixed indentation and other minor formatting issues.

Changes since v4:
- Minor rewording.

Changes since v3:
- Splitted from DnD progress notification changes.
- Further rationales in commit log.

Changes since v2:
- Renamed notify_actions to set_actions on both sides, seems more consistent
  with the rest of the protocol.
- Spelled out better which events may be triggered on the compositor side
  by the requests, the circumstances in which events are emitted, and
  what are events useful for in clients.
- Defined a minimal common ground wrt compositor-side action picking and
  keybindings.
- Acknowledge the possibility of compositor/toolkit defined actions, even
  though none are used at the moment.
Changes since v1:
- Added wl_data_offer.source_actions to let know of the actions offered
  by a data source.
- Renamed wl_data_source.finished to "drag_finished" for clarity
- Improved wording as suggested by Bryce

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Michael Catanzaro <mcatanzaro@igalia.com>
Reviewed-by: Mike Blumenkrantz <zmike@samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoprotocol: Improve data source notification around DnD progress
Carlos Garnacho [Fri, 15 Jan 2016 20:11:39 +0000 (21:11 +0100)]
protocol: Improve data source notification around DnD progress

Currently, there's no means for the DnD origin to know whether the
destination is actually finished with the DnD transaction, short of
finalizing it after the first transfer finishes, or leaking it forever.

But this poses other interoperation problems, drag destinations might
be requesting several mimetypes at once, might be just poking to find
out the most suitable format, might want to defer the action to a popup,
might be poking contents early before the selection was dropped...

In addition, data_source.cancelled is suitable for the situations where
the DnD operation fails (not on a drop target, no matching mimetypes,
etc..), but seems undocumented for that use (and unused in weston's DnD).

In order to improve the situation, the drag source should be notified
of all stages of DnD. In addition to documenting the "cancelled" event
for DnD purposes, The following 2 events have been added:

- wl_data_source.dnd_drop_performed: Happens when the operation has been
  physically finished (eg. the button is released), it could be the right
  place to reset the pointer cursor back and undo any other state resulting
  from the initial button press.
- wl_data_source.dnd_finished: Happens when the destination side destroys
  the wl_data_offer, at this point the source can just forget all data
  related to the DnD selection as well, plus optionally deleting the data
  on move operations.

Changes since v6:
  - Turned wl_data_offer.finish calls with 0/NULL state/mimetype an
    error, made it explicit that it will only result in
    wl_data_offer.dnd_finished being sent if successful.

Changes since v5:
  - Further rewording of wl_data_offer.finish and wl_data_offer.accept.
    Added error for untimely wl_data_offer.finish requests.

Changes since v4:
  - Applied rewording suggestions from Jonas Ådahl. Added new
    wl_data_offer.finish request to allow explicit finalization on the
    destination side.

Changes since v3:
  - Renamed dnd_performed to a more descriptive dnd_drop_performed,
    documented backwards compatible behavior on wl_data_offer.accept and
    wl_data_source.cancelled.

Changes since v2:
  - Minor rewording.

Changes since v1:
  - Renamed events to have a common "dnd" namespace. Made dnd_performed to
    happen invariably, data_device.cancelled may still happen afterwards.

Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Michael Catanzaro <mcatanzaro@igalia.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Mike Blumenkrantz <zmike@samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoserver: Test for illegally low interface versions in wl_global_create()
Derek Foreman [Thu, 14 Jan 2016 17:02:18 +0000 (11:02 -0600)]
server: Test for illegally low interface versions in wl_global_create()

Any version lower than 1 is unreasonable.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoserver: improve failure log message for wl_global_create()
Derek Foreman [Thu, 14 Jan 2016 17:02:17 +0000 (11:02 -0600)]
server: improve failure log message for wl_global_create()

The gratuitous %m jammed onto the end of the string prints errno
concatenated with the word "version".

I've removed the %m, and printed some additional information about the
failure.

Also, reversed the order of the expressions in the conditional to
make it match the english in the log message.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoprotocol: add wl_pointer.frame, axis_source, axis_stop, and axis_discrete
Peter Hutterer [Tue, 8 Dec 2015 01:11:07 +0000 (11:11 +1000)]
protocol: add wl_pointer.frame, axis_source, axis_stop, and axis_discrete

The frame event groups separate pointer events together. The primary use-case
for this at the moment is diagonal scrolling - a vertical/horizontal scroll
event can be grouped together to calculate the correct motion vector.
Frame events group all wl_pointer events. An example sequence of motion events
followed by a diagonal scroll followed by a button event is:
wl_pointer.motion
wl_pointer.frame
wl_pointer.motion
wl_pointer.frame
wl_pointer.axis
wl_pointer.axis
wl_pointer.frame
wl_pointer.button
wl_pointer.frame

In the future, other extensions may insert additional information about an
event into the frame. For example, an extension may add information about the
physical device that generated an event into the frame. For this reason,
enter/leave events are grouped by a frame event too.

The axis_source event determines how an axis event was generated. That enables
clients to judge when to use kinetic scrolling. Only one axis_source event is
allowed per frame and applies to all events in this frame.

The axis_stop event notifies a client about the termination of a scroll
sequence, likewise needed to calculate kinetic scrolling parameters.
Multiple axis_stop events within the same frame indicate that scrolling has
stopped in all these axis at the same time.

The axis_discrete event provides the wheel click count. Previously the axis
value was some hardcoded number (10), with the discrete steps this enables a
client to differ between line-based scrolling on a mouse wheel and smooth
scrolling with a touchpad. The axis_discrete event carries the axis
information and the discrete value and can occur at any time in the frame
provided it is ordered before the matching axis event. Specifically, this
sequence is valid:

wl_pointer.axis_source
wl_pointer.axis_discrete (vert)
wl_pointer.axis_discrete (horiz)
wl_pointer.axis (horiz)
wl_pointer.axis (vert)
wl_pointer.frame

Enter and leave event also trigger wl_pointer.frame events, where possible the
compositor should group leave and subsequent enter into the same frame. This
indicates to the client that the pointer has moved between surfaces and may
allow a client to shortcut code otherwise triggerd by the leave or enter
events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agosocket-test: Refactor if check into the assert
Bryce Harrington [Tue, 8 Dec 2015 06:49:14 +0000 (22:49 -0800)]
socket-test: Refactor if check into the assert

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agosocket-test: Fix some comment typos
Bryce Harrington [Tue, 8 Dec 2015 06:49:13 +0000 (22:49 -0800)]
socket-test: Fix some comment typos

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoserver: don't send an error to NULL display_resource
Marek Chalupa [Mon, 11 Jan 2016 10:45:12 +0000 (11:45 +0100)]
server: don't send an error to NULL display_resource

if display_resource = wl_resource_create() fails in bind_display(),
we call wl_client_post_no_memory() which is wrong, since this function
uses display_resource (which is NULL at this point).
said simply: don't send an error to resource that you've just failed to create)

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

Reported-by: Ashim <ashim.shah@samsung.com>
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoclient: Add missing arg in a wl_log invocation
Victor Berger [Mon, 4 Jan 2016 10:09:01 +0000 (11:09 +0100)]
client: Add missing arg in a wl_log invocation

Without this 'proxy' argument, the '%p' formatter prints a constant
garbage value.

Signed-off-by: Victor Berger <victor.berger@m4x.org>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>