struct weston_pointer *pointer;
struct weston_keyboard *keyboard;
struct weston_touch *touch;
+ int pointer_device_count;
+ int keyboard_device_count;
+ int touch_device_count;
struct weston_output *output; /* constraint */
const char *seat_name);
void
weston_seat_init_pointer(struct weston_seat *seat);
+void
+weston_seat_release_pointer(struct weston_seat *seat);
int
weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap);
void
+weston_seat_release_keyboard(struct weston_seat *seat);
+void
weston_seat_init_touch(struct weston_seat *seat);
void
+weston_seat_release_touch(struct weston_seat *seat);
+void
weston_seat_repick(struct weston_seat *seat);
void
if ((device->caps & (EVDEV_MOTION_ABS | EVDEV_MOTION_REL)) &&
(device->caps & EVDEV_BUTTON)) {
weston_seat_init_pointer(device->seat);
+ device->seat_caps |= EVDEV_SEAT_POINTER;
weston_log("input device %s, %s is a pointer caps =%s%s%s\n",
device->devname, device->devnode,
device->caps & EVDEV_MOTION_ABS ? " absolute-motion" : "",
if ((device->caps & EVDEV_KEYBOARD)) {
if (weston_seat_init_keyboard(device->seat, NULL) < 0)
return -1;
+ device->seat_caps |= EVDEV_SEAT_KEYBOARD;
weston_log("input device %s, %s is a keyboard\n",
device->devname, device->devnode);
}
if ((device->caps & EVDEV_TOUCH)) {
weston_seat_init_touch(device->seat);
+ device->seat_caps |= EVDEV_SEAT_TOUCH;
weston_log("input device %s, %s is a touch device\n",
device->devname, device->devnode);
}
container_of(ec->output_list.next, struct weston_output, link);
device->seat = seat;
+ device->seat_caps = 0;
device->is_mt = 0;
device->mtdev = NULL;
device->devnode = strdup(path);
{
struct evdev_dispatch *dispatch;
+ if (device->seat_caps & EVDEV_SEAT_POINTER)
+ weston_seat_release_pointer(device->seat);
+ if (device->seat_caps & EVDEV_SEAT_KEYBOARD)
+ weston_seat_release_keyboard(device->seat);
+ if (device->seat_caps & EVDEV_SEAT_TOUCH)
+ weston_seat_release_touch(device->seat);
+
dispatch = device->dispatch;
if (dispatch)
dispatch->interface->destroy(dispatch);
EVDEV_TOUCH = (1 << 4),
};
+enum evdev_device_seat_capability {
+ EVDEV_SEAT_POINTER = (1 << 0),
+ EVDEV_SEAT_KEYBOARD = (1 << 1),
+ EVDEV_SEAT_TOUCH = (1 << 2)
+};
+
struct evdev_device {
struct weston_seat *seat;
struct wl_list link;
enum evdev_event_type pending_event;
enum evdev_device_capability caps;
+ enum evdev_device_seat_capability seat_caps;
int is_mt;
};
enum wl_seat_capability caps = 0;
struct wl_resource *resource;
- if (seat->pointer)
+ if (seat->pointer_device_count > 0)
caps |= WL_SEAT_CAPABILITY_POINTER;
- if (seat->keyboard)
+ if (seat->keyboard_device_count > 0)
caps |= WL_SEAT_CAPABILITY_KEYBOARD;
- if (seat->touch)
+ if (seat->touch_device_count > 0)
caps |= WL_SEAT_CAPABILITY_TOUCH;
wl_resource_for_each(resource, &seat->base_resource_list) {
{
struct weston_keyboard *keyboard;
- if (seat->keyboard)
+ if (seat->keyboard) {
+ seat->keyboard_device_count += 1;
+ if (seat->keyboard_device_count == 1)
+ seat_send_updated_caps(seat);
return 0;
+ }
#ifdef ENABLE_XKBCOMMON
if (seat->compositor->use_xkbcommon) {
}
seat->keyboard = keyboard;
+ seat->keyboard_device_count = 1;
keyboard->seat = seat;
seat_send_updated_caps(seat);
}
WL_EXPORT void
+weston_seat_release_keyboard(struct weston_seat *seat)
+{
+ seat->keyboard_device_count--;
+ if (seat->keyboard_device_count == 0) {
+ seat_send_updated_caps(seat);
+ }
+}
+
+WL_EXPORT void
weston_seat_init_pointer(struct weston_seat *seat)
{
struct weston_pointer *pointer;
- if (seat->pointer)
+ if (seat->pointer) {
+ seat->pointer_device_count += 1;
+ if (seat->pointer_device_count == 1)
+ seat_send_updated_caps(seat);
return;
+ }
pointer = weston_pointer_create();
if (pointer == NULL)
return;
seat->pointer = pointer;
- pointer->seat = seat;
+ seat->pointer_device_count = 1;
+ pointer->seat = seat;
seat_send_updated_caps(seat);
}
WL_EXPORT void
+weston_seat_release_pointer(struct weston_seat *seat)
+{
+ struct weston_pointer *pointer = seat->pointer;
+
+ seat->pointer_device_count--;
+ if (seat->pointer_device_count == 0) {
+ seat_send_updated_caps(seat);
+ }
+}
+
+WL_EXPORT void
weston_seat_init_touch(struct weston_seat *seat)
{
struct weston_touch *touch;
- if (seat->touch)
+ if (seat->touch) {
+ seat->touch_device_count += 1;
+ if (seat->touch_device_count == 1)
+ seat_send_updated_caps(seat);
return;
+ }
touch = weston_touch_create();
if (touch == NULL)
return;
seat->touch = touch;
+ seat->touch_device_count = 1;
touch->seat = seat;
seat_send_updated_caps(seat);
}
WL_EXPORT void
+weston_seat_release_touch(struct weston_seat *seat)
+{
+ seat->touch_device_count--;
+ if (seat->touch_device_count == 0) {
+ seat_send_updated_caps(seat);
+ }
+}
+
+WL_EXPORT void
weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,
const char *seat_name)
{