compositor: Move input devices to their own event loop

First step towards only handling input at repaint time.
Kristian Høgsberg 13 years ago
parent abcef3cf7a
commit 7ea10864c2
  1. 19
      src/compositor.c
  2. 3
      src/compositor.h
  3. 4
      src/evdev.c

@ -2268,6 +2268,16 @@ compositor_bind(struct wl_client *client,
&compositor_interface, id, compositor);
}
static int
weston_compositor_read_input(int fd, uint32_t mask, void *data)
{
struct weston_compositor *compositor = data;
wl_event_loop_dispatch(compositor->input_loop, 0);
return 1;
}
WL_EXPORT int
weston_compositor_init(struct weston_compositor *ec, struct wl_display *display)
{
@ -2337,6 +2347,15 @@ weston_compositor_init(struct weston_compositor *ec, struct wl_display *display)
ec->idle_source = wl_event_loop_add_timer(loop, idle_handler, ec);
wl_event_source_timer_update(ec->idle_source, ec->idle_time * 1000);
ec->input_loop = wl_event_loop_create();
ec->input_loop_source =
wl_event_loop_add_fd(loop,
wl_event_loop_get_fd(ec->input_loop),
WL_EVENT_READABLE,
weston_compositor_read_input, ec);
weston_compositor_schedule_repaint(ec);
return 0;

@ -184,6 +184,9 @@ struct weston_compositor {
struct weston_shell *shell;
struct wl_event_loop *input_loop;
struct wl_event_source *input_loop_source;
/* There can be more than one, but not right now... */
struct wl_input_device *input_device;

@ -437,7 +437,6 @@ evdev_input_device_create(struct evdev_input *master,
struct wl_display *display, const char *path)
{
struct evdev_input_device *device;
struct wl_event_loop *loop;
struct weston_compositor *ec;
device = malloc(sizeof *device);
@ -463,8 +462,7 @@ evdev_input_device_create(struct evdev_input *master,
if (evdev_configure_device(device) == -1)
goto err1;
loop = wl_display_get_event_loop(display);
device->source = wl_event_loop_add_fd(loop, device->fd,
device->source = wl_event_loop_add_fd(ec->input_loop, device->fd,
WL_EVENT_READABLE,
evdev_input_device_data, device);
if (device->source == NULL)

Loading…
Cancel
Save