From 009ac0a965708b89fe8e3db9ab862022e0395662 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 31 Jan 2012 15:24:48 -0500 Subject: [PATCH] window: Dont take width and height in window constructor Always set this by scheduling an initial resize. --- clients/clickdot.c | 2 +- clients/desktop-shell.c | 6 +++--- clients/dnd.c | 2 +- clients/eventdemo.c | 4 ++-- clients/flower.c | 4 ++-- clients/gears.c | 2 +- clients/image.c | 2 +- clients/resizor.c | 2 +- clients/smoke.c | 2 +- clients/tablet-shell.c | 10 +++------- clients/terminal.c | 4 +++- clients/view.c | 2 +- clients/window.c | 21 +++++++++------------ clients/window.h | 4 ++-- clients/wscreensaver.c | 2 +- 15 files changed, 32 insertions(+), 37 deletions(-) diff --git a/clients/clickdot.c b/clients/clickdot.c index 71bc091..cf35faa 100644 --- a/clients/clickdot.c +++ b/clients/clickdot.c @@ -130,7 +130,7 @@ clickdot_create(struct display *display) return clickdot; memset(clickdot, 0, sizeof *clickdot); - clickdot->window = window_create(display, 500, 400); + clickdot->window = window_create(display); clickdot->widget = frame_create(clickdot->window, clickdot); window_set_title(clickdot->window, "Wayland ClickDot"); clickdot->display = display; diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c index 3d5119a..db41568 100644 --- a/clients/desktop-shell.c +++ b/clients/desktop-shell.c @@ -319,7 +319,7 @@ panel_create(struct display *display) memset(panel, 0, sizeof *panel); panel->base.configure = panel_configure; - panel->window = window_create(display, 0, 0); + panel->window = window_create(display); panel->widget = window_add_widget(panel->window, panel); wl_list_init(&panel->launcher_list); @@ -542,7 +542,7 @@ unlock_dialog_create(struct desktop *desktop) return NULL; memset(dialog, 0, sizeof *dialog); - dialog->window = window_create(display, 260, 230); + dialog->window = window_create(display); dialog->widget = frame_create(dialog->window, dialog); window_set_title(dialog->window, "Unlock your desktop"); window_set_custom(dialog->window); @@ -630,7 +630,7 @@ background_create(struct desktop *desktop) memset(background, 0, sizeof *background); background->base.configure = background_configure; - background->window = window_create(desktop->display, 0, 0); + background->window = window_create(desktop->display); background->widget = window_add_widget(background->window, background); window_set_custom(background->window); window_set_user_data(background->window, background); diff --git a/clients/dnd.c b/clients/dnd.c index 632e3b9..b4a9c10 100644 --- a/clients/dnd.c +++ b/clients/dnd.c @@ -506,7 +506,7 @@ dnd_create(struct display *display) return dnd; memset(dnd, 0, sizeof *dnd); - dnd->window = window_create(display, 400, 400); + dnd->window = window_create(display); dnd->widget = frame_create(dnd->window, dnd); window_set_title(dnd->window, "Wayland Drag and Drop Demo"); diff --git a/clients/eventdemo.c b/clients/eventdemo.c index 0750cb8..7d591a7 100644 --- a/clients/eventdemo.c +++ b/clients/eventdemo.c @@ -266,7 +266,7 @@ eventdemo_create(struct display *d) if(e == NULL) return NULL; - e->window = window_create(d, width, height); + e->window = window_create(d); e->widget = frame_create(e->window, e); window_set_title(e->window, title); e->display = d; @@ -309,7 +309,7 @@ eventdemo_create(struct display *d) } /* Initial drawing of the window */ - window_schedule_redraw(e->window); + window_schedule_resize(e->window, width, height); return e; } diff --git a/clients/flower.c b/clients/flower.c index ae70d58..0565eea 100644 --- a/clients/flower.c +++ b/clients/flower.c @@ -180,7 +180,7 @@ int main(int argc, char *argv[]) flower.width = 200; flower.height = 200; flower.display = d; - flower.window = window_create(d, flower.width, flower.height); + flower.window = window_create(d); flower.widget = window_add_widget(flower.window, &flower); widget_set_resize_handler(flower.widget, resize_handler); @@ -188,7 +188,7 @@ int main(int argc, char *argv[]) widget_set_motion_handler(flower.widget, motion_handler); widget_set_button_handler(flower.widget, button_handler); - window_schedule_redraw(flower.window); + window_schedule_resize(flower.window, flower.width, flower.height); display_run(d); diff --git a/clients/gears.c b/clients/gears.c index 2b1668e..22312bd 100644 --- a/clients/gears.c +++ b/clients/gears.c @@ -313,7 +313,7 @@ gears_create(struct display *display) gears = malloc(sizeof *gears); memset(gears, 0, sizeof *gears); gears->d = display; - gears->window = window_create(display, width, height); + gears->window = window_create(display); gears->widget = frame_create(gears->window, gears); window_set_transparent(gears->window, 1); window_set_title(gears->window, "Wayland Gears"); diff --git a/clients/image.c b/clients/image.c index 7ffe20a..8f621eb 100644 --- a/clients/image.c +++ b/clients/image.c @@ -205,7 +205,7 @@ image_create(struct display *display, const char *filename) image->filename = g_strdup(filename); - image->window = window_create(display, 500, 400); + image->window = window_create(display); image->widget = frame_create(image->window, image); window_set_title(image->window, title); image->display = display; diff --git a/clients/resizor.c b/clients/resizor.c index 15900fc..9f9e1b5 100644 --- a/clients/resizor.c +++ b/clients/resizor.c @@ -201,7 +201,7 @@ resizor_create(struct display *display) return resizor; memset(resizor, 0, sizeof *resizor); - resizor->window = window_create(display, 500, 400); + resizor->window = window_create(display); resizor->widget = frame_create(resizor->window, resizor); window_set_title(resizor->window, "Wayland Resizor"); resizor->display = display; diff --git a/clients/smoke.c b/clients/smoke.c index 2405d42..c1665ce 100644 --- a/clients/smoke.c +++ b/clients/smoke.c @@ -267,7 +267,7 @@ int main(int argc, char *argv[]) smoke.width = 200; smoke.height = 200; smoke.display = d; - smoke.window = window_create(d, smoke.width, smoke.height); + smoke.window = window_create(d); smoke.widget = window_add_widget(smoke.window, &smoke); window_set_title(smoke.window, "smoke"); diff --git a/clients/tablet-shell.c b/clients/tablet-shell.c index 1a647e8..fd772af 100644 --- a/clients/tablet-shell.c +++ b/clients/tablet-shell.c @@ -213,9 +213,7 @@ show_lockscreen(void *data, struct tablet_shell *tablet_shell) { struct tablet_shell *shell = data; - shell->lockscreen = window_create(shell->display, - shell->allocation.width, - shell->allocation.height); + shell->lockscreen = window_create(shell->display); window_set_user_data(shell->lockscreen, shell); window_set_custom(shell->lockscreen); @@ -229,7 +227,7 @@ show_switcher(void *data, struct tablet_shell *tablet_shell) { struct tablet_shell *shell = data; - shell->switcher = window_create(shell->display, 0, 0); + shell->switcher = window_create(shell->display); window_set_user_data(shell->switcher, shell); window_set_custom(shell->switcher); tablet_shell_set_switcher(shell->tablet_shell, @@ -264,9 +262,7 @@ tablet_shell_create(struct display *display, uint32_t id) output = display_get_output(display); output_get_allocation(output, &shell->allocation); - shell->homescreen = window_create(display, - shell->allocation.width, - shell->allocation.height); + shell->homescreen = window_create(display); window_set_user_data(shell->homescreen, shell); window_set_custom(shell->homescreen); diff --git a/clients/terminal.c b/clients/terminal.c index e5baa0e..0792ecc 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -2269,7 +2269,7 @@ terminal_create(struct display *display, int fullscreen) terminal_init(terminal); terminal->margin_top = 0; terminal->margin_bottom = -1; - terminal->window = window_create(display, 500, 400); + terminal->window = window_create(display); terminal->widget = frame_create(terminal->window, terminal); window_set_title(terminal->window, "Wayland Terminal"); @@ -2307,6 +2307,8 @@ terminal_create(struct display *display, int fullscreen) cairo_destroy(cr); cairo_surface_destroy(surface); + window_schedule_resize(terminal->window, 500, 400); + return terminal; } diff --git a/clients/view.c b/clients/view.c index 6736826..2ee22bc 100644 --- a/clients/view.c +++ b/clients/view.c @@ -233,7 +233,7 @@ view_create(struct display *display, title = "File not found"; } - view->window = window_create(display, 500, 400); + view->window = window_create(display); view->widget = frame_create(view->window, view); window_set_title(view->window, title); view->display = display; diff --git a/clients/window.c b/clients/window.c index 2613b3c..bb17b8a 100644 --- a/clients/window.c +++ b/clients/window.c @@ -2271,8 +2271,7 @@ window_damage(struct window *window, int32_t x, int32_t y, } static struct window * -window_create_internal(struct display *display, struct window *parent, - int32_t width, int32_t height) +window_create_internal(struct display *display, struct window *parent) { struct window *window; @@ -2291,8 +2290,8 @@ window_create_internal(struct display *display, struct window *parent, } window->allocation.x = 0; window->allocation.y = 0; - window->allocation.width = width; - window->allocation.height = height; + window->allocation.width = 0; + window->allocation.height = 0; window->saved_allocation = window->allocation; window->transparent = 1; @@ -2319,11 +2318,11 @@ window_create_internal(struct display *display, struct window *parent, } struct window * -window_create(struct display *display, int32_t width, int32_t height) +window_create(struct display *display) { struct window *window; - window = window_create_internal(display, NULL, width, height); + window = window_create_internal(display, NULL); if (!window) return NULL; @@ -2332,12 +2331,11 @@ window_create(struct display *display, int32_t width, int32_t height) struct window * window_create_transient(struct display *display, struct window *parent, - int32_t x, int32_t y, int32_t width, int32_t height) + int32_t x, int32_t y) { struct window *window; - window = window_create_internal(parent->display, - parent, width, height); + window = window_create_internal(parent->display, parent); if (!window) return NULL; @@ -2468,8 +2466,7 @@ window_show_menu(struct display *display, if (!menu) return; - window = window_create_internal(parent->display, parent, - 200, count * 20 + margin * 2); + window = window_create_internal(parent->display, parent); if (!window) return; @@ -2497,7 +2494,7 @@ window_show_menu(struct display *display, widget_set_button_handler(menu->widget, menu_button_handler); input_grab(input, menu->widget, 0); - window_schedule_redraw(window); + window_schedule_resize(window, 200, count * 20 + margin * 2); } void diff --git a/clients/window.h b/clients/window.h index 15a556e..a199f6f 100644 --- a/clients/window.h +++ b/clients/window.h @@ -193,10 +193,10 @@ typedef void (*widget_button_handler_t)(struct widget *widget, int button, int state, void *data); struct window * -window_create(struct display *display, int32_t width, int32_t height); +window_create(struct display *display); struct window * window_create_transient(struct display *display, struct window *parent, - int32_t x, int32_t y, int32_t width, int32_t height); + int32_t x, int32_t y); typedef void (*menu_func_t)(struct window *window, int index, void *data); diff --git a/clients/wscreensaver.c b/clients/wscreensaver.c index 27364f0..414b8c9 100644 --- a/clients/wscreensaver.c +++ b/clients/wscreensaver.c @@ -181,7 +181,7 @@ create_wscreensaver_instance(struct wscreensaver *screensaver, if (!mi) return NULL; - mi->window = window_create(screensaver->display, width, height); + mi->window = window_create(screensaver->display); if (!mi->window) { fprintf(stderr, "%s: creating a window failed.\n", progname); free(mi); -- 2.7.4