Set window user data using separate function
This commit is contained in:
parent
dcb71b62a0
commit
c8c3734ef9
@ -141,7 +141,8 @@ int main(int argc, char *argv[])
|
|||||||
draw_stuff(s, flower.width, flower.height);
|
draw_stuff(s, flower.width, flower.height);
|
||||||
cairo_surface_flush(s);
|
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);
|
window_commit(flower.window, 0);
|
||||||
|
|
||||||
display_run(d);
|
display_run(d);
|
||||||
|
@ -431,10 +431,11 @@ gears_create(struct display *display)
|
|||||||
draw_gears(gears);
|
draw_gears(gears);
|
||||||
frame_handler(gears->window, 0, 0, gears);
|
frame_handler(gears->window, 0, 0, gears);
|
||||||
|
|
||||||
window_set_resize_handler(gears->window, resize_handler, gears);
|
window_set_user_data(gears->window, gears);
|
||||||
window_set_keyboard_focus_handler(gears->window, keyboard_focus_handler, gears);
|
window_set_resize_handler(gears->window, resize_handler);
|
||||||
window_set_acknowledge_handler(gears->window, acknowledge_handler, gears);
|
window_set_keyboard_focus_handler(gears->window, keyboard_focus_handler);
|
||||||
window_set_frame_handler(gears->window, frame_handler, gears);
|
window_set_acknowledge_handler(gears->window, acknowledge_handler);
|
||||||
|
window_set_frame_handler(gears->window, frame_handler);
|
||||||
|
|
||||||
return gears;
|
return gears;
|
||||||
}
|
}
|
||||||
|
@ -223,8 +223,9 @@ image_create(struct display *display, uint32_t key, const char *filename)
|
|||||||
* allocation scheme here. Or maybe just a real toolkit. */
|
* allocation scheme here. Or maybe just a real toolkit. */
|
||||||
image->key = key + 100;
|
image->key = key + 100;
|
||||||
|
|
||||||
window_set_redraw_handler(image->window, redraw_handler, image);
|
window_set_user_data(image->window, image);
|
||||||
window_set_keyboard_focus_handler(image->window, keyboard_focus_handler, image);
|
window_set_redraw_handler(image->window, redraw_handler);
|
||||||
|
window_set_keyboard_focus_handler(image->window, keyboard_focus_handler);
|
||||||
|
|
||||||
image_draw(image);
|
image_draw(image);
|
||||||
|
|
||||||
|
@ -438,12 +438,12 @@ terminal_create(struct display *display, int fullscreen)
|
|||||||
terminal->margin = 5;
|
terminal->margin = 5;
|
||||||
|
|
||||||
window_set_fullscreen(terminal->window, terminal->fullscreen);
|
window_set_fullscreen(terminal->window, terminal->fullscreen);
|
||||||
window_set_redraw_handler(terminal->window,
|
window_set_user_data(terminal->window, terminal);
|
||||||
redraw_handler, 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,
|
window_set_keyboard_focus_handler(terminal->window,
|
||||||
keyboard_focus_handler, terminal);
|
keyboard_focus_handler);
|
||||||
|
|
||||||
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0);
|
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0);
|
||||||
cr = cairo_create(surface);
|
cr = cairo_create(surface);
|
||||||
|
@ -184,10 +184,11 @@ view_create(struct display *display, uint32_t key, const char *filename)
|
|||||||
* allocation scheme here. Or maybe just a real toolkit. */
|
* allocation scheme here. Or maybe just a real toolkit. */
|
||||||
view->key = key + 100;
|
view->key = key + 100;
|
||||||
|
|
||||||
window_set_redraw_handler(view->window, redraw_handler, view);
|
window_set_user_data(view->window, view);
|
||||||
window_set_key_handler(view->window, key_handler, view);
|
window_set_redraw_handler(view->window, redraw_handler);
|
||||||
|
window_set_key_handler(view->window, key_handler);
|
||||||
window_set_keyboard_focus_handler(view->window,
|
window_set_keyboard_focus_handler(view->window,
|
||||||
keyboard_focus_handler, view);
|
keyboard_focus_handler);
|
||||||
|
|
||||||
view->document = poppler_document_new_from_file(view->filename,
|
view->document = poppler_document_new_from_file(view->filename,
|
||||||
NULL, &error);
|
NULL, &error);
|
||||||
|
@ -678,52 +678,52 @@ window_set_decoration(struct window *window, int decoration)
|
|||||||
window->decoration = decoration;
|
window->decoration = decoration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
window_set_user_data(struct window *window, void *data)
|
||||||
|
{
|
||||||
|
window->user_data = data;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_resize_handler(struct window *window,
|
window_set_resize_handler(struct window *window,
|
||||||
window_resize_handler_t handler, void *data)
|
window_resize_handler_t handler)
|
||||||
{
|
{
|
||||||
window->resize_handler = handler;
|
window->resize_handler = handler;
|
||||||
window->user_data = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_redraw_handler(struct window *window,
|
window_set_redraw_handler(struct window *window,
|
||||||
window_redraw_handler_t handler, void *data)
|
window_redraw_handler_t handler)
|
||||||
{
|
{
|
||||||
window->redraw_handler = handler;
|
window->redraw_handler = handler;
|
||||||
window->user_data = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_key_handler(struct window *window,
|
window_set_key_handler(struct window *window,
|
||||||
window_key_handler_t handler, void *data)
|
window_key_handler_t handler)
|
||||||
{
|
{
|
||||||
window->key_handler = handler;
|
window->key_handler = handler;
|
||||||
window->user_data = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_acknowledge_handler(struct window *window,
|
window_set_acknowledge_handler(struct window *window,
|
||||||
window_acknowledge_handler_t handler, void *data)
|
window_acknowledge_handler_t handler)
|
||||||
{
|
{
|
||||||
window->acknowledge_handler = handler;
|
window->acknowledge_handler = handler;
|
||||||
window->user_data = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_frame_handler(struct window *window,
|
window_set_frame_handler(struct window *window,
|
||||||
window_frame_handler_t handler, void *data)
|
window_frame_handler_t handler)
|
||||||
{
|
{
|
||||||
window->frame_handler = handler;
|
window->frame_handler = handler;
|
||||||
window->user_data = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_keyboard_focus_handler(struct window *window,
|
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->keyboard_focus_handler = handler;
|
||||||
window->user_data = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -102,37 +102,40 @@ window_copy_surface(struct window *window,
|
|||||||
void
|
void
|
||||||
window_set_fullscreen(struct window *window, int fullscreen);
|
window_set_fullscreen(struct window *window, int fullscreen);
|
||||||
|
|
||||||
|
void
|
||||||
|
window_set_user_data(struct window *window, void *data);
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_redraw_handler(struct window *window,
|
window_set_redraw_handler(struct window *window,
|
||||||
window_redraw_handler_t handler, void *data);
|
window_redraw_handler_t handler);
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_decoration(struct window *window, int decoration);
|
window_set_decoration(struct window *window, int decoration);
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_resize_handler(struct window *window,
|
window_set_resize_handler(struct window *window,
|
||||||
window_resize_handler_t handler, void *data);
|
window_resize_handler_t handler);
|
||||||
void
|
void
|
||||||
window_set_frame_handler(struct window *window,
|
window_set_frame_handler(struct window *window,
|
||||||
window_frame_handler_t handler, void *data);
|
window_frame_handler_t handler);
|
||||||
void
|
void
|
||||||
window_set_acknowledge_handler(struct window *window,
|
window_set_acknowledge_handler(struct window *window,
|
||||||
window_acknowledge_handler_t handler, void *data);
|
window_acknowledge_handler_t handler);
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_key_handler(struct window *window,
|
window_set_key_handler(struct window *window,
|
||||||
window_key_handler_t handler, void *data);
|
window_key_handler_t handler);
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_keyboard_focus_handler(struct window *window,
|
window_set_keyboard_focus_handler(struct window *window,
|
||||||
window_keyboard_focus_handler_t handler,
|
window_keyboard_focus_handler_t handler);
|
||||||
void *data);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_acknowledge_handler(struct window *window,
|
window_set_acknowledge_handler(struct window *window,
|
||||||
window_acknowledge_handler_t handler, void *data);
|
window_acknowledge_handler_t handler);
|
||||||
|
|
||||||
void
|
void
|
||||||
window_set_frame_handler(struct window *window,
|
window_set_frame_handler(struct window *window,
|
||||||
window_frame_handler_t handler, void *data);
|
window_frame_handler_t handler);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user