History

wayland: release pointer/keyboard on seat capabilities change

Sigrid Solveig Haflínudóttir committed 4 years ago

Commit bab0c791 parent 44f57782 files · +15 −4Browse files

Unified · Split

2 files
  1. gui-wl/wl-cb.c +14 −4
  2. gui-wl/wl-inc.h +1 −0
gui-wl/wl-cb.c+14−4
@@ -375,15 +375,25 @@ static void · 374 unmodified lines
375375 seat_handle_capabilities(void *data, struct wl_seat *seat, uint32_t capabilities)
376376 {
377377 Wlwin *wl;
378+ int pointer, keyboard;
378379
379380 wl = data;
380− if(capabilities & WL_SEAT_CAPABILITY_POINTER) {
381+ pointer = capabilities & WL_SEAT_CAPABILITY_POINTER;
382+ if(pointer && wl->pointer == nil){
381383 wl->pointer = wl_seat_get_pointer(seat);
382384 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;
383388 }
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;
387397 }
388398 }
389399
gui-wl/wl-inc.h+1−0
@@ -63,6 +63,7 @@ struct Wlwin { · 62 unmodified lines
6363 struct wl_data_device_manager *data_device_manager;
6464 struct wl_data_device *data_device;
6565 struct wl_pointer *pointer;
66+ struct wl_keyboard *keyboard;
6667 /* Keyboard state */
6768 struct xkb_state *xkb_state;
6869 struct xkb_context *xkb_context;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t