From c8c3734ef9dac948d1a440e76aba17de8cd5262d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Fri, 25 Jun 2010 11:19:22 -0400 Subject: [PATCH] Set window user data using separate function --- clients/flower.c | 3 ++- clients/gears.c | 9 +++++---- clients/image.c | 5 +++-- clients/terminal.c | 8 ++++---- clients/view.c | 7 ++++--- clients/window.c | 24 ++++++++++++------------ clients/window.h | 21 ++++++++++++--------- 7 files changed, 42 insertions(+), 35 deletions(-) diff --git a/clients/flower.c b/clients/flower.c index 5b18846..68c9062 100644 --- a/clients/flower.c +++ b/clients/flower.c @@ -141,7 +141,8 @@ int main(int argc, char *argv[]) draw_stuff(s, flower.width, flower.height); cairo_surface_flush(s); - window_set_frame_handler(flower.window, handle_frame, &flower); + window_set_user_data(flower.window, &flower); + window_set_frame_handler(flower.window, handle_frame); window_commit(flower.window, 0); display_run(d); diff --git a/clients/gears.c b/clients/gears.c index 1697170..04da3de 100644 --- a/clients/gears.c +++ b/clients/gears.c @@ -431,10 +431,11 @@ gears_create(struct display *display) draw_gears(gears); frame_handler(gears->window, 0, 0, gears); - window_set_resize_handler(gears->window, resize_handler, gears); - window_set_keyboard_focus_handler(gears->window, keyboard_focus_handler, gears); - window_set_acknowledge_handler(gears->window, acknowledge_handler, gears); - window_set_frame_handler(gears->window, frame_handler, gears); + window_set_user_data(gears->window, gears); + window_set_resize_handler(gears->window, resize_handler); + window_set_keyboard_focus_handler(gears->window, keyboard_focus_handler); + window_set_acknowledge_handler(gears->window, acknowledge_handler); + window_set_frame_handler(gears->window, frame_handler); return gears; } diff --git a/clients/image.c b/clients/image.c index 8493071..52621e9 100644 --- a/clients/image.c +++ b/clients/image.c @@ -223,8 +223,9 @@ image_create(struct display *display, uint32_t key, const char *filename) * allocation scheme here. Or maybe just a real toolkit. */ image->key = key + 100; - window_set_redraw_handler(image->window, redraw_handler, image); - window_set_keyboard_focus_handler(image->window, keyboard_focus_handler, image); + window_set_user_data(image->window, image); + window_set_redraw_handler(image->window, redraw_handler); + window_set_keyboard_focus_handler(image->window, keyboard_focus_handler); image_draw(image); diff --git a/clients/terminal.c b/clients/terminal.c index df217b6..162dfe8 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -438,12 +438,12 @@ terminal_create(struct display *display, int fullscreen) terminal->margin = 5; window_set_fullscreen(terminal->window, terminal->fullscreen); - window_set_redraw_handler(terminal->window, - redraw_handler, terminal); + window_set_user_data(terminal->window, terminal); + window_set_redraw_handler(terminal->window, redraw_handler); - window_set_key_handler(terminal->window, key_handler, terminal); + window_set_key_handler(terminal->window, key_handler); window_set_keyboard_focus_handler(terminal->window, - keyboard_focus_handler, terminal); + keyboard_focus_handler); surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0); cr = cairo_create(surface); diff --git a/clients/view.c b/clients/view.c index ceaf4ce..4ef6b6c 100644 --- a/clients/view.c +++ b/clients/view.c @@ -184,10 +184,11 @@ view_create(struct display *display, uint32_t key, const char *filename) * allocation scheme here. Or maybe just a real toolkit. */ view->key = key + 100; - window_set_redraw_handler(view->window, redraw_handler, view); - window_set_key_handler(view->window, key_handler, view); + window_set_user_data(view->window, view); + window_set_redraw_handler(view->window, redraw_handler); + window_set_key_handler(view->window, key_handler); window_set_keyboard_focus_handler(view->window, - keyboard_focus_handler, view); + keyboard_focus_handler); view->document = poppler_document_new_from_file(view->filename, NULL, &error); diff --git a/clients/window.c b/clients/window.c index 214d0d5..cac1eb8 100644 --- a/clients/window.c +++ b/clients/window.c @@ -679,51 +679,51 @@ window_set_decoration(struct window *window, int decoration) } void +window_set_user_data(struct window *window, void *data) +{ + window->user_data = data; +} + +void window_set_resize_handler(struct window *window, - window_resize_handler_t handler, void *data) + window_resize_handler_t handler) { window->resize_handler = handler; - window->user_data = data; } void window_set_redraw_handler(struct window *window, - window_redraw_handler_t handler, void *data) + window_redraw_handler_t handler) { window->redraw_handler = handler; - window->user_data = data; } void window_set_key_handler(struct window *window, - window_key_handler_t handler, void *data) + window_key_handler_t handler) { window->key_handler = handler; - window->user_data = data; } void window_set_acknowledge_handler(struct window *window, - window_acknowledge_handler_t handler, void *data) + window_acknowledge_handler_t handler) { window->acknowledge_handler = handler; - window->user_data = data; } void window_set_frame_handler(struct window *window, - window_frame_handler_t handler, void *data) + window_frame_handler_t handler) { window->frame_handler = handler; - window->user_data = data; } void window_set_keyboard_focus_handler(struct window *window, - window_keyboard_focus_handler_t handler, void *data) + window_keyboard_focus_handler_t handler) { window->keyboard_focus_handler = handler; - window->user_data = data; } void diff --git a/clients/window.h b/clients/window.h index 041d35d..7f8df80 100644 --- a/clients/window.h +++ b/clients/window.h @@ -103,36 +103,39 @@ void window_set_fullscreen(struct window *window, int fullscreen); void +window_set_user_data(struct window *window, void *data); + +void window_set_redraw_handler(struct window *window, - window_redraw_handler_t handler, void *data); + window_redraw_handler_t handler); void window_set_decoration(struct window *window, int decoration); void window_set_resize_handler(struct window *window, - window_resize_handler_t handler, void *data); + window_resize_handler_t handler); void window_set_frame_handler(struct window *window, - window_frame_handler_t handler, void *data); + window_frame_handler_t handler); void window_set_acknowledge_handler(struct window *window, - window_acknowledge_handler_t handler, void *data); + window_acknowledge_handler_t handler); + void window_set_key_handler(struct window *window, - window_key_handler_t handler, void *data); + window_key_handler_t handler); void window_set_keyboard_focus_handler(struct window *window, - window_keyboard_focus_handler_t handler, - void *data); + window_keyboard_focus_handler_t handler); void window_set_acknowledge_handler(struct window *window, - window_acknowledge_handler_t handler, void *data); + window_acknowledge_handler_t handler); void window_set_frame_handler(struct window *window, - window_frame_handler_t handler, void *data); + window_frame_handler_t handler); #endif -- 2.7.4