compositor: Move binding code to util.c

dev
Kristian Høgsberg 13 years ago
parent 2bd5b6376c
commit f47d8fe88c
  1. 55
      compositor/compositor.c
  2. 6
      compositor/compositor.h
  3. 55
      compositor/util.c

@ -1261,33 +1261,6 @@ wlsc_surface_activate(struct wlsc_surface *surface,
wlsc_data_device_set_keyboard_focus(device); 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 WL_EXPORT void
notify_button(struct wl_input_device *device, notify_button(struct wl_input_device *device,
uint32_t time, int32_t button, int32_t state) 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); 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 static void
update_modifier_state(struct wlsc_input_device *device, update_modifier_state(struct wlsc_input_device *device,
uint32_t key, uint32_t state) uint32_t key, uint32_t state)

@ -326,6 +326,12 @@ wlsc_compositor_add_binding(struct wlsc_compositor *compositor,
void void
wlsc_binding_destroy(struct wlsc_binding *binding); 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 * struct wlsc_surface *
wlsc_surface_create(struct wlsc_compositor *compositor, wlsc_surface_create(struct wlsc_compositor *compositor,
int32_t x, int32_t y, int32_t width, int32_t height); int32_t x, int32_t y, int32_t width, int32_t height);

@ -244,3 +244,58 @@ wlsc_zoom_run(struct wlsc_surface *surface, GLfloat start, GLfloat stop,
return zoom; 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;
}
}
}

Loading…
Cancel
Save