[PATCH weston 5/6] compositor-wayland: Add a --scale option

Jason Ekstrand jason at jlekstrand.net
Thu Nov 7 18:13:32 PST 2013


Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
---
 src/compositor-wayland.c | 16 ++++++++++++----
 src/compositor.c         |  1 +
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index e5c6726..e688820 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -707,7 +707,7 @@ static struct wayland_output *
 wayland_output_create_for_config(struct wayland_compositor *c,
 				 struct weston_config_section *config_section,
 				 int option_width, int option_height,
-				 int32_t x, int32_t y)
+				 int option_scale, int32_t x, int32_t y)
 {
 	struct wayland_output *output;
 	char *mode, *t, *name, *str;
@@ -756,6 +756,9 @@ wayland_output_create_for_config(struct wayland_compositor *c,
 
 	weston_config_section_get_int(config_section, "scale", &scale, 1);
 
+	if (option_scale)
+		scale = option_scale;
+
 	weston_config_section_get_string(config_section,
 					 "transform", &t, "normal");
 	transform = WL_OUTPUT_TRANSFORM_NORMAL;
@@ -1401,13 +1404,14 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
 	struct wayland_compositor *c;
 	struct wayland_output *output;
 	struct weston_config_section *section;
-	int x, count, width, height, use_pixman;
+	int x, count, width, height, scale, use_pixman;
 	const char *section_name, *display_name;
 	char *name;
 
 	const struct weston_option wayland_options[] = {
 		{ WESTON_OPTION_INTEGER, "width", 0, &width },
 		{ WESTON_OPTION_INTEGER, "height", 0, &height },
+		{ WESTON_OPTION_INTEGER, "scale", 0, &scale },
 		{ WESTON_OPTION_STRING, "display", 0, &display_name },
 		{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &use_pixman },
 		{ WESTON_OPTION_INTEGER, "output-count", 0, &count },
@@ -1415,6 +1419,7 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
 
 	width = 0;
 	height = 0;
+	scale = 0;
 	display_name = NULL;
 	use_pixman = 0;
 	count = 1;
@@ -1443,7 +1448,7 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
 		free(name);
 
 		output = wayland_output_create_for_config(c, section, width,
-							  height, x, 0);
+							  height, scale, x, 0);
 		if (!output)
 			goto err_outputs;
 
@@ -1455,8 +1460,11 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
 		width = 1024;
 	if (!height)
 		height = 640;
+	if (!scale)
+		scale = 1;
 	while (count > 0) {
-		output = wayland_output_create(c, x, 0, width, height, NULL, 0, 1);
+		output = wayland_output_create(c, x, 0, width, height,
+					       NULL, 0, scale);
 		if (!output)
 			goto err_outputs;
 
diff --git a/src/compositor.c b/src/compositor.c
index 2126742..d77d565 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3699,6 +3699,7 @@ usage(int error_code)
 		"Options for wayland-backend.so:\n\n"
 		"  --width=WIDTH\t\tWidth of Wayland surface\n"
 		"  --height=HEIGHT\tHeight of Wayland surface\n"
+ 		"  --scale=SCALE\tScale factor of ouput\n"
 		"  --use-pixman\t\tUse the pixman (CPU) renderer\n"
 		"  --output-count=COUNT\tCreate multiple outputs\n"
 		"  --display=DISPLAY\tWayland display to connect to\n\n");
-- 
1.8.3.1



More information about the wayland-devel mailing list