[PATCH weston] Make border width and ball radius configurable

Seedo Eldho Paul seedoeldhopaul at gmail.com
Sat Nov 29 05:36:38 PST 2014


Also change "simple-shm exiting" to "simple-damage exiting"

Signed-off-by: Seedo Eldho Paul <seedoeldhopaul at gmail.com>
---
 clients/simple-damage.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/clients/simple-damage.c b/clients/simple-damage.c
index fe532fe..9f3d58f 100644
--- a/clients/simple-damage.c
+++ b/clients/simple-damage.c
@@ -172,8 +172,6 @@ window_init_game(struct window *window)
 	gettimeofday(&tv, NULL);
 	srand(tv.tv_usec);
 
-	window->ball.radius = 10;
-
 	ax1 = window->border + window->ball.radius;
 	ay1 = window->border + window->ball.radius;
 	ax2 = window->width - window->border - window->ball.radius;
@@ -233,8 +231,8 @@ window_advance_game(struct window *window, uint32_t timestamp)
 
 static struct window *
 create_window(struct display *display, int width, int height,
-	      enum wl_output_transform transform, int scale,
-	      enum window_flags flags)
+	      int border, int radius, enum wl_output_transform transform,
+	      int scale, enum window_flags flags)
 {
 	struct window *window;
 
@@ -268,7 +266,8 @@ create_window(struct display *display, int width, int height,
 	window->display = display;
 	window->width = width;
 	window->height = height;
-	window->border = 10;
+	window->border = border;
+	window->ball.radius = radius;
 	window->flags = flags;
 	window->transform = transform;
 	window->scale = scale;
@@ -772,6 +771,8 @@ print_usage(int retval)
 		"  --version=VERSION\tVersion of wl_surface to use\n"
 		"  --width=WIDTH\t\tWidth of the window\n"
 		"  --height=HEIGHT\tHeight of the window\n"
+		"  --border=BORDER\tBorder width of the window\n"
+		"  --radius=RADIUS\tRadius of the ball\n"
 		"  --scale=SCALE\t\tScale factor for the surface\n"
 		"  --transform=TRANSFORM\tTransform for the surface\n"
 		"  --rotating-transform\tUse a different buffer_transform for each frame\n"
@@ -818,6 +819,7 @@ main(int argc, char **argv)
 	int i, ret = 0;
 	int version = -1;
 	int width = 300, height = 200, scale = 1;
+	int border = 10, radius = 10;
 	enum wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
 	enum window_flags flags = 0;
 
@@ -839,6 +841,10 @@ main(int argc, char **argv)
 			continue;
 		} else if (sscanf(argv[i], "--height=%d", &height) > 0) {
 			continue;
+		} else if (sscanf(argv[i], "--border=%d", &border) > 0) {
+			continue;
+		} else if (sscanf(argv[i], "--radius=%d", &radius) > 0) {
+			continue;
 		} else if (strncmp(argv[i], "--transform=", 12) == 0 &&
 			   parse_transform(argv[i] + 12, &transform) > 0) {
 			continue;
@@ -858,7 +864,8 @@ main(int argc, char **argv)
 
 	display = create_display(version);
 
-	window = create_window(display, width, height, transform, scale, flags);
+	window = create_window(display, width, height, border, radius, 
+		               transform, scale, flags);
 	if (!window)
 		return 1;
 
@@ -872,7 +879,7 @@ main(int argc, char **argv)
 	while (running && ret != -1)
 		ret = wl_display_dispatch(display->display);
 
-	fprintf(stderr, "simple-shm exiting\n");
+	fprintf(stderr, "simple-damage exiting\n");
 	destroy_window(window);
 	destroy_display(display);
 
-- 
1.9.1



More information about the wayland-devel mailing list