aboutsummaryrefslogtreecommitdiffstats
path: root/tests/proxy-test.c
Commit message (Collapse)AuthorAgeFilesLines
* client: Add method to get display for a given proxyDavid Edmundson2023-08-071-0/+2
| | | | | | | | This can be useful for additional validation purposes when handling proxies. This is similar to existing server side API wl_global_get_display. Signed-off-by: David Edmundson <david@davidedmundson.co.uk>
* tests: fix memory leak in proxy-testSimon Ser2020-01-281-0/+1
| | | | | | | | | | | | | | | | | | | | | When running tests with ASan, proxy-test fails at the proxy_tag test: ==27843==ERROR: LeakSanitizer: detected memory leaks Direct leak of 32 byte(s) in 1 object(s) allocated from: #0 0x7f65a732dada in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:144 #1 0x7f65a71cb3ea in wl_display_add_protocol_logger src/wayland-server.c:1813 #2 0x557c640c0980 in proxy_tag tests/proxy-test.c:104 #3 0x557c640c1159 in run_test tests/test-runner.c:153 #4 0x557c640c1e2e in main tests/test-runner.c:337 #5 0x7f65a6ea0ee2 in __libc_start_main (/usr/lib/libc.so.6+0x26ee2) SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s). Destroying the logger fixes the leak. Signed-off-by: Simon Ser <contact@emersion.fr> Fixes: 493ab79bd2cd ("proxy: Add API to tag proxy objects")
* proxy: Add API to tag proxy objectsJonas Ådahl2019-07-291-0/+136
When an application and a toolkit share the same Wayland connection, it will receive events with each others objects. For example if the toolkit manages a set of surfaces, and the application another set, if both the toolkit and application listen to pointer focus events, they'll receive focus events for each others surfaces. In order for the toolkit and application layers to identify whether a surface is managed by itself or not, it cannot only rely on retrieving the proxy user data, without going through all it's own proxy objects finding whether it's one of them. By adding the ability to "tag" a proxy object, the toolkit and application can use the tag to identify what the user data pointer points to something known. To create a tag, the recommended way is to define a statically allocated constant char array containing some descriptive string. The tag will be the pointer to the non-const pointer to the beginning of the array. For example, to identify whether a focus event is for a surface managed by the code in question: static const char *my_tag = "my tag"; static void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { struct window *window; const char * const *tag; tag = wl_proxy_get_tag((struct wl_proxy *) surface); if (tag != &my_tag) return; window = wl_surface_get_user_data(surface); ... } ... static void init_window_surface(struct window *window) { struct wl_surface *surface; surface = wl_compositor_create_surface(compositor); wl_surface_set_user_data(surface, window); wl_proxy_set_tag((struct wl_proxy *) surface, &my_tag); } Signed-off-by: Jonas Ådahl <jadahl@gmail.com>