[PATCH] wscreensaver: get decorations back

Pekka Paalanen ppaalanen at gmail.com
Tue Jan 17 06:10:41 PST 2012


In the great toytoolkit widget revolution, wscreensaver demo mode lost
its window decorations. Bring them back.

Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 clients/wscreensaver.c |   61 ++++++++++++++++++-----------------------------
 1 files changed, 23 insertions(+), 38 deletions(-)

diff --git a/clients/wscreensaver.c b/clients/wscreensaver.c
index a66cc8b..27364f0 100644
--- a/clients/wscreensaver.c
+++ b/clients/wscreensaver.c
@@ -69,9 +69,7 @@ frame_callback(void *data, struct wl_callback *callback, uint32_t time)
 	struct ModeInfo *mi = data;
 
 	window_schedule_redraw(mi->window);
-
-	if (callback)
-		wl_callback_destroy(callback);
+	wl_callback_destroy(callback);
 }
 
 static const struct wl_callback_listener listener = {
@@ -172,62 +170,49 @@ errout:
 }
 
 static struct ModeInfo *
-create_modeinfo(struct wscreensaver *wscr, struct window *window)
+create_wscreensaver_instance(struct wscreensaver *screensaver,
+			     struct wl_output *output, int width, int height)
 {
+	static int instance;
 	struct ModeInfo *mi;
 	struct rectangle drawarea;
-	static int instance;
 
 	mi = calloc(1, sizeof *mi);
 	if (!mi)
 		return NULL;
 
-	window_get_allocation(window, &drawarea);
-
-	mi->priv = wscr;
-	mi->eglctx = EGL_NO_CONTEXT;
-
-	mi->window = window;
-	mi->widget = window_add_widget(window, mi);
-	widget_set_redraw_handler(mi->widget, redraw_handler);
-
-	mi->instance_number = instance++; /* XXX */
-	mi->width = drawarea.width;
-	mi->height = drawarea.height;
-
-	return mi;
-}
-
-static struct ModeInfo *
-create_wscreensaver_instance(struct wscreensaver *screensaver,
-			     struct wl_output *output, int width, int height)
-{
-	struct ModeInfo *mi;
-	struct window *window;
-	
-	window = window_create(screensaver->display, width, height);
-	if (!window) {
+	mi->window = window_create(screensaver->display, width, height);
+	if (!mi->window) {
 		fprintf(stderr, "%s: creating a window failed.\n", progname);
+		free(mi);
 		return NULL;
 	}
 
-	window_set_transparent(window, 0);
-	window_set_title(window, progname);
+	window_set_transparent(mi->window, 0);
+	window_set_title(mi->window, progname);
 
 	if (screensaver->interface) {
-		window_set_custom(window);
+		window_set_custom(mi->window);
+		mi->widget = window_add_widget(mi->window, mi);
 		screensaver_set_surface(screensaver->interface,
-					window_get_wl_shell_surface(window),
+					window_get_wl_shell_surface(mi->window),
 					output);
+	} else {
+		mi->widget = frame_create(mi->window, mi);
 	}
+	widget_set_redraw_handler(mi->widget, redraw_handler);
 
-	mi = create_modeinfo(screensaver, window);
-	if (!mi)
-		return NULL;
+	mi->priv = screensaver;
+	mi->eglctx = EGL_NO_CONTEXT;
+	mi->instance_number = instance++; /* XXX */
+
+	widget_get_allocation(mi->widget, &drawarea);
+	mi->width = drawarea.width;
+	mi->height = drawarea.height;
 
 	screensaver->plugin->init(mi);
 
-	frame_callback(mi, NULL, 0);
+	window_schedule_resize(mi->window, width, height);
 	return mi;
 }
 
-- 
1.7.3.4



More information about the wayland-devel mailing list