From 57cd0ed9164a325ef87aee55b21ac317dc0e6c9e Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 17 Jan 2012 16:10:41 +0200 Subject: [PATCH] wscreensaver: get decorations back In the great toytoolkit widget revolution, wscreensaver demo mode lost its window decorations. Bring them back. Signed-off-by: Pekka Paalanen --- clients/wscreensaver.c | 61 ++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/clients/wscreensaver.c b/clients/wscreensaver.c index a66cc8bb..27364f0e 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; }