[PATCH 1/2] clipboard: add seat destroy signal handler

Rafal Mielniczuk rafal.mielniczuk2 at gmail.com
Wed Jul 11 09:48:12 PDT 2012


---
 src/clipboard.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/clipboard.c b/src/clipboard.c
index 22d4b26..689e563 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -243,6 +243,17 @@ clipboard_set_selection(struct wl_listener *listener, void *data)
 		return;
 }
 
+static void
+clipboard_destroy(struct wl_listener *listener, void *data)
+{
+	struct clipboard *clipboard =
+		container_of(listener, struct clipboard, destroy_listener);
+
+	wl_list_remove(&clipboard->selection_listener.link);
+
+	free(clipboard);
+}
+
 struct clipboard *
 clipboard_create(struct weston_seat *seat)
 {
@@ -255,9 +266,12 @@ clipboard_create(struct weston_seat *seat)
 
 	clipboard->seat = seat;
 	clipboard->selection_listener.notify = clipboard_set_selection;
+	clipboard->destroy_listener.notify = clipboard_destroy;
 
 	wl_signal_add(&seat->seat.selection_signal,
 		      &clipboard->selection_listener);
+	wl_signal_add(&seat->seat.destroy_signal,
+		      &clipboard->destroy_listener);
 
 	return clipboard;
 }
-- 
1.7.11.1



More information about the wayland-devel mailing list