platform/upstream/wayland.git
6 years agoconfigure.ac: bump to version 1.15.93 for the RC1 release 1.15.93
Derek Foreman [Fri, 10 Aug 2018 18:01:10 +0000 (13:01 -0500)]
configure.ac: bump to version 1.15.93 for the RC1 release

6 years agocontributing: Weston now uses GitLab MRs
Daniel Stone [Mon, 6 Aug 2018 10:49:31 +0000 (11:49 +0100)]
contributing: Weston now uses GitLab MRs

Note that Weston uses GitLab MRs for review, not mail.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoconfigure.ac: bump to version 1.15.92 for the beta release 1.15.92
Derek Foreman [Fri, 27 Jul 2018 16:46:27 +0000 (11:46 -0500)]
configure.ac: bump to version 1.15.92 for the beta release

6 years agospec: Delete old unused directory
Daniel Stone [Sun, 22 Jul 2018 09:17:39 +0000 (10:17 +0100)]
spec: Delete old unused directory

The protocol spec used to live here, but it's now part of the regular
doc build. The PNG files are created as part of the doc build. Delete
the pre-generated versions.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derek.foreman.samsung@gmail.com>
6 years agobuild: Remove support for non-pkg-config Expat
Daniel Stone [Sat, 21 Jul 2018 11:04:13 +0000 (12:04 +0100)]
build: Remove support for non-pkg-config Expat

The Expat XML library has shipped a pkg-config file for long enough to
be in Debian's oldstable (Jessie, April 2015) and Ubuntu's oldest
supported LTS (Trusty, 14.04). The pkg-config file was added in Expat
upstream's commit 352cfc8f59a7, in September 2007.

Drop build support for versions of Expat which do not ship a
pkg-config file.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derek.foreman.samsung@gmail.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agobuild: Remove execinfo.h check
Daniel Stone [Sat, 21 Jul 2018 10:58:41 +0000 (11:58 +0100)]
build: Remove execinfo.h check

The check for the execinfo.h header is only advisory; the build will not
fail if it is not present, and set HAVE_EXECINFO_H if it is. The check
was added in commit bc3e020475e ("build: Add declaration checks to check for
required syscall flags") with no obvious use or reasoning.

Remove the no-op check.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derek.foreman.samsung@gmail.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agowayland-server: Finally remove deprecated struct wl_buffer definition
Derek Foreman [Fri, 16 Feb 2018 16:54:40 +0000 (10:54 -0600)]
wayland-server: Finally remove deprecated struct wl_buffer definition

commit d94a8722cb29d8b897672be66ff3c9ff79eab6fe
warned this was coming, back in 2013.

I've seen libraries that have wayland client and server using functions
in the same file.  Since struct wl_buffer still exists as an opaque
entity in client code, the vestigial deprecated wl_buffer from the
server include will generate warnings when not building with
WL_HIDE_DEPRECATED.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoprotocol: allow to send a zero physical output size
Simon Ser [Tue, 3 Jul 2018 11:27:05 +0000 (07:27 -0400)]
protocol: allow to send a zero physical output size

Physical size doesn't always make sense for all outputs. In case
it's not available or not relevant, allow compositors to send zero.

Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
6 years agoconfigure.ac: bump to version 1.15.91 for the alpha release 1.15.91
Derek Foreman [Fri, 13 Jul 2018 16:27:03 +0000 (11:27 -0500)]
configure.ac: bump to version 1.15.91 for the alpha release

6 years agocontributing: document the release cycle freezes
Pekka Paalanen [Tue, 3 Jul 2018 10:32:03 +0000 (13:32 +0300)]
contributing: document the release cycle freezes

These should be the conventions we have been using since 1.0, written
down more accurately.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derek.foreman.samsung@gmail.com>
6 years agocontributing: about re-sending patches
Pekka Paalanen [Tue, 3 Jul 2018 10:32:02 +0000 (13:32 +0300)]
contributing: about re-sending patches

This is what is generally expected from people who re-send patches,
whether the patches are their own or not.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derek.foreman.samsung@gmail.com>
6 years agocontributing: review rules for bugs
Pekka Paalanen [Tue, 3 Jul 2018 10:32:01 +0000 (13:32 +0300)]
contributing: review rules for bugs

Half of the ideas came from Daniel but most of them are reworded, the
rest are my thoughts.

Mention compiler warnings specifically, and be more explicit on what
kind of code or bugs or bug fixes are acceptable or not. Clarify commit
scope.

v2: move the "In a patch series" rule to the bottom, reworded.

Cc: Daniel Stone <daniels@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derek.foreman.samsung@gmail.com>
6 years agocontributing: how to read the review rules
Pekka Paalanen [Tue, 3 Jul 2018 10:32:00 +0000 (13:32 +0300)]
contributing: how to read the review rules

This is to avoid fighting around the letter of the guidelines. This is
not a protocol spec.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derek.foreman.samsung@gmail.com>
6 years agoclient: remove definition of wl_global
Pekka Paalanen [Thu, 15 Feb 2018 11:48:35 +0000 (13:48 +0200)]
client: remove definition of wl_global

Nothing on the client side uses it since
9fe75537ad207c1496e6d9be41a8f5af4b876506 which was just before the 0.99
release.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-By: Markus Ongyerth <wl@ongy.net>
6 years agodoc: update IANA MIME types registry URL
Simon Ser [Mon, 18 Jun 2018 10:58:46 +0000 (06:58 -0400)]
doc: update IANA MIME types registry URL

Use a more official one, served over HTTP rather than FTP.

Reviewed-by: Matheus Santana <embs@cin.ufpe.br>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocontributing: commit rights
Pekka Paalanen [Fri, 15 Jun 2018 14:25:07 +0000 (17:25 +0300)]
contributing: commit rights

This has been copied from
https://cgit.freedesktop.org/xorg/app/intel-gpu-tools/tree/CONTRIBUTING?id=eccae1360d6d01e73c6af2bd97122cef708207ef
and slightly edited to better with Wayland and Weston.

The intention is to make it easier to give out commit access to new
people, let them know what is expected of them, and help the community
to grow. Hopefully this will in time improve the patch review throughput
and timeliness.

The original text was introduced in
https://cgit.freedesktop.org/xorg/app/intel-gpu-tools/commit/CONTRIBUTING?id=0350f0e7f6a0e07281445fc3082aa70419f4aac7

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Matheus Santana <embs@cin.ufpe.br>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Derek Foreman <derek.foreman.samsung@gmail.com>
6 years agocontributing: add review guidelines
Pekka Paalanen [Wed, 13 Jun 2018 13:02:51 +0000 (16:02 +0300)]
contributing: add review guidelines

This sets up the standards for patch review, and defines when a patch
can be merged. I believe these are the practises we have been using
already for a long time, now they are just written down explicitly.

It's not an exhaustive list of criteria and likely cannot ever be, but
it should give a good idea of what level of review we want to have.

It has been written in general terms, so that we can easily apply the
same text not just to Wayland, but also Weston and other projects as
necessary.

This addition is not redundant with
https://wayland.freedesktop.org/reviewing.html .

The web page is a friendly introduction and encouragement for people to
get involved. The guidelines here are more specific and aimed for people
who seek commit rights or maintainership.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Matheus Santana <embs@cin.ufpe.br>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Derek Foreman <derek.foreman.samsung@gmail.com>
6 years ago.gitlab-ci.yml: collect the distcheck error logs
Emil Velikov [Thu, 14 Jun 2018 17:14:14 +0000 (18:14 +0100)]
.gitlab-ci.yml: collect the distcheck error logs

Currently we issue both check and distcheck, as reportedly there has
been cases in the past one works, while the other doesn't.

Yet we only collect the check artefacts (test logs).

Correct that, by picking the distcheck ones as well.
Note: the build-*/wayland*/ directory is purged by distcheck if it runs
successfully.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocontributing: format as markdown
Pekka Paalanen [Wed, 13 Jun 2018 10:21:43 +0000 (13:21 +0300)]
contributing: format as markdown

Format for nice viewing through Gitlab.

Conduct and Licensing were raised to first level headings as they are
not technical guidelines for contributing patches. It's nice to use the
first level headings more.

Reformat patchwork link and add Xorg patchwork link for Xwayland.

v2: Unfortunately Gitlab harcodes a tab character to mean 4 spaces, so we
cannot reasonably spell the coding style examples correctly. Hence, tab
characters have been replaced with eight spaces so that they at least
look right in both the file and through gitlab web UI.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agodoc: move Contributing
Pekka Paalanen [Wed, 13 Jun 2018 09:45:36 +0000 (12:45 +0300)]
doc: move Contributing

Gitlab expects a CONTRIBUTING.md in the root directory, so move our
guide there.

Conversion to proper markup is a follow-up patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agodoc: Update URLs for GitLab transition
Daniel Stone [Fri, 8 Jun 2018 23:49:33 +0000 (00:49 +0100)]
doc: Update URLs for GitLab transition

Update bug and Git URLs for GitLab; the site has also been served over
HTTPS for quite some time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoscanner: allow referencing foreign enums
Simon Ser [Fri, 25 May 2018 21:24:41 +0000 (17:24 -0400)]
scanner: allow referencing foreign enums

It's already possible to reference foreign interfaces, so it
should also be possible to reference foreign enums.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Silvan Jegen <s.jegen@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoAdd .gitlab-ci.yml
Daniel Stone [Tue, 5 Jun 2018 20:22:38 +0000 (21:22 +0100)]
Add .gitlab-ci.yml

Add a GitLab CI configuration which tests building, 'make check', and
'make distcheck' of the tree inside a Debian Stretch container. The
choice of distribution base was arbitrary and may easily be changed.

When commits are pushed to upstream, the commits will run this CI
pipeline to run these tests, and capture the result as an artifact
bundle, including the compiled binaries and full test suite logs.

Results can be seen at:
    https://gitlab.freedesktop.org/wayland/wayland/pipelines/

Signed-off-by: Daniel Stone <daniels@collabora.com>
6 years agotests: Add free-without-remove test
Markus Ongyerth [Mon, 16 Apr 2018 20:01:00 +0000 (15:01 -0500)]
tests: Add free-without-remove test

[Derek Foreman <derekf@osg.samsung.com> moved this into resources-test]

Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoserver: Add special case destroy signal emitter
Derek Foreman [Mon, 16 Apr 2018 20:00:59 +0000 (15:00 -0500)]
server: Add special case destroy signal emitter

In the past much code (weston, efl/enlightenment, mutter) has
freed structures containing wl_listeners from destroy handlers
without first removing the listener from the signal.  As the
destroy notifier only fires once, this has largely gone
unnoticed until recently.

Other code does not (Qt, wlroots) - and removes itself from
the signal before free.

If somehow a destroy signal is listened to by code from both
kinds of callers, those that free will corrupt the lists for
those that don't, and Bad Things will happen.

To avoid these bad things, remove every item from the signal list
during destroy emit, and put it in a list all its own.  This way
whether the listener is removed or not has no impact on the
following emits.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Markus Ongyerth <wl@ongy.net>
6 years agotests: Test for use after free in resource destruction signals
Derek Foreman [Mon, 16 Apr 2018 20:00:58 +0000 (15:00 -0500)]
tests: Test for use after free in resource destruction signals

For years it's been common practice to free the object containing
the wl_listener inside resource destruction notifiers, but not
remove the listener from the list.

That is: It's been safe to assume (when only one listener is present)
that the wl_listener will never be touched again, since this is
a destruction callback.

Recently some patches were reviewed that made some positive changes
to our internal signal handling code, but would've violated this
assumption, and changed free()d memory in several existing compositors
(weston, mutter, enlightenment).

Since the breakage was extremely subtle, codify this assumption in
a test case (thus promoting it to an ABI promise).

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Markus Ongyerth <wl@ongy.net>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
6 years agowayland-server: Properly handle EAGAIN from wl_connection_read()
Dipen Somani [Thu, 19 Apr 2018 14:01:56 +0000 (09:01 -0500)]
wayland-server: Properly handle EAGAIN from wl_connection_read()

commit 3cddb3c692acd3536a7cc8542a29f0cc3c0ac3d6 casted len to an
unsigned value to compare to sizeof results.  However,
wl_connection_read() can fail, setting errno to EAGAIN and returning
a value of -1.

When cast to an unsigned type this leads to a loop condition of true
when it should be false.

Signed-off-by: Dipen Somani <dipen.somani@samsung.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoconfigure.ac: Reopen master for regular development
Derek Foreman [Mon, 9 Apr 2018 18:15:31 +0000 (13:15 -0500)]
configure.ac: Reopen master for regular development

6 years agoconfigure.ac: bump to version 1.15.0 for the official release 1.15.0 upstream/1.15.0
Derek Foreman [Mon, 9 Apr 2018 16:54:10 +0000 (11:54 -0500)]
configure.ac: bump to version 1.15.0 for the official release

6 years agoconfigure.ac: bump to version 1.14.93 for the RC1 release 1.14.93
Derek Foreman [Mon, 2 Apr 2018 17:50:16 +0000 (12:50 -0500)]
configure.ac: bump to version 1.14.93 for the RC1 release

6 years ago.gitignore: add wayland-egl-abi-check
Emil Velikov [Tue, 20 Mar 2018 11:10:45 +0000 (11:10 +0000)]
.gitignore: add wayland-egl-abi-check

Instruct git go ignore the file, in case we've done an in-tree build.

Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agowayland-egl: Ignore underscored symbols in ABI check
Daniel Stone [Tue, 20 Mar 2018 11:01:02 +0000 (11:01 +0000)]
wayland-egl: Ignore underscored symbols in ABI check

Rather than a hard-coded list of platform symbols, just ignore anything
prefaced with an underscore. This fixes breakage on ARM, which declares
several slightly different platform symbols to x86.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Fixes: 21b1f22eb056 ("wayland-egl: enhance the symbol test")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105620
Cc: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoconfigure.ac: bump to version 1.14.92 for the beta release 1.14.92
Derek Foreman [Mon, 19 Mar 2018 20:39:39 +0000 (15:39 -0500)]
configure.ac: bump to version 1.14.92 for the beta release

6 years agowayland-egl: Make symbol test fail on failure
Daniel Stone [Mon, 19 Mar 2018 15:13:14 +0000 (15:13 +0000)]
wayland-egl: Make symbol test fail on failure

The previous rewrite of the wayland-egl ABI checker introduced checks
for removed symbols as well as added symbols, but broke some failure
conditions. Add an explict return-code variable set in failure paths,
rather than chaining or conditions.

If we cannot find the binary or nm, we regard this as an error
condition, rather than test failure.

v2: Don't test if we can execute $NM.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Fixes: 21b1f22eb056 ("wayland-egl: enhance the symbol test")
Cc: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agowayland-egl: Pass nm path to check script
Daniel Stone [Mon, 19 Mar 2018 12:20:54 +0000 (12:20 +0000)]
wayland-egl: Pass nm path to check script

A previous patch used $NM as an environment variable, but this was only
set as a make variable. Make sure it is passed through from make to the
environment we use to run tests.

v2: Quote argument when passing to shell.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Fixes: 6903e4d53925 ("wayland-egl: use correct `nm` path when cross-compiling")
Cc: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
6 years agowayland-egl: bump the version number to 18.1.0
Emil Velikov [Thu, 15 Mar 2018 14:30:29 +0000 (14:30 +0000)]
wayland-egl: bump the version number to 18.1.0

Seems like I was overoptimistic with my earlier assumption, namely:

"... 17.3.x should be the last version that ships the library."

Mesa 18.0.0 and its wayland-egl is about to be released any time soon,
so bump the number since it must no be smaller. As soon as we get
a wayland release I'll drop the Mesa copy but for now.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agowayland-egl: enhance the symbol test
Emil Velikov [Thu, 15 Mar 2018 14:30:28 +0000 (14:30 +0000)]
wayland-egl: enhance the symbol test

The current test had a few fall-outs:
 - it was checking only for T (.text) symbols
 - did not consider symbol removal

Fix that by fetching all the symbols and doing a bidirectional check -
for added and removed symbols. Error out with informative message for
each case.

v2: Rebase on top of $NM patch.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agowayland-egl: fail the symbol check if lib is missing
Emil Velikov [Thu, 15 Mar 2018 14:30:27 +0000 (14:30 +0000)]
wayland-egl: fail the symbol check if lib is missing

Based on a similar patch (in Mesa) by Eric Engestrom.

v2: Rebase on top of $NM patch
v3: Rebase

Reviewed-by: Eric Engestrom <eric@engestrom.ch> (v1)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agowayland-egl: set the correct path to libwayland-egl.so
Emil Velikov [Fri, 16 Mar 2018 16:14:54 +0000 (16:14 +0000)]
wayland-egl: set the correct path to libwayland-egl.so

Earlier commit changed to passing the binary name as env. variable
introducing a typo.

That went unnoticed, since we do not check if the file is present or
not.

Cc: Pukka Paalanen <ppaalanen@gmail.com>
Cc: Daniel Stone <daniels@collabora.com>
Fixes: 85cb5ed64aa ("wayland-egl-symbols-check: pass the DSO name via
the build system")
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoconfigure.ac: don't install the static libraries
Emil Velikov [Tue, 13 Mar 2018 13:43:37 +0000 (13:43 +0000)]
configure.ac: don't install the static libraries

One should always be using the shared libraries.

Spotted while going through the Debian packaing.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: disable coredumps on sanity-test
Pekka Paalanen [Wed, 14 Feb 2018 12:22:23 +0000 (14:22 +0200)]
tests: disable coredumps on sanity-test

SEGV and ABRT by default cause a core dump, which may create a file,
launch crash handlers, and so on. sanity-test has 21 processes that
are expected to crash like this. Disable core dumps on them all.

I counted 21 entries in coredumpctl list, while only 16 functions needed
patching. After this patch no entries appear in coredumpctl list.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agowalyand-client: Fix trivial build break from previous commit
Derek Foreman [Wed, 7 Mar 2018 19:38:53 +0000 (13:38 -0600)]
walyand-client: Fix trivial build break from previous commit

previous commit, a9187853d44db41206b5d16a770d4db108972812 added
a trailing { on a line it shouldn't have, and I pushed without
building first.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoclient: Don't inappropriatly close fds for zombie objects
Derek Foreman [Tue, 6 Mar 2018 23:38:13 +0000 (17:38 -0600)]
client: Don't inappropriatly close fds for zombie objects

commit 239ba39331420f953de35c337ae57db35573f9cb which was intended
to stop leaking fds in events for zombie objects didn't notice that
passing 0 to wl_connection_close_fds_in() would still close fds.

Test the fd count before calling.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoconfigure.ac: bump to version 1.14.91 for the alpha release 1.14.91
Derek Foreman [Mon, 26 Feb 2018 16:52:17 +0000 (10:52 -0600)]
configure.ac: bump to version 1.14.91 for the alpha release

6 years agotests: fix scanner private-code test reference data
Pekka Paalanen [Mon, 26 Feb 2018 09:44:25 +0000 (11:44 +0200)]
tests: fix scanner private-code test reference data

Commit e501230d1dc8a5015616e104ec0e08886a0b88df "scanner: Fix broken
private-code generation" changed the scanner output without updating the
reference output for scanner tests.

Update the reference data. This fixes 'make check'.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoscanner: Fix broken private-code generation
Derek Foreman [Fri, 23 Feb 2018 22:23:15 +0000 (16:23 -0600)]
scanner: Fix broken private-code generation

Missing a closing bracket.

Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agowayland-egl: use correct `nm` path when cross-compiling
Emil Velikov [Fri, 23 Feb 2018 17:31:53 +0000 (17:31 +0000)]
wayland-egl: use correct `nm` path when cross-compiling

Inspired by Heiko Becker and Eric's work in libdrm and Mesa
respectively.

Cc: Eric Engestrom <eric.engestrom@imgtec.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agotests: add code, public-code and private-code tests
Emil Velikov [Thu, 22 Feb 2018 11:23:39 +0000 (11:23 +0000)]
tests: add code, public-code and private-code tests

First one is deprecated in favour of the second option.

The latter is newly introduced and annotates the generated symbols
accordingly.

v2: Don't introduce small-public-code.c - reuse small-code.c (Pekka)

Cc: Pekka Paalanen <ppaalanen@gmail.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoscanner: make use of __has_attribute()
Emil Velikov [Fri, 16 Feb 2018 16:22:32 +0000 (16:22 +0000)]
scanner: make use of __has_attribute()

A more generic way to evaluating various attributes, __has_attribute is
available with gcc, clang, even the Oracle/Sun compiler.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agobuild: use public-code when using the local wayland-scanner
Emil Velikov [Fri, 16 Feb 2018 16:22:31 +0000 (16:22 +0000)]
build: use public-code when using the local wayland-scanner

The core wayland interfaces are public, via the libwayland-server and
libwayland-client DSOs. Hence use "public-code" cmdline option, instead
of the deprecated code".

As the host wayland-scanner may not know about the new option, use the
legacy "code".

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoscanner: introduce "public-code" and "private-code"
Emil Velikov [Fri, 16 Feb 2018 16:22:30 +0000 (16:22 +0000)]
scanner: introduce "public-code" and "private-code"

The options are used to indicate how the code will be used - will it be
public, as part of a DSO or private.

In nearly every instance, people want to use the latter. One noticeable
exception is the wayland libraries. They provide the base marshalling
protocol that everyone uses.

The option "code" was deprecated in favour of "public-code" with a
warning message produced to guide people.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agobuild: remove white space in -uninstalled.pc.in files
Emil Velikov [Tue, 21 Feb 2017 16:14:29 +0000 (16:14 +0000)]
build: remove white space in -uninstalled.pc.in files

v2: Rebase, address wayland-client-uninstalled

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com> (v1)
6 years agoconnection: Fix broken log message when demarshalling short closure
Derek Foreman [Wed, 14 Feb 2018 18:15:11 +0000 (12:15 -0600)]
connection: Fix broken log message when demarshalling short closure

Like the similar wl_log() message further into this function that was
fixed in commit 2fc248dc2c877d02694db40aad52180d71373d5a this should
be printing the sender_id saved earlier instead of *p.

Since p is incremented during the loop it would not only print an
incorrect object id, it could read past the end of the array.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agowayland-egl: rename wl_egl_window::private to driver_private
Emil Velikov [Wed, 13 Dec 2017 12:03:54 +0000 (12:03 +0000)]
wayland-egl: rename wl_egl_window::private to driver_private

private is a reserved keyword in C++. Thus if one is to have a backend
driver written in said language build will fail as below:

.../wayland-egl-backend.h:56:8: expected unqualified-id before ‘private’

Rename it to driver_private and update the test.

NOTE: version bump is not required since:
 - this is a pure API change, ABI is identical
 - hardware drivers already require [minor] changes to move to the
upstream wayland-egl-backend.h

Cc: Arnaud Vrac <rawoul@gmail.com>
Cc: Miguel A . Vico <mvicomoya@nvidia.com>
Suggested-by: Arnaud Vrac <rawoul@gmail.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Miguel A Vico Moya <mvicomoya@nvidia.com>
6 years agowayland-egl: move the wayland-egl{, -core}.h headers to egl/
Emil Velikov [Tue, 10 Oct 2017 13:43:50 +0000 (14:43 +0100)]
wayland-egl: move the wayland-egl{, -core}.h headers to egl/

Now we have all the wayland-egl bits in a single place.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Arnaud Vrac <avrac@freebox.fr>
6 years agowayland-egl-symbols-check: pass the DSO name via the build system
Emil Velikov [Tue, 10 Oct 2017 13:43:49 +0000 (14:43 +0100)]
wayland-egl-symbols-check: pass the DSO name via the build system

The location of the file is build system specific so, keep it there.

Cc: Daniel Stone <daniels@collabora.com>
Suggested-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Arnaud Vrac <avrac@freebox.fr>
6 years agobuild: wire-up wayland-egl
Emil Velikov [Tue, 10 Oct 2017 13:43:48 +0000 (14:43 +0100)]
build: wire-up wayland-egl

Wire-up the imported sources, test and pkg-config files.

v2:
 - Don't mangle with existing EXTRA_DIST list
 - Add the symbols check script to the `make check' target
 - Rename wayland-egl-{priv,backend}.h

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Arnaud Vrac <avrac@freebox.fr>
6 years agowayland-egl: add a note about keeping the backend version in sync
Emil Velikov [Tue, 10 Oct 2017 13:43:47 +0000 (14:43 +0100)]
wayland-egl: add a note about keeping the backend version in sync

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Arnaud Vrac <avrac@freebox.fr>
6 years agowayland-egl: introduce wayland-egl-backend.pc
Emil Velikov [Tue, 10 Oct 2017 13:43:46 +0000 (14:43 +0100)]
wayland-egl: introduce wayland-egl-backend.pc

File will be installed alongside the backend header.

This way vendor implementations have enough information about the
interface and they can build their backend/driver library accordingly.

Cc: Miguel A. Vico <mvicomoya@nvidia.com>
Cc: James Jones <jajones@nvidia.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: duncan-roe <duncan_roe@optusnet.com.au>
Cc: Takanari Hayama <taki@igel.co.jp>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Miguel A Vico Moya <mvicomoya@nvidia.com>
Reviewed-by: Arnaud Vrac <avrac@freebox.fr>
6 years agowayland-egl: correct wayland-egl.pc description/version
Emil Velikov [Tue, 10 Oct 2017 13:43:45 +0000 (14:43 +0100)]
wayland-egl: correct wayland-egl.pc description/version

Drop the "Mesa" part from the commit message and change the version to
17.4.0. The number bears references from its Mesa heritage.

Currently Mesa provides 17.2.x while 17.3.x should be the last version
that ships the library.

Some version numbers of wayland-egl.pc providers and users.
The latter is taken from Ubuntu 17.04.

Providers:
 - Mali: 7.10
 - Mesa: 17.2.2

Users:
 - retroarch: NA
 - qtwayland5: NA
 - mpv, libmpv1: 9.0
 - mesa-utils-extra: NA
 - weston, libweston-1-0: NA

 - libwaffle-1-0: 9.1
 - libsdl2-2.0-0: NA

 - libgstreamer-plugins-bad1.0-0: autotools 9.0, meson 1.0
 - libglfw3-wayland: NA

 - kwin-wayland, kwin-wayland-backend-wayland: NA?
 - glmark2-wayland, glmark2-es2-wayland: NA

 - libwebkit2gtk-4.0-37, libwebkit2gtk-4.0-37-gtk2, (webkit overall): NA
 - libgtk-3-0 (gtk overall): NA
 - libcogl20 (cogl overall): 1.0.0

v2: Bump the version to 17.4.0

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Arnaud Vrac <avrac@freebox.fr>
6 years agowayland-egl: reuse the existing WL_EXPORT macro
Emil Velikov [Tue, 10 Oct 2017 13:43:44 +0000 (14:43 +0100)]
wayland-egl: reuse the existing WL_EXPORT macro

There's little point if redefining new one ourselves. Just reuse the one
that's already available.

Cc: Daniel Stone <daniels@collabora.com>
Suggested-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Arnaud Vrac <avrac@freebox.fr>
6 years agowayland-egl: import libwayland-egl.so frontend library from Mesa
Emil Velikov [Tue, 10 Oct 2017 13:43:43 +0000 (14:43 +0100)]
wayland-egl: import libwayland-egl.so frontend library from Mesa

Currently the client-facing libwayland-egl API is defined by a header
file shipped by Wayland, but the implementation is left to each vendor.

This can cause collisions when multiple implementations are installed on
the same system. Importing the implementation into Wayland with a stable
and versioned driver-facing ABI allows multiple drivers to coexist on
the same system.

Pull the sample implementation from Mesa commit 677edff5cfd
("wayland-egl: rework and simplify wl_egl_window initialization")
It has been used by the Mesa open source drivers, NVIDIA and others[1].

v2: Reword commit message, rebase on top of newer Mesa.

[1] https://github.com/thayama/wayland-egl

Cc: Miguel A. Vico <mvicomoya@nvidia.com>
Cc: James Jones <jajones@nvidia.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: duncan-roe <duncan_roe@optusnet.com.au>
Cc: Takanari Hayama <taki@igel.co.jp>
Suggested-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Miguel A Vico Moya <mvicomoya@nvidia.com>
Reviewed-by: Arnaud Vrac <avrac@freebox.fr>
6 years agoshm: provide actual error on mmap failed
Olivier Fourdan [Mon, 5 Feb 2018 14:39:43 +0000 (15:39 +0100)]
shm: provide actual error on mmap failed

When an mmap() fails, a WL_SHM_ERROR_INVALID_FD is raised and the client
is killed.

However, there is no indication of the actual system error that caused
mmap() to fail, which makes such error harder to investigate.

Provide the actual error message that caused mmap() to fail.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
6 years agoserver: add wl_display_destroy_clients()
Simon Ser [Wed, 13 Dec 2017 10:51:19 +0000 (11:51 +0100)]
server: add wl_display_destroy_clients()

Bug [1] reported that wl_display_destroy() doesn't destroy clients, so
client socket file descriptors are being kept open until the compositor
process exits.

Patch [2] proposed to destroy clients in wl_display_destroy(). The
patch was not accepted because doing so changes the ABI.

Thus, a new wl_display_destroy_clients() function is added in this
patch. It should be called by compositors right before
wl_display_destroy().

[1] https://bugs.freedesktop.org/show_bug.cgi?id=99142
[2] https://patchwork.freedesktop.org/patch/128832/

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Daniel Stone <daniels@collabora.com>
6 years agodoc: Document behavior of non-nullable object arguments in clients
Philipp Kerling [Wed, 24 Jan 2018 13:28:15 +0000 (14:28 +0100)]
doc: Document behavior of non-nullable object arguments in clients

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoconnection: Clear correct args when clearing fds to -1
Derek Foreman [Fri, 19 Jan 2018 21:20:31 +0000 (15:20 -0600)]
connection: Clear correct args when clearing fds to -1

commit 52609ddf79a96fee0465006e2c6339a3a5d23a87 was intended to
set fds to -1 in the arg list, however it failed to account for
version information at the start of signatures.

Most noticably, this broke mesa's create_prime_buffer by setting
width to -1 instead of the fd, as the width was the argument
following the fd, and the version was one byte long.

This should close https://bugs.kde.org/show_bug.cgi?id=389200

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agotests: Add missing file to distribution
Derek Foreman [Fri, 19 Jan 2018 17:51:35 +0000 (11:51 -0600)]
tests: Add missing file to distribution

In f74c9b98db49ce16e037c3012590c4a24a4fc32e I added tests.xml to the
repository, but not to the distribution tarball.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoserver: add log message when client connection is destroyed due to an error
Fiedler, Mathias [Tue, 5 Dec 2017 08:49:52 +0000 (09:49 +0100)]
server: add log message when client connection is destroyed due to an error

The client connection is destroyed by the server in several
circumstances. This patch adds log messages in case the connection is
destroyed due to an error other than normal hangup.

Signed-off-by: Mathias Fiedler <mathias_fiedler@mentor.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agotests: Check for wrong fd delivery with zombie objects
Derek Foreman [Wed, 6 Dec 2017 17:22:25 +0000 (11:22 -0600)]
tests: Check for wrong fd delivery with zombie objects

Until recently, if an event attempting to deliver an fd to a zombie
object was demarshalled after the object was made into a zombie, we
leaked the fd and left it in the buffer.

If another event attempting to deliver an fd to a live object was in that
same buffer, the zombie's fd would be delivered instead.

This test recreates that situation.

While this is a ridiculously contrived way to force this race - delivering
an event from a destruction handler - I do have reports of this race
being hit in real world code.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
6 years agotests: Add a test for fd leaks on zombie objects
Derek Foreman [Wed, 6 Dec 2017 17:22:24 +0000 (11:22 -0600)]
tests: Add a test for fd leaks on zombie objects

Until recently, if a client destroying a resource raced with the
server generating an event on that resource that delivered a file
descriptor, we would leak the fd.

This tests for a leaked fd from that race condition.

Reviewed-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoclient: Consume file descriptors destined for zombie proxies
Derek Foreman [Wed, 6 Dec 2017 17:22:23 +0000 (11:22 -0600)]
client: Consume file descriptors destined for zombie proxies

We need to close file descriptors sent to zombie proxies to avoid leaking
them, and perhaps more importantly, to prevent them from being dispatched
in events on other objects (since they would previously be left in the
buffer and potentially fed to following events destined for live proxies)

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoclient: Replace the singleton zombie with bespoke zombies
Derek Foreman [Wed, 6 Dec 2017 17:22:22 +0000 (11:22 -0600)]
client: Replace the singleton zombie with bespoke zombies

Using the singleton zombie object doesn't allow us to posthumously retain
object interface information, which makes it difficult to properly inter
future events destined for the recently deceased proxy.

Notably, this makes it impossible for zombie proxy destined file
descriptors to be properly consumed.

When we create a proxy, we now create a zombie-state object to hold
information about the file descriptors in events it can receive. This
will allow us, in a future patch, to close those FDs.

[daniels: Split Derek's patch into a few smaller ones.]

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoclient: Plug a race in proxy destruction vs. dispatch
Daniel Stone [Thu, 28 Dec 2017 16:05:59 +0000 (16:05 +0000)]
client: Plug a race in proxy destruction vs. dispatch

Closures created to hold events which will be dispatched on the client,
take a reference to the proxy for the object the event was sent to, as
well as the proxies for all objects referenced in that event.

These references are dropped immediately before dispatch, with the
display lock also being released. This leaves the potential for a
vanishingly small race, where another thread drops the last reference
on one of the proxies used in an event as it is being dispatched.

Fix this by splitting decrease_closure_args_refcount into two functions:
one which validates the objects (to ensure that clients are not returned
objects which they have destroyed), and another which unrefs all proxies
on the closure (object event was sent to, all referenced objects) as
well as the closure itself. For symmetry, increase_closure_args_refcount
is now the place where the refcount for the proxy for the object the
event was sent to, is increased.

This also happens to fix a bug: previously, if an event was sent to a
client-destroyed object, and the event had object arguments, a reference
would be leaked on the proxy for each of the object arguments.

Found by inspection whilst reviewing the zombie-FD-leak series.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Cc: Jonas Ådahl <jadahl@gmail.com>
Cc: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoclient: Add wl_proxy_unref helper
Daniel Stone [Thu, 28 Dec 2017 15:50:06 +0000 (15:50 +0000)]
client: Add wl_proxy_unref helper

Rather than open-coded decrement-and-maybe-free, introduce a
wl_proxy_unref helper to do this for us. This will come in useful for
future patches, where we may also have to free a zombie object.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Cc: Jonas Ådahl <jadahl@gmail.com>
6 years agoclient: Use refcount exclusively for destruction
Daniel Stone [Thu, 28 Dec 2017 15:41:18 +0000 (15:41 +0000)]
client: Use refcount exclusively for destruction

Commit e273c7cde added a refcount to wl_proxy. The refcount is set to 1
on creation, decreased when the client explicitly destroys the proxy,
and is increased and decreased every time an event referencing that
proxy is queued.

Assuming no bugs, this means the refcount cannot reach 0 without the
proxy being explicitly destroyed. However, some (not all) of the
proxy-unref paths were only destroying the proxy if it had already been
deleted. This should already be enforced by refcounting, so remove the
check and rely solely on the refcount as the arbiter of when to free a
proxy.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Cc: Jonas Ådahl <jadahl@gmail.com>
6 years agoclient: Remove WL_ZOMBIE_OBJECT global
Derek Foreman [Thu, 28 Dec 2017 15:30:09 +0000 (15:30 +0000)]
client: Remove WL_ZOMBIE_OBJECT global

Since we now have the WL_MAP_ENTRY_ZOMBIE flag to determine whether or
not a client-side object is a zombie, we can remove the faux object.

[daniels: Extracted from Derek's bespoke-zombie patch as an intermediate
          step.]

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoclient: Restructure delete_id handler control flow
Derek Foreman [Thu, 28 Dec 2017 15:28:11 +0000 (15:28 +0000)]
client: Restructure delete_id handler control flow

This makes it easier for future patches in the series, which can
possibly return NULL for extant map entries.

[daniels: Extracted from Derek's bespoke-zombie patch as an intermediate
          step.]

Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoclient: Add WL_MAP_ENTRY_ZOMBIE flag
Derek Foreman [Thu, 28 Dec 2017 15:22:25 +0000 (15:22 +0000)]
client: Add WL_MAP_ENTRY_ZOMBIE flag

Add a new map entry flag to indicate that the object received is valid,
but a zombie. Previously this relied on a fixed object pointer, but
future patches in this series will have map entries returning either
NULL, or a different structure type entirely, for zombie objects.

wl_object_is_zombie() now solely uses the new flag to determine whether
or not the object is a zombie.

[daniels: Extracted from Derek's bespoke-zombie patch as an intermediate
          step.]

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoclient: Add wl_object_is_zombie() helper function
Derek Foreman [Thu, 28 Dec 2017 15:15:46 +0000 (15:15 +0000)]
client: Add wl_object_is_zombie() helper function

Add a helper function which determines whether or not an object is a
zombie.

[daniels: Extracted from Derek's bespoke-zombie patch as an intermediate
          step.]

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoutil: Pass flags to map iterators
Derek Foreman [Wed, 6 Dec 2017 17:22:21 +0000 (11:22 -0600)]
util: Pass flags to map iterators

On the client side we're going to need to know if an object from the
map is a zombie before we attempt to dereference it, so we need to
pass this to the iterator.

Reviewed-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoconnection: Make wl_closure_destroy() close fds of undispatched closures
Derek Foreman [Wed, 6 Dec 2017 17:22:20 +0000 (11:22 -0600)]
connection: Make wl_closure_destroy() close fds of undispatched closures

When we have a closure that can't be dispatched for some reason, and it
contains file descriptors, we must close those descriptors to prevent
leaking them.

Previous commits ensure that only FDs belonging to this invocation of
the closure, i.e. not FDs provided by the client for marshalling, nor
FDs which have already been dispatched to either client or server, will
be left in the closure by destroy time.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoconnection: Clear fds we shouldn't close to -1
Derek Foreman [Wed, 6 Dec 2017 17:22:19 +0000 (11:22 -0600)]
connection: Clear fds we shouldn't close to -1

This initializes all the fd arguments in closures to -1 and clears
them back to -1 when they've been dispatched or serialized.

This means that any valid fd in a closure is currently libwayland's
responsibility to close in the case of an error.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoconnection: Refactor out closure allocation
Derek Foreman [Wed, 6 Dec 2017 17:22:18 +0000 (11:22 -0600)]
connection: Refactor out closure allocation

Moves the common/similar bits into one place.

This has a minor functional change - count and message are now initialized
immediately, previously they'd only be set if (de)marshal was successful.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoserver: Log closure before sending it
Derek Foreman [Wed, 6 Dec 2017 17:22:17 +0000 (11:22 -0600)]
server: Log closure before sending it

This seems foolishly cosmetic on the surface - and will reorder log
messages in certain failure cases.  "request could not be marshalled"
will now appear after logging the request that failed to marshal
instead of before.

The real point of this is that a follow up patch will make
wl_closure_send() set fds to -1 as it buffers them for send, so
they can be more easily cleaned up.

Doing that while leaving this order unchanged would result in
printing -1 for fds instead of their value.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoconnection: Don't declare a local variable just to takes its size
Derek Foreman [Wed, 6 Dec 2017 17:22:16 +0000 (11:22 -0600)]
connection: Don't declare a local variable just to takes its size

We can sizeof the struct type instead of declaring a pointer and
taking the size of what it points to.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agodoc: start documenting Xwayland
Pekka Paalanen [Mon, 21 Nov 2016 10:09:46 +0000 (12:09 +0200)]
doc: start documenting Xwayland

This is a rough intro to what Xwayland is and does, with just one
implementation detail so far (Window identification).

I paid no attention to formatting details, those can be polished in
follow-ups. I just want the prose out.

I also just quickly whacked up the diagram, would be happy to see
someone replace it with a nicer one. I just didn't have time to learn
dot for now.

v2:
- typo fix
- rephrase "talking to hardware" as "driving the displays"
- mention circular dependency in intro
- add section to explain rootless and rootful modes
- remove paragraph about Xwayland protocol usage
- move TBD part to the end under a new section header

v3:
- use "advantage" and "disadvantage" instead of "pro" and "con"
- slight rewording on rootful mode and rootless mode paragraphs
- removed the paragraph about the lack of shell and special Wayland
  protocol extensions
- removed the commented out list of ideas to write

v4:
- typo fixes pointed out by Yong

Cc: Olivier Fourdan <ofourdan@redhat.com>
Cc: Jonas Ådahl <jadahl@gmail.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
6 years agoclient: Allow absolute paths in WAYLAND_DISPLAY
Matt Hoosier [Mon, 27 Nov 2017 14:54:54 +0000 (08:54 -0600)]
client: Allow absolute paths in WAYLAND_DISPLAY

In order to support system compositor instances, it is necessary to
allow clients' wl_display_connect() to find the compositor's listening
socket somewhere outside of XDG_RUNTIME_DIR. For a full account, see
the discussion beginning here:

https://lists.freedesktop.org/archives/wayland-devel/2017-November/035664.html

This change adjusts the client-side connection logic so that, if
WAYLAND_DISPLAY is formatted as an absolute pathname, the socket
connection attempt is made to just $WAYLAND_DISPLAY rather than
usual user-private location $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY.

This change is based on Davide Bettio's submission of the same concept
at:

https://lists.freedesktop.org/archives/wayland-devel/2015-August/023838.html.

v4 changes:

* Improved internal comments and some boundary-condition
  error checks in test case.
* Refer to compositor as "Wayland server" rather than "Wayland
  display" in wl_display_connect() doxygen comments.
* Remove redundant descriptions of parameter-interpretation
  mechanics from wl_display_connect() manpage. Reworked things
  to make it clear that 'name' and $WAYLAND_DISLAY are each
  capable of encoding absolute server socket paths.
* Remove callout to reference implementation behavior in protocol
  documented. In its place there is now a simple statement that
  implementations can optionally support absolute socket paths.

v3 changes:

* Added test case.
* Clarified documentation to note that 'name' parameter to wl_display_connect()
  can also be an absolute path.

v2 changes:

* Added backward incompatibility note to wl_display_connect() manpage.
* Rephased wl_display_connect() manpage changes to precisely match actual
  changed behavior.
* Added mention of new absolute path behavior in wl_display_connect()
  doxygen comments.
* Mentioned new absolute path interpretation of WAYLAND_DISPLAY in
  protocol documentation.

Signed-off-by: Matt Hoosier <matt.hoosier@gmail.com>
Acked-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoprotocol: make get_subsurface double-buffered
Pekka Paalanen [Mon, 9 May 2016 11:45:05 +0000 (14:45 +0300)]
protocol: make get_subsurface double-buffered

The existing specification was not explicitly clear on when
wl_subcompositor.get_subsurface request actually adds the sub-surface to
the parent in the compositor's scenegraph. The implicit assumption was
that this happens immediately, but it was not written anywhere.

If it happens immediately, the client doing things in a wrong order may
cause a glitch on screen. Particularly, if the wl_surface B that is
going to be a sub-surface for wl_surface A (the parent) already has a
buffer committed, and the parent surface is mapped, then get_subsurface
will (may?) cause wl_surface B to become mapped immediately. That leaves
no time to set up the sub-surface z-order or position before mapping,
hence there can be a visible glitch.

The way to avoid that, given that the parent surface is mapped, is to
not commit a buffer to wl_surface B until all the sub-surface setup is
done.

However, doing the sub-surface setup always requires a wl_surface.commit
on the parent surface unless the defaults happen to be correct.

To make setting up a subsurface slightly easier by removing one
possibility for a glitch, this patch amends the specification to require
a wl_surface.commit on the parent surface for get_subsurface to
complete. The sub-surface cannot become mapped before a parent commit.

This change may break existing clients that relied on the glitchy
sequence to not need a parent surface commit to map the sub-surface.
However, presumably all uses would at least issue a
wl_subsurface.set_position, which requires a parent surface commit to
apply. That would guarantee that there is a parent surface commit after
get_subsurface, and so reduces the chances of breaking anything.

In other cases, this change may simply remove a possibility for the
glitch.

This patch also adds a note about changing wl_surface.commit behaviour
on wl_subcompositor.get_subsurface. (That could be a separate patch.)

The behaviour of wl_subsurface.destroy remains as specified, even though
it is now slightly asymmetrical to get_subsurface. This is emphasized by
adding the word "immediately". The effects of destruction were already
explicitly documented, as is the way to achieve synchronized unmapping,
so changing destruction behaviour would likely be more disruptive, and
also open up more corner cases (what would happen between destroy and
unmapping?).

Bug: https://phabricator.freedesktop.org/T7358
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Martin Gräßlin <mgraesslin@kde.org>
6 years agoscanner: Add --strict flag
Jonas Ådahl [Wed, 11 Oct 2017 09:31:33 +0000 (17:31 +0800)]
scanner: Add --strict flag

Add a --strict flag for making wayland-scanner fail if the DTD
verification fails. This is useful for testing, so that a test case can
fail a scan when the protocol doesn't comply with the DTD.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
6 years agoconnection: Use wl_buffer_size() for all buffer size calculations
Derek Foreman [Thu, 13 Apr 2017 16:51:51 +0000 (11:51 -0500)]
connection: Use wl_buffer_size() for all buffer size calculations

There were two places where we did the same calculation manually.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoclient: Simplify some logic in queue_event
Derek Foreman [Thu, 13 Apr 2017 16:51:47 +0000 (11:51 -0500)]
client: Simplify some logic in queue_event

Both the blocks in this if/else clause do the same thing, so combine
the comparisons into one.

No functional change.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoconnection: close_fds() should only remove fds it closed from the buffer
Derek Foreman [Thu, 13 Apr 2017 16:51:43 +0000 (11:51 -0500)]
connection: close_fds() should only remove fds it closed from the buffer

All current callers close all fds, so this has gone unnoticed, but if
we close less than all fds with close_fds() we leak all the unclosed
ones and ruin further event demarshalling.

A future patch will close less than the full buffer's worth of fds,
so this is now noticed.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoDo not create man page links with doxygen
Armin Krezović [Thu, 27 Jul 2017 12:08:37 +0000 (14:08 +0200)]
Do not create man page links with doxygen

There is a lot of files created with .so links to non-installed
files, making most of installed pages useless. The files
referenced in .so links are not suitable for installation nor
do they contain any useful information for them to be worth
fixing.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Acked-by: Daniel Stone <daniels@collabora.com>
6 years agoeventloop: clarify post_dispatch_check()
Christopher James Halse Rogers [Mon, 28 Aug 2017 08:03:38 +0000 (18:03 +1000)]
eventloop: clarify post_dispatch_check()

This *technically* changes the semantics of the return value of the source callbacks.
Previously you could return a negative number from a source callback and it would prevent
*other* source callbacks from triggering a subsequent recheck.

Doing that seems like such a bad idea it's not worth supporting.

v2: Log this case if it is hit, so we don't silently change behaviour.

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoprotocol: Add deprecation note about wl_shell
Jonas Ådahl [Sat, 2 Dec 2017 02:57:45 +0000 (10:57 +0800)]
protocol: Add deprecation note about wl_shell

Now that xdg_shell is stable and much better defined than wl_shell we
can finally deprecate wl_shell and guide users towards xdg_shell
instead.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocursor: add forward declaration for struct wl_buffer
Emil Velikov [Thu, 12 Oct 2017 12:39:17 +0000 (13:39 +0100)]
cursor: add forward declaration for struct wl_buffer

This makes the header self-contained, since the struct is considered
opaque from waylad-cursor POV.

As we're here move the wl_shm fwd. declaration alongside the others.
Making it easier to read and track.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
6 years agotests: Mark tests used so they don’t get removed at link time
Emmanuel Gil Peyrot [Fri, 14 Apr 2017 18:48:05 +0000 (19:48 +0100)]
tests: Mark tests used so they don’t get removed at link time

Without this attribute, these macros were making Weston’s tests fail to
build with LTO enabled.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94602
Signed-off-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Tested-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agotests: Add one more indentation level to some macros
Emmanuel Gil Peyrot [Fri, 14 Apr 2017 18:48:04 +0000 (19:48 +0100)]
tests: Add one more indentation level to some macros

This is a preparatory patch for the next one.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocursor: Fix heap overflows when parsing malicious files.
Tobias Stoeckmann [Tue, 28 Nov 2017 20:38:07 +0000 (21:38 +0100)]
cursor: Fix heap overflows when parsing malicious files.

It is possible to trigger heap overflows due to an integer overflow
while parsing images.

The integer overflow occurs because the chosen limit 0x10000 for
dimensions is too large for 32 bit systems, because each pixel takes
4 bytes. Properly chosen values allow an overflow which in turn will
lead to less allocated memory than needed for subsequent reads.

See also: https://cgit.freedesktop.org/xorg/lib/libXcursor/commit/?id=4794b5dd34688158fb51a2943032569d3780c4b8
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=103961

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
[Pekka: add link to the corresponding libXcursor commit]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agowayland-server: document WL_HIDE_DEPRECATED
Emil Velikov [Fri, 8 Sep 2017 10:49:53 +0000 (11:49 +0100)]
wayland-server: document WL_HIDE_DEPRECATED

Add some inline information, what the macro is used for, why it came to
be and what we shouldn't do if we consider further deprecation in the future
deprecation.

Cc: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>