static void seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps) { struct display *d = data; if ((caps & WL_SEAT_CAPABILITY_POINTER) && !d->pointer) { d->pointer = wl_seat_get_pointer(seat); wl_pointer_add_listener(d->pointer, &pointer_listener, d); } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && d->pointer) { wl_pointer_destroy(d->pointer); d->pointer = NULL; } if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !d->keyboard) { d->keyboard = wl_seat_get_keyboard(seat); wl_keyboard_add_listener(d->keyboard, &keyboard_listener, d); } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && d->keyboard) { wl_keyboard_destroy(d->keyboard); d->keyboard = NULL; } if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !d->touch) { d->touch = wl_seat_get_touch(seat); wl_touch_set_user_data(d->touch, d); wl_touch_add_listener(d->touch, &touch_listener, d); } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && d->touch) { wl_touch_destroy(d->touch); d->touch = NULL; } }
static void _ecore_wl_input_seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps) { Ecore_Wl_Input *input; if (!(input = data)) return; LOGFN(__FILE__, __LINE__, __FUNCTION__); 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); if (!input->cursor_surface) { input->cursor_surface = wl_compositor_create_surface(_ecore_wl_disp->wl.compositor); } } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && (input->pointer)) { if (input->cursor_surface) wl_surface_destroy(input->cursor_surface); input->cursor_surface = NULL; 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; } if ((caps & WL_SEAT_CAPABILITY_TOUCH) && (!input->touch)) { input->touch = wl_seat_get_touch(seat); wl_touch_set_user_data(input->touch, input); wl_touch_add_listener(input->touch, &touch_listener, input); } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && (input->touch)) { wl_touch_destroy(input->touch); input->touch = NULL; } }
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; } }
void WLContext::SeatHandleCapabilities(void* data, struct wl_seat* seat, uint32_t caps) { struct WLContext::seat_data* context = static_cast<struct WLContext::seat_data*>(data); assert(context); if ((caps & WL_SEAT_CAPABILITY_POINTER) && !context->wlPointer){ context->wlPointer = wl_seat_get_pointer(seat); wl_pointer_set_user_data(context->wlPointer, data); wl_pointer_add_listener(context->wlPointer, context->ctx->GetWLPointerListener(), data); } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && context->wlPointer){ wl_pointer_destroy(context->wlPointer); context->wlPointer = NULL; } if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !context->wlKeyboard){ context->wlKeyboard = wl_seat_get_keyboard(seat); wl_keyboard_set_user_data(context->wlKeyboard, data); wl_keyboard_add_listener(context->wlKeyboard, context->ctx->GetWLKeyboardListener(), data); } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && context->wlKeyboard){ wl_keyboard_destroy(context->wlKeyboard); context->wlKeyboard = NULL; } if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !context->wlTouch){ context->wlTouch = wl_seat_get_touch(seat); wl_touch_set_user_data(context->wlTouch, data); wl_touch_add_listener(context->wlTouch, context->ctx->GetWLTouchListener(), data); } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && context->wlTouch){ wl_touch_destroy(context->wlTouch); context->wlTouch = NULL; } wl_display_dispatch(context->ctx->GetWLDisplay()); }