[PATCH 1/3] compositor: Add a switch_mode hook and a wrapper into the output.

zhiwen.wu at linux.intel.com zhiwen.wu at linux.intel.com
Tue Apr 17 02:20:47 PDT 2012


From: Alex Wu <zhiwen.wu at linux.intel.com>

This allow each output backend to switch the display mode. It is
useful to some applications like fullscreen game, xbmc.
---
 src/compositor-drm.c     |    1 +
 src/compositor-openwfd.c |    1 +
 src/compositor-wayland.c |    1 +
 src/compositor-x11.c     |    1 +
 src/compositor.c         |    9 +++++++++
 src/compositor.h         |    4 ++++
 6 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 1b0fbd0..4232f78 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1165,6 +1165,7 @@ create_output_for_connector(struct drm_compositor *ec,
 	output->base.assign_planes = drm_assign_planes;
 	output->base.read_pixels = drm_output_read_pixels;
 	output->base.set_dpms = drm_set_dpms;
+	output->base.switch_mode = NULL;
 
 	return 0;
 
diff --git a/src/compositor-openwfd.c b/src/compositor-openwfd.c
index 2dba07d..bbf1067 100644
--- a/src/compositor-openwfd.c
+++ b/src/compositor-openwfd.c
@@ -409,6 +409,7 @@ create_output_for_port(struct wfd_compositor *ec,
 	output->base.assign_planes = NULL;
 	output->base.set_backlight = NULL;
 	output->base.set_dpms = NULL;
+	output->base.switch_mode = NULL;
 
 	wl_list_insert(ec->base.output_list.prev, &output->base.link);
 
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 7a9ebde..561a68c 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -461,6 +461,7 @@ wayland_compositor_create_output(struct wayland_compositor *c,
 	output->base.read_pixels = wayland_output_read_pixels;
 	output->base.set_backlight = NULL;
 	output->base.set_dpms = NULL;
+	output->base.switch_mode = NULL;
 
 	wl_list_insert(c->base.output_list.prev, &output->base.link);
 
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 9822c2c..4a487d7 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -471,6 +471,7 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
 	output->base.read_pixels = x11_output_read_pixels;
 	output->base.set_backlight = NULL;
 	output->base.set_dpms = NULL;
+	output->base.switch_mode = NULL;
 
 	wl_list_insert(c->base.output_list.prev, &output->base.link);
 
diff --git a/src/compositor.c b/src/compositor.c
index 03f0eb1..963e50c 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -79,6 +79,15 @@ sigchld_handler(int signal_number, void *data)
 	return 1;
 }
 
+WL_EXPORT int
+weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode)
+{
+	if (!output->switch_mode)
+		return -1;
+
+	return output->switch_mode(output, mode);
+}
+
 WL_EXPORT void
 weston_watch_process(struct weston_process *process)
 {
diff --git a/src/compositor.h b/src/compositor.h
index 8fc5ab0..a0eb84b 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -98,6 +98,7 @@ struct weston_output {
 	void (*destroy)(struct weston_output *output);
 	void (*assign_planes)(struct weston_output *output);
 	void (*read_pixels)(struct weston_output *output, void *data);
+	int (*switch_mode)(struct weston_output *output, struct weston_mode *mode);
 
 	/* backlight values are on 0-255 range, where higher is brighter */
 	uint32_t backlight_current;
@@ -558,4 +559,7 @@ weston_surface_destroy(struct weston_surface *surface);
 struct weston_compositor *
 backend_init(struct wl_display *display, int argc, char *argv[]);
 
+int
+weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode);
+
 #endif
-- 
1.7.5.4



More information about the wayland-devel mailing list