xwayland: Split up device class init/release into functions

Put device class initialization in init_[device_class](xwl_seat) and
releasing in release_[device class](xwl_seat). The purpose is to make
it easier to add more type of initialization here later, without making
the function too large.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Jonas Ådahl 2016-09-13 15:17:00 +08:00 committed by Adam Jackson
parent 9037ba736a
commit a77d0715c6

View File

@ -768,14 +768,9 @@ add_device(struct xwl_seat *xwl_seat,
}
static void
seat_handle_capabilities(void *data, struct wl_seat *seat,
enum wl_seat_capability caps)
init_pointer(struct xwl_seat *xwl_seat)
{
struct xwl_seat *xwl_seat = data;
DeviceIntPtr master;
if (caps & WL_SEAT_CAPABILITY_POINTER && xwl_seat->wl_pointer == NULL) {
xwl_seat->wl_pointer = wl_seat_get_pointer(seat);
xwl_seat->wl_pointer = wl_seat_get_pointer(xwl_seat->seat);
wl_pointer_add_listener(xwl_seat->wl_pointer,
&pointer_listener, xwl_seat);
@ -786,16 +781,24 @@ seat_handle_capabilities(void *data, struct wl_seat *seat,
ActivateDevice(xwl_seat->pointer, TRUE);
}
EnableDevice(xwl_seat->pointer, TRUE);
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && xwl_seat->wl_pointer) {
}
static void
release_pointer(struct xwl_seat *xwl_seat)
{
wl_pointer_release(xwl_seat->wl_pointer);
xwl_seat->wl_pointer = NULL;
if (xwl_seat->pointer)
DisableDevice(xwl_seat->pointer, TRUE);
}
}
if (caps & WL_SEAT_CAPABILITY_KEYBOARD && xwl_seat->wl_keyboard == NULL) {
xwl_seat->wl_keyboard = wl_seat_get_keyboard(seat);
static void
init_keyboard(struct xwl_seat *xwl_seat)
{
DeviceIntPtr master;
xwl_seat->wl_keyboard = wl_seat_get_keyboard(xwl_seat->seat);
wl_keyboard_add_listener(xwl_seat->wl_keyboard,
&keyboard_listener, xwl_seat);
@ -809,7 +812,11 @@ seat_handle_capabilities(void *data, struct wl_seat *seat,
master = GetMaster(xwl_seat->keyboard, MASTER_KEYBOARD);
if (master)
master->key->xkbInfo->checkRepeat = keyboard_check_repeat;
} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && xwl_seat->wl_keyboard) {
}
static void
release_keyboard(struct xwl_seat *xwl_seat)
{
wl_keyboard_release(xwl_seat->wl_keyboard);
xwl_seat->wl_keyboard = NULL;
@ -817,10 +824,12 @@ seat_handle_capabilities(void *data, struct wl_seat *seat,
remove_sync_pending(xwl_seat->keyboard);
DisableDevice(xwl_seat->keyboard, TRUE);
}
}
}
if (caps & WL_SEAT_CAPABILITY_TOUCH && xwl_seat->wl_touch == NULL) {
xwl_seat->wl_touch = wl_seat_get_touch(seat);
static void
init_touch(struct xwl_seat *xwl_seat)
{
xwl_seat->wl_touch = wl_seat_get_touch(xwl_seat->seat);
wl_touch_add_listener(xwl_seat->wl_touch,
&touch_listener, xwl_seat);
@ -830,12 +839,40 @@ seat_handle_capabilities(void *data, struct wl_seat *seat,
xwl_seat->touch =
add_device(xwl_seat, "xwayland-touch", xwl_touch_proc);
}
} else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && xwl_seat->wl_touch) {
}
static void
release_touch(struct xwl_seat *xwl_seat)
{
wl_touch_release(xwl_seat->wl_touch);
xwl_seat->wl_touch = NULL;
if (xwl_seat->touch)
DisableDevice(xwl_seat->touch, TRUE);
}
static void
seat_handle_capabilities(void *data, struct wl_seat *seat,
enum wl_seat_capability caps)
{
struct xwl_seat *xwl_seat = data;
if (caps & WL_SEAT_CAPABILITY_POINTER && xwl_seat->wl_pointer == NULL) {
init_pointer(xwl_seat);
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && xwl_seat->wl_pointer) {
release_pointer(xwl_seat);
}
if (caps & WL_SEAT_CAPABILITY_KEYBOARD && xwl_seat->wl_keyboard == NULL) {
init_keyboard(xwl_seat);
} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && xwl_seat->wl_keyboard) {
release_keyboard(xwl_seat);
}
if (caps & WL_SEAT_CAPABILITY_TOUCH && xwl_seat->wl_touch == NULL) {
init_touch(xwl_seat);
} else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && xwl_seat->wl_touch) {
release_touch(xwl_seat);
}
xwl_seat->xwl_screen->expecting_event--;