From f47d8fe88c946458fb10194c071c289d8b793421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 19 Dec 2011 15:16:06 -0500 Subject: [PATCH] compositor: Move binding code to util.c --- compositor/compositor.c | 55 ----------------------------------------- compositor/compositor.h | 6 +++++ compositor/util.c | 55 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 55 deletions(-) diff --git a/compositor/compositor.c b/compositor/compositor.c index 1be2475b..89fe12ae 100644 --- a/compositor/compositor.c +++ b/compositor/compositor.c @@ -1261,33 +1261,6 @@ wlsc_surface_activate(struct wlsc_surface *surface, wlsc_data_device_set_keyboard_focus(device); } -struct wlsc_binding { - uint32_t key; - uint32_t button; - uint32_t modifier; - wlsc_binding_handler_t handler; - void *data; - struct wl_list link; -}; - -static void -wlsc_compositor_run_binding(struct wlsc_compositor *compositor, - struct wlsc_input_device *device, - uint32_t time, - uint32_t key, uint32_t button, int32_t state) -{ - struct wlsc_binding *b; - - wl_list_for_each(b, &compositor->binding_list, link) { - if (b->key == key && b->button == button && - b->modifier == device->modifier_state && state) { - b->handler(&device->input_device, - time, key, button, state, b->data); - break; - } - } -} - WL_EXPORT void notify_button(struct wl_input_device *device, uint32_t time, int32_t button, int32_t state) @@ -1349,34 +1322,6 @@ click_to_activate_binding(struct wl_input_device *device, focus, wd, time); } -WL_EXPORT struct wlsc_binding * -wlsc_compositor_add_binding(struct wlsc_compositor *compositor, - uint32_t key, uint32_t button, uint32_t modifier, - wlsc_binding_handler_t handler, void *data) -{ - struct wlsc_binding *binding; - - binding = malloc(sizeof *binding); - if (binding == NULL) - return NULL; - - binding->key = key; - binding->button = button; - binding->modifier = modifier; - binding->handler = handler; - binding->data = data; - wl_list_insert(compositor->binding_list.prev, &binding->link); - - return binding; -} - -WL_EXPORT void -wlsc_binding_destroy(struct wlsc_binding *binding) -{ - wl_list_remove(&binding->link); - free(binding); -} - static void update_modifier_state(struct wlsc_input_device *device, uint32_t key, uint32_t state) diff --git a/compositor/compositor.h b/compositor/compositor.h index 0d5ad07e..793a0c80 100644 --- a/compositor/compositor.h +++ b/compositor/compositor.h @@ -326,6 +326,12 @@ wlsc_compositor_add_binding(struct wlsc_compositor *compositor, void wlsc_binding_destroy(struct wlsc_binding *binding); +void +wlsc_compositor_run_binding(struct wlsc_compositor *compositor, + struct wlsc_input_device *device, + uint32_t time, + uint32_t key, uint32_t button, int32_t state); + struct wlsc_surface * wlsc_surface_create(struct wlsc_compositor *compositor, int32_t x, int32_t y, int32_t width, int32_t height); diff --git a/compositor/util.c b/compositor/util.c index f144b766..370edbc7 100644 --- a/compositor/util.c +++ b/compositor/util.c @@ -244,3 +244,58 @@ wlsc_zoom_run(struct wlsc_surface *surface, GLfloat start, GLfloat stop, return zoom; } + +struct wlsc_binding { + uint32_t key; + uint32_t button; + uint32_t modifier; + wlsc_binding_handler_t handler; + void *data; + struct wl_list link; +}; + +WL_EXPORT struct wlsc_binding * +wlsc_compositor_add_binding(struct wlsc_compositor *compositor, + uint32_t key, uint32_t button, uint32_t modifier, + wlsc_binding_handler_t handler, void *data) +{ + struct wlsc_binding *binding; + + binding = malloc(sizeof *binding); + if (binding == NULL) + return NULL; + + binding->key = key; + binding->button = button; + binding->modifier = modifier; + binding->handler = handler; + binding->data = data; + wl_list_insert(compositor->binding_list.prev, &binding->link); + + return binding; +} + +WL_EXPORT void +wlsc_binding_destroy(struct wlsc_binding *binding) +{ + wl_list_remove(&binding->link); + free(binding); +} + +WL_EXPORT void +wlsc_compositor_run_binding(struct wlsc_compositor *compositor, + struct wlsc_input_device *device, + uint32_t time, + uint32_t key, uint32_t button, int32_t state) +{ + struct wlsc_binding *b; + + wl_list_for_each(b, &compositor->binding_list, link) { + if (b->key == key && b->button == button && + b->modifier == device->modifier_state && state) { + b->handler(&device->input_device, + time, key, button, state, b->data); + break; + } + } +}