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
+39
-39
@@ -625,22 +625,22 @@ drm_output_prepare_overlay_surface(struct weston_output *output_base,
|
||||
|
||||
static int
|
||||
drm_output_set_cursor(struct weston_output *output_base,
|
||||
struct weston_input_device *eid);
|
||||
struct weston_seat *es);
|
||||
|
||||
static void
|
||||
weston_output_set_cursor(struct weston_output *output,
|
||||
struct weston_input_device *device,
|
||||
struct weston_seat *seat,
|
||||
pixman_region32_t *overlap)
|
||||
{
|
||||
pixman_region32_t cursor_region;
|
||||
int prior_was_hardware;
|
||||
|
||||
if (device->sprite == NULL)
|
||||
if (seat->sprite == NULL)
|
||||
return;
|
||||
|
||||
pixman_region32_init(&cursor_region);
|
||||
pixman_region32_intersect(&cursor_region,
|
||||
&device->sprite->transform.boundingbox,
|
||||
&seat->sprite->transform.boundingbox,
|
||||
&output->region);
|
||||
|
||||
if (!pixman_region32_not_empty(&cursor_region)) {
|
||||
@@ -648,19 +648,19 @@ weston_output_set_cursor(struct weston_output *output,
|
||||
goto out;
|
||||
}
|
||||
|
||||
prior_was_hardware = device->hw_cursor;
|
||||
prior_was_hardware = seat->hw_cursor;
|
||||
if (pixman_region32_not_empty(overlap) ||
|
||||
drm_output_set_cursor(output, device) < 0) {
|
||||
drm_output_set_cursor(output, seat) < 0) {
|
||||
if (prior_was_hardware) {
|
||||
weston_surface_damage(device->sprite);
|
||||
weston_surface_damage(seat->sprite);
|
||||
drm_output_set_cursor(output, NULL);
|
||||
}
|
||||
device->hw_cursor = 0;
|
||||
seat->hw_cursor = 0;
|
||||
} else {
|
||||
if (!prior_was_hardware)
|
||||
weston_surface_damage_below(device->sprite);
|
||||
wl_list_remove(&device->sprite->link);
|
||||
device->hw_cursor = 1;
|
||||
weston_surface_damage_below(seat->sprite);
|
||||
wl_list_remove(&seat->sprite->link);
|
||||
seat->hw_cursor = 1;
|
||||
}
|
||||
|
||||
out:
|
||||
@@ -673,7 +673,7 @@ drm_assign_planes(struct weston_output *output)
|
||||
struct weston_compositor *ec = output->compositor;
|
||||
struct weston_surface *es, *next;
|
||||
pixman_region32_t overlap, surface_overlap;
|
||||
struct weston_input_device *device;
|
||||
struct weston_seat *seat;
|
||||
|
||||
/*
|
||||
* Find a surface for each sprite in the output using some heuristics:
|
||||
@@ -698,12 +698,12 @@ drm_assign_planes(struct weston_output *output)
|
||||
pixman_region32_intersect(&surface_overlap, &overlap,
|
||||
&es->transform.boundingbox);
|
||||
|
||||
device = (struct weston_input_device *) ec->input_device;
|
||||
if (es == device->sprite) {
|
||||
weston_output_set_cursor(output, device,
|
||||
seat = (struct weston_seat *) ec->seat;
|
||||
if (es == seat->sprite) {
|
||||
weston_output_set_cursor(output, seat,
|
||||
&surface_overlap);
|
||||
|
||||
if (!device->hw_cursor)
|
||||
if (!seat->hw_cursor)
|
||||
pixman_region32_union(&overlap, &overlap,
|
||||
&es->transform.boundingbox);
|
||||
} else if (!drm_output_prepare_overlay_surface(output, es,
|
||||
@@ -723,7 +723,7 @@ drm_assign_planes(struct weston_output *output)
|
||||
|
||||
static int
|
||||
drm_output_set_cursor(struct weston_output *output_base,
|
||||
struct weston_input_device *eid)
|
||||
struct weston_seat *es)
|
||||
{
|
||||
struct drm_output *output = (struct drm_output *) output_base;
|
||||
struct drm_compositor *c =
|
||||
@@ -734,17 +734,17 @@ drm_output_set_cursor(struct weston_output *output_base,
|
||||
uint32_t buf[64 * 64];
|
||||
unsigned char *d, *s, *end;
|
||||
|
||||
if (eid == NULL) {
|
||||
if (es == NULL) {
|
||||
drmModeSetCursor(c->drm.fd, output->crtc_id, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (eid->sprite->buffer == NULL ||
|
||||
!wl_buffer_is_shm(eid->sprite->buffer))
|
||||
if (es->sprite->buffer == NULL ||
|
||||
!wl_buffer_is_shm(es->sprite->buffer))
|
||||
goto out;
|
||||
|
||||
if (eid->sprite->geometry.width > 64 ||
|
||||
eid->sprite->geometry.height > 64)
|
||||
if (es->sprite->geometry.width > 64 ||
|
||||
es->sprite->geometry.height > 64)
|
||||
goto out;
|
||||
|
||||
output->current_cursor ^= 1;
|
||||
@@ -754,11 +754,11 @@ drm_output_set_cursor(struct weston_output *output_base,
|
||||
|
||||
memset(buf, 0, sizeof buf);
|
||||
d = (unsigned char *) buf;
|
||||
stride = wl_shm_buffer_get_stride(eid->sprite->buffer);
|
||||
s = wl_shm_buffer_get_data(eid->sprite->buffer);
|
||||
end = s + stride * eid->sprite->geometry.height;
|
||||
stride = wl_shm_buffer_get_stride(es->sprite->buffer);
|
||||
s = wl_shm_buffer_get_data(es->sprite->buffer);
|
||||
end = s + stride * es->sprite->geometry.height;
|
||||
while (s < end) {
|
||||
memcpy(d, s, eid->sprite->geometry.width * 4);
|
||||
memcpy(d, s, es->sprite->geometry.width * 4);
|
||||
s += stride;
|
||||
d += 64 * 4;
|
||||
}
|
||||
@@ -774,8 +774,8 @@ drm_output_set_cursor(struct weston_output *output_base,
|
||||
}
|
||||
|
||||
ret = drmModeMoveCursor(c->drm.fd, output->crtc_id,
|
||||
eid->sprite->geometry.x - output->base.x,
|
||||
eid->sprite->geometry.y - output->base.y);
|
||||
es->sprite->geometry.x - output->base.x,
|
||||
es->sprite->geometry.y - output->base.y);
|
||||
if (ret) {
|
||||
fprintf(stderr, "failed to move cursor: %s\n", strerror(-ret));
|
||||
goto out;
|
||||
@@ -1616,10 +1616,10 @@ static void
|
||||
drm_destroy(struct weston_compositor *ec)
|
||||
{
|
||||
struct drm_compositor *d = (struct drm_compositor *) ec;
|
||||
struct weston_input_device *input, *next;
|
||||
struct weston_seat *seat, *next;
|
||||
|
||||
wl_list_for_each_safe(input, next, &ec->input_device_list, link)
|
||||
evdev_input_destroy(input);
|
||||
wl_list_for_each_safe(seat, next, &ec->seat_list, link)
|
||||
evdev_input_destroy(seat);
|
||||
|
||||
wl_event_source_remove(d->udev_drm_source);
|
||||
wl_event_source_remove(d->drm_source);
|
||||
@@ -1668,7 +1668,7 @@ vt_func(struct weston_compositor *compositor, int event)
|
||||
{
|
||||
struct drm_compositor *ec = (struct drm_compositor *) compositor;
|
||||
struct weston_output *output;
|
||||
struct weston_input_device *input;
|
||||
struct weston_seat *seat;
|
||||
struct drm_sprite *sprite;
|
||||
struct drm_output *drm_output;
|
||||
|
||||
@@ -1682,15 +1682,15 @@ vt_func(struct weston_compositor *compositor, int event)
|
||||
compositor->state = ec->prev_state;
|
||||
drm_compositor_set_modes(ec);
|
||||
weston_compositor_damage_all(compositor);
|
||||
wl_list_for_each(input, &compositor->input_device_list, link) {
|
||||
evdev_add_devices(ec->udev, input);
|
||||
evdev_enable_udev_monitor(ec->udev, input);
|
||||
wl_list_for_each(seat, &compositor->seat_list, link) {
|
||||
evdev_add_devices(ec->udev, seat);
|
||||
evdev_enable_udev_monitor(ec->udev, seat);
|
||||
}
|
||||
break;
|
||||
case TTY_LEAVE_VT:
|
||||
wl_list_for_each(input, &compositor->input_device_list, link) {
|
||||
evdev_disable_udev_monitor(input);
|
||||
evdev_remove_devices(input);
|
||||
wl_list_for_each(seat, &compositor->seat_list, link) {
|
||||
evdev_disable_udev_monitor(seat);
|
||||
evdev_remove_devices(seat);
|
||||
}
|
||||
|
||||
compositor->focus = 0;
|
||||
@@ -1727,7 +1727,7 @@ vt_func(struct weston_compositor *compositor, int event)
|
||||
}
|
||||
|
||||
static void
|
||||
switch_vt_binding(struct wl_input_device *device, uint32_t time,
|
||||
switch_vt_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
|
||||
{
|
||||
struct drm_compositor *ec = data;
|
||||
|
||||
+113
-80
@@ -85,7 +85,10 @@ struct wayland_output {
|
||||
|
||||
struct wayland_input {
|
||||
struct wayland_compositor *compositor;
|
||||
struct wl_input_device *input_device;
|
||||
struct wl_seat *seat;
|
||||
struct wl_pointer *pointer;
|
||||
struct wl_keyboard *keyboard;
|
||||
struct wl_touch *touch;
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
@@ -244,16 +247,16 @@ create_border(struct wayland_compositor *c)
|
||||
static int
|
||||
wayland_input_create(struct wayland_compositor *c)
|
||||
{
|
||||
struct weston_input_device *input;
|
||||
struct weston_seat *seat;
|
||||
|
||||
input = malloc(sizeof *input);
|
||||
if (input == NULL)
|
||||
seat = malloc(sizeof *seat);
|
||||
if (seat == NULL)
|
||||
return -1;
|
||||
|
||||
memset(input, 0, sizeof *input);
|
||||
weston_input_device_init(input, &c->base);
|
||||
memset(seat, 0, sizeof *seat);
|
||||
weston_seat_init(seat, &c->base);
|
||||
|
||||
c->base.input_device = &input->input_device;
|
||||
c->base.seat = seat;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -507,52 +510,8 @@ static const struct wl_output_listener output_listener = {
|
||||
|
||||
/* parent input interface */
|
||||
static void
|
||||
input_handle_motion(void *data, struct wl_input_device *input_device,
|
||||
uint32_t time, wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
|
||||
notify_motion(c->base.input_device, time,
|
||||
x - wl_fixed_from_int(c->border.left),
|
||||
y - wl_fixed_from_int(c->border.top));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
|
||||
notify_button(c->base.input_device, time, button, state);
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_axis(void *data, struct wl_input_device *input_device,
|
||||
uint32_t time, uint32_t axis, int32_t value)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
|
||||
notify_axis(c->base.input_device, time, axis, 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)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
|
||||
notify_key(c->base.input_device, time, key, state);
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_pointer_enter(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t time, struct wl_surface *surface,
|
||||
input_handle_pointer_enter(void *data, struct wl_pointer *pointer,
|
||||
uint32_t serial, struct wl_surface *surface,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
@@ -560,59 +519,134 @@ input_handle_pointer_enter(void *data,
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
|
||||
output = wl_surface_get_user_data(surface);
|
||||
notify_pointer_focus(c->base.input_device, &output->base, x, y);
|
||||
wl_input_device_attach(input->input_device, time, NULL, 0, 0);
|
||||
notify_pointer_focus(&c->base.seat->seat, &output->base, x, y);
|
||||
wl_pointer_attach(input->pointer, serial, NULL, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_pointer_leave(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t time, struct wl_surface *surface)
|
||||
input_handle_pointer_leave(void *data, struct wl_pointer *pointer,
|
||||
uint32_t serial, struct wl_surface *surface)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
|
||||
notify_pointer_focus(c->base.input_device, NULL, 0, 0);
|
||||
notify_pointer_focus(&c->base.seat->seat, NULL, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_motion(void *data, struct wl_pointer *pointer,
|
||||
uint32_t time, wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
|
||||
notify_motion(&c->base.seat->seat, time,
|
||||
x - wl_fixed_from_int(c->border.left),
|
||||
y - wl_fixed_from_int(c->border.top));
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_button(void *data, struct wl_pointer *pointer,
|
||||
uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
|
||||
notify_button(&c->base.seat->seat, time, button, state);
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_axis(void *data, struct wl_pointer *pointer,
|
||||
uint32_t time, uint32_t axis, int32_t value)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
|
||||
notify_axis(&c->base.seat->seat, time, axis, value);
|
||||
}
|
||||
|
||||
static const struct wl_pointer_listener pointer_listener = {
|
||||
input_handle_pointer_enter,
|
||||
input_handle_pointer_leave,
|
||||
input_handle_motion,
|
||||
input_handle_button,
|
||||
input_handle_axis,
|
||||
};
|
||||
|
||||
static void
|
||||
input_handle_keyboard_enter(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t time,
|
||||
struct wl_keyboard *keyboard,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface,
|
||||
struct wl_array *keys)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
|
||||
notify_keyboard_focus(c->base.input_device, keys);
|
||||
notify_keyboard_focus(&c->base.seat->seat, keys);
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_keyboard_leave(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t time,
|
||||
struct wl_keyboard *keyboard,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
|
||||
notify_keyboard_focus(c->base.input_device, NULL);
|
||||
notify_keyboard_focus(&c->base.seat->seat, NULL);
|
||||
}
|
||||
|
||||
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,
|
||||
static void
|
||||
input_handle_key(void *data, struct wl_keyboard *keyboard,
|
||||
uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
|
||||
notify_key(&c->base.seat->seat, time, key, state);
|
||||
}
|
||||
|
||||
static const struct wl_keyboard_listener keyboard_listener = {
|
||||
input_handle_keyboard_enter,
|
||||
input_handle_keyboard_leave,
|
||||
input_handle_key,
|
||||
};
|
||||
|
||||
static void
|
||||
display_add_input(struct wayland_compositor *c, uint32_t id)
|
||||
input_handle_capabilities(void *data, struct wl_seat *seat,
|
||||
enum wl_seat_capability caps)
|
||||
{
|
||||
struct wayland_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 const struct wl_seat_listener seat_listener = {
|
||||
input_handle_capabilities,
|
||||
};
|
||||
|
||||
static void
|
||||
display_add_seat(struct wayland_compositor *c, uint32_t id)
|
||||
{
|
||||
struct wayland_input *input;
|
||||
|
||||
@@ -623,13 +657,12 @@ display_add_input(struct wayland_compositor *c, uint32_t id)
|
||||
memset(input, 0, sizeof *input);
|
||||
|
||||
input->compositor = c;
|
||||
input->input_device = wl_display_bind(c->parent.display,
|
||||
id, &wl_input_device_interface);
|
||||
input->seat = wl_display_bind(c->parent.display, id,
|
||||
&wl_seat_interface);
|
||||
wl_list_insert(c->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);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -645,8 +678,8 @@ display_handle_global(struct wl_display *display, uint32_t id,
|
||||
c->parent.output =
|
||||
wl_display_bind(display, id, &wl_output_interface);
|
||||
wl_output_add_listener(c->parent.output, &output_listener, c);
|
||||
} else if (strcmp(interface, "wl_input_device") == 0) {
|
||||
display_add_input(c, id);
|
||||
} else if (strcmp(interface, "wl_seat") == 0) {
|
||||
display_add_seat(c, id);
|
||||
} else if (strcmp(interface, "wl_shell") == 0) {
|
||||
c->parent.shell =
|
||||
wl_display_bind(display, id, &wl_shell_interface);
|
||||
|
||||
+23
-23
@@ -83,7 +83,7 @@ struct x11_output {
|
||||
};
|
||||
|
||||
struct x11_input {
|
||||
struct weston_input_device base;
|
||||
struct weston_seat base;
|
||||
};
|
||||
|
||||
|
||||
@@ -97,9 +97,9 @@ x11_input_create(struct x11_compositor *c)
|
||||
return -1;
|
||||
|
||||
memset(input, 0, sizeof *input);
|
||||
weston_input_device_init(&input->base, &c->base);
|
||||
weston_seat_init(&input->base, &c->base);
|
||||
|
||||
c->base.input_device = &input->base.input_device;
|
||||
c->base.seat = &input->base;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -107,11 +107,11 @@ x11_input_create(struct x11_compositor *c)
|
||||
static void
|
||||
x11_input_destroy(struct x11_compositor *compositor)
|
||||
{
|
||||
struct x11_input *input = container_of(compositor->base.input_device,
|
||||
struct x11_input *input = container_of(compositor->base.seat,
|
||||
struct x11_input,
|
||||
base.input_device);
|
||||
base);
|
||||
|
||||
weston_input_device_release(&input->base);
|
||||
weston_seat_release(&input->base);
|
||||
free(input);
|
||||
}
|
||||
|
||||
@@ -500,31 +500,31 @@ x11_compositor_deliver_button_event(struct x11_compositor *c,
|
||||
break;
|
||||
case 4:
|
||||
if (state)
|
||||
notify_axis(c->base.input_device,
|
||||
notify_axis(&c->base.seat->seat,
|
||||
weston_compositor_get_time(),
|
||||
WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, 1);
|
||||
WL_POINTER_AXIS_VERTICAL_SCROLL, 1);
|
||||
return;
|
||||
case 5:
|
||||
if (state)
|
||||
notify_axis(c->base.input_device,
|
||||
notify_axis(&c->base.seat->seat,
|
||||
weston_compositor_get_time(),
|
||||
WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, -1);
|
||||
WL_POINTER_AXIS_VERTICAL_SCROLL, -1);
|
||||
return;
|
||||
case 6:
|
||||
if (state)
|
||||
notify_axis(c->base.input_device,
|
||||
notify_axis(&c->base.seat->seat,
|
||||
weston_compositor_get_time(),
|
||||
WL_INPUT_DEVICE_AXIS_HORIZONTAL_SCROLL, 1);
|
||||
WL_POINTER_AXIS_HORIZONTAL_SCROLL, 1);
|
||||
return;
|
||||
case 7:
|
||||
if (state)
|
||||
notify_axis(c->base.input_device,
|
||||
notify_axis(&c->base.seat->seat,
|
||||
weston_compositor_get_time(),
|
||||
WL_INPUT_DEVICE_AXIS_HORIZONTAL_SCROLL, -1);
|
||||
WL_POINTER_AXIS_HORIZONTAL_SCROLL, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
notify_button(c->base.input_device,
|
||||
notify_button(&c->base.seat->seat,
|
||||
weston_compositor_get_time(), button, state);
|
||||
}
|
||||
|
||||
@@ -581,7 +581,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
|
||||
/* Deliver the held key release now
|
||||
* and fall through and handle the new
|
||||
* event below. */
|
||||
notify_key(c->base.input_device,
|
||||
notify_key(&c->base.seat->seat,
|
||||
weston_compositor_get_time(),
|
||||
key_release->detail - 8, 0);
|
||||
free(prev);
|
||||
@@ -604,7 +604,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
|
||||
}
|
||||
|
||||
output = x11_compositor_find_output(c, focus_in->event);
|
||||
notify_keyboard_focus(c->base.input_device, &c->keys);
|
||||
notify_keyboard_focus(&c->base.seat->seat, &c->keys);
|
||||
|
||||
free(prev);
|
||||
prev = NULL;
|
||||
@@ -618,7 +618,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
|
||||
switch (event->response_type & ~0x80) {
|
||||
case XCB_KEY_PRESS:
|
||||
key_press = (xcb_key_press_event_t *) event;
|
||||
notify_key(c->base.input_device,
|
||||
notify_key(&c->base.seat->seat,
|
||||
weston_compositor_get_time(),
|
||||
key_press->detail - 8, 1);
|
||||
break;
|
||||
@@ -636,7 +636,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
|
||||
output = x11_compositor_find_output(c, motion_notify->event);
|
||||
x = wl_fixed_from_int(output->base.x + motion_notify->event_x);
|
||||
y = wl_fixed_from_int(output->base.y + motion_notify->event_y);
|
||||
notify_motion(c->base.input_device,
|
||||
notify_motion(&c->base.seat->seat,
|
||||
weston_compositor_get_time(), x, y);
|
||||
break;
|
||||
|
||||
@@ -655,7 +655,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
|
||||
x = wl_fixed_from_int(output->base.x + enter_notify->event_x);
|
||||
y = wl_fixed_from_int(output->base.y + enter_notify->event_y);
|
||||
|
||||
notify_pointer_focus(c->base.input_device,
|
||||
notify_pointer_focus(&c->base.seat->seat,
|
||||
&output->base, x, y);
|
||||
break;
|
||||
|
||||
@@ -664,7 +664,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
|
||||
if (enter_notify->state >= Button1Mask)
|
||||
break;
|
||||
output = x11_compositor_find_output(c, enter_notify->event);
|
||||
notify_pointer_focus(c->base.input_device, NULL, 0, 0);
|
||||
notify_pointer_focus(&c->base.seat->seat, NULL, 0, 0);
|
||||
break;
|
||||
|
||||
case XCB_CLIENT_MESSAGE:
|
||||
@@ -687,7 +687,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
|
||||
if (focus_in->mode == XCB_NOTIFY_MODE_WHILE_GRABBED ||
|
||||
focus_in->mode == XCB_NOTIFY_MODE_UNGRAB)
|
||||
break;
|
||||
notify_keyboard_focus(c->base.input_device, NULL);
|
||||
notify_keyboard_focus(&c->base.seat->seat, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -701,7 +701,7 @@ x11_compositor_handle_event(int fd, uint32_t mask, void *data)
|
||||
switch (prev ? prev->response_type & ~0x80 : 0x80) {
|
||||
case XCB_KEY_RELEASE:
|
||||
key_release = (xcb_key_press_event_t *) prev;
|
||||
notify_key(c->base.input_device,
|
||||
notify_key(&c->base.seat->seat,
|
||||
weston_compositor_get_time(),
|
||||
key_release->detail - 8, 0);
|
||||
free(prev);
|
||||
|
||||
+345
-283
File diff suppressed because it is too large
Load Diff
+24
-23
@@ -45,7 +45,7 @@ struct weston_transform {
|
||||
|
||||
struct weston_surface;
|
||||
struct shell_surface;
|
||||
struct weston_input_device;
|
||||
struct weston_seat;
|
||||
struct weston_output;
|
||||
|
||||
struct weston_mode {
|
||||
@@ -131,8 +131,11 @@ struct weston_output {
|
||||
void (*set_dpms)(struct weston_output *output, enum dpms_enum level);
|
||||
};
|
||||
|
||||
struct weston_input_device {
|
||||
struct wl_input_device input_device;
|
||||
struct weston_seat {
|
||||
struct wl_seat seat;
|
||||
struct wl_pointer pointer;
|
||||
struct wl_keyboard keyboard;
|
||||
struct wl_touch touch;
|
||||
struct weston_compositor *compositor;
|
||||
struct weston_surface *sprite;
|
||||
struct weston_surface *drag_surface;
|
||||
@@ -213,13 +216,13 @@ struct weston_compositor {
|
||||
struct wl_event_source *input_loop_source;
|
||||
|
||||
/* There can be more than one, but not right now... */
|
||||
struct wl_input_device *input_device;
|
||||
struct weston_seat *seat;
|
||||
|
||||
struct weston_layer fade_layer;
|
||||
struct weston_layer cursor_layer;
|
||||
|
||||
struct wl_list output_list;
|
||||
struct wl_list input_device_list;
|
||||
struct wl_list seat_list;
|
||||
struct wl_list layer_list;
|
||||
struct wl_list surface_list;
|
||||
struct wl_list binding_list;
|
||||
@@ -419,34 +422,33 @@ weston_spring_done(struct weston_spring *spring);
|
||||
|
||||
void
|
||||
weston_surface_activate(struct weston_surface *surface,
|
||||
struct weston_input_device *device);
|
||||
struct weston_seat *seat);
|
||||
void
|
||||
weston_surface_draw(struct weston_surface *es,
|
||||
struct weston_output *output, pixman_region32_t *damage);
|
||||
|
||||
void
|
||||
notify_motion(struct wl_input_device *device,
|
||||
uint32_t time, wl_fixed_t x, wl_fixed_t y);
|
||||
notify_motion(struct wl_seat *seat, uint32_t time,
|
||||
wl_fixed_t x, wl_fixed_t y);
|
||||
void
|
||||
notify_button(struct wl_input_device *device,
|
||||
uint32_t time, int32_t button, uint32_t state);
|
||||
notify_button(struct wl_seat *seat, uint32_t time, int32_t button,
|
||||
uint32_t state);
|
||||
void
|
||||
notify_axis(struct wl_input_device *device,
|
||||
uint32_t time, uint32_t axis, int32_t value);
|
||||
notify_axis(struct wl_seat *seat, uint32_t time, uint32_t axis,
|
||||
int32_t value);
|
||||
void
|
||||
notify_key(struct wl_input_device *device,
|
||||
uint32_t time, uint32_t key, uint32_t state);
|
||||
notify_key(struct wl_seat *seat, uint32_t time, uint32_t key,
|
||||
uint32_t state);
|
||||
|
||||
void
|
||||
notify_pointer_focus(struct wl_input_device *device,
|
||||
struct weston_output *output,
|
||||
notify_pointer_focus(struct wl_seat *seat, struct weston_output *output,
|
||||
wl_fixed_t x, wl_fixed_t y);
|
||||
|
||||
void
|
||||
notify_keyboard_focus(struct wl_input_device *device, struct wl_array *keys);
|
||||
notify_keyboard_focus(struct wl_seat *seat, struct wl_array *keys);
|
||||
|
||||
void
|
||||
notify_touch(struct wl_input_device *device, uint32_t time, int touch_id,
|
||||
notify_touch(struct wl_seat *seat, uint32_t time, int touch_id,
|
||||
wl_fixed_t x, wl_fixed_t y, int touch_type);
|
||||
|
||||
void
|
||||
@@ -477,7 +479,7 @@ weston_compositor_update_drag_surfaces(struct weston_compositor *compositor);
|
||||
|
||||
|
||||
struct weston_binding;
|
||||
typedef void (*weston_binding_handler_t)(struct wl_input_device *device,
|
||||
typedef void (*weston_binding_handler_t)(struct wl_seat *seat,
|
||||
uint32_t time, uint32_t key,
|
||||
uint32_t button,
|
||||
uint32_t axis,
|
||||
@@ -495,7 +497,7 @@ weston_binding_list_destroy_all(struct wl_list *list);
|
||||
|
||||
void
|
||||
weston_compositor_run_binding(struct weston_compositor *compositor,
|
||||
struct weston_input_device *device,
|
||||
struct weston_seat *seat,
|
||||
uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis,
|
||||
int32_t value);
|
||||
@@ -554,11 +556,10 @@ void
|
||||
weston_output_destroy(struct weston_output *output);
|
||||
|
||||
void
|
||||
weston_input_device_init(struct weston_input_device *device,
|
||||
struct weston_compositor *ec);
|
||||
weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec);
|
||||
|
||||
void
|
||||
weston_input_device_release(struct weston_input_device *device);
|
||||
weston_seat_release(struct weston_seat *seat);
|
||||
|
||||
enum {
|
||||
TTY_ENTER_VT,
|
||||
|
||||
+64
-64
@@ -32,8 +32,8 @@
|
||||
#include "evdev.h"
|
||||
#include "launcher-util.h"
|
||||
|
||||
struct evdev_input {
|
||||
struct weston_input_device base;
|
||||
struct evdev_seat {
|
||||
struct weston_seat base;
|
||||
struct wl_list devices_list;
|
||||
struct udev_monitor *udev_monitor;
|
||||
struct wl_event_source *udev_monitor_source;
|
||||
@@ -43,7 +43,7 @@ struct evdev_input {
|
||||
#define MAX_SLOTS 16
|
||||
|
||||
struct evdev_input_device {
|
||||
struct evdev_input *master;
|
||||
struct evdev_seat *master;
|
||||
struct wl_list link;
|
||||
struct wl_event_source *source;
|
||||
struct weston_output *output;
|
||||
@@ -120,12 +120,12 @@ evdev_process_key(struct evdev_input_device *device,
|
||||
case BTN_FORWARD:
|
||||
case BTN_BACK:
|
||||
case BTN_TASK:
|
||||
notify_button(&device->master->base.input_device,
|
||||
notify_button(&device->master->base.seat,
|
||||
time, e->code, e->value);
|
||||
break;
|
||||
|
||||
default:
|
||||
notify_key(&device->master->base.input_device,
|
||||
notify_key(&device->master->base.seat,
|
||||
time, e->code, e->value);
|
||||
break;
|
||||
}
|
||||
@@ -245,14 +245,14 @@ evdev_process_relative(struct evdev_input_device *device,
|
||||
device->type |= EVDEV_RELATIVE_MOTION;
|
||||
break;
|
||||
case REL_WHEEL:
|
||||
notify_axis(&device->master->base.input_device,
|
||||
notify_axis(&device->master->base.seat,
|
||||
time,
|
||||
WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, e->value);
|
||||
WL_POINTER_AXIS_VERTICAL_SCROLL, e->value);
|
||||
break;
|
||||
case REL_HWHEEL:
|
||||
notify_axis(&device->master->base.input_device,
|
||||
notify_axis(&device->master->base.seat,
|
||||
time,
|
||||
WL_INPUT_DEVICE_AXIS_HORIZONTAL_SCROLL, e->value);
|
||||
WL_POINTER_AXIS_HORIZONTAL_SCROLL, e->value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -296,44 +296,44 @@ is_motion_event(struct input_event *e)
|
||||
static void
|
||||
evdev_flush_motion(struct evdev_input_device *device, uint32_t time)
|
||||
{
|
||||
struct wl_input_device *master = &device->master->base.input_device;
|
||||
struct weston_seat *master = &device->master->base;
|
||||
|
||||
if (!device->type)
|
||||
return;
|
||||
|
||||
if (device->type & EVDEV_RELATIVE_MOTION) {
|
||||
notify_motion(master, time,
|
||||
master->x + device->rel.dx,
|
||||
master->y + device->rel.dy);
|
||||
notify_motion(&master->seat, time,
|
||||
master->seat.pointer->x + device->rel.dx,
|
||||
master->seat.pointer->y + device->rel.dy);
|
||||
device->type &= ~EVDEV_RELATIVE_MOTION;
|
||||
device->rel.dx = 0;
|
||||
device->rel.dy = 0;
|
||||
}
|
||||
if (device->type & EVDEV_ABSOLUTE_MT_DOWN) {
|
||||
notify_touch(master, time,
|
||||
notify_touch(&master->seat, time,
|
||||
device->mt.slot,
|
||||
wl_fixed_from_int(device->mt.x[device->mt.slot]),
|
||||
wl_fixed_from_int(device->mt.y[device->mt.slot]),
|
||||
WL_INPUT_DEVICE_TOUCH_DOWN);
|
||||
WL_TOUCH_DOWN);
|
||||
device->type &= ~EVDEV_ABSOLUTE_MT_DOWN;
|
||||
device->type &= ~EVDEV_ABSOLUTE_MT_MOTION;
|
||||
}
|
||||
if (device->type & EVDEV_ABSOLUTE_MT_MOTION) {
|
||||
notify_touch(master, time,
|
||||
notify_touch(&master->seat, time,
|
||||
device->mt.slot,
|
||||
wl_fixed_from_int(device->mt.x[device->mt.slot]),
|
||||
wl_fixed_from_int(device->mt.y[device->mt.slot]),
|
||||
WL_INPUT_DEVICE_TOUCH_MOTION);
|
||||
WL_TOUCH_MOTION);
|
||||
device->type &= ~EVDEV_ABSOLUTE_MT_DOWN;
|
||||
device->type &= ~EVDEV_ABSOLUTE_MT_MOTION;
|
||||
}
|
||||
if (device->type & EVDEV_ABSOLUTE_MT_UP) {
|
||||
notify_touch(master, time, device->mt.slot, 0, 0,
|
||||
WL_INPUT_DEVICE_TOUCH_UP);
|
||||
notify_touch(&master->seat, time, device->mt.slot, 0, 0,
|
||||
WL_TOUCH_UP);
|
||||
device->type &= ~EVDEV_ABSOLUTE_MT_UP;
|
||||
}
|
||||
if (device->type & EVDEV_ABSOLUTE_MOTION) {
|
||||
notify_motion(master, time,
|
||||
notify_motion(&master->seat, time,
|
||||
wl_fixed_from_int(device->abs.x),
|
||||
wl_fixed_from_int(device->abs.y));
|
||||
device->type &= ~EVDEV_ABSOLUTE_MOTION;
|
||||
@@ -472,7 +472,7 @@ evdev_configure_device(struct evdev_input_device *device)
|
||||
}
|
||||
|
||||
static struct evdev_input_device *
|
||||
evdev_input_device_create(struct evdev_input *master,
|
||||
evdev_input_device_create(struct evdev_seat *master,
|
||||
struct wl_display *display, const char *path)
|
||||
{
|
||||
struct evdev_input_device *device;
|
||||
@@ -532,7 +532,7 @@ err0:
|
||||
static const char default_seat[] = "seat0";
|
||||
|
||||
static void
|
||||
device_added(struct udev_device *udev_device, struct evdev_input *master)
|
||||
device_added(struct udev_device *udev_device, struct evdev_seat *master)
|
||||
{
|
||||
struct weston_compositor *c;
|
||||
const char *devnode;
|
||||
@@ -563,7 +563,7 @@ device_removed(struct evdev_input_device *device)
|
||||
}
|
||||
|
||||
static void
|
||||
evdev_notify_keyboard_focus(struct evdev_input *input)
|
||||
evdev_notify_keyboard_focus(struct evdev_seat *seat)
|
||||
{
|
||||
struct evdev_input_device *device;
|
||||
struct wl_array keys;
|
||||
@@ -573,7 +573,7 @@ evdev_notify_keyboard_focus(struct evdev_input *input)
|
||||
int ret;
|
||||
|
||||
memset(all_keys, 0, sizeof all_keys);
|
||||
wl_list_for_each(device, &input->devices_list, link) {
|
||||
wl_list_for_each(device, &seat->devices_list, link) {
|
||||
memset(evdev_keys, 0, sizeof evdev_keys);
|
||||
ret = ioctl(device->fd,
|
||||
EVIOCGKEY(sizeof evdev_keys), evdev_keys);
|
||||
@@ -595,15 +595,15 @@ evdev_notify_keyboard_focus(struct evdev_input *input)
|
||||
}
|
||||
}
|
||||
|
||||
notify_keyboard_focus(&input->base.input_device, &keys);
|
||||
notify_keyboard_focus(&seat->base.seat, &keys);
|
||||
|
||||
wl_array_release(&keys);
|
||||
}
|
||||
|
||||
void
|
||||
evdev_add_devices(struct udev *udev, struct weston_input_device *input_base)
|
||||
evdev_add_devices(struct udev *udev, struct weston_seat *seat_base)
|
||||
{
|
||||
struct evdev_input *input = (struct evdev_input *) input_base;
|
||||
struct evdev_seat *seat = (struct evdev_seat *) seat_base;
|
||||
struct udev_enumerate *e;
|
||||
struct udev_list_entry *entry;
|
||||
struct udev_device *device;
|
||||
@@ -622,15 +622,15 @@ evdev_add_devices(struct udev *udev, struct weston_input_device *input_base)
|
||||
continue;
|
||||
}
|
||||
|
||||
device_added(device, input);
|
||||
device_added(device, seat);
|
||||
|
||||
udev_device_unref(device);
|
||||
}
|
||||
udev_enumerate_unref(e);
|
||||
|
||||
evdev_notify_keyboard_focus(input);
|
||||
evdev_notify_keyboard_focus(seat);
|
||||
|
||||
if (wl_list_empty(&input->devices_list)) {
|
||||
if (wl_list_empty(&seat->devices_list)) {
|
||||
fprintf(stderr,
|
||||
"warning: no input devices on entering Weston. "
|
||||
"Possible causes:\n"
|
||||
@@ -644,7 +644,7 @@ evdev_add_devices(struct udev *udev, struct weston_input_device *input_base)
|
||||
static int
|
||||
evdev_udev_handler(int fd, uint32_t mask, void *data)
|
||||
{
|
||||
struct evdev_input *master = data;
|
||||
struct evdev_seat *master = data;
|
||||
struct udev_device *udev_device;
|
||||
struct evdev_input_device *device, *next;
|
||||
const char *action;
|
||||
@@ -678,9 +678,9 @@ evdev_udev_handler(int fd, uint32_t mask, void *data)
|
||||
}
|
||||
|
||||
int
|
||||
evdev_enable_udev_monitor(struct udev *udev, struct weston_input_device *input_base)
|
||||
evdev_enable_udev_monitor(struct udev *udev, struct weston_seat *seat_base)
|
||||
{
|
||||
struct evdev_input *master = (struct evdev_input *) input_base;
|
||||
struct evdev_seat *master = (struct evdev_seat *) seat_base;
|
||||
struct wl_event_loop *loop;
|
||||
struct weston_compositor *c = master->base.compositor;
|
||||
int fd;
|
||||
@@ -714,66 +714,66 @@ evdev_enable_udev_monitor(struct udev *udev, struct weston_input_device *input_b
|
||||
}
|
||||
|
||||
void
|
||||
evdev_disable_udev_monitor(struct weston_input_device *input_base)
|
||||
evdev_disable_udev_monitor(struct weston_seat *seat_base)
|
||||
{
|
||||
struct evdev_input *input = (struct evdev_input *) input_base;
|
||||
struct evdev_seat *seat = (struct evdev_seat *) seat_base;
|
||||
|
||||
if (!input->udev_monitor)
|
||||
if (!seat->udev_monitor)
|
||||
return;
|
||||
|
||||
udev_monitor_unref(input->udev_monitor);
|
||||
input->udev_monitor = NULL;
|
||||
wl_event_source_remove(input->udev_monitor_source);
|
||||
input->udev_monitor_source = NULL;
|
||||
udev_monitor_unref(seat->udev_monitor);
|
||||
seat->udev_monitor = NULL;
|
||||
wl_event_source_remove(seat->udev_monitor_source);
|
||||
seat->udev_monitor_source = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
evdev_input_create(struct weston_compositor *c, struct udev *udev,
|
||||
const char *seat)
|
||||
const char *seat_id)
|
||||
{
|
||||
struct evdev_input *input;
|
||||
struct evdev_seat *seat;
|
||||
|
||||
input = malloc(sizeof *input);
|
||||
if (input == NULL)
|
||||
seat = malloc(sizeof *seat);
|
||||
if (seat == NULL)
|
||||
return;
|
||||
|
||||
memset(input, 0, sizeof *input);
|
||||
weston_input_device_init(&input->base, c);
|
||||
memset(seat, 0, sizeof *seat);
|
||||
weston_seat_init(&seat->base, c);
|
||||
|
||||
wl_list_init(&input->devices_list);
|
||||
input->seat_id = strdup(seat);
|
||||
if (!evdev_enable_udev_monitor(udev, &input->base)) {
|
||||
free(input->seat_id);
|
||||
free(input);
|
||||
wl_list_init(&seat->devices_list);
|
||||
seat->seat_id = strdup(seat_id);
|
||||
if (!evdev_enable_udev_monitor(udev, &seat->base)) {
|
||||
free(seat->seat_id);
|
||||
free(seat);
|
||||
return;
|
||||
}
|
||||
|
||||
evdev_add_devices(udev, &input->base);
|
||||
evdev_add_devices(udev, &seat->base);
|
||||
|
||||
c->input_device = &input->base.input_device;
|
||||
c->seat = &seat->base;
|
||||
}
|
||||
|
||||
void
|
||||
evdev_remove_devices(struct weston_input_device *input_base)
|
||||
evdev_remove_devices(struct weston_seat *seat_base)
|
||||
{
|
||||
struct evdev_input *input = (struct evdev_input *) input_base;
|
||||
struct evdev_seat *seat = (struct evdev_seat *) seat_base;
|
||||
struct evdev_input_device *device, *next;
|
||||
|
||||
wl_list_for_each_safe(device, next, &input->devices_list, link)
|
||||
wl_list_for_each_safe(device, next, &seat->devices_list, link)
|
||||
device_removed(device);
|
||||
|
||||
notify_keyboard_focus(&input->base.input_device, NULL);
|
||||
notify_keyboard_focus(&seat->base.seat, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
evdev_input_destroy(struct weston_input_device *input_base)
|
||||
evdev_input_destroy(struct weston_seat *seat_base)
|
||||
{
|
||||
struct evdev_input *input = (struct evdev_input *) input_base;
|
||||
struct evdev_seat *seat = (struct evdev_seat *) seat_base;
|
||||
|
||||
evdev_remove_devices(input_base);
|
||||
evdev_disable_udev_monitor(&input->base);
|
||||
evdev_remove_devices(seat_base);
|
||||
evdev_disable_udev_monitor(&seat->base);
|
||||
|
||||
wl_list_remove(&input->base.link);
|
||||
free(input->seat_id);
|
||||
free(input);
|
||||
wl_list_remove(&seat->base.link);
|
||||
free(seat->seat_id);
|
||||
free(seat);
|
||||
}
|
||||
|
||||
+5
-6
@@ -23,21 +23,20 @@
|
||||
#include <libudev.h>
|
||||
|
||||
void
|
||||
evdev_add_devices(struct udev *udev, struct weston_input_device
|
||||
*input_base);
|
||||
evdev_add_devices(struct udev *udev, struct weston_seat *seat_base);
|
||||
|
||||
void
|
||||
evdev_remove_devices(struct weston_input_device *input_base);
|
||||
evdev_remove_devices(struct weston_seat *seat_base);
|
||||
|
||||
void
|
||||
evdev_input_create(struct weston_compositor *c, struct udev *udev,
|
||||
const char *seat);
|
||||
|
||||
void
|
||||
evdev_input_destroy(struct weston_input_device *input_base);
|
||||
evdev_input_destroy(struct weston_seat *seat);
|
||||
|
||||
int
|
||||
evdev_enable_udev_monitor(struct udev *udev, struct weston_input_device *input_base);
|
||||
evdev_enable_udev_monitor(struct udev *udev, struct weston_seat *seat_base);
|
||||
|
||||
void
|
||||
evdev_disable_udev_monitor(struct weston_input_device *input_base);
|
||||
evdev_disable_udev_monitor(struct weston_seat *seat_base);
|
||||
|
||||
+1
-1
@@ -193,7 +193,7 @@ screenshooter_sigchld(struct weston_process *process, int status)
|
||||
}
|
||||
|
||||
static void
|
||||
screenshooter_binding(struct wl_input_device *device, uint32_t time,
|
||||
screenshooter_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis,
|
||||
int32_t state, void *data)
|
||||
{
|
||||
|
||||
+115
-119
@@ -132,7 +132,7 @@ struct shell_surface {
|
||||
int32_t x, y;
|
||||
struct weston_transform parent_transform;
|
||||
int32_t initial_up;
|
||||
struct wl_input_device *device;
|
||||
struct wl_seat *seat;
|
||||
uint32_t serial;
|
||||
} popup;
|
||||
|
||||
@@ -314,11 +314,11 @@ move_grab_motion(struct wl_pointer_grab *grab,
|
||||
uint32_t time, wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct weston_move_grab *move = (struct weston_move_grab *) grab;
|
||||
struct wl_input_device *device = grab->input_device;
|
||||
struct wl_pointer *pointer = grab->pointer;
|
||||
struct shell_surface *shsurf = move->base.shsurf;
|
||||
struct weston_surface *es;
|
||||
int dx = wl_fixed_to_int(device->x + move->dx);
|
||||
int dy = wl_fixed_to_int(device->y + move->dy);
|
||||
int dx = wl_fixed_to_int(pointer->x + move->dx);
|
||||
int dy = wl_fixed_to_int(pointer->y + move->dy);
|
||||
|
||||
if (!shsurf)
|
||||
return;
|
||||
@@ -335,11 +335,11 @@ move_grab_button(struct wl_pointer_grab *grab,
|
||||
{
|
||||
struct shell_grab *shell_grab = container_of(grab, struct shell_grab,
|
||||
grab);
|
||||
struct wl_input_device *device = grab->input_device;
|
||||
struct wl_pointer *pointer = grab->pointer;
|
||||
|
||||
if (device->button_count == 0 && state == 0) {
|
||||
if (pointer->button_count == 0 && state == 0) {
|
||||
shell_grab_finish(shell_grab);
|
||||
wl_input_device_end_pointer_grab(device);
|
||||
wl_pointer_end_grab(pointer);
|
||||
free(grab);
|
||||
}
|
||||
}
|
||||
@@ -502,7 +502,7 @@ shell_surface_set_class(struct wl_client *client,
|
||||
|
||||
static int
|
||||
weston_surface_move(struct weston_surface *es,
|
||||
struct weston_input_device *wd)
|
||||
struct weston_seat *ws)
|
||||
{
|
||||
struct weston_move_grab *move;
|
||||
struct shell_surface *shsurf = get_shell_surface(es);
|
||||
@@ -516,32 +516,33 @@ weston_surface_move(struct weston_surface *es,
|
||||
|
||||
shell_grab_init(&move->base, &move_grab_interface, shsurf);
|
||||
|
||||
move->dx = wl_fixed_from_double(es->geometry.x) - wd->input_device.grab_x;
|
||||
move->dy = wl_fixed_from_double(es->geometry.y) - wd->input_device.grab_y;
|
||||
move->dx = wl_fixed_from_double(es->geometry.x) -
|
||||
ws->seat.pointer->grab_x;
|
||||
move->dy = wl_fixed_from_double(es->geometry.y) -
|
||||
ws->seat.pointer->grab_y;
|
||||
|
||||
wl_input_device_start_pointer_grab(&wd->input_device,
|
||||
&move->base.grab);
|
||||
wl_pointer_start_grab(ws->seat.pointer, &move->base.grab);
|
||||
|
||||
wl_input_device_set_pointer_focus(&wd->input_device, NULL,
|
||||
wl_fixed_from_int(0),
|
||||
wl_fixed_from_int(0));
|
||||
wl_pointer_set_focus(ws->seat.pointer, NULL,
|
||||
wl_fixed_from_int(0),
|
||||
wl_fixed_from_int(0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
shell_surface_move(struct wl_client *client, struct wl_resource *resource,
|
||||
struct wl_resource *input_resource, uint32_t serial)
|
||||
struct wl_resource *seat_resource, uint32_t serial)
|
||||
{
|
||||
struct weston_input_device *wd = input_resource->data;
|
||||
struct weston_seat *ws = seat_resource->data;
|
||||
struct shell_surface *shsurf = resource->data;
|
||||
|
||||
if (wd->input_device.button_count == 0 ||
|
||||
wd->input_device.grab_serial != serial ||
|
||||
wd->input_device.pointer_focus != &shsurf->surface->surface)
|
||||
if (ws->seat.pointer->button_count == 0 ||
|
||||
ws->seat.pointer->grab_serial != serial ||
|
||||
ws->seat.pointer->focus != &shsurf->surface->surface)
|
||||
return;
|
||||
|
||||
if (weston_surface_move(shsurf->surface, wd) < 0)
|
||||
if (weston_surface_move(shsurf->surface, ws) < 0)
|
||||
wl_resource_post_no_memory(resource);
|
||||
}
|
||||
|
||||
@@ -556,7 +557,7 @@ resize_grab_motion(struct wl_pointer_grab *grab,
|
||||
uint32_t time, wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
|
||||
struct wl_input_device *device = grab->input_device;
|
||||
struct wl_pointer *pointer = grab->pointer;
|
||||
int32_t width, height;
|
||||
wl_fixed_t from_x, from_y;
|
||||
wl_fixed_t to_x, to_y;
|
||||
@@ -565,10 +566,10 @@ resize_grab_motion(struct wl_pointer_grab *grab,
|
||||
return;
|
||||
|
||||
weston_surface_from_global_fixed(resize->base.shsurf->surface,
|
||||
device->grab_x, device->grab_y,
|
||||
pointer->grab_x, pointer->grab_y,
|
||||
&from_x, &from_y);
|
||||
weston_surface_from_global_fixed(resize->base.shsurf->surface,
|
||||
device->x, device->y, &to_x, &to_y);
|
||||
pointer->x, pointer->y, &to_x, &to_y);
|
||||
|
||||
width = resize->width;
|
||||
if (resize->edges & WL_SHELL_SURFACE_RESIZE_LEFT) {
|
||||
@@ -593,11 +594,11 @@ resize_grab_button(struct wl_pointer_grab *grab,
|
||||
uint32_t time, uint32_t button, uint32_t state)
|
||||
{
|
||||
struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
|
||||
struct wl_input_device *device = grab->input_device;
|
||||
struct wl_pointer *pointer = grab->pointer;
|
||||
|
||||
if (device->button_count == 0 && state == 0) {
|
||||
if (pointer->button_count == 0 && state == 0) {
|
||||
shell_grab_finish(&resize->base);
|
||||
wl_input_device_end_pointer_grab(device);
|
||||
wl_pointer_end_grab(pointer);
|
||||
free(grab);
|
||||
}
|
||||
}
|
||||
@@ -610,7 +611,7 @@ static const struct wl_pointer_grab_interface resize_grab_interface = {
|
||||
|
||||
static int
|
||||
weston_surface_resize(struct shell_surface *shsurf,
|
||||
struct weston_input_device *wd, uint32_t edges)
|
||||
struct weston_seat *ws, uint32_t edges)
|
||||
{
|
||||
struct weston_resize_grab *resize;
|
||||
|
||||
@@ -631,33 +632,32 @@ weston_surface_resize(struct shell_surface *shsurf,
|
||||
resize->width = shsurf->surface->geometry.width;
|
||||
resize->height = shsurf->surface->geometry.height;
|
||||
|
||||
wl_input_device_start_pointer_grab(&wd->input_device,
|
||||
&resize->base.grab);
|
||||
wl_pointer_start_grab(ws->seat.pointer, &resize->base.grab);
|
||||
|
||||
wl_input_device_set_pointer_focus(&wd->input_device, NULL,
|
||||
wl_fixed_from_int(0),
|
||||
wl_fixed_from_int(0));
|
||||
wl_pointer_set_focus(ws->seat.pointer, NULL,
|
||||
wl_fixed_from_int(0),
|
||||
wl_fixed_from_int(0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
shell_surface_resize(struct wl_client *client, struct wl_resource *resource,
|
||||
struct wl_resource *input_resource, uint32_t serial,
|
||||
struct wl_resource *seat_resource, uint32_t serial,
|
||||
uint32_t edges)
|
||||
{
|
||||
struct weston_input_device *wd = input_resource->data;
|
||||
struct weston_seat *ws = seat_resource->data;
|
||||
struct shell_surface *shsurf = resource->data;
|
||||
|
||||
if (shsurf->type == SHELL_SURFACE_FULLSCREEN)
|
||||
return;
|
||||
|
||||
if (wd->input_device.button_count == 0 ||
|
||||
wd->input_device.grab_serial != serial ||
|
||||
wd->input_device.pointer_focus != &shsurf->surface->surface)
|
||||
if (ws->seat.pointer->button_count == 0 ||
|
||||
ws->seat.pointer->grab_serial != serial ||
|
||||
ws->seat.pointer->focus != &shsurf->surface->surface)
|
||||
return;
|
||||
|
||||
if (weston_surface_resize(shsurf, wd, edges) < 0)
|
||||
if (weston_surface_resize(shsurf, ws, edges) < 0)
|
||||
wl_resource_post_no_memory(resource);
|
||||
}
|
||||
|
||||
@@ -1042,18 +1042,18 @@ popup_grab_focus(struct wl_pointer_grab *grab,
|
||||
wl_fixed_t x,
|
||||
wl_fixed_t y)
|
||||
{
|
||||
struct wl_input_device *device = grab->input_device;
|
||||
struct wl_pointer *pointer = grab->pointer;
|
||||
struct shell_surface *priv =
|
||||
container_of(grab, struct shell_surface, popup.grab);
|
||||
struct wl_client *client = priv->surface->surface.resource.client;
|
||||
|
||||
if (surface && surface->resource.client == client) {
|
||||
wl_input_device_set_pointer_focus(device, surface, x, y);
|
||||
wl_pointer_set_focus(pointer, surface, x, y);
|
||||
grab->focus = surface;
|
||||
} else {
|
||||
wl_input_device_set_pointer_focus(device, NULL,
|
||||
wl_fixed_from_int(0),
|
||||
wl_fixed_from_int(0));
|
||||
wl_pointer_set_focus(pointer, NULL,
|
||||
wl_fixed_from_int(0),
|
||||
wl_fixed_from_int(0));
|
||||
grab->focus = NULL;
|
||||
}
|
||||
}
|
||||
@@ -1064,9 +1064,9 @@ popup_grab_motion(struct wl_pointer_grab *grab,
|
||||
{
|
||||
struct wl_resource *resource;
|
||||
|
||||
resource = grab->input_device->pointer_focus_resource;
|
||||
resource = grab->pointer->focus_resource;
|
||||
if (resource)
|
||||
wl_input_device_send_motion(resource, time, sx, sy);
|
||||
wl_pointer_send_motion(resource, time, sx, sy);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1079,18 +1079,17 @@ popup_grab_button(struct wl_pointer_grab *grab,
|
||||
struct wl_display *display;
|
||||
uint32_t serial;
|
||||
|
||||
resource = grab->input_device->pointer_focus_resource;
|
||||
resource = grab->pointer->focus_resource;
|
||||
if (resource) {
|
||||
display = wl_client_get_display(resource->client);
|
||||
serial = wl_display_get_serial(display);
|
||||
wl_input_device_send_button(resource, serial,
|
||||
time, button, state);
|
||||
wl_pointer_send_button(resource, serial, time, button, state);
|
||||
} else if (state == 0 &&
|
||||
(shsurf->popup.initial_up ||
|
||||
time - shsurf->popup.device->grab_time > 500)) {
|
||||
time - shsurf->popup.seat->pointer->grab_time > 500)) {
|
||||
wl_shell_surface_send_popup_done(&shsurf->resource);
|
||||
wl_input_device_end_pointer_grab(grab->input_device);
|
||||
shsurf->popup.grab.input_device = NULL;
|
||||
wl_pointer_end_grab(grab->pointer);
|
||||
shsurf->popup.grab.pointer = NULL;
|
||||
}
|
||||
|
||||
if (state == 0)
|
||||
@@ -1106,7 +1105,7 @@ static const struct wl_pointer_grab_interface popup_grab_interface = {
|
||||
static void
|
||||
shell_map_popup(struct shell_surface *shsurf)
|
||||
{
|
||||
struct wl_input_device *device = shsurf->popup.device;
|
||||
struct wl_seat *seat = shsurf->popup.seat;
|
||||
struct weston_surface *es = shsurf->surface;
|
||||
struct weston_surface *parent = shsurf->parent->surface;
|
||||
|
||||
@@ -1133,9 +1132,8 @@ shell_map_popup(struct shell_surface *shsurf)
|
||||
|
||||
/* We don't require the grab to still be active, but if another
|
||||
* grab has started in the meantime, we end the popup now. */
|
||||
if (device->grab_serial == shsurf->popup.serial) {
|
||||
wl_input_device_start_pointer_grab(device,
|
||||
&shsurf->popup.grab);
|
||||
if (seat->pointer->grab_serial == shsurf->popup.serial) {
|
||||
wl_pointer_start_grab(seat->pointer, &shsurf->popup.grab);
|
||||
} else {
|
||||
wl_shell_surface_send_popup_done(&shsurf->resource);
|
||||
}
|
||||
@@ -1144,7 +1142,7 @@ shell_map_popup(struct shell_surface *shsurf)
|
||||
static void
|
||||
shell_surface_set_popup(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
struct wl_resource *input_device_resource,
|
||||
struct wl_resource *seat_resource,
|
||||
uint32_t serial,
|
||||
struct wl_resource *parent_resource,
|
||||
int32_t x, int32_t y, uint32_t flags)
|
||||
@@ -1153,7 +1151,7 @@ shell_surface_set_popup(struct wl_client *client,
|
||||
|
||||
shsurf->type = SHELL_SURFACE_POPUP;
|
||||
shsurf->parent = parent_resource->data;
|
||||
shsurf->popup.device = input_device_resource->data;
|
||||
shsurf->popup.seat = seat_resource->data;
|
||||
shsurf->popup.serial = serial;
|
||||
shsurf->popup.x = x;
|
||||
shsurf->popup.y = y;
|
||||
@@ -1175,8 +1173,8 @@ static const struct wl_shell_surface_interface shell_surface_implementation = {
|
||||
static void
|
||||
destroy_shell_surface(struct shell_surface *shsurf)
|
||||
{
|
||||
if (shsurf->popup.grab.input_device)
|
||||
wl_input_device_end_pointer_grab(shsurf->popup.grab.input_device);
|
||||
if (shsurf->popup.grab.pointer)
|
||||
wl_pointer_end_grab(shsurf->popup.grab.pointer);
|
||||
|
||||
if (shsurf->fullscreen.type == WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER &&
|
||||
shell_surface_is_top_fullscreen(shsurf)) {
|
||||
@@ -1507,12 +1505,12 @@ get_shell_surface_type(struct weston_surface *surface)
|
||||
}
|
||||
|
||||
static void
|
||||
move_binding(struct wl_input_device *device, uint32_t time,
|
||||
move_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis, int32_t value,
|
||||
void *data)
|
||||
{
|
||||
struct weston_surface *surface =
|
||||
(struct weston_surface *) device->pointer_focus;
|
||||
(struct weston_surface *) seat->pointer->focus;
|
||||
|
||||
if (surface == NULL)
|
||||
return;
|
||||
@@ -1527,16 +1525,16 @@ move_binding(struct wl_input_device *device, uint32_t time,
|
||||
break;
|
||||
}
|
||||
|
||||
weston_surface_move(surface, (struct weston_input_device *) device);
|
||||
weston_surface_move(surface, (struct weston_seat *) seat);
|
||||
}
|
||||
|
||||
static void
|
||||
resize_binding(struct wl_input_device *device, uint32_t time,
|
||||
resize_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis, int32_t value,
|
||||
void *data)
|
||||
{
|
||||
struct weston_surface *surface =
|
||||
(struct weston_surface *) device->pointer_focus;
|
||||
(struct weston_surface *) seat->pointer->focus;
|
||||
uint32_t edges = 0;
|
||||
int32_t x, y;
|
||||
struct shell_surface *shsurf;
|
||||
@@ -1559,8 +1557,8 @@ resize_binding(struct wl_input_device *device, uint32_t time,
|
||||
}
|
||||
|
||||
weston_surface_from_global(surface,
|
||||
wl_fixed_to_int(device->grab_x),
|
||||
wl_fixed_to_int(device->grab_y),
|
||||
wl_fixed_to_int(seat->pointer->grab_x),
|
||||
wl_fixed_to_int(seat->pointer->grab_y),
|
||||
&x, &y);
|
||||
|
||||
if (x < surface->geometry.width / 3)
|
||||
@@ -1577,19 +1575,18 @@ resize_binding(struct wl_input_device *device, uint32_t time,
|
||||
else
|
||||
edges |= WL_SHELL_SURFACE_RESIZE_BOTTOM;
|
||||
|
||||
weston_surface_resize(shsurf, (struct weston_input_device *) device,
|
||||
edges);
|
||||
weston_surface_resize(shsurf, (struct weston_seat *) seat, edges);
|
||||
}
|
||||
|
||||
static void
|
||||
surface_opacity_binding(struct wl_input_device *device, uint32_t time,
|
||||
surface_opacity_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis,
|
||||
int32_t value, void *data)
|
||||
{
|
||||
uint32_t step = 15;
|
||||
struct shell_surface *shsurf;
|
||||
struct weston_surface *surface =
|
||||
(struct weston_surface *) device->pointer_focus;
|
||||
(struct weston_surface *) seat->pointer->focus;
|
||||
|
||||
if (surface == NULL)
|
||||
return;
|
||||
@@ -1618,18 +1615,18 @@ surface_opacity_binding(struct wl_input_device *device, uint32_t time,
|
||||
}
|
||||
|
||||
static void
|
||||
zoom_binding(struct wl_input_device *device, uint32_t time,
|
||||
zoom_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis, int32_t value,
|
||||
void *data)
|
||||
{
|
||||
struct weston_input_device *wd = (struct weston_input_device *) device;
|
||||
struct weston_compositor *compositor = wd->compositor;
|
||||
struct weston_seat *ws = (struct weston_seat *) seat;
|
||||
struct weston_compositor *compositor = ws->compositor;
|
||||
struct weston_output *output;
|
||||
|
||||
wl_list_for_each(output, &compositor->output_list, link) {
|
||||
if (pixman_region32_contains_point(&output->region,
|
||||
wl_fixed_to_double(device->x),
|
||||
wl_fixed_to_double(device->y),
|
||||
wl_fixed_to_double(seat->pointer->x),
|
||||
wl_fixed_to_double(seat->pointer->y),
|
||||
NULL)) {
|
||||
output->zoom.active = 1;
|
||||
output->zoom.level += output->zoom.increment * -value;
|
||||
@@ -1642,13 +1639,15 @@ zoom_binding(struct wl_input_device *device, uint32_t time,
|
||||
if (output->zoom.level < output->zoom.increment)
|
||||
output->zoom.level = output->zoom.increment;
|
||||
|
||||
weston_output_update_zoom(output, device->x, device->y);
|
||||
weston_output_update_zoom(output,
|
||||
seat->pointer->x,
|
||||
seat->pointer->y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
terminate_binding(struct wl_input_device *device, uint32_t time,
|
||||
terminate_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
|
||||
{
|
||||
struct weston_compositor *compositor = data;
|
||||
@@ -1663,7 +1662,7 @@ rotate_grab_motion(struct wl_pointer_grab *grab,
|
||||
{
|
||||
struct rotate_grab *rotate =
|
||||
container_of(grab, struct rotate_grab, base.grab);
|
||||
struct wl_input_device *device = grab->input_device;
|
||||
struct wl_pointer *pointer = grab->pointer;
|
||||
struct shell_surface *shsurf = rotate->base.shsurf;
|
||||
struct weston_surface *surface;
|
||||
GLfloat cx, cy, dx, dy, cposx, cposy, dposx, dposy, r;
|
||||
@@ -1676,8 +1675,8 @@ rotate_grab_motion(struct wl_pointer_grab *grab,
|
||||
cx = 0.5f * surface->geometry.width;
|
||||
cy = 0.5f * surface->geometry.height;
|
||||
|
||||
dx = wl_fixed_to_double(device->x) - rotate->center.x;
|
||||
dy = wl_fixed_to_double(device->y) - rotate->center.y;
|
||||
dx = wl_fixed_to_double(pointer->x) - rotate->center.x;
|
||||
dy = wl_fixed_to_double(pointer->y) - rotate->center.y;
|
||||
r = sqrtf(dx * dx + dy * dy);
|
||||
|
||||
wl_list_remove(&shsurf->rotation.transform.link);
|
||||
@@ -1732,15 +1731,15 @@ rotate_grab_button(struct wl_pointer_grab *grab,
|
||||
{
|
||||
struct rotate_grab *rotate =
|
||||
container_of(grab, struct rotate_grab, base.grab);
|
||||
struct wl_input_device *device = grab->input_device;
|
||||
struct wl_pointer *pointer = grab->pointer;
|
||||
struct shell_surface *shsurf = rotate->base.shsurf;
|
||||
|
||||
if (device->button_count == 0 && state == 0) {
|
||||
if (pointer->button_count == 0 && state == 0) {
|
||||
if (shsurf)
|
||||
weston_matrix_multiply(&shsurf->rotation.rotation,
|
||||
&rotate->rotation);
|
||||
shell_grab_finish(&rotate->base);
|
||||
wl_input_device_end_pointer_grab(device);
|
||||
wl_pointer_end_grab(pointer);
|
||||
free(rotate);
|
||||
}
|
||||
}
|
||||
@@ -1752,12 +1751,12 @@ static const struct wl_pointer_grab_interface rotate_grab_interface = {
|
||||
};
|
||||
|
||||
static void
|
||||
rotate_binding(struct wl_input_device *device, uint32_t time,
|
||||
rotate_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis, int32_t value,
|
||||
void *data)
|
||||
{
|
||||
struct weston_surface *base_surface =
|
||||
(struct weston_surface *) device->pointer_focus;
|
||||
(struct weston_surface *) seat->pointer->focus;
|
||||
struct shell_surface *surface;
|
||||
struct rotate_grab *rotate;
|
||||
GLfloat dx, dy;
|
||||
@@ -1791,10 +1790,10 @@ rotate_binding(struct wl_input_device *device, uint32_t time,
|
||||
surface->surface->geometry.height / 2,
|
||||
&rotate->center.x, &rotate->center.y);
|
||||
|
||||
wl_input_device_start_pointer_grab(device, &rotate->base.grab);
|
||||
wl_pointer_start_grab(seat->pointer, &rotate->base.grab);
|
||||
|
||||
dx = wl_fixed_to_double(device->x) - rotate->center.x;
|
||||
dy = wl_fixed_to_double(device->y) - rotate->center.y;
|
||||
dx = wl_fixed_to_double(seat->pointer->x) - rotate->center.x;
|
||||
dy = wl_fixed_to_double(seat->pointer->y) - rotate->center.y;
|
||||
r = sqrtf(dx * dx + dy * dy);
|
||||
if (r > 20.0f) {
|
||||
struct weston_matrix inverse;
|
||||
@@ -1816,18 +1815,18 @@ rotate_binding(struct wl_input_device *device, uint32_t time,
|
||||
weston_matrix_init(&rotate->rotation);
|
||||
}
|
||||
|
||||
wl_input_device_set_pointer_focus(device, NULL,
|
||||
wl_fixed_from_int(0),
|
||||
wl_fixed_from_int(0));
|
||||
wl_pointer_set_focus(seat->pointer, NULL,
|
||||
wl_fixed_from_int(0),
|
||||
wl_fixed_from_int(0));
|
||||
}
|
||||
|
||||
static void
|
||||
activate(struct desktop_shell *shell, struct weston_surface *es,
|
||||
struct weston_input_device *device)
|
||||
struct weston_seat *seat)
|
||||
{
|
||||
struct weston_surface *surf, *prev;
|
||||
|
||||
weston_surface_activate(es, device);
|
||||
weston_surface_activate(es, seat);
|
||||
|
||||
switch (get_shell_surface_type(es)) {
|
||||
case SHELL_SURFACE_BACKGROUND:
|
||||
@@ -1881,24 +1880,24 @@ is_black_surface (struct weston_surface *es, struct weston_surface **fs_surface)
|
||||
}
|
||||
|
||||
static void
|
||||
click_to_activate_binding(struct wl_input_device *device,
|
||||
click_to_activate_binding(struct wl_seat *seat,
|
||||
uint32_t time, uint32_t key,
|
||||
uint32_t button, uint32_t axis, int32_t state, void *data)
|
||||
{
|
||||
struct weston_input_device *wd = (struct weston_input_device *) device;
|
||||
struct weston_seat *ws = (struct weston_seat *) seat;
|
||||
struct desktop_shell *shell = data;
|
||||
struct weston_surface *focus;
|
||||
struct weston_surface *upper;
|
||||
|
||||
focus = (struct weston_surface *) device->pointer_focus;
|
||||
focus = (struct weston_surface *) seat->pointer->focus;
|
||||
if (!focus)
|
||||
return;
|
||||
|
||||
if (is_black_surface(focus, &upper))
|
||||
focus = upper;
|
||||
|
||||
if (state && device->pointer_grab == &device->default_pointer_grab)
|
||||
activate(shell, focus, wd);
|
||||
if (state && seat->pointer->grab == &seat->pointer->default_grab)
|
||||
activate(shell, focus, ws);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1906,7 +1905,7 @@ lock(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct desktop_shell *shell =
|
||||
container_of(listener, struct desktop_shell, lock_listener);
|
||||
struct weston_input_device *device;
|
||||
struct weston_seat *seat;
|
||||
struct shell_surface *shsurf;
|
||||
struct weston_output *output;
|
||||
|
||||
@@ -1945,9 +1944,8 @@ lock(struct wl_listener *listener, void *data)
|
||||
weston_compositor_schedule_repaint(shell->compositor);
|
||||
|
||||
/* reset keyboard foci */
|
||||
wl_list_for_each(device, &shell->compositor->input_device_list, link) {
|
||||
wl_input_device_set_keyboard_focus(&device->input_device,
|
||||
NULL);
|
||||
wl_list_for_each(seat, &shell->compositor->seat_list, link) {
|
||||
wl_keyboard_set_focus(seat->seat.keyboard, NULL);
|
||||
}
|
||||
|
||||
/* TODO: disable bindings that should not work while locked. */
|
||||
@@ -2094,8 +2092,7 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
|
||||
case SHELL_SURFACE_MAXIMIZED:
|
||||
if (!shell->locked)
|
||||
activate(shell, surface,
|
||||
(struct weston_input_device *)
|
||||
compositor->input_device);
|
||||
(struct weston_seat *) compositor->seat);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -2406,8 +2403,7 @@ switcher_destroy(struct switcher *switcher, uint32_t time)
|
||||
{
|
||||
struct weston_compositor *compositor = switcher->shell->compositor;
|
||||
struct weston_surface *surface;
|
||||
struct weston_input_device *device =
|
||||
(struct weston_input_device *) switcher->grab.input_device;
|
||||
struct wl_keyboard *keyboard = switcher->grab.keyboard;
|
||||
|
||||
wl_list_for_each(surface, &compositor->surface_list, link) {
|
||||
surface->alpha = 255;
|
||||
@@ -2415,9 +2411,10 @@ switcher_destroy(struct switcher *switcher, uint32_t time)
|
||||
}
|
||||
|
||||
if (switcher->current)
|
||||
activate(switcher->shell, switcher->current, device);
|
||||
activate(switcher->shell, switcher->current,
|
||||
(struct weston_seat *) keyboard->seat);
|
||||
wl_list_remove(&switcher->listener.link);
|
||||
wl_input_device_end_keyboard_grab(&device->input_device);
|
||||
wl_keyboard_end_grab(keyboard);
|
||||
free(switcher);
|
||||
}
|
||||
|
||||
@@ -2426,10 +2423,9 @@ switcher_key(struct wl_keyboard_grab *grab,
|
||||
uint32_t time, uint32_t key, uint32_t state)
|
||||
{
|
||||
struct switcher *switcher = container_of(grab, struct switcher, grab);
|
||||
struct weston_input_device *device =
|
||||
(struct weston_input_device *) grab->input_device;
|
||||
struct weston_seat *seat = (struct weston_seat *) grab->keyboard->seat;
|
||||
|
||||
if ((device->modifier_state & switcher->shell->binding_modifier) == 0) {
|
||||
if ((seat->modifier_state & switcher->shell->binding_modifier) == 0) {
|
||||
switcher_destroy(switcher, time);
|
||||
} else if (key == KEY_TAB && state) {
|
||||
switcher_next(switcher);
|
||||
@@ -2441,7 +2437,7 @@ static const struct wl_keyboard_grab_interface switcher_grab = {
|
||||
};
|
||||
|
||||
static void
|
||||
switcher_binding(struct wl_input_device *device, uint32_t time,
|
||||
switcher_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis,
|
||||
int32_t value, void *data)
|
||||
{
|
||||
@@ -2455,13 +2451,13 @@ switcher_binding(struct wl_input_device *device, uint32_t time,
|
||||
wl_list_init(&switcher->listener.link);
|
||||
|
||||
switcher->grab.interface = &switcher_grab;
|
||||
wl_input_device_start_keyboard_grab(device, &switcher->grab);
|
||||
wl_input_device_set_keyboard_focus(device, NULL);
|
||||
wl_keyboard_start_grab(seat->keyboard, &switcher->grab);
|
||||
wl_keyboard_set_focus(seat->keyboard, NULL);
|
||||
switcher_next(switcher);
|
||||
}
|
||||
|
||||
static void
|
||||
backlight_binding(struct wl_input_device *device, uint32_t time,
|
||||
backlight_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
|
||||
{
|
||||
struct weston_compositor *compositor = data;
|
||||
@@ -2494,7 +2490,7 @@ backlight_binding(struct wl_input_device *device, uint32_t time,
|
||||
}
|
||||
|
||||
static void
|
||||
debug_repaint_binding(struct wl_input_device *device, uint32_t time,
|
||||
debug_repaint_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis,
|
||||
int32_t value, void *data)
|
||||
{
|
||||
@@ -2556,11 +2552,11 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell)
|
||||
weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, 0,
|
||||
click_to_activate_binding, shell);
|
||||
weston_compositor_add_binding(ec, 0, 0,
|
||||
WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL,
|
||||
WL_POINTER_AXIS_VERTICAL_SCROLL,
|
||||
MODIFIER_SUPER | MODIFIER_ALT,
|
||||
surface_opacity_binding, NULL);
|
||||
weston_compositor_add_binding(ec, 0, 0,
|
||||
WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL,
|
||||
WL_POINTER_AXIS_VERTICAL_SCROLL,
|
||||
MODIFIER_SUPER, zoom_binding, NULL);
|
||||
|
||||
/* configurable bindings */
|
||||
|
||||
+11
-13
@@ -52,7 +52,7 @@ struct tablet_shell {
|
||||
|
||||
struct weston_compositor *compositor;
|
||||
struct weston_process process;
|
||||
struct weston_input_device *device;
|
||||
struct weston_seat *seat;
|
||||
struct wl_client *client;
|
||||
|
||||
struct weston_surface *surface;
|
||||
@@ -241,10 +241,9 @@ minimize_zoom_done(struct weston_zoom *zoom, void *data)
|
||||
{
|
||||
struct tablet_shell *shell = data;
|
||||
struct weston_compositor *compositor = shell->compositor;
|
||||
struct weston_input_device *device =
|
||||
(struct weston_input_device *) compositor->input_device;
|
||||
struct weston_seat *seat = (struct weston_seat *) compositor->seat;
|
||||
|
||||
weston_surface_activate(shell->home_surface, device);
|
||||
weston_surface_activate(shell->home_surface, seat);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -252,8 +251,7 @@ tablet_shell_switch_to(struct tablet_shell *shell,
|
||||
struct weston_surface *surface)
|
||||
{
|
||||
struct weston_compositor *compositor = shell->compositor;
|
||||
struct weston_input_device *device =
|
||||
(struct weston_input_device *) compositor->input_device;
|
||||
struct weston_seat *seat = (struct weston_seat *) compositor->seat;
|
||||
struct weston_surface *current;
|
||||
|
||||
if (shell->state == STATE_SWITCHER) {
|
||||
@@ -271,7 +269,7 @@ tablet_shell_switch_to(struct tablet_shell *shell,
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "switch to %p\n", surface);
|
||||
weston_surface_activate(surface, device);
|
||||
weston_surface_activate(surface, seat);
|
||||
tablet_shell_set_state(shell, STATE_TASK);
|
||||
weston_zoom_run(surface, 0.3, 1.0, NULL, NULL);
|
||||
}
|
||||
@@ -428,13 +426,13 @@ tablet_shell_unlock(struct wl_listener *listener, void *data)
|
||||
static void
|
||||
go_home(struct tablet_shell *shell)
|
||||
{
|
||||
struct weston_input_device *device =
|
||||
(struct weston_input_device *) shell->compositor->input_device;
|
||||
struct weston_seat *seat =
|
||||
(struct weston_seat *) shell->compositor->seat;
|
||||
|
||||
if (shell->state == STATE_SWITCHER)
|
||||
tablet_shell_send_hide_switcher(&shell->resource);
|
||||
|
||||
weston_surface_activate(shell->home_surface, device);
|
||||
weston_surface_activate(shell->home_surface, seat);
|
||||
|
||||
tablet_shell_set_state(shell, STATE_HOME);
|
||||
}
|
||||
@@ -451,7 +449,7 @@ long_press_handler(void *data)
|
||||
}
|
||||
|
||||
static void
|
||||
menu_key_binding(struct wl_input_device *device, uint32_t time,
|
||||
menu_key_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
|
||||
{
|
||||
struct tablet_shell *shell = data;
|
||||
@@ -464,7 +462,7 @@ menu_key_binding(struct wl_input_device *device, uint32_t time,
|
||||
}
|
||||
|
||||
static void
|
||||
home_key_binding(struct wl_input_device *device, uint32_t time,
|
||||
home_key_binding(struct wl_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
|
||||
{
|
||||
struct tablet_shell *shell = data;
|
||||
@@ -472,7 +470,7 @@ home_key_binding(struct wl_input_device *device, uint32_t time,
|
||||
if (shell->state == STATE_LOCKED)
|
||||
return;
|
||||
|
||||
shell->device = (struct weston_input_device *) device;
|
||||
shell->seat = (struct weston_seat *) seat;
|
||||
|
||||
if (state) {
|
||||
wl_event_source_timer_update(shell->long_press_source, 500);
|
||||
|
||||
+11
-12
@@ -257,16 +257,16 @@ binding_key(struct wl_keyboard_grab *grab,
|
||||
struct wl_display *display;
|
||||
uint32_t serial;
|
||||
|
||||
resource = grab->input_device->keyboard_focus_resource;
|
||||
resource = grab->keyboard->focus_resource;
|
||||
if (key == b->key) {
|
||||
if (!state) {
|
||||
wl_input_device_end_keyboard_grab(grab->input_device);
|
||||
wl_keyboard_end_grab(grab->keyboard);
|
||||
free(b);
|
||||
}
|
||||
} else if (resource) {
|
||||
display = wl_client_get_display(resource->client);
|
||||
serial = wl_display_next_serial(display);
|
||||
wl_input_device_send_key(resource, serial, time, key, state);
|
||||
wl_keyboard_send_key(resource, serial, time, key, state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ static const struct wl_keyboard_grab_interface binding_grab = {
|
||||
};
|
||||
|
||||
static void
|
||||
install_binding_grab(struct wl_input_device *device,
|
||||
install_binding_grab(struct wl_seat *seat,
|
||||
uint32_t time, uint32_t key)
|
||||
{
|
||||
struct binding_keyboard_grab *grab;
|
||||
@@ -283,12 +283,12 @@ install_binding_grab(struct wl_input_device *device,
|
||||
grab = malloc(sizeof *grab);
|
||||
grab->key = key;
|
||||
grab->grab.interface = &binding_grab;
|
||||
wl_input_device_start_keyboard_grab(device, &grab->grab);
|
||||
wl_keyboard_start_grab(seat->keyboard, &grab->grab);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_compositor_run_binding(struct weston_compositor *compositor,
|
||||
struct weston_input_device *device,
|
||||
struct weston_seat *seat,
|
||||
uint32_t time, uint32_t key,
|
||||
uint32_t button, uint32_t axis, int32_t value)
|
||||
{
|
||||
@@ -296,18 +296,17 @@ weston_compositor_run_binding(struct weston_compositor *compositor,
|
||||
|
||||
wl_list_for_each(b, &compositor->binding_list, link) {
|
||||
if (b->key == key && b->button == button && b->axis == axis &&
|
||||
b->modifier == device->modifier_state && value) {
|
||||
b->handler(&device->input_device,
|
||||
b->modifier == seat->modifier_state && value) {
|
||||
b->handler(&seat->seat,
|
||||
time, key, button, axis, value, b->data);
|
||||
|
||||
/* If this was a key binding and it didn't
|
||||
* install a keyboard grab, install one now to
|
||||
* swallow the key release. */
|
||||
if (b->key &&
|
||||
device->input_device.keyboard_grab ==
|
||||
&device->input_device.default_keyboard_grab)
|
||||
install_binding_grab(&device->input_device,
|
||||
time, key);
|
||||
seat->seat.keyboard->grab ==
|
||||
&seat->seat.keyboard->default_grab)
|
||||
install_binding_grab(&seat->seat, time, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,8 +427,8 @@ weston_wm_get_selection_targets(struct weston_wm *wm)
|
||||
}
|
||||
|
||||
compositor = wm->server->compositor;
|
||||
wl_input_device_set_selection(compositor->input_device, source,
|
||||
wl_display_next_serial(compositor->wl_display));
|
||||
wl_seat_set_selection(&compositor->seat->seat, source,
|
||||
wl_display_next_serial(compositor->wl_display));
|
||||
|
||||
free(reply);
|
||||
}
|
||||
@@ -546,10 +546,10 @@ weston_wm_get_incr_chunk(struct weston_wm *wm)
|
||||
static void
|
||||
weston_wm_set_selection(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wl_input_device *device = data;
|
||||
struct wl_seat *seat = data;
|
||||
struct weston_wm *wm =
|
||||
container_of(listener, struct weston_wm, selection_listener);
|
||||
struct wl_data_source *source = device->selection_data_source;
|
||||
struct wl_data_source *source = seat->selection_data_source;
|
||||
const char **p, **end;
|
||||
int has_text_plain = 0;
|
||||
|
||||
@@ -1060,7 +1060,7 @@ weston_wm_read_data_source(int fd, uint32_t mask, void *data)
|
||||
static void
|
||||
weston_wm_send_data(struct weston_wm *wm, xcb_atom_t target, const char *mime_type)
|
||||
{
|
||||
struct wl_input_device *device = wm->server->compositor->input_device;
|
||||
struct wl_seat *seat = &wm->server->compositor->seat->seat;
|
||||
int p[2];
|
||||
|
||||
if (pipe2(p, O_CLOEXEC | O_NONBLOCK) == -1) {
|
||||
@@ -1078,7 +1078,7 @@ weston_wm_send_data(struct weston_wm *wm, xcb_atom_t target, const char *mime_ty
|
||||
weston_wm_read_data_source,
|
||||
wm);
|
||||
|
||||
wl_data_source_send_send(&device->selection_data_source->resource,
|
||||
wl_data_source_send_send(&seat->selection_data_source->resource,
|
||||
mime_type, p[1]);
|
||||
close(p[1]);
|
||||
}
|
||||
@@ -1505,7 +1505,7 @@ weston_wm_create_wm_window(struct weston_wm *wm)
|
||||
static struct weston_wm *
|
||||
weston_wm_create(struct weston_xserver *wxs)
|
||||
{
|
||||
struct wl_input_device *device;
|
||||
struct wl_seat *seat;
|
||||
struct weston_wm *wm;
|
||||
struct wl_event_loop *loop;
|
||||
xcb_screen_iterator_t s;
|
||||
@@ -1604,9 +1604,9 @@ weston_wm_create(struct weston_xserver *wxs)
|
||||
|
||||
xcb_flush(wm->conn);
|
||||
|
||||
device = wxs->compositor->input_device;
|
||||
seat = &wxs->compositor->seat->seat;
|
||||
wm->selection_listener.notify = weston_wm_set_selection;
|
||||
wl_signal_add(&device->selection_signal, &wm->selection_listener);
|
||||
wl_signal_add(&seat->selection_signal, &wm->selection_listener);
|
||||
|
||||
fprintf(stderr, "created wm\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user