Convert wl_input_device to wl_seat (and friends)
wl_input_device has been both renamed and split. wl_seat is now a virtual object representing a group of logically related input devices with related focus. It now only generates one event: to let clients know that it has new capabilities. It takes requests which hand back objects for the wl_pointer, wl_keyboard and wl_touch interfaces it exposes which all provide the old input interface, just under different names. This commit tracks these changes in weston and the clients, as well as similar renames (e.g. weston_input_device -> weston_seat). Some other changes were necessary, e.g. renaming the name for the visible mouse sprite from 'pointer' to 'cursor' so as to not conflict. For simplicity, every seat is always exposed with all three interfaces, although this will change as time goes on. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
committed by
Kristian Høgsberg
parent
dc549932b7
commit
37816df646
+62
-92
@@ -35,12 +35,13 @@
|
||||
#include <EGL/egl.h>
|
||||
|
||||
struct window;
|
||||
struct seat;
|
||||
|
||||
struct display {
|
||||
struct wl_display *display;
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_shell *shell;
|
||||
struct wl_input_device *input;
|
||||
struct seat *seat;
|
||||
struct {
|
||||
EGLDisplay dpy;
|
||||
EGLContext ctx;
|
||||
@@ -50,6 +51,14 @@ 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 {
|
||||
@@ -352,118 +361,80 @@ static const struct wl_callback_listener frame_listener = {
|
||||
};
|
||||
|
||||
static void
|
||||
input_handle_motion(void *data, struct wl_input_device *input_device,
|
||||
uint32_t time, int32_t sx, int32_t sy)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_button(void *data,
|
||||
struct wl_input_device *input_device, uint32_t serial,
|
||||
uint32_t time, uint32_t button, uint32_t state)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_axis(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t time, uint32_t axis, int32_t value)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_key(void *data, struct wl_input_device *input_device,
|
||||
uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_pointer_enter(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial, struct wl_surface *surface,
|
||||
int32_t sx, int32_t sy)
|
||||
pointer_handle_enter(void *data, struct wl_pointer *pointer,
|
||||
uint32_t serial, struct wl_surface *surface,
|
||||
wl_fixed_t sx, wl_fixed_t sy)
|
||||
{
|
||||
struct display *display = data;
|
||||
|
||||
if (display->window->fullscreen)
|
||||
wl_input_device_attach(input_device, serial, NULL, 0, 0);
|
||||
wl_pointer_attach(pointer, serial, NULL, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_pointer_leave(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial, struct wl_surface *surface)
|
||||
pointer_handle_leave(void *data, struct wl_pointer *pointer,
|
||||
uint32_t serial, struct wl_surface *surface)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_keyboard_enter(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface,
|
||||
struct wl_array *keys)
|
||||
pointer_handle_motion(void *data, struct wl_pointer *pointer,
|
||||
uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_keyboard_leave(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface)
|
||||
pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t serial, uint32_t time, uint32_t button,
|
||||
uint32_t state)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_touch_down(void *data,
|
||||
struct wl_input_device *wl_input_device,
|
||||
uint32_t serial, uint32_t time,
|
||||
struct wl_surface *surface,
|
||||
int32_t id, int32_t x, int32_t y)
|
||||
pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t time, uint32_t axis, int32_t value)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_touch_up(void *data,
|
||||
struct wl_input_device *wl_input_device,
|
||||
uint32_t serial, uint32_t time, int32_t id)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_touch_motion(void *data,
|
||||
struct wl_input_device *wl_input_device,
|
||||
uint32_t time, int32_t id, int32_t x, int32_t y)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_touch_frame(void *data,
|
||||
struct wl_input_device *wl_input_device)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_touch_cancel(void *data,
|
||||
struct wl_input_device *wl_input_device)
|
||||
{
|
||||
}
|
||||
|
||||
static const struct wl_input_device_listener input_listener = {
|
||||
input_handle_motion,
|
||||
input_handle_button,
|
||||
input_handle_axis,
|
||||
input_handle_key,
|
||||
input_handle_pointer_enter,
|
||||
input_handle_pointer_leave,
|
||||
input_handle_keyboard_enter,
|
||||
input_handle_keyboard_leave,
|
||||
input_handle_touch_down,
|
||||
input_handle_touch_up,
|
||||
input_handle_touch_motion,
|
||||
input_handle_touch_frame,
|
||||
input_handle_touch_cancel,
|
||||
static const struct wl_pointer_listener pointer_listener = {
|
||||
pointer_handle_enter,
|
||||
pointer_handle_leave,
|
||||
pointer_handle_motion,
|
||||
pointer_handle_button,
|
||||
pointer_handle_axis,
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wl_seat_listener seat_listener = {
|
||||
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
|
||||
display_handle_global(struct wl_display *display, uint32_t id,
|
||||
const char *interface, uint32_t version, void *data)
|
||||
@@ -475,9 +446,8 @@ display_handle_global(struct wl_display *display, uint32_t id,
|
||||
wl_display_bind(display, id, &wl_compositor_interface);
|
||||
} else if (strcmp(interface, "wl_shell") == 0) {
|
||||
d->shell = wl_display_bind(display, id, &wl_shell_interface);
|
||||
} else if (strcmp(interface, "wl_input_device") == 0) {
|
||||
d->input = wl_display_bind(display, id, &wl_input_device_interface);
|
||||
wl_input_device_add_listener(d->input, &input_listener, d);
|
||||
} else if (strcmp(interface, "wl_seat") == 0) {
|
||||
bind_seat(d, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+42
-102
@@ -38,7 +38,10 @@ struct touch {
|
||||
struct wl_compositor *compositor;
|
||||
struct wl_shell *shell;
|
||||
struct wl_shm *shm;
|
||||
struct wl_input_device *input_device;
|
||||
struct wl_seat *seat;
|
||||
struct wl_touch *wl_touch;
|
||||
struct wl_pointer *pointer;
|
||||
struct wl_keyboard *keyboard;
|
||||
struct wl_surface *surface;
|
||||
struct wl_shell_surface *shell_surface;
|
||||
struct wl_buffer *buffer;
|
||||
@@ -102,67 +105,6 @@ struct wl_shm_listener shm_listenter = {
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
input_device_handle_motion(void *data, struct wl_input_device *input_device,
|
||||
uint32_t time,
|
||||
wl_fixed_t sx_w,
|
||||
wl_fixed_t sy_w)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_handle_button(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial, uint32_t time,
|
||||
uint32_t button, uint32_t state)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_handle_axis(void *data, struct wl_input_device *input_device,
|
||||
uint32_t time, uint32_t axis, int32_t value)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_handle_key(void *data, struct wl_input_device *input_device,
|
||||
uint32_t serial, uint32_t time,
|
||||
uint32_t key, uint32_t state)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_handle_pointer_enter(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial, struct wl_surface *surface,
|
||||
wl_fixed_t sx_w, wl_fixed_t sy_w)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_handle_pointer_leave(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial, struct wl_surface *surface)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_handle_keyboard_enter(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface,
|
||||
struct wl_array *keys)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_handle_keyboard_leave(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
touch_paint(struct touch *touch, int32_t x, int32_t y, int32_t id)
|
||||
{
|
||||
@@ -196,13 +138,9 @@ touch_paint(struct touch *touch, int32_t x, int32_t y, int32_t id)
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_handle_touch_down(void *data,
|
||||
struct wl_input_device *wl_input_device,
|
||||
uint32_t serial, uint32_t time,
|
||||
struct wl_surface *surface,
|
||||
int32_t id,
|
||||
wl_fixed_t x_w,
|
||||
wl_fixed_t y_w)
|
||||
touch_handle_down(void *data, struct wl_touch *wl_touch,
|
||||
uint32_t serial, uint32_t time, struct wl_surface *surface,
|
||||
int32_t id, wl_fixed_t x_w, wl_fixed_t y_w)
|
||||
{
|
||||
struct touch *touch = data;
|
||||
float x = wl_fixed_to_double(x_w);
|
||||
@@ -212,19 +150,14 @@ input_device_handle_touch_down(void *data,
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_handle_touch_up(void *data,
|
||||
struct wl_input_device *wl_input_device,
|
||||
uint32_t serial, uint32_t time, int32_t id)
|
||||
touch_handle_up(void *data, struct wl_touch *wl_touch,
|
||||
uint32_t serial, uint32_t time, int32_t id)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_handle_touch_motion(void *data,
|
||||
struct wl_input_device *wl_input_device,
|
||||
uint32_t time,
|
||||
int32_t id,
|
||||
wl_fixed_t x_w,
|
||||
wl_fixed_t y_w)
|
||||
touch_handle_motion(void *data, struct wl_touch *wl_touch,
|
||||
uint32_t time, int32_t id, wl_fixed_t x_w, wl_fixed_t y_w)
|
||||
{
|
||||
struct touch *touch = data;
|
||||
float x = wl_fixed_to_double(x_w);
|
||||
@@ -234,31 +167,41 @@ input_device_handle_touch_motion(void *data,
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_handle_touch_frame(void *data,
|
||||
struct wl_input_device *wl_input_device)
|
||||
touch_handle_frame(void *data, struct wl_touch *wl_touch)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_device_handle_touch_cancel(void *data,
|
||||
struct wl_input_device *wl_input_device)
|
||||
touch_handle_cancel(void *data, struct wl_touch *wl_touch)
|
||||
{
|
||||
}
|
||||
|
||||
static const struct wl_input_device_listener input_device_listener = {
|
||||
input_device_handle_motion,
|
||||
input_device_handle_button,
|
||||
input_device_handle_axis,
|
||||
input_device_handle_key,
|
||||
input_device_handle_pointer_enter,
|
||||
input_device_handle_pointer_leave,
|
||||
input_device_handle_keyboard_enter,
|
||||
input_device_handle_keyboard_leave,
|
||||
input_device_handle_touch_down,
|
||||
input_device_handle_touch_up,
|
||||
input_device_handle_touch_motion,
|
||||
input_device_handle_touch_frame,
|
||||
input_device_handle_touch_cancel,
|
||||
static const struct wl_touch_listener touch_listener = {
|
||||
touch_handle_down,
|
||||
touch_handle_up,
|
||||
touch_handle_motion,
|
||||
touch_handle_frame,
|
||||
touch_handle_cancel,
|
||||
};
|
||||
|
||||
static void
|
||||
seat_handle_capabilities(void *data, struct wl_seat *seat,
|
||||
enum wl_seat_capability caps)
|
||||
{
|
||||
struct touch *touch = data;
|
||||
|
||||
if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !touch->wl_touch) {
|
||||
touch->wl_touch = wl_seat_get_touch(seat);
|
||||
wl_touch_set_user_data(touch->wl_touch, touch);
|
||||
wl_touch_add_listener(touch->wl_touch, &touch_listener, touch);
|
||||
} else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && touch->wl_touch) {
|
||||
wl_touch_destroy(touch->wl_touch);
|
||||
touch->wl_touch = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wl_seat_listener seat_listener = {
|
||||
seat_handle_capabilities,
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -276,12 +219,9 @@ handle_global(struct wl_display *display, uint32_t id,
|
||||
} else if (strcmp(interface, "wl_shm") == 0) {
|
||||
touch->shm = wl_display_bind(display, id, &wl_shm_interface);
|
||||
wl_shm_add_listener(touch->shm, &shm_listenter, touch);
|
||||
} else if (strcmp(interface, "wl_input_device") == 0) {
|
||||
touch->input_device =
|
||||
wl_display_bind(display, id,
|
||||
&wl_input_device_interface);
|
||||
wl_input_device_add_listener(touch->input_device,
|
||||
&input_device_listener, touch);
|
||||
} else if (strcmp(interface, "wl_seat") == 0) {
|
||||
touch->seat = wl_display_bind(display, id, &wl_seat_interface);
|
||||
wl_seat_add_listener(touch->seat, &seat_listener, touch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+80
-96
@@ -186,7 +186,9 @@ struct widget {
|
||||
|
||||
struct input {
|
||||
struct display *display;
|
||||
struct wl_input_device *input_device;
|
||||
struct wl_seat *seat;
|
||||
struct wl_pointer *pointer;
|
||||
struct wl_keyboard *keyboard;
|
||||
struct window *pointer_focus;
|
||||
struct window *keyboard_focus;
|
||||
int current_cursor;
|
||||
@@ -1580,7 +1582,7 @@ frame_button_handler(struct widget *widget,
|
||||
input_set_pointer_image(input, time, POINTER_DRAGGING);
|
||||
input_ungrab(input);
|
||||
wl_shell_surface_move(window->shell_surface,
|
||||
input_get_input_device(input),
|
||||
input_get_seat(input),
|
||||
display->serial);
|
||||
break;
|
||||
case WINDOW_RESIZING_TOP:
|
||||
@@ -1605,7 +1607,7 @@ frame_button_handler(struct widget *widget,
|
||||
}
|
||||
|
||||
wl_shell_surface_resize(window->shell_surface,
|
||||
input_get_input_device(input),
|
||||
input_get_seat(input),
|
||||
display->serial, location);
|
||||
break;
|
||||
}
|
||||
@@ -1699,13 +1701,13 @@ input_set_focus_widget(struct input *input, struct widget *focus,
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_motion(void *data, struct wl_input_device *input_device,
|
||||
uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w)
|
||||
pointer_handle_motion(void *data, struct wl_pointer *pointer,
|
||||
uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w)
|
||||
{
|
||||
struct input *input = data;
|
||||
struct window *window = input->pointer_focus;
|
||||
struct widget *widget;
|
||||
int pointer = POINTER_LEFT_PTR;
|
||||
int cursor = POINTER_LEFT_PTR;
|
||||
float sx = wl_fixed_to_double(sx_w);
|
||||
float sy = wl_fixed_to_double(sy_w);
|
||||
|
||||
@@ -1722,11 +1724,11 @@ input_handle_motion(void *data, struct wl_input_device *input_device,
|
||||
else
|
||||
widget = input->focus_widget;
|
||||
if (widget && widget->motion_handler)
|
||||
pointer = widget->motion_handler(input->focus_widget,
|
||||
input, time, sx, sy,
|
||||
widget->user_data);
|
||||
cursor = widget->motion_handler(input->focus_widget,
|
||||
input, time, sx, sy,
|
||||
widget->user_data);
|
||||
|
||||
input_set_pointer_image(input, time, pointer);
|
||||
input_set_pointer_image(input, time, cursor);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1750,9 +1752,8 @@ input_ungrab(struct input *input)
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_button(void *data,
|
||||
struct wl_input_device *input_device, uint32_t serial,
|
||||
uint32_t time, uint32_t button, uint32_t state)
|
||||
pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
|
||||
uint32_t time, uint32_t button, uint32_t state)
|
||||
{
|
||||
struct input *input = data;
|
||||
struct widget *widget;
|
||||
@@ -1773,15 +1774,14 @@ input_handle_button(void *data,
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_axis(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
pointer_handle_axis(void *data, struct wl_pointer *pointer,
|
||||
uint32_t time, uint32_t axis, int32_t value)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_key(void *data, struct wl_input_device *input_device,
|
||||
uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
|
||||
keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
|
||||
uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
|
||||
{
|
||||
struct input *input = data;
|
||||
struct window *window = input->keyboard_focus;
|
||||
@@ -1842,10 +1842,9 @@ input_remove_pointer_focus(struct input *input)
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_pointer_enter(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial, struct wl_surface *surface,
|
||||
wl_fixed_t sx_w, wl_fixed_t sy_w)
|
||||
pointer_handle_enter(void *data, struct wl_pointer *pointer,
|
||||
uint32_t serial, struct wl_surface *surface,
|
||||
wl_fixed_t sx_w, wl_fixed_t sy_w)
|
||||
{
|
||||
struct input *input = data;
|
||||
struct window *window;
|
||||
@@ -1878,9 +1877,8 @@ input_handle_pointer_enter(void *data,
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_pointer_leave(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial, struct wl_surface *surface)
|
||||
pointer_handle_leave(void *data, struct wl_pointer *pointer,
|
||||
uint32_t serial, struct wl_surface *surface)
|
||||
{
|
||||
struct input *input = data;
|
||||
|
||||
@@ -1905,11 +1903,9 @@ input_remove_keyboard_focus(struct input *input)
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_keyboard_enter(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface,
|
||||
struct wl_array *keys)
|
||||
keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
|
||||
uint32_t serial, struct wl_surface *surface,
|
||||
struct wl_array *keys)
|
||||
{
|
||||
struct input *input = data;
|
||||
struct window *window;
|
||||
@@ -1926,10 +1922,8 @@ input_handle_keyboard_enter(void *data,
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_keyboard_leave(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface)
|
||||
keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
|
||||
uint32_t serial, struct wl_surface *surface)
|
||||
{
|
||||
struct input *input = data;
|
||||
|
||||
@@ -1937,56 +1931,49 @@ input_handle_keyboard_leave(void *data,
|
||||
input_remove_keyboard_focus(input);
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_touch_down(void *data,
|
||||
struct wl_input_device *wl_input_device,
|
||||
uint32_t serial, uint32_t time,
|
||||
struct wl_surface *surface,
|
||||
int32_t id, wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
}
|
||||
static const struct wl_pointer_listener pointer_listener = {
|
||||
pointer_handle_enter,
|
||||
pointer_handle_leave,
|
||||
pointer_handle_motion,
|
||||
pointer_handle_button,
|
||||
pointer_handle_axis,
|
||||
};
|
||||
|
||||
static const struct wl_keyboard_listener keyboard_listener = {
|
||||
keyboard_handle_enter,
|
||||
keyboard_handle_leave,
|
||||
keyboard_handle_key,
|
||||
};
|
||||
|
||||
static void
|
||||
input_handle_touch_up(void *data,
|
||||
struct wl_input_device *wl_input_device,
|
||||
uint32_t serial, uint32_t time, int32_t id)
|
||||
seat_handle_capabilities(void *data, struct wl_seat *seat,
|
||||
enum wl_seat_capability caps)
|
||||
{
|
||||
struct input *input = data;
|
||||
|
||||
if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) {
|
||||
input->pointer = wl_seat_get_pointer(seat);
|
||||
wl_pointer_set_user_data(input->pointer, input);
|
||||
wl_pointer_add_listener(input->pointer, &pointer_listener,
|
||||
input);
|
||||
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
|
||||
wl_pointer_destroy(input->pointer);
|
||||
input->pointer = NULL;
|
||||
}
|
||||
|
||||
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) {
|
||||
input->keyboard = wl_seat_get_keyboard(seat);
|
||||
wl_keyboard_set_user_data(input->keyboard, input);
|
||||
wl_keyboard_add_listener(input->keyboard, &keyboard_listener,
|
||||
input);
|
||||
} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
|
||||
wl_keyboard_destroy(input->keyboard);
|
||||
input->keyboard = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_touch_motion(void *data,
|
||||
struct wl_input_device *wl_input_device,
|
||||
uint32_t time, int32_t id,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_touch_frame(void *data,
|
||||
struct wl_input_device *wl_input_device)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_touch_cancel(void *data,
|
||||
struct wl_input_device *wl_input_device)
|
||||
{
|
||||
}
|
||||
|
||||
static const struct wl_input_device_listener input_device_listener = {
|
||||
input_handle_motion,
|
||||
input_handle_button,
|
||||
input_handle_axis,
|
||||
input_handle_key,
|
||||
input_handle_pointer_enter,
|
||||
input_handle_pointer_leave,
|
||||
input_handle_keyboard_enter,
|
||||
input_handle_keyboard_leave,
|
||||
input_handle_touch_down,
|
||||
input_handle_touch_up,
|
||||
input_handle_touch_motion,
|
||||
input_handle_touch_frame,
|
||||
input_handle_touch_cancel,
|
||||
static const struct wl_seat_listener seat_listener = {
|
||||
seat_handle_capabilities,
|
||||
};
|
||||
|
||||
void
|
||||
@@ -1996,10 +1983,10 @@ input_get_position(struct input *input, int32_t *x, int32_t *y)
|
||||
*y = input->sy;
|
||||
}
|
||||
|
||||
struct wl_input_device *
|
||||
input_get_input_device(struct input *input)
|
||||
struct wl_seat *
|
||||
input_get_seat(struct input *input)
|
||||
{
|
||||
return input->input_device;
|
||||
return input->seat;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
@@ -2189,8 +2176,8 @@ input_set_pointer_image(struct input *input, uint32_t time, int pointer)
|
||||
|
||||
input->current_cursor = pointer;
|
||||
buffer = display_get_buffer_for_surface(display, image->surface);
|
||||
wl_input_device_attach(input->input_device, time, buffer,
|
||||
image->hotspot_x, image->hotspot_y);
|
||||
wl_pointer_attach(input->pointer, time, buffer,
|
||||
image->hotspot_x, image->hotspot_y);
|
||||
}
|
||||
|
||||
struct wl_data_device *
|
||||
@@ -2298,8 +2285,7 @@ window_move(struct window *window, struct input *input, uint32_t serial)
|
||||
if (!window->shell_surface)
|
||||
return;
|
||||
|
||||
wl_shell_surface_move(window->shell_surface,
|
||||
input->input_device, serial);
|
||||
wl_shell_surface_move(window->shell_surface, input->seat, serial);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2865,7 +2851,7 @@ window_show_menu(struct display *display,
|
||||
window->y = y;
|
||||
|
||||
input_ungrab(input);
|
||||
wl_shell_surface_set_popup(window->shell_surface, input->input_device,
|
||||
wl_shell_surface_set_popup(window->shell_surface, input->seat,
|
||||
display_get_serial(window->display),
|
||||
window->parent->shell_surface,
|
||||
window->x, window->y, 0);
|
||||
@@ -3015,21 +3001,19 @@ display_add_input(struct display *d, uint32_t id)
|
||||
|
||||
memset(input, 0, sizeof *input);
|
||||
input->display = d;
|
||||
input->input_device =
|
||||
wl_display_bind(d->display, id, &wl_input_device_interface);
|
||||
input->seat = wl_display_bind(d->display, id, &wl_seat_interface);
|
||||
input->pointer_focus = NULL;
|
||||
input->keyboard_focus = NULL;
|
||||
wl_list_insert(d->input_list.prev, &input->link);
|
||||
|
||||
wl_input_device_add_listener(input->input_device,
|
||||
&input_device_listener, input);
|
||||
wl_input_device_set_user_data(input->input_device, input);
|
||||
wl_seat_add_listener(input->seat, &seat_listener, input);
|
||||
wl_seat_set_user_data(input->seat, input);
|
||||
|
||||
input->data_device =
|
||||
wl_data_device_manager_get_data_device(d->data_device_manager,
|
||||
input->input_device);
|
||||
wl_data_device_add_listener(input->data_device,
|
||||
&data_device_listener, input);
|
||||
input->seat);
|
||||
wl_data_device_add_listener(input->data_device, &data_device_listener,
|
||||
input);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3046,7 +3030,7 @@ input_destroy(struct input *input)
|
||||
|
||||
wl_data_device_destroy(input->data_device);
|
||||
wl_list_remove(&input->link);
|
||||
wl_input_device_destroy(input->input_device);
|
||||
wl_seat_destroy(input->seat);
|
||||
free(input);
|
||||
}
|
||||
|
||||
@@ -3061,7 +3045,7 @@ display_handle_global(struct wl_display *display, uint32_t id,
|
||||
wl_display_bind(display, id, &wl_compositor_interface);
|
||||
} else if (strcmp(interface, "wl_output") == 0) {
|
||||
display_add_output(d, id);
|
||||
} else if (strcmp(interface, "wl_input_device") == 0) {
|
||||
} else if (strcmp(interface, "wl_seat") == 0) {
|
||||
display_add_input(d, id);
|
||||
} else if (strcmp(interface, "wl_shell") == 0) {
|
||||
d->shell = wl_display_bind(display, id, &wl_shell_interface);
|
||||
|
||||
+2
-2
@@ -375,8 +375,8 @@ input_ungrab(struct input *input);
|
||||
struct widget *
|
||||
input_get_focus_widget(struct input *input);
|
||||
|
||||
struct wl_input_device *
|
||||
input_get_input_device(struct input *input);
|
||||
struct wl_seat *
|
||||
input_get_seat(struct input *input);
|
||||
|
||||
struct wl_data_device *
|
||||
input_get_data_device(struct input *input);
|
||||
|
||||
Reference in New Issue
Block a user