summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-05-16 16:16:19 -0400
committerKristian Høgsberg <krh@bitplanet.net>2012-05-16 16:16:19 -0400
commitb84108d72afc0a29ac7c5271a1c139ca9e6d370d (patch)
treeba28860b0117d9e3e5f9fa680262fc92d6a8d7ad
parent0b0c2bb3e94ce11c2717f7670fa66f9cba675151 (diff)
simple-egl: Fix crash and simplify
pointer_handle_enter() expects the struct display as the user data, so just move wl_seat and wl_pointer into struct display.
-rw-r--r--clients/simple-egl.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index 441686f..831f6af 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -41,7 +41,8 @@ struct display {
struct wl_display *display;
struct wl_compositor *compositor;
struct wl_shell *shell;
- struct seat *seat;
+ struct wl_seat *seat;
+ struct wl_pointer *pointer;
struct {
EGLDisplay dpy;
EGLContext ctx;
@@ -51,14 +52,6 @@ struct display {
struct window *window;
};
-struct seat {
- struct display *display;
- struct wl_seat *seat;
- struct wl_pointer *pointer;
- struct wl_keyboard *keyboard;
- struct wl_touch *touch;
-};
-
struct window {
struct display *display;
struct {
@@ -408,15 +401,14 @@ static void
seat_handle_capabilities(void *data, struct wl_seat *seat,
enum wl_seat_capability caps)
{
- struct seat *s = data;
-
- if ((caps & WL_SEAT_CAPABILITY_POINTER) && !s->pointer) {
- s->pointer = wl_seat_get_pointer(seat);
- wl_pointer_set_user_data(s->pointer, s);
- wl_pointer_add_listener(s->pointer, &pointer_listener, s);
- } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && s->pointer) {
- wl_pointer_destroy(s->pointer);
- s->pointer = NULL;
+ struct display *d = data;
+
+ if ((caps & WL_SEAT_CAPABILITY_POINTER) && !d->pointer) {
+ d->pointer = wl_seat_get_pointer(seat);
+ wl_pointer_add_listener(d->pointer, &pointer_listener, d);
+ } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && d->pointer) {
+ wl_pointer_destroy(d->pointer);
+ d->pointer = NULL;
}
}
@@ -425,17 +417,6 @@ static const struct wl_seat_listener seat_listener = {
};
static void
-bind_seat(struct display *d, uint32_t id)
-{
- struct seat *s = calloc(1, sizeof *s);
-
- s->display = d;
- s->seat = wl_display_bind(d->display, id, &wl_seat_interface);
- wl_seat_add_listener(s->seat, &seat_listener, s);
- d->seat = s;
-}
-
-static void
display_handle_global(struct wl_display *display, uint32_t id,
const char *interface, uint32_t version, void *data)
{
@@ -447,7 +428,8 @@ display_handle_global(struct wl_display *display, uint32_t id,
} else if (strcmp(interface, "wl_shell") == 0) {
d->shell = wl_display_bind(display, id, &wl_shell_interface);
} else if (strcmp(interface, "wl_seat") == 0) {
- bind_seat(d, id);
+ d->seat = wl_display_bind(d->display, id, &wl_seat_interface);
+ wl_seat_add_listener(d->seat, &seat_listener, d);
}
}