Unified · Split
| @@ -375,15 +375,25 @@ static void · 374 unmodified lines | ||
| 375 | 375 | seat_handle_capabilities(void *data, struct wl_seat *seat, uint32_t capabilities) |
| 376 | 376 | { |
| 377 | 377 | Wlwin *wl; |
| 378 | + int pointer, keyboard; | |
| 378 | 379 | |
| 379 | 380 | wl = data; |
| 380 | − if(capabilities & WL_SEAT_CAPABILITY_POINTER) { | |
| 381 | + pointer = capabilities & WL_SEAT_CAPABILITY_POINTER; | |
| 382 | + if(pointer && wl->pointer == nil){ | |
| 381 | 383 | wl->pointer = wl_seat_get_pointer(seat); |
| 382 | 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) { | |
| 385 | − struct wl_keyboard *keyboard = wl_seat_get_keyboard(seat); | |
| 386 | − wl_keyboard_add_listener(keyboard, &keyboard_listener, wl); | |
| 389 | + | |
| 390 | + keyboard = capabilities & WL_SEAT_CAPABILITY_KEYBOARD; | |
| 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 | |
| @@ -63,6 +63,7 @@ struct Wlwin { · 62 unmodified lines | ||
| 63 | 63 | struct wl_data_device_manager *data_device_manager; |
| 64 | 64 | struct wl_data_device *data_device; |
| 65 | 65 | struct wl_pointer *pointer; |
| 66 | + struct wl_keyboard *keyboard; | |
| 66 | 67 | /* Keyboard state */ |
| 67 | 68 | struct xkb_state *xkb_state; |
| 68 | 69 | struct xkb_context *xkb_context; |