[PATCH 3/2 weston] clickdot: Add --debug option to preserve useful behavior.

Scott Moreau oreaus at gmail.com
Fri Nov 9 01:20:33 PST 2012


---

Hi Pekka,

Thanks for the review. Here is a patch that could be applied on top to
preserve the original behavior.

 clients/clickdot.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/clients/clickdot.c b/clients/clickdot.c
index b04db6b..9e3def0 100644
--- a/clients/clickdot.c
+++ b/clients/clickdot.c
@@ -52,7 +52,7 @@ struct clickdot {
 		int32_t old_x, old_y;
 	} line;
 
-	int reset, clicked;
+	int reset, clicked, debug;
 };
 
 static void
@@ -153,14 +153,18 @@ redraw_handler(struct widget *widget, void *data)
 	cairo_set_source_rgba(cr, 0, 0, 0, 0.8);
 	cairo_fill(cr);
 
-	if (clickdot->clicked)
+	if (clickdot->debug)
 		draw_line(clickdot, cr, &allocation);
-	else if (clickdot->buffer) {
-		cairo_surface_destroy(clickdot->buffer);
-		clickdot->buffer =
-			cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
-						   allocation.width,
-						   allocation.height);
+	else {
+		if (clickdot->clicked)
+			draw_line(clickdot, cr, &allocation);
+		else if (clickdot->buffer) {
+			cairo_surface_destroy(clickdot->buffer);
+			clickdot->buffer =
+				cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
+							   allocation.width,
+							   allocation.height);
+		}
 	}
 
 	window_get_allocation(clickdot->window, &window);
@@ -225,7 +229,8 @@ button_handler(struct widget *widget,
 		clickdot->dot.rh = (float) clickdot->dot.y / allocation.height;
 		clickdot->clicked = 1;
 	} else {
-		clickdot->reset = 1;
+		if (!clickdot->debug)
+			clickdot->reset = 1;
 		clickdot->clicked = 0;
 	}
 
@@ -330,6 +335,9 @@ main(int argc, char *argv[])
 
 	clickdot = clickdot_create(display);
 
+	if (argc > 1 && !strcmp(argv[1], "--debug"))
+		clickdot->debug = 1;
+
 	display_run(display);
 
 	clickdot_destroy(clickdot);
-- 
1.7.11.7



More information about the wayland-devel mailing list