aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Ashworth <bosrsf04@gmail.com>2019-04-14 01:06:09 -0400
committerSimon Ser <contact@emersion.fr>2019-04-14 10:24:19 +0300
commit8c69da11bbe70caa2f5db1665e9d60387604c5e4 (patch)
tree3aa7bc628c8c3121ecff718b21faf49bf55cd9bb
parent69a1a0ff99171f15c7842bfde23ed90f09a37256 (diff)
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.
-rw-r--r--swaynag/swaynag.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c
index f0c6a3c5..eb31da57 100644
--- a/swaynag/swaynag.c
+++ b/swaynag/swaynag.c
@@ -239,10 +239,14 @@ static struct wl_pointer_listener pointer_listener = {
static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
enum wl_seat_capability caps) {
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);
wl_pointer_add_listener(swaynag->pointer.pointer, &pointer_listener,
swaynag);
+ } else if (!cap_pointer && swaynag->pointer.pointer) {
+ wl_pointer_destroy(swaynag->pointer.pointer);
+ swaynag->pointer.pointer = NULL;
}
}