[PATCH weston] toytoolkit: avoid redrawing a window between when it asks to be maximized and when it gets the configure

MoD mod-oss at hush.ai
Mon Feb 25 16:02:47 PST 2013


This patch is intended to resolve a bad frame that is visible when maximizing 
toytoolkit programs by clicking the maximize button in their decorations. The
issue, as far as I can tell, is that toytoolkit queues a draw to restore the
button to its unclicked state at the same time it asks for its shell surface to
be maximized. It then ends up drawing a small window on a large, maximized
surface in the top-left corner of the screen. This patch adds a flag to the
window which indicates that a resize has been requested but not received, and
avoids drawing until a configure is received.

I'm not sure this is the best way to perform the logic, though: this assumes
that other parts of window.c might try to draw in similar scenarios and will
handle those, but it may be preferable to simply avoid scheduling the button's
redraw in the button-press callback when we're going to request a maximize.

Comments would be appreciated.
MoD
---
 clients/window.c | 49 +++++++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 249ba6f..e8d2561 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -218,6 +218,7 @@ struct window {
 	int redraw_needed;
 	struct task redraw_task;
 	int resize_needed;
+	int resize_requested;
 	int type;
 	int focus_count;
 
@@ -1899,6 +1900,28 @@ frame_button_button_handler(struct widget *widget,
 	if (button != BTN_LEFT)
 		return;
 
+	if (was_pressed)
+	{
+		switch (frame_button->type) {
+		case FRAME_BUTTON_CLOSE:
+			if (window->close_handler)
+				window->close_handler(window->parent,
+							  window->user_data);
+			else
+				display_exit(window->display);
+			break;
+		case FRAME_BUTTON_MINIMIZE:
+			fprintf(stderr,"Minimize stub\n");
+			break;
+		case FRAME_BUTTON_MAXIMIZE:
+			window_set_maximized(window, window->type != TYPE_MAXIMIZED);
+			break;
+		default:
+			/* Unknown operation */
+			break;
+		}
+	}
+
 	switch (state) {
 	case WL_POINTER_BUTTON_STATE_PRESSED:
 		frame_button->state = FRAME_BUTTON_ACTIVE;
@@ -1912,28 +1935,6 @@ frame_button_button_handler(struct widget *widget,
 		widget_schedule_redraw(frame_button->widget);
 		break;
 	}
-
-	if (!was_pressed)
-		return;
-
-	switch (frame_button->type) {
-	case FRAME_BUTTON_CLOSE:
-		if (window->close_handler)
-			window->close_handler(window->parent,
-					      window->user_data);
-		else
-			display_exit(window->display);
-		break;
-	case FRAME_BUTTON_MINIMIZE:
-		fprintf(stderr,"Minimize stub\n");
-		break;
-	case FRAME_BUTTON_MAXIMIZE:
-		window_set_maximized(window, window->type != TYPE_MAXIMIZED);
-		break;
-	default:
-		/* Unknown operation */
-		break;
-	}
 }
 
 static int
@@ -3285,6 +3286,7 @@ handle_configure(void *data, struct wl_shell_surface *shell_surface,
 {
 	struct window *window = data;
 
+	window->resize_requested = 0;
 	window->resize_edges = edges;
 	window_schedule_resize(window, width, height);
 }
@@ -3374,6 +3376,8 @@ idle_redraw(struct task *task, uint32_t events)
 void
 window_schedule_redraw(struct window *window)
 {
+	if (window->resize_requested)
+		return;
 	window->redraw_needed = 1;
 	if (!window->redraw_scheduled) {
 		window->redraw_task.run = idle_redraw;
@@ -3436,6 +3440,7 @@ window_set_maximized(struct window *window, int maximized)
 
 	if (window->type == TYPE_TOPLEVEL) {
 		window->saved_allocation = window->main_surface->allocation;
+		window->resize_requested = 1;
 		wl_shell_surface_set_maximized(window->shell_surface, NULL);
 		window->type = TYPE_MAXIMIZED;
 	} else {
-- 
1.8.1.4




More information about the wayland-devel mailing list