[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

weston: Changes to 'upstream-unstable'



 .gitignore                    |    1 
 clients/.gitignore            |   39 -
 clients/Makefile.am           |   22 
 clients/clickdot.c            |    4 
 clients/cliptest.c            |    6 
 clients/desktop-shell.c       |   55 +-
 clients/dnd.c                 |   52 +
 clients/editor.c              |    3 
 clients/gears.c               |    3 
 clients/image.c               |    3 
 clients/keyboard.c            |   61 +-
 clients/multi-resource.c      |  597 +++++++++++++++++++++
 clients/nested.c              |   19 
 clients/resizor.c             |    6 
 clients/screenshot.c          |    2 
 clients/simple-shm.c          |    4 
 clients/simple-touch.c        |    6 
 clients/subsurfaces.c         |   17 
 clients/tablet-shell.c        |   88 +--
 clients/terminal.c            |  151 ++++-
 clients/view.c                |    3 
 clients/weston-info.c         |   25 
 clients/window.c              |  207 ++++---
 clients/window.h              |   20 
 configure.ac                  |   35 -
 shared/cairo-util.c           |   31 +
 shared/cairo-util.h           |    3 
 shared/config-parser.c        |  236 ++------
 shared/config-parser.h        |   17 
 shared/zalloc.h               |   42 +
 src/Makefile.am               |   22 
 src/animation.c               |   24 
 src/bindings.c                |   26 
 src/clipboard.c               |   32 -
 src/cms-colord.c              |    3 
 src/cms-static.c              |    3 
 src/compositor-drm.c          |  250 ++++++---
 src/compositor-fbdev.c        |  163 ++++-
 src/compositor-headless.c     |   10 
 src/compositor-rdp.c          |   40 -
 src/compositor-rpi.c          |   51 -
 src/compositor-wayland.c      |   16 
 src/compositor-x11.c          |   23 
 src/compositor.c              |  204 +++++--
 src/compositor.h              |   71 +-
 src/data-device.c             |  146 ++---
 src/evdev-touchpad.c          |   43 +
 src/evdev.c                   |  283 +++++-----
 src/evdev.h                   |   21 
 src/gl-renderer.c             |  379 ++-----------
 src/input.c                   |  548 ++++++++++++-------
 src/launcher-util.c           |  315 +++++++++--
 src/launcher-util.h           |   17 
 src/log.c                     |    1 
 src/pixman-renderer.c         |   18 
 src/rpi-bcm-stubs.h           |    8 
 src/rpi-renderer.c            |  279 +++++++++-
 src/screenshooter.c           |   59 +-
 src/shell.c                   |   79 +-
 src/tablet-shell.c            |    3 
 src/text-backend.c            |    4 
 src/tty.c                     |  294 ----------
 src/udev-seat.c               |    5 
 src/vaapi-recorder.c          | 1155 ++++++++++++++++++++++++++++++++++++++++++
 src/vaapi-recorder.h          |   35 +
 src/version.h.in              |    6 
 src/vertex-clipping.c         |  317 +++++++++++
 src/vertex-clipping.h         |   65 ++
 src/weston-egl-ext.h          |   10 
 src/weston-launch.c           |  387 +++++++-------
 src/weston-launch.h           |   12 
 src/xwayland/Makefile.am      |    1 
 src/xwayland/dnd.c            |  274 +++++++++
 src/xwayland/launcher.c       |    4 
 src/xwayland/selection.c      |   72 +-
 src/xwayland/window-manager.c |  337 ++++++++++--
 src/xwayland/xwayland.h       |   22 
 tests/Makefile.am             |   55 +-
 tests/config-parser-test.c    |    2 
 tests/vertex-clip-test.c      |  219 +++++++
 tests/weston-test-runner.c    |  139 +++--
 tests/weston-test-runner.h    |   52 +
 tests/weston-test.c           |    3 
 tests/weston-tests-env        |   17 
 weston.ini                    |   10 
 85 files changed, 6055 insertions(+), 2337 deletions(-)

New commits:
commit 0333282f6bd27ce8cb639d34920515c9ca0182c9
Author: Héctor Orón Martínez <zumbi@debian.org>
Date:   Fri Oct 11 14:35:01 2013 +0200

    Merge 1.3.0 upstream tag
    
    Signed-off-by: Héctor Orón Martínez <zumbi@debian.org>

diff --git a/clients/Makefile.am b/clients/Makefile.am
index 24ee9e4..4f9dc48 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -8,7 +8,6 @@ demo_clients = \
 	$(poppler_programs)			\
 	$(simple_clients_programs)		\
 	$(simple_egl_clients_programs)
-endif
 
 if ENABLE_DEMO_CLIENTS
 bin_PROGRAMS += $(demo_clients)
diff --git a/configure.ac b/configure.ac
index a5ae749..5abf65f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,7 +190,7 @@ AM_CONDITIONAL([ENABLE_FBDEV_COMPOSITOR],
                [test x$enable_fbdev_compositor = xyes])
 AS_IF([test x$enable_fbdev_compositor = xyes], [
   AC_DEFINE([BUILD_FBDEV_COMPOSITOR], [1], [Build the fbdev compositor])
-  PKG_CHECK_MODULES([FBDEV_COMPOSITOR], [libudev >= 136 mtdev >= 1.1.0 libdrm >= 2.4.30])
+  PKG_CHECK_MODULES([FBDEV_COMPOSITOR], [libudev >= 136 mtdev >= 1.1.0])
 ])
 
 AC_ARG_ENABLE([rdp-compositor], [  --enable-rdp-compositor],,
diff --git a/src/evdev.c b/src/evdev.c
index c01266a..48e5470 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -190,11 +190,6 @@ evdev_process_key(struct evdev_device *device, struct input_event *e, int time)
 					 WL_POINTER_BUTTON_STATE_RELEASED);
 		break;
 
-	case BTN_TOUCH:
-		if (e->value == 0 && !device->is_mt)
-			notify_touch(device->seat, time, 0, 0, 0,
-				     WL_TOUCH_UP);
-		break;
 	default:
 		notify_key(device->seat,
 			   time, e->code,

commit 95659c03219b057d9d703b04cf89bc0329ce947a
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Wed Oct 9 16:20:50 2013 -0700

    configure.ac: Bump version to 1.3

diff --git a/configure.ac b/configure.ac
index 302075e..5abf65f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 m4_define([weston_major_version], [1])
-m4_define([weston_minor_version], [2])
-m4_define([weston_micro_version], [92])
+m4_define([weston_minor_version], [3])
+m4_define([weston_micro_version], [0])
 m4_define([weston_version],
           [weston_major_version.weston_minor_version.weston_micro_version])
 

commit 6a11a8ab544d7fa186374ca5f26c2f403409f223
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Wed Oct 9 15:17:01 2013 -0700

    Revert "Resize the shell when the mode is switched"
    
    This breaks panel resizing as it doesn't account for output rotation.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=70249
    
    This reverts commit a356f7b1ef08fd9c2ad69cada89d68841e71a6bb.

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index 1a5a94f..599c0a5 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -1160,13 +1160,6 @@ output_handle_mode(void *data,
 		   int height,
 		   int refresh)
 {
-	struct output *output = (struct output *)data;
-
-	if (flags & WL_OUTPUT_MODE_CURRENT) {
-		window_schedule_resize(output->panel->window, width, 32);
-		window_schedule_resize(output->background->window,
-				       width, height);
-	}
 }
 
 static void

commit cb406f1afd560762f60c27f7a88fd9f65c15041f
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Wed Oct 9 10:54:03 2013 -0700

    input: Don't send modifiers if client doesn't have a pointer resource
    
    This fixes an uninitialized serial error, were we could send out the
    modifier event even if the client didn't have a pointer resource.  We
    send out the modifier event to let clients know the modifer mask when
    they receive a pointer button event.  Thus, if the client doesn't have
    a pointer we don't need to send the modifier event.
    
    Additionally we would send out the modifier event with an
    uninitialized serial number.
    
    Finally, this commit restores the order of sending the modifier event
    before the enter, like it used to be.  Not likely to be an issue,
    since the client will always receive the modifier event before any
    button event, but it's a little nicer to give the client the modifier
    events before it receives any pointer events.

diff --git a/src/input.c b/src/input.c
index 1313b52..a994fb9 100644
--- a/src/input.c
+++ b/src/input.c
@@ -489,6 +489,12 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
 
 		serial = wl_display_next_serial(display);
 
+		if (kbd && kbd->focus != pointer->focus)
+			send_modifiers_to_client_in_list(surface_client,
+							 &kbd->resource_list,
+							 serial,
+							 kbd);
+
 		move_resources_for_client(focus_resource_list,
 					  &pointer->resource_list,
 					  surface_client);
@@ -503,15 +509,6 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
 		pointer->focus_serial = serial;
 	}
 
-	if (kbd && surface && surface->resource && kbd->focus != pointer->focus) {
-		struct wl_client *surface_client =
-			wl_resource_get_client(surface->resource);
-		send_modifiers_to_client_in_list(surface_client,
-						 &kbd->resource_list,
-						 serial,
-						 kbd);
-	}
-
 	pointer->focus = surface;
 	wl_signal_emit(&pointer->focus_signal, pointer);
 }

commit b4659eb15959091ab8bab8e20ed66233d39922fa
Author: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Date:   Mon Oct 7 11:02:20 2013 +0200

    rpi: Add support for EGL buffers
    
    The EGL implementation on the RPi allocates a front and a back
    DispmanX resources for each EGLSurface, which we composite along
    the others.

diff --git a/src/rpi-bcm-stubs.h b/src/rpi-bcm-stubs.h
index d3ffd4b..703cd77 100644
--- a/src/rpi-bcm-stubs.h
+++ b/src/rpi-bcm-stubs.h
@@ -296,6 +296,13 @@ vc_dispmanx_snapshot(DISPMANX_DISPLAY_HANDLE_T display,
 	return -1;
 }
 
+struct wl_resource;
+static inline DISPMANX_RESOURCE_HANDLE_T
+vc_dispmanx_get_handle_from_wl_buffer(struct wl_resource *_buffer)
+{
+	return DISPMANX_NO_HANDLE;
+}
+
 /* from /opt/vc/include/EGL/eglplatform.h */
 
 typedef struct {
diff --git a/src/rpi-renderer.c b/src/rpi-renderer.c
index 3ba5fc4..6b39e8c 100644
--- a/src/rpi-renderer.c
+++ b/src/rpi-renderer.c
@@ -35,6 +35,12 @@
 #include "compositor.h"
 #include "rpi-renderer.h"
 
+#ifdef ENABLE_EGL
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include "weston-egl-ext.h"
+#endif
+
 /*
  * Dispmanx API offers alpha-blended overlays for hardware compositing.
  * The final composite consists of dispmanx elements, and their contents:
@@ -84,6 +90,17 @@ struct rpi_resource {
 
 struct rpir_output;
 
+struct rpir_egl_buffer {
+	struct weston_buffer_reference buffer_ref;
+	DISPMANX_RESOURCE_HANDLE_T resource_handle;
+};
+
+enum buffer_type {
+	BUFFER_TYPE_NULL,
+	BUFFER_TYPE_SHM,
+	BUFFER_TYPE_EGL
+};
+
 struct rpir_surface {
 	struct weston_surface *surface;
 
@@ -102,7 +119,12 @@ struct rpir_surface {
 	struct rpi_resource *back;
 	pixman_region32_t prev_damage;
 
+	struct rpir_egl_buffer *egl_front;
+	struct rpir_egl_buffer *egl_back;
+	struct rpir_egl_buffer *egl_old_front;
+
 	struct weston_buffer_reference buffer_ref;
+	enum buffer_type buffer_type;
 };
 
 struct rpir_output {
@@ -125,6 +147,15 @@ struct rpi_renderer {
 	struct weston_renderer base;
 
 	int single_buffer;
+
+#ifdef ENABLE_EGL
+	EGLDisplay egl_display;
+
+	PFNEGLBINDWAYLANDDISPLAYWL bind_display;
+	PFNEGLUNBINDWAYLANDDISPLAYWL unbind_display;
+	PFNEGLQUERYWAYLANDBUFFERWL query_buffer;
+#endif
+	int has_bind_display;
 };
 
 static inline struct rpir_surface *
@@ -335,6 +366,7 @@ rpir_surface_create(struct rpi_renderer *renderer)
 		surface->back = &surface->resources[0];
 	else
 		surface->back = &surface->resources[1];
+	surface->buffer_type = BUFFER_TYPE_NULL;
 
 	pixman_region32_init(&surface->prev_damage);
 
@@ -354,6 +386,24 @@ rpir_surface_destroy(struct rpir_surface *surface)
 	rpi_resource_release(&surface->resources[1]);
 	DBG("rpir_surface %p destroyed (%u)\n", surface, surface->handle);
 
+	if (surface->egl_back != NULL) {
+		weston_buffer_reference(&surface->egl_back->buffer_ref, NULL);
+		free(surface->egl_back);
+		surface->egl_back = NULL;
+	}
+
+	if (surface->egl_front != NULL) {
+		weston_buffer_reference(&surface->egl_front->buffer_ref, NULL);
+		free(surface->egl_front);
+		surface->egl_front = NULL;
+	}
+
+	if (surface->egl_old_front != NULL) {
+		weston_buffer_reference(&surface->egl_old_front->buffer_ref, NULL);
+		free(surface->egl_old_front);
+		surface->egl_old_front = NULL;
+	}
+
 	free(surface);
 }
 
@@ -472,8 +522,16 @@ rpir_surface_compute_rects(struct rpir_surface *surface,
 
 	src_x = 0 << 16;
 	src_y = 0 << 16;
-	src_width = surface->front->width << 16;
-	src_height = surface->front->height << 16;
+
+	if (surface->buffer_type == BUFFER_TYPE_EGL) {
+		struct weston_buffer *buffer = surface->egl_front->buffer_ref.buffer;
+
+		src_width = buffer->width << 16;
+		src_height = buffer->height << 16;
+	} else {
+		src_width = surface->front->width << 16;
+		src_height = surface->front->height << 16;
+	}
 
 	weston_matrix_multiply(&matrix, &output->matrix);
 
@@ -647,6 +705,10 @@ rpir_surface_compute_rects(struct rpir_surface *surface,
 		return -1;
 	}
 
+	/* EGL buffers will be upside-down related to what DispmanX expects */
+	if (surface->buffer_type == BUFFER_TYPE_EGL)
+		flipt ^= TRANSFORM_VFLIP;
+
 	vc_dispmanx_rect_set(src_rect, src_x, src_y, src_width, src_height);
 	vc_dispmanx_rect_set(dst_rect, dst_x, dst_y, dst_width, dst_height);
 	*flipmask = flipt;
@@ -681,6 +743,22 @@ vc_image2dispmanx_transform(VC_IMAGE_TRANSFORM_T t)
 	}
 }
 
+
+static DISPMANX_RESOURCE_HANDLE_T
+rpir_surface_get_resource(struct rpir_surface *surface)
+{
+	switch (surface->buffer_type) {
+	case BUFFER_TYPE_SHM:
+	case BUFFER_TYPE_NULL:
+		return surface->front->handle;
+	case BUFFER_TYPE_EGL:
+		if (surface->egl_front != NULL)
+			return surface->egl_front->resource_handle;
+	default:
+		return DISPMANX_NO_HANDLE;
+	}
+}
+
 static int
 rpir_surface_dmx_add(struct rpir_surface *surface, struct rpir_output *output,
 		    DISPMANX_UPDATE_HANDLE_T update, int layer)
@@ -700,6 +778,13 @@ rpir_surface_dmx_add(struct rpir_surface *surface, struct rpir_output *output,
 	VC_RECT_T src_rect;
 	VC_IMAGE_TRANSFORM_T flipmask;
 	int ret;
+	DISPMANX_RESOURCE_HANDLE_T resource_handle;
+
+	resource_handle = rpir_surface_get_resource(surface);
+	if (resource_handle == DISPMANX_NO_HANDLE) {
+		weston_log("%s: no buffer yet, aborting\n", __func__);
+		return 0;
+	}
 
 	ret = rpir_surface_compute_rects(surface, &src_rect, &dst_rect,
 					 &flipmask);
@@ -711,17 +796,14 @@ rpir_surface_dmx_add(struct rpir_surface *surface, struct rpir_output *output,
 		output->display,
 		layer,
 		&dst_rect,
-		surface->front->handle,
+		resource_handle,
 		&src_rect,
 		DISPMANX_PROTECTION_NONE,
 		&alphasetup,
 		NULL /* clamp */,
 		vc_image2dispmanx_transform(flipmask));
-	DBG("rpir_surface %p add %u, alpha %f\n", surface, surface->handle,
-	    surface->surface->alpha);
-
-	if (surface->handle == DISPMANX_NO_HANDLE)
-		return -1;
+	DBG("rpir_surface %p add %u, alpha %f resource %d\n", surface,
+	    surface->handle, surface->surface->alpha, resource_handle);
 
 	return 1;
 }
@@ -758,6 +840,20 @@ rpir_surface_dmx_move(struct rpir_surface *surface,
 
 	/* XXX: return early, if all attributes stay the same */
 
+	if (surface->buffer_type == BUFFER_TYPE_EGL) {
+		DISPMANX_RESOURCE_HANDLE_T resource_handle;
+
+		resource_handle = rpir_surface_get_resource(surface);
+		if (resource_handle == DISPMANX_NO_HANDLE) {
+			weston_log("%s: no buffer yet, aborting\n", __func__);
+			return 0;
+		}
+
+		vc_dispmanx_element_change_source(update,
+						  surface->handle,
+						  resource_handle);
+	}
+
 	ret = rpir_surface_compute_rects(surface, &src_rect, &dst_rect,
 					 &flipmask);
 	if (ret < 0)
@@ -835,8 +931,31 @@ rpir_surface_update(struct rpir_surface *surface, struct rpir_output *output,
 	int ret;
 	int obscured;
 
-	if (need_swap)
-		rpir_surface_swap_pointers(surface);
+	if (surface->buffer_type == BUFFER_TYPE_EGL) {
+		if (surface->egl_back != NULL) {
+			assert(surface->egl_old_front == NULL);
+			surface->egl_old_front = surface->egl_front;
+			surface->egl_front = surface->egl_back;
+			surface->egl_back = NULL;
+		}
+		if (surface->egl_front->buffer_ref.buffer == NULL) {
+			weston_log("warning: client unreffed current front buffer\n");
+
+			wl_list_remove(&surface->link);
+			if (surface->handle == DISPMANX_NO_HANDLE) {
+				wl_list_init(&surface->link);
+			} else {
+				rpir_surface_dmx_remove(surface, update);
+				wl_list_insert(&output->surface_cleanup_list,
+						   &surface->link);
+			}
+
+			goto out;
+		}
+	} else {
+		if (need_swap)
+			rpir_surface_swap_pointers(surface);
+	}
 
 	obscured = is_surface_not_visible(surface->surface);
 	if (obscured) {
@@ -1133,40 +1252,72 @@ static void
 rpi_renderer_attach(struct weston_surface *base, struct weston_buffer *buffer)
 {
 	/* Called every time a client commits an attach. */
-	static int warned;
 	struct rpir_surface *surface = to_rpir_surface(base);
 
 	assert(surface);
 	if (!surface)
 		return;
 
-	if (buffer && !wl_shm_buffer_get(buffer->resource) && !warned) {
-		weston_log("Error: non-wl_shm buffers not supported.\n");
-		warned = 1;
-		return;
+	if (surface->buffer_type == BUFFER_TYPE_SHM) {
+		if (!surface->single_buffer)
+			/* XXX: need to check if in middle of update */
+			rpi_resource_release(surface->back);
+
+		if (surface->handle == DISPMANX_NO_HANDLE)
+			/* XXX: cannot do this, if middle of an update */
+			rpi_resource_release(surface->front);
+
+		weston_buffer_reference(&surface->buffer_ref, NULL);
 	}
 
+	/* If buffer is NULL, Weston core unmaps the surface, the surface
+	 * will not appear in repaint list, and so rpi_renderer_repaint_output
+	 * will remove the DispmanX element. Later, for SHM, also the front
+	 * buffer will be released in the cleanup_list processing.
+	 */
+	if (!buffer)
+		return;
+
 	if (wl_shm_buffer_get(buffer->resource)) {
+		surface->buffer_type = BUFFER_TYPE_SHM;
 		buffer->shm_buffer = wl_shm_buffer_get(buffer->resource);
 		buffer->width = wl_shm_buffer_get_width(buffer->shm_buffer);
 		buffer->height = wl_shm_buffer_get_height(buffer->shm_buffer);
-	}
 
-	weston_buffer_reference(&surface->buffer_ref, buffer);
+		weston_buffer_reference(&surface->buffer_ref, buffer);
+	} else {
+#if ENABLE_EGL
+		struct rpi_renderer *renderer = to_rpi_renderer(base->compositor);
+		struct wl_resource *wl_resource =
+			(struct wl_resource *)buffer->resource;
+
+		if (!renderer->has_bind_display ||
+		    !renderer->query_buffer(renderer->egl_display,
+					    wl_resource,
+					    EGL_WIDTH, &buffer->width)) {
+			weston_log("unhandled buffer type!\n");
+			weston_buffer_reference(&surface->buffer_ref, NULL);
+			surface->buffer_type = BUFFER_TYPE_NULL;
+		}
+
+		renderer->query_buffer(renderer->egl_display,
+				       wl_resource,
+				       EGL_HEIGHT, &buffer->height);
 
-	/* XXX: need to check if in middle of update
-	if (!buffer && !surface->single_buffer)
-		rpi_resource_release(surface->back); */
+		surface->buffer_type = BUFFER_TYPE_EGL;
 
-	/* XXX: cannot do this, if middle of an update
-	if (surface->handle == DISPMANX_NO_HANDLE)
-		rpi_resource_release(surface->front); */
+		if(surface->egl_back == NULL)
+			surface->egl_back = calloc(1, sizeof *surface->egl_back);
 
-	/* If buffer is NULL, Weston core unmaps the surface, the surface
-	 * will not appear in repaint list, and so rpi_renderer_repaint_output
-	 * will remove the DispmanX element. Later, also the front buffer
-	 * will be released in the cleanup_list processing.
-	 */
+		weston_buffer_reference(&surface->egl_back->buffer_ref, buffer);
+		surface->egl_back->resource_handle =
+			vc_dispmanx_get_handle_from_wl_buffer(wl_resource);
+#else
+		weston_log("unhandled buffer type!\n");
+		weston_buffer_reference(&surface->buffer_ref, NULL);
+		surface->buffer_type = BUFFER_TYPE_NULL;
+#endif
+	}
 }
 
 static int
@@ -1256,6 +1407,12 @@ rpi_renderer_destroy(struct weston_compositor *compositor)
 {
 	struct rpi_renderer *renderer = to_rpi_renderer(compositor);
 
+#if ENABLE_EGL
+	if (renderer->has_bind_display)
+		renderer->unbind_display(renderer->egl_display,
+		                         compositor->wl_display);
+#endif
+
 	free(renderer);
 	compositor->renderer = NULL;
 }
@@ -1265,6 +1422,11 @@ rpi_renderer_create(struct weston_compositor *compositor,
 		    const struct rpi_renderer_parameters *params)
 {
 	struct rpi_renderer *renderer;
+#if ENABLE_EGL
+	const char *extensions;
+	EGLBoolean ret;
+	EGLint major, minor;
+#endif
 
 	weston_log("Initializing the DispmanX compositing renderer\n");
 
@@ -1283,6 +1445,43 @@ rpi_renderer_create(struct weston_compositor *compositor,
 	renderer->base.destroy_surface = rpi_renderer_destroy_surface;
 	renderer->base.destroy = rpi_renderer_destroy;
 
+#ifdef ENABLE_EGL
+	renderer->egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+	if (renderer->egl_display == EGL_NO_DISPLAY) {
+		weston_log("failed to create EGL display\n");
+		return -1;
+	}
+
+	if (!eglInitialize(renderer->egl_display, &major, &minor)) {
+		weston_log("failed to initialize EGL display\n");
+		return -1;
+	}
+
+	renderer->bind_display =
+		(void *) eglGetProcAddress("eglBindWaylandDisplayWL");
+	renderer->unbind_display =
+		(void *) eglGetProcAddress("eglUnbindWaylandDisplayWL");
+	renderer->query_buffer =
+		(void *) eglGetProcAddress("eglQueryWaylandBufferWL");
+
+	extensions = (const char *) eglQueryString(renderer->egl_display,
+						   EGL_EXTENSIONS);
+	if (!extensions) {
+		weston_log("Retrieving EGL extension string failed.\n");
+		return -1;
+	}
+
+	if (strstr(extensions, "EGL_WL_bind_wayland_display"))
+		renderer->has_bind_display = 1;
+
+	if (renderer->has_bind_display) {
+		ret = renderer->bind_display(renderer->egl_display,
+					     compositor->wl_display);
+		if (!ret)
+			renderer->has_bind_display = 0;
+	}
+#endif
+
 	compositor->renderer = &renderer->base;
 	compositor->read_format = PIXMAN_a8r8g8b8;
 	/* WESTON_CAP_ROTATION_ANY not supported */
@@ -1354,6 +1553,8 @@ WL_EXPORT void
 rpi_renderer_finish_frame(struct weston_output *base)
 {
 	struct rpir_output *output = to_rpir_output(base);
+	struct weston_compositor *compositor = base->compositor;
+	struct weston_surface *ws;
 	struct rpir_surface *surface;
 
 	while (!wl_list_empty(&output->surface_cleanup_list)) {
@@ -1376,5 +1577,19 @@ rpi_renderer_finish_frame(struct weston_output *base)
 		}
 	}
 
+	wl_list_for_each(ws, &compositor->surface_list, link) {
+		surface = to_rpir_surface(ws);
+
+		if (surface->buffer_type != BUFFER_TYPE_EGL)
+			continue;
+
+		if(surface->egl_old_front == NULL)
+			continue;
+
+		weston_buffer_reference(&surface->egl_old_front->buffer_ref, NULL);
+		free(surface->egl_old_front);
+		surface->egl_old_front = NULL;
+	}
+
 	wl_signal_emit(&base->frame_signal, base);
 }

commit 8d7bef2673a63e7cb6267ef51799fc0bb07124e0
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Wed Oct 2 22:14:23 2013 -0700

    configure.ac: Bump version to 1.2.92

diff --git a/configure.ac b/configure.ac
index a43bf5b..302075e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 m4_define([weston_major_version], [1])
 m4_define([weston_minor_version], [2])
-m4_define([weston_micro_version], [91])
+m4_define([weston_micro_version], [92])
 m4_define([weston_version],
           [weston_major_version.weston_minor_version.weston_micro_version])
 

commit e05f228a5f60bdd41edfd92b12731a42110a5743
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Wed Oct 2 13:06:02 2013 -0700

    launcher: Print a more descriptive error message when we don't get a VT
    
    weston-launch has two supported use cases now: either launch from
    and VT login as a regular user (running within that session) or
    from an init script (systemd or such) with the -u option to create
    a session for the specified user.  Running from within X or ssh is
    not possible.  It's still possible to run weston as root from X or ssh
    but that's strictly a development/debug/test feature.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=69727

diff --git a/src/weston-launch.c b/src/weston-launch.c
index 1b560af..49b8964 100644
--- a/src/weston-launch.c
+++ b/src/weston-launch.c
@@ -492,6 +492,10 @@ setup_tty(struct weston_launch *wl, const char *tty)
 	if (wl->tty < 0)
 		error(1, errno, "failed to open tty");
 
+	if (fstat(wl->tty, &buf) == -1 ||
+	    major(buf.st_rdev) != TTY_MAJOR || minor(buf.st_rdev) == 0)
+		error(1, 0, "weston-launch must be run from a virtual terminal");
+
 	if (tty) {
 		if (fstat(wl->tty, &buf) < 0)
 			error(1, errno, "stat %s failed", tty);

commit 6ff3ff57aa76aa8738383cbacc4e9f425e1da056
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Wed Oct 2 10:53:33 2013 -0700

    launcher: Add back support for specifying VT to run on
    
    This is only available when running weston directly as root typically for
    ssh logins.  It's a somewhat destructive option, as it will take over any
    existing VT completely, unless there's already an display server running
    there.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=69731

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 2770c85..0ac5efa 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2564,7 +2564,7 @@ drm_compositor_create(struct wl_display *display,
 	}
 
 	/* Check if we run drm-backend using weston-launch */
-	ec->base.launcher = weston_launcher_connect(&ec->base);
+	ec->base.launcher = weston_launcher_connect(&ec->base, tty);
 	if (ec->base.launcher == NULL) {
 		weston_log("fatal: drm backend should be run "
 			   "using weston-launch binary or as root\n");
diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index f0625cd..92aefda 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -880,7 +880,8 @@ fbdev_compositor_create(struct wl_display *display, int *argc, char *argv[],
 		goto out_free;
 
 	/* Check if we run fbdev-backend using weston-launch */
-	compositor->base.launcher = weston_launcher_connect(&compositor->base);
+	compositor->base.launcher =
+		weston_launcher_connect(&compositor->base, param->tty);
 	if (compositor->base.launcher == NULL && geteuid() != 0) {
 		weston_log("fatal: fbdev backend should be run "
 			   "using weston-launch binary or as root\n");
@@ -897,7 +898,8 @@ fbdev_compositor_create(struct wl_display *display, int *argc, char *argv[],
 	compositor->session_listener.notify = session_notify;
 	wl_signal_add(&compositor->base.session_signal,
 		      &compositor->session_listener);
-	compositor->base.launcher = weston_launcher_connect(&compositor->base);
+	compositor->base.launcher =
+		weston_launcher_connect(&compositor->base, param->tty);
 	if (!compositor->base.launcher) {
 		weston_log("Failed to set up launcher.\n");
 		goto out_udev;
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index 7c5ed0e..05667fb 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -751,7 +751,8 @@ rpi_compositor_create(struct wl_display *display, int *argc, char *argv[],
 	compositor->session_listener.notify = session_notify;
 	wl_signal_add(&compositor->base.session_signal,
 		      &compositor ->session_listener);
-	compositor->base.launcher = weston_launcher_connect(&compositor->base);
+	compositor->base.launcher =
+		weston_launcher_connect(&compositor->base, param->tty);
 	if (!compositor->base.launcher) {
 		weston_log("Failed to initialize tty.\n");
 		goto out_udev;
diff --git a/src/launcher-util.c b/src/launcher-util.c
index ad93d37..6c28dc3 100644
--- a/src/launcher-util.c
+++ b/src/launcher-util.c
@@ -247,22 +247,50 @@ vt_handler(int signal_number, void *data)
 }
 
 static int
-setup_tty(struct weston_launcher *launcher)
+setup_tty(struct weston_launcher *launcher, int tty)
 {
 	struct wl_event_loop *loop;
 	struct vt_mode mode = { 0 };
 	struct stat buf;
-	int ret;
+	char tty_device[32] ="<stdin>";
+	int ret, kd_mode;
 
-	if (fstat(STDIN_FILENO, &buf) == -1 ||
+	if (tty == 0) {
+		launcher->tty = tty;
+	} else {
+		snprintf(tty_device, sizeof tty_device, "/dev/tty%d", tty);
+		launcher->tty = open(tty_device, O_RDWR | O_CLOEXEC);
+		if (launcher->tty == -1) {
+			weston_log("couldn't open tty %s: %m\n", tty_device);
+			return -1;
+		}
+	}
+
+	if (fstat(launcher->tty, &buf) == -1 ||
 	    major(buf.st_rdev) != TTY_MAJOR || minor(buf.st_rdev) == 0) {
-		weston_log("stdin not a vt\n");
+		weston_log("%s not a vt\n", tty_device);
 		weston_log("if running weston from ssh, "
 			   "use --tty to specify a tty\n");
 		return -1;
 	}
 
-	launcher->tty = STDIN_FILENO;
+	ret = ioctl(launcher->tty, KDGETMODE, &kd_mode);
+	if (ret) {
+		weston_log("failed to get VT mode: %m\n");
+		return -1;
+	}
+	if (kd_mode != KD_TEXT) {
+		weston_log("%s is already in graphics mode, "
+			   "is another display server running?\n", tty_device);
+		return -1;
+	}
+
+	ret = ioctl(launcher->tty, VT_ACTIVATE, minor(buf.st_rdev));
+	weston_log("VT_ACTIVATE ret=%d, %m vt\n", ret);
+
+	ret = ioctl(launcher->tty, VT_WAITACTIVE, minor(buf.st_rdev));
+	weston_log("VT_WAITACTIVE ret=%d, %m vt\n", ret);
+
 	if (ioctl(launcher->tty, KDGKBMODE, &launcher->kb_mode)) {
 		weston_log("failed to read keyboard mode: %m\n");
 		return -1;
@@ -304,7 +332,7 @@ weston_launcher_activate_vt(struct weston_launcher *launcher, int vt)
 }
 
 struct weston_launcher *
-weston_launcher_connect(struct weston_compositor *compositor)
+weston_launcher_connect(struct weston_compositor *compositor, int tty)
 {
 	struct weston_launcher *launcher;
 	struct wl_event_loop *loop;
@@ -328,7 +356,7 @@ weston_launcher_connect(struct weston_compositor *compositor)
 			return NULL;
 		}
 	} else if (geteuid() == 0) {
-		if (setup_tty(launcher) == -1) {
+		if (setup_tty(launcher, tty) == -1) {
 			free(launcher);
 			return NULL;
 		}
diff --git a/src/launcher-util.h b/src/launcher-util.h
index ab66916..3e7ceb5 100644
--- a/src/launcher-util.h
+++ b/src/launcher-util.h
@@ -30,7 +30,7 @@
 struct weston_launcher;
 
 struct weston_launcher *
-weston_launcher_connect(struct weston_compositor *compositor);
+weston_launcher_connect(struct weston_compositor *compositor, int tty);
 
 void
 weston_launcher_destroy(struct weston_launcher *launcher);

commit 1468e60647db296c7eeaebe7021de26cbe4a56f9
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Wed Oct 2 10:49:05 2013 -0700

    launcher: Bail out if we can't be drm master
    
    If we can't be drm master, we won't be able to do anything useful with
    the drm device.

diff --git a/src/launcher-util.c b/src/launcher-util.c
index 88eb06a..ad93d37 100644
--- a/src/launcher-util.c
+++ b/src/launcher-util.c
@@ -110,9 +110,11 @@ weston_launcher_open(struct weston_launcher *launcher,
 		}
 
 		if (major(s.st_rdev) == DRM_MAJOR) {
+			drm_magic_t magic;
 			launcher->drm_fd = fd;
-			if (drm_set_master(fd) == -1) {
-				weston_log("could not set master on drm fd\n");
+			if (drmGetMagic(fd, &magic) != 0 ||
+			    drmAuthMagic(fd, magic) != 0) {
+				weston_log("drm fd not master\n");
 				close(fd);
 				return -1;
 			}

commit 57a10e4d136a7d3e5c1260184f38fd5133a5998a
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Oct 1 15:37:09 2013 -0700

    launcher: Set make sure we're drm master when opening the drm device
    
    In case we try to run on a tty where some other process is already
    drm master, back off and exit with an error message.

diff --git a/src/launcher-util.c b/src/launcher-util.c
index 237f8c5..88eb06a 100644
--- a/src/launcher-util.c
+++ b/src/launcher-util.c
@@ -65,6 +65,26 @@ struct weston_launcher {
 	struct wl_event_source *vt_source;
 };
 
+#ifdef BUILD_DRM_COMPOSITOR
+static int
+drm_drop_master(int drm_fd)
+{
+	if (drm_fd != -1)
+		return drmDropMaster(drm_fd);
+	return -EBADF;
+}
+static int
+drm_set_master(int drm_fd)
+{
+	if (drm_fd != -1)
+		return drmSetMaster(drm_fd);
+	return -EBADF;
+}
+#else
+static int drm_drop_master(int drm_fd) {return 0;}
+static int drm_set_master(int drm_fd) {return 0;}
+#endif
+
 int
 weston_launcher_open(struct weston_launcher *launcher,
 		     const char *path, int flags)
@@ -81,7 +101,6 @@ weston_launcher_open(struct weston_launcher *launcher,
 
 	if (launcher->fd == -1) {
 		fd = open(path, flags | O_CLOEXEC);
-
 		if (fd == -1)
 			return -1;
 
@@ -90,8 +109,14 @@ weston_launcher_open(struct weston_launcher *launcher,
 			return -1;
 		}
 
-		if (major(s.st_rdev) == DRM_MAJOR)
+		if (major(s.st_rdev) == DRM_MAJOR) {
 			launcher->drm_fd = fd;
+			if (drm_set_master(fd) == -1) {
+				weston_log("could not set master on drm fd\n");
+				close(fd);
+				return -1;
+			}
+		}
 
 		return fd;
 	}


Reply to: