dbe: Cleanup in CloseScreen hook not ext CloseDown

Instead of registering an extension CloseDownProc when adding the dbe
extension this patch hooks into pScreen->CloseScreen so that the chain
of pScreen->DestroyWindow hooks remains valid until all windows have
been destroyed. Previously it was possible for DbeResetProc to be called
before the root window had been destroyed and the unwrapping of
pScreen->DestroyWindow would clobber the chain of callbacks.

This is needed for xwayland to be able to know when the root window is
destroyed so it can unredirect root sub-windows.
xkb: Add struct XkbCompContext

This commit adds a struct that contains most of the context for starting,
running and cleaning up after xkbcomp.

Reviewed-by: Daniel Stone <daniel@fooishbar.org>
xkb: Split out code to start and finish xkbcomp

Using the context struct from previous commit, we can now split out
code to start xkbcomp and to finish and clean up after it.

Reviewed-by: Daniel Stone <daniel@fooishbar.org>
xkb: Add XkbCompileKeymapFromString()

This new function compiles a keymap from an in-memory string.  We use it
to add a new keyooard device init function,
InitKeyboardDeviceStructFromString(), which inits a keyboard device with
a keymap specified as a string instead of a rmlvo set.

Reviewed-by: Daniel Stone <daniel@fooishbar.org>
os: Add a function to create a client for an fd
Export xf86NewInputDevice and xf86AllocateInput
Export CompositeRedirectSubwindows and CompositeUnRedirectSubwindows
Add redirect window for input device feature
dri2: Introduce a third version of the AuthMagic function

This most recent version takes a client pointer to allow xwayland to
asynchronously authenticate a client.
Add xwayland module

Squashed and rebased from the xwayland-1.12 branch.  Contributions from

  Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
  Corentin Chary <corentin.chary@gmail.com>
  Daniel Stone <daniel@fooishbar.org>
  Kristian Høgsberg <krh@bitplanet.net>
  Robert Bragg <robert@linux.intel.com>
  Scott Moreau <oreaus@gmail.com>
  Tiago Vignatti <tiago.vignatti@intel.com>
xwayland: Add a HW_WAYLAND flag to let drivers explicitly opt-in
xwayland-shm: don't create alpha buffers if the window doesn't have alpha

If the window is using a 24 bit visual, we must request a buffer
format without alpha, or garbage is rendered.
xwayland: handle global object destruction

Certain global objects, such as outputs, can be destroyed during
the session. We must handle that and not crash.
xwayland: add support for multiple outputs

Drop xf86InitialConfiguration, which just gets in the way
of the compositor doing its own output arrangement, and transform
wayland events into the appropriate low-level xf86 calls to
keep the screen size updated.

Kristian: after the rebase it was crashing for me too, had to fix
the patch a bit. This one should work, and also gives sensible (though
not perfect) results for xrandr clients.
Tested with weston/x11 and mutter-wayland/kms.
xwayland: Probe outputs on preinit

When running xwayland, calls to xf86SetDesiredModes() would fail due to
the probed modes list not being populated. This was previously done
indirectly by calling xf86InitialConfiguration() and now needs to be
done explicitly instead.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
XFree86: Load wlshm driver as fallback for Wayland

Since fbdev or vesa are unlikely to be too useful there ...

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
XWayland: Don't send out-of-bounds damage co-ordinates

Make sure we don't send damage regions larger than the buffer.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
xwayland: Introduce an auto mode for --enable-wayland

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
XWayland: Don't hardcode DRM libs and -lwayland-client

Take -lwayland-client from configure.ac, and only use DRM if we've
actually asked for it.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
XWayland: Support 16bpp X surfaces in DRM/SHM

Properly look at the window's visual to determine which format we should
use for allocation.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>