Merge remote-tracking branch 'vignatti/evdev'
diff --git a/clients/cairo-util.c b/clients/cairo-util.c
index 61a053b..54a05b1 100644
--- a/clients/cairo-util.c
+++ b/clients/cairo-util.c
@@ -289,13 +289,28 @@
 	cairo_close_path(cr);
 }
 
+static void
+swizzle_row(JSAMPLE *row, JDIMENSION width)
+{
+	JSAMPLE *s;
+	uint32_t *d;
+
+	s = row + (width - 1) * 3;
+	d = (uint32_t *) (row + (width - 1) * 4);
+	while (s >= row) {
+		*d = 0xff000000 | (s[0] << 16) | (s[1] << 8) | (s[2] << 0);
+		s -= 3;
+		d--;
+	}
+}
+
 cairo_surface_t *
 load_jpeg(const char *filename)
 {
 	struct jpeg_decompress_struct cinfo;
 	struct jpeg_error_mgr jerr;
 	FILE *fp;
-	int stride, i;
+	int stride, i, first;
 	JSAMPLE *data, *rows[4];
 
 	cinfo.err = jpeg_std_error(&jerr);
@@ -310,7 +325,7 @@
 
 	jpeg_read_header(&cinfo, TRUE);
 
-	cinfo.out_color_space = JCS_EXT_BGRX;
+	cinfo.out_color_space = JCS_RGB;
 	jpeg_start_decompress(&cinfo);
 
 	stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24,
@@ -322,10 +337,13 @@
 	}
 
 	while (cinfo.output_scanline < cinfo.output_height) {
+		first = cinfo.output_scanline;
 		for (i = 0; i < ARRAY_LENGTH(rows); i++)
-			rows[i] = data + (cinfo.output_scanline + i) * stride;
+			rows[i] = data + (first + i) * stride;
 
 		jpeg_read_scanlines(&cinfo, rows, ARRAY_LENGTH(rows));
+		for (i = 0; first + i < cinfo.output_scanline; i++)
+			swizzle_row(rows[i], cinfo.output_width);
 	}
 
 	jpeg_finish_decompress(&cinfo);
diff --git a/clients/config.c b/clients/config.c
index 5680d50..69edbc6 100644
--- a/clients/config.c
+++ b/clients/config.c
@@ -25,7 +25,7 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include <window.h>
+#include "window.h"
 
 static int
 handle_key(const struct config_key *key, const char *value)
diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index adf3a5c..3cca520 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -32,11 +32,11 @@
 #include <sys/wait.h>
 #include <linux/input.h>
 
-#include "wayland-client.h"
+#include <wayland-client.h>
 #include "cairo-util.h"
 #include "window.h"
 
-#include <desktop-shell-client-protocol.h>
+#include "desktop-shell-client-protocol.h"
 
 struct desktop {
 	struct display *display;
diff --git a/clients/dnd.c b/clients/dnd.c
index 5bfe31c..db794fd 100644
--- a/clients/dnd.c
+++ b/clients/dnd.c
@@ -32,7 +32,7 @@
 #include <sys/epoll.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
-#include "wayland-client.h"
+#include <wayland-client.h>
 
 #include "window.h"
 #include "cairo-util.h"
diff --git a/clients/flower.c b/clients/flower.c
index 5ad58f1..7743b44 100644
--- a/clients/flower.c
+++ b/clients/flower.c
@@ -33,7 +33,7 @@
 #include <sys/time.h>
 #include <glib.h>
 
-#include "wayland-client.h"
+#include <wayland-client.h>
 #include "window.h"
 
 static void
diff --git a/clients/gears.c b/clients/gears.c
index 6af505b..bc85f54 100644
--- a/clients/gears.c
+++ b/clients/gears.c
@@ -36,8 +36,7 @@
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
 
-#include "wayland-util.h"
-#include "wayland-client.h"
+#include <wayland-client.h>
 
 #include "window.h"
 
diff --git a/clients/image.c b/clients/image.c
index 51ce1f0..13115d2 100644
--- a/clients/image.c
+++ b/clients/image.c
@@ -33,7 +33,7 @@
 #include <glib.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
-#include "wayland-client.h"
+#include <wayland-client.h>
 
 #include "window.h"
 
diff --git a/clients/resizor.c b/clients/resizor.c
index e48095f..c3d0327 100644
--- a/clients/resizor.c
+++ b/clients/resizor.c
@@ -27,8 +27,7 @@
 #include <cairo.h>
 #include <math.h>
 
-#include "wayland-util.h"
-#include "wayland-client.h"
+#include <wayland-client.h>
 
 #include "window.h"
 
diff --git a/clients/screenshot.c b/clients/screenshot.c
index 124e576..bfe5ea0 100644
--- a/clients/screenshot.c
+++ b/clients/screenshot.c
@@ -30,7 +30,7 @@
 #include <glib.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
-#include "wayland-client.h"
+#include <wayland-client.h>
 #include "screenshooter-client-protocol.h"
 
 /* The screenshooter is a good example of a custom object exposed by
diff --git a/clients/smoke.c b/clients/smoke.c
index 061bd6d..6ceade0 100644
--- a/clients/smoke.c
+++ b/clients/smoke.c
@@ -32,7 +32,7 @@
 #include <cairo.h>
 #include <glib.h>
 
-#include "wayland-client.h"
+#include <wayland-client.h>
 #include "window.h"
 
 struct smoke {
diff --git a/clients/terminal.c b/clients/terminal.c
index 092e069..8651073 100644
--- a/clients/terminal.c
+++ b/clients/terminal.c
@@ -36,8 +36,7 @@
 
 #include <X11/keysym.h>
 
-#include "wayland-util.h"
-#include "wayland-client.h"
+#include <wayland-client.h>
 
 #include "window.h"
 
diff --git a/clients/view.c b/clients/view.c
index 0eec1f9..9d8a99f 100644
--- a/clients/view.c
+++ b/clients/view.c
@@ -37,8 +37,7 @@
 #include <glib/poppler-document.h>
 #include <glib/poppler-page.h>
 
-#include "wayland-util.h"
-#include "wayland-client.h"
+#include <wayland-client.h>
 
 #include "window.h"
 
diff --git a/clients/window.c b/clients/window.c
index 16322ff..1e317c7 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -50,8 +50,7 @@
 #include <X11/extensions/XKBcommon.h>
 
 #include <linux/input.h>
-#include "wayland-util.h"
-#include "wayland-client.h"
+#include <wayland-client.h>
 #include "cairo-util.h"
 
 #include "window.h"
@@ -316,7 +315,6 @@
 	struct egl_image_surface_data *data;
 	EGLDisplay dpy = display->dpy;
 	cairo_surface_t *surface;
-	EGLConfig config;
 	cairo_content_t content;
 
 	data = malloc(sizeof *data);
@@ -334,11 +332,9 @@
 
 	if (flags & SURFACE_OPAQUE) {
 		data->device = display->rgb_device;
-		config = display->rgb_config;
 		content = CAIRO_CONTENT_COLOR;
 	} else {
 		data->device = display->argb_device;
-		config = display->premultiplied_argb_config;
 		content = CAIRO_CONTENT_COLOR_ALPHA;
 	}
 
diff --git a/clients/wscreensaver-glue.h b/clients/wscreensaver-glue.h
index 74c9e5c..e07915f 100644
--- a/clients/wscreensaver-glue.h
+++ b/clients/wscreensaver-glue.h
@@ -43,7 +43,6 @@
 #include <GL/gl.h>
 #include <GL/glu.h>
 
-#include "wayland-util.h"
 #include "window.h"
 
 #define ENTRYPOINT static
diff --git a/clients/wscreensaver.c b/clients/wscreensaver.c
index 6070c5d..f00741e 100644
--- a/clients/wscreensaver.c
+++ b/clients/wscreensaver.c
@@ -32,8 +32,7 @@
 #include <GL/gl.h>
 #include <EGL/eglext.h>
 
-#include "wayland-util.h"
-#include "wayland-client.h"
+#include <wayland-client.h>
 
 #include "window.h"
 
diff --git a/compositor/compositor.c b/compositor/compositor.c
index 9b32eff..fe123f8 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -42,7 +42,7 @@
 #include <getopt.h>
 #include <signal.h>
 
-#include "wayland-server.h"
+#include <wayland-server.h>
 #include "compositor.h"
 
 /* The plan here is to generate a random anonymous socket name and
diff --git a/compositor/compositor.h b/compositor/compositor.h
index c61e697..b66903a 100644
--- a/compositor/compositor.h
+++ b/compositor/compositor.h
@@ -25,8 +25,7 @@
 
 #include <libudev.h>
 #include <pixman.h>
-#include "wayland-server.h"
-#include "wayland-util.h"
+#include <wayland-server.h>
 
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
diff --git a/compositor/shell.c b/compositor/shell.c
index 7bae944..f8305db 100644
--- a/compositor/shell.c
+++ b/compositor/shell.c
@@ -32,7 +32,7 @@
 #include <fcntl.h>
 #include <assert.h>
 
-#include "wayland-server.h"
+#include <wayland-server.h>
 #include "compositor.h"
 #include "desktop-shell-server-protocol.h"