|
|
@ -41,7 +41,8 @@ struct display { |
|
|
|
struct wl_display *display; |
|
|
|
struct wl_display *display; |
|
|
|
struct wl_compositor *compositor; |
|
|
|
struct wl_compositor *compositor; |
|
|
|
struct wl_shell *shell; |
|
|
|
struct wl_shell *shell; |
|
|
|
struct seat *seat; |
|
|
|
struct wl_seat *seat; |
|
|
|
|
|
|
|
struct wl_pointer *pointer; |
|
|
|
struct { |
|
|
|
struct { |
|
|
|
EGLDisplay dpy; |
|
|
|
EGLDisplay dpy; |
|
|
|
EGLContext ctx; |
|
|
|
EGLContext ctx; |
|
|
@ -51,14 +52,6 @@ struct display { |
|
|
|
struct window *window; |
|
|
|
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 window { |
|
|
|
struct display *display; |
|
|
|
struct display *display; |
|
|
|
struct { |
|
|
|
struct { |
|
|
@ -408,15 +401,14 @@ static void |
|
|
|
seat_handle_capabilities(void *data, struct wl_seat *seat, |
|
|
|
seat_handle_capabilities(void *data, struct wl_seat *seat, |
|
|
|
enum wl_seat_capability caps) |
|
|
|
enum wl_seat_capability caps) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct seat *s = data; |
|
|
|
struct display *d = data; |
|
|
|
|
|
|
|
|
|
|
|
if ((caps & WL_SEAT_CAPABILITY_POINTER) && !s->pointer) { |
|
|
|
if ((caps & WL_SEAT_CAPABILITY_POINTER) && !d->pointer) { |
|
|
|
s->pointer = wl_seat_get_pointer(seat); |
|
|
|
d->pointer = wl_seat_get_pointer(seat); |
|
|
|
wl_pointer_set_user_data(s->pointer, s); |
|
|
|
wl_pointer_add_listener(d->pointer, &pointer_listener, d); |
|
|
|
wl_pointer_add_listener(s->pointer, &pointer_listener, s); |
|
|
|
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && d->pointer) { |
|
|
|
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && s->pointer) { |
|
|
|
wl_pointer_destroy(d->pointer); |
|
|
|
wl_pointer_destroy(s->pointer); |
|
|
|
d->pointer = NULL; |
|
|
|
s->pointer = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -424,17 +416,6 @@ static const struct wl_seat_listener seat_listener = { |
|
|
|
seat_handle_capabilities, |
|
|
|
seat_handle_capabilities, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
static void |
|
|
|
display_handle_global(struct wl_display *display, uint32_t id, |
|
|
|
display_handle_global(struct wl_display *display, uint32_t id, |
|
|
|
const char *interface, uint32_t version, void *data) |
|
|
|
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) { |
|
|
|
} else if (strcmp(interface, "wl_shell") == 0) { |
|
|
|
d->shell = wl_display_bind(display, id, &wl_shell_interface); |
|
|
|
d->shell = wl_display_bind(display, id, &wl_shell_interface); |
|
|
|
} else if (strcmp(interface, "wl_seat") == 0) { |
|
|
|
} 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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|