mirror of
https://github.com/swaywm/sway.git
synced 2024-11-25 17:31:28 +00:00
swaynag: fix pointer management
Currently on master, swaynag will retrieve a pointer instance whenever the capabilities change and WL_SEAT_CAPBILITY_POINTER is set. The pointer instances were never being destroyed so swaynag received events multiple times due to having several instances of the pointer. This fixes it so if there is already a pointer instance, swaynag does not attempt to retrieve another. Additionally, if the pointer capability is removed, the pointer instance is destroyed.
This commit is contained in:
parent
69a1a0ff99
commit
8c69da11bb
|
@ -239,10 +239,14 @@ static struct wl_pointer_listener pointer_listener = {
|
||||||
static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
|
static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
|
||||||
enum wl_seat_capability caps) {
|
enum wl_seat_capability caps) {
|
||||||
struct swaynag *swaynag = data;
|
struct swaynag *swaynag = data;
|
||||||
if ((caps & WL_SEAT_CAPABILITY_POINTER)) {
|
bool cap_pointer = caps & WL_SEAT_CAPABILITY_POINTER;
|
||||||
|
if (cap_pointer && !swaynag->pointer.pointer) {
|
||||||
swaynag->pointer.pointer = wl_seat_get_pointer(wl_seat);
|
swaynag->pointer.pointer = wl_seat_get_pointer(wl_seat);
|
||||||
wl_pointer_add_listener(swaynag->pointer.pointer, &pointer_listener,
|
wl_pointer_add_listener(swaynag->pointer.pointer, &pointer_listener,
|
||||||
swaynag);
|
swaynag);
|
||||||
|
} else if (!cap_pointer && swaynag->pointer.pointer) {
|
||||||
|
wl_pointer_destroy(swaynag->pointer.pointer);
|
||||||
|
swaynag->pointer.pointer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue