[PATCH weston 14/15] libweston: expose the wayland backend API

Giulio Camuffo giuliocamuffo at gmail.com
Thu Nov 6 12:41:33 PST 2014


---
 Makefile.am              |  1 +
 src/compositor-wayland.c | 37 ++++++++++++++++++-----------------
 src/compositor-wayland.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+), 18 deletions(-)
 create mode 100644 src/compositor-wayland.h

diff --git a/Makefile.am b/Makefile.am
index 3d732de..dcc0488 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -171,6 +171,7 @@ westoninclude_HEADERS =				\
 	src/compositor.h			\
 	src/compositor-x11.h			\
 	src/compositor-drm.h			\
+	src/compositor-wayland.h		\
 	src/weston-launcher.h			\
 	shared/matrix.h				\
 	shared/config-parser.h			\
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 40d6f64..f9e5e8f 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -37,6 +37,7 @@
 #include <wayland-cursor.h>
 
 #include "compositor.h"
+#include "compositor-wayland.h"
 #include "gl-renderer.h"
 #include "pixman-renderer.h"
 #include "../shared/image-loader.h"
@@ -733,7 +734,7 @@ wayland_output_resize_surface(struct wayland_output *output)
 		buffer->output = NULL;
 }
 
-static int
+WL_EXPORT int
 wayland_output_set_windowed(struct wayland_output *output)
 {
 	struct wayland_backend *b =
@@ -778,9 +779,9 @@ wayland_output_set_windowed(struct wayland_output *output)
 	return 0;
 }
 
-static void
+WL_EXPORT void
 wayland_output_set_fullscreen(struct wayland_output *output,
-			      enum wl_shell_surface_fullscreen_method method,
+			      enum wayland_backend_fullscreen_method method,
 			      uint32_t framerate, struct wl_output *target)
 {
 	struct wayland_backend *b =
@@ -966,7 +967,7 @@ err_output:
 	return -1;
 }
 
-static struct wayland_output *
+WL_EXPORT struct wayland_output *
 wayland_output_create(struct wayland_backend *b, int x, int y,
 		      int width, int height, const char *name, int fullscreen,
 		      uint32_t transform, int32_t scale)
@@ -1923,13 +1924,14 @@ fullscreen_binding(struct weston_seat *seat_base, uint32_t time, uint32_t key,
 	weston_output_schedule_repaint(&input->output->base);
 }
 
-static struct wayland_backend *
+WL_EXPORT struct wayland_backend *
 wayland_backend_create(struct weston_compositor *compositor, int use_pixman,
 		       const char *display_name,
-		       const char *cursor_theme, int cursor_size)
+		       const char *cursor_theme, int cursor_size, int sprawl)
 {
 	struct wayland_backend *b;
 	struct wl_event_loop *loop;
+	struct wayland_parent_output *poutput;
 	int fd;
 
 	b = zalloc(sizeof *b);
@@ -1994,6 +1996,16 @@ wayland_backend_create(struct weston_compositor *compositor, int use_pixman,
 
 	wl_event_source_check(b->parent.wl_source);
 
+	if (sprawl || b->parent.fshell) {
+		b->sprawl_across_outputs = 1;
+		wl_display_roundtrip(b->parent.wl_display);
+
+		wl_list_for_each(poutput, &b->parent.output_list, link)
+		wayland_output_create_for_parent_output(b, poutput);
+
+		return 0;
+	}
+
 	compositor->backend = &b->base;
 	return b;
 err_renderer:
@@ -2034,7 +2046,6 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
 {
 	struct wayland_backend *b;
 	struct wayland_output *output;
-	struct wayland_parent_output *poutput;
 	struct weston_config_section *section;
 	int x, count, width, height, scale, use_pixman, fullscreen, sprawl;
 	const char *section_name, *display_name;
@@ -2069,21 +2080,11 @@ backend_init(struct weston_compositor *compositor, int *argc, char *argv[],
 	weston_config_section_get_int(section, "cursor-size", &size, 32);
 
 	b = wayland_backend_create(compositor, use_pixman, display_name,
-				   theme, size);
+				   theme, size, sprawl);
 	free(theme);
 	if (!b)
 		return -1;
 
-	if (sprawl || b->parent.fshell) {
-		b->sprawl_across_outputs = 1;
-		wl_display_roundtrip(b->parent.wl_display);
-
-		wl_list_for_each(poutput, &b->parent.output_list, link)
-			wayland_output_create_for_parent_output(b, poutput);
-
-		return 0;
-	}
-
 	if (fullscreen) {
 		output = wayland_output_create(b, 0, 0, width, height,
 					       NULL, 1, 0, 1);
diff --git a/src/compositor-wayland.h b/src/compositor-wayland.h
new file mode 100644
index 0000000..c4d1838
--- /dev/null
+++ b/src/compositor-wayland.h
@@ -0,0 +1,51 @@
+
+#ifndef WESTON_COMPOSITOR_WAYLAND_H
+#define WESTON_COMPOSITOR_WAYLAND_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include "compositor.h"
+
+struct weston_compositor;
+struct weston_seat;
+struct wayland_backend;
+struct wayland_output;
+
+enum wayland_backend_fullscreen_method {
+	WESTON_WAYLAND_BACKEND_FULLSCREEN_METHOD_DEFAULT = 0,
+	WESTON_WAYLAND_BACKEND_FULLSCREEN_METHOD_SCALE = 1,
+	WESTON_WAYLAND_BACKEND_FULLSCREEN_METHOD_DRIVER = 2,
+	WESTON_WAYLAND_BACKEND_FULLSCREEN_METHOD_FILL = 3,
+};
+
+struct wayland_backend *
+wayland_backend_create(struct weston_compositor *c, int use_pixman,
+		       const char *display_name,
+		       const char *cursor_theme, int cursor_size,
+		       int sprawl);
+
+struct wayland_output *
+wayland_output_create(struct wayland_backend *b, int x, int y,
+		      int width, int height, const char *name, int fullscreen,
+		      uint32_t transform, int32_t scale);
+int
+wayland_output_is_fullscreen(struct wayland_output *output);
+int
+wayland_output_set_windowed(struct wayland_output *output);
+void
+wayland_output_set_fullscreen(struct wayland_output *output,
+			      enum wayland_backend_fullscreen_method method,
+			      uint32_t framerate, struct wl_output *target);
+struct weston_output *
+wayland_output_get_base(struct wayland_output *o);
+struct wayland_output *
+wayland_backend_find_output(struct wayland_backend *b,
+			    struct weston_seat *seat);
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
-- 
2.1.3



More information about the wayland-devel mailing list