Re: [PATCH libinput 1/2] test: create a lock file to avoid parallel udev reloads during device add

2016-07-04 Thread Jonas Ådahl
On Tue, Jul 05, 2016 at 12:43:43PM +1000, Peter Hutterer wrote:
> litest_add_device and litest_delete_device trigger a udev rule reload. This
> messes with some test devices and when we run multiple tests in parallel we
> get weird errors like "keyboard $BLAH failed the touchpad sanity test".
> 
> Still not 100% reliable to run tests in parallel, but it's vastly improved
> now.
> 
> Signed-off-by: Peter Hutterer 
> ---
>  configure.ac  |  3 +++
>  test/litest.c | 63 
> +++
>  2 files changed, 66 insertions(+)
> 
> diff --git a/configure.ac b/configure.ac
> index 8c14efe..3e973d4 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -194,6 +194,9 @@ if test "x$build_tests" = "xyes"; then
>   AC_DEFINE_UNQUOTED(HAVE_ADDR2LINE, 1, [addr2line found])
>   AC_DEFINE_UNQUOTED(ADDR2LINE, ["$ADDR2LINE"], [Path to 
> addr2line])
>   fi
> +
> + AC_DEFINE(LITEST_UDEV_LOCKFILE, ["/tmp/litest-udev.lock"],
> +   [Lock file used to restrict udev reloads during tests])
>  fi
>  AM_CONDITIONAL(HAVE_LIBUNWIND, [test "x$HAVE_LIBUNWIND" = xyes])
>  
> diff --git a/test/litest.c b/test/litest.c
> index 9b4feed..1250b3f 100644
> --- a/test/litest.c
> +++ b/test/litest.c
> @@ -1164,6 +1164,58 @@ litest_restore_log_handler(struct libinput *libinput)
>   libinput_log_set_handler(libinput, litest_log_handler);
>  }
>  
> +static inline int
> +create_udev_lock_file(void)
> +{
> + int lfd;
> +
> + /* Running the multiple tests in parallel usually trips over udev
> +  * not being  up-to-date. We change the udev rules for every device
> +  * created, sometimes this means we end up getting the wrong udev
> +  * device, or having wrong properties applied.
> +  *
> +  * litests use the path interface and there is a window between
> +  * creating the device (which triggers udev reloads) and adding the
> +  * device to the libinput context where another udev reload may
> +  * upset things.
> +  *
> +  * To avoid this, create a lockfile on device add and device delete
> +  * to make sure that we have exclusive access to udev while
> +  * the udev rules are reloaded.
> +  */
> + do {
> + lfd = open(LITEST_UDEV_LOCKFILE, O_CREAT|O_EXCL, O_RDWR);
> +
> + if (lfd == -1) {
> + struct stat st;
> + time_t now = time(NULL);
> +
> + litest_assert_int_eq(errno, EEXIST);
> + msleep(10);
> +
> + /* If the lock file is older than 10s, it's a
> +leftover from some aborted test */
> + if (stat(LITEST_UDEV_LOCKFILE, ) != -1) {
> + if (st.st_mtime < now - 10) {

I suppose making sure the test case runs fine when changing between
summer time/not summer time is unimportant enough to care about, but I
suspect it could make this check fail.

This and the next one is Reviewed-by: Jonas Ådahl 


Jonas

> + fprintf(stderr,
> + "Removing stale lock file 
> %s.\n",
> + LITEST_UDEV_LOCKFILE);
> + unlink(LITEST_UDEV_LOCKFILE);
> + }
> + }
> + }
> + } while (lfd < 0);
> +
> + return lfd;
> +}
> +
> +static inline void
> +delete_udev_lock_file(int lfd)
> +{
> + close(lfd);
> + unlink(LITEST_UDEV_LOCKFILE);
> +}
> +
>  struct litest_device *
>  litest_add_device_with_overrides(struct libinput *libinput,
>enum litest_device_type which,
> @@ -1177,6 +1229,8 @@ litest_add_device_with_overrides(struct libinput 
> *libinput,
>   int rc;
>   const char *path;
>  
> + int lfd = create_udev_lock_file();
> +
>   d = litest_create(which,
> name_override,
> id_override,
> @@ -1202,6 +1256,9 @@ litest_add_device_with_overrides(struct libinput 
> *libinput,
>   d->interface->min[ABS_Y] = libevdev_get_abs_minimum(d->evdev, 
> ABS_Y);
>   d->interface->max[ABS_Y] = libevdev_get_abs_maximum(d->evdev, 
> ABS_Y);
>   }
> +
> + delete_udev_lock_file(lfd);
> +
>   return d;
>  }
>  
> @@ -1258,9 +1315,13 @@ litest_handle_events(struct litest_device *d)
>  void
>  litest_delete_device(struct litest_device *d)
>  {
> + int lfd;
> +
>   if (!d)
>   return;
>  
> + lfd = create_udev_lock_file();
> +
>   if (d->udev_rule_file) {
>   unlink(d->udev_rule_file);
>   free(d->udev_rule_file);
> @@ -1278,6 +1339,8 @@ litest_delete_device(struct litest_device *d)
>   free(d->private);
>   memset(d,0, sizeof(*d));
>   free(d);
> +
> + delete_udev_lock_file(lfd);
>  }
>  
>  

[PATCH libinput 2/2] test: up the timeout to 30s

2016-07-04 Thread Peter Hutterer
10s is not enough when running the test suite in parallel as any test may have
to wait longer than that to get access to the udev lock. Especially for
tests with multiple timeouts it was too easy to trigger timeouts.

Up the timeout to 30s, this seems reliable enough now.

Signed-off-by: Peter Hutterer 
---
 test/litest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/litest.c b/test/litest.c
index 1250b3f..0df480e 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -3104,7 +3104,7 @@ main(int argc, char **argv)
 
list_init(_tests);
 
-   setenv("CK_DEFAULT_TIMEOUT", "10", 0);
+   setenv("CK_DEFAULT_TIMEOUT", "30", 0);
setenv("LIBINPUT_RUNNING_TEST_SUITE", "1", 1);
 
mode = litest_parse_argv(argc, argv);
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 1/2] test: create a lock file to avoid parallel udev reloads during device add

2016-07-04 Thread Peter Hutterer
litest_add_device and litest_delete_device trigger a udev rule reload. This
messes with some test devices and when we run multiple tests in parallel we
get weird errors like "keyboard $BLAH failed the touchpad sanity test".

Still not 100% reliable to run tests in parallel, but it's vastly improved
now.

Signed-off-by: Peter Hutterer 
---
 configure.ac  |  3 +++
 test/litest.c | 63 +++
 2 files changed, 66 insertions(+)

diff --git a/configure.ac b/configure.ac
index 8c14efe..3e973d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,6 +194,9 @@ if test "x$build_tests" = "xyes"; then
AC_DEFINE_UNQUOTED(HAVE_ADDR2LINE, 1, [addr2line found])
AC_DEFINE_UNQUOTED(ADDR2LINE, ["$ADDR2LINE"], [Path to 
addr2line])
fi
+
+   AC_DEFINE(LITEST_UDEV_LOCKFILE, ["/tmp/litest-udev.lock"],
+ [Lock file used to restrict udev reloads during tests])
 fi
 AM_CONDITIONAL(HAVE_LIBUNWIND, [test "x$HAVE_LIBUNWIND" = xyes])
 
diff --git a/test/litest.c b/test/litest.c
index 9b4feed..1250b3f 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -1164,6 +1164,58 @@ litest_restore_log_handler(struct libinput *libinput)
libinput_log_set_handler(libinput, litest_log_handler);
 }
 
+static inline int
+create_udev_lock_file(void)
+{
+   int lfd;
+
+   /* Running the multiple tests in parallel usually trips over udev
+* not being  up-to-date. We change the udev rules for every device
+* created, sometimes this means we end up getting the wrong udev
+* device, or having wrong properties applied.
+*
+* litests use the path interface and there is a window between
+* creating the device (which triggers udev reloads) and adding the
+* device to the libinput context where another udev reload may
+* upset things.
+*
+* To avoid this, create a lockfile on device add and device delete
+* to make sure that we have exclusive access to udev while
+* the udev rules are reloaded.
+*/
+   do {
+   lfd = open(LITEST_UDEV_LOCKFILE, O_CREAT|O_EXCL, O_RDWR);
+
+   if (lfd == -1) {
+   struct stat st;
+   time_t now = time(NULL);
+
+   litest_assert_int_eq(errno, EEXIST);
+   msleep(10);
+
+   /* If the lock file is older than 10s, it's a
+  leftover from some aborted test */
+   if (stat(LITEST_UDEV_LOCKFILE, ) != -1) {
+   if (st.st_mtime < now - 10) {
+   fprintf(stderr,
+   "Removing stale lock file 
%s.\n",
+   LITEST_UDEV_LOCKFILE);
+   unlink(LITEST_UDEV_LOCKFILE);
+   }
+   }
+   }
+   } while (lfd < 0);
+
+   return lfd;
+}
+
+static inline void
+delete_udev_lock_file(int lfd)
+{
+   close(lfd);
+   unlink(LITEST_UDEV_LOCKFILE);
+}
+
 struct litest_device *
 litest_add_device_with_overrides(struct libinput *libinput,
 enum litest_device_type which,
@@ -1177,6 +1229,8 @@ litest_add_device_with_overrides(struct libinput 
*libinput,
int rc;
const char *path;
 
+   int lfd = create_udev_lock_file();
+
d = litest_create(which,
  name_override,
  id_override,
@@ -1202,6 +1256,9 @@ litest_add_device_with_overrides(struct libinput 
*libinput,
d->interface->min[ABS_Y] = libevdev_get_abs_minimum(d->evdev, 
ABS_Y);
d->interface->max[ABS_Y] = libevdev_get_abs_maximum(d->evdev, 
ABS_Y);
}
+
+   delete_udev_lock_file(lfd);
+
return d;
 }
 
@@ -1258,9 +1315,13 @@ litest_handle_events(struct litest_device *d)
 void
 litest_delete_device(struct litest_device *d)
 {
+   int lfd;
+
if (!d)
return;
 
+   lfd = create_udev_lock_file();
+
if (d->udev_rule_file) {
unlink(d->udev_rule_file);
free(d->udev_rule_file);
@@ -1278,6 +1339,8 @@ litest_delete_device(struct litest_device *d)
free(d->private);
memset(d,0, sizeof(*d));
free(d);
+
+   delete_udev_lock_file(lfd);
 }
 
 void
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 3/9] gl-renderer: move check_extension() to shared/

2016-07-04 Thread Emil Velikov
On 4 July 2016 at 15:34, Emil Velikov  wrote:

> diff --git a/shared/config-parser.c b/shared/config-parser.c
> index 2256469..d316958 100644
> --- a/shared/config-parser.c
> +++ b/shared/config-parser.c
> @@ -39,6 +39,7 @@
>
>  #include 
>  #include "config-parser.h"
> +#include "config-parser-priv.h"
Git rebase failure. This hunk shouldn't be here.

-Emil
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 4/6] libweston: use new versioning scheme

2016-07-04 Thread Emil Velikov
On 4 July 2016 at 15:45, Quentin Glidic  wrote:
> On 04/07/2016 16:23, Emil Velikov wrote:
>>
>> Use the documented libweston-$major.so.0.$minor.$patch scheme.
>>
>> An (almost) identical one is used by GLIB, GTK{2,3}, QT5, json-glib and
>> others.
>>
>> v2:
>>  - Use shorter variable names LIBWESTON_{MAJOR,MINOR...}
>>  - Correctly use -version-info.
>>  - Drop unneeded @LIBWESTON_VERSION_MAJOR@ additions.
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>
>> XXX:
>>  - Should we rename libweston{,-0}.pc.in ?
>>  - Drop the s/LIBWESTON_ABI_VERSION/LIBWESTON_MAJOR/ hunk ?
>>  - Keep the configure libweston_*_version variables shorter ?
>>  - Yes, the LT_VERSION_INFO hunk looks a bit nasty, yet this is what GTK
>> is doing, once you unraver the 2-3 layers of variables. It works as
>> expected though, and I'd imagine others are doing a similar trick.
>>
>> fixup! libweston: use new versioning scheme
>
>
> Looks good. A bit hard to read but I thing you at least build-tested it. :-)
>
> I think you can drop the "v2" part in the commit message, btw.
>
I've noticed that other commits keep their revision history above the
--- line, and thus is present in git log. So I take that it's a nice
to have, but here it's just useless ?

> One last comment inline to make it perfect.
>
>
>
>> ---
>>  Makefile.am | 24 
>>  compositor/weston.pc.in |  2 +-
>>  configure.ac| 12 +---
>>  3 files changed, 22 insertions(+), 16 deletions(-)
>>
>> diff --git a/Makefile.am b/Makefile.am
>> index b050c60..1c3d553 100644
>> --- a/Makefile.am
>> +++ b/Makefile.am
>> @@ -5,7 +5,7 @@ noinst_PROGRAMS =
>>  libexec_PROGRAMS =
>>  moduledir = $(libdir)/weston
>>  module_LTLIBRARIES =
>> -libweston_moduledir = $(libdir)/libweston-${LIBWESTON_ABI_VERSION}
>> +libweston_moduledir = $(libdir)/libweston-$(LIBWESTON_MAJOR)
>>  libweston_module_LTLIBRARIES =
>>  noinst_LTLIBRARIES =
>>  BUILT_SOURCES =
>> @@ -61,15 +61,15 @@ CLEANFILES = weston.ini \
>> internal-screenshot-00.png  \
>> $(BUILT_SOURCES)
>>
>> -lib_LTLIBRARIES = libweston.la
>> -libweston_la_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
>> -libweston_la_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS)
>> $(LIBUNWIND_CFLAGS)
>> -libweston_la_LIBADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
>> +lib_LTLIBRARIES = libweston-@LIBWESTON_MAJOR@.la
>> +libweston_@LIBWESTON_MAJOR@_la_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
>> +libweston_@LIBWESTON_MAJOR@_la_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS)
>> $(LIBUNWIND_CFLAGS)
>> +libweston_@LIBWESTON_MAJOR@_la_LIBADD = $(COMPOSITOR_LIBS)
>> $(LIBUNWIND_LIBS) \
>> $(DLOPEN_LIBS) -lm $(CLOCK_GETTIME_LIBS) \
>> $(LIBINPUT_BACKEND_LIBS) libshared.la
>> -libweston_la_LDFLAGS = -release ${LIBWESTON_ABI_VERSION}
>> +libweston_@LIBWESTON_MAJOR@_la_LDFLAGS = -version-info $(LT_VERSION_INFO)
>>
>> -libweston_la_SOURCES = \
>> +libweston_@LIBWESTON_MAJOR@la_SOURCES =\
>> libweston/git-version.h \
>> libweston/log.c \
>> libweston/compositor.c  \
>> @@ -121,7 +121,7 @@ systemd_notify_la_SOURCES = \
>> libweston/compositor.h
>>  endif
>>
>> -nodist_libweston_la_SOURCES =  \
>> +nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES =
>> \
>> protocol/weston-screenshooter-protocol.c\
>> protocol/weston-screenshooter-server-protocol.h \
>> protocol/text-cursor-position-protocol.c\
>> @@ -137,7 +137,7 @@ nodist_libweston_la_SOURCES =
>> \
>> protocol/linux-dmabuf-unstable-v1-protocol.c\
>> protocol/linux-dmabuf-unstable-v1-server-protocol.h
>>
>> -BUILT_SOURCES += $(nodist_libweston_la_SOURCES)
>> +BUILT_SOURCES += $(nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES)
>>
>>  bin_PROGRAMS += weston
>>
>> @@ -148,7 +148,7 @@ weston_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
>> \
>>  weston_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS)
>>  weston_LDADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
>> $(DLOPEN_LIBS) $(LIBINPUT_BACKEND_LIBS) \
>> -   -lm libshared.la libweston.la
>> +   -lm libshared.la libweston-@LIBWESTON_MAJOR@.la
>>
>>  weston_SOURCES =   \
>> compositor/main.c   \
>> @@ -225,12 +225,12 @@ endif
>>  endif # BUILD_WESTON_LAUNCH
>>
>>  pkgconfigdir = $(libdir)/pkgconfig
>> -pkgconfig_DATA = compositor/weston.pc
>> libweston/libweston-${LIBWESTON_ABI_VERSION}.pc
>> +pkgconfig_DATA = compositor/weston.pc
>> libweston/libweston-${LIBWESTON_MAJOR}.pc
>>
>>  wayland_sessiondir = $(datadir)/wayland-sessions
>>  dist_wayland_session_DATA = compositor/weston.desktop
>>
>> -libwestonincludedir = 

Re: [PATCH weston 6/6] libweston: do not use weston version in libweston.pc

2016-07-04 Thread Emil Velikov
On 4 July 2016 at 15:35, Quentin Glidic  wrote:
> On 04/07/2016 16:23, Emil Velikov wrote:
>>
>> From: Emil Velikov 
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>  configure.ac  | 1 +
>>  libweston/libweston.pc.in | 2 +-
>>  2 files changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index be40f10..46b61ae 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -21,6 +21,7 @@ AC_SUBST([WESTON_VERSION_MINOR], [weston_minor_version])
>>  AC_SUBST([WESTON_VERSION_MICRO], [weston_micro_version])
>>  AC_SUBST([WESTON_VERSION], [weston_version])
>>  AC_SUBST([LIBWESTON_MAJOR], [libweston_major_version])
>> +AC_SUBST([LIBWESTON_VERSION],
>> [libweston_major_version.libweston_minor_version.libweston_patch_version])
>
>
> That makes packaging a pain. Although the whole libweston (supposedly
> parallel-installable) is already a pain.
>
> When you have a project with a dep on libweston, you’ll have to dig the
> weston version because the tarball is versioned as weston.
>
> I would only do that once (and if) we split libweston and weston to
> different repositories.
>
Yes splitting libweston into separate repo makes sense. Yet I failed
to see where the actual pain is - there is a minor annoyance, and devs
and/or distro maintainers have learned to deal with a lot nastier
things through the years.

If anything, having libweston-2 provided by (a future)
libweston-1.12.0 tarball/package would make things even more
confusing/annoying. That is unless one is planning to say "f**k it,
let's decrease the version" upon the split. With the later upsetting a
lot of people.

-Emil
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 0/6] Rework libweston versioning, take 2(?)

2016-07-04 Thread Emil Velikov
On 4 July 2016 at 15:55, Pekka Paalanen  wrote:
> On Mon,  4 Jul 2016 15:23:48 +0100
> Emil Velikov  wrote:
>
>> Hi all,
>>
>> Here is a respin of the earlier series which changes how libweston is
>> named, and thus shipped. I believe all the logic/reasoning is explicitly
>> stated, although if something feels amiss, please let me know.
>>
>> NOTE: WARNING: The series exposes a fatal bug in weston thus the tests
>> fail to build (let alone run).
>> Namely: atm some/many of the modules are built with unresolved symbols.
>> Is that a bug or by design ? From a quick look it seems to be the
>> latter.
>
> Hi Emil,
>
> what unresolved symbols?
>
For the exact list check your system weston with ldd -r foo. For
example on my Arch setup with weston 1.10.0-1

$ ldd -r /usr/lib/weston/* | grep undefined | wc -l

$ ldd -r /usr/lib/weston/* | grep undefined | head
undefined symbol: weston_log(/usr/lib/weston/cms-colord.so)
undefined symbol: weston_log(/usr/lib/weston/cms-static.so)
undefined symbol: zwp_input_panel_v1_interface
(/usr/lib/weston/desktop-shell.so)
undefined symbol: zwp_input_panel_surface_v1_interface
(/usr/lib/weston/desktop-shell.so)
undefined symbol: weston_stable_fade_run
(/usr/lib/weston/desktop-shell.so)
undefined symbol: weston_compositor_schedule_repaint
(/usr/lib/weston/desktop-shell.so)
undefined symbol: weston_surface_set_size
(/usr/lib/weston/desktop-shell.so)
undefined symbol: weston_move_scale_run (/usr/lib/weston/desktop-shell.so)
undefined symbol: weston_matrix_multiply
(/usr/lib/weston/desktop-shell.so)
undefined symbol: weston_install_debug_key_binding
(/usr/lib/weston/desktop-shell.so)

> You mean the symbols that are resolved from Weston the executable?
>
I'd imagine so.

> Or maybe the symbols that libweston exports, and test modules expect to
> be present without actually linking to libweston?
>
> Yeah, all that needs to be fixed in time. Should we link all modules to
> libweston? I'd assume that should fix almost all of them, but I haven't
> looked yet.
>
> Obviously we cannot land patches that break the tests.
>
Agree. Sadly things were already broken before I came - my changes
only exposed the existing bugs(?).

>> If anyone is interested in resolving this please grep through mesa for
>> "no-undefined" - it handles both -no-undefined and -Wl,--no-undefined in
>> a portable manner.
>
> Preferably all the binaries we build would be using no-undefined. It
> was not possible before libweston because weston the executable
> provided lots of them, but now it should be achievable and a very good
> improvement in catching stupid bugs.
>
From a quick look - most symbols are (should come) from libweston now
that we have it. Although there's a bunch of generated ones, which I'm
not sure about.

It'll be great if someone with more weston/wayland experience than me,
takes a look (at the output of ldd) and categorises them. Then myself
and/or others can divide and concur.

Cheers,
Emil
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 5/6] libweston: do not add libweston-$version to the Cflags

2016-07-04 Thread Emil Velikov
On 4 July 2016 at 15:32, Quentin Glidic  wrote:
> On 04/07/2016 16:23, Emil Velikov wrote:
>>
>> From: Emil Velikov 
>>
>> When managing headers there's normally two ways to handle them
>> - with or without the subfolder.
>>
>> Opting for the latter case here, since it will provide direct feedback,
>> whether one is using libweston-0 or any other version.
>>
>> Which in turn should deter (help prevent) issues like building/linking
>> against multiple versions of libweston.
>>
>> Signed-off-by: Emil Velikov 
>
>
> I really prefer not to do that. It means supporting multiple versions of
> libweston will lead to a really big #ifdef dance at the top of the file to
> include every single version you might support, instead of a just a few
> #ifdef around specific new/old functions you use.
>
Yes, I agree with you - adding ifdef spaghetti is ugly. Then again, if
one wants to support multiple versions they will need a bunch of them
either way.

Keeping things explicit will give (and/or save) you and others a fair
bit of time when it goes wrong/nasty. Here is an (somewhat silly, or
you might say sad) example I've seen in the open-source Tizen world...
or was it Android:

Dev. lacks exact knowledge when function A (libfoo1) and B (libfoo2)
are introduced. Thus he/she adds both versions of libfoo in the
configure pkg-config checks. At which point, you will have symbol
collisions, seemingly random corruption and/or crashes.

Cheers,
Emil
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 0/9] Finalise EGL/GL define(s) rework

2016-07-04 Thread Emil Velikov
Hi all,

This series depends on "EGL/GL definitions cleanup" and does a couple of 
things:
 - makes sure that we consistently use check_extension over strstr for 
extension checking, as the latter might trigger false positives.
 - The remainder of the fall-back definitions has been moved to 
weston-egl-ext.h and reused throughout the tree.

Hopefully I haven't lost my marbles with any of these. But if I did 
please, don't be shy and be blunt :-)

Emil

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 2/9] libweston: don't install shared/platform.h

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

The header contains a set of extension check (helpers), which do not
provide any compositor related functionality and are not required for
using libweston.

Signed-off-by: Emil Velikov 
---
Feel free to disagree, but imho having a combination of nested (inline)
functions some of which using static variables is fragile/nasty.
---
 Makefile.am | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 1c3d553..0163f25 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -244,8 +244,7 @@ libwestoninclude_HEADERS =  \
libweston/timeline-object.h \
shared/matrix.h \
shared/config-parser.h  \
-   shared/zalloc.h \
-   shared/platform.h
+   shared/zalloc.h
 
 westonincludedir = $(includedir)/weston
 westoninclude_HEADERS = compositor/weston.h
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 7/9] weston-egl-ext.h: add EGL platform definitions

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

Will allow us to consolidate the multiple definitions through the tree.

Signed-off-by: Emil Velikov 
---
 libweston/weston-egl-ext.h | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
index c0dbe32..abb767a 100644
--- a/libweston/weston-egl-ext.h
+++ b/libweston/weston-egl-ext.h
@@ -123,5 +123,24 @@ typedef EGLBoolean (EGLAPIENTRYP 
PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay
 #define EGL_NO_CONFIG_MESA  ((EGLConfig)0)
 #endif
 
+#ifndef EGL_EXT_platform_base
+#define EGL_EXT_platform_base 1
+typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum 
platform, void *native_display, const EGLint *attrib_list);
+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) 
(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint 
*attrib_list);
+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) 
(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint 
*attrib_list);
+#endif /* EGL_EXT_platform_base */
+
+#ifndef EGL_PLATFORM_GBM_KHR
+#define EGL_PLATFORM_GBM_KHR 0x31D7
+#endif
+
+#ifndef EGL_PLATFORM_WAYLAND_KHR
+#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
+#endif
+
+#ifndef EGL_PLATFORM_X11_KHR
+#define EGL_PLATFORM_X11_KHR 0x31D5
+#endif
+
 
 #endif
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 4/9] shared/platform.h: use weston_check_extension over strstr

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

The later can give false positives.

Signed-off-by: Emil Velikov 
---
 shared/platform.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/shared/platform.h b/shared/platform.h
index 98849f0..b8be6bf 100644
--- a/shared/platform.h
+++ b/shared/platform.h
@@ -88,9 +88,9 @@ weston_platform_get_egl_proc_address(const char *address)
 {
const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
 
-   if (extensions
-   && (strstr(extensions, "EGL_EXT_platform_wayland")
-   || strstr(extensions, "EGL_KHR_platform_wayland"))) {
+   if (extensions &&
+   (weston_check_extension(extensions, "EGL_EXT_platform_wayland") ||
+weston_check_extension(extensions, "EGL_KHR_platform_wayland"))) {
return (void *) eglGetProcAddress(address);
}
 
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 5/6] libweston: do not add libweston-$version to the Cflags

2016-07-04 Thread Quentin Glidic

On 04/07/2016 16:23, Emil Velikov wrote:

From: Emil Velikov 

When managing headers there's normally two ways to handle them
- with or without the subfolder.

Opting for the latter case here, since it will provide direct feedback,
whether one is using libweston-0 or any other version.

Which in turn should deter (help prevent) issues like building/linking
against multiple versions of libweston.

Signed-off-by: Emil Velikov 


I really prefer not to do that. It means supporting multiple versions of 
libweston will lead to a really big #ifdef dance at the top of the file 
to include every single version you might support, instead of a just a 
few #ifdef around specific new/old functions you use.


NAK for me.


Cheers,


---
 libweston/libweston.pc.in | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libweston/libweston.pc.in b/libweston/libweston.pc.in
index 24fe813..bb95af9 100644
--- a/libweston/libweston.pc.in
+++ b/libweston/libweston.pc.in
@@ -2,11 +2,10 @@ prefix=@prefix@
 exec_prefix=@exec_prefix@
 libdir=@libdir@
 includedir=@includedir@
-pkgincludedir=${includedir}/libweston-@LIBWESTON_ABI_VERSION@

 Name: libweston API
 Description: Header files for libweston compositors development
 Version: @WESTON_VERSION@
 Requires.private: wayland-server pixman-1 xkbcommon
-Cflags: -I${pkgincludedir}
+Cflags: -I${includedir}
 Libs: -L${libdir} -lweston-@LIBWESTON_ABI_VERSION@




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 6/9] clients/simple-egl: use weston_check_extension over strstr

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

Signed-off-by: Emil Velikov 
---
 clients/simple-egl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index d5a2660..0214b2d 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -188,8 +188,8 @@ init_egl(struct display *display, struct window *window)
display->swap_buffers_with_damage = NULL;
extensions = eglQueryString(display->egl.dpy, EGL_EXTENSIONS);
if (extensions &&
-   strstr(extensions, "EGL_EXT_swap_buffers_with_damage") &&
-   strstr(extensions, "EGL_EXT_buffer_age"))
+   weston_check_extension(extensions, 
"EGL_EXT_swap_buffers_with_damage") &&
+   weston_check_extension(extensions, "EGL_EXT_buffer_age"))
display->swap_buffers_with_damage =
(PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)
eglGetProcAddress("eglSwapBuffersWithDamageEXT");
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/9] shared/platform.h: add missing stdbool.h include

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

Required by the bool type, used through the header.

Signed-off-by: Emil Velikov 
---
 shared/platform.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/shared/platform.h b/shared/platform.h
index dd55008..b1b9128 100644
--- a/shared/platform.h
+++ b/shared/platform.h
@@ -26,6 +26,7 @@
 #ifndef WESTON_PLATFORM_H
 #define WESTON_PLATFORM_H
 
+#include 
 #include 
 
 #ifdef ENABLE_EGL
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 8/9] gl-renderer: remove local EGL platform (re)definitions

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

Signed-off-by: Emil Velikov 
---
 libweston/gl-renderer.h | 17 -
 1 file changed, 17 deletions(-)

diff --git a/libweston/gl-renderer.h b/libweston/gl-renderer.h
index 71f6b46..ad81a64 100644
--- a/libweston/gl-renderer.h
+++ b/libweston/gl-renderer.h
@@ -45,23 +45,6 @@ typedef intptr_t EGLNativeWindowType;
 
 #endif /* ENABLE_EGL */
 
-#ifndef EGL_EXT_platform_base
-typedef EGLDisplay (*PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void 
*native_display, const EGLint *attrib_list);
-typedef EGLSurface (*PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay 
dpy, EGLConfig config, void *native_window, const EGLint *attrib_list);
-#endif
-
-#ifndef EGL_PLATFORM_GBM_KHR
-#define EGL_PLATFORM_GBM_KHR 0x31D7
-#endif
-
-#ifndef EGL_PLATFORM_WAYLAND_KHR
-#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
-#endif
-
-#ifndef EGL_PLATFORM_X11_KHR
-#define EGL_PLATFORM_X11_KHR 0x31D5
-#endif
-
 #define NO_EGL_PLATFORM 0
 
 enum gl_renderer_border_side {
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 5/9] clients/nested: use weston_check_extension over strstr

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

Signed-off-by: Emil Velikov 
---
 clients/nested.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clients/nested.c b/clients/nested.c
index 6c21aa4..9f74326 100644
--- a/clients/nested.c
+++ b/clients/nested.c
@@ -748,7 +748,7 @@ nested_init_compositor(struct nested *nested)
 
nested->egl_display = display_get_egl_display(nested->display);
extensions = eglQueryString(nested->egl_display, EGL_EXTENSIONS);
-   if (strstr(extensions, "EGL_WL_bind_wayland_display") == NULL) {
+   if (weston_check_extension(extensions, "EGL_WL_bind_wayland_display") 
== NULL) {
fprintf(stderr, "no EGL_WL_bind_wayland_display extension\n");
return -1;
}
@@ -771,7 +771,7 @@ nested_init_compositor(struct nested *nested)
const char *func = "eglCreateWaylandBufferFromImageWL";
const char *ext = "EGL_WL_create_wayland_buffer_from_image";
 
-   if (strstr(extensions, ext)) {
+   if (weston_check_extension(extensions, ext)) {
create_wayland_buffer_from_image =
(void *) eglGetProcAddress(func);
use_ss_renderer = 1;
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 3/9] gl-renderer: move check_extension() to shared/

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

... prefixing it with a "weston_". This way we can reuse it across the
board, instead of the current strstr. The latter of which can give us
false positives, thus it will be resolved with next commit(s).

Signed-off-by: Emil Velikov 
---
 libweston/gl-renderer.c | 59 ++---
 shared/config-parser.c  |  1 +
 shared/platform.h   | 28 +++
 3 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 17377d2..8588db2 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -44,6 +44,7 @@
 #include "linux-dmabuf-unstable-v1-server-protocol.h"
 
 #include "shared/helpers.h"
+#include "shared/platform.h"
 #include "weston-egl-ext.h"
 
 struct gl_shader {
@@ -2652,34 +2653,6 @@ gl_renderer_destroy(struct weston_compositor *ec)
free(gr);
 }
 
-static bool
-check_extension(const char *extensions, const char *extension)
-{
-   size_t extlen = strlen(extension);
-   const char *end = extensions + strlen(extensions);
-
-   while (extensions < end) {
-   size_t n = 0;
-
-   /* Skip whitespaces, if any */
-   if (*extensions == ' ') {
-   extensions++;
-   continue;
-   }
-
-   n = strcspn(extensions, " ");
-
-   /* Compare strings */
-   if (n == extlen && strncmp(extension, extensions, n) == 0)
-   return true; /* Found */
-
-   extensions += n;
-   }
-
-   /* Not found */
-   return false;
-}
-
 static void
 renderer_setup_egl_client_extensions(struct gl_renderer *gr)
 {
@@ -2691,7 +2664,7 @@ renderer_setup_egl_client_extensions(struct gl_renderer 
*gr)
return;
}
 
-   if (check_extension(extensions, "EGL_EXT_platform_base"))
+   if (weston_check_extension(extensions, "EGL_EXT_platform_base"))
gr->create_platform_window =
(void *) 
eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
else
@@ -2721,7 +2694,7 @@ gl_renderer_setup_egl_extensions(struct weston_compositor 
*ec)
return -1;
}
 
-   if (check_extension(extensions, "EGL_WL_bind_wayland_display"))
+   if (weston_check_extension(extensions, "EGL_WL_bind_wayland_display"))
gr->has_bind_display = 1;
if (gr->has_bind_display) {
ret = gr->bind_display(gr->egl_display, ec->wl_display);
@@ -2729,26 +2702,26 @@ gl_renderer_setup_egl_extensions(struct 
weston_compositor *ec)
gr->has_bind_display = 0;
}
 
-   if (check_extension(extensions, "EGL_EXT_buffer_age"))
+   if (weston_check_extension(extensions, "EGL_EXT_buffer_age"))
gr->has_egl_buffer_age = 1;
else
weston_log("warning: EGL_EXT_buffer_age not supported. "
   "Performance could be affected.\n");
 
-   if (check_extension(extensions, "EGL_EXT_swap_buffers_with_damage"))
+   if (weston_check_extension(extensions, 
"EGL_EXT_swap_buffers_with_damage"))
gr->swap_buffers_with_damage =
(void *) 
eglGetProcAddress("eglSwapBuffersWithDamageEXT");
else
weston_log("warning: EGL_EXT_swap_buffers_with_damage not "
   "supported. Performance could be affected.\n");
 
-   if (check_extension(extensions, "EGL_MESA_configless_context"))
+   if (weston_check_extension(extensions, "EGL_MESA_configless_context"))
gr->has_configless_context = 1;
 
-   if (check_extension(extensions, "EGL_KHR_surfaceless_context"))
+   if (weston_check_extension(extensions, "EGL_KHR_surfaceless_context"))
gr->has_surfaceless_context = 1;
 
-   if (check_extension(extensions, "EGL_EXT_image_dma_buf_import"))
+   if (weston_check_extension(extensions, "EGL_EXT_image_dma_buf_import"))
gr->has_dmabuf_import = 1;
 
renderer_setup_egl_client_extensions(gr);
@@ -2817,19 +2790,19 @@ gl_renderer_supports(struct weston_compositor *ec,
   extensions);
}
 
-   if (!check_extension(extensions, "EGL_EXT_platform_base"))
+   if (!weston_check_extension(extensions, "EGL_EXT_platform_base"))
return 0;
 
snprintf(s, sizeof s, "EGL_KHR_platform_%s", extension_suffix);
-   if (check_extension(extensions, s))
+   if (weston_check_extension(extensions, s))
return 1;
 
snprintf(s, sizeof s, "EGL_EXT_platform_%s", extension_suffix);
-   if (check_extension(extensions, s))
+   if (weston_check_extension(extensions, s))
return 1;
 
snprintf(s, sizeof s, "EGL_MESA_platform_%s", extension_suffix);
-   if 

[PATCH weston 2/7] weston-egl-ext.h: remove EGL_EGLEXT_PROTOTYPES sections

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

Those the function declarations alongside the EGL_EGLEXT_PROTOTYPES
guards. Although those are copy/paste sections from the header(s),
having and/or using them is a bad idea, as per the EGL spec.

Signed-off-by: Emil Velikov 
---
If people like them one could keep them I, but considering they are not
used (and they shouldn't be used) it's better to remove them.
---
 libweston/weston-egl-ext.h | 10 --
 1 file changed, 10 deletions(-)

diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
index 32f6108..e1754f5 100644
--- a/libweston/weston-egl-ext.h
+++ b/libweston/weston-egl-ext.h
@@ -33,10 +33,6 @@
 
 struct wl_display;
 
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLBoolean EGLAPIENTRY eglBindWaylandDisplayWL(EGLDisplay dpy, struct 
wl_display *display);
-EGLAPI EGLBoolean EGLAPIENTRY eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct 
wl_display *display);
-#endif
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, 
struct wl_display *display);
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWL) (EGLDisplay 
dpy, struct wl_display *display);
 #endif
@@ -63,18 +59,12 @@ typedef EGLBoolean (EGLAPIENTRYP 
PFNEGLUNBINDWAYLANDDISPLAYWL) (EGLDisplay dpy,
 #define EGL_TEXTURE_EXTERNAL_WL 0x31DA
 
 struct wl_resource;
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLBoolean EGLAPIENTRY eglQueryWaylandBufferWL(EGLDisplay dpy, struct 
wl_resource *buffer, EGLint attribute, EGLint *value);
-#endif
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWL) (EGLDisplay dpy, 
struct wl_resource *buffer, EGLint attribute, EGLint *value);
 #endif
 
 #ifndef EGL_WL_create_wayland_buffer_from_image
 #define EGL_WL_create_wayland_buffer_from_image 1
 
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI struct wl_buffer * EGLAPIENTRY 
eglCreateWaylandBufferFromImageWL(EGLDisplay dpy, EGLImageKHR image);
-#endif
 typedef struct wl_buffer * (EGLAPIENTRYP PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) 
(EGLDisplay dpy, EGLImageKHR image);
 #endif
 
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 0/7] EGL/GL definitions cleanup

2016-07-04 Thread Emil Velikov
It seems that a handful of extensions were missing fallback definitions 
and/or were handled sub optimally.

So this series folds most (the 
remainder coming in another series) of the typedef/defines in 
weston-egl-ext.h and cleanups all the ifdef spaghetti through the 
codebase.

-Emil

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 7/7] simple-egl: remove incomplete EGL_EXT_buffer_age definition

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

A more complete alternative is already provided by the weston-egl-ext.h
header. The latter of which we already include.

Signed-off-by: Emil Velikov 
---
 clients/simple-egl.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index 6b4f1a1..d5a2660 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -50,11 +50,6 @@
 #include "shared/platform.h"
 #include "weston-egl-ext.h"
 
-#ifndef EGL_EXT_buffer_age
-#define EGL_EXT_buffer_age 1
-#define EGL_BUFFER_AGE_EXT 0x313D
-#endif
-
 struct window;
 struct seat;
 
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/7] client/nested: reuse weston-egl-ext.h declarations

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

Rather than introducing a local copy of the
EGL_WL_create_wayland_buffer_from_image (re)definition, just use the
local header.

This also gives us access to EGL_WL_bind_wayland_display which is also
used in the client, yet the C file is missing a fall-back definition.

Signed-off-by: Emil Velikov 
---
 clients/nested.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/clients/nested.c b/clients/nested.c
index 72aab15..6c21aa4 100644
--- a/clients/nested.c
+++ b/clients/nested.c
@@ -50,15 +50,8 @@
 #include "shared/xalloc.h"
 #include "window.h"
 
-#ifndef EGL_WL_create_wayland_buffer_from_image
-#define EGL_WL_create_wayland_buffer_from_image 1
+#include "weston-egl-ext.h"
 
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI struct wl_buffer * EGLAPIENTRY 
eglCreateWaylandBufferFromImageWL(EGLDisplay dpy, EGLImageKHR image);
-#endif
-typedef struct wl_buffer * (EGLAPIENTRYP PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) 
(EGLDisplay dpy, EGLImageKHR image);
-
-#endif
 
 static int option_blit;
 
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 6/7] gl-renderer: remove EGL_EXT_image_dma_buf_import guards

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

We provide a (workaround) definition in weston-egl-ext.h, thus we don't
need any guards.

Signed-off-by: Emil Velikov 
---
 libweston/gl-renderer.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 1546453..17377d2 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -2748,10 +2748,8 @@ gl_renderer_setup_egl_extensions(struct 
weston_compositor *ec)
if (check_extension(extensions, "EGL_KHR_surfaceless_context"))
gr->has_surfaceless_context = 1;
 
-#ifdef EGL_EXT_image_dma_buf_import
if (check_extension(extensions, "EGL_EXT_image_dma_buf_import"))
gr->has_dmabuf_import = 1;
-#endif
 
renderer_setup_egl_client_extensions(gr);
 
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 3/7] weston-egl-ext.h: add EGL_EXT_swap_buffers_with_damage definitions

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

... and use it from simple-egl and gl-renderer.

Signed-off-by: Emil Velikov 
---
 clients/simple-egl.c   |  6 +-
 libweston/gl-renderer.c| 12 
 libweston/weston-egl-ext.h |  5 +
 3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index d8233c1..6b4f1a1 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -48,11 +48,7 @@
 #define IVI_SURFACE_ID 9000
 
 #include "shared/platform.h"
-
-#ifndef EGL_EXT_swap_buffers_with_damage
-#define EGL_EXT_swap_buffers_with_damage 1
-typedef EGLBoolean (EGLAPIENTRYP 
PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)(EGLDisplay dpy, EGLSurface surface, EGLint 
*rects, EGLint n_rects);
-#endif
+#include "weston-egl-ext.h"
 
 #ifndef EGL_EXT_buffer_age
 #define EGL_EXT_buffer_age 1
diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 28c0b50..bff74ef 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -183,11 +183,7 @@ struct gl_renderer {
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
PFNEGLCREATEIMAGEKHRPROC create_image;
PFNEGLDESTROYIMAGEKHRPROC destroy_image;
-
-#ifdef EGL_EXT_swap_buffers_with_damage
PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC swap_buffers_with_damage;
-#endif
-
PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC create_platform_window;
 
int has_unpack_subimage;
@@ -1085,11 +1081,9 @@ gl_renderer_repaint_output(struct weston_output *output,
struct gl_renderer *gr = get_renderer(compositor);
EGLBoolean ret;
static int errored;
-#ifdef EGL_EXT_swap_buffers_with_damage
int i, nrects, buffer_height;
EGLint *egl_damage, *d;
pixman_box32_t *rects;
-#endif
pixman_region32_t buffer_damage, total_damage;
enum gl_border_status border_damage = BORDER_STATUS_CLEAN;
 
@@ -1144,7 +1138,6 @@ gl_renderer_repaint_output(struct weston_output *output,
pixman_region32_copy(>previous_damage, output_damage);
wl_signal_emit(>frame_signal, output);
 
-#ifdef EGL_EXT_swap_buffers_with_damage
if (gr->swap_buffers_with_damage) {
pixman_region32_init(_damage);
weston_transformed_region(output->width, output->height,
@@ -1182,9 +1175,6 @@ gl_renderer_repaint_output(struct weston_output *output,
} else {
ret = eglSwapBuffers(gr->egl_display, go->egl_surface);
}
-#else /* ! defined EGL_EXT_swap_buffers_with_damage */
-   ret = eglSwapBuffers(gr->egl_display, go->egl_surface);
-#endif
 
if (ret == EGL_FALSE && !errored) {
errored = 1;
@@ -2752,14 +2742,12 @@ gl_renderer_setup_egl_extensions(struct 
weston_compositor *ec)
weston_log("warning: EGL_EXT_buffer_age not supported. "
   "Performance could be affected.\n");
 
-#ifdef EGL_EXT_swap_buffers_with_damage
if (check_extension(extensions, "EGL_EXT_swap_buffers_with_damage"))
gr->swap_buffers_with_damage =
(void *) 
eglGetProcAddress("eglSwapBuffersWithDamageEXT");
else
weston_log("warning: EGL_EXT_swap_buffers_with_damage not "
   "supported. Performance could be affected.\n");
-#endif
 
 #ifdef EGL_MESA_configless_context
if (check_extension(extensions, "EGL_MESA_configless_context"))
diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
index e1754f5..7f69ecb 100644
--- a/libweston/weston-egl-ext.h
+++ b/libweston/weston-egl-ext.h
@@ -106,5 +106,10 @@ typedef struct wl_buffer * (EGLAPIENTRYP 
PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) (
 #define EGL_DMA_BUF_PLANE2_PITCH_EXT   0x327A
 #endif
 
+#ifndef EGL_EXT_swap_buffers_with_damage
+#define EGL_EXT_swap_buffers_with_damage 1
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) 
(EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
+#endif /* EGL_EXT_swap_buffers_with_damage */
+
 
 #endif
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 4/7] weston-egl-ext.h: add EGL_MESA_configless_context definitions

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

... and use it in gl-renderer.

Signed-off-by: Emil Velikov 
---
 libweston/gl-renderer.c| 4 
 libweston/weston-egl-ext.h | 5 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index bff74ef..64ef628 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -2749,10 +2749,8 @@ gl_renderer_setup_egl_extensions(struct 
weston_compositor *ec)
weston_log("warning: EGL_EXT_swap_buffers_with_damage not "
   "supported. Performance could be affected.\n");
 
-#ifdef EGL_MESA_configless_context
if (check_extension(extensions, "EGL_MESA_configless_context"))
gr->has_configless_context = 1;
-#endif
 
if (check_extension(extensions, "EGL_KHR_surfaceless_context"))
gr->has_surfaceless_context = 1;
@@ -3114,10 +3112,8 @@ gl_renderer_setup(struct weston_compositor *ec, 
EGLSurface egl_surface)
 
context_config = gr->egl_config;
 
-#ifdef EGL_MESA_configless_context
if (gr->has_configless_context)
context_config = EGL_NO_CONFIG_MESA;
-#endif
 
gr->egl_context = eglCreateContext(gr->egl_display, context_config,
   EGL_NO_CONTEXT, context_attribs);
diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
index 7f69ecb..d79356b 100644
--- a/libweston/weston-egl-ext.h
+++ b/libweston/weston-egl-ext.h
@@ -111,5 +111,10 @@ typedef struct wl_buffer * (EGLAPIENTRYP 
PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) (
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) 
(EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects);
 #endif /* EGL_EXT_swap_buffers_with_damage */
 
+#ifndef EGL_MESA_configless_context
+#define EGL_MESA_configless_context 1
+#define EGL_NO_CONFIG_MESA  ((EGLConfig)0)
+#endif
+
 
 #endif
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 5/7] weston-egl-ext.h: add GL_EXT_unpack_subimage definitions

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

... and use it in gl-renderer.

Signed-off-by: Emil Velikov 
---
 libweston/gl-renderer.c| 9 -
 libweston/weston-egl-ext.h | 7 +++
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 64ef628..1546453 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -869,11 +869,9 @@ draw_output_border_texture(struct gl_output_state *go,
}
 
if (go->border_status & (1 << side)) {
-#ifdef GL_EXT_unpack_subimage
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, 0);
-#endif
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
 img->tex_width, img->height, 0,
 GL_BGRA_EXT, GL_UNSIGNED_BYTE, img->data);
@@ -1226,12 +1224,9 @@ gl_renderer_flush_damage(struct weston_surface *surface)
struct weston_buffer *buffer = gs->buffer_ref.buffer;
struct weston_view *view;
bool texture_used;
-
-#ifdef GL_EXT_unpack_subimage
pixman_box32_t *rectangles;
void *data;
int i, n;
-#endif
 
pixman_region32_union(>texture_damage,
  >texture_damage, >damage);
@@ -1271,7 +1266,6 @@ gl_renderer_flush_damage(struct weston_surface *surface)
goto done;
}
 
-#ifdef GL_EXT_unpack_subimage
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, gs->pitch);
data = wl_shm_buffer_get_data(buffer->shm_buffer);
 
@@ -1300,7 +1294,6 @@ gl_renderer_flush_damage(struct weston_surface *surface)
gs->gl_format, gs->gl_pixel_type, data);
}
wl_shm_buffer_end_access(buffer->shm_buffer);
-#endif
 
 done:
pixman_region32_fini(>texture_damage);
@@ -3152,10 +3145,8 @@ gl_renderer_setup(struct weston_compositor *ec, 
EGLSurface egl_surface)
else
ec->read_format = PIXMAN_a8b8g8r8;
 
-#ifdef GL_EXT_unpack_subimage
if (check_extension(extensions, "GL_EXT_unpack_subimage"))
gr->has_unpack_subimage = 1;
-#endif
 
if (check_extension(extensions, "GL_OES_EGL_image_external"))
gr->has_egl_image_external = 1;
diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
index d79356b..c0dbe32 100644
--- a/libweston/weston-egl-ext.h
+++ b/libweston/weston-egl-ext.h
@@ -80,6 +80,13 @@ typedef struct wl_buffer * (EGLAPIENTRYP 
PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) (
 #define EGL_WAYLAND_Y_INVERTED_WL  0x31DB /* 
eglQueryWaylandBufferWL attribute */
 #endif
 
+#ifndef GL_EXT_unpack_subimage
+#define GL_EXT_unpack_subimage 1
+#define GL_UNPACK_ROW_LENGTH_EXT  0x0CF2
+#define GL_UNPACK_SKIP_ROWS_EXT   0x0CF3
+#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4
+#endif /* GL_EXT_unpack_subimage */
+
 /* Mesas gl2ext.h and probably Khronos upstream defined
  * GL_EXT_unpack_subimage with non _EXT suffixed GL_UNPACK_* tokens.
  * In case we're using that mess, manually define the _EXT versions
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 6/6] libweston: do not use weston version in libweston.pc

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

Signed-off-by: Emil Velikov 
---
 configure.ac  | 1 +
 libweston/libweston.pc.in | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index be40f10..46b61ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,6 +21,7 @@ AC_SUBST([WESTON_VERSION_MINOR], [weston_minor_version])
 AC_SUBST([WESTON_VERSION_MICRO], [weston_micro_version])
 AC_SUBST([WESTON_VERSION], [weston_version])
 AC_SUBST([LIBWESTON_MAJOR], [libweston_major_version])
+AC_SUBST([LIBWESTON_VERSION], 
[libweston_major_version.libweston_minor_version.libweston_patch_version])
 m4_define([lt_current], [libweston_minor_version])
 m4_define([lt_revision], [libweston_patch_version])
 m4_define([lt_age], [libweston_minor_version])
diff --git a/libweston/libweston.pc.in b/libweston/libweston.pc.in
index bb95af9..41ea8d7 100644
--- a/libweston/libweston.pc.in
+++ b/libweston/libweston.pc.in
@@ -5,7 +5,7 @@ includedir=@includedir@
 
 Name: libweston API
 Description: Header files for libweston compositors development
-Version: @WESTON_VERSION@
+Version: @LIBWESTON_VERSION@
 Requires.private: wayland-server pixman-1 xkbcommon
 Cflags: -I${includedir}
 Libs: -L${libdir} -lweston-@LIBWESTON_ABI_VERSION@
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/6] README: clarify libweston purpose/goals.

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

v2: Rewrap, add a couple of missing words (Pekka).
v3: Use alternative wording (Yong).

Signed-off-by: Emil Velikov 
---
 README | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/README b/README
index 789755d..1265ad1 100644
--- a/README
+++ b/README
@@ -73,17 +73,17 @@ http://ometer.com/parallel.html
 Libweston design goals
 --
 
-The high-level goal of libweston is that what used to be shell plugins
-will be main executables. Instead of launching 'weston' with various
-arguments to choose the shell, one would be launching
-'weston-desktop', 'weston-ivi', 'orbital', etc. The main executable
-(the hosting program) links to libweston for a fundamental compositor
-implementation. Libweston is also intended for use by other projects
-who want to create new "Wayland WMs".
-
-The libweston API/ABI will be separating the shell logic and main
-program from the rest of the "Weston compositor" (libweston
-internals).
+The high-level goal of libweston is to decouple the compositor from
+the shell implementation (what used to be shell plugins).
+
+Thus, instead of launching 'weston' with various arguments to choose the
+shell, one would launch the shell itself, eg. 'weston-desktop',
+'weston-ivi', 'orbital',etc. The main executable (the hosting program)
+will implement the shell, while libweston will be used for a fundamental
+compositor implementation.
+
+Libweston is also intended for use by other project developers who want
+to create new "Wayland WMs".
 
 Details:
 
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 4/6] libweston: use new versioning scheme

2016-07-04 Thread Emil Velikov
Use the documented libweston-$major.so.0.$minor.$patch scheme.

An (almost) identical one is used by GLIB, GTK{2,3}, QT5, json-glib and
others.

v2:
 - Use shorter variable names LIBWESTON_{MAJOR,MINOR...}
 - Correctly use -version-info.
 - Drop unneeded @LIBWESTON_VERSION_MAJOR@ additions.

Signed-off-by: Emil Velikov 
---

XXX:
 - Should we rename libweston{,-0}.pc.in ?
 - Drop the s/LIBWESTON_ABI_VERSION/LIBWESTON_MAJOR/ hunk ?
 - Keep the configure libweston_*_version variables shorter ?
 - Yes, the LT_VERSION_INFO hunk looks a bit nasty, yet this is what GTK
is doing, once you unraver the 2-3 layers of variables. It works as
expected though, and I'd imagine others are doing a similar trick.

fixup! libweston: use new versioning scheme
---
 Makefile.am | 24 
 compositor/weston.pc.in |  2 +-
 configure.ac| 12 +---
 3 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index b050c60..1c3d553 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ noinst_PROGRAMS =
 libexec_PROGRAMS =
 moduledir = $(libdir)/weston
 module_LTLIBRARIES =
-libweston_moduledir = $(libdir)/libweston-${LIBWESTON_ABI_VERSION}
+libweston_moduledir = $(libdir)/libweston-$(LIBWESTON_MAJOR)
 libweston_module_LTLIBRARIES =
 noinst_LTLIBRARIES =
 BUILT_SOURCES =
@@ -61,15 +61,15 @@ CLEANFILES = weston.ini \
internal-screenshot-00.png  \
$(BUILT_SOURCES)
 
-lib_LTLIBRARIES = libweston.la
-libweston_la_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
-libweston_la_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS)
-libweston_la_LIBADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
+lib_LTLIBRARIES = libweston-@LIBWESTON_MAJOR@.la
+libweston_@LIBWESTON_MAJOR@_la_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
+libweston_@LIBWESTON_MAJOR@_la_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS) 
$(LIBUNWIND_CFLAGS)
+libweston_@LIBWESTON_MAJOR@_la_LIBADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
$(DLOPEN_LIBS) -lm $(CLOCK_GETTIME_LIBS) \
$(LIBINPUT_BACKEND_LIBS) libshared.la
-libweston_la_LDFLAGS = -release ${LIBWESTON_ABI_VERSION}
+libweston_@LIBWESTON_MAJOR@_la_LDFLAGS = -version-info $(LT_VERSION_INFO)
 
-libweston_la_SOURCES = \
+libweston_@LIBWESTON_MAJOR@la_SOURCES =\
libweston/git-version.h \
libweston/log.c \
libweston/compositor.c  \
@@ -121,7 +121,7 @@ systemd_notify_la_SOURCES = \
libweston/compositor.h
 endif
 
-nodist_libweston_la_SOURCES =  \
+nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES =
\
protocol/weston-screenshooter-protocol.c\
protocol/weston-screenshooter-server-protocol.h \
protocol/text-cursor-position-protocol.c\
@@ -137,7 +137,7 @@ nodist_libweston_la_SOURCES =   
\
protocol/linux-dmabuf-unstable-v1-protocol.c\
protocol/linux-dmabuf-unstable-v1-server-protocol.h
 
-BUILT_SOURCES += $(nodist_libweston_la_SOURCES)
+BUILT_SOURCES += $(nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES)
 
 bin_PROGRAMS += weston
 
@@ -148,7 +148,7 @@ weston_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
\
 weston_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS)
 weston_LDADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
$(DLOPEN_LIBS) $(LIBINPUT_BACKEND_LIBS) \
-   -lm libshared.la libweston.la
+   -lm libshared.la libweston-@LIBWESTON_MAJOR@.la
 
 weston_SOURCES =   \
compositor/main.c   \
@@ -225,12 +225,12 @@ endif
 endif # BUILD_WESTON_LAUNCH
 
 pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = compositor/weston.pc 
libweston/libweston-${LIBWESTON_ABI_VERSION}.pc
+pkgconfig_DATA = compositor/weston.pc libweston/libweston-${LIBWESTON_MAJOR}.pc
 
 wayland_sessiondir = $(datadir)/wayland-sessions
 dist_wayland_session_DATA = compositor/weston.desktop
 
-libwestonincludedir = $(includedir)/libweston-${LIBWESTON_ABI_VERSION}
+libwestonincludedir = $(includedir)/libweston-${LIBWESTON_MAJOR}
 libwestoninclude_HEADERS = \
libweston/version.h \
libweston/compositor.h  \
diff --git a/compositor/weston.pc.in b/compositor/weston.pc.in
index 09e8580..6890a77 100644
--- a/compositor/weston.pc.in
+++ b/compositor/weston.pc.in
@@ -8,5 +8,5 @@ pkglibexecdir=${libexecdir}/@PACKAGE@
 Name: Weston Plugin API
 Description: Header files for Weston plugin development
 Version: @WESTON_VERSION@
-Requires.private: libweston-@LIBWESTON_ABI_VERSION@
+Requires.private: libweston-@LIBWESTON_MAJOR@
 Cflags: -I${includedir}/weston
diff --git 

[PATCH weston 2/6] README: minor the libweston ABI/API documentation

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

v2: Elaborate what is meant with "major ABI versions" (Pekka).

Signed-off-by: Emil Velikov 
Reviewed-by: Pekka Paalanen  (v1)
---
 README | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/README b/README
index 1265ad1..126df4d 100644
--- a/README
+++ b/README
@@ -41,25 +41,25 @@ continue evolving through many Weston releases before it 
achieves a
 stable API and feature completeness.
 
 
-API (in)stability and parallel installability
--
+API/ABI (in)stability and parallel installability
+-
 
 As libweston's API surface is huge, it is impossible to get it right
-in one go. Therefore developers reserve the right to break the API
+in one go. Therefore developers reserve the right to break the API/ABI
 between every 1.x.0 Weston release (minor version bumps), just like
 Weston's plugin API does. For git snapshots of the master branch, the
-API can break any time without warning or version bump.
+API/ABI can break any time without warning or version bump.
 
 Libweston API or ABI will not be broken between Weston's stable
 releases 1.x.0 and 1.x.y, where y < 90.
 
-To make things tolerable for libweston users despite ABI breakages,
+To make things tolerable for libweston users despite API/ABI breakages,
 libweston is designed to be perfectly parallel-installable. An
-ABI-version is defined for libweston, and it is bumped for releases as
-needed. Different ABI-versions of libweston can be installed in
-parallel, so that external projects can easily depend on a particular
-ABI-version, and they do not have to fight over which ABI-version is
-installed in a user's system. This allows a user to install many
+API/ABI-version is defined for libweston, and it is bumped for releases as
+needed. Different non-backward compatible ABI versions of libweston can be
+installed in parallel, so that external projects can easily depend on a
+particular ABI-version. Thus they do not have to fight over which ABI-version
+is installed in a user's system. This allows a user to install many
 different compositors each requiring a different libweston ABI-version
 without tricks or conflicts.
 
@@ -161,8 +161,9 @@ would be roughly like this:
 
 - and possibly more...
 
-Everything should be parallel-installable across libweston
-ABI-versions, except those explicitly mentioned.
+Everything should be parallel-installable across libweston major
+ABI-versions (libweston-1.so, libweston-2.so, etc.), except those
+explicitly mentioned.
 
 Weston's build may not sanely allow this yet, but this is the
 intention.
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 5/6] libweston: do not add libweston-$version to the Cflags

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

When managing headers there's normally two ways to handle them
- with or without the subfolder.

Opting for the latter case here, since it will provide direct feedback,
whether one is using libweston-0 or any other version.

Which in turn should deter (help prevent) issues like building/linking
against multiple versions of libweston.

Signed-off-by: Emil Velikov 
---
 libweston/libweston.pc.in | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libweston/libweston.pc.in b/libweston/libweston.pc.in
index 24fe813..bb95af9 100644
--- a/libweston/libweston.pc.in
+++ b/libweston/libweston.pc.in
@@ -2,11 +2,10 @@ prefix=@prefix@
 exec_prefix=@exec_prefix@
 libdir=@libdir@
 includedir=@includedir@
-pkgincludedir=${includedir}/libweston-@LIBWESTON_ABI_VERSION@
 
 Name: libweston API
 Description: Header files for libweston compositors development
 Version: @WESTON_VERSION@
 Requires.private: wayland-server pixman-1 xkbcommon
-Cflags: -I${pkgincludedir}
+Cflags: -I${includedir}
 Libs: -L${libdir} -lweston-@LIBWESTON_ABI_VERSION@
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 0/6] Rework libweston versioning, take 2(?)

2016-07-04 Thread Emil Velikov
Hi all,

Here is a respin of the earlier series which changes how libweston is 
named, and thus shipped. I believe all the logic/reasoning is explicitly 
stated, although if something feels amiss, please let me know.

NOTE: WARNING: The series exposes a fatal bug in weston thus the tests 
fail to build (let alone run).
Namely: atm some/many of the modules are built with unresolved symbols. 
Is that a bug or by design ? From a quick look it seems to be the 
latter.

If anyone is interested in resolving this please grep through mesa for 
"no-undefined" - it handles both -no-undefined and -Wl,--no-undefined in 
a portable manner.


Thanks
Emil

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 3/6] README: Document versioning scheme, forward compatibility

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

Signed-off-by: Emil Velikov 
---
Pekka,

There's a couple of things to 'break' - forward and backward
compatibility.

Latter implies changing (removing) certain existing API, while the
former is used in reference to functionality introduced with minor
bumps.

Since people don't always know when the new API is introduced, let alone
bump the version accordingly in configure (and thus package runtime
dependency), things end up badly.

In some subtle cases (the autogenerated headers in wayland) not only is
the new API available, but you end up using it without knowing. And yes,
I fully agree that approach used in wayland is good, but it can cause
subtle breakage.

If weston devs don't want this approach (i.e. adding the ifdef guards
prove too annoying and/or other), then one can just stick with only with
MAJOR. Then the number will ramp quite fast and user will have no way
of knowing/detecting bugfix (patch versions).

From my experience, using the LIBWESTON_API_VERSION alike macros does
not get in the way of development. Yet it's up-to you guys to make the
call.

-Emil
---
 README | 46 ++
 1 file changed, 46 insertions(+)

diff --git a/README b/README
index 126df4d..72e8c7c 100644
--- a/README
+++ b/README
@@ -70,6 +70,52 @@ For more information about parallel installability, see
 http://ometer.com/parallel.html
 
 
+Versioning scheme
+-
+
+In order to provide consistent, easy to use versioning, libweston
+follows the rules in the Apache Portable Runtime Project
+http://apr.apache.org/versioning.html.
+
+The document provides the full details, with the gist summed below:
+ - Major - backward incompatible changes.
+ - Minor - new backward compatible features.
+ - Patch - internal (implementation specific) fixes.
+
+
+Forward compatibility
+-
+
+In order to ensure prevent subtle breaks with a simple recompile
+(against a newer version), features introduced with minor versions are
+guarded with a LIBWESTON_API_VERSION guard.
+
+For example:
+Libweston v1.1.0 introduces a new entry point weston_ham_sandwich().
+As such it will be annotated as below in the relevant header(s).
+
+#if LIBWESTON_API_VERSION >= 0x0101
+
+bool
+weston_ham_sandwich(void);
+
+#endif
+
+As the user requires the said symbol, they must explicitly set the
+LIBWESTON_API_VERSION macro. By doing so they explicitly state "yes I
+want to use the said version of the library", at which point they should
+also bump the version check in their configure (or equivalent) script.
+
+The LIBWESTON_API_VERSION is of the format 0x$MAJOR$MINOR and does not
+include PATCH version. As mentioned in the Versioning scheme section,
+PATCH does not reflect any user visible API changes, thus should be not
+considered part of the API VERSION.
+
+Similar approach is used by ATK, QT and KDE programs/libraries,
+libjpeg-turbo, GTK, NetworkManager (in a more complex/compherensive
+manner), js17, lz4 and many others.
+
+
 Libweston design goals
 --
 
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 1/3] weston: Add a specific option to load XWayland

2016-07-04 Thread Michael Schellenberger Costa
Hi Quentin,

Am 04.07.2016 um 15:58 schrieb Quentin Glidic:
> From: Quentin Glidic 
> 
> Signed-off-by: Quentin Glidic 
> ---
>  compositor/main.c  | 25 +++--
>  man/weston.ini.man |  7 +--
>  man/weston.man |  7 +--
>  tests/weston-tests-env |  7 ---
>  weston.ini.in  |  3 ++-
>  5 files changed, 31 insertions(+), 18 deletions(-)
> 
> diff --git a/compositor/main.c b/compositor/main.c
> index 6cf9194..4e6b7ae 100644
> --- a/compositor/main.c
> +++ b/compositor/main.c
> @@ -763,16 +763,11 @@ load_modules(struct weston_compositor *ec, const char 
> *modules,
>   end = strchrnul(p, ',');
>   snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);
>  
> - if (strstr(buffer, "xwayland.so")) {
> - if (wet_load_xwayland(ec) < 0)
> - return -1;
> - } else {
> - module_init = wet_load_module(buffer, "module_init");
> - if (!module_init)
> - return -1;
> - if (module_init(ec, argc, argv) < 0)
> - return -1;
> - }
> + module_init = wet_load_module(buffer, "module_init");
> + if (!module_init)
> + return -1;
> + if (module_init(ec, argc, argv) < 0)
> + return -1;
>   p = end;
>   while (*p == ',')
>   p++;
> @@ -1564,6 +1559,7 @@ int main(int argc, char *argv[])
>   int i, fd;
>   char *backend = NULL;
>   char *shell = NULL;
> + int32_t xwayland = 0;
>   char *modules = NULL;
>   char *option_modules = NULL;
>   char *log = NULL;
> @@ -1586,6 +1582,7 @@ int main(int argc, char *argv[])
>   { WESTON_OPTION_STRING, "shell", 0,  },
>   { WESTON_OPTION_STRING, "socket", 'S', _name },
>   { WESTON_OPTION_INTEGER, "idle-time", 'i', _time },
> + { WESTON_OPTION_BOOLEAN, "xwayland", 0,  },
>   { WESTON_OPTION_STRING, "modules", 0, _modules },
>   { WESTON_OPTION_STRING, "log", 0,  },
>   { WESTON_OPTION_BOOLEAN, "help", 'h',  },
> @@ -1709,6 +1706,14 @@ int main(int argc, char *argv[])
>   weston_config_section_get_string(section, "shell", ,
>"desktop-shell.so");
>  
> + if (!xwayland)
> + weston_config_section_get_bool(section, "xwayland", ,
> +false);
> + if (xwayland) {
Can you make that the else clause?
--Michael

> + if (wet_load_xwayland(ec) < 0)
> + goto out;
> + }
> +
>   if (load_modules(ec, shell, , argv) < 0)
>   goto out;
>  
> diff --git a/man/weston.ini.man b/man/weston.ini.man
> index 7aa7810..1b1e05a 100644
> --- a/man/weston.ini.man
> +++ b/man/weston.ini.man
> @@ -106,14 +106,17 @@ directory are:
>  .fi
>  .RE
>  .TP 7
> -.BI "modules=" xwayland.so,cms-colord.so
> +.BI "xwayland=" true
> +ask Weston to load the XWayland module (boolean).
> +.RE
> +.TP 7
> +.BI "modules=" cms-colord.so,screen-share.so
>  specifies the modules to load (string). Available modules in the
>  .IR "__weston_modules_dir__"
>  directory are:
>  .PP
>  .RS 10
>  .nf
> -.BR xwayland.so
>  .BR cms-colord.so
>  .BR screen-share.so
>  .fi
> diff --git a/man/weston.man b/man/weston.man
> index 0c3e8dc..face229 100644
> --- a/man/weston.man
> +++ b/man/weston.man
> @@ -83,7 +83,7 @@ the X server. XWayland provides backwards compatibility to 
> X applications in a
>  Wayland stack.
>  
>  XWayland is activated by instructing
> -.BR weston " to load " xwayland.so " module, see " EXAMPLES .
> +.BR weston " to load the XWayland module, see " EXAMPLES .
>  Weston starts listening on a new X display socket, and exports it in the
>  environment variable
>  .BR DISPLAY .
> @@ -143,6 +143,9 @@ Append log messages to the file
>  .I file.log
>  instead of writing them to stderr.
>  .TP
> +\fB\-\-xwayland\fR
> +Ask Weston to load the XWayland module.
> +.TP
>  \fB\-\-modules\fR=\fImodule1.so,module2.so\fR
>  Load the comma-separated list of modules. Only used by the test
>  suite. The file is searched for in
> @@ -326,7 +329,7 @@ http://wayland.freedesktop.org/
>  .IP "Launch Weston with the DRM backend on a VT"
>  weston-launch
>  .IP "Launch Weston with the DRM backend and XWayland support"
> -weston-launch -- --modules=xwayland.so
> +weston-launch -- --xwayland
>  .IP "Launch Weston (wayland-1) nested in another Weston instance (wayland-0)"
>  WAYLAND_DISPLAY=wayland-0 weston -Swayland-1
>  .IP "From an X terminal, launch Weston with the x11 backend"
> diff --git a/tests/weston-tests-env b/tests/weston-tests-env
> index 8a6447e..4159809 100755
> --- a/tests/weston-tests-env
> +++ b/tests/weston-tests-env
> @@ 

Re: [PATCH weston 1/3] weston: Add a specific option to load XWayland

2016-07-04 Thread Quentin Glidic

On 04/07/2016 16:02, Michael Schellenberger Costa wrote:

Hi Quentin,

Am 04.07.2016 um 15:58 schrieb Quentin Glidic:

From: Quentin Glidic 

Signed-off-by: Quentin Glidic 
---
 compositor/main.c  | 25 +++--
 man/weston.ini.man |  7 +--
 man/weston.man |  7 +--
 tests/weston-tests-env |  7 ---
 weston.ini.in  |  3 ++-
 5 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 6cf9194..4e6b7ae 100644
--- a/compositor/main.c
+++ b/compositor/main.c
[snip]
+   if (!xwayland)
+   weston_config_section_get_bool(section, "xwayland", ,
+  false);
+   if (xwayland) {

Can you make that the else clause?


No, this pattern is there so we get the config file value as fallback.



--Michael


[snip]



--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] gl-renderer: Silence silly warning

2016-07-04 Thread Quentin Glidic
From: Quentin Glidic 

Signed-off-by: Quentin Glidic 
---
 libweston/gl-renderer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 28c0b50..73b6ccc 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -455,7 +455,7 @@ static int
 compress_bands(pixman_box32_t *inrects, int nrects,
   pixman_box32_t **outrects)
 {
-   bool merged;
+   bool merged = false;
pixman_box32_t *out, merge_rect;
int i, j, nout;
 
-- 
2.9.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 0/3] libweston common modules

2016-07-04 Thread Quentin Glidic
From: Quentin Glidic 

A little series to allow compositors to share modules which only rely on
libweston.

Patch 1 is standalone, and it makes it more obvious that patch 3 is just
copying a function around.

Patch 2 is mostly renames. It looks big but it’s quite straightforward.

Patch 3 is the real deal. Both libweston and weston implementations.

Quentin Glidic (3):
  weston: Add a specific option to load XWayland
  modules: Drop module_init as a shared init function
  libweston: Add a generic weston_compositor_load_module

 Makefile.am |   3 +-
 compositor/cms-colord.c |   5 +-
 compositor/cms-static.c |   4 +-
 compositor/main.c   | 100 +++-
 compositor/screen-share.c   |   4 +-
 compositor/weston.h |  13 -
 desktop-shell/shell.c   |   4 +-
 fullscreen-shell/fullscreen-shell.c |   5 +-
 ivi-shell/ivi-layout.c  |   4 +-
 ivi-shell/ivi-shell.c   |   4 +-
 libweston/compositor-drm.c  |   4 +-
 libweston/compositor-fbdev.c|   4 +-
 libweston/compositor-headless.c |   4 +-
 libweston/compositor-rdp.c  |   4 +-
 libweston/compositor-wayland.c  |   4 +-
 libweston/compositor-x11.c  |   4 +-
 libweston/compositor.c  |  32 
 libweston/compositor.h  |  11 ++--
 man/weston.ini.man  |  15 --
 man/weston.man  |  13 -
 tests/plugin-registry-test.c|   4 +-
 tests/surface-global-test.c |   4 +-
 tests/surface-screenshot.c  |   5 +-
 tests/surface-test.c|   4 +-
 tests/weston-test.c |   4 +-
 tests/weston-tests-env  |   7 +--
 weston.ini.in   |   3 +-
 xwayland/launcher.c |   3 +-
 28 files changed, 203 insertions(+), 72 deletions(-)

-- 
2.9.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 2/3] modules: Drop module_init as a shared init function

2016-07-04 Thread Quentin Glidic
From: Quentin Glidic 

Use different functions so we cannot load a libweston module in weston
or the other way around.

Also properly namespace backend_init and use a different name for weston
shells.

Signed-off-by: Quentin Glidic 
---
 compositor/cms-colord.c |  5 +++--
 compositor/cms-static.c |  4 ++--
 compositor/main.c   | 45 ++---
 compositor/screen-share.c   |  4 ++--
 compositor/weston.h | 13 ++-
 desktop-shell/shell.c   |  4 ++--
 fullscreen-shell/fullscreen-shell.c |  5 +++--
 ivi-shell/ivi-layout.c  |  4 +++-
 ivi-shell/ivi-shell.c   |  4 ++--
 libweston/compositor-drm.c  |  4 ++--
 libweston/compositor-fbdev.c|  4 ++--
 libweston/compositor-headless.c |  4 ++--
 libweston/compositor-rdp.c  |  4 ++--
 libweston/compositor-wayland.c  |  4 ++--
 libweston/compositor-x11.c  |  4 ++--
 libweston/compositor.c  | 23 ---
 libweston/compositor.h  |  7 +++---
 tests/plugin-registry-test.c|  4 +++-
 tests/surface-global-test.c |  4 +++-
 tests/surface-screenshot.c  |  5 +++--
 tests/surface-test.c|  4 +++-
 tests/weston-test.c |  4 ++--
 xwayland/launcher.c |  3 +--
 23 files changed, 111 insertions(+), 55 deletions(-)

diff --git a/compositor/cms-colord.c b/compositor/cms-colord.c
index b9bc9e3..b9938b9 100644
--- a/compositor/cms-colord.c
+++ b/compositor/cms-colord.c
@@ -33,6 +33,7 @@
 #include 
 
 #include "compositor.h"
+#include "weston.h"
 #include "cms-helper.h"
 #include "shared/helpers.h"
 
@@ -494,8 +495,8 @@ colord_cms_output_destroy(gpointer data)
 }
 
 WL_EXPORT int
-module_init(struct weston_compositor *ec,
-   int *argc, char *argv[])
+wet_module_init(struct weston_compositor *ec,
+   int *argc, char *argv[])
 {
gboolean ret;
GError *error = NULL;
diff --git a/compositor/cms-static.c b/compositor/cms-static.c
index a6bbfd4..e24501b 100644
--- a/compositor/cms-static.c
+++ b/compositor/cms-static.c
@@ -91,8 +91,8 @@ cms_notifier_destroy(struct wl_listener *listener, void *data)
 
 
 WL_EXPORT int
-module_init(struct weston_compositor *ec,
-   int *argc, char *argv[])
+wet_module_init(struct weston_compositor *ec,
+   int *argc, char *argv[])
 {
struct cms_static *cms;
struct weston_output *output;
diff --git a/compositor/main.c b/compositor/main.c
index 4e6b7ae..88f7911 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -704,7 +704,7 @@ weston_create_listening_socket(struct wl_display *display, 
const char *socket_na
 }
 
 WL_EXPORT void *
-wet_load_module(const char *name, const char *entrypoint)
+wet_load_module_entrypoint(const char *name, const char *entrypoint)
 {
const char *builddir = getenv("WESTON_BUILD_DIR");
char path[PATH_MAX];
@@ -746,14 +746,46 @@ wet_load_module(const char *name, const char *entrypoint)
return init;
 }
 
+static int
+wet_load_shell(struct weston_compositor *compositor,
+  const char *name, int *argc, char *argv[])
+{
+   int (*shell_init)(struct weston_compositor *ec,
+ int *argc, char *argv[]);
+
+   shell_init = wet_load_module_entrypoint(name, "wet_shell_init");
+   if (!shell_init)
+   shell_init = wet_load_module_entrypoint(name, "module_init");
+   if (!shell_init)
+   return -1;
+   if (shell_init(compositor, argc, argv) < 0)
+   return -1;
+   return 0;
+}
+
+WL_EXPORT int
+wet_load_module(struct weston_compositor *compositor,
+   const char *name, int *argc, char *argv[])
+{
+   int (*module_init)(struct weston_compositor *ec,
+  int *argc, char *argv[]);
+
+   module_init = wet_load_module_entrypoint(name, "wet_module_init");
+   if (!module_init)
+   module_init = wet_load_module_entrypoint(name, "module_init");
+   if (!module_init)
+   return -1;
+   if (module_init(compositor, argc, argv) < 0)
+   return -1;
+   return 0;
+}
+
 static int
 load_modules(struct weston_compositor *ec, const char *modules,
 int *argc, char *argv[])
 {
const char *p, *end;
char buffer[256];
-   int (*module_init)(struct weston_compositor *ec,
-  int *argc, char *argv[]);
 
if (modules == NULL)
return 0;
@@ -763,10 +795,7 @@ load_modules(struct weston_compositor *ec, const char 
*modules,
end = strchrnul(p, ',');
snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);
 
-   module_init = wet_load_module(buffer, "module_init");
-   if (!module_init)
-   return -1;
-

[PATCH weston 3/3] libweston: Add a generic weston_compositor_load_module

2016-07-04 Thread Quentin Glidic
From: Quentin Glidic 

This way, we can share modules between libweston-based compositors, but
they can only be loaded explicitely by the compositor.

Signed-off-by: Quentin Glidic 
---
 Makefile.am|  3 ++-
 compositor/main.c  | 38 ++
 libweston/compositor.c | 13 ++---
 libweston/compositor.h |  4 
 man/weston.ini.man |  8 +++-
 man/weston.man |  6 ++
 6 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 436bb1b..d99437a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1414,7 +1414,8 @@ endif
 
 MAN_SUBSTS =   \
-e 's|__weston_native_backend__|$(WESTON_NATIVE_BACKEND)|g' \
-   -e 's|__weston_modules_dir__|$(pkglibdir)|g'\
+   -e 's|__libweston_modules_dir__|$(libweston_moduledir)|g'   \
+   -e 's|__weston_modules_dir__|$(moduledir)|g'\
-e 's|__weston_shell_client__|$(WESTON_SHELL_CLIENT)|g' \
-e 's|__version__|$(PACKAGE_VERSION)|g'
 
diff --git a/compositor/main.c b/compositor/main.c
index 88f7911..ea89e47 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -780,6 +780,33 @@ wet_load_module(struct weston_compositor *compositor,
return 0;
 }
 
+static int
+load_cmodules(struct weston_compositor *ec, const char *modules,
+int *argc, char *argv[])
+{
+   const char *p, *end;
+   char buffer[256];
+
+   if (modules == NULL)
+   return 0;
+
+   p = modules;
+   while (*p) {
+   end = strchrnul(p, ',');
+   snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);
+
+   if (weston_compositor_load_module(ec, buffer) < 0)
+   return -1;
+
+   p = end;
+   while (*p == ',')
+   p++;
+
+   }
+
+   return 0;
+}
+
 static int
 load_modules(struct weston_compositor *ec, const char *modules,
 int *argc, char *argv[])
@@ -1589,7 +1616,9 @@ int main(int argc, char *argv[])
char *backend = NULL;
char *shell = NULL;
int32_t xwayland = 0;
+   char *cmodules = NULL;
char *modules = NULL;
+   char *option_cmodules = NULL;
char *option_modules = NULL;
char *log = NULL;
char *server_socket = NULL, *end;
@@ -1612,6 +1641,7 @@ int main(int argc, char *argv[])
{ WESTON_OPTION_STRING, "socket", 'S', _name },
{ WESTON_OPTION_INTEGER, "idle-time", 'i', _time },
{ WESTON_OPTION_BOOLEAN, "xwayland", 0,  },
+   { WESTON_OPTION_STRING, "common-modules", 0, _cmodules },
{ WESTON_OPTION_STRING, "modules", 0, _modules },
{ WESTON_OPTION_STRING, "log", 0,  },
{ WESTON_OPTION_BOOLEAN, "help", 'h',  },
@@ -1746,6 +1776,14 @@ int main(int argc, char *argv[])
if (wet_load_shell(ec, shell, , argv) < 0)
goto out;
 
+   weston_config_section_get_string(section, "common-modules", ,
+"");
+   if (load_cmodules(ec, cmodules, , argv) < 0)
+   goto out;
+
+   if (load_cmodules(ec, option_cmodules, , argv) < 0)
+   goto out;
+
weston_config_section_get_string(section, "modules", , "");
if (load_modules(ec, modules, , argv) < 0)
goto out;
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 8f30b46..0ed3b0c 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -5033,17 +5033,18 @@ weston_compositor_load_backend(struct weston_compositor 
*compositor,
 }
 
 WL_EXPORT int
-weston_compositor_load_xwayland(struct weston_compositor *compositor)
+weston_compositor_load_module(struct weston_compositor *compositor,
+ const char *name)
 {
int (*weston_module_init)(struct weston_compositor *ec);
 
-   weston_module_init = weston_load_module("xwayland.so", 
"weston_module_init");
+   weston_module_init = weston_load_module(name, "weston_module_init");
if (!weston_module_init) {
int (*module_init)(struct weston_compositor *ec,
   int *argc, char *argv[]);
int argc = 0;
 
-   module_init = weston_load_module("xwayland.so", "module_init");
+   module_init = weston_load_module(name, "module_init");
if (!module_init || module_init(compositor, , NULL) < 0)
return -1;
} else if (weston_module_init(compositor) < 0) {
@@ -5051,3 +5052,9 @@ weston_compositor_load_xwayland(struct weston_compositor 
*compositor)
}
return 0;
 }
+
+WL_EXPORT int
+weston_compositor_load_xwayland(struct weston_compositor *compositor)
+{
+   return 

[PATCH weston 2/2] automake: add missing git-version.h dependency

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

compositor/main.c depends on the header, while the dependency isn't
specified. Thus depending on the order of how things are build we could
get a build failure.

Signed-off-by: Emil Velikov 
---
Strictly speaking one could resolve this (and future) issue, by not
pushing everything from BUILT_SOURCES into CLEANFILES, but I'll leave
that to someone more familiar with why things are as is.
---
 Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile.am b/Makefile.am
index 60d3bc1..b050c60 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -160,6 +160,7 @@ weston_SOURCES =\
 # add BUILT_SOURCES to CLEANFILES, but we want to keep git-version.h
 # in case we're building from tarballs.
 
+compositor/main.c : $(top_builddir)/libweston/git-version.h
 libweston/compositor.c : $(top_builddir)/libweston/git-version.h
 
 noinst_LTLIBRARIES +=  \
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/2] automake: list the the builddir include before the srcdir

2016-07-04 Thread Emil Velikov
From: Emil Velikov 

Otherwise we'll pick up the stale (in-tree) generated source(s) over the
fresh (out-of-tree) ones.

Signed-off-by: Emil Velikov 
---
It's quite a corner case, although it could save you a lot of time
debugging.
---
 Makefile.am | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 436bb1b..60d3bc1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,8 +44,8 @@ all-local : weston.ini ivi-shell/weston.ini
 AM_CFLAGS = $(GCC_CFLAGS)
 
 AM_CPPFLAGS =  \
-   -I$(top_srcdir)/libweston   \
-I$(top_builddir)/libweston \
+   -I$(top_srcdir)/libweston   \
-I$(top_builddir)/clients   \
-I$(top_builddir)/tests \
-I$(top_srcdir)/shared  \
@@ -842,8 +842,8 @@ module_LTLIBRARIES += desktop-shell.la
 desktop_shell_la_CPPFLAGS =\
-I$(top_builddir)/protocol  \
-I$(top_srcdir)/shared  \
-   -I$(top_srcdir)/libweston   \
-I$(top_builddir)/libweston \
+   -I$(top_srcdir)/libweston   \
-I$(top_builddir)/desktop-shell \
-DDATADIR='"$(datadir)"'\
-DMODULEDIR='"$(moduledir)"'\
@@ -875,8 +875,8 @@ module_LTLIBRARIES += fullscreen-shell.la
 fullscreen_shell_la_CPPFLAGS = \
-I$(top_builddir)/protocol  \
-I$(top_srcdir)/shared  \
-   -I$(top_srcdir)/libweston   \
-I$(top_builddir)/libweston \
+   -I$(top_srcdir)/libweston   \
-DIN_WESTON
 
 fullscreen_shell_la_LDFLAGS = -module -avoid-version
@@ -965,8 +965,8 @@ libweston_module_LTLIBRARIES += xwayland.la
 xwayland_la_CPPFLAGS = \
-I$(top_builddir)/protocol  \
-I$(top_srcdir)/shared  \
-   -I$(top_srcdir)/libweston   \
-I$(top_builddir)/libweston \
+   -I$(top_srcdir)/libweston   \
-I$(top_builddir)/xwayland  \
-DDATADIR='"$(datadir)"'\
-DMODULEDIR='"$(moduledir)"'\
-- 
2.8.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland 3/5] Add API to get the list of connected clients

2016-07-04 Thread Giulio Camuffo
2016-06-17 13:51 GMT+02:00 Pekka Paalanen :
> On Mon,  7 Mar 2016 18:31:33 +0100
> Giulio Camuffo  wrote:
>
>> ---
>>  src/wayland-server-core.h | 14 +
>>  src/wayland-server.c  | 52 
>> +++
>>  2 files changed, 66 insertions(+)
>>
>> diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
>> index a4ca350..4201b2c 100644
>> --- a/src/wayland-server-core.h
>> +++ b/src/wayland-server-core.h
>> @@ -176,6 +176,20 @@ wl_global_destroy(struct wl_global *global);
>>  struct wl_client *
>>  wl_client_create(struct wl_display *display, int fd);
>>
>> +struct wl_list *
>> +wl_display_get_client_list(struct wl_display *display);
>> +
>> +struct wl_list *
>> +wl_client_get_link(struct wl_client *client);
>> +
>> +struct wl_client *
>> +wl_client_from_link(struct wl_list *link);
>> +
>> +#define wl_client_for_each(client, list) \
>> + for (client = 0, client = wl_client_from_link((list)->next);\
>> +  wl_client_get_link(client) != (list);  \
>> +  client = wl_client_from_link(wl_client_get_link(client)->next))
>> +
>
> Hi,
>
> ok, there is this style of iterating over opaque objects. Then there is
> the other style you add for iterating over resources. Why are they
> different? Shouldn't we use the same style for both?
>
> That would mean we use the funcptr callback style, because wl_resources
> are kept in a wl_map, not a wl_list. But should that be the exception,
> is it so much harder to use?
>
> We already have wl_resource_for_each{,_safe}() macros. One could have
> written a wl_list_for_each_resource(struct wl_list *resource_list, func
> iterator, void *user_data). I do not know why it wasn't made that way.
> Ease of use at the cost of more function calls into the library?
>
> Do you know why there is the 'client = 0'? It seems to be present
> already in wl_resource_for_each() and I can't figure out why.
>
> I suppose the style you chose here is the one you prefer the most?
>
> I'm fine with both ways, though I would hope the commit message
> explained the reason why go this way and not the other way.

Yes, i prefer this style, since it allows to easily use data from the
outer scope in the loop, while the iterator approach requires you to
store your context somewhere and reference it through a pointer. On
the other hand, this exposes API which is not needed otherwise, and
which could also allow the user to shoot in his foot by manipulating
the list. So i don't have a strong opinion...

>
>>  void
>>  wl_client_destroy(struct wl_client *client);
>>
>> diff --git a/src/wayland-server.c b/src/wayland-server.c
>> index 5099614..a5527eb 100644
>> --- a/src/wayland-server.c
>> +++ b/src/wayland-server.c
>> @@ -1512,6 +1512,58 @@ wl_display_get_additional_shm_formats(struct 
>> wl_display *display)
>>   return >additional_shm_formats;
>>  }
>>
>> +/** Get the list of currently connected clients
>> + *
>> + * \param display The display object
>> + *
>> + * This function returns a pointer to the list of clients currently
>> + * connected to the display. You can iterate on the list by using
>> + * the \a wl_client_for_each macro.
>> + *
>> + * \sa wl_client_for_each()
>> + * \sa wl_client_get_link()
>> + * \sa wl_client_from_link()
>> + *
>> + * \memberof wl_display
>> + */
>> +WL_EXPORT struct wl_list *
>> +wl_display_get_client_list(struct wl_display *display)
>> +{
>> + return >client_list;
>> +}
>
> This should document how long the returned list head is valid. First I
> thought it would become invalid the moment the list is manipulated
> again, but it doesn't. Shouldn't we also say one must not change the
> list?
>
>> +
>> +/** Get the link by which a client is inserted in the client list
>> + *
>> + * \param client The client object
>> + *
>> + * \sa wl_client_for_each()
>> + * \sa wl_display_get_client_list()
>> + * \sa wl_client_from_link()
>> + *
>> + * \memberof wl_client
>> + */
>> +WL_EXPORT struct wl_list *
>> +wl_client_get_link(struct wl_client *client)
>> +{
>> + return >link;
>> +}
>> +
>> +/** Get a wl_client by its link
>> + *
>> + * \param link The link of a wl_client
>> + *
>> + * \sa wl_client_for_each()
>> + * \sa wl_display_get_client_list()
>> + * \sa wl_client_get_link()
>> + *
>> + * \memberof wl_client
>> + */
>> +WL_EXPORT struct wl_client *
>> +wl_client_from_link(struct wl_list *link)
>> +{
>> + return wl_container_of(link, (struct wl_client *)0, link);
>
> How about using container_of() instead?

Ah, i didn't know there was a container_of() in wayland too.

>
> wl_resource_from_link() could use the same treatment...
>
>> +}
>> +
>>  /** \cond */ /* Deprecated functions below. */
>>
>>  uint32_t
>
> Looks pretty good to me in general.
>
>
> Thanks,
> pq
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org

Re: [PATCH weston 2/2] gl-renderer,simple-dmabuf-v4l: fix dmabuf y-invert

2016-07-04 Thread Pekka Paalanen
On Mon,  4 Jul 2016 16:25:16 +0300
Pekka Paalanen  wrote:

> From: Pekka Paalanen 
> 
> Invert the Y_INVERT flag for the EGL import fo dmabufs. This fixes
> weston-simple-dmabuf-intel to show the same image on both GL-composited
> and with direct scanout on a hardware plane. Before, the image would
> y-flip when switching between these two cases. Now the orientation also
> matches the color values written in simple-dmabuf-intel.c.
> 
> The GL-renderer uses the OpenGL convention of texture coordinates, where
> the origin is at the bottom-left of an image. This can be observed in
> texture_region() where the texcoords are inverted if y_invert is false,
> since the surface coordinates have origin at top-left.  Both wl_shm and
> dmabuf buffers have origin at the top-left.
> 
> When wl_shm buffer is imported with glTexImage2D, it gets inverted
> because glTexImage2D is defined to read in the bottom row first. The shm
> data is top row first. This incidentally also means, that buffer pixel
> 0,0 ends up at texture coordinates 0,0. This is now inverted compared to
> the GL coordinate convention, and therefore gl_renderer_attach_shm()
> sets y_inverted to true. This causes texture_region() to NOT invert the
> texcoords. Wayland surface coordinates have origin at top-left, hence
> the double-inversion.
> 
> Dmabuf buffers also have the origin at top-left. However, they are
> imported via EGL to GL, where they should get the GL oriented
> coordinates but they do not. It is as if pixel 0,0 ends up at texcoords
> 0,0 - the same thing as with wl_shm buffers. Therefore we need to invert
> the invert flag.
> 
> Too bad EGL_EXT_image_dma_buf_import does not seem to specify the image
> orientation. The GL spec implied result seems to conflict with the
> reality in Mesa 11.2.2.
> 
> I asked about this in the Mesa developer mailing list. The question with
> no answers:
> https://lists.freedesktop.org/archives/mesa-dev/2016-June/120249.html
> and the thread I hijacked to get some answers:
> https://lists.freedesktop.org/archives/mesa-dev/2016-June/120733.html
> which culminated to the conclusion:
> https://lists.freedesktop.org/archives/mesa-dev/2016-June/120955.html
> that supports this patch.
> 
> simple-dmabuf-v4l is equally fixed to not add Y_INVERT. There is no
> rational reason to have it, and removing is necessary together with the
> GL-renderer change to keep the image the right way up. This has been
> tested with VIVID.
> 
> Signed-off-by: Pekka Paalanen 

Hi,

forgot to add that this patch is a partial fix to
https://phabricator.freedesktop.org/T7475


Thanks,
pq

> ---
>  clients/simple-dmabuf-v4l.c | 7 ++-
>  libweston/gl-renderer.c | 8 +++-
>  2 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/clients/simple-dmabuf-v4l.c b/clients/simple-dmabuf-v4l.c
> index 060b4fa..6ef0eb3 100644
> --- a/clients/simple-dmabuf-v4l.c
> +++ b/clients/simple-dmabuf-v4l.c
> @@ -353,7 +353,12 @@ create_dmabuf_buffer(struct display *display, struct 
> buffer *buffer)
>   unsigned i;
>  
>   modifier = 0;
> - flags = ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT;
> + flags = 0;
> +
> + /* XXX: apparently some webcams may actually provide y-inverted images,
> +  * in which case we should set
> +  * flags = ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT
> +  */
>  
>   params = zwp_linux_dmabuf_v1_create_params(display->dmabuf);
>   for (i = 0; i < display->format.num_planes; ++i)
> diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
> index 28c0b50..a404e7e 100644
> --- a/libweston/gl-renderer.c
> +++ b/libweston/gl-renderer.c
> @@ -1837,8 +1837,14 @@ gl_renderer_attach_dmabuf(struct weston_surface 
> *surface,
>  
>   buffer->width = dmabuf->attributes.width;
>   buffer->height = dmabuf->attributes.height;
> +
> + /*
> +  * GL-renderer uses the OpenGL convention of texture coordinates, where
> +  * the origin is at bottom-left. Because dmabuf buffers have the origin
> +  * at top-left, we must invert the Y_INVERT flag to get the image right.
> +  */
>   buffer->y_inverted =
> - !!(dmabuf->attributes.flags & 
> ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT);
> + !(dmabuf->attributes.flags & 
> ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT);
>  
>   for (i = 0; i < gs->num_images; i++)
>   egl_image_unref(gs->images[i]);
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/2] clients/dmabuf-v4l: explain vivid setup

2016-07-04 Thread Pekka Paalanen
From: Pekka Paalanen 

Add very short explanation on how to set up Vivid driver, when you don't
have suitable V4L2 device to use.

Using the XR24 (DRM_FORMAT_XRGB) format practically guarantees that
you can test direct scanout on a hardware overlay, too. At least on PC
hardware that has overlays. Tested to work on Intel.

Signed-off-by: Pekka Paalanen 
---
 clients/simple-dmabuf-v4l.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/clients/simple-dmabuf-v4l.c b/clients/simple-dmabuf-v4l.c
index 7ee5cce..060b4fa 100644
--- a/clients/simple-dmabuf-v4l.c
+++ b/clients/simple-dmabuf-v4l.c
@@ -866,6 +866,23 @@ usage(const char *argv0)
   "The default for both formats is YUYV.\n"
   "If the V4L2 and DRM formats differ, the data is simply "
   "reinterpreted rather than converted.\n", argv0);
+
+   printf("\n"
+  "How to set up Vivid the virtual video driver for testing:\n"
+  "- build your kernel with CONFIG_VIDEO_VIVID=m\n"
+  "- add this to a /etc/modprobe.d/ file:\n"
+  "options vivid node_types=0x1 num_inputs=1 
input_types=0x00\n"
+  "- modprobe vivid and check which device was created,\n"
+  "  here we assume /dev/video0\n"
+  "- set the pixel format:\n"
+  "$ v4l2-ctl -d /dev/video0 
--set-fmt-video=width=640,pixelformat=XR24\n"
+  "- launch the demo:\n"
+  "$ %s /dev/video0 XR24 XR24\n"
+  "You should see a test pattern with color bars, and some text.\n"
+  "\n"
+  "More about vivid: 
https://www.kernel.org/doc/Documentation/video4linux/vivid.txt\n;
+  "\n", argv0);
+
exit(0);
 }
 
-- 
2.7.3

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 2/2] gl-renderer, simple-dmabuf-v4l: fix dmabuf y-invert

2016-07-04 Thread Pekka Paalanen
From: Pekka Paalanen 

Invert the Y_INVERT flag for the EGL import fo dmabufs. This fixes
weston-simple-dmabuf-intel to show the same image on both GL-composited
and with direct scanout on a hardware plane. Before, the image would
y-flip when switching between these two cases. Now the orientation also
matches the color values written in simple-dmabuf-intel.c.

The GL-renderer uses the OpenGL convention of texture coordinates, where
the origin is at the bottom-left of an image. This can be observed in
texture_region() where the texcoords are inverted if y_invert is false,
since the surface coordinates have origin at top-left.  Both wl_shm and
dmabuf buffers have origin at the top-left.

When wl_shm buffer is imported with glTexImage2D, it gets inverted
because glTexImage2D is defined to read in the bottom row first. The shm
data is top row first. This incidentally also means, that buffer pixel
0,0 ends up at texture coordinates 0,0. This is now inverted compared to
the GL coordinate convention, and therefore gl_renderer_attach_shm()
sets y_inverted to true. This causes texture_region() to NOT invert the
texcoords. Wayland surface coordinates have origin at top-left, hence
the double-inversion.

Dmabuf buffers also have the origin at top-left. However, they are
imported via EGL to GL, where they should get the GL oriented
coordinates but they do not. It is as if pixel 0,0 ends up at texcoords
0,0 - the same thing as with wl_shm buffers. Therefore we need to invert
the invert flag.

Too bad EGL_EXT_image_dma_buf_import does not seem to specify the image
orientation. The GL spec implied result seems to conflict with the
reality in Mesa 11.2.2.

I asked about this in the Mesa developer mailing list. The question with
no answers:
https://lists.freedesktop.org/archives/mesa-dev/2016-June/120249.html
and the thread I hijacked to get some answers:
https://lists.freedesktop.org/archives/mesa-dev/2016-June/120733.html
which culminated to the conclusion:
https://lists.freedesktop.org/archives/mesa-dev/2016-June/120955.html
that supports this patch.

simple-dmabuf-v4l is equally fixed to not add Y_INVERT. There is no
rational reason to have it, and removing is necessary together with the
GL-renderer change to keep the image the right way up. This has been
tested with VIVID.

Signed-off-by: Pekka Paalanen 
---
 clients/simple-dmabuf-v4l.c | 7 ++-
 libweston/gl-renderer.c | 8 +++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/clients/simple-dmabuf-v4l.c b/clients/simple-dmabuf-v4l.c
index 060b4fa..6ef0eb3 100644
--- a/clients/simple-dmabuf-v4l.c
+++ b/clients/simple-dmabuf-v4l.c
@@ -353,7 +353,12 @@ create_dmabuf_buffer(struct display *display, struct 
buffer *buffer)
unsigned i;
 
modifier = 0;
-   flags = ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT;
+   flags = 0;
+
+   /* XXX: apparently some webcams may actually provide y-inverted images,
+* in which case we should set
+* flags = ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT
+*/
 
params = zwp_linux_dmabuf_v1_create_params(display->dmabuf);
for (i = 0; i < display->format.num_planes; ++i)
diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 28c0b50..a404e7e 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -1837,8 +1837,14 @@ gl_renderer_attach_dmabuf(struct weston_surface *surface,
 
buffer->width = dmabuf->attributes.width;
buffer->height = dmabuf->attributes.height;
+
+   /*
+* GL-renderer uses the OpenGL convention of texture coordinates, where
+* the origin is at bottom-left. Because dmabuf buffers have the origin
+* at top-left, we must invert the Y_INVERT flag to get the image right.
+*/
buffer->y_inverted =
-   !!(dmabuf->attributes.flags & 
ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT);
+   !(dmabuf->attributes.flags & 
ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT);
 
for (i = 0; i < gs->num_images; i++)
egl_image_unref(gs->images[i]);
-- 
2.7.3

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Override redirect windows with keyboard grabs on Xwayland

2016-07-04 Thread Olivier Fourdan
Hey Adam,

> This feels a lot like any other "app wants attention" case where you
> should just get a pulsing button or bouncing icon in the taskbar. The
> o-r window might be mapped and focused from Xwayland's perspective but
> there's nothing compelling wayland to actually show or focus it
> promptly, you know it's o-r, you know it's full-screen sized, and you
> have control of the display so when you _do_ put it up you can vignette
> it and add a Get Me Out Of Here checkbox in the upper-right or
> whatever.

That mechanism would probably not work as is with O-R windows for a couple of 
reasons:

 - the WM is not supposed to manage O-R windows (well, a compositor has of 
course, but the WM doesn't get a MapRequest and most WM will do as little as 
possible with O-R).

 - O-R are not listed in the window list so even if the compositor would have 
set the demand attention flag, the shell would probably ignore it.

Besides, what happens here is that O-R is already covering the entire screen 
(thus most likely cover any shell notification as well), and it feels natural 
for the user to start typing as the screen is covered and a nice text input is 
displayed :)
 
> I guess the thing you don't really get is a GrabNotify to let the wm
> know what's going on, though maybe you could infer it from FocusOut.
> There also appears to be no "wants attention" request in any wayland
> protocol, which is perhaps suboptimal. But if we had that, xserver
> could just emit that when an active grab fires, and then once the
> window gets focus the grab works just as well as it ever would.

We do (well, in gtk-shell no not strictly standard) have a "present" protocol 
that allows a Wayland client to ask the compositor to raise and focus a 
surface, we could use this with Xwayland to achieve that, but I suspect mutter 
would most likely deny such request on O-R (and being gtk-shell, that wouldn't 
work with any other compositor).

Thing is, weston seems to do this right so there should be a way to achieve 
that in mutter as well.

The approach I took in my patch for GNOME bug 
https://bugzilla.gnome.org/show_bug.cgi?id=752956 is to not deny focus for O-R 
that are fullscreen (either on a single monitor or the whole screen):

https://bugzilla.gnome.org/attachment.cgi?id=330053=diff

It does fix the issue, but I am not sure this can be acceptable in GNOME.

Cheers,
Olivier
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel