| @@ -375,15 +375,25 @@ static void · 374 unmodified lines |
| 375 | seat_handle_capabilities(void *data, struct wl_seat *seat, uint32_t capabilities) | 375 | seat_handle_capabilities(void *data, struct wl_seat *seat, uint32_t capabilities) |
| 376 | { | 376 | { |
| 377 | Wlwin *wl; | 377 | Wlwin *wl; |
| | 378 | int pointer, keyboard; |
| 378 | | 379 | |
| 379 | wl = data; | 380 | wl = data; |
| 380 | if(capabilities & WL_SEAT_CAPABILITY_POINTER) { | 381 | pointer = capabilities & WL_SEAT_CAPABILITY_POINTER; |
| | 382 | if(pointer && wl->pointer == nil){ |
| 381 | wl->pointer = wl_seat_get_pointer(seat); | 383 | wl->pointer = wl_seat_get_pointer(seat); |
| 382 | wl_pointer_add_listener(wl->pointer, &pointer_listener, wl); | 384 | wl_pointer_add_listener(wl->pointer, &pointer_listener, wl); |
| | 385 | }else if(!pointer && wl->pointer != nil){ |
| | 386 | wl_pointer_release(wl->pointer); |
| | 387 | wl->pointer = nil; |
| 383 | } | 388 | } |
| 384 | if(capabilities & WL_SEAT_CAPABILITY_KEYBOARD) { | 389 | |
| 385 | struct wl_keyboard *keyboard = wl_seat_get_keyboard(seat); | 390 | keyboard = capabilities & WL_SEAT_CAPABILITY_KEYBOARD; |
| 386 | wl_keyboard_add_listener(keyboard, &keyboard_listener, wl); | 391 | if(keyboard && wl->keyboard == nil){ |
| | 392 | wl->keyboard = wl_seat_get_keyboard(seat); |
| | 393 | wl_keyboard_add_listener(wl->keyboard, &keyboard_listener, wl); |
| | 394 | }else if(!keyboard && wl->keyboard != nil){ |
| | 395 | wl_keyboard_release(wl->keyboard); |
| | 396 | wl->keyboard = nil; |
| 387 | } | 397 | } |
| 388 | } | 398 | } |
| 389 | | 399 | |