wayland: Ensure that shell and compositor are registered

Waffle requires that wayland_display::wl_shell and ::wl_compositor are set
before wayland_display_connect() returns. In two ways Waffle failed to
ensure that:
  - wayland_display_connect() assumes that the requirement is satisified.
    It did not explicitly check it.

  - In an attempt to satisfy the requirement, wayland_display_connect()
    called wl_display_dispatch() before returning. That's not sufficient;
    a roundtrip to the server is needed.

This patch fixes the above mistakes by calling wl_display_roundtrip() and
then explicitly checking that the shell and compositor have been
registered.  This method follows that of Enlightenment's Wayland engine:
  https://svn.enlightenment.org/svn/e/trunk/expedite/src/bin/engine_wayland_egl.c?rev=83377

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
(cherry picked from commit 44ad3412db508b7e9c6ee230bc1fc6d5fda2d82f)
android: Fix createSurface compiler error

It looks like createSurface changed signature:

waffle/src/waffle/android/droid_surfaceflingerlink.cpp:113:36:
error: no matching function for call to
android::SurfaceComposerClient::createSurface(
  android::String8, int, const uint32_t&, const uint32_t&, android::<anonymous enum>, int)

Candidate is:
frameworks/native/include/gui/SurfaceComposerClient.h:80:24:
android::sp<android::SurfaceControl> android::SurfaceComposerClient::createSurface(
  const android::String8&, uint32_t, uint32 _t, android::PixelFormat, uint32_t)

Reviewed-by: Tom Gall <tom.gall@linaro.org>
Signed-off-by: Adrian Marius Negreanu <adrian.m.negreanu@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
(cherry picked from commit d49cc713332b565ad4913ef859972b82a3bca358)
Android: Fix surface setup segfault

Seems like compiling with latest Android tree malloc/free did not work
with structures in droid_surfaceflingerlink.cpp, some members
in structures become strange causing segfault. Using new/delete fix
this.

Signed-off-by: Juha-Pekka Heikkila <juha-pekka.heikkila@linux.intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
(cherry picked from commit c42522c76a94e82907b218c7670c89a8f92f952c)
examples/gl_basic: Fix example in usage message

Version and profile were swapped.

(cherry picked from commit 32dccd3c9a244279d6c90e27064d9f4a82cfb42c)
cmake: Use libudev.pc, not non-existent udev.pc

CMake called pkg-config on a non-existent pkgname, udev.
Fixes build with clang-3.3 if GBM is enabled.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
(cherry picked from commit 7fc45480fc6dadfdbdf55b4c9042edadb57c8376)
x11: Catch Xlib errors with function wrappers

This patch defines a wrapper for each Xlib function called by the x11
directory.  Each wrapper catches any Xlib error emitted by the wrapped
function. The wrapper's signature matches the wrapped.

All Xlib errors generated by Waffle must be caught by Waffle. Otherwise,
the Xlib error handler installed by the user will catch the error and
may handle it in a way Waffle doesn't like. Or, even worse, the default
Xlib error handler will catch it, which exits the process.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
(cherry picked from commit 7217987e5dbf25fcbedda42ba92769121abc5e24)
glx: Catch Xlib errors with function wrappers

This patch defines a wrapper for each GLX function called by the glx
directory.  Each wrapper catches any Xlib error emitted by the wrapped
function. The wrapper's signature matches the wrapped.

All Xlib errors generated by Waffle must be caught by Waffle. Otherwise,
the Xlib error handler installed by the user will catch the error and
may handle it in a way Waffle doesn't like. Or, even worse, the default
Xlib error handler will catch it, which exits the process.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
(cherry picked from commit 229693794eb4038d8796e1c77e43097e73ca19a6)