window: Dont take width and height in window constructor

Always set this by scheduling an initial resize.
dev
Kristian Høgsberg 13 years ago
parent 8e054f76cc
commit 009ac0a965
  1. 2
      clients/clickdot.c
  2. 6
      clients/desktop-shell.c
  3. 2
      clients/dnd.c
  4. 4
      clients/eventdemo.c
  5. 4
      clients/flower.c
  6. 2
      clients/gears.c
  7. 2
      clients/image.c
  8. 2
      clients/resizor.c
  9. 2
      clients/smoke.c
  10. 10
      clients/tablet-shell.c
  11. 4
      clients/terminal.c
  12. 2
      clients/view.c
  13. 21
      clients/window.c
  14. 4
      clients/window.h
  15. 2
      clients/wscreensaver.c

@ -130,7 +130,7 @@ clickdot_create(struct display *display)
return clickdot; return clickdot;
memset(clickdot, 0, sizeof *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); clickdot->widget = frame_create(clickdot->window, clickdot);
window_set_title(clickdot->window, "Wayland ClickDot"); window_set_title(clickdot->window, "Wayland ClickDot");
clickdot->display = display; clickdot->display = display;

@ -319,7 +319,7 @@ panel_create(struct display *display)
memset(panel, 0, sizeof *panel); memset(panel, 0, sizeof *panel);
panel->base.configure = panel_configure; 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); panel->widget = window_add_widget(panel->window, panel);
wl_list_init(&panel->launcher_list); wl_list_init(&panel->launcher_list);
@ -542,7 +542,7 @@ unlock_dialog_create(struct desktop *desktop)
return NULL; return NULL;
memset(dialog, 0, sizeof *dialog); memset(dialog, 0, sizeof *dialog);
dialog->window = window_create(display, 260, 230); dialog->window = window_create(display);
dialog->widget = frame_create(dialog->window, dialog); dialog->widget = frame_create(dialog->window, dialog);
window_set_title(dialog->window, "Unlock your desktop"); window_set_title(dialog->window, "Unlock your desktop");
window_set_custom(dialog->window); window_set_custom(dialog->window);
@ -630,7 +630,7 @@ background_create(struct desktop *desktop)
memset(background, 0, sizeof *background); memset(background, 0, sizeof *background);
background->base.configure = background_configure; 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); background->widget = window_add_widget(background->window, background);
window_set_custom(background->window); window_set_custom(background->window);
window_set_user_data(background->window, background); window_set_user_data(background->window, background);

@ -506,7 +506,7 @@ dnd_create(struct display *display)
return dnd; return dnd;
memset(dnd, 0, sizeof *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); dnd->widget = frame_create(dnd->window, dnd);
window_set_title(dnd->window, "Wayland Drag and Drop Demo"); window_set_title(dnd->window, "Wayland Drag and Drop Demo");

@ -266,7 +266,7 @@ eventdemo_create(struct display *d)
if(e == NULL) if(e == NULL)
return NULL; return NULL;
e->window = window_create(d, width, height); e->window = window_create(d);
e->widget = frame_create(e->window, e); e->widget = frame_create(e->window, e);
window_set_title(e->window, title); window_set_title(e->window, title);
e->display = d; e->display = d;
@ -309,7 +309,7 @@ eventdemo_create(struct display *d)
} }
/* Initial drawing of the window */ /* Initial drawing of the window */
window_schedule_redraw(e->window); window_schedule_resize(e->window, width, height);
return e; return e;
} }

@ -180,7 +180,7 @@ int main(int argc, char *argv[])
flower.width = 200; flower.width = 200;
flower.height = 200; flower.height = 200;
flower.display = d; 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); flower.widget = window_add_widget(flower.window, &flower);
widget_set_resize_handler(flower.widget, resize_handler); 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_motion_handler(flower.widget, motion_handler);
widget_set_button_handler(flower.widget, button_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); display_run(d);

@ -313,7 +313,7 @@ gears_create(struct display *display)
gears = malloc(sizeof *gears); gears = malloc(sizeof *gears);
memset(gears, 0, sizeof *gears); memset(gears, 0, sizeof *gears);
gears->d = display; gears->d = display;
gears->window = window_create(display, width, height); gears->window = window_create(display);
gears->widget = frame_create(gears->window, gears); gears->widget = frame_create(gears->window, gears);
window_set_transparent(gears->window, 1); window_set_transparent(gears->window, 1);
window_set_title(gears->window, "Wayland Gears"); window_set_title(gears->window, "Wayland Gears");

@ -205,7 +205,7 @@ image_create(struct display *display, const char *filename)
image->filename = g_strdup(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); image->widget = frame_create(image->window, image);
window_set_title(image->window, title); window_set_title(image->window, title);
image->display = display; image->display = display;

@ -201,7 +201,7 @@ resizor_create(struct display *display)
return resizor; return resizor;
memset(resizor, 0, sizeof *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); resizor->widget = frame_create(resizor->window, resizor);
window_set_title(resizor->window, "Wayland Resizor"); window_set_title(resizor->window, "Wayland Resizor");
resizor->display = display; resizor->display = display;

@ -267,7 +267,7 @@ int main(int argc, char *argv[])
smoke.width = 200; smoke.width = 200;
smoke.height = 200; smoke.height = 200;
smoke.display = d; 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); smoke.widget = window_add_widget(smoke.window, &smoke);
window_set_title(smoke.window, "smoke"); window_set_title(smoke.window, "smoke");

@ -213,9 +213,7 @@ show_lockscreen(void *data, struct tablet_shell *tablet_shell)
{ {
struct tablet_shell *shell = data; struct tablet_shell *shell = data;
shell->lockscreen = window_create(shell->display, shell->lockscreen = window_create(shell->display);
shell->allocation.width,
shell->allocation.height);
window_set_user_data(shell->lockscreen, shell); window_set_user_data(shell->lockscreen, shell);
window_set_custom(shell->lockscreen); window_set_custom(shell->lockscreen);
@ -229,7 +227,7 @@ show_switcher(void *data, struct tablet_shell *tablet_shell)
{ {
struct tablet_shell *shell = data; 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_user_data(shell->switcher, shell);
window_set_custom(shell->switcher); window_set_custom(shell->switcher);
tablet_shell_set_switcher(shell->tablet_shell, 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 = display_get_output(display);
output_get_allocation(output, &shell->allocation); output_get_allocation(output, &shell->allocation);
shell->homescreen = window_create(display, shell->homescreen = window_create(display);
shell->allocation.width,
shell->allocation.height);
window_set_user_data(shell->homescreen, shell); window_set_user_data(shell->homescreen, shell);
window_set_custom(shell->homescreen); window_set_custom(shell->homescreen);

@ -2269,7 +2269,7 @@ terminal_create(struct display *display, int fullscreen)
terminal_init(terminal); terminal_init(terminal);
terminal->margin_top = 0; terminal->margin_top = 0;
terminal->margin_bottom = -1; terminal->margin_bottom = -1;
terminal->window = window_create(display, 500, 400); terminal->window = window_create(display);
terminal->widget = frame_create(terminal->window, terminal); terminal->widget = frame_create(terminal->window, terminal);
window_set_title(terminal->window, "Wayland Terminal"); window_set_title(terminal->window, "Wayland Terminal");
@ -2307,6 +2307,8 @@ terminal_create(struct display *display, int fullscreen)
cairo_destroy(cr); cairo_destroy(cr);
cairo_surface_destroy(surface); cairo_surface_destroy(surface);
window_schedule_resize(terminal->window, 500, 400);
return terminal; return terminal;
} }

@ -233,7 +233,7 @@ view_create(struct display *display,
title = "File not found"; title = "File not found";
} }
view->window = window_create(display, 500, 400); view->window = window_create(display);
view->widget = frame_create(view->window, view); view->widget = frame_create(view->window, view);
window_set_title(view->window, title); window_set_title(view->window, title);
view->display = display; view->display = display;

@ -2271,8 +2271,7 @@ window_damage(struct window *window, int32_t x, int32_t y,
} }
static struct window * static struct window *
window_create_internal(struct display *display, struct window *parent, window_create_internal(struct display *display, struct window *parent)
int32_t width, int32_t height)
{ {
struct window *window; struct window *window;
@ -2291,8 +2290,8 @@ window_create_internal(struct display *display, struct window *parent,
} }
window->allocation.x = 0; window->allocation.x = 0;
window->allocation.y = 0; window->allocation.y = 0;
window->allocation.width = width; window->allocation.width = 0;
window->allocation.height = height; window->allocation.height = 0;
window->saved_allocation = window->allocation; window->saved_allocation = window->allocation;
window->transparent = 1; window->transparent = 1;
@ -2319,11 +2318,11 @@ window_create_internal(struct display *display, struct window *parent,
} }
struct window * struct window *
window_create(struct display *display, int32_t width, int32_t height) window_create(struct display *display)
{ {
struct window *window; struct window *window;
window = window_create_internal(display, NULL, width, height); window = window_create_internal(display, NULL);
if (!window) if (!window)
return NULL; return NULL;
@ -2332,12 +2331,11 @@ window_create(struct display *display, int32_t width, int32_t height)
struct window * struct window *
window_create_transient(struct display *display, struct window *parent, 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; struct window *window;
window = window_create_internal(parent->display, window = window_create_internal(parent->display, parent);
parent, width, height);
if (!window) if (!window)
return NULL; return NULL;
@ -2468,8 +2466,7 @@ window_show_menu(struct display *display,
if (!menu) if (!menu)
return; return;
window = window_create_internal(parent->display, parent, window = window_create_internal(parent->display, parent);
200, count * 20 + margin * 2);
if (!window) if (!window)
return; return;
@ -2497,7 +2494,7 @@ window_show_menu(struct display *display,
widget_set_button_handler(menu->widget, menu_button_handler); widget_set_button_handler(menu->widget, menu_button_handler);
input_grab(input, menu->widget, 0); input_grab(input, menu->widget, 0);
window_schedule_redraw(window); window_schedule_resize(window, 200, count * 20 + margin * 2);
} }
void void

@ -193,10 +193,10 @@ typedef void (*widget_button_handler_t)(struct widget *widget,
int button, int state, void *data); int button, int state, void *data);
struct window * struct window *
window_create(struct display *display, int32_t width, int32_t height); window_create(struct display *display);
struct window * struct window *
window_create_transient(struct display *display, struct window *parent, 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); typedef void (*menu_func_t)(struct window *window, int index, void *data);

@ -181,7 +181,7 @@ create_wscreensaver_instance(struct wscreensaver *screensaver,
if (!mi) if (!mi)
return NULL; return NULL;
mi->window = window_create(screensaver->display, width, height); mi->window = window_create(screensaver->display);
if (!mi->window) { if (!mi->window) {
fprintf(stderr, "%s: creating a window failed.\n", progname); fprintf(stderr, "%s: creating a window failed.\n", progname);
free(mi); free(mi);

Loading…
Cancel
Save