commit 85150be

Michael Forney  ·  2013-06-14 03:35:05 +0000 UTC
parent 06e5a78
Add swc_find_resource_for_client
2 files changed,  +25, -0
M util.c
M util.h
M util.c
+22, -0
 1@@ -1,6 +1,7 @@
 2 #include "util.h"
 3 
 4 #include <stdlib.h>
 5+#include <stdio.h>
 6 
 7 void swc_unbind_resource(struct wl_resource * resource)
 8 {
 9@@ -8,3 +9,24 @@ void swc_unbind_resource(struct wl_resource * resource)
10     free(resource);
11 }
12 
13+struct wl_resource * swc_find_resource_for_client(struct wl_list * resources,
14+                                                  struct wl_client * client)
15+{
16+    struct wl_resource * resource;
17+
18+    printf("looking for client %p\n", client);
19+
20+    wl_list_for_each(resource, resources, link)
21+    {
22+        if (wl_resource_get_client(resource) == client)
23+        {
24+            printf("found client\n");
25+            return resource;
26+        }
27+    }
28+
29+    printf("couldn't find resource\n");
30+
31+    return NULL;
32+}
33+
M util.h
+3, -0
1@@ -16,5 +16,8 @@ void swc_client_add_object(struct wl_clientstruct wl_resource * resource, );
2 
3 void swc_unbind_resource(struct wl_resource * resource);
4 
5+struct wl_resource * swc_find_resource_for_client(struct wl_list * resources,
6+                                                  struct wl_client * client);
7+
8 #endif
9