| 625 | }; |
| 626 | |
| 627 | static void seat_handle_capabilities(void *data, wl_seat *seat, uint32_t caps) { |
| 628 | // Subscribe to pointer events |
| 629 | Demo &demo = *static_cast<Demo *>(data); |
| 630 | if ((caps & WL_SEAT_CAPABILITY_POINTER) && !demo.pointer) { |
| 631 | demo.pointer = wl_seat_get_pointer(seat); |
| 632 | wl_pointer_add_listener(demo.pointer, &pointer_listener, &demo); |
| 633 | } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && demo.pointer) { |
| 634 | wl_pointer_destroy(demo.pointer); |
| 635 | demo.pointer = nullptr; |
| 636 | } |
| 637 | // Subscribe to keyboard events |
| 638 | if (caps & WL_SEAT_CAPABILITY_KEYBOARD) { |
| 639 | demo.keyboard = wl_seat_get_keyboard(seat); |
| 640 | wl_keyboard_add_listener(demo.keyboard, &keyboard_listener, &demo); |
| 641 | } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && demo.keyboard) { |
| 642 | wl_keyboard_destroy(demo.keyboard); |
| 643 | demo.keyboard = nullptr; |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | static const wl_seat_listener seat_listener = { |
| 648 | seat_handle_capabilities, |
nothing calls this directly
no outgoing calls
no test coverage detected