window: Dont take width and height in window constructor

Always set this by scheduling an initial resize.
This commit is contained in:
Kristian Høgsberg 2012-01-31 15:24:48 -05:00
parent 8e054f76cc
commit 009ac0a965
15 changed files with 32 additions and 37 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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");

View File

@ -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;
}

View File

@ -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);

View File

@ -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");

View File

@ -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;

View File

@ -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;

View File

@ -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");

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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);